/* ═══════════════════════════════════════════════════════════
   SecureEye — Main Stylesheet (v5 — Responsive Audit 2026)
   Christdanrey Construction
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400&display=swap');

/* ── Font scaling: prevent iOS/Android OS-level text size adjustments ─ */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: hidden;
}

/* ── CSS Variables — Orange Theme ─────────────────────────── */
:root {
  --primary:        #e87c1e;
  --primary-dark:   #c96a10;
  --primary-light:  #fff4e8;
  --accent:         #f5a623;
  --sidebar-bg:     #1a1008;
  --sidebar-text:   #a89070;
  --sidebar-active: #e87c1e;
  --sidebar-hover:  #2a1a0c;
  --topbar-bg:      #ffffff;
  --body-bg:        #f7f3ef;
  --card-bg:        #ffffff;
  --border:         #e8ddd0;
  --text-primary:   #1a0f00;
  --text-muted:     #7a6050;
  --success:        #10b981;
  --warning:        #f59e0b;
  --danger:         #ef4444;
  --info:           #0ea5e9;
  --radius:         10px;
  --shadow:         0 1px 3px rgba(180,100,0,.08), 0 1px 2px rgba(180,100,0,.05);
  --shadow-md:      0 4px 6px -1px rgba(180,100,0,.1), 0 2px 4px -1px rgba(180,100,0,.06);
  --sidebar-width:  240px;
  --topbar-height:  60px;
}

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

/* ── Touch optimisation: eliminate 300ms tap delay + suppress blue flash ── */
a, button, .btn, input[type="button"], input[type="submit"],
label, .nav-item, .rail-item, .mob-nav-item, .stat-card, .task-btn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background: var(--body-bg);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  overflow-wrap: break-word;
  word-break: break-word;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ═══════════════════════════════════════════════════════════
   LOGIN PAGE
   ═══════════════════════════════════════════════════════════ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a1008 0%, #3d2208 55%, #e87c1e 100%);
  padding: 20px;
}

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 48px 40px;
  width: 100%;
  max-width: 430px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.login-logo .logo-img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border-radius: 10px;
  background: #1a1008;
  padding: 4px;
}

.login-logo .logo-text h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.login-logo .logo-text span {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}

.login-card h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.login-card .subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 28px;
}

/* ═══════════════════════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════════════════════ */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: left .3s ease;
  overflow: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid #2a1a0c;
}

.sidebar-brand .brand-logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 8px;
  background: #2a1a0c;
  padding: 3px;
  flex-shrink: 0;
}

.sidebar-brand .brand-name {
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
}

.sidebar-brand .brand-sub {
  color: var(--sidebar-text);
  font-size: 10px;
  font-weight: 400;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.nav-section-label {
  color: #4a3020;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 12px 20px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 20px;
  color: var(--sidebar-text);
  font-size: 14.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
  text-decoration: none;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: #f5d0a0;
  text-decoration: none;
}

.nav-item.active {
  background: var(--sidebar-active);
  color: #ffffff;
}

.nav-item .nav-icon {
  width: 22px;
  text-align: center;
  font-size: 17px;
  opacity: .9;
  flex-shrink: 0;
}

/* ── Collapsible nav groups (Canvas-style) ──────────────────── */
.nav-group { display: block; }

.nav-group-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 13px 20px;
  background: none;
  border: none;
  color: var(--sidebar-text);
  font-size: 14.5px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: background .15s, color .15s;
}

.nav-group-toggle:hover {
  background: var(--sidebar-hover);
  color: #f5d0a0;
}

.nav-group-toggle .nav-icon {
  width: 22px;
  text-align: center;
  font-size: 17px;
  opacity: .9;
  flex-shrink: 0;
}

.nav-group-title { flex: 1; }

.nav-chevron {
  font-size: 12px;
  opacity: .7;
  transition: transform .25s ease;
}

.nav-group.open .nav-chevron { transform: rotate(180deg); }

/* Highlight the parent when one of its children is the active page */
.nav-group.has-active > .nav-group-toggle {
  color: #f5d0a0;
}

/* The collapsible panel */
.nav-subnav {
  max-height: 0;
  overflow: hidden;
  transition: max-height .28s ease;
  background: rgba(0, 0, 0, .18);
}

.nav-group.open .nav-subnav { max-height: 600px; }

/* Sub-items: slightly indented and smaller */
.nav-subitem {
  padding-left: 30px;
  font-size: 13.5px;
}

.nav-subitem .nav-icon { font-size: 15px; }

.nav-subitem.active {
  background: var(--sidebar-active);
  color: #ffffff;
}

.sidebar-user {
  padding: 16px 20px;
  border-top: 1px solid #2a1a0c;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-user .user-avatar {
  width: 34px;
  height: 34px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-user .user-info .user-name {
  color: #f5d0a0;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
}

.sidebar-user .user-info .user-role {
  color: var(--sidebar-text);
  font-size: 11px;
}

/* ── Main Content ─────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--topbar-height);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left .page-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.topbar-left .breadcrumb {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-time { font-size: 12px; color: var(--text-muted); }

.btn-logout {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: #fff4e8;
  border: 1px solid #f5d0a0;
  border-radius: 6px;
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s;
}

.btn-logout:hover { background: #ffe0c0; color: var(--primary-dark); text-decoration: none; }

.page-body { padding: 24px; flex: 1; }

/* ═══════════════════════════════════════════════════════════
   CARDS
   ═══════════════════════════════════════════════════════════ */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

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

.card-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body { padding: 20px; }

/* ── Stat Cards ───────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.stat-card .stat-icon {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.stat-card .stat-icon.blue   { background: #fff4e8; color: var(--primary); }
.stat-card .stat-icon.green  { background: #d1fae5; color: var(--success); }
.stat-card .stat-icon.yellow { background: #fef3c7; color: var(--warning); }
.stat-card .stat-icon.red    { background: #fee2e2; color: var(--danger); }
.stat-card .stat-icon.cyan   { background: #e0f2fe; color: var(--info); }
.stat-card .stat-icon.orange { background: #fff4e8; color: var(--primary); }

/* Calm dashboard: neutral brand-tinted tile by default; a semantic colour
   appears only when that metric needs attention (warn = pending, alert = problem). */
.stat-card .stat-icon.neutral { background: var(--primary-light); color: var(--primary); }
.stat-card.is-warn  .stat-icon  { background: #fef3c7; color: var(--warning); }
.stat-card.is-warn  .stat-value { color: var(--warning); }
.stat-card.is-alert .stat-icon  { background: #fee2e2; color: var(--danger); }
.stat-card.is-alert .stat-value { color: var(--danger); }

.stat-card .stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.stat-card .stat-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ═══════════════════════════════════════════════════════════
   CCTV MONITOR
   ═══════════════════════════════════════════════════════════ */
.cctv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(520px, 100%), 1fr));
  gap: 20px;
}

.camera-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: box-shadow .2s;
}

.camera-card:hover { box-shadow: var(--shadow-md); }

.camera-feed {
  width: 100%;
  height: 0;
  padding-top: 56.25%;  /* 16:9 aspect ratio */
  background: #1a1008;
  display: block;
  position: relative;
  overflow: hidden;
}
.camera-feed > * {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.camera-feed::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,0) 0px, rgba(0,0,0,0) 2px, rgba(0,0,0,.05) 2px, rgba(0,0,0,.05) 4px);
  pointer-events: none;
}

