/* KhaBot design system — one hand-written stylesheet, CSS custom properties,
   automatic light/dark via prefers-color-scheme. No framework. Clean + dense. */

:root {
  --brand: #0e3674;
  --brand-2: #1f5fd0;
  --brand-ink: #ffffff;

  --bg: #f6f7f9;
  --bg-elev: #ffffff;
  --bg-sunken: #eceef1;
  --card: #ffffff;
  --border: #e2e5ea;
  --border-strong: #cdd2da;

  --text: #16181d;
  --text-muted: #5b6472;
  --text-faint: #8a93a2;

  --ok: #1a7f4b;
  --warn: #b26a00;
  --danger: #c0362c;
  --ok-bg: #e7f6ed;
  --warn-bg: #fbf1de;
  --danger-bg: #fbe9e7;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, .18);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --maxw: 1180px;
}

/* Dark theme variables. --brand/--brand-2 are accessible LIGHTER tints of the
   #0e3674 hue (~216°) — #0e3674 itself is too dark for text/UI on dark bg.
   Applied when the OS is dark AND the user hasn't forced a theme (System), OR
   when the user explicitly forces Dark. Forced Light never gets these. */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]):not([data-theme="dark"]) {
    --brand: #4d86e6; --brand-2: #6fa0ef; --brand-ink: #08111f;
    --bg: #0c0f14; --bg-elev: #141922; --bg-sunken: #0a0d12; --card: #141922;
    --border: #232a35; --border-strong: #333c49;
    --text: #e8ebf0; --text-muted: #a3adba; --text-faint: #6f7a89;
    --ok: #4ecb83; --warn: #e2a94b; --danger: #ef6b5f;
    --ok-bg: #10261a; --warn-bg: #2a2110; --danger-bg: #2a1512;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 1px 3px rgba(0, 0, 0, .4);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, .55);
  }
}
html[data-theme="dark"] {
  --brand: #4d86e6; --brand-2: #6fa0ef; --brand-ink: #08111f;
  --bg: #0c0f14; --bg-elev: #141922; --bg-sunken: #0a0d12; --card: #141922;
  --border: #232a35; --border-strong: #333c49;
  --text: #e8ebf0; --text-muted: #a3adba; --text-faint: #6f7a89;
  --ok: #4ecb83; --warn: #e2a94b; --danger: #ef6b5f;
  --ok-bg: #10261a; --warn-bg: #2a2110; --danger-bg: #2a1512;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 1px 3px rgba(0, 0, 0, .4);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  /* Wide tables scroll inside their own .table-wrap; the page itself never
     scrolls horizontally on phones (PH-11). */
  overflow-x: hidden;
}
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; font-weight: 650; }
code, pre { font-family: var(--mono); }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.25rem 0; }

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 1.25rem; }
.stack > * + * { margin-top: 1rem; }
.row { display: flex; gap: .6rem; align-items: center; }
.row-wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; }
.hidden { display: none !important; }

/* --- buttons --- */
.btn {
  appearance: none; cursor: pointer; font: inherit; font-weight: 550;
  padding: .5rem .85rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--bg-elev); color: var(--text);
  transition: background .12s, border-color .12s, opacity .12s;
}
.btn:hover { background: var(--bg-sunken); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--bg-sunken); }
.btn-sm { padding: .3rem .6rem; font-size: 13px; }
.icon-btn { cursor: pointer; border: 0; background: transparent; color: var(--text-muted);
  font-size: 16px; line-height: 1; padding: .3rem .45rem; border-radius: var(--radius-sm); }
.icon-btn:hover { background: var(--bg-sunken); color: var(--text); }

