/* ── Design tokens ──────────────────────────────────────────────────
   Dark-first. Light tokens defined under prefers-color-scheme and
   explicit [data-theme="light"] so all three viewer states resolve.
──────────────────────────────────────────────────────────────────── */
:root {
  --bg:           #080d1a;
  --sidebar-bg:   #0d1424;
  --surface:      #111827;
  --surface-2:    #1c2536;
  --surface-3:    #243047;
  --border:       #2a3654;
  --border-light: #334166;
  --text:         #e2e8f0;
  --text-muted:   #718096;
  --text-dim:     #4a5568;
  --accent:       #5b8af5;
  --accent-glow:  rgba(91,138,245,.18);
  --accent-hover: #7aa3ff;
  --online:       #22c55e;
  --busy:         #f59e0b;
  --break-c:      #60a5fa;
  --offline:      #4b5563;
  --danger:       #ef4444;
  --danger-bg:    rgba(239,68,68,.12);
  --success:      #22c55e;
  --warning:      #f59e0b;
  --sidebar-w:    220px;
  --topbar-h:     54px;
  --radius-sm:    4px;
  --radius:       8px;
  --radius-lg:    12px;
  --font:         'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono:         'Cascadia Code', 'Consolas', 'Fira Mono', monospace;
  --shadow:       0 1px 3px rgba(0,0,0,.5), 0 4px 12px rgba(0,0,0,.3);
  --shadow-sm:    0 1px 2px rgba(0,0,0,.4);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg:           #f0f4fc;
    --sidebar-bg:   #1a2342;
    --surface:      #ffffff;
    --surface-2:    #f5f7fc;
    --surface-3:    #eaeff8;
    --border:       #dde3f0;
    --border-light: #c8d0e4;
    --text:         #1a2036;
    --text-muted:   #5a6480;
    --text-dim:     #8892a8;
    --accent:       #3b6be8;
    --accent-glow:  rgba(59,107,232,.12);
    --accent-hover: #2d5cd4;
    --shadow:       0 1px 3px rgba(0,0,0,.1), 0 4px 12px rgba(0,0,0,.07);
    --shadow-sm:    0 1px 2px rgba(0,0,0,.08);
  }
}
:root[data-theme="dark"] {
  --bg:           #080d1a;
  --sidebar-bg:   #0d1424;
  --surface:      #111827;
  --surface-2:    #1c2536;
  --surface-3:    #243047;
  --border:       #2a3654;
  --border-light: #334166;
  --text:         #e2e8f0;
  --text-muted:   #718096;
  --text-dim:     #4a5568;
  --accent:       #5b8af5;
  --accent-glow:  rgba(91,138,245,.18);
  --accent-hover: #7aa3ff;
  --shadow:       0 1px 3px rgba(0,0,0,.5), 0 4px 12px rgba(0,0,0,.3);
}
:root[data-theme="light"] {
  --bg:           #f0f4fc;
  --sidebar-bg:   #1a2342;
  --surface:      #ffffff;
  --surface-2:    #f5f7fc;
  --surface-3:    #eaeff8;
  --border:       #dde3f0;
  --border-light: #c8d0e4;
  --text:         #1a2036;
  --text-muted:   #5a6480;
  --text-dim:     #8892a8;
  --accent:       #3b6be8;
  --accent-glow:  rgba(59,107,232,.12);
  --accent-hover: #2d5cd4;
  --shadow:       0 1px 3px rgba(0,0,0,.1), 0 4px 12px rgba(0,0,0,.07);
}

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

body {
  font-family: var(--font);
  font-size: 13.5px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

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

button { font-family: var(--font); cursor: pointer; }

/* ── App shell ──────────────────────────────────────────────────── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

/* subtle inner glow on right edge */
.sidebar::after {
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 1px;
  background: linear-gradient(180deg, transparent, rgba(91,138,245,.3) 40%, transparent);
  pointer-events: none;
}

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

.brand-mark {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  letter-spacing: .04em;
  flex-shrink: 0;
}

.brand-text { display: flex; flex-direction: column; gap: 0; }
.brand-name { font-size: 13px; font-weight: 700; color: var(--text); line-height: 1.2; }
.brand-sub  { font-size: 10px; color: var(--text-muted); letter-spacing: .03em; }

/* Agent identity chip */
.agent-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 14px;
  margin: 10px 10px 4px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  position: relative;
}

