/* Gmail Agency admin panel. Plain CSS, no external fonts or CDNs (strict CSP: everything from 'self'). */
:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --line: #e5e8f0;
  --line-2: #eef0f6;
  --text: #0f172a;
  --muted: #64748b;
  --soft: #94a3b8;
  --brand: #4f46e5;
  --brand-2: #6366f1;
  --brand-soft: #eef2ff;
  --side: #0f172a;
  --side-2: #1e293b;
  --side-text: #cbd5e1;
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --bad: #dc2626;
  --bad-soft: #fef2f2;
  --info: #0284c7;
  --info-soft: #f0f9ff;
  --violet: #7c3aed;
  --violet-soft: #f5f3ff;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .06);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, .18);
  --side-w: 252px;
  --top-h: 64px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font); font-size: 14.5px; line-height: 1.5; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.hidden { display: none !important; }
.mono { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--muted); }
.soft { color: var(--soft); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------------- login */
.login-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 10% -10%, #e0e7ff 0%, transparent 60%),
              radial-gradient(900px 500px at 110% 110%, #ede9fe 0%, transparent 55%), var(--bg); }
.login-card { width: 100%; max-width: 400px; background: var(--card); border-radius: 20px; box-shadow: var(--shadow-lg); padding: 32px 28px; }
.login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.logo-mark { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 18px;
  background: linear-gradient(135deg, var(--brand), #8b5cf6); box-shadow: 0 6px 16px rgba(79, 70, 229, .35); flex: none; }
.login-card h1 { font-size: 21px; margin: 0; letter-spacing: -.01em; }
.login-card p.lead { margin: 2px 0 0; color: var(--muted); font-size: 13.5px; }
.login-step-note { background: var(--brand-soft); color: #3730a3; border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13px; margin-bottom: 14px; }

/* ---------------------------------------------------------------- shell */
.app { display: flex; min-height: 100vh; min-height: 100dvh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--side-w); background: var(--side); color: var(--side-text);
  display: flex; flex-direction: column; z-index: 40; transition: transform .25s ease; }
.side-head { height: var(--top-h); display: flex; align-items: center; gap: 12px; padding: 0 18px; border-bottom: 1px solid rgba(255,255,255,.06); }
.side-head .logo-mark { width: 36px; height: 36px; font-size: 15px; border-radius: 10px; }
.side-title { color: #fff; font-weight: 700; font-size: 15px; line-height: 1.2; }
.side-sub { font-size: 12px; color: #94a3b8; }
.side-nav { flex: 1; overflow-y: auto; padding: 12px 10px 18px; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #64748b; padding: 14px 12px 6px; font-weight: 600; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 9px 12px; margin: 2px 0; border-radius: 10px; color: var(--side-text);
  cursor: pointer; text-decoration: none; font-weight: 500; border: 0; background: none; width: 100%; text-align: left; }
.nav-item:hover { background: var(--side-2); color: #fff; text-decoration: none; }
.nav-item.active { background: linear-gradient(135deg, rgba(99,102,241,.95), rgba(124,58,237,.95)); color: #fff; box-shadow: 0 6px 14px rgba(79,70,229,.35); }
.nav-item .count { margin-left: auto; background: #ef4444; color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 7px; min-width: 20px; text-align: center; }
.nav-item.active .count { background: rgba(255,255,255,.25); }
.side-foot { padding: 12px; border-top: 1px solid rgba(255,255,255,.06); }
.me-box { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; flex: none;
  background: linear-gradient(135deg, #0ea5e9, #6366f1); font-size: 13px; }
.me-name { color: #fff; font-weight: 600; font-size: 13px; }
.me-sub { font-size: 12px; color: #94a3b8; }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; border: 1px solid transparent; background: transparent;
  color: inherit; cursor: pointer; flex: none; }
.icon-btn:hover { background: rgba(148,163,184,.15); }
.side-foot .icon-btn { margin-left: auto; color: #94a3b8; }

.main { flex: 1; min-width: 0; margin-left: var(--side-w); display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; height: var(--top-h); display: flex; align-items: center; gap: 12px; padding: 0 28px;
  background: rgba(244,246,251,.85); backdrop-filter: saturate(160%) blur(10px); -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line); }
.topbar h2 { font-size: 19px; margin: 0; letter-spacing: -.01em; }
.topbar .sub { color: var(--muted); font-size: 13px; }
.menu-btn { display: none; }
.content { padding: 24px 28px 48px; width: 100%; max-width: 1320px; }
.overlay { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 35; opacity: 0; pointer-events: none; transition: opacity .2s; }
.overlay.show { opacity: 1; pointer-events: auto; }
.bottom-nav { display: none; }

/* ---------------------------------------------------------------- cards & grids */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.card-head h3 { margin: 0; font-size: 15px; }
.card-head .sub { color: var(--muted); font-size: 12.5px; }
.card-body { padding: 16px 20px; }
.grid { display: grid; gap: 16px; }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
.section { margin-top: 20px; }
.section-title { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 26px 0 10px; }

.kpi { padding: 16px 18px; display: flex; gap: 14px; align-items: flex-start; }
.kpi-ic { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.kpi-ic svg.i { width: 20px; height: 20px; }
.kpi-label { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.kpi-value { font-size: 24px; font-weight: 750; letter-spacing: -.02em; line-height: 1.2; margin-top: 2px; }
.kpi-sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.kpi.link { cursor: pointer; transition: transform .15s, box-shadow .15s; }
.kpi.link:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.t-brand { background: var(--brand-soft); color: var(--brand); }
.t-ok { background: var(--ok-soft); color: var(--ok); }
.t-warn { background: var(--warn-soft); color: var(--warn); }
.t-bad { background: var(--bad-soft); color: var(--bad); }
.t-info { background: var(--info-soft); color: var(--info); }
.t-violet { background: var(--violet-soft); color: var(--violet); }

.alerts { display: grid; gap: 10px; margin-bottom: 18px; }
.alert { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 12px; border: 1px solid; font-size: 13.5px; }
.alert svg.i { width: 20px; height: 20px; }
.alert .grow { min-width: 0; }
.alert.warn { background: var(--warn-soft); border-color: #fde68a; color: #92400e; }
.alert.bad { background: var(--bad-soft); border-color: #fecaca; color: #991b1b; }
.alert.info { background: var(--info-soft); border-color: #bae6fd; color: #075985; }
.alert.ok { background: var(--ok-soft); border-color: #a7f3d0; color: #065f46; }

/* ---------------------------------------------------------------- chips, badges */
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 1.6; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.plain::before { display: none; }
.b-gray { background: #f1f5f9; color: #475569; }
.b-blue { background: var(--info-soft); color: var(--info); }
.b-amber { background: var(--warn-soft); color: #b45309; }
.b-violet { background: var(--violet-soft); color: var(--violet); }
.b-green { background: var(--ok-soft); color: var(--ok); }
.b-teal { background: #f0fdfa; color: #0f766e; }
.b-red { background: var(--bad-soft); color: var(--bad); }
.b-brand { background: var(--brand-soft); color: var(--brand); }
.tag2fa { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 700; border-radius: 6px; padding: 1px 6px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed); color: #fff; letter-spacing: .02em; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 13px; font-size: 13px; font-weight: 600; color: #334155;
  cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.chip:hover { border-color: #c7d2fe; background: #fafaff; }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip .n { font-size: 11.5px; opacity: .75; }

/* ---------------------------------------------------------------- buttons, inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border-radius: 10px; padding: 8px 14px; font-weight: 600;
  font-size: 13.5px; border: 1px solid var(--line); background: var(--card); color: #1e293b; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s; min-height: 38px; text-decoration: none; }
.btn:hover { background: #f8fafc; border-color: #cbd5e1; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg.i { width: 16px; height: 16px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 4px 12px rgba(79,70,229,.25); }
.btn.primary:hover { background: #4338ca; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ok:hover { background: #047857; }
.btn.danger { background: #fff; border-color: #fecaca; color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.danger.solid { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: #eef2f7; }
.btn.sm { padding: 5px 10px; min-height: 32px; font-size: 12.5px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn.loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.loading::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor;
  border-color: rgba(255,255,255,.9) rgba(255,255,255,.9) rgba(255,255,255,.9) transparent; animation: spin .7s linear infinite; }
.btn:not(.primary):not(.ok):not(.solid).loading::after { border-color: #64748b #64748b #64748b transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 13px; font-weight: 600; color: #334155; }
.field .hint { font-size: 12px; color: var(--muted); }
.input, select.input, textarea.input { width: 100%; border: 1px solid #d5dae4; background: #fff; border-radius: 10px; padding: 9px 12px; min-height: 40px;
  outline: none; transition: border-color .15s, box-shadow .15s; font-size: 14px; }
textarea.input { resize: vertical; min-height: 110px; line-height: 1.45; }
.input:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(99,102,241,.18); }
.input.code { font-family: var(--mono); font-size: 22px; letter-spacing: .4em; text-align: center; padding: 10px; }
.search { position: relative; flex: 1; min-width: 200px; max-width: 420px; }
.search svg.i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--soft); width: 17px; height: 17px; }
.search .input { padding-left: 36px; }
select.input { appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }

/* switch */
.switch { position: relative; width: 44px; height: 26px; flex: none; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: #cbd5e1; border-radius: 999px; transition: background .2s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px rgba(99,102,241,.3); }

/* ---------------------------------------------------------------- tables */
.table-wrap { width: 100%; overflow-x: auto; }
table.t { width: 100%; border-collapse: separate; border-spacing: 0; }
table.t th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650;
  padding: 11px 14px; border-bottom: 1px solid var(--line); background: #fafbfd; white-space: nowrap; }
table.t th:first-child { padding-left: 20px; }
table.t th:last-child { padding-right: 20px; }
table.t td { padding: 12px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.t td:first-child { padding-left: 20px; }
table.t td:last-child { padding-right: 20px; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr.click { cursor: pointer; }
table.t tbody tr.click:hover td { background: #fafbff; }
table.t td .actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: nowrap; }
.cell-main { font-weight: 600; color: var(--text); }
.cell-sub { font-size: 12.5px; color: var(--muted); }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty svg.i { width: 38px; height: 38px; color: #cbd5e1; margin-bottom: 8px; stroke-width: 1.6; }
.empty h4 { margin: 0 0 4px; color: #334155; font-size: 15px; }
.pager { display: flex; align-items: center; gap: 10px; justify-content: space-between; padding: 12px 20px; border-top: 1px solid var(--line-2);
  color: var(--muted); font-size: 13px; flex-wrap: wrap; }
.pager .row { gap: 6px; }

/* key/value lists */
.kv { display: grid; grid-template-columns: minmax(120px, 38%) minmax(0, 1fr); gap: 0; }
.kv > div { padding: 9px 0; border-bottom: 1px solid var(--line-2); min-width: 0; }
.kv > div:nth-child(odd) { color: var(--muted); font-size: 13px; padding-right: 12px; }
.kv > div:nth-child(even) { font-weight: 500; overflow-wrap: anywhere; }
.kv > div:nth-last-child(-n+2) { border-bottom: 0; }
.copy { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; border-radius: 6px; padding: 1px 4px; margin: -1px -4px;
  max-width: 100%; overflow-wrap: anywhere; text-align: left; border: 0; background: none; }
.copy:hover { background: var(--brand-soft); }
.copy svg.i { width: 14px; height: 14px; color: var(--soft); flex: none; }

/* stat bars */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 132px minmax(0, 1fr) 92px; gap: 12px; align-items: center; font-size: 13px; }
.bar-track { height: 10px; border-radius: 999px; background: #eef1f6; overflow: hidden; display: flex; }
.bar-fill { height: 100%; background: linear-gradient(90deg, #6366f1, #8b5cf6); border-radius: 999px; }
.bar-fill.tfa { background: linear-gradient(90deg, #a78bfa, #c084fc); border-radius: 0 999px 999px 0; }
.bar-num { text-align: right; font-variant-numeric: tabular-nums; color: #334155; }
.bar-num small { color: var(--muted); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.lg-a { background: #6366f1; }
.lg-b { background: #34d399; }
.lg-c { background: #c084fc; }
.chart svg { width: 100%; height: 220px; display: block; }
.chart text { font-size: 11px; fill: #94a3b8; font-family: var(--font); }

/* ---------------------------------------------------------------- drawer / modal / toast */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(620px, 100%); background: var(--bg); z-index: 60; box-shadow: var(--shadow-lg);
  transform: translateX(105%); transition: transform .28s cubic-bezier(.2,.8,.2,1); display: flex; flex-direction: column; }
.drawer.show { transform: none; }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; background: var(--card); border-bottom: 1px solid var(--line); min-height: var(--top-h); }
.drawer-head h3 { margin: 0; font-size: 16.5px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px; -webkit-overflow-scrolling: touch; }
.drawer-body .card + .card { margin-top: 14px; }
.drawer-actions { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 18px; background: var(--card); border-top: 1px solid var(--line); }
.drawer-actions .btn { flex: 1 1 140px; }
.dim { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 55; opacity: 0; pointer-events: none; transition: opacity .2s; }
.dim.show { opacity: 1; pointer-events: auto; }

.modal-back { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 80; display: grid; place-items: center; padding: 18px;
  opacity: 0; pointer-events: none; transition: opacity .18s; }
.modal-back.show { opacity: 1; pointer-events: auto; }
.modal { width: 100%; max-width: 440px; background: var(--card); border-radius: 18px; box-shadow: var(--shadow-lg); transform: translateY(10px) scale(.98);
  transition: transform .18s; max-height: calc(100vh - 36px); overflow-y: auto; }
.modal-back.show .modal { transform: none; }
.modal-head { padding: 20px 22px 6px; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-head p { margin: 6px 0 0; color: var(--muted); font-size: 13.5px; }
.modal-body { padding: 12px 22px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { padding: 12px 22px 20px; display: flex; gap: 10px; justify-content: flex-end; }

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100% - 40px)); }
.toast { background: #0f172a; color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); display: flex; gap: 10px; align-items: flex-start;
  font-size: 13.5px; animation: toast-in .22s ease; }
.toast.ok svg.i { color: #34d399; }
.toast.bad svg.i { color: #f87171; }
.toast svg.i { margin-top: 1px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -4px 0 14px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { border: 0; background: none; padding: 10px 12px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -1px; white-space: nowrap; font-size: 13.5px; }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab .n { background: #eef2f7; color: #475569; border-radius: 999px; padding: 0 7px; font-size: 11.5px; margin-left: 4px; }

.otp { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 12px; background: linear-gradient(135deg, #eef2ff, #f5f3ff); }
.otp-code { font-family: var(--mono); font-size: 26px; font-weight: 700; letter-spacing: .14em; color: #3730a3; }
.otp-left { font-size: 12px; color: var(--muted); }
.ring { width: 36px; height: 36px; flex: none; }
.ring circle { fill: none; stroke-width: 4; }
.ring .bg { stroke: #ddd6fe; }
.ring .fg { stroke: #6366f1; stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; transition: stroke-dashoffset 1s linear; }

.set-row { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 18px; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--line-2); }
.set-row:last-child { border-bottom: 0; }
.set-label { font-weight: 600; }
.set-help { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.set-ctl { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.set-ctl .input { max-width: 150px; text-align: right; font-variant-numeric: tabular-nums; }
.affix { position: relative; display: flex; align-items: center; }
.affix span { position: absolute; color: var(--soft); font-size: 13px; pointer-events: none; }
.affix .pre { left: 12px; }
.affix .post { right: 12px; }
.affix .input.has-pre { padding-left: 24px; }
.affix .input.has-post { padding-right: 30px; }

.skeleton { background: linear-gradient(90deg, #eef1f6 25%, #f6f8fb 37%, #eef1f6 63%); background-size: 400% 100%; animation: sk 1.3s ease infinite; border-radius: 8px; }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.sk-kpi { height: 92px; }
.sk-block { height: 280px; }
.loading-page { display: grid; gap: 16px; }

.note { font-size: 12.5px; color: var(--muted); }
.divider { height: 1px; background: var(--line-2); margin: 14px 0; }
.pill-num { font-variant-numeric: tabular-nums; }
.list-plain { margin: 0; padding: 0; list-style: none; }
.list-plain li { padding: 9px 0; border-bottom: 1px solid var(--line-2); display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.list-plain li:last-child { border-bottom: 0; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1180px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-main { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .menu-btn { display: grid; }
  .topbar { padding: 0 14px; height: 58px; }
  .topbar h2 { font-size: 17px; }
  .topbar .sub { display: none; }
  .content { padding: 16px 14px 96px; }
  .g-3, .g-2 { grid-template-columns: minmax(0, 1fr); }
  .bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: rgba(255,255,255,.96);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-top: 1px solid var(--line);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
  .bottom-nav button { flex: 1; border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px;
    font-size: 11px; font-weight: 600; color: #64748b; cursor: pointer; border-radius: 10px; position: relative; min-width: 0; }
  .bottom-nav button svg.i { width: 21px; height: 21px; }
  .bottom-nav button.active { color: var(--brand); }
  .bottom-nav .count { position: absolute; top: 2px; left: calc(50% + 6px); background: #ef4444; color: #fff; font-size: 10px; border-radius: 999px; padding: 0 5px; line-height: 16px; min-width: 16px; }
  .toasts { left: 14px; right: 14px; bottom: 84px; max-width: none; }

  /* tables become stacked cards */
  table.t.stack-mobile thead { display: none; }
  table.t.stack-mobile, table.t.stack-mobile tbody, table.t.stack-mobile tr, table.t.stack-mobile td { display: block; width: 100%; }
  table.t.stack-mobile tr { padding: 12px 16px; border-bottom: 1px solid var(--line-2); }
  table.t.stack-mobile tr:last-child { border-bottom: 0; }
  table.t.stack-mobile td { padding: 3px 0 !important; border: 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: right; min-width: 0; }
  table.t.stack-mobile td::before { content: attr(data-label); color: var(--muted); font-size: 12.5px; font-weight: 500; text-align: left; flex: none; }
  table.t.stack-mobile td.lead { display: block; text-align: left; padding-bottom: 6px !important; }
  table.t.stack-mobile td.lead::before { display: none; }
  table.t.stack-mobile td > * { min-width: 0; }
  table.t.stack-mobile td .actions { justify-content: flex-end; flex-wrap: wrap; }
  table.t.stack-mobile td.act { padding-top: 8px !important; }
  table.t.stack-mobile td.act::before { display: none; }
  table.t.stack-mobile td.act .actions { width: 100%; }
  table.t.stack-mobile td.act .actions .btn { flex: 1; }
  table.t.stack-mobile td.hide-m { display: none; }
  table.t.stack-mobile tbody tr.click:hover td { background: none; }

  .set-row { grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 14px 16px; }
  .set-ctl { justify-content: flex-start; }
  .set-ctl .input { max-width: none; flex: 1; }
  .card-head, .card-body, .card-pad { padding-left: 16px; padding-right: 16px; }
  table.t th:first-child, table.t td:first-child { padding-left: 16px; }
  .bar-row { grid-template-columns: 104px minmax(0, 1fr) 70px; gap: 8px; }
  .drawer { width: 100%; }
  .search { max-width: none; min-width: 100%; }
  .toolbar .btn { flex: none; }
  .kpi-value { font-size: 21px; }
  .modal-foot .btn { flex: 1; }
}
@media (max-width: 520px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px; gap: 10px; flex-direction: column; }
  .kpi-ic { width: 34px; height: 34px; border-radius: 10px; }
  .kpi-ic svg.i { width: 17px; height: 17px; }
  .kpi-value { font-size: 19px; }
  .kpi-sub { font-size: 11.5px; }
  .kv { grid-template-columns: minmax(0, 1fr); }
  .kv > div:nth-child(odd) { padding-bottom: 0; border-bottom: 0; font-size: 12px; }
  .kv > div:nth-child(even) { padding-top: 2px; }
  .kv > div:nth-last-child(2) { border-bottom: 0; }
  .otp-code { font-size: 22px; }
  .login-card { padding: 26px 20px; }
}

/* ---------------------------------------------------------------- chart (heights set from JS via CSSOM, CSP-safe) */
.chart-cols { display: flex; align-items: stretch; gap: 6px; height: 230px; padding-top: 6px; }
.chart-col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.chart-bars { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 3px; border-bottom: 1px solid var(--line);
  background: repeating-linear-gradient(to top, transparent 0, transparent calc(25% - 1px), #f1f3f8 calc(25% - 1px), #f1f3f8 25%); }
.cb { width: 42%; max-width: 16px; border-radius: 5px 5px 0 0; min-height: 0; transition: height .5s ease; }
.cb.a { background: linear-gradient(180deg, #818cf8, #6366f1); }
.cb.b { background: linear-gradient(180deg, #6ee7b7, #34d399); }
.chart-x { text-align: center; font-size: 11px; color: var(--soft); font-variant-numeric: tabular-nums; }
.chart-col:hover .chart-bars { background-color: #f8f9ff; }

/* ---------------------------------------------------------------- small helpers used by app.js */
.t-bad-text { color: var(--bad); }
.t-ok-text { color: var(--ok); }
.section-tight { margin-bottom: 14px; }
.section-first { margin-bottom: 18px; }
.click-li { cursor: pointer; border-radius: 8px; }
.click-li:hover { background: #fafbff; }
.list-plain li.click-li { padding-left: 6px; padding-right: 6px; margin: 0 -6px; }
.list-plain li svg.i { width: 15px; height: 15px; vertical-align: -2px; color: var(--soft); }
.list-plain li svg.i + * { margin-left: 2px; }
.list-plain li .row { min-width: 0; }
.kpi .grow { min-width: 0; }
.kpi-sub { overflow-wrap: anywhere; }
.drawer .kpi { box-shadow: none; }
.drawer .grid.g-2 { gap: 12px; }
.badge svg.i { width: 13px; height: 13px; }
a.badge { text-decoration: none; }
a.badge:hover { filter: brightness(.96); }
.cell-main a, a.cell-main { color: var(--text); }
a.cell-main:hover { color: var(--brand); }
.topbar .btn.ghost { color: var(--muted); }
@media (max-width: 900px) {
  .hide-sm { display: none !important; }
  .chart-cols { gap: 3px; height: 190px; }
  .cb { width: 44%; border-radius: 3px 3px 0 0; }
  .chart-x { font-size: 10px; }
}
@media (max-width: 520px) {
  .chart-col:nth-child(odd) .chart-x { visibility: hidden; }
}

/* ---------------------------------------------------------------- fixes after screenshot review */
table.t th.right, table.t td.right { text-align: right; }
.toolbar select.input { width: auto; min-width: 170px; flex: none; }
.g-main > .card { display: flex; flex-direction: column; }
.g-main > .card > .card-body { flex: 1; display: flex; flex-direction: column; }
.g-main > .card > .card-body > .chart-cols { flex: 1; height: auto; min-height: 230px; }
@media (max-width: 900px) {
  .toolbar select.input { flex: 1 1 150px; min-width: 0; }
  .bar-row { grid-template-columns: 128px minmax(0, 1fr) auto; }
  .drawer .grid.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .drawer .kpi { padding: 12px; gap: 10px; flex-direction: column; }
  .drawer .kpi-ic { width: 34px; height: 34px; border-radius: 10px; }
  .drawer .kpi-value { font-size: 19px; }
  .g-main > .card > .card-body > .chart-cols { min-height: 190px; }
}
.drawer-body .grid > .card + .card { margin-top: 0; }
.drawer-body .grid + .card, .drawer-body .card + .grid { margin-top: 14px; }
