/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

/* ── TOKENS ── */
:root {
  --bg-base:      #0D0E11;
  --bg-surface:   #13151A;
  --bg-elevated:  #1C1F26;
  --bg-input:     #1A1D24;
  --border:       #2A2D35;
  --border-focus: #4F6BFF;
  --text-primary: #F0F1F3;
  --text-secondary: #8B8FA8;
  --text-muted:   #4A4E63;
  --accent:       #4F6BFF;
  --accent-hover: #3D57E8;
  --accent-dim:   rgba(79,107,255,0.12);
  --success:      #22C55E;
  --warning:      #F59E0B;
  --danger:       #EF4444;
  --radius:       6px;
  --sidebar-w:    220px;
  --font:         'Inter', system-ui, sans-serif;
}

/* ── LAYOUT ── */
body { background: var(--bg-base); color: var(--text-primary);
  font-family: var(--font); font-size: 14px; line-height: 1.5; }

.layout { display: flex; height: 100vh; overflow: hidden; }

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w); min-width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 0; overflow: hidden;
}
.sidebar-brand {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand .logo {
  font-size: 15px; font-weight: 700; letter-spacing: 0.08em;
  color: var(--text-primary);
}
.sidebar-brand .tagline {
  font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-muted); margin-top: 2px;
}
.sidebar-nav { flex: 1; padding: 8px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius);
  color: var(--text-secondary); font-size: 13px;
  cursor: pointer; text-decoration: none;
  transition: background 0.15s, color 0.15s;
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--bg-elevated); color: var(--text-primary); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); font-weight: 500; }
.nav-item svg { width: 15px; height: 15px; flex-shrink: 0; opacity: 0.8; }
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.agents-status { display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--text-muted); }
.agents-dot { width: 6px; height: 6px; border-radius: 50%;
  background: var(--success); }
.btn-logout { font-size: 12px; color: var(--text-muted);
  background: none; border: none; cursor: pointer; padding: 4px 8px;
  border-radius: var(--radius); transition: color 0.15s; }
.btn-logout:hover { color: var(--danger); }

/* MAIN */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.page-header {
  padding: 20px 28px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.page-header h1 { font-size: 18px; font-weight: 600; }
.page-header p { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.page-content { flex: 1; overflow-y: auto; padding: 24px 28px; }

/* ── CARDS ── */
.card {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 20px 24px;
}
.kpi-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; }
.kpi-card { background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 20px 24px; }
.kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); margin-bottom: 8px; }
.kpi-value { font-size: 32px; font-weight: 600; line-height: 1; }
.kpi-delta { font-size: 12px; margin-top: 6px; }
.kpi-delta.up { color: var(--success); }
.kpi-delta.down { color: var(--danger); }

/* ── TABLES ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); padding: 0 12px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left; font-weight: 500;
}
tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-elevated); }
tbody td { padding: 0 12px; height: 44px; font-size: 13px; vertical-align: middle; }

/* ── BADGES ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 500; white-space: nowrap;
}
.badge-neutral  { background: rgba(107,114,128,0.15); color: #9CA3AF; }
.badge-accent   { background: var(--accent-dim); color: var(--accent); }
.badge-warning  { background: rgba(245,158,11,0.12); color: #F59E0B; }
.badge-success  { background: rgba(34,197,94,0.12); color: #22C55E; }
.badge-danger   { background: rgba(239,68,68,0.10); color: #EF4444; }
.badge-agent    { background: var(--bg-elevated); border: 1px solid var(--border);
  color: var(--text-secondary); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; cursor: pointer;
  border: none; transition: background 0.15s, color 0.15s;
  text-decoration: none; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: transparent; border: 1px solid var(--border);
  color: var(--text-secondary); }
.btn-secondary:hover { background: var(--bg-elevated); color: var(--text-primary); }
.btn-ghost { background: transparent; color: var(--text-secondary); border: none; }
.btn-ghost:hover { color: var(--text-primary); }
.btn-danger-ghost { background: transparent; color: var(--danger); border: none;
  opacity: 0.7; }
.btn-danger-ghost:hover { opacity: 1; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ── FORMS ── */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 6px; }
input, select, textarea {
  width: 100%; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-primary);
  padding: 8px 12px; font-size: 13px; font-family: var(--font);
  outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
