/* ==========================================================================
   Sendloom UI — LiteLLM-inspired light theme
   ========================================================================== */

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #0f172a;
  --text-2: #374151;
  --muted: #6b7280;
  --muted-2: #9ca3af;
  --brand: #4f46e5;
  --brand-600: #4f46e5;
  --brand-700: #4338ca;
  --brand-50: #eef2ff;
  --green: #059669;
  --green-bg: #ecfdf5;
  --amber: #b45309;
  --amber-bg: #fffbeb;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --blue: #2563eb;
  --blue-bg: #eff6ff;
  --violet: #7c3aed;
  --violet-bg: #f5f3ff;
  --sidebar-w: 238px;
  --topbar-h: 56px;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d7dce3; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #b8c0cc; }

[hidden] { display: none !important; }

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

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  display: block; flex: 0 0 auto;
}

.sidebar-brand h1 { font-size: 15px; font-weight: 700; margin: 0; letter-spacing: -.2px; }
.sidebar-brand p { font-size: 11px; color: var(--muted); margin: 0; }

.nav { flex: 1; overflow-y: auto; padding: 12px 10px; }

.nav-group-label {
  font-size: 10.5px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted-2);
  padding: 14px 10px 6px;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  color: var(--text-2); font-size: 13.5px; font-weight: 500;
  text-decoration: none; cursor: pointer; user-select: none;
  transition: background .12s, color .12s;
}
.nav-item svg { width: 17px; height: 17px; flex: 0 0 auto; color: var(--muted); }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--brand-50); color: var(--brand-700); }
.nav-item.active svg { color: var(--brand-600); }
.nav-item .nav-badge {
  margin-left: auto; font-size: 10.5px; font-weight: 600;
  background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px; padding: 1px 6px;
}

