/* ═══════════════════════════════════════════════════════════════
   VerdeSeg — Design System
   Paleta Corporativa Azul/Verde | v2.0
   ═══════════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* ── CSS Variables ─────────────────────────────────────────────── */
:root {
  /* ── Brand VerdeSeg ── */
  --primary:         #063F6C;   /* Azul Corporativo */
  --primary-hover:   #0D5A96;   /* Hover Azul */
  --secondary:       #05C242;   /* Verde Corporativo */
  --secondary-hover: #049B35;   /* Hover Verde */
  --accent:          #0A7A7A;   /* Azul Petróleo */

  /* ── Interface ── */
  --bg-main:    #F5F7FA;
  --bg-card:    #FFFFFF;
  --bg-input:   #F8FAFC;
  --header-bg:  #063F6C;

  /* ── Sidebar ── */
  --sidebar-bg:        #052E4D;
  --sidebar-active-bg: rgba(255,255,255,0.16);
  --sidebar-hover-bg:  rgba(255,255,255,0.09);
  --sidebar-text:      rgba(255,255,255,0.80);
  --sidebar-text-act:  #ffffff;
  --sidebar-width:     235px;
  --sidebar-collapsed: 64px;

  /* ── Text ── */
  --text-primary:   #1F2937;
  --text-secondary: #6B7280;
  --text-muted:     #9CA3AF;

  /* ── Border / Shadow ── */
  --border:    #DDE3EA;
  --shadow-sm: 0 1px 4px rgba(6,63,108,0.07);
  --shadow-md: 0 4px 16px rgba(6,63,108,0.11);
  --shadow-lg: 0 8px 32px rgba(6,63,108,0.16);

  /* ── Semantic ── */
  --red:         #DC3545;
  --red-light:   #FDECEA;
  --green:       #05C242;
  --green-light: #EAF8F0;
  --orange:      #FFC107;
  --orange-light:#FFF8E1;

  /* ── KPI Status ── */
  --status-excellent: #05C242;
  --status-good:      #28A745;
  --status-warning:   #FFC107;
  --status-critical:  #DC3545;
  --status-none:      #ADB5BD;

  /* ── Heatmap Scale ── */
  --heat-very-low: #EAF8F0;
  --heat-low:      #B7EBCB;
  --heat-medium:   #7DDBA4;
  --heat-high:     #36C66E;
  --heat-very-high:#05C242;

  /* ── Chart Colors ── */
  --chart-1: #063F6C;
  --chart-2: #05C242;
  --chart-3: #0A7A7A;
  --chart-4: #2E86DE;
  --chart-5: #00B894;
  --chart-6: #74B9FF;
  --chart-7: #55EFC4;
  --chart-8: #34495E;

  /* ── Radius ── */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;

  /* ── Animation ── */
  --transition: 0.2s ease;
}

/* ── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  overflow: hidden;
}

/* ══════════════════════════════════════════════════════════════
   SIDEBAR
   ══════════════════════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: width var(--transition);
  overflow: hidden;
  box-shadow: 2px 0 16px rgba(6,63,108,0.18);
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }

/* Logo / brand */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 14px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
  min-height: 68px;
  text-decoration: none;
}
.sidebar-logo .logo-icon {
  width: 36px; height: 36px;
  background: rgba(255,255,255,0.12);
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.sidebar-logo .logo-icon img {
  width: 100%; height: 100%;
  object-fit: contain;
  filter: brightness(0) invert(1);
}
.sidebar-logo .logo-icon svg { width: 20px; height: 20px; }
.sidebar-logo .logo-text { overflow: hidden; white-space: nowrap; }
.sidebar-logo .logo-text strong {
  display: block;
  color: #fff;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.2px;
}
.sidebar-logo .logo-text span {
  display: block;
  color: rgba(255,255,255,0.55);
  font-size: 0.7rem;
  font-weight: 400;
}

/* Unit switcher badge in sidebar */
.sidebar-unit-badge {
  margin: 10px 10px 0;
  padding: 8px 12px;
  background: rgba(5,194,66,0.12);
  border: 1px solid rgba(5,194,66,0.22);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: background var(--transition);
  text-decoration: none;
}
.sidebar-unit-badge:hover { background: rgba(5,194,66,0.20); }
.sidebar-unit-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--secondary);
  flex-shrink: 0;
  animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%,100% { opacity:1; transform:scale(1); }
  50% { opacity:0.5; transform:scale(1.4); }
}
.sidebar-unit-name {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Nav */
.sidebar-nav { flex: 1; padding: 10px 8px; overflow-y: auto; overflow-x: hidden; }
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 3px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--sidebar-hover-bg); color: #fff; }
.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-text-act);
  font-weight: 600;
  border-left: 3px solid var(--secondary);
}
.nav-item .nav-icon { width: 20px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.nav-item .nav-label { overflow: hidden; }

.sidebar-footer {
  padding: 8px;
  border-top: 1px solid rgba(255,255,255,0.10);
}
.sidebar-footer .nav-item { margin-bottom: 0; }

/* Collapse toggle */
.sidebar-toggle {
  padding: 10px 0;
  border-top: 1px solid rgba(255,255,255,0.10);
  display: flex; align-items: center; justify-content: center;
}
.sidebar-toggle button {
  background: rgba(255,255,255,0.08);
  border: none; color: #fff;
  width: 34px; height: 34px;
  border-radius: var(--r-md);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
}
.sidebar-toggle button:hover { background: rgba(255,255,255,0.18); }
.mobile-menu-toggle,
.mobile-menu-backdrop { display: none; }

/* ══════════════════════════════════════════════════════════════
   MAIN CONTENT
   ══════════════════════════════════════════════════════════════ */
.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
  overflow-y: auto;
  height: 100vh;
}
.main-wrapper.sidebar-collapsed { margin-left: var(--sidebar-collapsed); }