.agent-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #8b6fff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.avatar { /* reusable */
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #8b6fff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.avatar.sm { width: 30px; height: 30px; font-size: 12px; }

.agent-info { flex: 1; min-width: 0; }
.agent-display-name {
  display: block;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.agent-role-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: capitalize;
}

.agent-status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--offline);
  flex-shrink: 0;
}
.agent-status-dot.online { background: var(--online); box-shadow: 0 0 0 2px rgba(34,197,94,.2); }

/* Sidebar navigation */
.sidebar-nav { flex: 1; padding: 6px 8px; overflow-y: auto; }

.nav-section { margin-bottom: 4px; }
.nav-section-label {
  display: block;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 8px 8px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  transition: background .12s, color .12s;
  margin-bottom: 1px;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active {
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid rgba(91,138,245,.2);
}
.nav-icon { font-size: 14px; opacity: .75; }
.nav-label { flex: 1; }

.sidebar-footer {
  padding: 10px;
  border-top: 1px solid var(--border);
}

.btn-signout {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  transition: background .12s, color .12s, border-color .12s;
}
.btn-signout:hover { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.signout-icon { font-size: 13px; }

/* ── Main wrapper ───────────────────────────────────────────────── */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── Topbar ─────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
  gap: 12px;
}

.page-breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.breadcrumb-app  { color: var(--text-muted); }
.breadcrumb-sep  { color: var(--border-light); }
.breadcrumb-page { color: var(--text); font-weight: 600; }

.topbar-alerts { display: flex; align-items: center; gap: 8px; }

.alert-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: opacity .15s;
}
.alert-pill:hover { opacity: .8; }
.alert-call { background: rgba(239,68,68,.15); color: var(--danger); }
.alert-chat { background: var(--accent-glow); color: var(--accent); }

.alert-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
}
.pulse      { background: var(--danger); animation: pulse-red 1.2s infinite; }
.pulse-blue { background: var(--accent); animation: pulse-blue 1.2s infinite; }

@keyframes pulse-red  { 0%,100%{box-shadow:0 0 0 0 rgba(239,68,68,.6)} 50%{box-shadow:0 0 0 4px rgba(239,68,68,0)} }
@keyframes pulse-blue { 0%,100%{box-shadow:0 0 0 0 rgba(91,138,245,.6)} 50%{box-shadow:0 0 0 4px rgba(91,138,245,0)} }

/* ── Page body ──────────────────────────────────────────────────── */
.page-body { flex: 1; overflow: hidden; }

/* ── Dashboard grid ─────────────────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 300px 1fr 280px;
  height: 100%;
}

/* ── Panels ──────────────────────────────────────────────────────── */
.panel {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.panel:last-child { border-right: none; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface-2);
}
.panel-header h2 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }

.panel-body { flex: 1; overflow-y: auto; }

/* ── Queue panel ────────────────────────────────────────────────── */
.queue-filters { display: flex; gap: 6px; }

.filter-select, .search-input {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 11.5px;
  font-family: var(--font);
  outline: none;
  transition: border-color .15s;
}
.filter-select { padding: 4px 7px; }
.filter-select:focus { border-color: var(--accent); }
.search-input  { padding: 6px 10px; width: 220px; }
.search-input:focus { border-color: var(--accent); }

.ticket-row {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .1s;
  border-left: 3px solid transparent;
}
.ticket-row:hover { background: var(--surface-2); }
.ticket-row.selected {
  background: var(--accent-glow);
  border-left-color: var(--accent);
}

.ticket-row-top { display: flex; align-items: center; gap: 5px; margin-bottom: 3px; }
.ticket-code { font-family: var(--mono); font-size: 10.5px; color: var(--text-muted); }
.ticket-subject { font-size: 12.5px; color: var(--text); margin-bottom: 5px; line-height: 1.3; }
.ticket-meta { display: flex; gap: 5px; }

