/* ============================================================
   WHHTOSWMS — Premium UI
   Desktop sidebar + Mobile bottom nav
   ============================================================ */

/* ── Google Font ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --primary:      #2563eb;
  --primary-dk:   #1d4ed8;
  --primary-lt:   #eff6ff;
  --success:      #059669;
  --success-lt:   #ecfdf5;
  --warning:      #d97706;
  --warning-lt:   #fffbeb;
  --danger:       #dc2626;
  --danger-lt:    #fef2f2;
  --purple:       #7c3aed;
  --purple-lt:    #f5f3ff;

  --bg:           #f1f5f9;
  --surface:      #ffffff;
  --surface-2:    #f8fafc;
  --border:       #e2e8f0;
  --border-dk:    #cbd5e1;
  --text:         #0f172a;
  --text-2:       #334155;
  --muted:        #64748b;
  --muted-lt:     #94a3b8;

  --sidebar-w:    260px;
  --topbar-h:     64px;
  --radius-sm:    6px;
  --radius:       12px;
  --radius-lg:    16px;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow:       0 4px 6px -1px rgba(0,0,0,.08), 0 2px 4px -1px rgba(0,0,0,.04);
  --shadow-lg:    0 20px 25px -5px rgba(0,0,0,.1), 0 10px 10px -5px rgba(0,0,0,.04);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ══════════════════════════════════════════
   LAYOUT
══════════════════════════════════════════ */

#app { min-height: 100vh; }

#layout {
  display: flex;
  min-height: 100vh;
}

/* ══════════════════════════════════════════
   SIDEBAR — Desktop
══════════════════════════════════════════ */

.sidebar {
  width: var(--sidebar-w);
  background: #0f172a;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }

/* Brand */
.sidebar-brand {
  padding: 24px 20px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  text-decoration: none;
}

.brand-img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 10px;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255,255,255,.1);
}

.brand-name {
  font-size: .85rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: .02em;
  line-height: 1.2;
}

.brand-sub {
  font-size: .7rem;
  color: #64748b;
  font-weight: 400;
  letter-spacing: .03em;
}

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-label {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #475569;
  padding: 12px 8px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: #94a3b8;
  text-decoration: none;
  font-size: .85rem;
  font-weight: 500;
  transition: all .15s ease;
  position: relative;
}

.nav-link:hover {
  background: rgba(255,255,255,.06);
  color: #e2e8f0;
}

.nav-link.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(37,99,235,.4);
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: .7;
}

.nav-link.active .nav-icon { opacity: 1; }

/* Sidebar footer */
.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,.06);
}