/* --- cards --- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem 1.2rem; box-shadow: var(--shadow); }
.card-title { font-size: 15px; font-weight: 650; margin-bottom: .8rem; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-faint); font-weight: 650; margin: 1.4rem 0 .6rem; }

/* --- forms --- */
.form .field { margin-bottom: .9rem; }
.field-label { display: block; font-size: 13px; font-weight: 550; margin-bottom: .3rem; color: var(--text-muted); }
.field-label .req { color: var(--danger); }
.field-help { font-size: 12.5px; color: var(--text-faint); margin-top: .3rem; }
input, select, textarea {
  font: inherit; width: 100%; padding: .5rem .6rem; color: var(--text);
  background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-2); outline-offset: -1px; border-color: var(--brand-2); }
textarea { resize: vertical; }
.checkbox { display: inline-flex; align-items: center; gap: .5rem; font-size: 14px; cursor: pointer; }
.checkbox input { width: auto; }
.form-actions { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1.1rem; }
.form-error { color: var(--danger); background: var(--danger-bg); border: 1px solid var(--danger);
  border-radius: var(--radius-sm); padding: .5rem .7rem; font-size: 13.5px; margin-top: .3rem; }
.money-input { position: relative; }
.money-input .money-prefix { position: absolute; left: .6rem; top: 50%; transform: translateY(-50%); color: var(--text-faint); }
.money-input input { padding-left: 1.4rem; }

/* --- table --- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table thead th { background: var(--bg-sunken); font-size: 12.5px; text-transform: uppercase;
  letter-spacing: .03em; color: var(--text-muted); position: sticky; top: 0; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--bg-sunken); }
.th-sort { cursor: pointer; user-select: none; }
.sort-ind { color: var(--brand-2); }
.al-right { text-align: right; }
.al-center { text-align: center; }

/* --- stat tiles + meters --- */
.stat-grid { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.stat-tile { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; box-shadow: var(--shadow); }
.stat-label { font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-faint); font-weight: 600; }
.stat-value { font-size: 24px; font-weight: 700; margin-top: .2rem; }
.stat-sub { font-size: 12.5px; color: var(--text-muted); margin-top: .2rem; }
.tone-ok .stat-value { color: var(--ok); }
.tone-danger .stat-value { color: var(--danger); }
.tone-warn .stat-value { color: var(--warn); }
.meter { margin: .7rem 0; }
.meter-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: .3rem; }
.meter-val { color: var(--text-muted); }
.meter-track { height: 8px; background: var(--bg-sunken); border-radius: 99px; overflow: hidden; }
.meter-fill { height: 100%; border-radius: 99px; transition: width .3s; }
.fill-ok { background: var(--ok); } .fill-warn { background: var(--warn); } .fill-danger { background: var(--danger); }

/* --- badges --- */
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: .12rem .5rem; border-radius: 99px; border: 1px solid transparent; }
.badge-neutral { background: var(--bg-sunken); color: var(--text-muted); }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-brand { background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand-2); }

/* --- modal --- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(6, 10, 18, .5); display: flex;
  align-items: flex-start; justify-content: center; padding: 6vh 1rem; z-index: 100; overflow-y: auto; }
.modal { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 460px; }
.modal-wide { max-width: 760px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.2rem .5rem; }
.modal-head h3 { margin: 0; }
.modal-body { padding: .5rem 1.2rem 1rem; }
.modal-foot { display: flex; gap: .6rem; justify-content: flex-end; padding: .5rem 1.2rem 1.1rem; }

/* --- toasts --- */
.toaster { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 200; }
.toast { padding: .6rem .9rem; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); cursor: pointer;
  background: var(--bg-elev); border: 1px solid var(--border); max-width: 340px; font-size: 14px; }
.toast-success { border-color: var(--ok); background: var(--ok-bg); color: var(--ok); }
.toast-error { border-color: var(--danger); background: var(--danger-bg); color: var(--danger); }
.toast-info { border-color: var(--brand-2); }

/* --- spinner / empty --- */
.spinner { display: flex; align-items: center; gap: .6rem; color: var(--text-muted); padding: 1.5rem; justify-content: center; }
.spin { width: 16px; height: 16px; border: 2px solid var(--border-strong); border-top-color: var(--brand-2);
  border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--text-muted); }
