/* ══════════════════════════════════════════════════════════════════
   FSDA HELPDESK — DESIGN SYSTEM
   Corporate · Human · Premium · Restrained
   ══════════════════════════════════════════════════════════════════ */

/* ─── DESIGN TOKENS ─── */
:root {
  /* Brand Colours */
  --navy:          #1C3557;
  --navy-dark:     #122440;
  --navy-light:    #2A4F7A;
  --gold:          #D4A853;
  --gold-light:    #E8C07A;

  /* Neutrals (warm-tinted grey scale) */
  --bg:            #F7F6F4;
  --surface:       #FFFFFF;
  --surface-raised:#FAFAF9;
  --border:        #E2E0DC;
  --border-strong: #C8C5BF;

  /* Text */
  --text-primary:  #1A1917;
  --text-secondary:#5C5850;
  --text-muted:    #9E9A93;
  --text-inverse:  #FFFFFF;

  /* Semantic */
  --success:       #2D7A4F;
  --success-bg:    #EAF4EE;
  --warning:       #A06320;
  --warning-bg:    #FEF4E4;
  --error:         #C0392B;
  --error-bg:      #FBEAE9;
  --info:          #1C5A8A;
  --info-bg:       #E8F0F8;

  /* Spacing */
  --s1: 4px;  --s2: 8px;  --s3: 12px;
  --s4: 16px; --s5: 20px; --s6: 24px;
  --s8: 32px; --s10: 40px; --s12: 48px;

  /* Typography */
  --font: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;

  /* Radius */
  --radius-sm: 3px;
  --radius:    5px;
  --radius-md: 8px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:    0 2px 8px rgba(0,0,0,0.07), 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.09), 0 2px 6px rgba(0,0,0,0.05);

  /* Layout */
  --sidebar-w: 220px;
  --header-h:  56px;
}

/* ─── RESET & BASE ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: var(--font); cursor: pointer; }
input, select { font-family: var(--font); }
svg { display: block; flex-shrink: 0; }

/* ─── PAGE ROUTER ─── */
.page { display: none; min-height: 100vh; }
.page.active { display: flex; flex-direction: column; }
#page-app.active { flex-direction: column; height: 100vh; overflow: hidden; }

/* ══════════════════════════════════════════════════════════════════
   LOGIN PAGE
   ══════════════════════════════════════════════════════════════════ */
.login-layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  min-height: 100vh;
}

.login-brand {
  background: var(--navy-dark);
  display: flex;
  align-items: stretch;
  position: relative;
  overflow: hidden;
}
.login-brand::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--gold);
}

.brand-inner {
  padding: var(--s10) var(--s8);
  display: flex;
  flex-direction: column;
  gap: var(--s6);
  width: 100%;
}

.brand-emblem { flex-shrink: 0; }

.brand-text { display: flex; flex-direction: column; gap: 6px; }
.brand-dept {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
}
.brand-name {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-inverse);
  line-height: 1.3;
  letter-spacing: -0.01em;
}
.brand-system {
  font-size: 13px;
  color: rgba(255,255,255,0.5);
  font-weight: 400;
}

.brand-divider {
  height: 1px;
  background: rgba(255,255,255,0.1);
}

.brand-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s4);
}
.stat-item { display: flex; flex-direction: column; gap: 2px; }
.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-inverse);
  letter-spacing: -0.03em;
  line-height: 1;
}
.stat-unit { font-size: 16px; font-weight: 500; }
.stat-label {
  font-size: 11px;
  color: rgba(255,255,255,0.45);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.brand-tagline { margin-top: auto; }
.brand-tagline p {
  font-size: 14px;
  color: rgba(255,255,255,0.6);
  font-style: italic;
}
.brand-sub {
  font-size: 11px !important;
  color: rgba(255,255,255,0.3) !important;
  margin-top: var(--s2);
  font-style: normal !important;
  letter-spacing: 0.04em;
}

/* Login Form Area */
.login-form-area {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: var(--s8);
}
.login-form-inner {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: var(--s6);
}

.login-header { display: flex; flex-direction: column; gap: var(--s2); }
.login-header h2 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}
.login-header p {
  font-size: 14px;
  color: var(--text-secondary);
}