/* Top bar */
.topbar {
  background: var(--header-bg);
  padding: 0 28px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0; z-index: 50;
  box-shadow: 0 2px 12px rgba(6,63,108,0.20);
}
.topbar-left h1 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
}
.topbar-left p {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.65);
  margin-top: 1px;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
.topbar-brand-logo {
  height: 36px; width: auto;
  object-fit: contain;
  filter: brightness(0) invert(1);
  opacity: 0.9;
}

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px;
  border-radius: var(--r-md);
  font-family: inherit;
  font-size: 0.85rem; font-weight: 600;
  cursor: pointer; border: none;
  transition: all var(--transition);
  text-decoration: none; white-space: nowrap;
}
.btn-primary { background: var(--secondary); color: #fff; }
.btn-primary:hover { background: var(--secondary-hover); box-shadow: 0 4px 12px rgba(5,194,66,0.30); }
.btn-secondary { background: var(--primary); color: #fff; }
.btn-secondary:hover { background: var(--primary-hover); box-shadow: 0 4px 12px rgba(6,63,108,0.30); }
.btn-danger  { background: var(--red); color: #fff; }
.btn-danger:hover  { background: #B02A37; box-shadow: 0 4px 12px rgba(220,53,69,0.30); }
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-primary);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: rgba(6,63,108,0.05); }
.btn-ghost { background: transparent; color: var(--text-secondary); padding: 8px 12px; }
.btn-ghost:hover { background: var(--bg-main); color: var(--text-primary); }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-icon { padding: 8px; border-radius: var(--r-md); }

/* ── Cards ─────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  padding: 16px 22px 14px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h2 { font-size: 0.95rem; font-weight: 700; color: var(--text-primary); }
.card-body { padding: 20px 22px; }

/* ── Forms ─────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label {
  font-size: 0.78rem; font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.4px;
}
.form-label .required { color: var(--red); }
.form-control {
  width: 100%; padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  font-family: inherit; font-size: 0.9rem;
  color: var(--text-primary);
  background: var(--bg-input);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none; appearance: none;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(6,63,108,0.10);
  background: #fff;
}
.form-control::placeholder { color: var(--text-muted); }
select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236B7280' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
  cursor: pointer;
}

/* Sector select with add button */
.select-with-action { position: relative; display: flex; gap: 8px; align-items: stretch; }
.select-with-action select { flex: 1; }
.select-with-action .btn-add-sector {
  flex-shrink: 0;
  padding: 10px 14px;
  background: rgba(6,63,108,0.06);
  border: 1.5px solid rgba(6,63,108,0.18);
  color: var(--primary);
  border-radius: var(--r-md);
  font-size: 1.2rem;
  cursor: pointer;
  transition: all var(--transition);
  display: flex; align-items: center; justify-content: center;
  font-family: inherit; font-weight: 600; line-height: 1;
}
.select-with-action .btn-add-sector:hover {
  background: var(--primary); color: #fff; border-color: var(--primary);
}

/* ── Grid layout ───────────────────────────────────────────────── */
.page-content { padding: 24px 28px; max-width: 100%; width: 100%; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-grid .full { grid-column: 1 / -1; }

/* ── Severity badges ───────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem; font-weight: 600;
}
.badge-leve       { background: var(--green-light); color: var(--status-good); }
.badge-moderado   { background: var(--orange-light); color: #856404; }
.badge-grave      { background: #FDE8D0; color: #B35000; }
.badge-gravissimo { background: var(--red-light); color: var(--red); }

/* ══════════════════════════════════════════════════════════════
   MAP LOCATION SELECTOR
   ══════════════════════════════════════════════════════════════ */
.location-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border: 1.5px dashed var(--primary);
  border-radius: var(--r-md);
  background: rgba(6,63,108,0.04);
  color: var(--primary);
  font-family: inherit; font-size: 0.9rem; font-weight: 500;
  cursor: pointer; width: 100%;
  transition: all var(--transition);
}
.location-btn:hover { background: rgba(6,63,108,0.08); border-color: var(--primary-hover); box-shadow: var(--shadow-md); }
.location-btn.selected {
  background: rgba(6,63,108,0.08);
  border: 1.5px solid var(--primary);
  color: var(--primary); font-weight: 600;
}
.location-btn svg { flex-shrink: 0; }

/* ── Modal ─────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(5,46,77,0.88);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: none; align-items: center; justify-content: center;
  padding: 20px;
  transition: opacity 0.25s ease;
}
.modal-overlay.open { display: flex; opacity: 1; }

.modal {
  background: var(--bg-card);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 900px;
  max-height: 85vh;
  display: flex; flex-direction: column;
  transform: translateY(20px) scale(0.97);
  transition: transform 0.25s ease;
  overflow: hidden;
}
.modal-overlay.open .modal { transform: translateY(0) scale(1); }

.modal-header {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; justify-content: space-between;
  flex-shrink: 0;
  background: var(--bg-main);
}
.modal-header h3 { font-size: 1rem; font-weight: 700; color: var(--text-primary); display: flex; align-items: center; gap: 8px; }
.modal-header p  { font-size: 0.78rem; color: var(--text-secondary); margin-top: 3px; }
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 4px; border-radius: var(--r-sm);
  transition: color var(--transition), background var(--transition);
  display: flex;
}
.modal-close:hover { color: var(--red); background: var(--red-light); }
.modal-body { padding: 16px 22px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 12px 22px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  flex-shrink: 0;
}

/* ── Warehouse map ─────────────────────────────────────────────── */
.map-container {
  position: relative; border-radius: var(--r-md);
  overflow: hidden; border: 1px solid var(--border);
  background: #1A2B3C; user-select: none;
}
.map-container img { width: 100%; height: auto; display: block; pointer-events: none; }
.map-overlay { position: absolute; inset: 0; pointer-events: all; }

.map-zone {
  position: absolute;
  border: 2px solid rgba(255,255,255,0.5);
  border-radius: 4px; cursor: pointer; opacity: 0.35;
  transition: opacity 0.2s, transform 0.15s;
  display: flex; align-items: center; justify-content: center;
}
.map-zone:hover { opacity: 0.65; transform: scale(1.02); }
.map-zone.selected {
  opacity: 0.80;
  border: 2.5px solid #fff;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.4), 0 0 20px rgba(5,194,66,0.5);
  z-index: 5;
}
.map-zone-label {
  color: #fff; font-size: 0.65rem; font-weight: 700;
  text-align: center; text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  pointer-events: none; padding: 2px 4px; line-height: 1.2;
}

.zone-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.zone-chip {
  padding: 5px 12px; border-radius: 20px;
  font-size: 0.75rem; font-weight: 600;
  border: 1.5px solid var(--border);
  background: var(--bg-main); color: var(--text-secondary);
  cursor: pointer; transition: all var(--transition);
}
.zone-chip:hover { border-color: var(--primary); color: var(--primary); background: rgba(6,63,108,0.05); }
.zone-chip.active {
  background: var(--primary); color: #fff; border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(6,63,108,0.25);
}

/* ══════════════════════════════════════════════════════════════
   MAP UPLOAD (novo mapa base)
   ══════════════════════════════════════════════════════════════ */
.map-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--r-lg);
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg-main);
}
.map-upload-area:hover {
  border-color: var(--secondary);
  background: rgba(5,194,66,0.04);
}
.map-upload-area.dragover {
  border-color: var(--secondary);
  background: rgba(5,194,66,0.08);
  transform: scale(1.01);
}
.map-upload-icon {
  width: 52px; height: 52px; border-radius: 14px;
  background: rgba(5,194,66,0.10);
  color: var(--secondary-hover);
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
}
.map-upload-label { font-size: 0.9rem; font-weight: 600; color: var(--text-primary); }
.map-upload-hint  { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }
.map-preview-wrap {
  position: relative;
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--border);
  margin-top: 12px;
}
.map-preview-wrap img { width: 100%; height: auto; display: block; max-height: 220px; object-fit: contain; background: #1A2B3C; }
.map-preview-remove {
  position: absolute; top: 8px; right: 8px;
  background: rgba(220,53,69,0.85); color: #fff;
  border: none; border-radius: 50%; width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 1rem; font-weight: 700;
  transition: background 0.2s;
}
.map-preview-remove:hover { background: var(--red); }

/* ══════════════════════════════════════════════════════════════
   MAP CONFIG MODE
   ══════════════════════════════════════════════════════════════ */
.config-toolbar { display: flex; align-items: center; gap: 10px; padding: 12px 0; flex-wrap: wrap; }
.drawing-rect {
  position: absolute;
  border: 2px dashed var(--secondary);
  background: rgba(5,194,66,0.18);
  pointer-events: none; z-index: 20; border-radius: 4px;
}
.zone-config-list { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.zone-config-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--bg-main);
  border-radius: var(--r-md); border: 1px solid var(--border);
}
.zone-color-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.zone-config-item input {
  flex: 1; font-family: inherit; font-size: 0.85rem;
  border: none; background: transparent; color: var(--text-primary); outline: none; font-weight: 500;
}
.zone-config-item input:focus { color: var(--primary); }
.zone-config-item .btn-del {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 4px; border-radius: var(--r-sm);
  display: flex; transition: color var(--transition), background var(--transition);
}
.zone-config-item .btn-del:hover { color: var(--red); background: var(--red-light); }