.sidebar-foot { padding: 12px; border-top: 1px solid var(--border); flex: 0 0 auto; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 8px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: #e0e7ff; color: #4338ca; font-weight: 700; font-size: 12px;
  display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.user-chip .u-email { font-size: 12px; color: var(--text-2); font-weight: 500; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .u-role { font-size: 10.5px; color: var(--muted-2); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }

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

.crumb { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.crumb strong { color: var(--text); font-weight: 600; }
.crumb svg { width: 15px; height: 15px; color: var(--muted-2); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.tabs-row {
  flex: 0 0 auto; display: flex; align-items: flex-end; gap: 4px;
  padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.tab {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  padding: 10px 12px 9px; font-size: 13px; font-weight: 500; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  text-decoration: none;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--brand-700); border-bottom-color: var(--brand-600); }

.view { flex: 1; overflow: auto; padding: 22px 24px 40px; }
.view-inner { max-width: 1500px; margin: 0 auto; }

/* ---------- Page headers ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.page-head h2 { margin: 0; font-size: 21px; font-weight: 700; letter-spacing: -.3px; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; }

/* ---------- Buttons / inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text-2); font-size: 12.5px; font-weight: 500;
  cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, color .12s;
  font-family: inherit;
}
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.btn-primary:hover { background: var(--brand-700); border-color: var(--brand-700); color: #fff; }
.btn-danger { color: var(--red); border-color: #fecaca; background: #fff; }
.btn-danger:hover { background: var(--red-bg); color: var(--red); }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-success:hover { background: #047857; border-color: #047857; color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { height: 28px; padding: 0 9px; font-size: 12px; border-radius: 7px; }
.btn-icon { width: 34px; padding: 0; }
.btn.spin svg { animation: spin .8s linear infinite; }

.input, .select, textarea.input {
  height: 34px; padding: 0 10px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); font-size: 12.5px; font-family: inherit; outline: none;
  transition: border-color .12s, box-shadow .12s;
}
textarea.input { height: auto; padding: 9px 10px; line-height: 1.5; resize: vertical; }
.input:focus, .select:focus, textarea.input:focus {
  border-color: #a5b4fc; box-shadow: 0 0 0 3px rgba(99, 102, 241, .13);
}
.input::placeholder { color: var(--muted-2); }
.select { appearance: none; padding-right: 28px; background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%236b7280' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; }

.search-wrap { position: relative; display: flex; align-items: center; }
.search-wrap svg { position: absolute; left: 10px; width: 15px; height: 15px; color: var(--muted-2); pointer-events: none; }
.search-wrap .input { padding-left: 32px; width: 290px; max-width: 100%; }

/* ---------- Cards / banners / stats ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }

.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 9px 14px; border-radius: 8px; font-size: 12.5px; margin-bottom: 14px;
  border: 1px solid #bbf7d0; background: #f0fdf4; color: #166534;
}
.banner .btn-link { color: #166534; font-weight: 600; background: none; border: 0; cursor: pointer; font-size: 12.5px; }
.banner.warn { border-color: #fde68a; background: #fffbeb; color: #92400e; }
.banner.info { border-color: #bfdbfe; background: #eff6ff; color: #1e40af; }

.stat-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px;
  padding: 10px 12px; cursor: pointer; transition: border-color .12s, background .12s;
  text-align: left; font-family: inherit;
}
.stat:hover { border-color: #c7d2fe; background: #fbfcff; }
.stat.active { border-color: #a5b4fc; background: var(--brand-50); }
.stat .k { display: block; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.stat .v { display: block; font-size: 18px; font-weight: 700; margin-top: 2px; letter-spacing: -.4px; }
.stat .v small { font-size: 11px; color: var(--muted-2); font-weight: 500; }

/* ---------- Toolbar / filters ---------- */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .spacer { flex: 1; }
.toolbar .count-chip {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 17px; height: 17px; padding: 0 5px; border-radius: 999px;
  background: var(--brand-600); color: #fff; font-size: 10px; font-weight: 700;
}

.filter-panel {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px;
  padding: 12px; margin-bottom: 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.filter-panel label { display: block; font-size: 10.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.filter-panel .select, .filter-panel .input { width: 100%; }

/* ---------- Tables ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table-scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
table.data thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-2); color: var(--muted);
  font-size: 10.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data thead th.sortable { cursor: pointer; user-select: none; }
table.data thead th.sortable:hover { color: var(--text); }
table.data thead th .arrow { margin-left: 4px; color: var(--brand-600); }
table.data tbody td { padding: 8px 12px; border-bottom: 1px solid #f1f3f5; vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr[data-id] { cursor: pointer; }
table.data tbody tr[data-id]:hover { background: var(--surface-2); }
table.data tbody tr.selected { background: var(--brand-50); }
table.data tbody tr.selected:hover { background: #e6e9ff; }
.cell-main { font-weight: 600; color: var(--text); }
.cell-sub { font-size: 11px; color: var(--muted-2); margin-top: 1px; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11.5px; }
.muted { color: var(--muted); }
.faint { color: var(--muted-2); }
.nowrap { white-space: nowrap; }
.check { width: 14px; height: 14px; accent-color: var(--brand-600); cursor: pointer; }
.row-actions { display: inline-flex; align-items: center; gap: 6px; }
.link { color: var(--brand-600); cursor: pointer; text-decoration: none; font-weight: 500; }
.link:hover { text-decoration: underline; }

/* ---------- Pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
  border: 1px solid transparent; white-space: nowrap; line-height: 1.5;
}
.pill .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
.pill.green { color: var(--green); background: var(--green-bg); border-color: #a7f3d0; }
.pill.amber { color: var(--amber); background: var(--amber-bg); border-color: #fde68a; }
.pill.red { color: var(--red); background: var(--red-bg); border-color: #fecaca; }
.pill.blue { color: var(--blue); background: var(--blue-bg); border-color: #bfdbfe; }
.pill.violet { color: var(--violet); background: var(--violet-bg); border-color: #ddd6fe; }
.pill.gray { color: var(--muted); background: var(--surface-2); border-color: var(--border); }

.kw-tag {
  display: inline-flex; align-items: center; gap: 5px; max-width: 210px;
  padding: 2px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 500;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kw-tag .dot { width: 6px; height: 6px; border-radius: 50%; flex: 0 0 auto; }

.dr { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 12px; }
.dr .bar { width: 34px; height: 4px; border-radius: 3px; background: #eef0f3; overflow: hidden; }
.dr .bar i { display: block; height: 100%; border-radius: 3px; }

.badge-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 20px; padding: 0 6px; border-radius: 6px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 11px; font-weight: 600; color: var(--text-2);
}
.badge-count.zero { color: var(--muted-2); font-weight: 500; }

/* ---------- Pagination ---------- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 2px 0; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.pager .pager-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pager .page-size { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.pager .page-size .select { height: 28px; padding: 0 26px 0 8px; font-size: 12px; }
.pager .pages { display: flex; align-items: center; gap: 3px; }
.pager button {
  min-width: 28px; height: 28px; padding: 0 7px; border-radius: 7px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  font-size: 12px; cursor: pointer; font-family: inherit;
}
.pager button:hover:not(:disabled) { background: var(--surface-2); }
.pager button.active { background: var(--brand-600); border-color: var(--brand-600); color: #fff; font-weight: 600; }
.pager button:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- Drawer ---------- */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .32);
  z-index: 60; opacity: 0; transition: opacity .18s ease;
}
.drawer-backdrop.open { opacity: 1; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 560px; max-width: 100vw;
  background: var(--surface); z-index: 61; display: flex; flex-direction: column;
  transform: translateX(102%); transition: transform .22s cubic-bezier(.32,.72,0,1);
  box-shadow: -18px 0 50px rgba(15, 23, 42, .14);
}
.drawer.open { transform: translateX(0); }
.drawer-head {
  flex: 0 0 auto; padding: 18px 20px 14px; border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; gap: 12px;
}
.drawer-head h3 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -.2px; word-break: break-word; }
.drawer-head .sub { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.drawer-head .head-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 20px 24px; }
.drawer-foot { flex: 0 0 auto; padding: 12px 20px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: flex-end; gap: 8px; background: var(--surface-2); }

.dsection { margin-bottom: 18px; }
.dsection h4 { margin: 0 0 8px; font-size: 10.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted-2); }
.prompt-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.prompt-head h4 { margin: 0; }
.pill-row { display: flex; flex-wrap: wrap; gap: 6px; }

.meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.k { font-size: 10.5px; color: var(--muted-2); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.meta-grid .k { font-size: 10.5px; color: var(--muted-2); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.meta-grid .v { font-size: 12.5px; color: var(--text); margin-top: 2px; word-break: break-word; }

.list { border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.list-row { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-bottom: 1px solid #f1f3f5; font-size: 12.5px; }
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; }

.chip {
  display: inline-flex; align-items: center; padding: 2px 7px; border-radius: 6px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 11px; color: var(--text-2); font-family: ui-monospace, monospace;
}

/* ---------- Toast ---------- */
#toasts { position: fixed; right: 18px; bottom: 18px; z-index: 90; display: flex; flex-direction: column; gap: 8px; }
.toast {
  min-width: 240px; max-width: 380px; padding: 10px 13px; border-radius: 9px;
  background: #111827; color: #f9fafb; font-size: 12.5px;
  box-shadow: 0 10px 30px rgba(0,0,0,.18); animation: toastIn .18s ease;
}
.toast.err { background: #b91c1c; }
.toast.ok { background: #065f46; }
@keyframes toastIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Misc ---------- */
.empty { padding: 44px 20px; text-align: center; color: var(--muted); }
.empty .title { font-weight: 600; color: var(--text-2); margin-bottom: 3px; }
.empty .sub { font-size: 12px; color: var(--muted-2); }

.setup-gate {
  max-width: 560px; margin: 28px auto; padding: 32px 28px; text-align: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
}
.setup-gate-icon {
  width: 46px; height: 46px; margin: 0 auto 14px; border-radius: 13px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--brand-700); background: var(--brand-50, #eef2ff); border: 1px solid #e0e7ff;
}
.setup-gate h3 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -.2px; }
.setup-gate p { margin: 7px auto 0; max-width: 410px; color: var(--muted); font-size: 12.5px; line-height: 1.55; }
.setup-gate-action { margin-top: 18px; }
.setup-gate-hint { margin-top: 14px; color: var(--muted-2); font-size: 11px; }

.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(99,102,241,.2); border-top-color: #6366f1;
  animation: spin .6s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-wrap { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 40px; color: var(--muted); font-size: 12.5px; }

.skeleton { position: relative; overflow: hidden; background: #eef1f5; border-radius: 6px; }
.skeleton::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,.65), transparent); animation: shimmer 1.2s infinite; }
@keyframes shimmer { 100% { transform: translateX(100%); } }

.fade-in { animation: fadeIn .18s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: translateY(0); } }

.live-dot { width: 7px; height: 7px; border-radius: 50%; background: #10b981; box-shadow: 0 0 0 0 rgba(16,185,129,.5); animation: pulse 1.6s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 6px rgba(16,185,129,0); } 100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); } }

.switch { position: relative; width: 34px; height: 19px; border-radius: 999px; background: #d1d5db; border: 0; cursor: pointer; transition: background .15s; flex: 0 0 auto; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch.on { background: var(--brand-600); }
.switch.on::after { transform: translateX(15px); }

.popover { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; width: 210px; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; box-shadow: 0 12px 30px rgba(15,23,42,.12); padding: 8px; }
.popover label { display: flex; align-items: center; gap: 8px; padding: 5px 7px; border-radius: 6px; font-size: 12.5px; color: var(--text-2); cursor: pointer; }
.popover label:hover { background: var(--surface-2); }
.popover .pop-title { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted-2); padding: 4px 7px 6px; }
.pop-wrap { position: relative; }

.bulkbar {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; z-index: 40;
  padding: 8px 10px; border-radius: 12px; background: #111827; color: #f9fafb;
  box-shadow: 0 16px 40px rgba(0,0,0,.22); font-size: 12.5px;
}
.bulkbar .btn { height: 28px; border-color: #374151; background: #1f2937; color: #e5e7eb; }
.bulkbar .btn:hover { background: #374151; color: #fff; }
.bulkbar .count { font-weight: 600; padding: 0 6px; }

/* ---------- Dashboard ---------- */
.dash-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 16px;
}
.dash-title h2 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.4px; }
.dash-title .sub { margin: 3px 0 0; font-size: 12px; color: var(--muted); }

.range-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.range-controls {
  display: flex; align-items: center; gap: 6px; padding: 5px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px;
}
.range-controls .select { height: 30px; border: 0; background-color: transparent; font-size: 12px; padding-right: 24px; }
.range-controls .btn { height: 30px; font-size: 12px; padding: 0 10px; }
.date-pair { display: flex; align-items: center; gap: 4px; }
.date-pair .input { height: 30px; width: 132px; font-size: 12px; padding: 0 7px; }
.date-dash { color: var(--muted-2); font-size: 11px; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; min-width: 0; position: relative; overflow: hidden;
}
.kpi-card::before {
  content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--muted-2); opacity: .55;
}
.kpi-card.tone-brand::before { background: var(--brand); }
.kpi-card.tone-cyan::before { background: #0891b2; }
.kpi-card.tone-blue::before { background: var(--blue); }
.kpi-card.tone-green::before { background: var(--green); }
.kpi-card.tone-violet::before { background: var(--violet); }
.kpi-card.tone-amber::before { background: #d97706; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-label { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted-2); }
.kpi-icon {
  width: 26px; height: 26px; border-radius: 7px; display: inline-flex;
  align-items: center; justify-content: center; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--border); flex: 0 0 auto;
}
.tone-brand .kpi-icon { color: var(--brand); background: var(--brand-50); border-color: transparent; }
.tone-cyan .kpi-icon { color: #0891b2; background: #ecfeff; border-color: transparent; }
.tone-blue .kpi-icon { color: var(--blue); background: var(--blue-bg); border-color: transparent; }
.tone-green .kpi-icon { color: var(--green); background: var(--green-bg); border-color: transparent; }
.tone-violet .kpi-icon { color: var(--violet); background: var(--violet-bg); border-color: transparent; }
.tone-amber .kpi-icon { color: #b45309; background: var(--amber-bg); border-color: transparent; }
.kpi-value { font-size: 25px; font-weight: 700; letter-spacing: -.6px; line-height: 1.15; margin: 7px 0 3px; font-variant-numeric: tabular-nums; }
.kpi-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 18px; font-size: 11px; }
.kpi-today { color: var(--green); background: var(--green-bg); border-radius: 999px; padding: 1px 6px; font-weight: 650; white-space: nowrap; }
.kpi-sub { color: var(--muted-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.chart-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 13px 14px 12px; min-width: 0; display: flex; flex-direction: column;
}
.chart-card.span-2 { grid-column: span 2; }
.chart-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.chart-head h3 { margin: 0; font-size: 13px; font-weight: 650; letter-spacing: -.1px; }
.chart-head p { margin: 2px 0 0; font-size: 11px; color: var(--muted-2); }
.chart-chip {
  font-size: 10px; color: var(--muted); background: var(--surface-2);
  border: 1px solid var(--border); padding: 2px 7px; border-radius: 999px; white-space: nowrap;
}
.chart-box { position: relative; height: 208px; min-width: 0; }
.chart-box.chart-tall { height: 258px; }
.chart-empty { height: 100%; display: flex; align-items: center; justify-content: center; text-align: center; color: var(--muted-2); font-size: 12px; border: 1px dashed var(--border); border-radius: 8px; background: var(--surface-2); padding: 12px; }
.chart-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  border-top: 1px solid #f1f3f5; margin-top: 8px; padding-top: 8px;
  font-size: 11px; color: var(--muted-2);
}
.chart-foot strong { color: var(--text); font-variant-numeric: tabular-nums; }

.dash-tables { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.section-head h3 { margin: 0; font-size: 13px; font-weight: 650; }
.section-head p { margin: 2px 0 0; font-size: 11px; color: var(--muted-2); }
.btn-link { color: var(--brand); font-size: 11.5px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.btn-link:hover { color: var(--brand-700); text-decoration: underline; }
.mini-empty { padding: 28px 14px; text-align: center; color: var(--muted-2); font-size: 12px; }
.cell-main { font-weight: 550; color: var(--text); word-break: break-word; }
.cell-sub { font-size: 11px; color: var(--muted-2); margin-top: 1px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .sub-tab { padding: 8px 9px 7px; gap: 5px; }
  .filter-panel { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .chart-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-card.span-2 { grid-column: span 2; }
  .dash-tables { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .sidebar { width: 64px; flex-basis: 64px; }
  .sidebar-brand h1, .sidebar-brand p, .nav-group-label, .nav-item span, .nav-badge { display: none; }
  .nav-item { justify-content: center; padding: 10px; }
  .user-chip .u-meta, .sidebar-foot .run-btn span { display: none; }
  .search-wrap .input { width: 190px; }
  .drawer { width: 100vw; }
}
@media (max-width: 640px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-panel { grid-template-columns: 1fr 1fr; }
  .view { padding: 16px 14px 32px; }
  .topbar { padding: 0 14px; }
  .tabs-row { padding: 0 12px; overflow-x: auto; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-grid { grid-template-columns: 1fr; }
  .chart-card.span-2 { grid-column: span 1; }
  .range-bar { width: 100%; }
  .range-controls { flex: 1; flex-wrap: wrap; }
  .date-pair .input { width: 120px; }
}

/* ---------- Outreach tabs ---------- */
.sub-tabs-bar {
  display: flex; align-items: flex-end; gap: 8px;
  margin: 0 0 12px; border-bottom: 1px solid var(--border);
}
.sub-tabs-bar .sub-tabs { flex: 1; border-bottom: 0; margin-bottom: 0; }
.tabs-refresh {
  margin-bottom: 5px; color: var(--muted-2);
  width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center;
}
.tabs-refresh:hover { color: var(--text); }
.tabs-refresh.spin svg { animation: spin .8s linear infinite; }
.sub-tabs {
  display: flex; align-items: flex-end; flex-wrap: wrap; gap: 4px; overflow: visible;
}
.sub-tab {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 11px 8px; font-size: 12.5px; font-weight: 500; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
  font-family: inherit;
}
.sub-tab:hover { color: var(--text); }
.sub-tab.active { color: var(--brand-700); border-bottom-color: var(--brand-600); }
.sub-tab.locked { color: var(--muted-2); }
.sub-tab.locked .sub-tab-count { opacity: .65; }
.sub-tab-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 10.5px; font-variant-numeric: tabular-nums; color: var(--muted);
}
.sub-tab.active .sub-tab-count { background: var(--brand-50, #eef2ff); border-color: #c7d2fe; color: var(--brand-700); }

/* ---------- Checkbox multi-select ---------- */
.multiselect { position: relative; }
.multiselect-toggle {
  width: 100%; display: flex; align-items: center; gap: 8px;
  text-align: left; cursor: pointer; font-family: inherit; color: var(--text);
}
.multiselect-toggle > svg { flex: 0 0 auto; margin-left: auto; color: var(--muted-2); transition: transform .12s ease; }
.multiselect.open .multiselect-toggle > svg { transform: rotate(90deg); }
.multiselect.open .multiselect-toggle { border-color: #a5b4fc; box-shadow: 0 0 0 3px rgba(99, 102, 241, .13); }
.multiselect-summary { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.multiselect-menu {
  display: none; position: absolute; z-index: 12; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, .14); padding: 5px;
}
.multiselect.open .multiselect-menu { display: flex; flex-direction: column; }
.multiselect-options { overflow-y: auto; max-height: 190px; }
.multiselect-option {
  display: flex; align-items: center; gap: 9px; padding: 7px 8px;
  border-radius: 7px; font-size: 12.5px; color: var(--text-2); cursor: pointer;
}
.multiselect-option:hover { background: var(--brand-50); color: var(--text); }
.multiselect-option input { flex: 0 0 auto; margin: 0; }
.multiselect-option-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.multiselect-all {
  position: sticky; top: 0; z-index: 1; margin-bottom: 4px;
  border-bottom: 1px solid var(--border); border-radius: 7px 7px 0 0;
  background: var(--surface); font-weight: 600; color: var(--text);
}
.multiselect-all .faint { margin-left: auto; font-size: 11px; font-weight: 500; }
.multiselect-empty { padding: 10px 8px; color: var(--muted-2); font-size: 12px; }