.role-selector {
  display: flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.role-btn {
  flex: 1;
  padding: var(--s2) var(--s3);
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.15s ease;
}
.role-btn + .role-btn { border-left: 1px solid var(--border-strong); }
.role-btn.active {
  background: var(--navy);
  color: var(--text-inverse);
}
.role-btn:hover:not(.active) {
  background: var(--surface-raised);
  color: var(--text-secondary);
}

.login-form { display: flex; flex-direction: column; gap: var(--s5); }

.form-group { display: flex; flex-direction: column; gap: var(--s2); }
.form-group label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
  text-transform: uppercase;
}
.form-group input {
  width: 100%;
  padding: 10px var(--s4);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 14px;
  color: var(--text-primary);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  outline: none;
}
.form-group input:focus {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(28,53,87,0.08);
}
.input-wrap { position: relative; }
.input-wrap input { padding-right: 40px; }
.input-action {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 2px;
  transition: color 0.15s;
}
.input-action:hover { color: var(--text-secondary); }

.form-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--s2);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
}
.checkbox-label input { accent-color: var(--navy); width: 14px; height: 14px; }

.text-link {
  font-size: 13px;
  color: var(--navy);
  text-decoration: none;
  transition: opacity 0.15s;
}
.text-link:hover { opacity: 0.7; text-decoration: none; }

.login-footer { display: flex; flex-direction: column; gap: var(--s2); }
.login-footer p { font-size: 13px; color: var(--text-muted); }
.login-legal { font-size: 11px !important; color: var(--text-muted); opacity: 0.7; }

/* ══════════════════════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════════════════════ */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  padding: 10px var(--s5);
  background: var(--navy);
  color: var(--text-inverse);
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: background 0.15s ease, transform 0.1s ease;
  cursor: pointer;
  white-space: nowrap;
}
.btn-primary:hover { background: var(--navy-light); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary.btn-full { width: 100%; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  padding: 9px var(--s5);
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s;
  cursor: pointer;
  white-space: nowrap;
}
.btn-secondary:hover { background: var(--surface-raised); border-color: var(--text-muted); }
.btn-secondary.btn-full { width: 100%; }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: transparent;
  color: var(--text-secondary);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
  white-space: nowrap;
}
.btn-ghost:hover { background: var(--border); color: var(--text-primary); }
.btn-ghost.btn-full { width: 100%; justify-content: center; }
.btn-ghost.tiny { font-size: 12px; padding: 4px 8px; }
.btn-ghost.danger { color: var(--error); }
.btn-ghost.danger:hover { background: var(--error-bg); }
.play-btn { color: var(--navy); }
.play-btn:hover { background: var(--info-bg); }

/* ══════════════════════════════════════════════════════════════════
   APP HEADER
   ══════════════════════════════════════════════════════════════════ */
.app-header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 var(--s5);
  gap: var(--s4);
  flex-shrink: 0;
  position: relative;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--s3);
  flex-shrink: 0;
  min-width: var(--sidebar-w);
}

