/* ============================================================
   PriooCare RSMS Dashboard — Design System
   Dark professional theme matching Field Intelligence aesthetic
   ============================================================ */

/* ─── Tokens ─────────────────────────────────────────────── */
:root {
  --bg:          #0f1117;
  --surface-1:   #161b27;
  --surface-2:   #1e2535;
  --surface-3:   #252d3e;
  --border:      rgba(255,255,255,0.07);
  --border-md:   rgba(255,255,255,0.12);

  --text-primary:   #e8edf5;
  --text-secondary: #94a3b8;
  --text-muted:     #64748b;

  --accent:      #3b82f6;
  --accent-glow: rgba(59,130,246,0.2);
  --accent-hover:#2563eb;

  --green:  #10b981;
  --amber:  #f59e0b;
  --red:    #ef4444;
  --blue:   #3b82f6;
  --purple: #8b5cf6;
  --teal:   #14b8a6;
  --gold:   #eab308;

  --sidebar-w: 224px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  --radius-sm: 4px;
  --radius:    8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --font: 'DM Sans', system-ui, sans-serif;
  --mono: 'DM Mono', 'Fira Mono', monospace;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow:    0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.6);
}

/* ─── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
button { font-family: var(--font); cursor: pointer; }
input, select, textarea { font-family: var(--font); }

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

/* ─── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-4);
  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-weight: 700; font-size: 12px; letter-spacing: 0.05em;
  color: #fff; flex-shrink: 0;
}
.brand-mark--lg { width: 40px; height: 40px; font-size: 14px; border-radius: var(--radius); }
.brand-name { font-weight: 600; font-size: 13px; line-height: 1.2; }
.brand-sub { font-size: 11px; color: var(--text-muted); }

.sidebar-nav {
  flex: 1;
  padding: var(--space-3) var(--space-2);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item:hover { background: var(--surface-2); color: var(--text-primary); }
.nav-item.active { background: var(--accent-glow); color: var(--accent); }

.nav-item--sub { padding-left: var(--space-8); font-size: 12px; opacity: 0.8; }

/* Collapsible nav group (Reference section) */
.nav-group { list-style: none; }
.nav-group summary { list-style: none; }
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group-toggle { cursor: pointer; user-select: none; }
.nav-group-label { flex: 1; }
.nav-group-chevron { width: 12px !important; height: 12px !important; transition: transform 0.2s; color: var(--text-muted); }
details.nav-group[open] .nav-group-chevron { transform: rotate(180deg); }
.nav-sub { display: flex; flex-direction: column; gap: 1px; padding-left: var(--space-5); margin-top: 2px; }
.nav-sub-item {
  display: block; padding: 5px var(--space-3);
  border-radius: var(--radius-sm); color: var(--text-secondary);
  font-size: 12px; font-weight: 500; text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.nav-sub-item:hover { background: var(--surface-2); color: var(--text-primary); }
.nav-sub-item.active { background: var(--accent-glow); color: var(--accent); }
.nav-item--ps { gap: var(--space-2); }

.ps-avatar {
  width: 22px; height: 22px;
  background: var(--surface-3);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; flex-shrink: 0;
  border: 1px solid var(--border-md);
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: var(--space-4) var(--space-3) var(--space-2);
}

.nav-divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-2) 0;
}

