/* Kashly admin: design system, shell, components and data tables. Light + dark. No framework. */

:root {
    --bg: #f4f6fb;
    --bg-glow: radial-gradient(1200px 600px at 85% -10%, rgba(47, 91, 255, .08), transparent 60%), radial-gradient(900px 500px at -10% 110%, rgba(34, 197, 94, .06), transparent 60%);
    --surface: #ffffff;
    --surface-2: #f8f9fc;
    --surface-3: #eef1f7;
    --ink: #0a1022;
    --ink-2: #2a3247;
    --muted: #5b6478;
    --faint: #8a93a6;
    --line: #e4e8f0;
    --line-2: #d5dbe7;
    --blue: #2f5bff;
    --blue-deep: #1f3fd9;
    --blue-soft: #eef2ff;
    --blue-ink: #1f3fd9;
    --green: #16a34a;
    --green-soft: #e8f7ee;
    --amber: #b45309;
    --amber-soft: #fef3e2;
    --red: #dc2626;
    --red-soft: #fdecec;
    --violet: #7c3aed;
    --violet-soft: #f1ebfe;
    --shadow-sm: 0 1px 2px rgba(10, 16, 34, .05);
    --shadow: 0 1px 2px rgba(10, 16, 34, .04), 0 8px 24px -12px rgba(10, 16, 34, .12);
    --shadow-lg: 0 24px 60px -20px rgba(10, 16, 34, .35);
    --radius: 14px;
    --radius-sm: 10px;
    --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
    --side-w: 264px;
    color-scheme: light;
}