/* Priority chips */
.priority-chip {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.priority-urgent { background: rgba(239,68,68,.18); color: #f87171; }
.priority-high   { background: rgba(245,158,11,.18); color: #fbbf24; }
.priority-normal { background: var(--accent-glow);  color: var(--accent); }
.priority-low    { background: var(--surface-3);     color: var(--text-muted); }

.sla-breach-badge {
  background: var(--danger);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: .04em;
}
.sla-breach-text { color: var(--danger); font-weight: 600; }

.module-tag, .channel-tag {
  font-size: 10px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--text-dim);
}

/* ── Chat panel ─────────────────────────────────────────────────── */
.chat-panel { background: var(--bg); border-right: 1px solid var(--border); }

.chat-header {
  background: var(--surface);
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.chat-ticket-info { display: flex; flex-direction: column; gap: 1px; }
.chat-ticket-info .ticket-code { font-size: 10.5px; }
.chat-ticket-info .ticket-subject { font-size: 13px; font-weight: 600; margin-bottom: 0; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message { display: flex; flex-direction: column; max-width: 78%; }
.from-agent { align-self: flex-end; align-items: flex-end; }
.from-user  { align-self: flex-start; align-items: flex-start; }

.message-bubble {
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.45;
  word-break: break-word;
}
.from-agent .message-bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 3px;
}
.from-user .message-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 3px;
}
.message-meta { font-size: 10px; color: var(--text-dim); margin-top: 3px; }

.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  color: var(--text);
  font-size: 13px;
  font-family: var(--font);
  outline: none;
  transition: border-color .15s;
}
.chat-input:focus { border-color: var(--accent); }

.btn-send {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 0 16px;
  font-size: 13px;
  font-weight: 600;
  transition: background .15s;
}
.btn-send:hover:not(:disabled) { background: var(--accent-hover); }
.btn-send:disabled { opacity: .45; cursor: default; }

.btn-resolve {
  background: rgba(34,197,94,.15);
  color: var(--success);
  border: 1px solid rgba(34,197,94,.25);
  border-radius: var(--radius-sm);
  padding: 4px 11px;
  font-size: 11.5px;
  font-weight: 600;
  transition: background .15s;
}
.btn-resolve:hover { background: rgba(34,197,94,.25); }

/* ── Right detail panel ─────────────────────────────────────────── */
.right-panel { overflow-y: auto; background: var(--surface); }

.right-section {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.ticket-details { display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; }
.ticket-details dt { color: var(--text-muted); font-size: 11.5px; align-self: center; }
.ticket-details dd { margin: 0; font-size: 12.5px; align-self: center; }

.status-chip {
  display: inline-block;
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 20px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  font-weight: 600;
  text-transform: capitalize;
}

.note-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 9px 10px;
  font-size: 13px;
  font-family: var(--font);
  resize: vertical;
  outline: none;
  transition: border-color .15s;
}
.note-input:focus { border-color: var(--accent); }

.btn-note {
  margin-top: 7px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  transition: border-color .15s;
}
.btn-note:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn-note:disabled { opacity: .4; cursor: default; }

/* ── Customer card ──────────────────────────────────────────────── */
.customer-card { font-size: 13px; }

.card-header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }

.user-badge {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 2px 7px;
  border-radius: 3px;
}
.user-badge.customer { background: var(--accent-glow);          color: var(--accent); }
.user-badge.driver   { background: rgba(34,197,94,.12);          color: var(--online); }

.user-name { font-weight: 600; font-size: 13px; }

.card-details { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; }
.card-details dt { color: var(--text-muted); font-size: 11px; }
.card-details dd { margin: 0; font-size: 12.5px; }

/* ── Login page ─────────────────────────────────────────────────── */
.login-shell {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

/* subtle background grid */
.login-shell::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 40px 40px;
  opacity: .25;
  pointer-events: none;
}

.login-card {
  position: relative;
  width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px;
  box-shadow: var(--shadow);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 6px;
  letter-spacing: -.01em;
}

.login-logo-mark {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 900;
  color: #fff;
}