.sidebar-footer {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.user-chip {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}
.user-chip-avatar {
  width: 28px; height: 28px;
  background: var(--accent-glow);
  border: 1px solid var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: var(--accent);
  flex-shrink: 0;
}
.user-chip-name { font-size: 12px; font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip-role { font-size: 10px; color: var(--text-muted); text-transform: capitalize; display: block; }

.btn-logout {
  width: 28px; height: 28px;
  background: none;
  border: 1px solid var(--border-md);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.btn-logout svg { width: 14px; height: 14px; }
.btn-logout:hover { background: var(--surface-3); color: var(--red); border-color: var(--red); }

/* ─── Main Content ───────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: var(--space-8);
  min-width: 0;
}

/* ─── Page Header ────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  gap: var(--space-4);
}
.page-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}
.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}
.breadcrumb {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--accent); }

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

/* ─── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: 7px var(--space-4);
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  border: 1px solid transparent;
  transition: all 0.15s;
  cursor: pointer; white-space: nowrap;
}
.btn-icon { width: 14px; height: 14px; }
.btn--primary  { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn--primary:hover { background: var(--accent-hover); }
.btn--outline  { background: transparent; color: var(--text-secondary); border-color: var(--border-md); }
.btn--outline:hover { background: var(--surface-2); color: var(--text-primary); }
.btn--ghost    { background: transparent; color: var(--text-muted); border-color: transparent; }
.btn--ghost:hover { background: var(--surface-2); color: var(--text-secondary); }
.btn--full     { width: 100%; justify-content: center; }
.btn--sm       { padding: 5px var(--space-3); font-size: 12px; }
.btn:disabled  { opacity: 0.5; cursor: not-allowed; }

/* ─── Forms ──────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: var(--space-1); }
.form-label { font-size: 12px; font-weight: 500; color: var(--text-secondary); }
.form-input, .form-select {
  background: var(--surface-2);
  border: 1px solid var(--border-md);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 7px var(--space-3);
  font-size: 13px;
  transition: border-color 0.15s;
  width: 100%;
}
.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}
.form-input--sm, .form-select--sm { padding: 5px var(--space-2); font-size: 12px; }
.inline-select {
  background: var(--surface-2); border: 1px solid var(--border-md);
  color: var(--text-primary); border-radius: var(--radius-sm);
  padding: 2px 6px; font-size: 13px; cursor: pointer;
}

/* ─── Section Card ───────────────────────────────────────── */
.section-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.section-card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}
.section-title {
  font-size: 14px; font-weight: 600;
  color: var(--text-primary);
}

/* ─── KPI Row ────────────────────────────────────────────── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.kpi-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  position: relative;
}
.kpi-card--accent { border-color: rgba(59,130,246,0.3); background: rgba(59,130,246,0.05); }
.kpi-label { font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted); margin-bottom: var(--space-2); }
.kpi-value { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; margin-bottom: var(--space-1); }
.kpi-value--rm { font-size: 22px; }
.kpi-sub { font-size: 11px; color: var(--text-muted); margin-bottom: var(--space-3); }
.kpi-bar { height: 3px; background: var(--surface-3); border-radius: 2px; margin-bottom: var(--space-2); overflow: hidden; }
.kpi-bar-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.6s ease; }
.kpi-bar-fill--blue  { background: var(--blue); }
.kpi-bar-fill--green { background: var(--green); }
.kpi-bar-fill--amber { background: var(--amber); }
.kpi-bar-fill--gold  { background: var(--gold); }
.kpi-pct { font-size: 12px; font-weight: 600; }

/* ─── PS Cards (manager overview) ───────────────────────── */
.ps-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-5);
  margin-bottom: var(--space-6);
}
.ps-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  transition: border-color 0.2s;
}
.ps-card:hover { border-color: var(--border-md); }
.ps-card-header { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-5); }
.ps-card-avatar {
  width: 38px; height: 38px;
  background: var(--accent-glow);
  border: 1px solid rgba(59,130,246,0.4);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; color: var(--accent);
  flex-shrink: 0;
}
.ps-card-name { font-size: 14px; font-weight: 600; }
.ps-card-email { font-size: 11px; color: var(--text-muted); }
.ps-card-link {
  margin-left: auto;
  width: 28px; height: 28px;
  background: var(--surface-2);
  border: 1px solid var(--border-md);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: all 0.15s;
}
.ps-card-link svg { width: 12px; height: 12px; }
.ps-card-link:hover { background: var(--accent); border-color: var(--accent); color: #fff; }

.ps-card-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-3); margin-bottom: var(--space-4); }
.mini-kpi { text-align: center; }
.mini-kpi-val { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.mini-kpi-label { font-size: 10px; color: var(--text-muted); }

.achievement-bar-wrap { margin-bottom: var(--space-3); }
.achievement-bar-label { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-muted); margin-bottom: var(--space-1); }
.achievement-bar { height: 4px; background: var(--surface-3); border-radius: 2px; overflow: hidden; }
.achievement-bar-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.6s; }
.achievement-bar-fill--blue { background: var(--blue); }

.ps-card-incentive { display: flex; justify-content: space-between; align-items: center; padding-top: var(--space-3); border-top: 1px solid var(--border); font-size: 12px; color: var(--text-muted); margin-top: var(--space-3); }
.incentive-val { font-weight: 600; color: var(--text-primary); font-family: var(--mono); }
.incentive-of { font-weight: 400; color: var(--text-muted); }

/* ─── Achievement % colors ───────────────────────────────── */
.pct--good { color: var(--green); }
.pct--mid  { color: var(--amber); }
.pct--low  { color: var(--red); }

/* ─── Tables ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  vertical-align: middle;
}
.data-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table th.text-right,
.data-table td.text-right { text-align: right; }
.data-table th.num,
.data-table td.num { text-align: right; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table--compact th, .data-table--compact td { padding: var(--space-2) var(--space-3); }

.table-total td { font-weight: 600; background: var(--surface-2); }

.table-bar-wrap { display: flex; align-items: center; gap: var(--space-2); }
.table-bar { flex: 1; height: 4px; background: var(--surface-3); border-radius: 2px; overflow: hidden; min-width: 48px; }
.table-bar-fill { height: 100%; border-radius: 2px; transition: width 0.5s; }
.fill--good { background: var(--green); }
.fill--mid  { background: var(--amber); }
.fill--low  { background: var(--red); }
.table-bar-pct { font-size: 11px; color: var(--text-muted); white-space: nowrap; font-family: var(--mono); min-width: 38px; text-align: right; }

.ps-avatar-sm {
  width: 22px; height: 22px;
  background: var(--accent-glow);
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: var(--accent);
  vertical-align: middle; margin-right: var(--space-2); flex-shrink: 0;
}
.link-name { display: inline-flex; align-items: center; color: var(--text-primary); font-weight: 500; }
.link-name:hover { color: var(--accent); }

/* ─── Two-col layout ─────────────────────────────────────── */
.two-col-grid { display: grid; grid-template-columns: 1fr 380px; gap: var(--space-6); align-items: start; }
.col-right { display: flex; flex-direction: column; gap: var(--space-4); }