:root[data-theme="dark"] {
    --bg: #0b0f1a;
    --bg-glow: radial-gradient(1200px 600px at 85% -10%, rgba(79, 123, 255, .14), transparent 60%), radial-gradient(900px 500px at -10% 110%, rgba(34, 197, 94, .07), transparent 60%);
    --surface: #121827;
    --surface-2: #161d2e;
    --surface-3: #1c2438;
    --ink: #eef1f8;
    --ink-2: #ccd3e2;
    --muted: #95a0b8;
    --faint: #6f7a93;
    --line: #232c42;
    --line-2: #2e3852;
    --blue: #5b7fff;
    --blue-deep: #7593ff;
    --blue-soft: rgba(91, 127, 255, .14);
    --blue-ink: #9db2ff;
    --green: #34d399;
    --green-soft: rgba(52, 211, 153, .12);
    --amber: #fbbf24;
    --amber-soft: rgba(251, 191, 36, .12);
    --red: #f87171;
    --red-soft: rgba(248, 113, 113, .12);
    --violet: #a78bfa;
    --violet-soft: rgba(167, 139, 250, .14);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -14px rgba(0, 0, 0, .6);
    --shadow-lg: 0 30px 70px -20px rgba(0, 0, 0, .7);
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body.ka {
    margin: 0; min-height: 100vh;
    background: var(--bg-glow), var(--bg); background-attachment: fixed;
    color: var(--ink); font: 400 14px/1.55 var(--font);
    -webkit-font-smoothing: antialiased;
}
a { color: var(--blue-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; color: var(--ink); font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
p { margin: 0; }
img, svg { display: block; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 6px; }
.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.i--sm { width: 15px; height: 15px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

/* ───────── Shell ───────── */
.ka-shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); gap: 16px; min-height: 100vh; padding: 14px; }
.ka-side {
    position: sticky; top: 14px; height: calc(100vh - 28px);
    display: flex; flex-direction: column;
    background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
    overflow: hidden;
}
.ka-brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 18px; border-bottom: 1px solid var(--line); color: var(--ink); }
.ka-brand:hover { text-decoration: none; }
.ka-brand img { width: 30px; height: 30px; }
.ka-brand b { font-size: 18px; font-weight: 600; letter-spacing: -0.03em; }
.ka-brand small { margin-left: auto; padding: 3px 7px; font: 500 10px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); background: var(--surface-3); border-radius: 6px; }
.ka-nav { flex: 1; overflow-y: auto; padding: 10px 12px 16px; }
.ka-nav__label { margin: 16px 10px 6px; font: 500 11px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--faint); }
.ka-nav a {
    position: relative; display: flex; align-items: center; gap: 12px; padding: 9px 12px; margin: 2px 0;
    font-weight: 500; color: var(--ink-2); border-radius: 10px;
    transition: background .15s ease, color .15s ease;
}
.ka-nav a:hover { background: var(--surface-3); text-decoration: none; }
.ka-nav a[aria-current="page"] { background: var(--blue-soft); color: var(--blue-ink); }
.ka-nav a[aria-current="page"]::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; background: var(--blue); border-radius: 0 3px 3px 0; }
.ka-nav .ka-count { margin-left: auto; min-width: 22px; padding: 2px 7px; font: 500 11px/1.4 var(--mono); text-align: center; color: #fff; background: var(--blue); border-radius: 999px; }
.ka-side__foot { padding: 14px; border-top: 1px solid var(--line); }
.ka-note { display: flex; gap: 10px; padding: 12px; font-size: 12.5px; line-height: 1.45; color: var(--ink-2); background: var(--amber-soft); border-radius: 12px; }
.ka-note .i { color: var(--amber); margin-top: 1px; }

.ka-main { display: flex; flex-direction: column; min-width: 0; }
.ka-top {
    position: sticky; top: 14px; z-index: 20;
    display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px;
    background: color-mix(in srgb, var(--surface) 86%, transparent);
    backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px);
    border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-sm);
}
.ka-crumbs { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 14px; color: var(--muted); }
.ka-crumbs b { color: var(--ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ka-crumbs .i { color: var(--faint); }
.ka-top__right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.ka-jump {
    display: inline-flex; align-items: center; gap: 10px; width: 240px; height: 38px; padding: 0 8px 0 12px;
    color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font: inherit;
}
.ka-jump:hover { border-color: var(--line-2); }
.ka-jump kbd { margin-left: auto; padding: 2px 6px; font: 500 11px/1.3 var(--mono); color: var(--muted); background: var(--surface); border: 1px solid var(--line-2); border-radius: 6px; }
.ka-chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; font-size: 12px; font-weight: 600; color: var(--amber); background: var(--amber-soft); border-radius: 999px; white-space: nowrap; }
.ka-chip i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.ka-icon-btn {
    display: inline-grid; place-items: center; width: 38px; height: 38px; padding: 0;
    color: var(--ink-2); background: transparent; border: 1px solid transparent; border-radius: 10px; cursor: pointer;
}
.ka-icon-btn:hover { background: var(--surface-3); }
.ka-menu-btn { display: none; }
.ka-user { position: relative; }
.ka-user > button {
    display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 10px 0 4px;
    color: var(--ink); background: transparent; border: 1px solid transparent; border-radius: 12px; cursor: pointer; font: inherit; text-align: left;
}
.ka-user > button:hover { background: var(--surface-3); }
.ka-user__name { display: grid; line-height: 1.25; }
.ka-user__name b { font-weight: 600; font-size: 13.5px; }
.ka-user__name small { font-size: 12px; color: var(--muted); }
.ka-pop {
    position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; min-width: 220px; padding: 6px;
    background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg);
}
.ka-pop[hidden] { display: none; }
.ka-pop a, .ka-pop button {
    display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; font: inherit; font-weight: 500;
    color: var(--ink-2); background: none; border: 0; border-radius: 8px; cursor: pointer; text-align: left;
}
.ka-pop a:hover, .ka-pop button:hover { background: var(--surface-3); text-decoration: none; }
.ka-pop hr { margin: 6px 4px; border: 0; border-top: 1px solid var(--line); }
.ka-pop .is-danger { color: var(--red); }

.ka-content { flex: 1; padding: 26px 4px 32px; }
.ka-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.ka-head h1 { font-size: clamp(24px, 2.6vw, 32px); letter-spacing: -0.035em; }
.ka-head p { margin-top: 6px; color: var(--muted); }
.ka-head__actions { display: flex; flex-wrap: wrap; gap: 10px; }
.ka-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 4px 6px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.ka-foot__brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; color: var(--ink); }
.ka-foot__brand img { width: 20px; height: 20px; }