.sidebar-toggle {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: transparent;
  border: none;
  padding: var(--s2);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.sidebar-toggle:hover { background: var(--border); }
.sidebar-toggle span {
  display: block;
  width: 16px;
  height: 1.5px;
  background: var(--text-secondary);
  border-radius: 1px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: var(--s3);
}
.header-brand > div { display: flex; flex-direction: column; gap: 2px; }
.header-org {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.header-module {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.header-center { flex: 1; max-width: 480px; }

.search-bar {
  display: flex;
  align-items: center;
  gap: var(--s3);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 8px var(--s4);
  color: var(--text-muted);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-bar:focus-within {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(28,53,87,0.07);
  background: var(--surface);
}
.search-bar input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 13px;
  color: var(--text-primary);
  width: 100%;
}
.search-bar input::placeholder { color: var(--text-muted); }

.header-right {
  display: flex;
  align-items: center;
  gap: var(--s3);
  margin-left: auto;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  padding: 5px 10px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid transparent;
}
.status-pill.online {
  background: var(--success-bg);
  color: var(--success);
  border-color: rgba(45,122,79,0.2);
}
.status-pill.large { font-size: 13px; padding: 7px 14px; }
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
  animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.icon-btn {
  position: relative;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px;
  color: var(--text-secondary);
  transition: background 0.15s, border-color 0.15s;
}
.icon-btn:hover { background: var(--border); border-color: var(--border-strong); }
.badge {
  position: absolute;
  top: -5px; right: -5px;
  width: 16px; height: 16px;
  background: var(--error);
  color: white;
  font-size: 9px;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--surface);
}

.user-menu {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: 6px var(--s3) 6px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  position: relative;
  transition: background 0.15s;
}
.user-menu:hover { background: var(--surface-raised); }
.user-info { display: flex; flex-direction: column; gap: 1px; }
.user-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.user-role { font-size: 11px; color: var(--text-muted); }

.avatar {
  width: 32px; height: 32px;
  background: var(--navy);
  color: var(--text-inverse);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}
.avatar.sm { width: 26px; height: 26px; font-size: 10px; }

.user-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  min-width: 180px;
  z-index: 200;
  overflow: hidden;
}
.user-dropdown.open { display: block; }
.dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px var(--s4);
  font-size: 13px;
  color: var(--text-primary);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.1s;
}
.dropdown-item:hover { background: var(--surface-raised); }
.dropdown-divider { height: 1px; background: var(--border); }

/* ══════════════════════════════════════════════════════════════════
   APP BODY & SIDEBAR
   ══════════════════════════════════════════════════════════════════ */
.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.app-sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
  transition: width 0.2s ease;
}
.app-sidebar.collapsed { width: 0; overflow: hidden; }

.sidebar-nav {
  padding: var(--s4) 0;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  flex: 1;
}
.nav-section {
  display: flex;
  flex-direction: column;
  padding: var(--s2) 0;
}
.nav-section + .nav-section {
  border-top: 1px solid var(--border);
}
.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: var(--s3) var(--s4) var(--s2);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 8px var(--s4);
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: 0;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  position: relative;
}
.nav-item:hover { background: var(--bg); color: var(--text-primary); }
.nav-item.active {
  background: var(--info-bg);
  color: var(--navy);
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: var(--navy);
}
.nav-badge {
  margin-left: auto;
  background: var(--warning-bg);
  color: var(--warning);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 100px;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: var(--s4);
}
.system-health { display: flex; flex-direction: column; gap: var(--s3); }
.health-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.health-bars { display: flex; flex-direction: column; gap: var(--s2); }
.health-bar-item {
  display: flex;
  align-items: center;
  gap: var(--s2);
  font-size: 11px;
  color: var(--text-muted);
}
.bar {
  flex: 1;
  height: 3px;
  background: var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: var(--success);
  border-radius: 10px;
}

/* ══════════════════════════════════════════════════════════════════
   MAIN CONTENT AREA
   ══════════════════════════════════════════════════════════════════ */
.app-main {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.view { display: none; flex-direction: column; padding: var(--s8); gap: var(--s6); }
.view.active { display: flex; }

.view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s4);
}
.view-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}
.view-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 3px;
}
.view-actions { display: flex; align-items: center; gap: var(--s3); flex-shrink: 0; }

/* ══════════════════════════════════════════════════════════════════
   KPI CARDS
   ══════════════════════════════════════════════════════════════════ */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--s4);
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--s5);
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  transition: box-shadow 0.2s;
}
.kpi-card:hover { box-shadow: var(--shadow); }
.kpi-card.accent { border-left: 3px solid var(--gold); }
.kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.kpi-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.kpi-trend {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 100px;
}
.kpi-trend.up { background: var(--success-bg); color: var(--success); }
.kpi-trend.warning { background: var(--warning-bg); color: var(--warning); }
.kpi-value {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--text-primary);
  line-height: 1;
}
.kpi-unit { font-size: 20px; font-weight: 500; }
.kpi-sub {
  font-size: 12px;
  color: var(--text-muted);
}