.drawing-hint {
  position: absolute; top: 20px; left: 50%; transform: translateX(-50%);
  background: rgba(5,46,77,0.88);
  color: #fff; padding: 8px 16px; border-radius: 30px;
  font-size: 0.85rem; font-weight: 600; z-index: 1100;
  pointer-events: none; display: flex; align-items: center; gap: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  opacity: 0; transition: opacity 0.3s ease, transform 0.3s ease;
}
.drawing-hint.active { opacity: 1; transform: translateX(-50%) translateY(10px); }

.zone-detail-card {
  background: #fff; border-radius: var(--r-lg); padding: 20px;
  width: 100%; max-width: 320px;
  box-shadow: var(--shadow-lg); border: 1px solid var(--border);
}
.color-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 12px; }
.color-option {
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; transition: all var(--transition);
  display: flex; align-items: center; justify-content: center;
}
.color-option:hover { transform: scale(1.1); }
.color-option.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px rgba(6,63,108,0.20);
}
.color-option svg { color: #fff; opacity: 0; transition: opacity 0.2s; }
.color-option.selected svg { opacity: 1; }
body.is-drawing .modal-overlay#mapConfigModal { display: none !important; }
body.is-drawing .modal-overlay#mapModal { display: flex !important; opacity: 1; }

/* ══════════════════════════════════════════════════════════════
   SECTOR MODAL
   ══════════════════════════════════════════════════════════════ */
.sector-list { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.sector-list-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-main); border-radius: var(--r-md); border: 1px solid var(--border);
  font-size: 0.88rem; font-weight: 500;
}
.sector-list-item .btn-del {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 4px; border-radius: var(--r-sm);
  display: flex; transition: color var(--transition), background var(--transition);
}
.sector-list-item .btn-del:hover { color: var(--red); background: var(--red-light); }