.empty-icon { font-size: 28px; opacity: .5; }
.empty-title { font-weight: 600; margin-top: .4rem; }
.empty-hint { font-size: 13px; color: var(--text-faint); margin-top: .25rem; }

/* --- copy field --- */
.copy-field { margin: .5rem 0; }
.copy-row { display: flex; gap: .5rem; align-items: stretch; }
.copy-value { flex: 1; background: var(--bg-sunken); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: .5rem .6rem; overflow-x: auto; white-space: nowrap; font-size: 13px; }

/* --- tabs --- */
.tabs { display: flex; gap: .2rem; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin-bottom: 1.2rem; }
.tab { padding: .55rem .85rem; border-radius: var(--radius-sm) var(--radius-sm) 0 0; color: var(--text-muted);
  font-weight: 550; font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--text); text-decoration: none; background: var(--bg-sunken); }
.tab-active { color: var(--brand-2); border-bottom-color: var(--brand-2); }
.tab-icon { margin-right: .35rem; }

/* --- top nav (site + app shells) --- */
.topbar { background: var(--bg-elev); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; }
.topbar-inner { max-width: var(--maxw); margin: 0 auto; padding: .6rem 1.25rem; display: flex; align-items: center; gap: 1rem; }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--text); font-size: 17px; }
.brand:hover { text-decoration: none; }
.brand img { height: 26px; width: 26px; }
/* Theme-aware brand mark: logo-dark.png on light backgrounds, logo-white.png on
   dark. Both render; CSS shows the right one for the active theme. */
.brand-mark { height: 26px; width: auto; display: block; }
.brand-mark--dark { display: none; }
html[data-theme="dark"] .brand-mark--light { display: none; }
html[data-theme="dark"] .brand-mark--dark { display: block; }
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]):not([data-theme="dark"]) .brand-mark--light { display: none; }
  html:not([data-theme="light"]):not([data-theme="dark"]) .brand-mark--dark { display: block; }
}
.theme-toggle { font-size: 17px; }
.nav-links { display: flex; gap: .3rem; align-items: center; margin-left: auto; }
.nav-links a { padding: .4rem .7rem; border-radius: var(--radius-sm); color: var(--text-muted); font-weight: 550; }
.nav-links a:hover { background: var(--bg-sunken); color: var(--text); text-decoration: none; }
@media (max-width: 560px) {
  /* Keep the header on one row on small phones (no 5px overflow / no 2-row wrap). */
  .topbar-inner { padding: .5rem .7rem; gap: .4rem; }
  .nav-links { gap: .1rem; }
  .nav-links a { padding: .35rem .45rem; font-size: 14px; }
  .brand { font-size: 15px; }
}

/* --- page scaffolds --- */
.page { padding: 1.6rem 0 4rem; }
.page-title { font-size: 22px; margin-bottom: .2rem; }
.page-sub { color: var(--text-muted); margin-bottom: 1.4rem; }

/* --- AppShell: responsive dashboard/admin chrome --- */
.app-shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.app-bar { display: none; }
.app-side { background: var(--bg-elev); border-right: 1px solid var(--border); padding: 1rem .8rem; display: flex; flex-direction: column; height: 100vh; top: 0px; position: sticky; }
.app-side-brand { padding: .3rem .5rem 1rem; }
.app-side-brand .brand { font-size: 16px; }
.side-nav { display: flex; flex-direction: column; gap: .12rem; }
.side-nav a { padding: .52rem .7rem; border-radius: var(--radius-sm); color: var(--text-muted); font-weight: 550; font-size: 14px;
  display: flex; gap: .6rem; align-items: center; transition: background .12s, color .12s; }