/* ══════════════════════════════════════════════════════════════════
   PANELS
   ══════════════════════════════════════════════════════════════════ */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--s5);
}
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: var(--s4);
}
.span-2 { grid-column: span 2; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s5);
}
.panel-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.panel-meta { font-size: 11px; color: var(--text-muted); }
.panel-divider { height: 1px; background: var(--border); margin: var(--s5) 0; }

/* ══════════════════════════════════════════════════════════════════
   TABLES
   ══════════════════════════════════════════════════════════════════ */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table.full {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.data-table thead { background: var(--bg); }
.data-table th {
  padding: 10px var(--s4);
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 11px var(--s4);
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr.clickable-row { cursor: pointer; transition: background 0.1s; }
.data-table tbody tr.clickable-row:hover { background: var(--bg); }

.case-id {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--navy);
  font-weight: 500;
}
.meta-text { font-size: 12px; color: var(--text-muted); }

/* ─── Status / Priority / Channel Badges ─── */
.status-badge, .priority-badge, .channel-badge, .role-badge, .lang-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.status-badge.open { background: var(--error-bg); color: var(--error); }
.status-badge.in-review { background: var(--warning-bg); color: var(--warning); }
.status-badge.resolved { background: var(--success-bg); color: var(--success); }

.priority-badge.high { background: var(--error-bg); color: var(--error); }
.priority-badge.medium { background: var(--warning-bg); color: var(--warning); }
.priority-badge.low { background: var(--success-bg); color: var(--success); }

.channel-badge.bot { background: var(--info-bg); color: var(--info); }
.channel-badge.qr { background: #F0EBF8; color: #6B3FA0; }

.role-badge.admin { background: var(--navy); color: white; }
.role-badge.incharge { background: var(--info-bg); color: var(--info); }
.role-badge.operator { background: var(--bg); color: var(--text-secondary); border: 1px solid var(--border-strong); }

.lang-badge { background: var(--bg); color: var(--text-secondary); border: 1px solid var(--border-strong); font-size: 10px; padding: 2px 6px; }

/* ─── Table Footer ─── */
.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s4) 0;
}
.pagination { display: flex; align-items: center; gap: var(--s2); }
.page-btn {
  padding: 5px 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.12s;
}
.page-btn:hover:not(:disabled) { background: var(--bg); }
.page-btn.active { background: var(--navy); color: white; border-color: var(--navy); }
.page-btn:disabled { opacity: 0.4; cursor: default; }

/* ══════════════════════════════════════════════════════════════════
   FILTER BAR
   ══════════════════════════════════════════════════════════════════ */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  flex-wrap: wrap;
}
.filter-group { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.filter-select {
  padding: 7px var(--s4);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}
.filter-select:focus { border-color: var(--navy); }
.filter-search {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: 7px var(--s4);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-muted);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.filter-search:focus-within { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(28,53,87,0.07); }
.filter-search input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 13px;
  color: var(--text-primary);
  width: 240px;
}
.filter-search input::placeholder { color: var(--text-muted); }

/* ══════════════════════════════════════════════════════════════════
   DISTRICT BARS
   ══════════════════════════════════════════════════════════════════ */
.district-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--s5);
}
.district-bars { display: flex; flex-direction: column; gap: var(--s3); }
.district-row {
  display: grid;
  grid-template-columns: 160px 1fr 40px;
  align-items: center;
  gap: var(--s4);
}
.district-name { font-size: 13px; color: var(--text-secondary); }
.district-track {
  height: 6px;
  background: var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.district-fill {
  height: 100%;
  background: var(--navy);
  border-radius: 10px;
  transition: width 0.6s ease;
}
.district-num {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: right;
}

/* ══════════════════════════════════════════════════════════════════
   BOT MONITOR
   ══════════════════════════════════════════════════════════════════ */
.bot-monitor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s4);
}
.system-checks { display: flex; flex-direction: column; gap: var(--s3); }
.check-item {
  display: grid;
  grid-template-columns: 20px 1fr auto;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  border-radius: var(--radius);
  font-size: 13px;
}
.check-item.ok { color: var(--text-primary); }
.check-item.ok svg { color: var(--success); }
.check-item.warning { color: var(--warning); background: var(--warning-bg); }
.check-item.warning svg { color: var(--warning); }
.check-meta { font-size: 11px; color: var(--text-muted); }
.check-item.warning .check-meta { color: var(--warning); opacity: 0.8; }