/* ══════════════════════════════════════════════════════════════
   ALERTS / TOAST
   ══════════════════════════════════════════════════════════════ */
.toast-container {
  position: fixed; top: 20px; right: 20px;
  z-index: 9999; display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 12px 18px; border-radius: var(--r-md);
  font-size: 0.88rem; font-weight: 500; color: #fff;
  display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow-lg); animation: slideIn 0.3s ease;
  min-width: 280px;
}
.toast-success { background: var(--secondary); }
.toast-error   { background: var(--red); }
.toast-info    { background: var(--primary); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { to { transform: translateX(100%); opacity: 0; } }

/* ══════════════════════════════════════════════════════════════
   STEP INDICATOR
   ══════════════════════════════════════════════════════════════ */
.step-bar { display: flex; align-items: center; gap: 0; margin-bottom: 28px; }
.step-item { display: flex; flex-direction: column; align-items: center; position: relative; flex: 1; }
.step-item:not(:last-child)::after {
  content: ''; position: absolute;
  top: 15px; left: calc(50% + 15px);
  width: calc(100% - 30px); height: 2px;
  background: var(--border); transition: background 0.4s;
}
.step-item.done:not(:last-child)::after { background: var(--secondary); }
.step-circle {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700;
  border: 2px solid var(--border); background: #fff; color: var(--text-muted);
  transition: all 0.3s; z-index: 1;
}
.step-item.active .step-circle {
  border-color: var(--primary); background: var(--primary); color: #fff;
  box-shadow: 0 0 0 4px rgba(6,63,108,0.12);
}
.step-item.done .step-circle { border-color: var(--secondary); background: var(--secondary); color: #fff; }
.step-label { font-size: 0.7rem; font-weight: 600; color: var(--text-muted); margin-top: 6px; white-space: nowrap; }
.step-item.active .step-label { color: var(--primary); }
.step-item.done .step-label   { color: var(--secondary-hover); }

/* ══════════════════════════════════════════════════════════════
   DIGITAL SIGNATURE PAD
   ══════════════════════════════════════════════════════════════ */
.signature-section { margin-bottom: 10px; }
.signature-pad-container {
  position: relative; background: #fdfdfd;
  border: 1.5px solid var(--border); border-radius: var(--r-md);
  margin-top: 8px; overflow: hidden;
}
.signature-pad { display: block; width: 100%; height: 150px; cursor: crosshair; touch-action: none; }
.btn-clear-pad {
  position: absolute; top: 10px; right: 10px;
  background: rgba(0,0,0,0.05); border: none; padding: 4px 8px;
  font-size: 0.7rem; border-radius: 4px; cursor: pointer;
  color: var(--text-secondary); transition: all var(--transition);
}
.btn-clear-pad:hover { background: var(--red-light); color: var(--red); }

/* ── Collaborator Alert ─ */
.input-info-alert {
  margin-top: 8px; padding: 8px 12px;
  background: #FFF9C4; border-left: 4px solid #FBC02D;
  color: #5D4037; font-size: 0.85rem; border-radius: 4px;
  animation: slideDown 0.3s ease;
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
.pulse { animation: pulseAnim 2s infinite; }
@keyframes pulseAnim {
  0%   { box-shadow: 0 0 0 0 rgba(251, 192, 45, 0.4); }
  70%  { box-shadow: 0 0 0 10px rgba(251, 192, 45, 0); }
  100% { box-shadow: 0 0 0 0 rgba(251, 192, 45, 0); }
}

/* Photo Upload */
.photo-upload-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px; margin-top: 10px;
}
.photo-item {
  aspect-ratio: 1; border-radius: var(--r-md);
  border: 2px dashed var(--border);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; cursor: pointer; background: #fcfcfc;
  transition: all var(--transition); position: relative; overflow: hidden;
}
.photo-item:hover { border-color: var(--secondary); background: rgba(5,194,66,0.04); }
.photo-item.add-photo { color: var(--text-secondary); font-size: 0.75rem; }
.photo-item img { width: 100%; height: 100%; object-fit: cover; }
.photo-item .remove-btn {
  position: absolute; top: 4px; right: 4px;
  background: rgba(0,0,0,0.5); color: white; border: none;
  border-radius: 50%; width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; opacity: 0; transition: opacity 0.2s;
}
.photo-item:hover .remove-btn { opacity: 1; }

/* ══════════════════════════════════════════════════════════════
   SAFETY CLOCK CARD
   ══════════════════════════════════════════════════════════════ */
.safety-clock-card {
  background: #ffffff;
  border-radius: 16px; border: 1px solid var(--border);
  padding: 24px 32px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: var(--shadow-sm); margin-bottom: 24px;
  border-left: 6px solid var(--secondary);
  transition: all 0.3s ease;
}
.safety-clock-left { display: flex; align-items: center; gap: 24px; }
.safety-clock-icon {
  width: 64px; height: 64px;
  background: var(--green-light); color: var(--secondary-hover);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.3s ease;
}
.safety-clock-info h3 {
  font-size: 0.75rem; font-weight: 700; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 1px; margin-bottom: 4px;
}
.safety-clock-days {
  font-size: 3.5rem; font-weight: 900; color: var(--secondary-hover);
  line-height: 1; transition: color 0.3s ease;
}
.safety-clock-subtext { font-size: 0.85rem; color: var(--text-secondary); font-weight: 500; margin-top: 4px; }
.safety-clock-record { text-align: right; }
.safety-clock-record .record-label {
  font-size: 0.75rem; font-weight: 700; color: var(--text-secondary);
  display: flex; align-items: center; justify-content: flex-end; gap: 6px;
}
.safety-clock-record .record-value {
  font-size: 2rem; font-weight: 800; color: var(--orange); margin-top: 2px;
}
.safety-clock-record .new-record-badge {
  font-size: 0.65rem; font-weight: 800; color: var(--orange);
  text-transform: uppercase; letter-spacing: 1px; display: block;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 20px; width: 100%;
}

/* ══════════════════════════════════════════════════════════════
   UNIT INDICATOR (topbar badge)
   ══════════════════════════════════════════════════════════════ */
.topbar-unit-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.20);
  color: rgba(255,255,255,0.90);
  font-size: 0.78rem; font-weight: 600;
  padding: 5px 12px; border-radius: 20px;
  cursor: pointer; text-decoration: none;
  transition: background 0.2s;
}
.topbar-unit-badge:hover { background: rgba(255,255,255,0.20); }