.login-heading {
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 6px;
  letter-spacing: -.02em;
}

.login-subheading {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 24px;
}

.login-divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

.login-error {
  background: var(--danger-bg);
  border: 1px solid rgba(239,68,68,.3);
  color: #f87171;
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  margin-bottom: 16px;
  font-size: 12.5px;
}

.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: .02em;
}

.form-control {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  color: var(--text);
  font-size: 13.5px;
  font-family: var(--font);
  outline: none;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-control:disabled { opacity: .5; cursor: not-allowed; }

.form-control-totp {
  letter-spacing: .35em;
  font-size: 22px;
  text-align: center;
  font-family: var(--mono);
}

.btn-login {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .01em;
  margin-top: 4px;
  transition: background .15s, transform .1s;
}
.btn-login:hover:not(:disabled) { background: var(--accent-hover); }
.btn-login:active:not(:disabled) { transform: translateY(1px); }
.btn-login:disabled { opacity: .55; cursor: default; }

.totp-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
  text-align: center;
}

.btn-back {
  display: block;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-muted);
  background: none;
  border: none;
  padding: 8px;
  margin-top: 6px;
  width: 100%;
}
.btn-back:hover { color: var(--text); }

/* ── Page container (agents, monitoring, etc.) ──────────────────── */
.page-container { padding: 24px; height: 100%; overflow-y: auto; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
}

.page-title   { font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ── Buttons ────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: background .15s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .5; cursor: default; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  transition: border-color .15s, color .15s;
}
.btn-ghost:hover { border-color: var(--text-muted); color: var(--text); }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  transition: opacity .15s;
}
.btn-danger:hover { opacity: .85; }

.btn-icon {
  width: 28px; height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-muted);
  transition: background .12s, color .12s, border-color .12s;
}
.btn-icon:hover { background: var(--surface-3); color: var(--text); }
.btn-icon.danger:hover { background: var(--danger-bg); color: var(--danger); border-color: rgba(239,68,68,.3); }
.btn-icon.success:hover { background: rgba(34,197,94,.1); color: var(--success); border-color: rgba(34,197,94,.3); }

/* ── Filter bar ─────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* ── Data card (table wrapper) ──────────────────────────────────── */
.data-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

/* ── Agents table ───────────────────────────────────────────────── */
.agents-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.agents-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.agents-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.agents-table tr:last-child td { border-bottom: none; }
.agents-table tr:hover td { background: var(--surface-2); }
.row-inactive td { opacity: .5; }

.agent-cell { display: flex; align-items: center; gap: 9px; }
.agent-cell-name  { font-weight: 600; font-size: 13px; }
.agent-cell-email { font-size: 11.5px; color: var(--text-muted); }

.row-actions { display: flex; gap: 4px; }

.empty-row {
  text-align: center;
  color: var(--text-muted);
  padding: 32px 14px !important;
  font-size: 13px;
}

.text-mono    { font-family: var(--mono); font-size: 12px; }
.text-muted-sm { font-size: 12px; color: var(--text-muted); }

/* Role badges */
.role-badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: capitalize;
  padding: 2px 8px;
  border-radius: 20px;
}
.role-admin      { background: rgba(239,68,68,.12); color: #f87171; }
.role-supervisor { background: rgba(245,158,11,.12); color: #fbbf24; }
.role-team_lead  { background: var(--accent-glow);  color: var(--accent); }
.role-agent      { background: var(--surface-3);     color: var(--text-muted); }

/* Status pills */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  text-transform: capitalize;
}
.status-dot-sm {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--offline);
}
.status-online  .status-dot-sm { background: var(--online); }
.status-busy    .status-dot-sm { background: var(--busy); }
.status-break   .status-dot-sm { background: var(--break-c); }

/* Skill chips */
.skill-chips { display: flex; flex-wrap: wrap; gap: 3px; }
.skill-chip-sm {
  font-size: 9.5px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--text-muted);
  font-weight: 500;
}
.skill-chip-sm.more { color: var(--accent); border-color: rgba(91,138,245,.3); background: var(--accent-glow); }