.side-nav a:hover { background: var(--bg-sunken); color: var(--text); text-decoration: none; }
.side-nav a.active { background: color-mix(in srgb, var(--brand) 13%, transparent); color: var(--brand-2); font-weight: 650; box-shadow: inset 2px 0 0 var(--brand-2); }
.side-nav .nav-ico { display: inline-flex; align-items: center; justify-content: center; }
.app-side-foot { margin-top: auto; padding: 1rem .5rem 0; font-size: 13px; color: var(--text-muted); }
.app-main { padding: 1.6rem 2rem 4rem; min-width: 0; }
.app-main-head { margin-bottom: 1.2rem; }
.drawer-backdrop { position: fixed; inset: 0; background: rgba(6, 10, 18, .45); z-index: 40; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .app-bar { display: flex; align-items: center; gap: .6rem; position: sticky; top: 0; z-index: 45;
    background: var(--bg-elev); border-bottom: 1px solid var(--border); padding: .5rem .8rem; }
  .app-burger { font-size: 20px; }
  .app-bar-title { font-weight: 700; font-size: 16px; }
  .app-side { position: fixed; z-index: 50; top: 0; left: 0; height: 100%; width: 260px; transform: translateX(-100%);
    transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  .app-side.open { transform: none; }
  .app-main { padding: 1.1rem 1.05rem 3rem; }
  .app-main-head .page-title { font-size: 20px; }
}

/* legacy shell alias (kept for any remaining consumers) */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--bg-elev); border-right: 1px solid var(--border); padding: 1rem .8rem; }
.main { padding: 1.6rem 2rem 4rem; min-width: 0; }

/* --- Overview alerts / boards --- */
.ov-alert { display: flex; gap: .7rem; align-items: center; padding: .6rem .9rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-elev); }
.ov-alert-ico { font-size: 18px; }
.ov-alert-title { font-weight: 600; }
.ov-alert-warn { border-color: var(--warn); background: var(--warn-bg); }
.ov-alert-danger { border-color: var(--danger); background: var(--danger-bg); }
.ov-allclear { display: flex; gap: .6rem; align-items: center; padding: .7rem 1rem; border-radius: var(--radius-sm);
  border: 1px solid var(--ok); background: var(--ok-bg); color: var(--ok); font-weight: 550; }
.ov-errrow { padding: .5rem .2rem; border-bottom: 1px solid var(--border); }
.ov-errrow:last-child { border-bottom: 0; }

/* --- wizard stepper --- */
.wiz-steps { display: flex; gap: .3rem; flex-wrap: wrap; border-bottom: 1px solid var(--border); padding-bottom: .7rem; }
.wiz-step { display: flex; align-items: center; gap: .4rem; font-size: 13px; color: var(--text-faint); font-weight: 550; padding: .2rem .5rem; }
.wiz-step.active { color: var(--brand-2); }
.wiz-step.done { color: var(--ok); }
.wiz-num { display: inline-grid; place-items: center; width: 1.4em; height: 1.4em; border-radius: 50%; background: var(--bg-sunken); font-size: 11px; }
.wiz-step.active .wiz-num { background: var(--brand); color: var(--brand-ink); }
.wiz-step.done .wiz-num { background: var(--ok); color: #fff; }

/* --- error card (never-blank states) --- */
.error-card { display: flex; gap: .8rem; align-items: center; background: var(--danger-bg); border: 1px solid var(--danger);
  border-radius: var(--radius); padding: .9rem 1.1rem; color: var(--text); }
.error-card-icon { font-size: 20px; }
.error-card-title { font-weight: 650; color: var(--danger); }

/* --- landing / hero --- */
.hero { padding: 4rem 0 3rem; text-align: center; }
.hero h1 { font-size: clamp(30px, 5vw, 46px); letter-spacing: -.02em; }
.hero p.lead { font-size: 18px; color: var(--text-muted); max-width: 42rem; margin: .6rem auto 1.4rem; }
.hero .cta { display: inline-flex; gap: .7rem; }
.valueprops { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); margin: 2rem 0; }
.vp { padding: 1.2rem; }
.vp .vp-icon { font-size: 22px; }
.vp h3 { margin: .5rem 0 .3rem; font-size: 16px; }
.vp p { color: var(--text-muted); font-size: 14px; margin: 0; }
.plans-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.plan-card { position: relative; }
.plan-card.current { border-color: var(--brand-2); box-shadow: 0 0 0 1px var(--brand-2); }
.plan-price { font-size: 30px; font-weight: 750; }
.plan-price small { font-size: 14px; color: var(--text-muted); font-weight: 500; }
.plan-feats { list-style: none; padding: 0; margin: .8rem 0; font-size: 14px; }
.plan-feats li { padding: .25rem 0; color: var(--text-muted); border-bottom: 1px dashed var(--border); }
.free-price { color: var(--danger); font-weight: 700; }