/* ───────── Buttons ───────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px;
    font: 600 13.5px/1 var(--font); color: var(--ink); background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px;
    cursor: pointer; white-space: nowrap; transition: background .15s ease, border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.btn:hover { text-decoration: none; background: var(--surface-2); border-color: var(--faint); }
.btn:active { transform: translateY(1px); }
.btn--primary { color: #fff; background: var(--blue); border-color: var(--blue); box-shadow: 0 6px 18px -8px rgba(47, 91, 255, .8); }
.btn--primary:hover { background: var(--blue-deep); border-color: var(--blue-deep); }
.btn--danger { color: #fff; background: var(--red); border-color: var(--red); }
.btn--danger:hover { background: #b91c1c; border-color: #b91c1c; }
.btn--ghost { background: transparent; border-color: transparent; }
.btn--ghost:hover { background: var(--surface-3); border-color: transparent; }
.btn--sm { height: 34px; padding: 0 12px; font-size: 13px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.act { display: inline-grid; place-items: center; width: 34px; height: 34px; color: var(--muted); background: none; border: 1px solid transparent; border-radius: 9px; cursor: pointer; }
.act:hover { color: var(--blue-ink); background: var(--blue-soft); text-decoration: none; }
.act--danger:hover { color: var(--red); background: var(--red-soft); }
.acts { display: inline-flex; gap: 2px; }

/* ───────── Cards ───────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 0; }
.card__head h2 { font-size: 16px; }
.card__head p { font-size: 13px; color: var(--muted); }
.card__body { padding: 18px 20px 20px; }
.grid { display: grid; gap: 16px; }
.grid--kpi { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid--2 { grid-template-columns: 1.6fr 1fr; }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.stack { display: grid; gap: 16px; }

.kpi { position: relative; overflow: hidden; padding: 18px 18px 16px; }
.kpi::after { content: ""; position: absolute; right: -40px; top: -40px; width: 140px; height: 140px; border-radius: 50%; background: radial-gradient(closest-side, var(--tone-soft, var(--blue-soft)), transparent); pointer-events: none; }
.kpi__top { display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--ink-2); }
.kpi__icon { display: grid; place-items: center; width: 36px; height: 36px; color: #fff; background: var(--tone, var(--blue)); border-radius: 10px; }
.kpi__value { margin-top: 16px; font: 500 30px/1 var(--mono); letter-spacing: -0.03em; }
.kpi__sub { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.delta { display: inline-flex; align-items: center; gap: 3px; padding: 2px 7px; font: 600 11.5px/1.3 var(--mono); border-radius: 999px; }
.delta--up { color: var(--green); background: var(--green-soft); }
.delta--down { color: var(--red); background: var(--red-soft); }
.delta--flat { color: var(--muted); background: var(--surface-3); }
.tone-blue { --tone: #2f5bff; --tone-soft: rgba(47, 91, 255, .14); }
.tone-green { --tone: #16a34a; --tone-soft: rgba(22, 163, 74, .14); }
.tone-amber { --tone: #d97706; --tone-soft: rgba(217, 119, 6, .14); }
.tone-violet { --tone: #7c3aed; --tone-soft: rgba(124, 58, 237, .14); }
.tone-rose { --tone: #e11d48; --tone-soft: rgba(225, 29, 72, .12); }

/* Charts and lists */
.bars { display: grid; grid-template-columns: repeat(12, 1fr); align-items: end; gap: 8px; height: 200px; padding-top: 8px; }
.bars__col { display: grid; grid-template-rows: 1fr auto; gap: 8px; height: 100%; text-align: center; }
.bars__bar { position: relative; align-self: end; min-height: 3px; background: linear-gradient(180deg, var(--blue), color-mix(in srgb, var(--blue) 55%, transparent)); border-radius: 6px 6px 3px 3px; transition: filter .15s ease; }
.bars__bar:hover { filter: brightness(1.12); }
.bars__bar b { position: absolute; left: 50%; bottom: calc(100% + 4px); transform: translateX(-50%); font: 500 11px/1 var(--mono); color: var(--ink-2); opacity: 0; transition: opacity .15s ease; }
.bars__col:hover .bars__bar b, .bars__col:focus-within .bars__bar b { opacity: 1; }
.bars__col.is-current .bars__bar { background: linear-gradient(180deg, #22c55e, color-mix(in srgb, #22c55e 50%, transparent)); }
.bars__col span { font: 500 10.5px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
.meter-list { display: grid; gap: 14px; margin: 0; padding: 0; list-style: none; }
.meter-list li { display: grid; gap: 7px; }
.meter-list header { display: flex; justify-content: space-between; gap: 10px; font-weight: 500; }
.meter-list header span { font: 500 12.5px/1.4 var(--mono); color: var(--muted); }
.meter { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--tone, var(--blue)); border-radius: inherit; }
.mini-list { margin: 0; padding: 0; list-style: none; }
.mini-list li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.mini-list li:last-child { border-bottom: 0; }
.mini-list .grow { flex: 1; min-width: 0; }
.mini-list .grow b, .mini-list .grow small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-list .grow b { font-weight: 600; }
.mini-list .grow small { font-size: 12.5px; color: var(--muted); }

/* ───────── Badges / avatar ───────── */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; font-size: 12px; font-weight: 600; white-space: nowrap; color: var(--ink-2); background: var(--surface-3); border-radius: 999px; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge--plain::before { display: none; }
.badge--blue { color: var(--blue-ink); background: var(--blue-soft); }
.badge--green { color: var(--green); background: var(--green-soft); }
.badge--amber { color: var(--amber); background: var(--amber-soft); }
.badge--red { color: var(--red); background: var(--red-soft); }
.badge--violet { color: var(--violet); background: var(--violet-soft); }
.avatar { display: grid; place-items: center; flex: none; width: 36px; height: 36px; font-size: 13px; font-weight: 600; color: #fff; border-radius: 50%; background: var(--av, #2f5bff); }
.avatar--lg { width: 64px; height: 64px; font-size: 22px; }
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.who > span { display: grid; min-width: 0; line-height: 1.35; }
.who b { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who small { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.who:hover { text-decoration: none; }
a.who:hover b { color: var(--blue-ink); }

/* ───────── Data table ───────── */
.dt { overflow: hidden; }
.dt__bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 16px; border-bottom: 1px solid var(--line); }
.dt__bar h2 { margin-right: auto; font-size: 16px; }
.dt__bar h2 small { margin-left: 8px; font: 500 12px/1 var(--mono); color: var(--muted); }
.dt__search { position: relative; flex: 0 1 300px; }
.dt__search .i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.dt__search input { padding-left: 38px !important; }
.dt__scroll { overflow: auto; max-height: calc(100vh - 290px); min-height: 220px; }
table.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th {
    position: sticky; top: 0; z-index: 2; padding: 11px 16px; text-align: left; white-space: nowrap;
    font: 500 11.5px/1.2 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
    background: var(--surface-2); border-bottom: 1px solid var(--line);
}
.table td { padding: 12px 16px; vertical-align: middle; border-bottom: 1px solid var(--line); color: var(--ink-2); }
.table tbody tr { transition: background .12s ease; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .t-right { text-align: right; }
.table .t-actions { width: 1%; white-space: nowrap; text-align: right; }
.table td.t-wrap { max-width: 420px; white-space: normal; }
.sort { display: inline-flex; align-items: center; gap: 4px; color: inherit; }
.sort:hover { color: var(--ink); text-decoration: none; }
.sort .i { width: 13px; height: 13px; opacity: .45; }
th[aria-sort="ascending"] .sort, th[aria-sort="descending"] .sort { color: var(--blue-ink); }
th[aria-sort="ascending"] .sort .i, th[aria-sort="descending"] .sort .i { opacity: 1; }
th[aria-sort="descending"] .sort .i { transform: rotate(180deg); }
.dt__foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.pager { display: flex; align-items: center; gap: 4px; margin: 0; padding: 0; list-style: none; }
.pager a, .pager span {
    display: inline-grid; place-items: center; min-width: 34px; height: 34px; padding: 0 8px;
    font: 500 13px/1 var(--mono); color: var(--ink-2); border: 1px solid transparent; border-radius: 9px;
}
.pager a:hover { background: var(--surface-3); text-decoration: none; }
.pager [aria-current="page"] { color: #fff; background: var(--blue); }
.pager .is-disabled { color: var(--faint); opacity: .6; }
.empty { display: grid; justify-items: center; gap: 10px; padding: 56px 20px; text-align: center; color: var(--muted); }
.empty__icon { display: grid; place-items: center; width: 52px; height: 52px; color: var(--blue-ink); background: var(--blue-soft); border-radius: 14px; }
.empty b { font-size: 15px; color: var(--ink); }

/* ───────── Forms ───────── */
.field { display: grid; gap: 7px; }
.field > label, .label { font-weight: 600; font-size: 13px; color: var(--ink-2); }
.field .hint { font-size: 12.5px; color: var(--muted); }
.field .error { font-size: 12.5px; font-weight: 500; color: var(--red); }
.req { color: var(--red); }
.input, .select, .textarea {
    width: 100%; height: 40px; padding: 0 12px;
    font: 400 14px/1.4 var(--font); color: var(--ink); background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.textarea { height: auto; min-height: 140px; padding: 10px 12px; resize: vertical; }
.select { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a93a6' stroke-width='2' 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 10px center; background-size: 16px; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--faint); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px color-mix(in srgb, var(--blue) 18%, transparent); }
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--red); }
.input[disabled] { color: var(--muted); background: var(--surface-2); cursor: not-allowed; }
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 44px; }
.input-wrap .act { position: absolute; right: 3px; top: 3px; }
.form { display: grid; gap: 18px; }
.form__row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form__actions { display: flex; flex-wrap: wrap; gap: 10px; padding-top: 18px; border-top: 1px solid var(--line); }
.form-card { max-width: 760px; }
.dl { display: grid; gap: 0; margin: 0; }
.dl > div { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.dl > div:last-child { border-bottom: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; font-weight: 500; text-align: right; color: var(--ink); }

/* ───────── Alerts, toasts, dialogs ───────── */
.alert { display: flex; gap: 10px; padding: 12px 14px; font-weight: 500; border-radius: 12px; }
.alert--red { color: var(--red); background: var(--red-soft); }
.alert--green { color: var(--green); background: var(--green-soft); }
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 80; display: grid; gap: 10px; width: min(380px, calc(100vw - 32px)); }
.toast {
    display: flex; align-items: flex-start; gap: 12px; padding: 14px 14px 14px 16px;
    color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--green); border-radius: 12px; box-shadow: var(--shadow-lg);
    animation: ka-in .25s cubic-bezier(.2, .8, .2, 1);
}
.toast--error { border-left-color: var(--red); }
.toast p { flex: 1; font-weight: 500; }
.toast .i { margin-top: 1px; }
.toast--success > .i { color: var(--green); }
.toast--error > .i { color: var(--red); }
@keyframes ka-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
dialog.ka-dialog {
    width: min(440px, calc(100vw - 32px)); padding: 0; color: var(--ink);
    background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg);
}
dialog.ka-dialog::backdrop { background: rgba(10, 16, 34, .45); backdrop-filter: blur(3px); }
dialog.ka-dialog[open] { animation: ka-in .2s cubic-bezier(.2, .8, .2, 1); }
.ka-dialog__body { display: grid; gap: 10px; padding: 22px 22px 8px; }
.ka-dialog__icon { display: grid; place-items: center; width: 44px; height: 44px; color: var(--red); background: var(--red-soft); border-radius: 12px; }
.ka-dialog__body h2 { font-size: 18px; }
.ka-dialog__body p { color: var(--muted); }
.ka-dialog__foot { display: flex; justify-content: flex-end; gap: 10px; padding: 18px 22px 22px; }

/* Command palette */
dialog.ka-palette { width: min(560px, calc(100vw - 32px)); margin-top: 12vh; padding: 0; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg); }
dialog.ka-palette::backdrop { background: rgba(10, 16, 34, .45); backdrop-filter: blur(3px); }
.ka-palette__search { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); color: var(--faint); }
.ka-palette__search input { flex: 1; height: 32px; font: 400 15px/1 var(--font); color: var(--ink); background: none; border: 0; outline: none; }
.ka-palette ul { max-height: 340px; overflow: auto; margin: 0; padding: 8px; list-style: none; }
.ka-palette li a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; color: var(--ink-2); border-radius: 10px; font-weight: 500; }
.ka-palette li a small { margin-left: auto; font: 500 11px/1 var(--mono); color: var(--faint); text-transform: uppercase; letter-spacing: .08em; }
.ka-palette li a:hover, .ka-palette li a.is-active { background: var(--blue-soft); color: var(--blue-ink); text-decoration: none; }
.ka-palette__empty { padding: 24px; text-align: center; color: var(--muted); }