/* ── Modal ──────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 560px;
  max-width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  animation: modal-in .15s ease-out;
}
.modal.modal-sm { width: 400px; }

@keyframes modal-in {
  from { opacity: 0; transform: scale(.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title { font-size: 15px; font-weight: 700; }
.modal-close {
  width: 28px; height: 28px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .12s;
}
.modal-close:hover { background: var(--surface-3); color: var(--text); }

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-group-full { grid-column: 1 / -1; }

.form-error-banner {
  background: var(--danger-bg);
  border: 1px solid rgba(239,68,68,.3);
  color: #f87171;
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  margin-bottom: 14px;
  font-size: 12.5px;
}

/* Skill picker */
.skill-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.skill-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
  transition: all .12s;
  user-select: none;
}
.skill-toggle input { display: none; }
.skill-toggle:hover { border-color: var(--accent); color: var(--accent); }
.skill-toggle.active { background: var(--accent-glow); border-color: rgba(91,138,245,.4); color: var(--accent); font-weight: 600; }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-muted);
}
.checkbox-label input { width: 14px; height: 14px; accent-color: var(--accent); }
.checkbox-label:hover { color: var(--text); }

/* ── Monitoring ─────────────────────────────────────────────────── */
.monitoring-page { padding: 24px; overflow-y: auto; height: 100%; }

.stats-bar { display: flex; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  min-width: 110px;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--border-light);
}
.stat-card.accent::before { background: var(--danger); }

.stat-value { font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.stat-label { font-size: 10.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; margin-top: 2px; }

.agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 10px;
  margin-bottom: 28px;
}

.agent-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  border-left: 3px solid var(--offline);
  transition: border-color .15s;
}
.agent-tile.status-online  { border-left-color: var(--online); }
.agent-tile.status-busy    { border-left-color: var(--busy); }
.agent-tile.status-break   { border-left-color: var(--break-c); }

.tile-name   { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
.tile-role   { font-size: 10.5px; color: var(--text-muted); text-transform: capitalize; margin-bottom: 7px; }
.tile-status { display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--text-muted); }

.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--offline); }
.status-online  .status-dot { background: var(--online); }
.status-busy    .status-dot { background: var(--busy); }
.status-break   .status-dot { background: var(--break-c); }

.tile-module-skills { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 8px; }
.skill-chip { font-size: 9.5px; background: var(--surface-2); border: 1px solid var(--border); padding: 1px 5px; border-radius: 3px; color: var(--text-dim); }

.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left;
  padding: 9px 12px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

/* ── Skeletons ──────────────────────────────────────────────────── */
.skeleton-line {
  height: 11px;
  background: var(--surface-2);
  border-radius: 4px;
  margin-bottom: 8px;
  animation: shimmer 1.4s ease-in-out infinite;
}
.skeleton-line.short { width: 55%; }
@keyframes shimmer { 0%,100%{opacity:1} 50%{opacity:.35} }

/* ── Empty/loading states ───────────────────────────────────────── */
.loading-text, .empty-text, .no-messages, .card-error,
.chat-empty p, .right-empty p {
  color: var(--text-muted);
  text-align: center;
  padding: 28px 16px;
  font-size: 13px;
}

/* ── Scrollbar styling ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ── Settings page ──────────────────────────────────────────────── */
.settings-shell {
  display: flex;
  height: 100%;
  overflow: hidden;
}

.settings-nav {
  width: 210px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 8px;
  overflow-y: auto;
}

.settings-nav-title {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 0 8px 12px;
}

.settings-nav-group { margin-bottom: 6px; }

.settings-nav-label {
  display: block;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 6px 8px 3px;
}

.settings-nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-family: var(--font);
  text-align: left;
  cursor: pointer;
  transition: background .12s, color .12s;
  margin-bottom: 1px;
}
.settings-nav-item:hover { background: var(--surface-2); color: var(--text); }
.settings-nav-item.active { background: var(--accent-glow); color: var(--accent); font-weight: 600; }

.settings-content { flex: 1; overflow-y: auto; padding: 24px; }