.auth-wrap { max-width: 400px; margin: 8vh auto; padding: 0 1.25rem; }
.auth-card { padding: 1.6rem; }

footer.site-foot { border-top: 1px solid var(--border); margin-top: 3rem; padding: 2rem 0; color: var(--text-muted); font-size: 14px; }
.foot-links { display: flex; gap: 1.2rem; flex-wrap: wrap; }

/* --- docs --- */
.docs-shell { display: grid; grid-template-columns: 230px 1fr; max-width: var(--maxw); margin: 0 auto; gap: 2rem; padding: 1.5rem 1.25rem 4rem; }
.docs-nav { position: sticky; top: 4rem; align-self: start; }
@media (max-width: 820px) {
  /* PH-9: docs must collapse to one column and stay readable on phones. */
  .docs-shell { grid-template-columns: 1fr; gap: 1rem; padding: 1rem 1.05rem 3rem; }
  .docs-nav { position: static; border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem .8rem; background: var(--bg-elev); }
  .docs-nav .nav-group:first-child { margin-top: 0; }
  .doc-content { max-width: 100%; }
  .doc-content pre { font-size: 12.5px; }
}
.docs-nav a { display: block; padding: .35rem .5rem; border-radius: var(--radius-sm); color: var(--text-muted); font-size: 14px; }
.docs-nav a:hover, .docs-nav a.active { background: var(--bg-sunken); color: var(--text); text-decoration: none; }
.docs-nav .nav-group { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint); margin: 1rem 0 .3rem; font-weight: 650; }
.doc-content { min-width: 0; max-width: 820px; overflow-wrap: break-word; }
/* Wide code blocks and tables scroll inside themselves, never the page. */
.doc-content pre { max-width: 100%; }
.doc-content table { display: block; max-width: 100%; overflow-x: auto; }
.doc-content h1 { font-size: 28px; }
.doc-content h2 { font-size: 20px; margin-top: 2rem; padding-bottom: .3rem; border-bottom: 1px solid var(--border); }
.doc-content h3 { font-size: 16px; margin-top: 1.4rem; }
.doc-content p, .doc-content li { color: var(--text); }
.doc-content pre { background: var(--bg-sunken); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .9rem 1rem; overflow-x: auto; font-size: 13px; line-height: 1.5; }
.doc-content :not(pre) > code { background: var(--bg-sunken); padding: .1rem .35rem; border-radius: 5px; font-size: 13px; }
.doc-content table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 1rem 0; }
.doc-content th, .doc-content td { border: 1px solid var(--border); padding: .45rem .6rem; text-align: left; }
.doc-content th { background: var(--bg-sunken); }
.callout { border-left: 3px solid var(--brand-2); background: color-mix(in srgb, var(--brand) 7%, transparent);
  padding: .7rem 1rem; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin: 1rem 0; font-size: 14px; }