/* ══════════════════════════════════════════════════════════════
   UTILS
   ══════════════════════════════════════════════════════════════ */
.divider-h { border: none; border-top: 1px solid var(--border); }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.text-muted { color: var(--text-muted); font-size: 0.82rem; }
.w-full { width: 100%; }
.mt-2 { margin-top: 8px; }

.shake {
  animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
  transform: translate3d(0, 0, 0);
  border-color: var(--red) !important;
}
@keyframes shake {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(2px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
  40%, 60% { transform: translate3d(4px, 0, 0); }
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  body { overflow: auto; }
  .sidebar { transform: translateX(-100%); transition: transform var(--transition), width var(--transition); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-wrapper,
  .main-wrapper.sidebar-collapsed { margin-left: 0; height: auto; min-width: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .topbar { padding: 8px 54px 8px 16px; height: auto; min-height: 64px; gap: 12px; }
  .topbar-left { min-width: 0; }
  .topbar-left h1 { font-size: 1rem; }
  .topbar-left p { white-space: normal; }
  .topbar-right { gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
  .topbar-brand-logo { display: none; }
  .page-content { padding: 16px; }
  .mobile-menu-toggle {
    display: flex;
    position: fixed;
    top: 13px;
    right: 12px;
    z-index: 130;
    width: 38px;
    height: 38px;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255,255,255,0.28);
    border-radius: var(--r-md);
    background: var(--primary);
    color: #fff;
    box-shadow: var(--shadow-md);
  }
  .mobile-menu-backdrop.open {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 90;
    border: 0;
    background: rgba(5,46,77,0.48);
  }
  .safety-clock-card { padding: 18px; align-items: flex-start; gap: 16px; }
  .safety-clock-left { gap: 14px; }
  .safety-clock-icon { width: 46px; height: 46px; }
  .safety-clock-days { font-size: 2.6rem; }
  .card-header,
  .card-body { padding-left: 16px; padding-right: 16px; }
  .modal-overlay { padding: 10px; }
  .modal { max-height: 92vh; border-radius: var(--r-lg); }
  .toast-container { left: 12px; right: 12px; top: 12px; }
  .toast { min-width: 0; width: 100%; }
}

@media (max-width: 560px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .topbar-right { width: 100%; justify-content: flex-start; }
  .topbar-right .btn { padding: 7px 10px; font-size: 0.78rem; }
  .page-content { padding: 12px; }
  .safety-clock-card { flex-direction: column; }
  .safety-clock-record { text-align: left; }
  .safety-clock-record .record-label { justify-content: flex-start; }
  .step-label { font-size: 0.6rem; white-space: normal; text-align: center; }
  .photo-upload-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