.camera-feed .feed-placeholder { text-align: center; color: #4a3020; flex-direction: column; }
.camera-feed .feed-placeholder .cam-icon { font-size: 36px; margin-bottom: 8px; display: block; }
.camera-feed .feed-placeholder .no-signal { font-size: 11px; color: #4a3020; letter-spacing: .05em; }
.camera-feed .feed-placeholder .cam-label { font-size: 13px; color: #7a5030; font-weight: 500; }

.status-indicator {
  position: absolute !important;
  top: 10px !important; right: 10px !important;
  left: auto !important; bottom: auto !important;
  width: auto !important; height: auto !important;
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(0,0,0,.6);
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 10px;
  color: #fff;
  font-weight: 500;
}

.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.online  { background: var(--success); animation: pulse 2s infinite; }
.status-dot.offline { background: var(--danger); }
.status-dot.maintenance { background: var(--warning); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .4; }
}

.camera-info { padding: 16px 20px; }
.camera-info .cam-name { font-size: 14px; font-weight: 600; color: var(--text-primary); margin-bottom: 2px; }
.camera-info .cam-location { font-size: 12px; color: var(--text-muted); }
.camera-info .cam-meta { margin-top: 8px; display: flex; align-items: center; justify-content: space-between; }
.camera-info .cam-meta .last-activity { font-size: 11px; color: var(--text-muted); }

/* ═══════════════════════════════════════════════════════════
   TABLES
   ═══════════════════════════════════════════════════════════ */
.table-wrapper { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

thead th {
  background: #faf6f2;
  padding: 11px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  color: var(--text-primary);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #faf6f2; }

/* ═══════════════════════════════════════════════════════════
   BADGES
   ═══════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-pending    { background: #fff4e8; color: #c96a10; }
.badge-verified   { background: #d1fae5; color: #065f46; }
.badge-flagged    { background: #fee2e2; color: #b91c1c; }
.badge-open       { background: #fff4e8; color: #c96a10; }
.badge-progress   { background: #fef3c7; color: #b45309; }
.badge-resolved   { background: #d1fae5; color: #065f46; }
.badge-closed     { background: #f1f5f9; color: #64748b; }
.badge-online     { background: #d1fae5; color: #065f46; }
.badge-offline    { background: #fee2e2; color: #b91c1c; }
.badge-maintenance { background: #fef3c7; color: #b45309; }
.badge-low        { background: #d1fae5; color: #065f46; }
.badge-medium     { background: #fff4e8; color: #c96a10; }
.badge-high       { background: #fee2e2; color: #b91c1c; }
.badge-critical   { background: #450a0a; color: #fca5a5; }
.badge-in_progress { background: #fef3c7; color: #b45309; }

/* ═══════════════════════════════════════════════════════════
   FORMS
   ═══════════════════════════════════════════════════════════ */
.form-group { margin-bottom: 20px; }

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.form-control,
.form-select {
  display: block;
  width: 100%;
  padding: 9px 12px;
  font-size: 14px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  color: var(--text-primary);
  background: #fff;
  border: 1px solid #d8c8b8;
  border-radius: 7px;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(232,124,30,.15);
}

.form-control.is-invalid { border-color: var(--danger); }
.form-text { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 20px;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0 20px;
}

/* ═══════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  font-size: 13.5px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 600;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  transition: background .15s, box-shadow .15s;
  text-decoration: none;
  line-height: 1;
}

.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; color: #fff; }

.btn-outline {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text-primary);
}
.btn-outline:hover { background: #faf6f2; text-decoration: none; color: var(--text-primary); }

.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; text-decoration: none; color: #fff; }
.btn-warning { background: #d97706; color: #fff; }
.btn-warning:hover { background: #b45309; text-decoration: none; color: #fff; }
.btn-success { background: #059669; color: #fff; }
.btn-success:hover { background: #047857; text-decoration: none; color: #fff; }
.btn-sm      { padding: 5px 12px; font-size: 12px; }

/* ═══════════════════════════════════════════════════════════
   EVIDENCE REF
   ═══════════════════════════════════════════════════════════ */
.evidence-ref {
  font-family: 'Courier New', monospace;
  font-size: 11px;
  background: var(--primary);
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--primary-dark);
  font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════
   ALERTS
   ═══════════════════════════════════════════════════════════ */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-success { background: #d1fae5; border: 1px solid #a7f3d0; color: #065f46; }
.alert-error   { background: #fee2e2; border: 1px solid #fca5a5; color: #b91c1c; }
.alert-warning { background: #fef3c7; border: 1px solid #fde68a; color: #92400e; }
.alert-info    { background: #fff4e8; border: 1px solid #f5d0a0; color: #c96a10; }

/* ═══════════════════════════════════════════════════════════
   AUDIT LOG
   ═══════════════════════════════════════════════════════════ */
.audit-timeline { display: flex; flex-direction: column; gap: 0; }

.audit-entry {
  display: grid;
  grid-template-columns: 140px 140px 1fr;
  gap: 12px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  align-items: center;
}

.audit-entry:last-child { border-bottom: none; }
.audit-entry:hover { background: #faf6f2; }
.audit-time { color: var(--text-muted); font-size: 12px; }
.audit-user { font-weight: 600; color: var(--text-primary); }
.audit-desc { color: var(--text-muted); }

/* ═══════════════════════════════════════════════════════════
   PAGE HEADER
   ═══════════════════════════════════════════════════════════ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.page-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

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

.section-divider {
  height: 1px;
  background: var(--border);
  margin: 24px 0;
}

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

.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* ── Prevent ALL horizontal overflow site-wide ── */
  body, .app-wrapper, .main-content, .page-body { overflow-x: hidden; max-width: 100%; }

  .sidebar { left: calc(-1 * var(--sidebar-width)); }
  .sidebar.open { left: 0; }
  .main-content { margin-left: 0; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .form-grid-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }

  /* ── Topbar: clamp to fixed 60px, truncate long titles/breadcrumbs ── */
  .topbar { gap: 8px; height: var(--topbar-height); overflow: hidden; padding: 0 12px; }
  .topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
    overflow: hidden;
  }
  .topbar-left > div { min-width: 0; flex: 1; overflow: hidden; }
  .topbar-left .page-title {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    display: block;
  }
  .topbar-left .breadcrumb {
    font-size: 11px;
    white-space: normal;
    overflow: visible;
    max-width: 100%;
    display: block;
    line-height: 1.3;
  }
  .topbar-right { flex-shrink: 0; gap: 6px; }

  /* ── Hamburger: proper tap target with breathing room ── */
  .sidebar-toggle {
    width: 36px;
    height: 36px;
    font-size: 20px;
    flex-shrink: 0;
    border-radius: 8px;
  }

  /* ── Page header: stack, shrink, wrap ── */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    max-width: 100%;
  }
  .page-header h2 { font-size: 17px; word-break: break-word; max-width: 100%; }
  .page-header p  { font-size: 12px; word-break: break-word; max-width: 100%; }
  .page-header > a,
  .page-header > div > a { align-self: flex-start; }

  /* ── Card headers: wrap, shrink text ── */
  .card-header { flex-wrap: wrap; gap: 6px; }
  .card-header h2, .card-header h3 { font-size: 14px; word-break: break-word; min-width: 0; max-width: 100%; }
  .card-header span { font-size: 11px; word-break: break-word; }

  /* ── All headings inside cards: prevent overflow ── */
  .card h2, .card h3, .card h4 { word-break: break-word; max-width: 100%; }

  /* ── Greeting hero ── */
  .greeting-hero-inner { min-width: 0; flex: 1; }
  .greeting-hero-text  { min-width: 0; overflow: hidden; }
  .greeting-hero-name  { font-size: 16px !important; white-space: normal !important; word-break: break-word; }
  .greeting-hero-sub   { font-size: 12px !important; white-space: normal !important; word-break: break-word; }

  /* ── Tables: scroll horizontally instead of breaking layout ── */
  .table-wrapper, .tools-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: unset; }

  /* ── Images and media: never overflow ── */
  img, video, iframe { max-width: 100%; height: auto; }

  /* ── Form elements: full width ── */
  .form-control, .form-select, select, input, textarea { max-width: 100%; box-sizing: border-box; }

  /* ── Buttons: prevent text overflow ── */
  .btn { word-break: break-word; }

  /* ── Wizard: compact ── */
  .wizard-progress { flex-wrap: wrap; gap: 6px 4px; padding: 12px 14px; }
  .wizard-step     { font-size: 11px; padding: 5px 10px; gap: 5px; }
  .wizard-connector { min-width: 10px; flex-shrink: 1; }
  .wizard-nav { flex-direction: column-reverse; gap: 8px; }
  .wizard-nav > button, .wizard-nav > a { width: 100%; justify-content: center; text-align: center; }

  /* ── Upload zone ── */
  .upload-btns { flex-direction: column; }
  .upload-btns > button { width: 100%; justify-content: center; }
  .upload-preview-img { max-width: 100%; }

  /* ── Toast alerts: top of screen on mobile, near the bell ── */
  .alert { top: 68px !important; left: 12px !important; right: 12px !important; bottom: auto !important; min-width: unset; max-width: unset; }

  /* ── Card/page padding: tighter ── */
  .card-body { padding: 14px 16px; }
  .page-body  { padding: 12px; }

  /* ── Topbar compress ── */
  .topbar-time { display: none; }
  .btn-logout  { font-size: 0; padding: 8px 10px; }
  .btn-logout i { font-size: 15px; }
  .topbar { padding: 0 12px; }
  .topbar-left { gap: 8px; }

  /* ── Form submit row ── */
  .form-submit-row { flex-direction: column; gap: 8px; }
  .form-submit-row > * { width: 100%; justify-content: center; text-align: center; }

  /* ── Content+sidebar layout: stack ── */
  .content-sidebar-layout { grid-template-columns: 1fr !important; }

  /* ── Inline grids with fixed columns: collapse ── */
  [style*="grid-template-columns:1fr 300px"],
  [style*="grid-template-columns: 1fr 300px"],
  [style*="grid-template-columns:1fr 320px"],
  [style*="grid-template-columns: 1fr 320px"],
  [style*="grid-template-columns:1fr 340px"],
  [style*="grid-template-columns: 1fr 340px"],
  [style*="grid-template-columns:1fr 260px"],
  [style*="grid-template-columns: 1fr 260px"],
  [style*="grid-template-columns:1fr 280px"],
  [style*="grid-template-columns: 1fr 280px"],
  [style*="grid-template-columns:1fr 360px"],
  [style*="grid-template-columns: 1fr 360px"],
  [style*="grid-template-columns:1fr 380px"],
  [style*="grid-template-columns: 1fr 380px"],
  [style*="grid-template-columns:1fr 400px"],
  [style*="grid-template-columns: 1fr 400px"],
  [style*="grid-template-columns:2fr 1fr"],
  [style*="grid-template-columns: 2fr 1fr"],
  [style*="grid-template-columns:3fr 1fr"],
  [style*="grid-template-columns: 3fr 1fr"],
  [style*="grid-template-columns:1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns:1fr 1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr 1fr"],
  [style*="grid-template-columns:1fr auto"],
  [style*="grid-template-columns: 1fr auto"],
  [style*="grid-template-columns:auto 1fr"],
  [style*="grid-template-columns: auto 1fr"],
  [style*="grid-template-columns:repeat(2"],
  [style*="grid-template-columns: repeat(2"] {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .page-body { padding: 10px; }
  .greeting-hero-name { font-size: 15px !important; }
  .wizard-step .step-number { display: none; }
  .wizard-step { padding: 4px 10px; }
  .wizard-progress { gap: 4px 3px; }
  .card-body { padding: 12px; }
  .page-header h2 { font-size: 16px; }
}

/* Progressive-disclosure "Show technical details" expanders */
details > summary { list-style: none; outline: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary .bi-chevron-right { display: inline-block; transition: transform .2s ease; }
details[open] > summary .bi-chevron-right { transform: rotate(90deg); }
details > summary:hover { color: var(--primary); }

/* ═══════════════════════════════════════════════════════════════════════════
   UI/UX REFRESH — 2026
   Modern "neutral surface + one vivid accent" treatment inspired by a
   smart-home dashboard reference. Keeps SecureEye's orange brand; shifts the
   warm-brown chrome to a cleaner charcoal/neutral base, with softer floating
   cards, rounded sidebar pills, pill toggles and header chips.
   Appended last so it overrides earlier rules via the cascade.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  /* keep the orange brand accent */
  --primary:        #e87c1e;
  --primary-dark:   #cc6a12;
  --primary-light:  #fff3e6;
  --accent:         #f5a623;

  /* charcoal chrome (was warm brown) */
  --sidebar-bg:     #1c1005;
  --sidebar-text:   #a89070;
  --sidebar-active: #e87c1e;
  --sidebar-hover:  #2a1a0c;

  /* clean neutral surfaces (was warm) */
  --topbar-bg:      #ffffff;
  --body-bg:        #f3f4f6;
  --card-bg:        #ffffff;
  --border:         #c8cdd6;
  --text-primary:   #16181d;
  --text-muted:     #6b7280;

  /* softer, larger, more modern */
  --radius:         14px;
  --radius-sm:      10px;
  --radius-lg:      20px;
  --shadow:         0 1px 2px rgba(17,24,39,.04), 0 4px 14px rgba(17,24,39,.05);
  --shadow-md:      0 6px 22px -6px rgba(17,24,39,.12), 0 2px 8px rgba(17,24,39,.06);
}

body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

/* ── Flex/grid shrink: prevent children overflowing their container ── */
.card, .card-body, .card-header,
.stat-card, .chip, .badge, .alert,
.page-content, .table-wrap, .tools-table-wrap,
.topbar-left, .topbar-right,
.sidebar-brand, .sidebar-user { min-width: 0; }

/* ── Cards: soft, floating, subtle hover lift ── */
.card {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: box-shadow .18s ease, transform .18s ease;
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header { padding: 18px 22px; }
.card-body { padding: 22px; }

/* ── Sidebar: rounded inset "pill" items like the reference rail ── */
.sidebar { background: var(--sidebar-bg); }
.sidebar-nav { padding: 14px 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.sidebar .nav-item {
  margin: 2px 12px;
  padding: 11px 14px;
  border-radius: 12px;
  font-weight: 500;
}
.sidebar .nav-item:hover { background: var(--sidebar-hover); color: #f3d9bd; }
.sidebar .nav-item.active {
  background: var(--sidebar-active);
  color: #fff;
  box-shadow: 0 8px 20px -8px rgba(232,124,30,.65);
}
.sidebar .nav-subitem {
  margin: 1px 12px 1px 16px;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 13.5px;
}
.sidebar .nav-group-toggle {
  margin: 2px 12px;
  padding: 11px 14px;
  border-radius: 12px;
  width: auto;
}
.sidebar .nav-group-toggle:hover { background: var(--sidebar-hover); }

/* ── Topbar: cleaner, lighter ── */
.topbar { border-bottom: 1px solid var(--border); box-shadow: 0 1px 0 rgba(17,24,39,.02); }

/* ── Buttons: rounder, springier ── */
.btn { border-radius: 11px; padding: 10px 18px; transition: background .15s, box-shadow .15s, transform .08s; }
.btn:active { transform: translateY(1px); }
.btn-primary { box-shadow: 0 8px 18px -8px rgba(232,124,30,.6); }
.btn-primary:hover { box-shadow: 0 10px 22px -8px rgba(232,124,30,.7); }
.btn-outline { background: #fff; border: 1px solid var(--border); }
.btn-outline:hover { background: #f7f8fa; }
.btn-sm { border-radius: 9px; padding: 6px 12px; }

/* ── Badges: pill, slightly bolder ── */
.badge { border-radius: 999px; font-weight: 600; letter-spacing: .01em; padding: 4px 10px; }

/* ── Inputs: rounder, soft focus ring ── */
.form-control, .form-select {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(232,124,30,.15);
  outline: none;
}

/* ── Stat cards: refined ── */
.stat-card { border-radius: var(--radius); }
.stat-card .stat-icon { border-radius: 14px; }

/* ── Page header ── */
.page-header h2 { letter-spacing: -.01em; }

/* ── Info chips (for headers / status strips, like the reference) ── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  box-shadow: var(--shadow);
}
.chip i { color: var(--primary); }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ── Pill toggle switch (reference-style) ── */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; cursor: pointer;
  background: #cbd0d8; border-radius: 999px; transition: background .2s;
}
.switch .slider::before {
  content: ""; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* ── Live "REC/LIVE" pill animation already used on recordings page ── */
@keyframes recpulse2 { 0%,100% { opacity:1 } 50% { opacity:.3 } }

/* ── Evidence ref chip: orange badge with white text for all contexts ── */
.evidence-ref { background: var(--primary); color: #fff; border-color: var(--primary-dark); }

/* ═══════════════════════════════════════════════════════════════════════════
   FLOATING ICON RAIL + FLYOUT SUB-MENUS  (reference: image 2)
   Slim rail of circular icon buttons; categories with sub-pages pop out a
   floating panel of sub-links beside the rail. Selectors are scoped to
   `.sidebar` so they win over the generic .sidebar .nav-item refresh rules.
   ═══════════════════════════════════════════════════════════════════════════ */

:root { --sidebar-width: 92px; }

.sidebar { width: var(--sidebar-width); align-items: center; }

.sidebar .sidebar-brand { justify-content: center; padding: 16px 0 10px; }
.sidebar .sidebar-brand .brand-text { display: none; }
.sidebar .sidebar-brand .brand-icon {
  width: 62px; height: 62px; border-radius: 16px;
  background: transparent;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}

.sidebar .sidebar-nav {
  display: flex; flex-direction: column; align-items: center;
  gap: 3px; width: 100%; padding: 6px 0;
  overflow-y: auto; overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
}
.sidebar .rail-spacer { flex: 1 1 auto; min-height: 8px; }

.sidebar .rail-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  width: 64px; margin: 1px 0; padding: 6px 4px; border-radius: 14px;
  background: transparent; border: none; cursor: pointer;
  color: var(--sidebar-text); font-family: inherit;
  font-size: 9.5px; font-weight: 600; text-align: center; line-height: 1.15;
  text-decoration: none; transition: color .15s;
}
.sidebar .rail-item .nav-icon {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--sidebar-hover);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; opacity: 1;
  transition: background .15s, color .15s, box-shadow .15s;
}
.sidebar .rail-label { white-space: nowrap; }
.sidebar .rail-item:hover { background: transparent; color: #f3d9bd; }
.sidebar .rail-item:hover .nav-icon { background: #2c2f3a; color: #fff; }

.sidebar .rail-item.active .nav-icon,
.sidebar .rail-group.group-active > .rail-toggle .nav-icon {
  background: var(--sidebar-active); color: #fff;
  box-shadow: 0 8px 18px -6px rgba(232,124,30,.6);
}
.sidebar .rail-item.active,
.sidebar .rail-group.group-active > .rail-toggle { color: #fff; }

.sidebar .rail-group { position: relative; width: 100%; display: flex; flex-direction: column; align-items: center; }
.sidebar .rail-flyout {
  position: fixed;
  min-width: 216px; max-height: 80vh; overflow-y: auto;
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow-md); padding: 9px;
  opacity: 0; visibility: hidden; transform: translateX(-6px);
  transition: opacity .15s ease, transform .15s ease, visibility .15s;
  z-index: 1200;
}
.sidebar .rail-flyout::before {
  content: ""; position: absolute; left: -6px; top: var(--ptr-top, 22px);
  width: 12px; height: 12px; background: var(--card-bg);
  border-left: 1px solid var(--border); border-bottom: 1px solid var(--border);
  transform: rotate(45deg);
}
.sidebar .rail-group.open .rail-flyout { opacity: 1; visibility: visible; transform: translateX(0); }

.sidebar .flyout-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-muted); padding: 6px 10px 8px;
}
.sidebar .flyout-link {
  display: flex; flex-direction: row; align-items: center; gap: 11px;
  width: auto; margin: 0; padding: 9px 12px; border-radius: 10px;
  font-size: 13.5px; font-weight: 500; text-align: left;
  color: var(--text-primary); text-decoration: none; white-space: nowrap;
}
.sidebar .flyout-link i { font-size: 15px; color: var(--text-muted); width: 18px; text-align: center; }
.sidebar .flyout-link:hover { background: var(--body-bg); color: var(--text-primary); text-decoration: none; }
.sidebar .flyout-link.active { background: var(--primary-light); color: var(--primary-dark); }
.sidebar .flyout-link.active i { color: var(--primary); }

.sidebar .sidebar-user { justify-content: center; padding: 12px 0; }
.sidebar .sidebar-user .user-info { display: none; }
.sidebar .sidebar-user .user-avatar { width: 40px; height: 40px; font-size: 14px; }

/* ── Flyout sub-headings + two-line descriptive links ── */
.sidebar .rail-flyout { min-width: 244px; }
.sidebar .flyout-sub {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: #9aa0ad; padding: 9px 12px 3px;
}
.sidebar .flyout-sub:first-of-type { padding-top: 2px; }
.sidebar .flyout-link.desc { align-items: flex-start; white-space: normal; }
.sidebar .flyout-link.desc > i { margin-top: 2px; flex-shrink: 0; }
.sidebar .flyout-link .fl-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.sidebar .flyout-link .fl-label { font-weight: 600; }
.sidebar .flyout-link .fl-desc { font-size: 11px; color: var(--text-muted); font-weight: 400; }
.sidebar .flyout-link.desc.active .fl-desc { color: var(--primary-dark); }

/* ── Materials tabbed page (Inventory · Allocation · Deliveries) ── */
.materials-head { margin-bottom: 14px; }
.materials-head h2 { font-size: 22px; font-weight: 700; }
.materials-tabs { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
@media (max-width: 768px) {
  .materials-tabs { flex-wrap: nowrap !important; gap: 6px !important; overflow: visible !important; }
  .materials-tabs .mtab { flex: 1 !important; flex-direction: column !important; align-items: center !important; justify-content: center !important; gap: 4px !important; padding: 10px 4px !important; min-width: 0 !important; max-width: none !important; border-radius: 12px !important; text-align: center !important; }
  .materials-tabs .mtab i { font-size: 18px !important; margin-bottom: 0 !important; flex-shrink: 0 !important; }
  .materials-tabs .mtab .mtab-label { font-size: 11px !important; font-weight: 700 !important; white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important; width: 100% !important; }
  .materials-tabs .mtab .mtab-sub { display: none !important; }
  .materials-head h2 { font-size: 18px; }
  .materials-head p { font-size: 12px; }
}
.materials-tabs .mtab {
  display: flex; flex-direction: column; gap: 1px;
  padding: 11px 20px 12px; border-radius: 14px; text-decoration: none;
  background: #fff; border: 1px solid var(--border); color: var(--text-primary);
  min-width: 150px; transition: background .15s, border-color .15s, box-shadow .15s, transform .1s;
}
.materials-tabs .mtab i { font-size: 17px; color: var(--text-muted); margin-bottom: 4px; }
.materials-tabs .mtab .mtab-label { font-weight: 700; font-size: 14.5px; }
.materials-tabs .mtab .mtab-sub { font-size: 11px; color: var(--text-muted); }
.materials-tabs .mtab:hover { border-color: var(--primary); background: var(--primary-light); }
.materials-tabs .mtab.active {
  background: var(--primary); border-color: var(--primary); color: #fff;
  box-shadow: 0 10px 22px -8px rgba(232,124,30,.55);
}
.materials-tabs .mtab.active i,
.materials-tabs .mtab.active .mtab-sub { color: rgba(255,255,255,.88); }
.materials-actionbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.materials-actionbar .muted { font-size: 13px; color: var(--text-muted); }
.materials-actionbar .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Dashboard task launcher (#4) ── */
.task-launcher { padding: 20px 22px; margin-bottom: 24px; }
.task-launcher-head h3 { font-size: 16px; font-weight: 700; margin: 0; }
.task-launcher-head p { font-size: 13px; color: var(--text-muted); margin: 2px 0 16px; }
.task-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.task-btn {
  display: flex; align-items: center; gap: 13px; text-decoration: none;
  padding: 14px 16px; border-radius: 14px; background: var(--card-bg);
  border: 1px solid var(--border); transition: border-color .15s, box-shadow .15s, transform .1s;
}
.task-btn:hover { border-color: var(--primary); box-shadow: 0 8px 20px -10px rgba(17,24,39,.2); transform: translateY(-1px); }
.task-ico {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.task-txt { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.task-verb { font-weight: 700; font-size: 14px; color: var(--text-primary); }
.task-frs { font-size: 11.5px; color: var(--text-muted); }

/* ── Allocation wizard helpers ── */
.wiz-h { font-size: 16px; font-weight: 700; margin: 0 0 4px; color: var(--text-primary); }
.wiz-p { font-size: 13px; color: var(--text-muted); margin: 0 0 18px; }
.review-box { display: flex; flex-direction: column; gap: 2px; }
.review-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 11px 14px; border-radius: 10px; background: var(--body-bg); font-size: 13.5px;
}
.review-row span { color: var(--text-muted); }
.review-row strong { color: var(--text-primary); text-align: right; }
.input-error { border-color: #ef4444 !important; background: #fef2f2 !important; box-shadow: 0 0 0 3px rgba(239,68,68,.15) !important; }
.wizard-field-error { color: #ef4444; font-size: 12px; margin-top: 5px; display: flex; align-items: center; gap: 5px; font-weight: 500; }

/* ═══════════════════════════════════════════════════════════
   NOTIFICATIONS
   ═══════════════════════════════════════════════════════════ */

/* ── Sidebar bell badge ── */
.notif-icon-wrap { position: relative; }
.notif-badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 18px; height: 18px; padding: 0 4px;
  background: #ef4444; color: #fff;
  font-size: 10px; font-weight: 700; line-height: 18px;
  border-radius: 9px; text-align: center;
  box-shadow: 0 0 0 2px var(--sidebar-bg);
  pointer-events: none;
}
.notif-badge-inline {
  display: inline-block;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: #ef4444; color: #fff;
  font-size: 9px; font-weight: 700; line-height: 16px;
  border-radius: 8px; text-align: center;
  vertical-align: middle; margin-left: 4px;
}

/* ── Notification list ── */
.notif-list { display: flex; flex-direction: column; gap: 10px; max-width: 800px; }

.notif-card {
  display: flex; align-items: flex-start; gap: 16px;
  padding: 16px 20px; border-radius: var(--radius);
  background: var(--card-bg); border: 1px solid var(--border);
  box-shadow: var(--shadow); transition: box-shadow .15s;
}
.notif-card:hover { box-shadow: var(--shadow-md); }
.notif-card.notif-unread {
  border-left: 4px solid var(--primary);
  background: var(--primary-light);
}

.notif-icon-col { flex-shrink: 0; }
.notif-type-icon {
  display: flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; border-radius: 50%; font-size: 18px;
}
.notif-type-requested { background: #fff3e0; color: #e87c1e; }
.notif-type-approved  { background: #d1fae5; color: #059669; }
.notif-type-rejected  { background: #fee2e2; color: #dc2626; }
.notif-type-info      { background: #e0f2fe; color: #0369a1; }

.notif-body { flex: 1; min-width: 0; }
.notif-message { font-size: 14px; color: var(--text-primary); line-height: 1.5; margin-bottom: 6px; }
.notif-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.notif-time { font-size: 12px; color: var(--text-muted); }
.notif-tag {
  display: inline-block; padding: 2px 8px; border-radius: 6px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em;
}
.notif-tag-requested { background: #fff3e0; color: #c96a10; }
.notif-tag-approved  { background: #d1fae5; color: #065f46; }
.notif-tag-rejected  { background: #fee2e2; color: #991b1b; }
.notif-tag-info      { background: #e0f2fe; color: #075985; }

.btn-sm-link {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12.5px; color: var(--primary); font-weight: 500;
  text-decoration: none; padding: 3px 0;
}
.btn-sm-link:hover { text-decoration: underline; }

/* ── Empty state ── */
.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--text-muted);
}

/* ── Notification popup dropdown ── */
.notif-popup-wrap {
  position: relative;
  display: inline-flex;
}

.notif-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 360px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,.14);
  z-index: 1500;
  overflow: hidden;
  animation: notifSlideIn .15s ease;
}
.notif-dropdown.open { display: flex; flex-direction: column; }
@media (max-width: 768px) {
  .notif-dropdown {
    position: fixed !important;
    top: 62px !important;
    left: 8px !important;
    right: 8px !important;
    width: auto !important;
    border-radius: 14px !important;
    max-height: calc(100vh - 140px) !important;
  }
}

@keyframes notifSlideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.notif-dropdown-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
}
.notif-dropdown-title { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.notif-dropdown-count {
  font-size: 11px; font-weight: 700;
  background: #ef4444; color: #fff;
  padding: 2px 8px; border-radius: 20px;
}

.notif-dropdown-body {
  max-height: 360px; overflow-y: auto;
  display: flex; flex-direction: column;
}

.notif-dropdown-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--body-bg);
  transition: background .1s;
}
.notif-dropdown-item:last-child { border-bottom: none; }
.notif-dropdown-item:hover { background: var(--body-bg); }
.notif-dropdown-item--unread { background: var(--primary-light); }
.notif-dropdown-item--unread:hover { background: #fdebd5; }

/* ── Notification search bar ── */
.notif-search-wrap {
  position: relative;
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--border);
}
.notif-search-icon {
  position: absolute;
  left: 22px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 13px;
  pointer-events: none;
}
.notif-search-input {
  width: 100%;
  padding: 7px 10px 7px 32px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12.5px;
  background: var(--body-bg);
  color: var(--text-primary);
  outline: none;
  box-sizing: border-box;
  transition: border-color .15s;
}
.notif-search-input:focus { border-color: var(--primary); }

/* ── Sender avatar circle ── */
.notif-avatar {
  flex-shrink: 0;
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
  letter-spacing: 0.5px;
}
.notif-avatar--requested { background: #e87c1e; }
.notif-avatar--approved  { background: #16a34a; }
.notif-avatar--rejected  { background: #dc2626; }
.notif-avatar--info      { background: #0ea5e9; }

/* ── Item text layout ── */
.notif-dropdown-text { flex: 1; min-width: 0; }

.notif-sender-row {
  display: flex; align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 3px;
}
.notif-sender-name {
  font-size: 13px; font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1;
}
.notif-dropdown-msg {
  font-size: 12px; color: var(--text-muted);
  line-height: 1.4;
}
.notif-dropdown-time {
  font-size: 10.5px; color: var(--text-muted);
  white-space: nowrap;
}

/* ── Empty / no-results states ── */
.notif-dropdown-empty,
.notif-no-results {
  text-align: center; padding: 28px 16px;
  color: var(--text-muted); font-size: 13px;
}

.notif-dropdown-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  text-align: center;
}
.notif-dropdown-viewall {
  font-size: 13px; font-weight: 600;
  color: var(--primary); text-decoration: none;
  display: inline-flex; align-items: center; gap: 4px;
  background: none; border: none; cursor: pointer; padding: 0;
}
.notif-dropdown-viewall:hover { text-decoration: underline; }

/* ═══════════════════════════════════════════════════════════
   Notifications side drawer (Google-Docs-style right panel)
   ═══════════════════════════════════════════════════════════ */
.notif-drawer-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 2000;
  animation: backdropFadeIn .2s ease;
}
.notif-drawer-backdrop.open { display: block; }

@keyframes backdropFadeIn {
  from { opacity: 0; } to { opacity: 1; }
}

.notif-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 400px;
  max-width: 95vw;
  background: var(--card-bg);
  border-left: 1px solid var(--border);
  box-shadow: -6px 0 32px rgba(0,0,0,.18);
  z-index: 2100;
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform .25s cubic-bezier(.4,0,.2,1);
}
.notif-drawer.open { transform: translateX(0); }

/* Header */
.notif-drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.notif-drawer-title {
  font-size: 15px; font-weight: 700; color: var(--text-primary);
  display: flex; align-items: center; gap: 7px;
}
.notif-drawer-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 16px;
  padding: 4px 6px; border-radius: 6px;
  transition: background .15s, color .15s;
  display: flex; align-items: center;
}
.notif-drawer-close:hover { background: var(--body-bg); color: var(--text-primary); }

/* Search */
.notif-drawer-search-wrap {
  position: relative;
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.notif-drawer-search-icon {
  position: absolute; left: 27px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted); font-size: 13px;
  pointer-events: none;
}
.notif-drawer-search-input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border: 1px solid var(--border);
  border-radius: 22px;
  font-size: 13px;
  background: var(--body-bg);
  color: var(--text-primary);
  outline: none; box-sizing: border-box;
  transition: border-color .15s;
}
.notif-drawer-search-input:focus { border-color: var(--primary); }

/* ── Filter chips bar ── */
.notif-filter-bar {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 16px 8px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex-wrap: nowrap;
  flex-shrink: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.notif-filter-bar::-webkit-scrollbar { height: 3px; }
.notif-filter-bar::-webkit-scrollbar-track { background: transparent; }
.notif-filter-bar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.notif-filter-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 12px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  background: var(--card-bg);
  color: var(--text-muted);
  font-size: 12px; font-weight: 500;
  white-space: nowrap; cursor: pointer;
  flex-shrink: 0;
  transition: background .15s, border-color .15s, color .15s;
}
.notif-filter-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.notif-filter-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
/* Coloured accent for type chips when active */
.notif-filter-chip--requested.active { background: #e87c1e; border-color: #e87c1e; }
.notif-filter-chip--approved.active  { background: #16a34a; border-color: #16a34a; }
.notif-filter-chip--rejected.active  { background: #dc2626; border-color: #dc2626; }

/* ── Type tag badge inside each drawer item ── */
.notif-drawer-type-tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 600;
  padding: 2px 8px; border-radius: 12px;
  margin-bottom: 4px;
}
.notif-drawer-type-tag--requested { background: #fff3e8; color: #c05c00; }
.notif-drawer-type-tag--approved  { background: #f0fdf4; color: #15803d; }
.notif-drawer-type-tag--rejected  { background: #fef2f2; color: #b91c1c; }
.notif-drawer-type-tag--info      { background: #e0f2fe; color: #075985; }

/* Body / scroll area */
.notif-drawer-body {
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column;
}

/* Each notification row */
.notif-drawer-item {
  display: flex; align-items: flex-start; gap: 13px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--body-bg);
  transition: background .12s;
}
.notif-drawer-item:last-child { border-bottom: none; }
.notif-drawer-item:hover { background: var(--body-bg); }
.notif-drawer-item--unread { background: var(--primary-light); }
.notif-drawer-item--unread:hover { background: #fdebd5; }

.notif-drawer-text { flex: 1; min-width: 0; }

.notif-drawer-sender-row {
  display: flex; align-items: baseline;
  justify-content: space-between; gap: 8px;
  margin-bottom: 4px;
}
.notif-drawer-sender {
  font-size: 13.5px; font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1;
}
.notif-drawer-time {
  font-size: 11px; color: var(--text-muted);
  white-space: nowrap;
}
.notif-drawer-msg {
  font-size: 12.5px; color: var(--text-muted);
  line-height: 1.45;
}

/* Empty / no-results */
.notif-drawer-empty,
.notif-drawer-no-results {
  text-align: center; padding: 48px 24px;
  color: var(--text-muted); font-size: 14px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   PREMIUM VISUAL LANGUAGE — matches login-page design feel on internal pages.
   Playfair Display headings, richer warm-glowing card shadows, accented stat
   tiles, page entrance animation, upgraded topbar.
   Appended last — overrides all earlier rules via cascade.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Warm parchment body background ── */
body:not(.login-page-body) {
  background: linear-gradient(160deg, #f4f0ec 0%, #f6f3ef 55%, #f3f4f6 100%);
}

/* ── Playfair Display for all page-level headings ── */
.page-header h2 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.015em;
  color: var(--text-primary);
}

/* ── Topbar: Playfair Display page title + cleaner shadow ── */
.topbar {
  background: #ffffff;
  box-shadow: 0 1px 0 var(--border), 0 2px 16px rgba(17,24,39,.05);
}
.topbar-left .page-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.01em;
}

/* ── Cards: white rim highlight + warm orange micro-glow ── */
.card {
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.80),
    0 2px 8px rgba(26,16,8,.06),
    0 6px 20px rgba(26,16,8,.05),
    0 0 40px rgba(232,124,30,.03);
  border-radius: 16px;
}
.card:hover {
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.90),
    0 4px 14px rgba(26,16,8,.09),
    0 10px 30px rgba(26,16,8,.07),
    0 0 48px rgba(232,124,30,.06);
}

/* ── Stat cards: orange gradient top accent + Playfair number + hover lift ── */
.stat-card {
  position: relative;
  overflow: hidden;
  padding: 22px 20px 20px;
  border-radius: 16px;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.80),
    0 2px 8px rgba(26,16,8,.06),
    0 6px 20px rgba(26,16,8,.05);
  transition: transform .20s ease, box-shadow .20s ease;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, #f59332 0%, #e87c1e 60%, #c96a10 100%);
  border-radius: 16px 16px 0 0;
}
.stat-card:hover {
  transform: translateY(-3px);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.90),
    0 6px 20px rgba(26,16,8,.10),
    0 12px 36px rgba(26,16,8,.08),
    0 0 50px rgba(232,124,30,.08);
}
.stat-card .stat-value {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -.025em;
  line-height: 1.1;
  color: var(--text-primary);
  margin-bottom: 3px;
}
.stat-card.is-warn  .stat-value { color: var(--warning); }
.stat-card.is-alert .stat-value { color: var(--danger); }
.stat-card .stat-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
}
.stat-card .stat-icon { border-radius: 14px; }

/* ── Page body: smooth entrance animation on every navigation ── */
@keyframes pageEnter {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.page-body { animation: pageEnter .38s cubic-bezier(.22,1,.36,1) both; }

/* ── ALL card h3: Playfair Display ── */
.card h3,
.card-header h3 {
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 700;
}

/* ── Card headers: orange-tinted divider, variable background ── */
.card-header {
  background: var(--card-bg);
  border-bottom: 1px solid rgba(232, 124, 30, 0.12);
}

/* ── Topbar: warm orange sunrise fade ── */
.topbar {
  background: linear-gradient(180deg, #fffaf6 0%, #ffffff 65%);
  border-bottom: 1px solid rgba(232, 124, 30, 0.14);
  box-shadow: 0 2px 24px rgba(232, 124, 30, 0.07);
}

/* ── Sidebar: orange brand accent strip at very top ── */
.sidebar::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, #c96a10 0%, #e87c1e 50%, #f59332 100%);
  z-index: 101;
}

/* ── Stat icons (neutral): gradient + warm glow ── */
.stat-card .stat-icon.neutral {
  background: linear-gradient(135deg, #fff3e0 0%, #ffd9a0 100%);
  color: #bf6012;
  box-shadow: 0 4px 14px rgba(232, 124, 30, 0.22);
}

/* ── Task launcher icon circles: warm glow + hover scale ── */
.task-ico {
  box-shadow: 0 4px 12px rgba(232, 124, 30, 0.16);
  transition: transform .18s ease, box-shadow .18s ease;
}
.task-btn:hover .task-ico {
  transform: scale(1.08);
  box-shadow: 0 6px 18px rgba(232, 124, 30, 0.28);
}

/* ── Task launcher h3 label ── */
.task-launcher-head h3 {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 17px;
}

/* ── Table: warm header tint + orange accent on hover row ── */
thead th {
  background: linear-gradient(180deg, #fff8f2 0%, #fdf4ee 100%);
  color: #7a5a40;
}
tbody tr:hover { background: #fff8f3; }

/* ── Btn-primary: richer glow ── */
.btn-primary {
  background: linear-gradient(135deg, #f59332 0%, #e87c1e 50%, #c96a10 100%);
  box-shadow: 0 8px 22px -8px rgba(232, 124, 30, 0.60),
              inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #f59d46 0%, #e87c1e 50%, #c05c00 100%);
  box-shadow: 0 10px 26px -6px rgba(232, 124, 30, 0.70),
              inset 0 1px 0 rgba(255, 255, 255, 0.25);
  text-decoration: none; color: #fff;
}

/* ── Chips: orange-tinted border, variable background ── */
.chip {
  background: var(--card-bg);
  border-color: rgba(232, 124, 30, 0.22);
  box-shadow: 0 1px 4px rgba(232, 124, 30, 0.08);
  color: var(--text-primary);
}

/* ── Active nav item: stronger glow ── */
.sidebar .rail-item.active .nav-icon,
.sidebar .rail-group.group-active > .rail-toggle .nav-icon {
  box-shadow: 0 6px 20px -4px rgba(232, 124, 30, 0.70);
}

/* ── Logout button: more premium ── */
.btn-logout {
  background: linear-gradient(135deg, #fff8f2 0%, #fff0e4 100%);
  border-color: rgba(232, 124, 30, 0.30);
  box-shadow: 0 2px 8px rgba(232, 124, 30, 0.10);
}
.btn-logout:hover {
  background: linear-gradient(135deg, #fff0e4 0%, #ffe3cc 100%);
  border-color: rgba(232, 124, 30, 0.45);
  color: var(--primary-dark);
}

/* ═══════════════════════════════════════════════════════════════════════════
   P0 UX FIXES — 2026-06-18  (revised)
   C2: Expand/collapse chevron indicator (JS-driven .is-open class)
   C1: Mobile navigation drawer
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────
   C2 — CHEVRON INDICATOR
   Rotation is driven purely by CSS, responding to
   .rail-group.open (set by JS on toggleFlyout).
   No inline style.transform is used — CSS is the
   single source of truth for the visual state.
   ───────────────────────────────────────────────── */

.sidebar .rail-chevron {
  display: inline-block;
  font-size: 13px;
  line-height: 1;
  color: rgba(168,144,112,.7);
  margin-top: 2px;
  flex-shrink: 0;
  /* explicit base — gives the browser a FROM value for the transition */
  transform: rotate(0deg);
  transition: transform .25s ease, color .2s ease;
}

/* OPEN STATE — driven by the group class, not by JS inline style.
   .rail-group.open is set by toggleFlyout(); that class is already
   controlling the flyout panel visibility so we know it works. */
.sidebar .rail-group.open > .rail-toggle .rail-chevron {
  transform: rotate(90deg);
  color: var(--sidebar-active);
}

/* Mobile row layout: right-align the chevron inside the horizontal row */
@media (max-width: 768px) {
  .sidebar.open .rail-chevron {
    margin-left: auto;
    margin-top: 0;
  }
}

/* Hover feedback */
.sidebar .rail-toggle:hover .rail-chevron {
  color: #f3d9bd;
  opacity: 1;
}

/* ─────────────────────────────────────────────────
   C2 — FULL-WIDTH CLICK TARGET (desktop rail)
   Buttons expand to the full sidebar width so the
   entire row is clickable, not just a 64px button.
   ───────────────────────────────────────────────── */

.sidebar .rail-group {
  width: 100%;
}
.sidebar .rail-toggle {
  width: calc(100% - 8px);   /* full sidebar width minus small side margins */
  margin: 1px 4px;
  border-radius: 14px;
  cursor: pointer;
}
/* Direct nav links: also full-width */
.sidebar .rail-item {
  width: calc(100% - 8px);
  margin: 1px 4px;
  border-radius: 14px;
}

/* ─────────────────────────────────────────────────
   C2 — ICON HOVER: subtle scale
   ───────────────────────────────────────────────── */
.sidebar .rail-item .nav-icon,
.sidebar .rail-toggle .nav-icon {
  transition: background .18s, color .18s, box-shadow .18s, transform .18s;
}
.sidebar .rail-item:hover .nav-icon,
.sidebar .rail-toggle:hover .nav-icon {
  transform: scale(1.09);
}

/* ─────────────────────────────────────────────────
   C2 — OPEN STATE: orange left-edge accent bar
   ───────────────────────────────────────────────── */
.sidebar .rail-group.open > .rail-toggle {
  position: relative;
}
.sidebar .rail-group.open > .rail-toggle::after {
  content: "";
  position: absolute;
  left: -4px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 28px;
  border-radius: 0 3px 3px 0;
  background: var(--sidebar-active);
  box-shadow: 0 0 10px rgba(232,124,30,.55);
}

/* ─────────────────────────────────────────────────
   C2 — FLYOUT PANEL: premium shadow + slide-in
   ───────────────────────────────────────────────── */
.sidebar .rail-flyout {
  border-radius: 18px;
  border: 1px solid rgba(0,0,0,.06);
  box-shadow: 0 24px 64px -12px rgba(0,0,0,.28),
              0 8px 24px -4px rgba(0,0,0,.14),
              0 0 0 1px rgba(0,0,0,.03);
  padding: 6px;
  background: var(--card-bg);
  transform: translateX(-10px) scale(.96);
  transform-origin: left center;
  transition: opacity .2s ease,
              transform .22s cubic-bezier(.16,1,.3,1),
              visibility .2s;
}
.sidebar .rail-group.open .rail-flyout {
  transform: translateX(0) scale(1);
}

/* Flyout title: orange gradient accent */
.sidebar .flyout-title {
  background: linear-gradient(90deg, var(--primary-light) 0%, transparent 80%);
  border-radius: 10px;
  color: var(--primary);
  font-size: 10.5px;
  font-weight: 700;
  padding: 6px 12px 6px;
  margin-bottom: 4px;
  letter-spacing: .06em;
}

/* Flyout links: sliding left-bar on hover */
.sidebar .flyout-link {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  transition: background .15s, color .15s, padding-left .18s ease;
}
.sidebar .flyout-link::after {
  content: "";
  position: absolute;
  left: 0; top: 18%; bottom: 18%;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--primary);
  opacity: 0;
  transition: opacity .15s;
}
.sidebar .flyout-link:hover::after,
.sidebar .flyout-link.active::after { opacity: 1; }
.sidebar .flyout-link:hover { padding-left: 16px; background: var(--body-bg); }
.sidebar .flyout-link:hover i,
.sidebar .flyout-link:hover .fl-label { color: var(--primary); }

/* ─────────────────────────────────────────────────
   C1 — HAMBURGER BUTTON
   ───────────────────────────────────────────────── */
.sidebar-toggle {
  display: none;            /* shown only on mobile */
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  color: var(--text-primary);
  font-size: 20px;
  transition: background .15s, border-color .15s, color .15s;
  flex-shrink: 0;
}
.sidebar-toggle:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

/* ─────────────────────────────────────────────────
   C1 — MOBILE DRAWER
   ───────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar-toggle { display: flex; }

  .sidebar {
    left: -290px;
    width: 290px;
    transition: left .28s cubic-bezier(.16,1,.3,1), box-shadow .28s;
    z-index: 150;
  }
  .sidebar.open {
    left: 0;
    box-shadow: 8px 0 40px rgba(0,0,0,.40);
  }
  #sidebar-overlay { z-index: 140; cursor: pointer; }
  .main-content { margin-left: 0; }

  /* Brand header */
  .sidebar.open .sidebar-brand .brand-text { display: block; }
  .sidebar.open .sidebar-brand {
    justify-content: flex-start;
    padding: 18px 18px 12px;
    border-bottom: 1px solid rgba(255,255,255,.07);
    margin-bottom: 6px;
  }
  .sidebar.open .sidebar-brand .brand-icon { width: 44px; height: 44px; border-radius: 12px; }
  .sidebar.open .sidebar-brand .brand-name { font-size: 15px; font-weight: 700; }
  .sidebar.open .sidebar-brand .brand-sub  { font-size: 10px; opacity: .6; }

  /* Full-width horizontal rows */
  .sidebar.open .rail-item,
  .sidebar.open .rail-toggle {
    flex-direction: row;
    width: calc(100% - 20px);
    margin: 2px 10px;
    padding: 12px 14px;
    gap: 14px;
    border-radius: 12px;
    justify-content: flex-start;
    font-size: 14px;
  }
  .sidebar.open .rail-item .nav-icon,
  .sidebar.open .rail-toggle .nav-icon { width: 36px; height: 36px; flex-shrink: 0; }
  .sidebar.open .rail-label {
    display: block !important;
    font-size: 14px; font-weight: 600; white-space: nowrap;
  }
  .sidebar.open .rail-group { align-items: stretch; }

  /* Left bar: hide on mobile */
  .sidebar.open .rail-group.open > .rail-toggle::after { display: none; }

  /* Chevron on mobile: right-aligned, inherits .is-open rotation */
  .sidebar.open .rail-chevron {
    font-size: 12px;
    margin-left: auto;
    margin-top: 0;
  }

  /* Flyouts: inline accordion — visibility depends ONLY on .rail-group.open,
     NOT on .sidebar.open, so scrolling never causes a collapse. */
  .sidebar .rail-flyout {
    position: static !important;
    left: auto !important;
    top: auto !important;
    opacity: 0;
    visibility: hidden;
    max-height: 0;
    overflow: hidden;
    transform: none !important;
    box-shadow: none;
    border: none;
    border-left: 2px solid rgba(232,124,30,.35);
    background: rgba(255,255,255,.04);
    margin: 0 10px 4px 24px;
    border-radius: 0 10px 10px 0;
    padding: 0 !important;
    min-width: 0;
    transition: max-height .32s cubic-bezier(.16,1,.3,1),
                opacity .22s ease,
                visibility .22s;
    z-index: auto;
  }
  .rail-group.open .rail-flyout {
    opacity: 1;
    visibility: visible;
    max-height: 700px;
    padding: 6px 6px 8px !important;
  }
  .sidebar .rail-flyout::before { display: none; }

  /* Mobile flyout content */
  .sidebar .flyout-title {
    background: none;
    border-bottom: none;
    font-size: 10px;
    padding: 6px 12px 4px;
    color: rgba(232,124,30,.85);
    letter-spacing: .07em;
  }
  .sidebar .flyout-link {
    white-space: normal;
    border-radius: 8px;
    font-size: 13.5px;
    padding: 10px 12px;
    color: rgba(255,255,255,.8);
  }
  .sidebar .flyout-link:hover { padding-left: 16px; color: #fff; }
  .sidebar .flyout-link .fl-desc { color: rgba(255,255,255,.45); }
  .sidebar .flyout-link.active { background: rgba(232,124,30,.22); color: #fff; }
  .sidebar .flyout-link.active .fl-label { color: #fff; }
  .sidebar .flyout-link.active .fl-desc { color: rgba(255,255,255,.55); }

  /* User panel */
  .sidebar.open .sidebar-user {
    justify-content: flex-start;
    padding: 14px 18px;
    border-top: 1px solid rgba(255,255,255,.07);
    margin-top: 6px;
  }
  .sidebar.open .sidebar-user .user-info  { display: flex; flex-direction: column; }
  .sidebar.open .sidebar-user .user-avatar { width: 38px; height: 38px; font-size: 13px; }
}


/* ── U2: Toast notifications — appear at top right, near the bell ── */
.alert {
  position: fixed;
  top: 72px; right: 16px;
  bottom: auto;
  z-index: 2000;
  min-width: 180px; max-width: 300px;
  border-radius: 10px;
  padding: 10px 14px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,.12), 0 2px 6px rgba(0,0,0,.07);
  animation: toast-in .35s cubic-bezier(.16,1,.3,1) forwards;
  font-size: 13px; font-weight: 500;
  cursor: pointer;
}
@keyframes toast-in {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-error, .alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.alert .alert-close {
  margin-left: auto; background: none; border: none; cursor: pointer;
  font-size: 16px; color: inherit; opacity: .6; padding: 0; line-height: 1;
}
.alert .alert-close:hover { opacity: 1; }

/* ── D2: Zebra striping for list pages ── */
tbody.list-rows tr:nth-child(even) {
  background: rgba(0,0,0,.018);
}
.dark-mode tbody.list-rows tr:nth-child(even) {
  background: rgba(255,255,255,.025);
}
tbody.list-rows tr:hover {
  background: var(--primary-light) !important;
  transition: background .12s;
}

/* ── D3: Card header sizing ── */
.card-header h3 { font-size: 15px; font-weight: 700; }
.card-header h2 { font-size: 17px; font-weight: 700; }

/* ── U6: FAQ answer highlight ── */
.faq-answer mark { background: #fef08a; color: inherit; border-radius: 2px; padding: 0 2px; }

/* ════════════════════════════════════════════════════════════════════════════
   SIDEBAR REDESIGN — 2026
   Replaces the compact 92px icon rail with a full 220px navigation sidebar.
   Row-layout items, orange accent indicators, smooth hover, visible labels.
   Appended last so every rule here overrides the earlier icon-rail block.
   ════════════════════════════════════════════════════════════════════════════ */

/* ── 1. Sidebar width ── */
:root { --sidebar-width: 220px; }

/* ── 2. Brand header: show name + sub on desktop ── */
.sidebar .sidebar-brand {
  justify-content: flex-start;
  padding: 20px 16px 14px;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  margin-bottom: 4px;
}
.sidebar .sidebar-brand .brand-text { display: block; }
.sidebar .sidebar-brand .brand-icon {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
}
.sidebar .sidebar-brand .brand-name { font-size: 14px; font-weight: 700; color: #fff; }
.sidebar .sidebar-brand .brand-sub  { font-size: 10px; opacity: .5; }

/* ── 3. Nav container: stretch children full-width ── */
.sidebar .sidebar-nav {
  align-items: stretch;
  padding: 6px 0;
  gap: 1px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
}

/* ── 4. Section label ── */
.sidebar .nav-section {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(168,144,112,.4);
  padding: 10px 20px 3px;
  pointer-events: none;
  user-select: none;
}

/* ── 5. Core item shape: horizontal row ── */
.sidebar .rail-item,
.sidebar .rail-toggle {
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 9px 14px;
  width: calc(100% - 12px);
  margin: 1px 6px;
  border-radius: 10px;
  text-align: left;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.2;
  position: relative;
  overflow: visible;
  transition: background .18s ease, color .18s ease;
}

/* ── 6. Icon pill ── */
.sidebar .rail-item .nav-icon,
.sidebar .rail-toggle .nav-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  flex-shrink: 0;
  font-size: 14px;
  background: rgba(255,255,255,.07);
  transition: background .18s ease, color .18s ease, box-shadow .18s ease, transform .18s ease;
}

/* ── 7. Label ── */
.sidebar .rail-label {
  flex: 1;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

/* ── 8. Spacer divider (between main nav and utility links) ── */
.sidebar .rail-spacer {
  height: 1px;
  background: rgba(255,255,255,.06);
  margin: 8px 16px;
  min-height: unset;
  flex: unset;
}

/* ── 9. Hover state ── */
.sidebar .rail-item:hover,
.sidebar .rail-toggle:hover {
  background: rgba(255,255,255,.06);
  color: #f5dfc0;
}
.sidebar .rail-item:hover .nav-icon,
.sidebar .rail-toggle:hover .nav-icon {
  background: rgba(232,124,30,.18);
  color: #e87c1e;
  transform: scale(1.07);
}

/* ── 10. Active direct link ── */
.sidebar .rail-item.active {
  background: rgba(232,124,30,.14);
  color: #fff;
  font-weight: 600;
}
.sidebar .rail-item.active .nav-icon {
  background: var(--sidebar-active);
  color: #fff;
  box-shadow: 0 4px 14px -4px rgba(232,124,30,.7);
  transform: scale(1);
}

/* Orange left accent bar — active link */
.sidebar .rail-item.active::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 18%; bottom: 18%;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--sidebar-active);
  box-shadow: 0 0 10px rgba(232,124,30,.55);
}

/* ── 11. Open / active expandable group ── */
.sidebar .rail-group.group-active > .rail-toggle {
  background: rgba(232,124,30,.14);
  color: #fff;
  font-weight: 600;
}
.sidebar .rail-group.group-active > .rail-toggle .nav-icon {
  background: var(--sidebar-active);
  color: #fff;
  box-shadow: 0 4px 14px -4px rgba(232,124,30,.7);
}

/* Orange left accent bar — active group only */
.sidebar .rail-group.group-active > .rail-toggle::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 18%; bottom: 18%;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--sidebar-active);
  box-shadow: 0 0 10px rgba(232,124,30,.55);
}
/* Suppress the old ::after accent bar */
.sidebar .rail-group.open > .rail-toggle::after { display: none; }

/* ── 12. User panel: show full name + role on desktop ── */
.sidebar .sidebar-user {
  justify-content: flex-start;
  padding: 12px 16px;
  gap: 10px;
  border-top: 1px solid rgba(255,255,255,.06);
  margin-top: 4px;
}
.sidebar .sidebar-user .user-info  { display: flex; flex-direction: column; }
.sidebar .sidebar-user .user-avatar { width: 36px; height: 36px; font-size: 12px; flex-shrink: 0; border-radius: 10px; }
.sidebar .sidebar-user .user-name  { font-size: 13px; font-weight: 600; color: #fff; }
.sidebar .sidebar-user .user-role  { font-size: 11px; color: rgba(168,144,112,.7); }

/* ── 13. Flyout panel redesign ── */
.sidebar .rail-flyout {
  min-width: 248px;
  padding: 8px;
  border-radius: 16px;
  border: 1px solid rgba(0,0,0,.08);
  background: #fff;
  box-shadow:
    0 20px 48px -12px rgba(0,0,0,.22),
    0 8px 20px -4px rgba(0,0,0,.10),
    0 0 0 1px rgba(0,0,0,.04);
  /* reset old scale transform */
  transform: translateX(-8px) scale(.97);
  transform-origin: left center;
  transition: opacity .18s ease, transform .2s cubic-bezier(.16,1,.3,1), visibility .18s;
}
.dark-mode .sidebar .rail-flyout { background: #1e2130; border-color: rgba(255,255,255,.08); }
.sidebar .rail-group.open .rail-flyout {
  transform: translateX(0) scale(1);
}

/* Flyout title */
.sidebar .flyout-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--primary);
  padding: 5px 12px 8px;
  border-bottom: 1px solid rgba(232,124,30,.12);
  margin-bottom: 4px;
  background: transparent;
  border-radius: 0;
}

/* Flyout links */
.sidebar .flyout-link {
  font-size: 13.5px;
  font-weight: 500;
  padding: 9px 13px;
  border-radius: 9px;
  gap: 12px;
  color: #1e293b;
  transition: background .15s ease, color .15s ease, padding-left .18s ease;
  overflow: hidden;
  position: relative;
}
.dark-mode .sidebar .flyout-link { color: #e2e8f0; }

.sidebar .flyout-link i  { font-size: 15px; color: #64748b; width: 18px; text-align: center; flex-shrink: 0; }
.dark-mode .sidebar .flyout-link i { color: #94a3b8; }

.sidebar .flyout-link:hover {
  background: #fff7ed;
  color: #9a3d08;
  padding-left: 18px;
}
.dark-mode .sidebar .flyout-link:hover { background: rgba(232,124,30,.12); color: #f5dfc0; }
.sidebar .flyout-link:hover i { color: var(--primary); }

.sidebar .flyout-link.active {
  background: #fff7ed;
  color: #9a3d08;
  font-weight: 600;
}
.dark-mode .sidebar .flyout-link.active { background: rgba(232,124,30,.15); color: #f5dfc0; }
.sidebar .flyout-link.active i { color: var(--primary); }

/* Left bar on hover / active */
.sidebar .flyout-link::after {
  content: "";
  position: absolute;
  left: 0; top: 16%; bottom: 16%;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--primary);
  opacity: 0;
  transition: opacity .15s;
}
.sidebar .flyout-link:hover::after,
.sidebar .flyout-link.active::after { opacity: 1; }

/* Descriptive sub-text */
.sidebar .flyout-link .fl-label { font-size: 13.5px; font-weight: 600; color: #1e293b; }
.dark-mode .sidebar .flyout-link .fl-label { color: #e2e8f0; }
.sidebar .flyout-link .fl-desc  { font-size: 11px; color: #94a3b8; font-weight: 400; margin-top: 1px; }
.sidebar .flyout-link:hover .fl-label,
.sidebar .flyout-link.active .fl-label { color: #9a3d08; }
.dark-mode .sidebar .flyout-link:hover .fl-label,
.dark-mode .sidebar .flyout-link.active .fl-label { color: #f5dfc0; }

/* ── 14. Mobile: 290px drawer, override width/position ── */
@media (max-width: 768px) {
  :root { --sidebar-width: 0px; }
  .sidebar { width: 290px; left: -290px; }
  .sidebar.open { left: 0; box-shadow: 8px 0 40px rgba(0,0,0,.42); }
  .main-content { margin-left: 0 !important; }

  .sidebar.open .rail-item,
  .sidebar.open .rail-toggle {
    padding: 11px 16px;
    font-size: 14px;
    width: calc(100% - 16px);
    margin: 1px 8px;
  }

  /* Mobile flyout: inline accordion — depends ONLY on .rail-group.open,
     never on .sidebar.open, so scrolling cannot collapse the dropdown. */
  .sidebar .rail-flyout {
    position: static !important;
    left: auto !important; top: auto !important;
    transform: none !important;
    opacity: 0;
    visibility: hidden;
    max-height: 0;
    overflow: hidden;
    box-shadow: none;
    border: none;
    border-radius: 0;
    border-left: 2px solid rgba(232,124,30,.3);
    background: rgba(255,255,255,.03);
    margin: 2px 10px 4px 28px;
    padding: 0 !important;
    transition: max-height .3s cubic-bezier(.16,1,.3,1), opacity .22s ease, visibility .22s;
  }
  .rail-group.open .rail-flyout {
    opacity: 1; visibility: visible; max-height: 600px;
    padding: 6px 6px 8px !important;
  }
  .sidebar .rail-flyout::before { display: none; }

  .sidebar .flyout-title {
    font-size: 9.5px; padding: 4px 10px 6px; border-bottom: none;
  }
  .sidebar .flyout-link {
    font-size: 13px; padding: 7px 10px; color: rgba(255,255,255,.75);
  }
  .sidebar .flyout-link:hover { color: #fff; background: rgba(255,255,255,.07); padding-left: 14px; }
  .sidebar .flyout-link i { color: rgba(255,255,255,.45); }
  .sidebar .flyout-link .fl-label { color: rgba(255,255,255,.85); }
  .sidebar .flyout-link .fl-desc  { color: rgba(255,255,255,.4); }
}

/* ── Fix: push Help/Settings/My Rights to bottom of sidebar ── */
.sidebar .rail-spacer {
  flex: 1 1 auto;
  min-height: 16px;
  height: auto;
  background: transparent;
  border-top: 1px solid rgba(255,255,255,.06);
  margin: 8px 16px 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE — 2026
   Responsive layouts, camera-capture upload zones, compressed topbar,
   stacking two-column grids.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Visibility utilities ── */
.mobile-only  { display: none !important; }
.desktop-only { display: block !important; }

/* ── Mobile bottom navigation ── */
.mob-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 60px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
  z-index: 200;
  justify-content: space-around;
  align-items: stretch;
}
.mob-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex: 1;
  padding: 6px 0;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
  transition: color .15s;
  position: relative;
}
.mob-nav-item i { font-size: 20px; line-height: 1; }
.mob-nav-item.active,
.mob-nav-item:active { color: var(--primary); }
.mob-nav-badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 18px);
  background: #ef4444;
  color: #fff;
  border-radius: 8px;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  min-width: 15px;
  text-align: center;
  line-height: 14px;
}

/* ── Stat card as link ── */
a.stat-card {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
a.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
}
a.stat-card:active { transform: translateY(0); }

/* ── Reusable content + sidebar two-column layout ── */
.content-sidebar-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 20px;
}

/* ── Mobile-friendly file upload zone ── */
.upload-zone { display: flex; flex-direction: column; gap: 10px; }
.upload-zone > input[type="file"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  height: 0;
  width: 0;
  overflow: hidden;
}
.upload-btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.upload-filename-hint {
  font-size: 12px;
  color: var(--text-muted);
  word-break: break-all;
  min-height: 18px;
  padding: 2px 0;
}
.upload-preview-img {
  display: none;
  margin-top: 4px;
  max-height: 180px;
  border-radius: 8px;
  border: 1px solid var(--border);
  object-fit: cover;
  width: 100%;
  max-width: 340px;
}
.btn-take-photo {
  background: #059669 !important;
  color: #fff !important;
  border-color: #059669 !important;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-take-photo:hover { background: #047857 !important; border-color: #047857 !important; }

/* ─────────────────────────────────────────────
   768 px breakpoint — main mobile layout
   ───────────────────────────────────────────── */
@media (max-width: 768px) {

  /* Visibility utilities */
  .mobile-only  { display: inline-flex !important; }
  .desktop-only { display: none  !important; }

  /* ── Global overflow guard ── */
  body, .app-wrapper, .main-content, .page-body { overflow-x: hidden !important; }

  /* ── Bottom nav: visible on mobile ── */
  .mob-bottom-nav { display: flex; }
  /* Add space at bottom so content isn't hidden behind the nav bar */
  .page-body { padding-bottom: 72px !important; }

  /* ── Topbar title + breadcrumb: never let them push the layout wider ── */
  .topbar { overflow: hidden; padding: 0 12px; }
  .topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; overflow: hidden; }
  .topbar-left > div { min-width: 0; flex: 1; overflow: hidden; }
  .topbar-left .page-title {
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    display: block; max-width: 100%; font-size: 13px; font-weight: 600;
  }
  .topbar-left .breadcrumb {
    white-space: normal; overflow: visible;
    display: block; max-width: 100%; line-height: 1.3;
  }
  .sidebar-toggle { width: 36px; height: 36px; flex-shrink: 0; border-radius: 8px; }

  /* ── Card headings: wrap instead of overflow ── */
  .card h2, .card h3, .card h4,
  .card-header h2, .card-header h3 { word-break: break-word; min-width: 0; max-width: 100%; }
  .page-header h2, .page-header p  { word-break: break-word; max-width: 100%; }

  /* ── Images and media ── */
  img, video, iframe, object, embed { max-width: 100% !important; height: auto; }

  /* ── All form inputs ── */
  input, textarea, select { max-width: 100%; box-sizing: border-box; }

  /* ── Collapse ALL hard-coded two-column inline grids ──
     Targets every template that uses inline style="display:grid;grid-template-columns:..."
     so we don't have to edit each template individually. */
  [style*="grid-template-columns:1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns:1fr 300px"],
  [style*="grid-template-columns: 1fr 300px"],
  [style*="grid-template-columns:1fr 320px"],
  [style*="grid-template-columns: 1fr 320px"],
  [style*="grid-template-columns:1fr 340px"],
  [style*="grid-template-columns: 1fr 340px"],
  [style*="grid-template-columns:1fr 260px"],
  [style*="grid-template-columns: 1fr 260px"],
  [style*="grid-template-columns:1fr 280px"],
  [style*="grid-template-columns: 1fr 280px"],
  [style*="grid-template-columns:1fr 360px"],
  [style*="grid-template-columns: 1fr 360px"],
  [style*="grid-template-columns:1fr 380px"],
  [style*="grid-template-columns: 1fr 380px"],
  [style*="grid-template-columns:1fr 400px"],
  [style*="grid-template-columns: 1fr 400px"],
  [style*="grid-template-columns:2fr 1fr"],
  [style*="grid-template-columns: 2fr 1fr"],
  [style*="grid-template-columns:3fr 1fr"],
  [style*="grid-template-columns: 3fr 1fr"],
  [style*="grid-template-columns:1fr auto"],
  [style*="grid-template-columns: 1fr auto"],
  [style*="grid-template-columns:auto 1fr"],
  [style*="grid-template-columns: auto 1fr"],
  [style*="grid-template-columns:repeat(2"],
  [style*="grid-template-columns: repeat(2"] {
    grid-template-columns: 1fr !important;
  }

  /* ── Content + sidebar: stack vertically ── */
  .content-sidebar-layout { grid-template-columns: 1fr !important; }

  /* ── Page header: stack heading and action button ── */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .page-header h2 { font-size: 18px; }
  .page-header > a,
  .page-header > div > a { align-self: flex-start; }

  /* ── Topbar: compress on mobile ── */
  .topbar-time { display: none; }
  .btn-logout  { font-size: 0; padding: 8px 10px; }
  .btn-logout i { font-size: 15px; }

  /* ── Topbar: reduce right-side padding ── */
  .topbar { padding: 0 12px; }
  .topbar-left { gap: 8px; }

  /* ── Wizard progress bar: compact and wrapping ── */
  .wizard-progress { flex-wrap: wrap; gap: 6px 4px; padding: 12px 14px; }
  .wizard-step     { font-size: 11px; padding: 5px 10px; gap: 5px; }
  .wizard-connector { min-width: 10px; flex-shrink: 1; }

  /* ── Wizard nav: full-width stacked buttons ── */
  .wizard-nav {
    flex-direction: column-reverse;
    gap: 8px;
  }
  .wizard-nav > button,
  .wizard-nav > a {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  /* ── Toast alerts: top of screen on mobile, near the bell ── */
  .alert {
    top: 68px !important;
    left: 12px !important;
    right: 12px !important;
    bottom: auto !important;
    min-width: unset;
    max-width: unset;
  }

  /* ── Upload zone buttons: stack on mobile ── */
  .upload-btns { flex-direction: column; }
  .upload-btns > button { width: 100%; justify-content: center; }
  .upload-preview-img  { max-width: 100%; }

  /* ── Card padding: tighter on mobile ── */
  .card-body { padding: 14px 16px; }
  .page-body { padding: 12px; }

  /* ── Form submit row: full width ── */
  .form-submit-row {
    flex-direction: column;
    gap: 8px;
  }
  .form-submit-row > * { width: 100%; justify-content: center; text-align: center; }

  /* ════════════════════════════════════════════════════
     MOBILE SIDEBAR DRAWER OVERRIDES
     Desktop sidebar is a narrow centered rail; on mobile
     it slides in as a full drawer — reset to row layout.
     ════════════════════════════════════════════════════ */
  .sidebar {
    align-items: stretch !important;
    width: 290px !important;
  }

  /* Brand: left-aligned, show text */
  .sidebar .sidebar-brand {
    justify-content: flex-start !important;
    padding: 20px 18px 16px !important;
    gap: 12px !important;
  }
  .sidebar .sidebar-brand .brand-text { display: block !important; }
  .sidebar .sidebar-brand .brand-icon {
    width: 44px !important; height: 44px !important;
    border-radius: 12px !important;
    flex-shrink: 0;
  }
  .sidebar .sidebar-brand .brand-name { font-size: 15px !important; }
  .sidebar .sidebar-brand .brand-sub  { font-size: 10px !important; }

  /* Nav: stretch full width, rows not columns */
  .sidebar .sidebar-nav {
    flex-direction: column !important;
    align-items: stretch !important;
    padding: 10px 0 !important;
    gap: 1px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    overscroll-behavior: contain !important;
    -webkit-overflow-scrolling: touch !important;
    min-height: 0 !important;
  }

  /* Section labels */
  .sidebar .nav-section {
    display: block !important;
    padding: 14px 18px 4px !important;
    font-size: 10px !important;
    font-weight: 700 !important;
    letter-spacing: .06em !important;
    text-transform: uppercase !important;
    color: rgba(255,255,255,.35) !important;
  }

  /* Nav items: horizontal rows */
  .sidebar .rail-item {
    flex-direction: row !important;
    width: auto !important;
    margin: 1px 10px !important;
    padding: 10px 14px !important;
    gap: 12px !important;
    text-align: left !important;
    font-size: 13px !important;
    border-radius: 10px !important;
    align-items: center !important;
    justify-content: flex-start !important;
  }
  .sidebar .rail-item .nav-icon {
    width: 34px !important; height: 34px !important;
    border-radius: 9px !important;
    font-size: 15px !important;
    flex-shrink: 0;
  }
  .sidebar .rail-label {
    white-space: nowrap !important;
    font-size: 13px !important;
    font-weight: 600 !important;
  }

  /* Rail groups: full width */
  .sidebar .rail-group {
    width: auto !important;
    align-items: stretch !important;
    margin: 1px 10px !important;
  }
  .sidebar .rail-group > .rail-toggle {
    margin: 0 !important;
    width: 100% !important;
    justify-content: flex-start !important;
  }

  /* Flyout: collapsed by default, expands when rail-group is open */
  .sidebar .rail-flyout {
    position: static !important;
    box-shadow: none !important;
    background: rgba(255,255,255,.04) !important;
    border-radius: 8px !important;
    margin: 4px 0 4px 12px !important;
    padding: 0 !important;
    opacity: 0 !important;
    visibility: hidden !important;
    max-height: 0 !important;
    overflow: hidden !important;
    pointer-events: none !important;
    transform: none !important;
    border: 1px solid rgba(255,255,255,.07) !important;
    transition: max-height .32s cubic-bezier(.16,1,.3,1), opacity .22s ease, visibility .22s !important;
  }
  .sidebar .rail-group.open .rail-flyout {
    opacity: 1 !important;
    visibility: visible !important;
    max-height: 700px !important;
    overflow: visible !important;
    pointer-events: auto !important;
    padding: 4px 0 !important;
  }
  .sidebar .flyout-title {
    font-size: 10px !important;
    padding: 6px 14px 3px !important;
    color: rgba(255,255,255,.4) !important;
  }
  .sidebar .flyout-link {
    padding: 8px 14px !important;
    font-size: 12.5px !important;
    border-radius: 6px !important;
    margin: 1px 6px !important;
  }

  /* User footer */
  .sidebar-user {
    padding: 14px 18px !important;
    border-top: 1px solid rgba(255,255,255,.08) !important;
    gap: 10px !important;
  }

  /* ── Stat cards: force 2-column grid ── */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px;
    margin-bottom: 16px;
  }
  .stat-card { padding: 14px 12px; gap: 10px; }
  .stat-card .stat-icon { width: 38px; height: 38px; font-size: 17px; border-radius: 10px; }
  .stat-card .stat-value { font-size: 22px; }
  .stat-card .stat-label { font-size: 10px; letter-spacing: .02em; }

  /* ── Dashboard table column hiding ── */
  .col-m-hide { display: none !important; }
  .table-wrapper table th,
  .table-wrapper table td { font-size: 12px; padding: 8px 10px; }

  /* ── CCTV: shorter feed on mobile ── */
  .dash-cam-feed { padding-top: 48% !important; }
  .dash-cam-grid { grid-template-columns: 1fr !important; }

  /* ── Text: break long content everywhere on mobile ── */
  td, th, label, .form-label, .form-text, .badge, .chip,
  .stat-label, .stat-value, p, li, span { overflow-wrap: break-word; }
  .btn { white-space: normal; }

  /* ── Flex wrap: force ALL inline-style flex rows to wrap on mobile.
     Excludes column-direction flex (already stacks, wrap would create side-by-side columns).
     This catches every filter bar, action bar, info row and activity log row
     that uses style="display:flex;..." without an explicit flex-wrap:wrap. ── */
  [style*="display:flex"]:not([style*="flex-direction:column"]):not([style*="flex-direction: column"]) {
    flex-wrap: wrap !important;
  }

  /* ── Min-width overrides: allow flex children with explicit min-width to shrink.
     Without this, a 140px-min timestamp span in a 320px card overflows.
     Covers the range 130-220px used in filter bars and activity log rows. ── */
  [style*="min-width:130px"], [style*="min-width: 130px"],
  [style*="min-width:140px"], [style*="min-width: 140px"],
  [style*="min-width:150px"], [style*="min-width: 150px"],
  [style*="min-width:160px"], [style*="min-width: 160px"],
  [style*="min-width:180px"], [style*="min-width: 180px"],
  [style*="min-width:200px"], [style*="min-width: 200px"],
  [style*="min-width:220px"], [style*="min-width: 220px"] {
    min-width: 0 !important;
  }

  /* ── Fixed-width inputs/selects: stretch to available width ── */
  [style*="width:145px"], [style*="width: 145px"],
  [style*="width:160px"], [style*="width: 160px"],
  [style*="width:140px"], [style*="width: 140px"],
  [style*="width:220px"], [style*="width: 220px"] {
    width: 100% !important;
    max-width: 100% !important;
  }

}

/* ─────────────────────────────────────────────
   480 px breakpoint — extra small phones
   ───────────────────────────────────────────── */
@media (max-width: 480px) {
  .wizard-step .step-number { display: none; }
  .wizard-step { padding: 4px 10px; }
  .wizard-progress { gap: 4px 3px; }
  .stats-grid { gap: 8px; }
  .stat-card { padding: 12px 10px; }
  .stat-card .stat-value { font-size: 20px; }

  /* ── Filter bars: allow date inputs to shrink/wrap on very small screens ── */
  input[type="date"] {
    min-width: 0 !important;
    flex: 1 1 120px !important;
    width: 100% !important;
    max-width: 145px !important;
  }
  /* Filter dropdowns (camera, status selects with fixed widths) */
  .form-select[style*="width:160px"],
  .form-select[style*="width:140px"] {
    width: 100% !important;
    max-width: 100% !important;
  }
  /* Search inputs with fixed widths */
  input[style*="width:220px"] {
    width: 100% !important;
    max-width: 100% !important;
  }
}