/* utility spacing */
.mt-0 { margin-top: 0; } .mt-1 { margin-top: .6rem; } .mt-2 { margin-top: 1.2rem; }
.mb-1 { margin-bottom: .6rem; } .mb-2 { margin-bottom: 1.2rem; }
.gap-grid { display: grid; gap: 1.1rem; }
.cols-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.launcher { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.app-tile { display: flex; flex-direction: column; gap: .3rem; text-decoration: none; color: var(--text); }
.app-tile:hover { text-decoration: none; border-color: var(--brand-2); }
.app-tile .app-icon { font-size: 26px; }
.app-tile .app-title { font-weight: 650; }
.app-tile .app-desc { font-size: 13px; color: var(--text-muted); }

/* ============================ Round-3 additions ============================ */

/* --- account chip + dropdown --- */
.acct { position: relative; }
.acct-btn { display: inline-flex; align-items: center; gap: .3rem; background: transparent; border: 1px solid var(--border); border-radius: 99px; padding: .2rem .5rem .2rem .25rem; cursor: pointer; color: var(--text); }
.acct-btn:hover { background: var(--bg-sunken); }
.acct-avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.acct-caret { color: var(--text-faint); font-size: 11px; }
.acct-menu { position: absolute; right: 0; top: calc(100% + .4rem); min-width: 190px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: .35rem; z-index: 120; }
.acct-menu .acct-email { font-size: 12.5px; color: var(--text-faint); padding: .35rem .55rem; border-bottom: 1px solid var(--border); margin-bottom: .3rem; overflow: hidden; text-overflow: ellipsis; }
.acct-menu a, .acct-menu .acct-logout { display: block; width: 100%; text-align: left; padding: .45rem .55rem; border-radius: var(--radius-sm); color: var(--text); font-size: 14px; background: transparent; border: 0; cursor: pointer; }
.acct-menu a:hover, .acct-menu .acct-logout:hover { background: var(--bg-sunken); text-decoration: none; }
.acct-menu .acct-logout { color: var(--danger); }

/* --- user dashboard landing --- */
.ud-topbar { background: var(--bg-elev); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; }
.ud-topbar-inner { max-width: var(--maxw); margin: 0 auto; padding: .6rem 1.25rem; display: flex; align-items: center; gap: 1rem; }
.ud-topbar .right { margin-left: auto; display: flex; align-items: center; gap: .6rem; }
.ud-body { max-width: var(--maxw); margin: 0 auto; padding: 1.6rem 1.25rem 4rem; }
.ud-section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint); font-weight: 650; margin: 1.6rem 0 .7rem; }
.ud-section-title:first-child { margin-top: 0; }

.featured-chats { display: flex; gap: 1.2rem; align-items: center; padding: 1.4rem 1.5rem; border-radius: var(--radius);
  background: linear-gradient(120deg, var(--brand) 0%, var(--brand-2) 100%); color: #fff; box-shadow: var(--shadow); text-decoration: none; }
.featured-chats:hover { text-decoration: none; filter: brightness(1.03); }
.featured-chats .fc-icon { font-size: 40px; line-height: 1; }
.featured-chats .fc-title { font-size: 20px; font-weight: 750; }
.featured-chats .fc-pitch { opacity: .92; font-size: 14.5px; margin-top: .15rem; }
.featured-chats .fc-cta { margin-left: auto; background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.35); color: #fff; padding: .5rem .9rem; border-radius: var(--radius-sm); font-weight: 600; white-space: nowrap; }

.app-cards { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); margin-top: .8rem; }
.app-card { display: flex; gap: .7rem; align-items: flex-start; padding: .9rem 1rem; text-decoration: none; color: var(--text); }
.app-card:hover { text-decoration: none; border-color: var(--brand-2); }
.app-card .ac-icon { font-size: 24px; line-height: 1; width: 30px; text-align: center; }
.app-card .ac-icon img { width: 28px; height: 28px; object-fit: contain; }
.app-card .ac-title { font-weight: 650; }
.app-card .ac-desc { font-size: 13px; color: var(--text-muted); margin-top: .1rem; }