/* ───────── Profile page ───────── */
.profile { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; padding: 22px; }
.profile h2 { font-size: 22px; }
.profile .badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.profile__saving { margin-left: auto; text-align: right; }
.profile__saving small { display: block; font: 500 11px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.profile__saving b { display: block; margin-top: 6px; font: 500 26px/1 var(--mono); letter-spacing: -0.03em; }
.stat-strip { display: grid; grid-template-columns: repeat(6, 1fr); border-top: 1px solid var(--line); }
.stat-strip div { padding: 14px 18px; border-right: 1px solid var(--line); }
.stat-strip div:last-child { border-right: 0; }
.stat-strip b { display: block; font: 500 20px/1 var(--mono); }
.stat-strip span { display: block; margin-top: 6px; font-size: 12px; color: var(--muted); }
.amount-in { color: var(--green); font-weight: 600; }
.amount-out { color: var(--ink); font-weight: 600; }

/* Calculator results */
.result-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.result { padding: 16px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; }
.result small { display: block; font: 500 11px/1.2 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.result b { display: block; margin-top: 8px; font: 500 22px/1.1 var(--mono); letter-spacing: -0.02em; }
.split { height: 12px; display: flex; overflow: hidden; border-radius: 999px; background: var(--surface-3); }
.split i { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 12.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; }

/* ───────── Auth (login) ───────── */
.auth { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); min-height: 100vh; }
.auth__brand {
    position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; gap: 40px; padding: 48px clamp(28px, 5vw, 64px);
    color: #fff; background: radial-gradient(900px 500px at 0% 0%, rgba(255, 255, 255, .16), transparent 60%), linear-gradient(150deg, #3d68ff 0%, #1f3fd9 55%, #13289b 100%);
}
.auth__brand::before { content: ""; position: absolute; inset: 0; background-image: linear-gradient(rgba(255, 255, 255, .06) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .06) 1px, transparent 1px); background-size: 44px 44px; mask-image: linear-gradient(180deg, transparent, #000 30%, #000 70%, transparent); pointer-events: none; }
.auth__brand > * { position: relative; }
.auth__logo { display: flex; align-items: center; gap: 12px; font-size: 22px; font-weight: 600; letter-spacing: -0.03em; color: #fff; }
.auth__logo img { width: 40px; height: 40px; border-radius: 11px; box-shadow: 0 0 0 1px rgba(255, 255, 255, .25); }
.auth__brand h1 { max-width: 520px; color: #fff; font-size: clamp(34px, 4vw, 52px); font-weight: 600; letter-spacing: -0.045em; line-height: 1.02; }
.auth__brand p { max-width: 440px; margin-top: 16px; font-size: 16px; color: rgba(255, 255, 255, .78); }
.auth__points { display: grid; gap: 10px; max-width: 400px; margin-top: 32px; }
.auth__points div { display: flex; align-items: center; gap: 12px; padding: 12px 14px; font-weight: 500; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .18); border-radius: 12px; backdrop-filter: blur(6px); }
.auth__points .i { padding: 6px; width: 30px; height: 30px; background: rgba(255, 255, 255, .16); border-radius: 8px; }
.auth__rings { position: absolute; right: -140px; bottom: -160px; width: 460px; height: 460px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .2); box-shadow: 0 0 0 60px rgba(255, 255, 255, .04), 0 0 0 120px rgba(255, 255, 255, .03); pointer-events: none; }
.auth__rings::after { content: ""; position: absolute; left: 22%; top: 2%; width: 18px; height: 18px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 6px rgba(34, 197, 94, .25), 0 0 30px #22c55e; }
.auth__copy { font-size: 12.5px; color: rgba(255, 255, 255, .65); }
.auth__panel { display: grid; place-items: center; padding: 40px 20px; }
.auth__card { width: min(440px, 100%); padding: 32px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-lg); }
.auth__card h2 { font-size: 26px; letter-spacing: -0.035em; }
.auth__card > p { margin-top: 6px; color: var(--muted); }
.auth__card .form { margin-top: 24px; }
.auth__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--ink-2); }
.check input { width: 16px; height: 16px; accent-color: var(--blue); }
.demo-accts { margin-top: 24px; padding-top: 20px; border-top: 1px dashed var(--line-2); }
.demo-accts h3 { font-size: 13px; margin-bottom: 10px; }
.demo-acct { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; text-align: left; font: inherit; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; cursor: pointer; transition: border-color .15s ease, background .15s ease; }
.demo-acct:hover { border-color: var(--blue); background: var(--blue-soft); }