/* ─── Capacity Grid ──────────────────────────────────────── */
.capacity-grid { padding: var(--space-4) var(--space-5); }
.cap-row { display: flex; justify-content: space-between; align-items: center; padding: var(--space-2) 0; font-size: 13px; }
.cap-row--divider { border-top: 1px solid var(--border); margin: var(--space-2) 0; padding: 0; }
.cap-row--total .cap-val { font-weight: 700; }
.cap-row--highlight { background: var(--surface-2); margin: 0 calc(-1 * var(--space-5)); padding: var(--space-3) var(--space-5); border-top: 1px solid var(--border); }
.cap-label { color: var(--text-muted); }
.cap-val { font-family: var(--mono); font-size: 13px; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

/* ─── Badges ─────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 500; }
.badge--neutral { background: var(--surface-3); color: var(--text-secondary); border: 1px solid var(--border-md); }

.code-badge {
  display: inline-block;
  background: var(--surface-3);
  border: 1px solid var(--border-md);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 11px;
  padding: 1px 6px;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* Brand tags */
.brand-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  border: 1px solid var(--border-md);
  background: var(--surface-3);
  color: var(--text-secondary);
}
.brand-tag--ntm  { background: rgba(16,185,129,0.12); border-color: rgba(16,185,129,0.3); color: #10b981; }
.brand-tag--ntz  { background: rgba(59,130,246,0.12); border-color: rgba(59,130,246,0.3); color: #60a5fa; }
.brand-tag--mds  { background: rgba(139,92,246,0.12); border-color: rgba(139,92,246,0.3); color: #a78bfa; }
.brand-tag--pfx  { background: rgba(245,158,11,0.12); border-color: rgba(245,158,11,0.3); color: #fbbf24; }
.brand-tag--tph  { background: rgba(236,72,153,0.12); border-color: rgba(236,72,153,0.3); color: #f472b6; }
.brand-tag--pgm  { background: rgba(20,184,166,0.12); border-color: rgba(20,184,166,0.3); color: #2dd4bf; }
.brand-tag--ntg  { background: rgba(234,179,8,0.12);  border-color: rgba(234,179,8,0.3);  color: #facc15; }
.brand-tag--all  { background: rgba(100,116,139,0.12); border-color: rgba(100,116,139,0.3); color: #94a3b8; }

.brand-tags { display: flex; flex-wrap: wrap; gap: 3px; }

/* ─── Recency Badges ─────────────────────────────────────── */
.recency-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.recency-badge--this_month { background: rgba(16,185,129,0.15); color: #10b981; border: 1px solid rgba(16,185,129,0.3); }
.recency-badge--2_months   { background: rgba(234,179,8,0.15);  color: #eab308; border: 1px solid rgba(234,179,8,0.3); }
.recency-badge--3_months   { background: rgba(245,158,11,0.15); color: #f59e0b; border: 1px solid rgba(245,158,11,0.3); }
.recency-badge--overdue    { background: rgba(239,68,68,0.15);  color: #ef4444; border: 1px solid rgba(239,68,68,0.3); }
.recency-badge--never      { background: rgba(100,116,139,0.15); color: #94a3b8; border: 1px solid rgba(100,116,139,0.3); }

.recency-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.recency-dot--this_month { background: var(--green); }
.recency-dot--2_months   { background: var(--gold); }
.recency-dot--3_months   { background: var(--amber); }
.recency-dot--overdue    { background: var(--red); }
.recency-dot--never      { background: var(--text-muted); }

/* ─── Chain selector ─────────────────────────────────────── */
.chain-selector {
  display: flex; flex-wrap: wrap; gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.chain-chip {
  display: inline-flex; flex-direction: column; align-items: center;
  gap: 2px;
  padding: var(--space-2) var(--space-4);
  background: var(--surface-1);
  border: 1px solid var(--border-md);
  border-radius: var(--radius);
  cursor: pointer; transition: all 0.15s;
  font-family: var(--font); min-width: 72px;
}
.chain-chip:hover { background: var(--surface-2); border-color: var(--accent); }
.chain-chip.active {
  background: var(--accent-glow);
  border-color: rgba(59,130,246,0.5);
  box-shadow: 0 0 0 1px rgba(59,130,246,0.2);
}
.chain-chip-code {
  font-size: 13px; font-weight: 700; letter-spacing: 0.04em;
  color: var(--text-primary);
}
.chain-chip.active .chain-chip-code { color: var(--accent); }
.chain-chip-name {
  font-size: 10px; color: var(--text-muted);
  white-space: nowrap; text-align: center;
}
.chain-chip.active .chain-chip-name { color: rgba(99,179,237,0.8); }
.chain-chip-count {
  font-size: 10px; font-family: var(--mono);
  color: var(--text-muted);
  background: var(--surface-3); border-radius: 999px;
  padding: 0 5px; line-height: 16px;
}
.chain-chip.active .chain-chip-count {
  background: rgba(59,130,246,0.2); color: var(--accent);
}

/* Per-chain accent colours */
.chain-chip--crl.active { --chain-c: #10b981; background: rgba(16,185,129,0.08); border-color: rgba(16,185,129,0.4); }
.chain-chip--crl.active .chain-chip-code,
.chain-chip--crl.active .chain-chip-count { color: #10b981; }
.chain-chip--hlp.active { --chain-c: #3b82f6; background: rgba(59,130,246,0.08); border-color: rgba(59,130,246,0.4); }
.chain-chip--hlp.active .chain-chip-code,
.chain-chip--hlp.active .chain-chip-count { color: #60a5fa; }
.chain-chip--wns.active { --chain-c: #8b5cf6; background: rgba(139,92,246,0.08); border-color: rgba(139,92,246,0.4); }
.chain-chip--wns.active .chain-chip-code,
.chain-chip--wns.active .chain-chip-count { color: #a78bfa; }
.chain-chip--grd.active { --chain-c: #f59e0b; background: rgba(245,158,11,0.08); border-color: rgba(245,158,11,0.4); }
.chain-chip--grd.active .chain-chip-code,
.chain-chip--grd.active .chain-chip-count { color: #fbbf24; }
.chain-chip--smc.active { --chain-c: #14b8a6; background: rgba(20,184,166,0.08); border-color: rgba(20,184,166,0.4); }
.chain-chip--smc.active .chain-chip-code,
.chain-chip--smc.active .chain-chip-count { color: #2dd4bf; }
.chain-chip--ap.active  { --chain-c: #ec4899; background: rgba(236,72,153,0.08); border-color: rgba(236,72,153,0.4); }
.chain-chip--ap.active  .chain-chip-code,
.chain-chip--ap.active  .chain-chip-count { color: #f472b6; }
.chain-chip--big.active { --chain-c: #f97316; background: rgba(249,115,22,0.08); border-color: rgba(249,115,22,0.4); }
.chain-chip--big.active .chain-chip-code,
.chain-chip--big.active .chain-chip-count { color: #fb923c; }

.filter-chip--chain { background: var(--surface-3); border-color: var(--border-md); color: var(--text-secondary); }

/* ─── Territory multi-filter bar ─────────────────────────── */
.mfilter-bar {
  display: flex; flex-wrap: wrap; gap: var(--space-2);
  align-items: center;
  padding: var(--space-3) var(--space-4);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-3);
}
.mfilter-search {
  display: flex; align-items: center; gap: var(--space-2);
  background: var(--surface-2); border: 1px solid var(--border-md);
  border-radius: var(--radius-sm); padding: 5px var(--space-3);
  flex: 1; min-width: 160px; max-width: 240px;
}
.mfilter-search-input {
  background: none; border: none; color: var(--text-primary);
  font-size: 13px; width: 100%; outline: none; font-family: var(--font);
}
.mfilter-search-input::placeholder { color: var(--text-muted); }

/* Checkbox dropdown */
.mfd { position: relative; }
.mfd-btn {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: 5px var(--space-3);
  background: var(--surface-2); border: 1px solid var(--border-md);
  border-radius: var(--radius-sm); color: var(--text-secondary);
  font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: all 0.15s; font-family: var(--font);
}
.mfd-btn:hover, .mfd-btn--open { background: var(--surface-3); color: var(--text-primary); border-color: var(--accent); }
.mfd-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  background: var(--accent); color: #fff;
  border-radius: 999px; font-size: 10px; font-weight: 700;
}
.mfd-chevron { width: 14px; height: 14px; color: var(--text-muted); transition: transform 0.15s; }
.mfd-btn--open .mfd-chevron { transform: rotate(180deg); }

.mfd-menu {
  display: none; position: absolute; top: calc(100% + 6px); left: 0;
  min-width: 200px; max-height: 280px;
  background: var(--surface-2); border: 1px solid var(--border-md);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  z-index: 300; overflow-y: auto; overflow-x: hidden;
}
.mfd-menu.open { display: block; }

.mfd-item {
  display: flex; align-items: center; gap: var(--space-2);
  padding: 7px var(--space-3); cursor: pointer;
  font-size: 13px; color: var(--text-secondary);
  transition: background 0.1s;
}
.mfd-item:hover { background: var(--surface-3); color: var(--text-primary); }
.mfd-item input[type="checkbox"] { width: 14px; height: 14px; flex-shrink: 0; accent-color: var(--accent); cursor: pointer; }
.mfd-brand-name { color: var(--text-muted); font-size: 12px; }

.mfd-footer {
  border-top: 1px solid var(--border); padding: var(--space-2) var(--space-3);
  display: flex; justify-content: flex-end;
}
.mfd-footer button {
  background: none; border: none; color: var(--text-muted); font-size: 12px;
  cursor: pointer; padding: 2px var(--space-2); border-radius: var(--radius-sm);
  font-family: var(--font);
}
.mfd-footer button:hover { background: var(--surface-3); color: var(--text-secondary); }

/* Active filter chips */
.filter-chips {
  display: flex; flex-wrap: wrap; gap: var(--space-2);
  margin-bottom: var(--space-4);
}
.filter-chip {
  display: inline-flex; align-items: center; gap: var(--space-1);
  background: var(--accent-glow); border: 1px solid rgba(59,130,246,0.3);
  border-radius: 999px; padding: 3px 10px;
  font-size: 12px; color: var(--accent);
}
.filter-chip-x {
  background: none; border: none; color: var(--accent); font-size: 14px;
  line-height: 1; cursor: pointer; padding: 0 1px; opacity: 0.7;
  font-family: var(--font);
}
.filter-chip-x:hover { opacity: 1; }

.assigned-ps-list { display: flex; flex-direction: column; gap: 3px; min-width: 160px; }
.assigned-chip {
  display: flex; align-items: center; gap: var(--space-2);
  background: var(--surface-2);
  border: 1px solid var(--border-md);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  font-size: 12px;
}
.assigned-name { flex: 1; }
.chip-remove { background: none; border: none; color: var(--text-muted); font-size: 14px; line-height: 1; padding: 0 2px; }
.chip-remove:hover { color: var(--red); }
.add-ps-select { width: 100%; font-size: 11px; background: var(--surface-2); border: 1px dashed var(--border-md); border-radius: var(--radius-sm); color: var(--text-muted); padding: 3px 6px; cursor: pointer; }
.add-ps-select:focus { outline: none; border-color: var(--accent); color: var(--text-primary); }

.outlet-name { font-weight: 500; font-size: 13px; }
.outlet-address { margin-top: 1px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px;
  background: var(--surface-2);
  border: 1px solid var(--border-md);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: all 0.15s;
}
.icon-btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Bulk panel (legacy - kept for reference) */
.bulk-panel { display: none; }

/* ─── Sticky bulk action bar ─────────────────────────────── */
.bulk-bar {
  position: fixed;
  bottom: 0;
  left: var(--sidebar-w);
  right: 0;
  z-index: 400;
  background: var(--surface-1);
  border-top: 2px solid var(--accent);
  box-shadow: 0 -4px 32px rgba(0,0,0,0.5);
  transition: transform 0.25s cubic-bezier(0.4,0,0.2,1), opacity 0.25s ease;
}
.bulk-bar--hidden  { transform: translateY(100%); opacity: 0; pointer-events: none; }
.bulk-bar--visible { transform: translateY(0);    opacity: 1; pointer-events: all; }

.bulk-bar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
  padding: var(--space-4) var(--space-8);
  max-width: 1600px;
}
.bulk-bar-info   { display: flex; align-items: center; gap: var(--space-3); }
.bulk-bar-count  { font-weight: 700; font-size: 14px; color: var(--accent); font-family: var(--mono); }
.bulk-bar-sep    { color: var(--border-md); font-size: 16px; }
.bulk-bar-clear  {
  background: none; border: none; cursor: pointer;
  font-size: 12px; color: var(--text-muted); font-family: var(--font);
  text-decoration: underline; padding: 0;
}
.bulk-bar-clear:hover { color: var(--text-secondary); }
.bulk-bar-actions { display: flex; align-items: center; gap: var(--space-3); }
.bulk-bar-label   { font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.bulk-bar-select  { min-width: 200px; }

/* Selected row highlight */
tr.row--selected { background: rgba(59,130,246,0.07) !important; outline: none; }
tr.row--selected td { border-bottom-color: rgba(59,130,246,0.2); }

/* ─── Target Grid ────────────────────────────────────────── */
.target-selector-bar {
  display: flex; align-items: flex-end; gap: var(--space-4); flex-wrap: wrap;
  margin-bottom: var(--space-5);
}
.selector-group { display: flex; flex-direction: column; gap: var(--space-1); }
.selector-group .form-select { min-width: 180px; }

.target-grid-wrap { overflow-x: auto; padding: var(--space-4); }
.target-grid { border-collapse: collapse; font-size: 12px; }
.target-grid th, .target-grid td { border: 1px solid var(--border); }
.tg-code-col { min-width: 140px; padding: var(--space-2) var(--space-3); background: var(--surface-2); position: sticky; left: 0; z-index: 2; }
.tg-pts-col  { width: 44px; text-align: center; background: var(--surface-2); padding: var(--space-2); position: sticky; left: 140px; z-index: 2; }
.tg-brand-col { min-width: 90px; text-align: center; padding: var(--space-2) var(--space-3); background: var(--surface-1); }
.target-grid thead th { background: var(--surface-2); color: var(--text-secondary); font-size: 11px; font-weight: 600; }
.tg-code-cell { background: var(--surface-1); padding: var(--space-2) var(--space-3); position: sticky; left: 0; z-index: 1; }
.tg-pts-cell  { text-align: center; background: var(--surface-1); font-size: 11px; padding: var(--space-2); position: sticky; left: 140px; z-index: 1; }
.tg-input-cell { padding: 3px; }
.tg-input {
  width: 70px; text-align: center;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--mono);
  font-size: 12px;
  padding: 4px 6px;
  transition: all 0.15s;
}
.tg-input:focus { outline: none; border-color: var(--accent); background: var(--surface-3); }
.tg-input::placeholder { color: var(--text-muted); }

.capacity-settings-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-4); padding: var(--space-5);
}

/* ─── Brand Tabs ─────────────────────────────────────────── */
.brand-tabs { display: flex; flex-wrap: wrap; gap: var(--space-2); padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border); }
.brand-tab-btn {
  display: flex; align-items: center; gap: var(--space-2);
  background: var(--surface-2); border: 1px solid var(--border-md);
  border-radius: var(--radius-sm); padding: 5px var(--space-3);
  color: var(--text-muted); font-size: 12px; cursor: pointer;
  transition: all 0.15s;
}
.brand-tab-btn.active { background: var(--accent-glow); border-color: rgba(59,130,246,0.4); color: var(--text-primary); }
.brand-tab-btn:hover:not(.active) { background: var(--surface-3); color: var(--text-secondary); }
.brand-tab-panel { display: none; }
.brand-tab-panel.active { display: block; }

/* ─── Visit Planning ─────────────────────────────────────── */
.recency-summary { display: flex; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-5); }
.recency-summary-chip {
  display: flex; align-items: center; gap: var(--space-2);
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--space-3) var(--space-4);
  font-size: 12px; cursor: pointer; transition: border-color 0.15s;
  text-decoration: none; color: var(--text-secondary);
}
.recency-summary-chip:hover { border-color: var(--border-md); color: var(--text-primary); }
.recency-summary-chip.active { border-color: var(--accent); color: var(--accent); background: var(--accent-glow); }
.summary-count { font-size: 20px; font-weight: 700; color: var(--text-primary); }
.summary-label { font-size: 11px; color: var(--text-muted); }

/* ─── Sync status ────────────────────────────────────────── */
.sync-status { display: flex; align-items: center; gap: var(--space-2); font-size: 12px; color: var(--text-muted); }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); flex-shrink: 0; }
.sync-status--running .sync-dot { background: var(--amber); animation: pulse 1s infinite; }
.sync-status--error .sync-dot { background: var(--red); }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.3; } }

/* ─── Toast ──────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: var(--space-5); right: var(--space-5);
  background: var(--surface-2); border: 1px solid var(--border-md);
  border-radius: var(--radius); padding: var(--space-3) var(--space-5);
  font-size: 13px; display: flex; align-items: center; gap: var(--space-3);
  box-shadow: var(--shadow-lg); z-index: 1000;
  transition: opacity 0.3s, transform 0.3s;
}
.toast--hidden  { opacity: 0; pointer-events: none; transform: translateY(8px); }
.toast--visible { opacity: 1; transform: none; }
.toast--success { border-color: rgba(16,185,129,0.4); background: rgba(16,185,129,0.1); }
.toast--error   { border-color: rgba(239,68,68,0.4); background: rgba(239,68,68,0.1); }
.toast-icon     { font-size: 16px; }

/* ─── Alerts ─────────────────────────────────────────────── */
.alert { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm); font-size: 13px; margin-bottom: var(--space-4); }
.alert--error { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: #fca5a5; }

/* ─── Login ──────────────────────────────────────────────── */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); padding: var(--space-5); }
.login-container { width: 100%; max-width: 380px; }
.login-card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-xl); padding: var(--space-8); box-shadow: var(--shadow-lg); }
.login-brand { display: flex; align-items: center; gap: var(--space-4); margin-bottom: var(--space-8); }
.login-brand-name { font-size: 16px; font-weight: 700; }
.login-brand-sub { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.login-form { display: flex; flex-direction: column; gap: var(--space-4); }
.login-footer { text-align: center; font-size: 11px; color: var(--text-muted); margin-top: var(--space-4); }

/* ─── Error page ─────────────────────────────────────────── */
.error-page { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 60vh; text-align: center; }
.error-code { font-size: 64px; font-weight: 800; color: var(--text-muted); opacity: 0.3; }
.error-msg { font-size: 16px; color: var(--text-secondary); margin: var(--space-3) 0 var(--space-6); }

/* ─── Empty state ────────────────────────────────────────── */
.empty-state { padding: var(--space-10); text-align: center; }
.empty-icon { font-size: 32px; margin-bottom: var(--space-4); }
.empty-title { font-size: 15px; font-weight: 600; margin-bottom: var(--space-2); }
.empty-sub { font-size: 13px; color: var(--text-muted); }

/* ─── Utility ────────────────────────────────────────────── */
.mono { font-family: var(--mono); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* ─── Badge variants ─────────────────────────────────────── */
.badge--success { background: rgba(16,185,129,0.12); color: #10b981; border: 1px solid rgba(16,185,129,0.3); }
.badge--warning { background: rgba(245,158,11,0.12); color: #f59e0b; border: 1px solid rgba(245,158,11,0.3); }
.badge--accent  { background: var(--accent-glow); color: var(--accent); border: 1px solid rgba(59,130,246,0.3); }
.badge--muted   { background: var(--surface-3); color: var(--text-muted); border: 1px solid var(--border); }

/* ─── Table row states ───────────────────────────────────── */
.row--inactive td { opacity: 0.45; }

/* ─── Modal ──────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(2px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-5);
  transition: opacity 0.2s;
}
.modal-backdrop--hidden  { opacity: 0; pointer-events: none; }
.modal-backdrop--visible { opacity: 1; pointer-events: all; }

.modal {
  background: var(--surface-1);
  border: 1px solid var(--border-md);
  border-radius: var(--radius-xl);
  width: 100%; max-width: 480px;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  max-height: 90vh; overflow: hidden;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title { font-size: 15px; font-weight: 600; }
.modal-close {
  width: 28px; height: 28px;
  background: none; border: 1px solid var(--border-md);
  border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: 16px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.15s;
}
.modal-close:hover { background: var(--surface-3); color: var(--text-primary); }

.modal-body {
  padding: var(--space-5) var(--space-6);
  display: flex; flex-direction: column; gap: var(--space-4);
  overflow-y: auto; flex: 1;
}
.modal-footer {
  display: flex; align-items: center; justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ─── Form extras ────────────────────────────────────────── */
.form-hint  { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.form-hint--success { color: var(--green); }
.form-hint--warn    { color: var(--amber); }
.form-error { font-size: 12px; color: #fca5a5; background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3); }
.form-error--warn { color: var(--amber); background: rgba(245,158,11,0.1); border-color: rgba(245,158,11,0.3); }
.input-with-action { display: flex; gap: var(--space-2); align-items: center; }

/* ─── User name cell ─────────────────────────────────────── */
.user-name-cell { display: flex; align-items: center; gap: var(--space-2); font-weight: 500; }

/* ─── Tabs ───────────────────────────────────────────────── */
.tab-bar {
  display: flex; gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-5);
}
.tab-btn {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  font-size: 13px; font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
  text-decoration: none;
  background: none; border-top: none; border-left: none; border-right: none;
  cursor: pointer;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px;
  background: rgba(239,68,68,0.15); color: #ef4444;
  border-radius: 999px; font-size: 10px; font-weight: 700;
  padding: 0 5px;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ─── Inline form (exceptions add row) ──────────────────── */
.inline-form { padding: var(--space-5); }
.inline-form-fields {
  display: flex; flex-wrap: wrap; gap: var(--space-4);
  margin-bottom: var(--space-4);
}
.inline-form-fields .form-group { flex: 1; min-width: 160px; }
.inline-form-fields .form-group--wide { flex: 2; min-width: 240px; }
.inline-form-actions { display: flex; justify-content: flex-end; }

/* ─── Error page (standalone) ────────────────────────────── */
.error-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); padding: var(--space-5); }
.error-card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-xl); padding: var(--space-10); text-align: center; max-width: 420px; width: 100%; box-shadow: var(--shadow-lg); }
.error-icon { color: var(--amber); margin-bottom: var(--space-5); }
.error-title { font-size: 20px; font-weight: 700; margin-bottom: var(--space-3); }
.error-message { font-size: 14px; color: var(--text-muted); margin-bottom: var(--space-6); line-height: 1.6; }

/* ─── PS Overview ─────────────────────────────────────────── */

/* Range picker */
.range-picker-form { display: flex; align-items: center; }
.range-picker { display: flex; align-items: center; gap: var(--space-3); background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-2) var(--space-4); }
.range-picker-group { display: flex; align-items: center; gap: var(--space-2); }
.range-picker-label { font-size: 11px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.range-picker-select { background: transparent; border: none; color: var(--text-primary); font-size: 13px; font-weight: 500; cursor: pointer; outline: none; }
.range-picker-sep { color: var(--text-muted); font-size: 13px; padding: 0 var(--space-1); }

/* PS card wrapper */
.pso-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  margin-bottom: var(--space-5);
  overflow: hidden;
}

/* Card header */
.pso-card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.pso-header-left { display: flex; align-items: center; gap: var(--space-4); }
.pso-header-right { display: flex; align-items: center; gap: var(--space-3); }
.pso-rank { font-size: 22px; min-width: 32px; }
.pso-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; flex-shrink: 0;
}
.pso-identity { display: flex; flex-direction: column; }
.pso-name { font-weight: 600; font-size: 15px; }
.pso-email { font-size: 12px; color: var(--text-muted); }

/* WV achievement bar */
.pso-wv-bar-wrap { padding: var(--space-4) var(--space-6) var(--space-3); }
.pso-wv-bar-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); margin-bottom: var(--space-2); }
.pso-wv-bar-pct { font-weight: 700; color: var(--text-primary); }
.pso-wv-bar-track {
  position: relative;
  height: 8px; border-radius: 4px;
  background: var(--surface-3);
  overflow: visible;
}
.pso-wv-bar-fill {
  height: 100%; border-radius: 4px; transition: width 0.4s ease;
}
.pso-wv-bar-fill--success { background: var(--green); }
.pso-wv-bar-fill--warning { background: var(--amber); }
.pso-wv-bar-fill--danger  { background: var(--red); }
.pso-wv-bar-marker {
  position: absolute; top: -4px; bottom: -4px;
  width: 2px; background: rgba(255,255,255,0.3); border-radius: 1px;
  transform: translateX(-50%);
}
.pso-wv-bar-marker span {
  position: absolute; top: -18px; left: 50%; transform: translateX(-50%);
  font-size: 10px; color: var(--text-muted); white-space: nowrap;
}

/* KPI grid */
.pso-kpis {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 1px; background: var(--border);
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.pso-kpi {
  background: var(--surface-1);
  padding: var(--space-4) var(--space-5);
}
.pso-kpi-val {
  font-size: 20px; font-weight: 700; font-family: var(--mono);
  color: var(--text-primary); margin-bottom: 2px;
}
.pso-kpi-cap { font-size: 14px; font-weight: 400; color: var(--text-muted); }
.pso-kpi-lbl { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 2px; }
.pso-kpi-sub { font-size: 12px; color: var(--text-muted); }

/* By-brand accordion */
.pso-brands { padding: var(--space-4) var(--space-6); }
.pso-brands-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-3); }
.pso-section-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-muted);
}
.btn--xs { font-size: 11px; padding: 3px 8px; height: auto; }

.pso-brand-accordion { border: 1px solid var(--border); border-radius: 6px; margin-bottom: var(--space-2); overflow: hidden; }
.pso-brand-accordion-hdr {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  cursor: pointer; user-select: none;
  background: var(--surface-2);
  transition: background 0.15s;
}
.pso-brand-accordion-hdr:hover { background: var(--surface-3); }
.pso-brand-code { font-size: 11px; font-weight: 700; color: var(--accent); width: 44px; flex-shrink: 0; }
.pso-brand-name-dim { font-size: 12px; color: var(--text-muted); flex: 1; }
.pso-brand-total-wv { font-size: 12px; font-weight: 600; font-family: var(--mono); color: var(--text-primary); margin-right: var(--space-2); }
.pso-brand-chevron { width: 14px; height: 14px; color: var(--text-muted); flex-shrink: 0; transition: transform 0.2s; }

.pso-brand-detail { background: var(--surface-1); border-top: 1px solid var(--border); }
.pso-brand-wv-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.pso-brand-wv-table th {
  padding: 6px 12px; text-align: left; font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted);
  border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.pso-brand-wv-table th.num { text-align: right; }
.pso-brand-wv-table td { padding: 6px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.pso-brand-wv-table td.num { text-align: right; font-family: var(--mono); }
.pso-brand-wv-table td.dim { color: var(--text-muted); }
.pso-brand-wv-table tr:last-child td { border-bottom: none; }

.pso-wv-inline-bar { display: flex; align-items: center; gap: var(--space-2); }
.pso-wv-inline-track { flex: 1; height: 5px; background: var(--surface-3); border-radius: 3px; overflow: hidden; min-width: 60px; }
.pso-wv-inline-fill { height: 100%; border-radius: 3px; transition: width 0.3s; }
.wvbar--success { background: var(--green); }
.wvbar--warn    { background: var(--amber); }
.wvbar--low     { background: var(--red); }
.pso-wv-inline-pct { font-size: 11px; font-family: var(--mono); color: var(--text-muted); white-space: nowrap; width: 60px; }
.pso-wv-inline-pct.pct--achieved { color: var(--green); font-weight: 600; }
.pso-wv-inline-pct.pct--warn     { color: var(--amber); font-weight: 600; }
.pso-wv-inline-pct.pct--low      { color: var(--red);   font-weight: 600; }
.wv-status-icon { font-size: 11px; }

/* Section divider */
.pso-section-divider { height: 1px; background: var(--border); margin: 0 var(--space-6); }

/* Calendar heatmap */
.cal-grid { padding: var(--space-3) var(--space-6) var(--space-2); max-width: 340px; }
.cal-dow-header {
  display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 3px; margin-bottom: 3px;
}
.cal-dow-header span {
  font-size: 9px; font-weight: 600; text-align: center;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em;
}
.cal-week {
  display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 3px; margin-bottom: 3px;
}
.cal-cell {
  aspect-ratio: 1;
  border-radius: 3px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  font-size: 9px; cursor: default;
  position: relative; min-height: 0; max-height: 48px; max-width: 48px;
  border: 1px solid transparent;
  transition: border-color 0.15s;
}
.cal-cell:hover { border-color: rgba(255,255,255,0.18); }
.cal-cell--other   { background: transparent; opacity: 0.2; }
.cal-cell--holiday { background: rgba(251,191,36,0.08); border-color: rgba(251,191,36,0.2); }
.cal-cell--zero    { background: var(--surface-2); }
.cal-cell--low     { background: rgba(99,102,241,0.15); }
.cal-cell--mid     { background: rgba(99,102,241,0.35); }
.cal-cell--high    { background: rgba(99,102,241,0.65); }
.cal-day-num { font-size: 9px; color: var(--text-muted); font-weight: 500; line-height: 1; }
.cal-visits { font-size: 11px; font-weight: 700; color: var(--text-primary); line-height: 1; }
.cal-holiday-mark { font-size: 8px; font-weight: 700; color: var(--amber); letter-spacing: 0.05em; }
.cal-legend {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 0 var(--space-6) var(--space-3);
}
.cal-legend-item { display: flex; align-items: center; gap: 4px; font-size: 10px; color: var(--text-muted); }
.cal-legend-swatch {
  width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0;
  border: 1px solid var(--border);
}

/* Chart wrapper */
.pso-chart-wrap { padding: var(--space-3) var(--space-6); }

/* Territory Visit Summary */
.pso-tvs-header { display: flex; align-items: center; justify-content: space-between; padding: var(--space-4) var(--space-6); }
.tvs-table td, .tvs-table th { padding: 5px 10px; font-size: 12px; }
.tvs-visits-cell { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.tvs-visits-num  { font-family: var(--mono); font-size: 12px; width: 20px; text-align: right; }
.tvs-visits-track { width: 60px; height: 5px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.tvs-visits-fill  { height: 100%; background: var(--accent); border-radius: 3px; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text-primary); }

/* Outlet detail search */
.outlet-search-wrap { position: relative; }
.outlet-search-row  { display: flex; gap: var(--space-3); align-items: center; }
.outlet-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 100;
  background: var(--surface-2); border: 1px solid var(--border-md);
  border-radius: var(--radius-sm); max-height: 240px; overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.outlet-dd-item {
  padding: 8px 14px; cursor: pointer; font-size: 13px;
  transition: background 0.12s;
}
.outlet-dd-item:hover { background: var(--surface-3); }
.outlet-dd-empty { padding: 10px 14px; font-size: 12px; color: var(--text-muted); }
.outlet-detail-header { padding: var(--space-4) 0 var(--space-3); }
.outlet-detail-title  { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.outlet-detail-meta   { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.outlet-detail-body   { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-6); margin-top: var(--space-4); }
@media (max-width: 900px) { .outlet-detail-body { grid-template-columns: 1fr; } }

/* Coverage section */
.pso-coverage-header {
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-4) var(--space-6);
  flex-wrap: wrap;
}
.pso-coverage-summary { display: flex; gap: var(--space-2); flex-wrap: wrap; flex: 1; }
.cov-toggle-btn { margin-left: auto; flex-shrink: 0; display: flex; align-items: center; gap: 4px; }
.cov-pill {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px;
}
.cov-pill--never   { background: rgba(239,68,68,0.15); color: #ef4444; }
.cov-pill--overdue { background: rgba(239,68,68,0.1); color: #f87171; }
.cov-pill--3months { background: rgba(251,191,36,0.15); color: var(--amber); }
.cov-pill--2months { background: rgba(99,102,241,0.15); color: var(--accent); }
.cov-pill--ok      { background: rgba(34,197,94,0.12); color: var(--green); }

.cov-table-wrap { border-top: 1px solid var(--border); }
.cov-table { border-radius: 0; border: none; }
.cov-table thead th:first-child { padding-left: var(--space-6); }
.cov-table tbody td:first-child { padding-left: var(--space-6); }

/* Brand matrix table */
.brand-matrix-table th, .brand-matrix-table td { text-align: center; }
.brand-matrix-table th:first-child, .brand-matrix-table td:first-child { text-align: left; }
.bm-cell { font-size: 12px; font-weight: 600; font-family: var(--mono); }
.bm-na   { color: var(--text-muted); }
.bm-good { color: var(--green); }
.bm-warn { color: var(--amber); }
.bm-bad  { color: var(--red); }

/* Utilities */
.fw-500 { font-weight: 500; }
.mono   { font-family: var(--mono); font-size: 12px; }

/* ─── Brand tag: HH ───────────────────────────────────────────────────────── */
.brand-tag--hh {
  background: rgba(34,197,94,0.12);
  border-color: rgba(34,197,94,0.3);
  color: #22c55e;
}

/* ─── Inline editing ───────────────────────────────────────────────────────── */
.editable-cell { cursor: text; border-radius: 3px; padding: 1px 4px; }
.editable-cell:hover { background: var(--surface-2); }
.editable-cell:focus { outline: 2px solid var(--accent); background: var(--surface); }
@keyframes flashGreen { 0%,100%{background:transparent} 20%{background:#d1fae5} }
@keyframes flashRed   { 0%,100%{background:transparent} 20%{background:#fee2e2} }
.cell-saved { animation: flashGreen 1.5s ease; }
.cell-error { animation: flashRed 2s ease; }

/* ─── Toggle switch ────────────────────────────────────────────────────────── */
.toggle-switch { position: relative; display: inline-block; width: 36px; height: 20px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: #ccc; border-radius: 20px; cursor: pointer; transition: .2s; }
.toggle-slider:before { content: ''; position: absolute; height: 14px; width: 14px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.toggle-switch input:checked + .toggle-slider { background: var(--green); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(16px); }