.sync-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.sync-badge::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sync-ok     { background: rgba(5,150,105,.15); color: #34d399; }
.sync-ok::before { background: #34d399; }
.sync-pending { background: rgba(217,119,6,.15); color: #fbbf24; }
.sync-pending::before { background: #fbbf24; animation: blink 1.2s infinite; }
.sync-offline { background: rgba(220,38,38,.15); color: #f87171; }
.sync-offline::before { background: #f87171; }
.sync-syncing { background: rgba(37,99,235,.15); color: #60a5fa; }
.sync-syncing::before { background: #60a5fa; animation: blink .8s infinite; }
.sync-conflict { background: rgba(220,38,38,.2); color: #f87171; animation: pulse 1s infinite; }
.sync-conflict::before { background: #f87171; }

@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.3} }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.7} }

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.04);
  margin-bottom: 8px;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .85rem;
  color: #fff;
  flex-shrink: 0;
}

.user-details { flex: 1; min-width: 0; }

.user-name {
  font-size: .8rem;
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.role-tag {
  font-size: .65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #60a5fa;
}

.btn-logout {
  width: 100%;
  background: transparent;
  border: 1px solid rgba(255,255,255,.1);
  color: #64748b;
  padding: 8px;
  border-radius: var(--radius-sm);
  font-size: .78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
}
.btn-logout:hover {
  border-color: #f87171;
  color: #f87171;
  background: rgba(220,38,38,.08);
}

/* ══════════════════════════════════════════
   MAIN CONTENT
══════════════════════════════════════════ */

.page-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Topbar */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 16px;
}

.topbar-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Page body */
.page-body {
  padding: 28px;
  flex: 1;
}

/* ══════════════════════════════════════════
   DASHBOARD STATS
══════════════════════════════════════════ */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: transform .2s, box-shadow .2s;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.stat-card-blue::before   { background: var(--primary); }
.stat-card-green::before  { background: var(--success); }
.stat-card-purple::before { background: var(--purple); }
.stat-card-red::before    { background: var(--danger); }

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.stat-icon-blue   { background: var(--primary-lt); }
.stat-icon-green  { background: var(--success-lt); }
.stat-icon-purple { background: var(--purple-lt);  }
.stat-icon-red    { background: var(--danger-lt);  }

.stat-info { flex: 1; min-width: 0; }

.stat-num {
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
  letter-spacing: -.02em;
}

.stat-label {
  font-size: .75rem;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-top: 4px;
}

/* ══════════════════════════════════════════
   DASHBOARD PANELS
══════════════════════════════════════════ */

.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.dash-grid-wide {
  grid-column: 1 / -1;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.panel-title {
  font-size: .88rem;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.panel-body { padding: 0; }

/* Location heatmap */
.location-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 8px;
  padding: 16px 20px;
}

.location-cell {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: .7rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform .15s;
  border: 2px solid transparent;
}

.location-cell:hover { transform: scale(1.06); }
.location-cell.empty { background: var(--surface-2); color: var(--muted); border-color: var(--border); }
.location-cell.low   { background: #dcfce7; color: #15803d; border-color: #86efac; }
.location-cell.mid   { background: #fef9c3; color: #854d0e; border-color: #fde047; }
.location-cell.high  { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }

.location-code  { font-size: .8rem; font-weight: 800; }
.location-count { font-size: .65rem; margin-top: 2px; }

/* Activity feed */
.activity-feed { padding: 8px 0; }

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}

.activity-item:last-child { border-bottom: none; }
.activity-item:hover { background: var(--surface-2); }

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}

.dot-blue   { background: var(--primary); }
.dot-green  { background: var(--success); }
.dot-purple { background: var(--purple);  }
.dot-red    { background: var(--danger);  }

.activity-text {
  flex: 1;
  font-size: .82rem;
  color: var(--text-2);
  line-height: 1.4;
}

.activity-text strong { color: var(--text); font-weight: 600; }

.activity-time {
  font-size: .72rem;
  color: var(--muted-lt);
  white-space: nowrap;
  margin-top: 1px;
}

/* Empty state */
.empty-panel {
  padding: 40px 20px;
  text-align: center;
}

.empty-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: .4;
}

.empty-title {
  font-size: .9rem;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 4px;
}

.empty-sub {
  font-size: .8rem;
  color: var(--muted);
}

/* ══════════════════════════════════════════
   CARDS & FORMS
══════════════════════════════════════════ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.card-title {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.form-group { margin-bottom: 16px; }

.form-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.form-row .form-group { flex: 1; min-width: 180px; }

label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
  letter-spacing: .01em;
}

.optional { font-weight: 400; color: var(--muted); }

input[type="text"],
input[type="email"],
input[type="number"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

.form-error {
  color: var(--danger);
  font-size: .78rem;
  margin-top: 6px;
  min-height: 1em;
}

/* ══════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: .855rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all .15s ease;
  white-space: nowrap;
}

.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 3px rgba(37,99,235,.3);
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-dk);
  box-shadow: 0 4px 12px rgba(37,99,235,.35);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text-2);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--border-dk);
}

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover:not(:disabled) { background: #047857; }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-sm   { padding: 6px 12px; font-size: .78rem; }
.btn-lg   { padding: 12px 24px; font-size: .95rem; }
.btn-full { width: 100%; margin-top: 4px; }

/* ══════════════════════════════════════════
   PAGE HEADERS
══════════════════════════════════════════ */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h2 {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.02em;
}

.page-header p {
  font-size: .83rem;
  color: var(--muted);
  margin-top: 2px;
}

/* ══════════════════════════════════════════
   TABLES
══════════════════════════════════════════ */

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .838rem;
  background: var(--surface);
}

thead { position: sticky; top: 0; z-index: 1; }

th {
  background: var(--surface-2);
  padding: 11px 16px;
  text-align: left;
  font-weight: 700;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text-2);
}

tr:last-child td { border-bottom: none; }

tbody tr {
  transition: background .1s;
}

tbody tr:hover td {
  background: #f8fafc;
}

.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--muted);
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 10px;
  opacity: .4;
}