.live-feed { display: flex; flex-direction: column; gap: 0; }
.feed-item {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: var(--s3);
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.feed-item:last-child { border-bottom: none; }
.feed-time { font-size: 11px; font-family: var(--font-mono); color: var(--text-muted); }
.feed-content { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.feed-content strong { font-weight: 600; }
.feed-lang {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}
.feed-type, .feed-status {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 100px;
  display: inline-flex;
  width: fit-content;
}
.enquiry-tag { background: var(--info-bg); color: var(--info); }
.complaint-tag { background: var(--error-bg); color: var(--error); }
.resolved-tag { background: var(--success-bg); color: var(--success); }
.open-tag { background: var(--warning-bg); color: var(--warning); }
.escalated-tag { background: #F0EBF8; color: #6B3FA0; }

.live-dot {
  width: 8px; height: 8px;
  background: var(--error);
  border-radius: 50%;
  animation: pulse-dot 1.5s infinite;
}

/* ══════════════════════════════════════════════════════════════════
   ACTIVITY LIST
   ══════════════════════════════════════════════════════════════════ */
.activity-list { display: flex; flex-direction: column; gap: var(--s3); }
.activity-item {
  display: grid;
  grid-template-columns: 28px 1fr 80px;
  align-items: center;
  gap: var(--s3);
}
.activity-icon {
  width: 28px; height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.activity-icon.calls { background: var(--info-bg); color: var(--info); }
.activity-icon.enquiry { background: var(--success-bg); color: var(--success); }
.activity-icon.escalated { background: var(--error-bg); color: var(--error); }
.activity-icon.lang { background: #F0EBF8; color: #6B3FA0; }
.activity-detail { display: flex; flex-direction: column; gap: 1px; }
.activity-label { font-size: 12px; color: var(--text-secondary); }
.activity-value { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.activity-bar-wrap {
  height: 4px;
  background: var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.activity-bar {
  height: 100%;
  background: var(--navy);
  border-radius: 10px;
}
.activity-bar.warning { background: var(--warning); }

.after-hours-stat { display: flex; flex-direction: column; gap: var(--s3); }
.ahs-item {
  display: flex;
  align-items: center;
  gap: var(--s4);
  padding: var(--s3) var(--s4);
  background: var(--bg);
  border-radius: var(--radius);
  font-size: 12px;
}
.ahs-time { font-weight: 600; color: var(--text-primary); min-width: 72px; }
.ahs-count { color: var(--text-secondary); flex: 1; }
.ahs-rate.good { color: var(--success); font-weight: 600; }

/* ══════════════════════════════════════════════════════════════════
   QR CODE MANAGER
   ══════════════════════════════════════════════════════════════════ */
.qr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--s4);
}
.qr-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--s5);
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  align-items: center;
  text-align: center;
  transition: box-shadow 0.2s;
}
.qr-card:hover { box-shadow: var(--shadow); }
.qr-placeholder {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s3);
}
.qr-info { display: flex; flex-direction: column; gap: var(--s2); }
.qr-location { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.qr-id { font-size: 11px; font-family: var(--font-mono); }
.qr-scans { font-size: 12px; color: var(--text-secondary); }
.qr-actions { display: flex; gap: var(--s2); }

/* ══════════════════════════════════════════════════════════════════
   SETTINGS
   ══════════════════════════════════════════════════════════════════ */
.settings-grid { display: flex; flex-direction: column; gap: var(--s6); }
.settings-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--s5);
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}
.settings-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  padding-bottom: var(--s3);
  border-bottom: 1px solid var(--border);
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
}
.settings-label { display: flex; flex-direction: column; gap: 2px; }
.settings-label span:first-child { font-size: 13px; color: var(--text-primary); }

.lang-toggles { display: flex; flex-wrap: wrap; gap: var(--s2); }
.toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
  padding: 4px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 100px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}