/* --- settings page (menu + panel) --- */
.settings-shell { display: grid; grid-template-columns: 210px 1fr; gap: 1.5rem; max-width: var(--maxw); margin: 0 auto; padding: 1.4rem 1.25rem 4rem; }
.settings-menu { display: flex; flex-direction: column; gap: .15rem; align-self: start; position: sticky; top: 4.5rem; }
.settings-menu a { padding: .5rem .7rem; border-radius: var(--radius-sm); color: var(--text-muted); font-weight: 550; font-size: 14px; display: flex; gap: .5rem; align-items: center; }
.settings-menu a:hover { background: var(--bg-sunken); color: var(--text); text-decoration: none; }
.settings-menu a.active { background: color-mix(in srgb, var(--brand) 13%, transparent); color: var(--brand-2); font-weight: 650; }
.settings-back { margin-bottom: .8rem; }
@media (max-width: 760px) {
  .settings-shell { grid-template-columns: 1fr; }
  .settings-menu { position: static; flex-direction: row; flex-wrap: wrap; }
}

/* --- progress rings --- */
.rings { display: flex; gap: 1rem; flex-wrap: wrap; }
.ring { display: flex; flex-direction: column; align-items: center; gap: .25rem; }
.ring svg { display: block; }
.ring .ring-label { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.ring .ring-sub { font-size: 11.5px; color: var(--text-faint); }
.ring-pct { font-weight: 700; font-size: 13px; fill: var(--text); }

/* --- inline SVG bar chart --- */
.chart-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; box-shadow: var(--shadow); }
.chart-title { font-size: 13px; font-weight: 650; margin-bottom: .5rem; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .bar { fill: var(--brand-2); }
.chart .bar-err { fill: var(--danger); }
.chart .axis-label { fill: var(--text-faint); font-size: 9px; }
.chart-tip { position: fixed; pointer-events: none; background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: .3rem .5rem; font-size: 12px; box-shadow: var(--shadow-lg); z-index: 300; white-space: nowrap; }

/* --- transactions / tx badges --- */
.tx-in { color: var(--ok); font-weight: 600; }
.tx-out { color: var(--danger); font-weight: 600; }
.usage-bar { height: 6px; background: var(--bg-sunken); border-radius: 99px; overflow: hidden; margin-top: .3rem; min-width: 90px; }
.usage-bar > div { height: 100%; background: var(--brand-2); }

/* chips (exclusive-plan user picker) */
.chips { display: flex; gap: .35rem; flex-wrap: wrap; margin: .4rem 0; }
.chip { display: inline-flex; align-items: center; gap: .3rem; background: var(--bg-sunken); border: 1px solid var(--border); border-radius: 99px; padding: .15rem .3rem .15rem .55rem; font-size: 13px; }
.chip button { border: 0; background: transparent; cursor: pointer; color: var(--text-faint); }

.pw-strength { font-size: 12px; margin-top: .3rem; }
.all-clear-inline { color: var(--ok); font-weight: 600; font-size: 14px; }

/* ===================== Round-4 additions ===================== */

/* --- HelpTip: circled "?" + popover --- */
.helptip { position: relative; display: inline-flex; vertical-align: middle; }
.helptip-btn { width: 16px; height: 16px; line-height: 14px; padding: 0; border-radius: 50%;
  border: 1px solid var(--border-strong); background: var(--bg-sunken); color: var(--text-muted);
  font-size: 11px; font-weight: 700; cursor: pointer; text-align: center; }
.helptip-btn:hover, .helptip-btn.open { border-color: var(--brand-2); color: var(--brand-2); }
.helptip-pop { position: absolute; top: calc(100% + 6px); z-index: 200; width: 260px; max-width: 78vw;
  background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: .7rem .8rem; font-size: 13px; line-height: 1.45; font-weight: 400;
  text-transform: none; letter-spacing: normal; color: var(--text); cursor: default; }
.helptip-pop--left { left: 0; }
.helptip-pop--right { right: 0; }
.helptip-title { display: block; font-weight: 650; margin-bottom: .25rem; }
.helptip-body { display: block; color: var(--text-muted); }

/* --- Subscription quota cards --- */
.qcard-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.qcard { display: flex; flex-direction: column; gap: .5rem; }
.qcard-free { border-style: dashed; }
.qwins { display: flex; flex-direction: column; gap: .7rem; margin-top: .3rem; }
.qwin-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; font-size: 13px; font-weight: 550; }
.qwin-idle .qwin-head span:last-child { font-style: italic; }
.qwin .usage-bar { height: 8px; }
.usage-bar.is-warn > div { background: var(--warn); }
.usage-bar.is-danger > div { background: var(--danger); }