/* ══════════════════════════════════════════
   BADGES & STATUS
══════════════════════════════════════════ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
}

.badge::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
}

.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-blue::before { background: #1d4ed8; }
.badge-green  { background: #d1fae5; color: #065f46; }
.badge-green::before { background: #059669; }
.badge-yellow { background: #fef9c3; color: #854d0e; }
.badge-yellow::before { background: #d97706; }
.badge-purple { background: #ede9fe; color: #5b21b6; }
.badge-purple::before { background: #7c3aed; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-red::before { background: #dc2626; }
.badge-grey   { background: var(--surface-2); color: var(--muted); }
.badge-grey::before { background: var(--muted-lt); }

/* ══════════════════════════════════════════
   SCANNER PAGE
══════════════════════════════════════════ */

.scanner-wrapper {
  max-width: 480px;
  margin: 0 auto;
}

#scanner-box {
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px solid var(--primary);
  box-shadow: 0 0 0 4px rgba(37,99,235,.1);
  margin: 16px 0;
  aspect-ratio: 1;
  max-height: 360px;
}

.scan-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.switch-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: .84rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-2);
}

.manual-override {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.manual-override input { flex: 1; }

.result-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-left: 4px solid var(--success);
  border-radius: var(--radius);
  padding: 16px 18px;
  font-size: .875rem;
  line-height: 1.7;
  margin-top: 16px;
  box-shadow: var(--shadow-sm);
}

.result-error { border-left-color: var(--danger); }

.continuous-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 200px;
  overflow-y: auto;
}

.scan-item {
  padding: 7px 12px;
  background: var(--success-lt);
  border-radius: var(--radius-sm);
  font-size: .8rem;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--success);
  border: 1px solid #a7f3d0;
}

/* ══════════════════════════════════════════
   QR & LABELS
══════════════════════════════════════════ */

.qr-preview {
  display: block;
  margin: 14px auto;
  width: 160px;
  height: 160px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.result-id {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: .02em;
}

/* ══════════════════════════════════════════
   CHIPS
══════════════════════════════════════════ */

.chip-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.chip {
  background: var(--primary-lt);
  color: var(--primary);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: .78rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #bfdbfe;
}

.chip button {
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  opacity: .6;
}
.chip button:hover { opacity: 1; }

/* ══════════════════════════════════════════
   TOOLBAR
══════════════════════════════════════════ */

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
  align-items: center;
}

.toolbar input, .toolbar select { max-width: 260px; }

/* ══════════════════════════════════════════
   TRAIL / AUDIT
══════════════════════════════════════════ */

.trail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.trail-meta {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px 24px;
  margin-bottom: 20px;
}

.trail-meta-item { display: flex; flex-direction: column; gap: 2px; }
.trail-meta-label { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.trail-meta-value { font-size: .875rem; color: var(--text); font-weight: 500; }

.timeline {
  position: relative;
  padding-left: 24px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  margin-bottom: 20px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -21px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 2px var(--primary);
}

.timeline-title {
  font-size: .82rem;
  font-weight: 700;
  color: var(--text);
}

.timeline-sub {
  font-size: .75rem;
  color: var(--muted);
  margin-top: 2px;
}

/* ══════════════════════════════════════════
   LOGIN PAGE
══════════════════════════════════════════ */

.login-wrapper {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.login-left {
  background: linear-gradient(145deg, #0f172a 0%, #1e3a5f 50%, #1d4ed8 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px;
  position: relative;
  overflow: hidden;
}

.login-left::before {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: rgba(37,99,235,.15);
  top: -100px;
  right: -100px;
}

.login-left::after {
  content: '';
  position: absolute;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: rgba(124,58,237,.1);
  bottom: -60px;
  left: -60px;
}

.login-hero-logo {
  width: 100px;
  height: 100px;
  object-fit: contain;
  margin-bottom: 28px;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 8px 24px rgba(0,0,0,.3));
}

.login-hero-title {
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.2;
  margin-bottom: 12px;
  position: relative;
  z-index: 1;
  text-align: center;
}

.login-hero-sub {
  font-size: .9rem;
  color: #93c5fd;
  text-align: center;
  line-height: 1.6;
  position: relative;
  z-index: 1;
  max-width: 320px;
}

.login-features {
  margin-top: 40px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  z-index: 1;
}

.login-feature {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: .84rem;
  color: #bfdbfe;
}

.login-feature-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.login-right {
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 50px;
}

.login-form-wrap {
  width: 100%;
  max-width: 380px;
}

.login-form-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 4px;
  letter-spacing: -.02em;
}

.login-form-sub {
  font-size: .85rem;
  color: var(--muted);
  margin-bottom: 28px;
}

.login-title { /* legacy compat */ margin-bottom: 24px; font-size: 1.4rem; font-weight: 700; }

.input-group {
  position: relative;
  margin-bottom: 16px;
}

.input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1rem;
  color: var(--muted-lt);
  pointer-events: none;
}