.toggle-chip input { display: none; }
.toggle-chip.active {
  background: var(--navy);
  color: white;
  border-color: var(--navy);
}
.toggle-chip:not(.active):hover { background: var(--bg); border-color: var(--navy); }

.toggle-switch { position: relative; display: inline-flex; align-items: center; }
.toggle-switch input { opacity: 0; position: absolute; }
.toggle-track {
  width: 36px;
  height: 20px;
  background: var(--border-strong);
  border-radius: 100px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 14px; height: 14px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-switch input:checked ~ .toggle-track { background: var(--navy); }
.toggle-switch input:checked ~ .toggle-track::after { transform: translateX(16px); }

.integration-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--border);
}
.integration-row:last-child { border-bottom: none; }
.int-info { display: flex; flex-direction: column; gap: 2px; }
.int-name { font-size: 13px; font-weight: 500; color: var(--text-primary); }

/* ══════════════════════════════════════════════════════════════════
   MODAL
   ══════════════════════════════════════════════════════════════════ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10,15,25,0.4);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: var(--s6);
  backdrop-filter: blur(2px);
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  max-width: 840px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modal-in 0.18s ease;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: var(--s5) var(--s6);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  display: block;
  margin-bottom: 4px;
}
.modal-title {
  font-size: 18px;
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: -0.01em;
  color: var(--navy);
}
.modal-close {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.12s;
  flex-shrink: 0;
}
.modal-close:hover { background: var(--bg); }

.modal-body { padding: var(--s6); overflow-y: auto; }

.modal-grid {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: var(--s6);
}
.modal-main { display: flex; flex-direction: column; gap: var(--s5); }
.detail-row { display: flex; flex-direction: column; gap: 4px; }
.detail-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.detail-row > span:not(.detail-label) {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.5;
}

.modal-timeline { margin-top: var(--s4); }
.timeline-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--s4);
}
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item {
  display: flex;
  gap: var(--s4);
  padding-bottom: var(--s4);
  position: relative;
}
.timeline-item::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 14px;
  bottom: 0;
  width: 1px;
  background: var(--border);
}
.timeline-item:last-child::before { display: none; }
.tl-dot {
  width: 13px; height: 13px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: var(--surface);
  flex-shrink: 0;
  margin-top: 2px;
  z-index: 1;
}
.tl-dot.active { background: var(--navy); border-color: var(--navy); }
.tl-dot.pending { border-color: var(--warning); }
.timeline-item > div { display: flex; flex-direction: column; gap: 2px; }
.tl-label { font-size: 13px; color: var(--text-primary); }
.tl-meta { font-size: 11px; color: var(--text-muted); }

.modal-sidebar { display: flex; flex-direction: column; gap: var(--s4); }
.modal-meta-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--s4);
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}
.meta-row { display: flex; flex-direction: column; gap: 2px; }
.modal-actions-block { display: flex; flex-direction: column; gap: var(--s2); }

/* ══════════════════════════════════════════════════════════════════
   USER CELL
   ══════════════════════════════════════════════════════════════════ */
.user-cell {
  display: flex;
  align-items: center;
  gap: var(--s3);
  font-size: 13px;
  font-weight: 500;
}

/* ══════════════════════════════════════════════════════════════════
   ANIMATIONS (respects reduced-motion)
   ══════════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ══════════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 1100px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .bot-monitor-grid { grid-template-columns: 1fr; }
}

@media (max-width: 800px) {
  :root { --sidebar-w: 0px; }
  .app-sidebar { width: 220px; position: absolute; left: -220px; top: var(--header-h); bottom: 0; z-index: 50; transition: left 0.2s; }
  .app-sidebar.mobile-open { left: 0; }
  .view { padding: var(--s5); }
  .header-center { display: none; }
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .login-layout { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .modal-grid { grid-template-columns: 1fr; }
  .district-row { grid-template-columns: 120px 1fr 40px; }
}

@media (max-width: 520px) {
  .kpi-row { grid-template-columns: 1fr; }
  .view-header { flex-direction: column; }
  .filter-bar { flex-direction: column; align-items: stretch; }
}