/* --- Plan action area --- */
.plan-action { margin-top: auto; }

/* --- Quickstart / how-to --- */
.copy-field--block .copy-row { align-items: flex-start; }
.copy-value--block { margin: 0; white-space: pre; overflow-x: auto; font-family: var(--mono, ui-monospace, monospace); line-height: 1.5; }
.quickstart code { background: var(--bg-sunken); border-radius: 4px; padding: .05rem .3rem; font-size: 12.5px; }
details.howto { padding: .6rem .9rem; }
details.howto > summary { cursor: pointer; font-weight: 600; font-size: 14px; }
details.howto[open] > summary { margin-bottom: .3rem; }

/* --- source badge (provider windows) --- */
.src-badge { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em;
  padding: .05rem .35rem; border-radius: 99px; border: 1px solid var(--border); color: var(--text-faint); }
.src-badge.src-api { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, var(--border)); }
.src-badge.src-manual { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, var(--border)); }
.src-badge.src-estimated { color: var(--text-muted); }

/* --- multi-select chip checkboxes (plan editor) --- */
.chips-grid { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip-check { display: inline-flex; align-items: center; gap: .35rem; font-size: 13px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 99px; padding: .2rem .6rem; background: var(--bg-sunken); }
.chip-check.on { border-color: var(--brand-2); color: var(--brand-2); background: color-mix(in srgb, var(--brand) 8%, transparent); }
.chip-check input { width: auto; margin: 0; }
.small.warn, .warn { color: var(--warn); }

/* --- mini-table (admin drawers: subscriptions etc.) --- */
.mini-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mini-table th { text-align: left; font-weight: 600; color: var(--text-faint); font-size: 11px;
  text-transform: uppercase; letter-spacing: .03em; padding: .3rem .4rem; border-bottom: 1px solid var(--border); }
.mini-table td { padding: .4rem .4rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.mini-table td.right, .mini-table th.right { text-align: right; }
.mini-table tr:last-child td { border-bottom: 0; }

/* --- provider window ring wrappers (source badge + reset under each ring) --- */
.ring-wrap { display: flex; flex-direction: column; align-items: center; gap: .25rem; }
.ring-meta { display: flex; flex-direction: column; align-items: center; gap: .1rem; }

/* --- plan sold-out + services line --- */
.plan-card.sold-out { opacity: .72; }
.plan-card.sold-out .free-price, .plan-card.sold-out .plan-price { filter: grayscale(.4); }
.plan-services { font-size: 12.5px; }

/* --- Inline-SVG menu icons (follow theme + active state via currentColor) --- */
/* Shared by the user Settings menu and the admin side-nav. */
.menu-ico { flex: 0 0 auto; width: 18px; height: 18px; }
.settings-menu a .menu-ico, .side-nav a .menu-ico { opacity: .85; }
.settings-menu a.active .menu-ico, .side-nav a.active .menu-ico { opacity: 1; }

/* --- compact per-row admin-tag select (Codes table) --- */
.tag-select { width: auto; min-width: 104px; max-width: 130px; padding: 2px 6px; font-size: 12.5px; line-height: 1.4; border-radius: 6px; }