.input-group input {
  padding-left: 38px;
}

/* ══════════════════════════════════════════
   TOASTS
══════════════════════════════════════════ */

#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: .855rem;
  font-weight: 600;
  color: #fff;
  box-shadow: var(--shadow-lg);
  animation: toastIn .3s cubic-bezier(.34,1.56,.64,1);
  max-width: 340px;
  pointer-events: all;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast::before {
  font-size: 1rem;
  flex-shrink: 0;
}

.toast-success { background: var(--success); }
.toast-success::before { content: '✓'; }
.toast-error   { background: var(--danger); }
.toast-error::before { content: '✕'; }
.toast-warning { background: var(--warning); }
.toast-warning::before { content: '⚠'; }
.toast-info    { background: var(--primary); }
.toast-info::before { content: 'ℹ'; }

@keyframes toastIn {
  from { transform: translateX(110%) scale(.95); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

/* ══════════════════════════════════════════
   LOADERS
══════════════════════════════════════════ */

.loading-spinner, .page-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  gap: 14px;
  color: var(--muted);
  font-size: .875rem;
}

.loading-spinner::before, .page-loading::before {
  content: '';
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.sync-note { font-size: .75rem; color: var(--muted); margin-bottom: 16px; }

/* ══════════════════════════════════════════
   MOBILE — Bottom navigation
══════════════════════════════════════════ */

.mobile-topbar {
  display: none;
  height: 56px;
  background: #0f172a;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 200;
}

.mobile-topbar-logo {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

.mobile-topbar-title {
  font-size: .9rem;
  font-weight: 700;
  color: #fff;
  flex: 1;
}

.mobile-sync {
  font-size: .65rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
}

.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #0f172a;
  border-top: 1px solid rgba(255,255,255,.08);
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav-inner {
  display: flex;
  align-items: stretch;
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 4px;
  text-decoration: none;
  color: #64748b;
  font-size: .6rem;
  font-weight: 600;
  gap: 4px;
  transition: color .15s;
  text-transform: uppercase;
  letter-spacing: .04em;
  min-height: 56px;
}

.bottom-nav-item:hover { color: #94a3b8; }

.bottom-nav-item.active {
  color: #60a5fa;
}

.bottom-nav-icon {
  font-size: 1.3rem;
  line-height: 1;
}

.bottom-nav-item.active .bottom-nav-icon {
  transform: scale(1.1);
}

/* ══════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
══════════════════════════════════════════ */

@media (max-width: 1024px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  /* Hide desktop sidebar */
  .sidebar { display: none; }

  /* Show mobile chrome */
  .mobile-topbar { display: flex; }
  .bottom-nav    { display: flex; flex-direction: column; }

  /* Content */
  .page-content {
    margin-left: 0;
    padding-bottom: 70px;
  }

  .topbar { display: none; }

  .page-body { padding: 16px; }

  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .stat-card { padding: 14px; gap: 10px; }
  .stat-num  { font-size: 1.5rem; }
  .stat-icon { width: 38px; height: 38px; font-size: 1.1rem; }

  .dash-grid { grid-template-columns: 1fr; gap: 14px; }

  .form-row { flex-direction: column; gap: 0; }

  /* Login — single column on mobile */
  .login-wrapper { grid-template-columns: 1fr; }
  .login-left    { display: none; }
  .login-right   { padding: 40px 24px; }
  .login-form-wrap { max-width: 100%; }

  /* Toast at top on mobile */
  #toast-container {
    bottom: auto;
    top: 16px;
    right: 16px;
    left: 16px;
  }
  .toast { max-width: 100%; }

  /* Tables scroll */
  .table-wrap { border-radius: var(--radius-sm); }

  /* Trail meta */
  .trail-meta { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 420px) {
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-num  { font-size: 1.3rem; }
  .page-body { padding: 12px; }
}

/* ══════════════════════════════════════════
   PRINT — Label only
══════════════════════════════════════════ */

@media print {
  * { visibility: hidden !important; }
  .print-label, .print-label * { visibility: visible !important; }
  .print-label {
    position: fixed !important;
    top: 0; left: 0;
    width: 4in; height: 6in;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.25in;
    font-family: monospace;
    background: #fff;
  }
  @page { size: 4in 6in; margin: 0; }
}