.settings-section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
}
.settings-section-title { font-size: 17px; font-weight: 700; letter-spacing: -.02em; }
.settings-section-sub   { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

.settings-hint { font-size: 11.5px; color: var(--text-dim); margin-top: 10px; }

.settings-empty { color: var(--text-muted); padding: 20px 0; font-size: 13px; }

.settings-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

/* VoIP summary cards */
.voip-summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  transition: border-color .15s;
}
.voip-summary-card:hover { border-color: var(--border-light); }
.voip-summary-card.card-inactive { opacity: .5; }

.vsc-top   { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.vsc-priority { font-family: var(--mono); font-size: 10px; color: var(--text-muted); background: var(--surface-2); padding: 1px 5px; border-radius: 3px; }
.vsc-number { font-family: var(--mono); font-size: 15px; font-weight: 700; letter-spacing: .02em; margin-bottom: 2px; }
.vsc-label  { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.vsc-meta   { display: flex; gap: 6px; font-size: 11px; color: var(--text-dim); }

/* SLA table values */
.sla-value  { font-family: var(--mono); font-size: 12px; }
.sla-urgent { color: var(--danger); font-weight: 700; }
.sla-high   { color: var(--warning); font-weight: 600; }

/* Teams */
.member-count { font-size: 12px; color: var(--text-muted); }

/* General grid tiles */
.general-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.general-tile {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  text-align: left;
  cursor: pointer;
  font-family: var(--font);
  color: var(--text);
  transition: border-color .15s, background .15s;
  text-decoration: none;
}
.general-tile:hover { border-color: var(--accent); background: var(--accent-glow); color: var(--text); }

.general-tile-icon  { font-size: 18px; margin-bottom: 10px; opacity: .7; }
.general-tile-title { font-size: 13px; font-weight: 700; margin-bottom: 5px; }
.general-tile-desc  { font-size: 11.5px; color: var(--text-muted); line-height: 1.4; }

/* Environment checklist */
.settings-info-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.env-checklist { display: flex; flex-direction: column; gap: 8px; }
.env-item { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.env-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-ok   { background: var(--online); }
.dot-warn { background: var(--warning); }
.dot-info { background: var(--accent); opacity: .7; }

/* ── VoIP Numbers page ──────────────────────────────────────────── */
.voip-label { font-weight: 500; font-size: 12.5px; }

.provider-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 2px 7px;
  border-radius: 3px;
}
.provider-exotel   { background: rgba(91,138,245,.15); color: var(--accent); }
.provider-ozonetel { background: rgba(34,197,94,.12);  color: var(--online); }
.provider-twilio   { background: rgba(245,158,11,.12); color: var(--warning); }

.priority-controls { display: flex; align-items: center; gap: 4px; }
.priority-value { font-family: var(--mono); font-size: 12px; min-width: 20px; text-align: center; }

.overflow-bar-wrap { display: flex; align-items: center; gap: 7px; }
.overflow-bar {
  width: 56px; height: 5px;
  background: var(--surface-3);
  border-radius: 3px;
  overflow: hidden;
  flex-shrink: 0;
}
.overflow-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width .3s;
}
.overflow-label { font-family: var(--mono); font-size: 11px; color: var(--text-muted); }

.label-hint { font-size: 10.5px; color: var(--text-dim); font-weight: 400; }

.routing-info { margin-top: 24px; }

.routing-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.routing-card {
  display: flex;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.routing-card-icon {
  width: 28px; height: 28px;
  background: var(--accent-glow);
  border: 1px solid rgba(91,138,245,.25);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  color: var(--accent);
  flex-shrink: 0;
}
.routing-card strong { font-size: 12.5px; display: block; margin-bottom: 3px; }
.routing-card p { font-size: 12px; color: var(--text-muted); line-height: 1.4; margin: 0; }

/* ── Blazor error UI ────────────────────────────────────────────── */
#blazor-error-ui {
  background: var(--danger);
  color: #fff;
  bottom: 0; left: 0; right: 0;
  position: fixed;
  padding: 9px 16px;
  display: none;
  z-index: 9999;
  font-size: 13px;
}
#blazor-error-ui a { color: #fff; text-decoration: underline; }