.demo-acct b { font-weight: 600; }
.demo-acct code { font: 400 12.5px/1.4 var(--mono); color: var(--muted); }
.demo-acct em { font-style: normal; padding: 6px 12px; font-size: 12.5px; font-weight: 600; color: #fff; background: var(--blue); border-radius: 999px; }

/* ───────── Responsive ───────── */
@media (max-width: 1180px) {
    .grid--2 { grid-template-columns: 1fr; }
    .grid--3 { grid-template-columns: 1fr 1fr; }
    .stat-strip { grid-template-columns: repeat(3, 1fr); }
    .stat-strip div:nth-child(3) { border-right: 0; }
    .stat-strip div:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
    .ka-jump { width: 44px; padding: 0; justify-content: center; }
    .ka-jump span, .ka-jump kbd { display: none; }
}
@media (max-width: 1024px) {
    .ka-shell { grid-template-columns: minmax(0, 1fr); padding: 10px; }
    .ka-side { position: fixed; z-index: 60; left: 10px; top: 10px; bottom: 10px; height: auto; width: min(300px, calc(100vw - 20px)); transform: translateX(calc(-100% - 20px)); transition: transform .25s cubic-bezier(.2, .8, .2, 1); }
    .ka-side.is-open { transform: none; }
    .ka-scrim { position: fixed; inset: 0; z-index: 55; background: rgba(10, 16, 34, .4); backdrop-filter: blur(2px); }
    .ka-scrim[hidden] { display: none; }
    .ka-menu-btn { display: inline-grid; }
    .ka-top { top: 10px; }
    .auth { grid-template-columns: 1fr; }
    .auth__brand { padding: 28px 24px; gap: 20px; }
    .auth__points, .auth__copy, .auth__rings { display: none; }
    .auth__brand p { font-size: 15px; }
}
@media (max-width: 720px) {
    .ka-user__name, .ka-chip span { display: none; }
    .ka-chip { padding: 0 9px; }
    .ka-content { padding-top: 18px; }
    .grid--3, .form__row { grid-template-columns: 1fr; }
    .result-grid { grid-template-columns: 1fr 1fr; }
    .stat-strip { grid-template-columns: repeat(2, 1fr); }
    .stat-strip div { border-right: 0 !important; border-bottom: 1px solid var(--line); }
    .stat-strip div:nth-child(odd) { border-right: 1px solid var(--line) !important; }
    .profile__saving { margin-left: 0; text-align: left; width: 100%; }
    .dt__search { flex: 1 1 100%; }
    .dt__bar .select, .dt__bar .btn { flex: 1 1 auto; }
    .dt__scroll { max-height: none; }
    /* tables become stacked cards */
    .table--cards thead { display: none; }
    .table--cards, .table--cards tbody, .table--cards tr, .table--cards td { display: block; width: 100%; }
    .table--cards tr { padding: 10px 16px; border-bottom: 1px solid var(--line); }
    .table--cards td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 0; border: 0; text-align: right; }
    .table--cards td::before { content: attr(data-label); flex: none; font: 500 11px/1.3 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--faint); text-align: left; }
    .table--cards td[data-label=""]::before { display: none; }
    .table--cards td.t-primary { justify-content: flex-start; text-align: left; }
    .table--cards td.t-primary::before { display: none; }
    .table--cards td.t-actions { justify-content: flex-end; width: 100%; }
    .table--cards td.t-wrap { max-width: none; white-space: normal; }
    .bars { gap: 4px; }
    .bars__col:nth-child(odd) span { visibility: hidden; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ───────── Auth extras ───────── */
.t-dark { display: none; }
:root[data-theme="dark"] .t-dark { display: block; }
:root[data-theme="dark"] .t-light { display: none; }
.btn--block { width: 100%; height: 46px; font-size: 14.5px; }
.spinner { display: none; width: 16px; height: 16px; border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff; border-radius: 50%; animation: ka-spin .7s linear infinite; }
.is-loading .spinner { display: inline-block; }
@keyframes ka-spin { to { transform: rotate(360deg); } }
.input-icon { position: relative; }
.input-icon > .i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.input-icon .input { height: 46px; padding-left: 42px; }
.input-icon.input-wrap .act { top: 6px; }
.caps { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--amber); }
.caps[hidden] { display: none; }
.auth__wrap { display: grid; gap: 14px; width: min(460px, 100%); }
.auth__bar { display: flex; justify-content: space-between; align-items: center; }
.auth__card .alert { font-size: 13.5px; }
.auth__card .alert .i { margin-top: 1px; }
.auth__alt { margin-top: 20px; text-align: center; }
.auth__alt a { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.auth__trust { display: flex; justify-content: center; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.auth__row a { font-weight: 600; }
.auth__preview { max-width: 400px; margin-top: 28px; padding: 16px; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .2); border-radius: 16px; backdrop-filter: blur(8px); box-shadow: 0 20px 40px -20px rgba(0, 0, 0, .35); }
.auth__preview-top { display: flex; justify-content: space-between; align-items: baseline; font: 500 11px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: rgba(255, 255, 255, .7); }
.auth__preview-top b { font: 600 22px/1 var(--font); letter-spacing: -0.03em; color: #fff; text-transform: none; }
.auth__preview svg { width: 100%; height: 64px; margin: 14px 0 12px; }
.auth__preview-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.auth__preview-row span { padding: 8px 10px; font-weight: 600; font-size: 13px; background: rgba(255, 255, 255, .1); border-radius: 10px; }
.auth__preview-row small { display: block; font: 500 10px/1.4 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: rgba(255, 255, 255, .65); }
@media (max-width: 1024px) { .auth__preview { display: none; } .auth__panel { padding-top: 24px; } }
@media (max-width: 480px) { .auth__card { padding: 24px 20px; } }

/* ───────── Fixes ───────── */
[hidden] { display: none !important; }
.hint { font-size: 12.5px; color: var(--muted); }
.demo-acct > span:not(.avatar) { flex: 1; display: grid; gap: 2px; }
.demo-acct > .avatar { flex: none; }
.ka-crumbs { flex: 1; }
@media (max-width: 720px) {
    .ka-crumbs > span, .ka-crumbs > .i { display: none; }
    .ka-chip { display: none; }
}