input::placeholder { color: var(--text-muted); }
select option { background: var(--bg-elevated); }

/* ── FILTERS BAR ── */
.filters { display: flex; gap: 12px; align-items: center;
  margin-bottom: 20px; flex-wrap: wrap; }
.filters input, .filters select { width: auto; min-width: 180px; }
.filters-spacer { flex: 1; }

/* ── MODALS ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 24px; width: 480px; max-width: 95vw;
  transform: translateY(8px); transition: transform 0.2s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header { display: flex; justify-content: space-between;
  align-items: center; margin-bottom: 20px; }
.modal-header h2 { font-size: 16px; font-weight: 600; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px;
  margin-top: 20px; }

/* ── PAGINATION ── */
.pagination { display: flex; align-items: center; gap: 8px;
  margin-top: 16px; font-size: 12px; color: var(--text-muted); }
.pagination .btn { padding: 4px 10px; }

/* ── TABS ── */
.tabs { display: flex; gap: 4px; margin-bottom: 20px;
  border-bottom: 1px solid var(--border); padding-bottom: 0; }
.tab { padding: 8px 14px; font-size: 13px; cursor: pointer;
  color: var(--text-secondary); border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: color 0.15s, border-color 0.15s;
  background: none; border-top: none; border-left: none; border-right: none; }
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── SPINNER ── */
.spinner { width: 20px; height: 20px; border: 2px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-center { display: flex; justify-content: center;
  align-items: center; padding: 60px; }

/* ── EMPTY STATE ── */
.empty { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty p { font-size: 13px; }

/* ── LOGIN PAGE ── */
.login-page { height: 100vh; display: flex; align-items: center;
  justify-content: center; background: var(--bg-base); }
.login-box { background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 40px; width: 380px; }
.login-box .logo { font-size: 20px; font-weight: 700; letter-spacing: 0.08em;
  margin-bottom: 4px; }
.login-box .tagline { font-size: 11px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 32px; }
.login-error { color: var(--danger); font-size: 12px;
  margin-bottom: 12px; display: none; }
.login-error.show { display: block; }

/* ── CHARTS ── */
.chart-wrap { position: relative; }
.charts-grid { display: grid; grid-template-columns: 1fr 380px; gap: 16px; }
.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 160px; padding-top: 8px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.bar-fill { width: 100%; background: var(--accent-dim); border-radius: 4px 4px 0 0;
  min-height: 4px; transition: height 0.3s; }
.bar-fill span { display: block; width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; height: 100%; }
.bar-label { font-size: 10px; color: var(--text-muted); }

/* ── DETAIL SECTIONS ── */
.detail-header { display: flex; justify-content: space-between;
  align-items: flex-start; margin-bottom: 24px; }
.detail-header h2 { font-size: 22px; font-weight: 600; }
.detail-header .meta { display: flex; gap: 8px; margin-top: 6px; }
.section-title { font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 14px; }
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.profile-field label { font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 4px; }

/* ── CALENDAR ── */
.calendar-grid { display: grid; grid-template-columns: repeat(7,1fr);
  border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.cal-header { text-align: center; padding: 10px 4px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); background: var(--bg-surface);
  border-bottom: 1px solid var(--border); }
.cal-col { border-right: 1px solid var(--border); }
.cal-col:last-child { border-right: none; }
.cal-slot { padding: 4px 8px; min-height: 48px;
  border-bottom: 1px solid var(--border); font-size: 12px; }
.cal-event { background: var(--accent-dim); color: var(--accent);
  border-radius: 4px; padding: 2px 6px; font-size: 11px; margin: 2px 0; }

/* ── SERVICE NOTICE ── */
.service-notice { background: rgba(245,158,11,0.08);
  border: 1px solid rgba(245,158,11,0.2);
  border-radius: var(--radius); padding: 10px 16px; margin: 0 28px 0;
  font-size: 12px; color: #F59E0B; display: none; flex-shrink: 0; }
.service-notice.show { display: block; }

/* ── UTILS ── */
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.font-mono { font-family: monospace; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link { color: var(--accent); text-decoration: none; }
.link:hover { text-decoration: underline; }

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }
}
