/* ==========================================================
   Cornerstone Hub — Admin Console
   Shared design system (login + dashboard)
   ========================================================== */

@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("/fonts/Inter-400.woff2") format("woff2");
}

@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("/fonts/Inter-500.woff2") format("woff2");
}

@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("/fonts/Inter-600.woff2") format("woff2");
}

@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("/fonts/Inter-700.woff2") format("woff2");
}

@font-face {
    font-family: "Sora";
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("/fonts/Sora-600.woff2") format("woff2");
}

@font-face {
    font-family: "Sora";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("/fonts/Sora-700.woff2") format("woff2");
}

@font-face {
    font-family: "Sora";
    font-style: normal;
    font-weight: 800;
    font-display: swap;
    src: url("/fonts/Sora-800.woff2") format("woff2");
}


:root,
[data-theme="dark"] {
    color-scheme: dark;
    --bg: #070b14;
    --bg-elev: #0d1320;
    --surface: #111a2b;
    --line: #1f2b41;
    --line-soft: #1a2436;
    --line-strong: #2b3d5c;

    --s-deep: #0b1220;
    --s-deepest: #080d18;
    --s-1: #0e1728;
    --s-2: #0c1524;
    --s-chip: #0f1828;
    --s-btn: #101a2b;
    --s-btn-hover: #142034;
    --s-row: #0d1626;
    --s-row-hover: #0f1a2c;
    --s-ico: #0d1728;
    --s-th: #0b1322;
    --s-kbd: #0f1829;
    --s-nav-hover: #101b2d;
    --s-profile-hover: #111c2f;
    --s-hover-strong: #16233a;
    --scroll: #21304a;
    --scroll-hover: #2c3f60;
    --glass: rgba(255, 255, 255, .035);
    --topbar-bg: rgba(8, 13, 24, .82);
    --avatar-ring: #0b1220;

    --fg: #eaf0fb;
    --fg-soft: #c8d5e8;
    --fg-muted: #8ea0bd;
    --fg-dim: #63748f;
    --nav-fg: #a5b6d1;
    --nav-icon: #6f88ad;
    --nav-label: #53688c;
    --th-fg: #5f7599;
    --placeholder: #4d5d78;
    --count-fg: #8fb2dd;

    --brand: #38e0b0;
    --brand-2: #2ea8ff;
    --brand-3: #7c6bff;
    --warn: #ffb547;
    --danger: #ff5f6d;
    --ok: #35d07f;
    --up: #6ceaa8;
    --down: #ff8f98;
    --on-brand: #05130f;

    --ok-bg: #0d2419;
    --ok-bd: #17452f;
    --ok-fg: #7df0b6;
    --warn-bg: #241a0a;
    --warn-bd: #4a3413;
    --warn-fg: #ffcf87;
    --danger-bg: #260d10;
    --danger-bd: #4d1c22;
    --danger-fg: #ff9aa3;
    --info-bg: #08202f;
    --info-bd: #143a55;
    --info-fg: #96d2ff;

    --grad-brand: linear-gradient(135deg, #38e0b0 0%, #2ea8ff 55%, #7c6bff 100%);
    /* See the light block: referenced by .auth-card::before, never defined. */
    --grad-glow: radial-gradient(60% 60% at 50% 0%, rgba(56, 224, 176, .22), transparent 70%);
    --grad-surface: linear-gradient(160deg, #131d30 0%, #0d1523 100%);
    --grad-sidebar: linear-gradient(180deg, #0b1220 0%, #080d18 100%);
    --grad-auth: radial-gradient(90% 70% at 10% 0%, rgba(124, 107, 255, .25), transparent 60%),
        radial-gradient(80% 80% at 90% 100%, rgba(56, 224, 176, .22), transparent 60%), #080d18;
    --main-glow: radial-gradient(100% 60% at 100% 0%, rgba(124, 107, 255, .10), transparent 55%);
    --grid-line: rgba(255, 255, 255, .035);

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 12px 30px -12px rgba(0, 0, 0, 0.7);
    --shadow-glow: 0 18px 50px -22px rgba(46, 168, 255, 0.55);

    --radius: 16px;
    --radius-sm: 10px;
    --sidebar-w: 268px;
    --sidebar-w-collapsed: 78px;
}

[data-theme="light"] {
    color-scheme: light;
    --bg: #f2f5fa;
    --bg-elev: #ffffff;
    --surface: #ffffff;
    --line: #dde4ef;
    --line-soft: #e7ecf4;
    --line-strong: #b9c6da;

    --s-deep: #eef2f9;
    --s-deepest: #e9eef6;
    --s-1: #ffffff;
    --s-2: #f4f7fc;
    --s-chip: #f1f5fb;
    --s-btn: #ffffff;
    --s-btn-hover: #eef4fc;
    --s-row: #f7f9fd;
    --s-row-hover: #eef4fc;
    --s-ico: #f2f7fd;
    --s-th: #f4f7fc;
    --s-kbd: #f1f5fb;
    --s-nav-hover: #eaf1fa;
    --s-profile-hover: #f2f7fd;
    --s-hover-strong: #e6edf8;
    --scroll: #c9d4e4;
    --scroll-hover: #aebdd2;
    --glass: rgba(255, 255, 255, .7);
    --topbar-bg: rgba(255, 255, 255, .82);
    --avatar-ring: #ffffff;

    --fg: #101a2b;
    --fg-soft: #33455e;
    --fg-muted: #5b6c86;
    --fg-dim: #7b8aa2;
    --nav-fg: #44576f;
    --nav-icon: #7d8ea6;
    --nav-label: #8395ae;
    --th-fg: #6c7d96;
    --placeholder: #9aa8bd;
    --count-fg: #47617f;

    --brand: #0fa47c;
    --brand-2: #1d84e0;
    --brand-3: #6a56f0;
    --warn: #c9820c;
    --danger: #dc3b4c;
    --ok: #14a05e;
    --up: #12904f;
    --down: #d33a4a;
    --on-brand: #ffffff;

    --ok-bg: #e6f7ee;
    --ok-bd: #bce6cf;
    --ok-fg: #127a48;
    --warn-bg: #fdf3e0;
    --warn-bd: #f0dcae;
    --warn-fg: #9a6407;
    --danger-bg: #fdecee;
    --danger-bd: #f4c7cd;
    --danger-fg: #b32a3a;
    --info-bg: #e8f2fe;
    --info-bd: #c3ddf8;
    --info-fg: #12608f;

    --grad-brand: linear-gradient(135deg, #10b58a 0%, #2288e6 55%, #6a56f0 100%);
    /* Referenced by .auth-card::before, previously never defined in either
       theme — the declaration was invalid at computed-value time, so that
       glow silently rendered as nothing. Defined now rather than deleting
       the rule, since the login card was clearly designed around it. */
    --grad-glow: radial-gradient(60% 60% at 50% 0%, rgba(16, 181, 138, .18), transparent 70%);
    --grad-surface: linear-gradient(160deg, #ffffff 0%, #f7fafe 100%);
    --grad-sidebar: linear-gradient(180deg, #ffffff 0%, #f5f8fd 100%);
    --grad-auth: radial-gradient(90% 70% at 10% 0%, rgba(106, 86, 240, .16), transparent 60%),
        radial-gradient(80% 80% at 90% 100%, rgba(16, 181, 138, .18), transparent 60%), #eef3fb;
    --main-glow: radial-gradient(100% 60% at 100% 0%, rgba(106, 86, 240, .07), transparent 55%);
    --grid-line: rgba(16, 26, 43, .05);

    --shadow-sm: 0 1px 3px rgba(16, 26, 43, .08);
    --shadow-md: 0 12px 28px -18px rgba(16, 26, 43, .35);
    --shadow-glow: 0 18px 40px -22px rgba(29, 132, 224, .45);
}


* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
}

body {
    font-family: "Inter", system-ui, sans-serif;
    background: var(--bg);
    color: var(--fg);
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4,
.brand-name {
    font-family: "Sora", "Inter", sans-serif;
    letter-spacing: -0.02em;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font: inherit;
    cursor: pointer;
    border: 0;
    background: none;
    color: inherit;
}

input,
select {
    font: inherit;
}

::-webkit-scrollbar {
    width: 9px;
    height: 9px;
}

::-webkit-scrollbar-thumb {
    background: var(--scroll);
    border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scroll-hover);
}

::-webkit-scrollbar-track {
    background: transparent;
}

/* ---------- Reusable atoms ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 4px 10px;
    border-radius: 99px;
    border: 1px solid var(--line);
    background: var(--s-chip);
    color: var(--fg-muted);
}

.badge.ok {
    color: var(--ok-fg);
    border-color: var(--ok-bd);
    background: var(--ok-bg);
}

.badge.warn {
    color: var(--warn-fg);
    border-color: var(--warn-bd);
    background: var(--warn-bg);
}

.badge.danger {
    color: var(--danger-fg);
    border-color: var(--danger-bd);
    background: var(--danger-bg);
}

.auth-alert {
    margin-top: 16px;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--danger-fg);
    border: 1px solid var(--danger-bd);
    background: var(--danger-bg);
}

/* Modal (centered variant of the existing .drawer pattern) */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(4, 8, 16, .6);
    backdrop-filter: blur(3px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s ease;
    z-index: 70;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: var(--grad-surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 420px;
    padding: 30px 30px 26px;
    transform: translateY(8px) scale(.98);
    opacity: 0;
    transition: transform .22s cubic-bezier(.22, .8, .24, 1), opacity .22s ease;
}

.modal-backdrop.open .modal {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.modal h2 {
    margin: 0 0 6px;
}

.modal .sub {
    margin: 0 0 4px;
}

.badge.info {
    color: var(--info-fg);
    border-color: var(--info-bd);
    background: var(--info-bg);
}

.badge .dot {
    width: 6px;
    height: 6px;
    border-radius: 99px;
    background: currentColor;
    box-shadow: 0 0 10px currentColor;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 16px;
    border-radius: 11px;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid var(--line);
    background: var(--s-btn);
    color: var(--fg);
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease, border-color .18s ease;
}

.btn:hover {
    transform: translateY(-1px);
    border-color: var(--line-strong);
    background: var(--s-btn-hover);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    border: 0;
    color: var(--on-brand);
    background: var(--grad-brand);
    box-shadow: 0 10px 26px -12px rgba(56, 224, 176, .8);
}

.btn-primary:hover {
    box-shadow: 0 16px 34px -12px rgba(46, 168, 255, .85);
}

.btn-ghost {
    background: transparent;
}

.btn-block {
    width: 100%;
}

.btn-sm {
    height: 32px;
    padding: 0 12px;
    font-size: 13px;
    border-radius: 9px;
}

.icon {
    width: 18px;
    height: 18px;
    flex: none;
    stroke: currentColor;
    stroke-width: 1.7;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.card {
    position: relative;
    overflow: hidden;
    background: var(--grad-surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
}

/* ==========================================================
   LOGIN
   ========================================================== */
.auth {
    min-height: 100%;
    display: grid;
    grid-template-columns: 1.05fr 1fr;
}

.auth-aside {
    position: relative;
    overflow: hidden;
    padding: 56px 60px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: var(--grad-auth);
    border-right: 1px solid var(--line-soft);
}

.auth-aside::after {
    content: "";
    position: absolute;
    inset: -40%;
    background-image: linear-gradient(var(--glass) 1px, transparent 1px),
        linear-gradient(90deg, var(--glass) 1px, transparent 1px);
    background-size: 46px 46px;
    transform: rotate(8deg);
    pointer-events: none;
}

.auth-aside>* {
    position: relative;
    z-index: 1;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 13px;
    background: var(--grad-brand);
    display: grid;
    place-items: center;
    color: var(--on-brand);
    box-shadow: 0 12px 28px -14px rgba(56, 224, 176, .9);
}

.brand-mark svg {
    width: 22px;
    height: 22px;
    stroke-width: 2.2;
}

.brand-logo {
    display: block;
    height: 45px;
    width: auto;
    max-width: 220px;
    object-fit: contain;
}

.brand-name {
    font-size: 17px;
    font-weight: 700;
    line-height: 1.1;
}

.brand-sub {
    font-size: 11.5px;
    color: var(--fg-muted);
    letter-spacing: .14em;
    text-transform: uppercase;
}

.auth-hero h1 {
    font-size: 44px;
    line-height: 1.08;
    max-width: 12ch;
}

.auth-hero h1 span {
    background: var(--grad-brand);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.auth-hero p {
    margin-top: 18px;
    color: var(--fg-muted);
    max-width: 44ch;
    line-height: 1.65;
    font-size: 15px;
}

.auth-stats {
    display: flex;
    gap: 14px;
    margin-top: 34px;
    flex-wrap: wrap;
}

.auth-stat {
    padding: 14px 18px;
    border-radius: 14px;
    min-width: 130px;
    background: var(--glass);
    border: 1px solid var(--line);
    backdrop-filter: blur(6px);
}

.auth-stat b {
    display: block;
    font-size: 22px;
    font-family: "Sora", sans-serif;
}

.auth-stat span {
    font-size: 12px;
    color: var(--fg-muted);
}

.auth-foot {
    font-size: 12.5px;
    color: var(--fg-dim);
}

.auth-main {
    display: grid;
    place-items: center;
    padding: 40px 24px;
    background: var(--bg);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    padding: 38px 34px;
}

.auth-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--grad-glow);
    pointer-events: none;
}

.auth-card>* {
    position: relative;
}

.auth-card h2 {
    font-size: 26px;
}

.auth-card .sub {
    color: var(--fg-muted);
    font-size: 14px;
    margin-top: 8px;
}

.field {
    margin-top: 20px;
}

.field label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--fg-muted);
    margin-bottom: 8px;
}

.control {
    position: relative;
    display: flex;
    align-items: center;
}

.control>.icon {
    position: absolute;
    left: 13px;
    color: var(--fg-dim);
    pointer-events: none;
}

.control .toggle .icon {
    position: static;
}

.field .control input,
.control input {
    width: 100%;
    height: 46px;
    padding: 0 44px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--s-deep);
    color: var(--fg);
    outline: none;
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.control input::placeholder {
    color: var(--placeholder);
}

.control input:focus {
    border-color: var(--brand-2);
    background: var(--s-2);
    box-shadow: 0 0 0 4px rgba(46, 168, 255, .14);
}

.control .toggle {
    position: absolute;
    right: 10px;
    color: var(--fg-dim);
    padding: 6px;
    border-radius: 8px;
}

.control .toggle:hover {
    color: var(--fg);
    background: var(--s-hover-strong);
}

.row-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--fg-muted);
    cursor: pointer;
}

.check input {
    accent-color: var(--brand);
    width: 15px;
    height: 15px;
}

.link {
    font-size: 13px;
    color: var(--info-fg);
    font-weight: 600;
}

.link:hover {
    text-decoration: underline;
}

.divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 24px 0;
    color: var(--fg-dim);
    font-size: 12px;
}

.divider::before,
.divider::after {
    content: "";
    height: 1px;
    flex: 1;
    background: var(--line);
}

.sso {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.auth-note {
    margin-top: 24px;
    font-size: 12.5px;
    color: var(--fg-dim);
    text-align: center;
}

/* ==========================================================
   APP SHELL
   ========================================================== */
.app {
    display: flex;
    min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-w);
    flex: none;
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--grad-sidebar);
    border-right: 1px solid var(--line-soft);
    transition: width .22s ease;
    z-index: 30;
}

.sidebar-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 18px;
    border-bottom: 1px solid var(--line-soft);
}

.sidebar-head .brand-text {
    overflow: hidden;
    white-space: nowrap;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px 22px;
}

.nav-group {
    margin-top: 18px;
}

.nav-group:first-child {
    margin-top: 4px;
}

.nav-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    margin-bottom: 4px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--nav-label);
    border-radius: 8px;
    width: 100%;
}

.nav-label:hover {
    color: var(--fg-soft);
}

.nav-label .chev {
    transition: transform .2s ease;
    width: 14px;
    height: 14px;
}

.nav-group.collapsed .chev {
    transform: rotate(-90deg);
}

.nav-group.collapsed .nav-items {
    display: none;
}

.nav-items {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 11px;
    border-radius: 11px;
    font-size: 13.6px;
    font-weight: 500;
    color: var(--nav-fg);
    transition: background .16s ease, color .16s ease, transform .16s ease;
}

.nav-item:hover {
    background: var(--s-nav-hover);
    color: var(--fg);
    transform: translateX(2px);
}

.nav-item .icon {
    width: 17px;
    height: 17px;
    color: var(--nav-icon);
    transition: color .16s ease;
}

.nav-item:hover .icon {
    color: var(--brand);
}

.nav-item.active {
    color: var(--on-brand);
    background: var(--grad-brand);
    box-shadow: 0 12px 26px -14px rgba(56, 224, 176, .9);
    font-weight: 650;
}

.nav-item.active .icon {
    color: var(--on-brand);
}

.nav-item .count {
    margin-left: auto;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 99px;
    background: var(--s-hover-strong);
    color: var(--count-fg);
}

.nav-item.active .count {
    background: rgba(0, 0, 0, .2);
    color: var(--on-brand);
}

.sidebar-foot {
    padding: 14px;
    border-top: 1px solid var(--line-soft);
}

.profile {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px;
    border-radius: 14px;
    background: var(--s-1);
    border: 1px solid var(--line);
    transition: border-color .18s ease, background .18s ease;
}

.profile:hover {
    border-color: var(--line-strong);
    background: var(--s-profile-hover);
}

.avatar {
    position: relative;
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    font-family: "Sora", sans-serif;
    font-weight: 700;
    font-size: 14px;
    color: var(--on-brand);
    background: var(--grad-brand);
    box-shadow: 0 8px 20px -10px rgba(56, 224, 176, .85);
}

.avatar.ring {
    box-shadow: 0 0 0 2px var(--s-deep), 0 0 0 4px rgba(56, 224, 176, .45);
}

.avatar.sm {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    font-size: 12px;
}

.avatar.lg {
    width: 54px;
    height: 54px;
    border-radius: 17px;
    font-size: 18px;
}

.avatar.v2 {
    background: linear-gradient(135deg, #ffb547, #ff5f6d);
}

.avatar.v3 {
    background: linear-gradient(135deg, #7c6bff, #2ea8ff);
}

.avatar.v4 {
    background: linear-gradient(135deg, #35d07f, #2ea8ff);
}

.avatar .status {
    position: absolute;
    right: -2px;
    bottom: -2px;
    width: 12px;
    height: 12px;
    border-radius: 99px;
    background: var(--ok);
    border: 2.5px solid var(--avatar-ring);
}

.profile-meta {
    min-width: 0;
}

.profile-meta b {
    display: block;
    font-size: 13.4px;
    font-weight: 650;
}

.profile-meta span {
    display: block;
    font-size: 11.5px;
    color: var(--fg-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile .icon {
    margin-left: auto;
    color: var(--fg-dim);
}

/* Collapsed sidebar */
.app.collapsed .sidebar {
    width: var(--sidebar-w-collapsed);
}

.app.collapsed .sidebar .brand-text,
.app.collapsed .sidebar .brand-logo,
.app.collapsed .sidebar .nav-item span,
.app.collapsed .sidebar .nav-item .count,
.app.collapsed .sidebar .nav-label span,
.app.collapsed .sidebar .profile-meta,
.app.collapsed .sidebar .profile>.icon {
    display: none;
}

.app.collapsed .sidebar .nav-label {
    justify-content: center;
}

.app.collapsed .sidebar .nav-item {
    justify-content: center;
    padding: 11px 0;
}

.app.collapsed .sidebar .profile {
    justify-content: center;
    padding: 8px;
}

.app.collapsed .sidebar .nav-item:hover::after {
    content: attr(data-tip);
    position: absolute;
    left: calc(100% + 12px);
    white-space: nowrap;
    background: var(--s-hover-strong);
    border: 1px solid var(--line);
    padding: 6px 10px;
    border-radius: 9px;
    font-size: 12.5px;
    color: var(--fg);
    box-shadow: var(--shadow-md);
    z-index: 50;
}

/* ---------- Main ---------- */
.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--main-glow), var(--bg);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 26px;
    background: var(--topbar-bg);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line-soft);
}

.iconbtn {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    background: var(--s-1);
    color: var(--fg-muted);
    transition: all .16s ease;
    position: relative;
}

.iconbtn:hover {
    color: var(--fg);
    border-color: var(--line-strong);
    transform: translateY(-1px);
}

.iconbtn .pip {
    position: absolute;
    top: 8px;
    right: 9px;
    width: 7px;
    height: 7px;
    border-radius: 99px;
    background: var(--danger);
    box-shadow: 0 0 0 2.5px var(--s-1), 0 0 10px var(--danger);
}

.search {
    position: relative;
    flex: 1;
    max-width: 420px;
    display: flex;
    align-items: center;
}

.search .icon {
    position: absolute;
    left: 12px;
    color: var(--fg-dim);
}

.search input {
    width: 100%;
    height: 38px;
    padding: 0 74px 0 38px;
    border-radius: 11px;
    border: 1px solid var(--line);
    background: var(--s-deep);
    color: var(--fg);
    outline: none;
    transition: border-color .16s ease, box-shadow .16s ease;
}

.search input::placeholder {
    color: var(--placeholder);
}

.search input:focus {
    border-color: var(--brand-2);
    box-shadow: 0 0 0 4px rgba(46, 168, 255, .12);
}

.search kbd {
    position: absolute;
    right: 10px;
    font-size: 10.5px;
    font-family: inherit;
    color: var(--fg-dim);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 2px 6px;
    background: var(--s-kbd);
}

.topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

.content {
    padding: 26px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    flex-wrap: wrap;
}

.page-head h1 {
    font-size: 26px;
}

.page-head p {
    color: var(--fg-muted);
    font-size: 14px;
    margin-top: 6px;
}

.page-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ---------- KPI cards ---------- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.kpi-grid-3col {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.kpi-grid-2col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.kpi {
    padding: 18px;
    border-radius: var(--radius);
    background: var(--grad-surface);
    border: 1px solid var(--line);
    position: relative;
    overflow: hidden;
    transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
}

.kpi::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(90% 120% at 100% 0%, var(--kpi-tint, rgba(56, 224, 176, .20)), transparent 62%);
    opacity: .85;
    transition: opacity .22s ease;
}

.kpi::after {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--kpi-bar, var(--grad-brand));
    opacity: .9;
}

.kpi:hover {
    transform: translateY(-4px);
    border-color: var(--line-strong);
    box-shadow: var(--shadow-glow);
}

.kpi:hover::before {
    opacity: 1;
}

.kpi>* {
    position: relative;
}

.kpi-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.kpi-ico {
    width: 40px;
    height: 40px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    background: var(--s-ico);
    border: 1px solid var(--line);
    color: var(--kpi-color, var(--brand));
    box-shadow: inset 0 0 22px -12px var(--kpi-color, var(--brand));
}

.kpi-label {
    margin-top: 16px;
    font-size: 12.5px;
    color: var(--fg-muted);
    font-weight: 550;
}

.kpi-value {
    font-family: "Sora", sans-serif;
    font-size: 30px;
    font-weight: 700;
    margin-top: 4px;
    letter-spacing: -.03em;
}

.kpi-foot {
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--fg-dim);
}

.trend {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 700;
    font-size: 12px;
}

.trend.up {
    color: var(--up);
}

.trend.down {
    color: var(--down);
}

.spark {
    width: 100%;
    height: 34px;
    margin-top: 14px;
    display: block;
}

.kpi.k2 {
    --kpi-tint: rgba(46, 168, 255, .20);
    --kpi-color: #2ea8ff;
    --kpi-bar: linear-gradient(180deg, #2ea8ff, #7c6bff);
}

.kpi.k3 {
    --kpi-tint: rgba(124, 107, 255, .20);
    --kpi-color: #9c8dff;
    --kpi-bar: linear-gradient(180deg, #7c6bff, #ff5f6d);
}

.kpi.k4 {
    --kpi-tint: rgba(255, 181, 71, .18);
    --kpi-color: #ffb547;
    --kpi-bar: linear-gradient(180deg, #ffb547, #ff5f6d);
}

/* ---------- Layout grids ---------- */
.grid-2 {
    display: grid;
    grid-template-columns: 1.65fr 1fr;
    gap: 16px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.panel {
    padding: 20px;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.panel-head h3 {
    font-size: 15.5px;
}

.panel-head p {
    font-size: 12.5px;
    color: var(--fg-muted);
    margin-top: 3px;
}

.seg {
    display: flex;
    gap: 4px;
    padding: 3px;
    background: var(--s-deep);
    border: 1px solid var(--line);
    border-radius: 10px;
}

.seg button {
    padding: 5px 11px;
    border-radius: 7px;
    font-size: 12px;
    color: var(--fg-muted);
    font-weight: 600;
}

.seg button.on {
    background: var(--s-hover-strong);
    color: var(--fg);
    box-shadow: var(--shadow-sm);
}

/* Chart */
.chart-wrap {
    position: relative;
}

.chart {
    width: 100%;
    height: 230px;
    display: block;
}

.legend {
    display: flex;
    gap: 16px;
    margin-top: 12px;
    font-size: 12px;
    color: var(--fg-muted);
}

.legend i {
    width: 9px;
    height: 9px;
    border-radius: 3px;
    display: inline-block;
    margin-right: 6px;
}

/* Plan bars */
.bars {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.bar-row .bar-top {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    margin-bottom: 7px;
}

.bar-row .bar-top span {
    color: var(--fg-muted);
}

.bar-track {
    height: 8px;
    border-radius: 99px;
    background: var(--s-2);
    overflow: hidden;
    border: 1px solid var(--line-soft);
}

.bar-fill {
    height: 100%;
    border-radius: 99px;
    background: var(--grad-brand);
    box-shadow: 0 0 18px -4px rgba(56, 224, 176, .8);
    animation: grow 1s cubic-bezier(.2, .8, .2, 1) both;
}

.bar-fill.b2 {
    background: linear-gradient(90deg, #2ea8ff, #7c6bff);
    box-shadow: 0 0 18px -4px rgba(46, 168, 255, .8);
}

.bar-fill.b3 {
    background: linear-gradient(90deg, #7c6bff, #ff5f6d);
    box-shadow: 0 0 18px -4px rgba(124, 107, 255, .8);
}

.bar-fill.b4 {
    background: linear-gradient(90deg, #ffb547, #ff5f6d);
    box-shadow: 0 0 18px -4px rgba(255, 181, 71, .7);
}

@keyframes grow {
    from {
        width: 0 !important;
    }
}

/* Health list */
.health {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.health-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 13px;
    border-radius: 12px;
    background: var(--s-row);
    border: 1px solid var(--line-soft);
    transition: border-color .16s ease, transform .16s ease;
}

.health-row:hover {
    border-color: var(--line-strong);
    transform: translateX(2px);
}

.health-row b {
    font-size: 13.4px;
    font-weight: 600;
}

.health-row .sub {
    font-size: 11.5px;
    color: var(--fg-dim);
}

.health-row .right {
    margin-left: auto;
    text-align: right;
}

.pulse {
    width: 9px;
    height: 9px;
    border-radius: 99px;
    background: var(--ok);
    position: relative;
}

.pulse::after {
    content: "";
    position: absolute;
    inset: -4px;
    border-radius: 99px;
    border: 1px solid currentColor;
    color: var(--ok);
    animation: ping 1.8s ease-out infinite;
}

.pulse.warn {
    background: var(--warn);
}

.pulse.warn::after {
    color: var(--warn);
}

.pulse.bad {
    background: var(--danger);
}

.pulse.bad::after {
    color: var(--danger);
}

@keyframes ping {
    0% {
        transform: scale(.7);
        opacity: .9;
    }

    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* Activity feed */
.feed {
    display: flex;
    flex-direction: column;
}

.feed-item {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px dashed var(--line-soft);
}

.feed-item:last-child {
    border-bottom: 0;
}

.feed-item p {
    font-size: 13.2px;
    line-height: 1.5;
}

.feed-item p b {
    font-weight: 650;
}

.feed-item .time {
    font-size: 11.5px;
    color: var(--fg-dim);
    margin-top: 3px;
    display: block;
}

/* ---------- Table ---------- */
.table-card {
    padding: 0;
    overflow: hidden;
}

.table-head {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 18px 20px;
    border-bottom: 1px solid var(--line-soft);
}

.table-tools {
    margin-left: auto;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.select {
    height: 34px;
    padding: 0 12px;
    border-radius: 10px;
    background: var(--s-deep);
    border: 1px solid var(--line);
    color: var(--fg-muted);
    outline: none;
}

.table-scroll {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 820px;
}

thead th {
    text-align: left;
    font-size: 11px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--th-fg);
    font-weight: 700;
    padding: 12px 20px;
    background: var(--s-th);
    border-bottom: 1px solid var(--line-soft);
    position: sticky;
    top: 0;
}

tbody td {
    padding: 14px 20px;
    font-size: 13.5px;
    border-bottom: 1px solid var(--line-soft);
    color: var(--fg-soft);
}

tbody tr {
    transition: background .16s ease;
}

tbody tr:hover {
    background: var(--s-row-hover);
}

tbody tr:last-child td {
    border-bottom: 0;
}

.cell-user {
    display: flex;
    align-items: center;
    gap: 11px;
}

.cell-user b {
    display: block;
    font-size: 13.6px;
    color: var(--fg);
    font-weight: 620;
}

.cell-user span {
    font-size: 11.5px;
    color: var(--fg-dim);
}

.usage-mini {
    display: flex;
    align-items: center;
    gap: 9px;
}

.usage-mini .bar-track {
    width: 88px;
    height: 6px;
}

.usage-mini small {
    color: var(--fg-muted);
    font-size: 11.5px;
}

.rowbtn {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    color: var(--fg-dim);
}

.rowbtn:hover {
    background: var(--s-hover-strong);
    color: var(--fg);
}

.table-foot {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    font-size: 12.5px;
    color: var(--fg-muted);
    flex-wrap: wrap;
}

.pager {
    margin-left: auto;
    display: flex;
    gap: 6px;
}

.pager button {
    min-width: 32px;
    height: 32px;
    padding: 0 9px;
    border-radius: 9px;
    border: 1px solid var(--line);
    color: var(--fg-muted);
    background: var(--s-2);
}

.pager button:hover {
    color: var(--fg);
    border-color: var(--line-strong);
}

.pager button.on {
    background: var(--grad-brand);
    color: var(--on-brand);
    border-color: transparent;
    font-weight: 700;
}

/* Team / profile cards */
.people {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.person {
    padding: 18px;
    text-align: center;
}

.person .avatar {
    margin: 0 auto 12px;
}

.person b {
    display: block;
    font-size: 14.5px;
}

.person span {
    font-size: 12px;
    color: var(--fg-muted);
}

.person .meta {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.person .actions {
    display: flex;
    gap: 8px;
    margin-top: 14px;
}

.person .actions .btn {
    flex: 1;
}

.footer {
    padding: 8px 26px 28px;
    color: var(--fg-dim);
    font-size: 12.5px;
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}

/* ---------- Responsive ---------- */
@media (max-width: 1240px) {
    .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .grid-2 {
        grid-template-columns: 1fr;
    }

    .people {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 980px) {
    .auth {
        grid-template-columns: 1fr;
    }

    .auth-aside {
        display: none;
    }

    .grid-3 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .people {
        grid-template-columns: 1fr;
    }

    .content {
        padding: 18px;
    }

    .sidebar {
        position: fixed;
        left: 0;
        transform: translateX(-100%);
        transition: transform .22s ease;
    }

    .app.nav-open .sidebar {
        transform: translateX(0);
        box-shadow: 0 0 60px rgba(0, 0, 0, .7);
    }

    .search {
        display: none;
    }
}


/* ==========================================================
   THEME TOGGLE + ADDED COMPONENTS
   ========================================================== */
html {
    transition: none;
}

body,
.card,
.kpi,
.sidebar,
.topbar,
.btn,
.nav-item,
table,
.health-row {
    transition: background-color .25s ease, color .25s ease, border-color .25s ease;
}

.theme-toggle {
    position: relative;
    overflow: hidden;
}

.theme-toggle .sun {
    display: none;
}

[data-theme="light"] .theme-toggle .sun {
    display: block;
}

[data-theme="light"] .theme-toggle .moon {
    display: none;
}

.auth-theme {
    position: absolute;
    top: 22px;
    right: 24px;
    z-index: 5;
}

/* Breadcrumb */
.crumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    color: var(--fg-dim);
    margin-bottom: 6px;
}

.crumbs a:hover {
    color: var(--fg);
}

.crumbs i {
    opacity: .6;
    font-style: normal;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--line-soft);
    overflow-x: auto;
}

.tabs button {
    padding: 10px 14px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--fg-muted);
    border-bottom: 2px solid transparent;
    white-space: nowrap;
}

.tabs button:hover {
    color: var(--fg);
}

.tabs button.on {
    color: var(--fg);
    border-bottom-color: var(--brand);
}

/* Stat strip */
.stat-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.stat {
    padding: 16px 18px;
}

.stat span {
    font-size: 12.5px;
    color: var(--fg-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat b {
    display: block;
    font-family: "Sora", sans-serif;
    font-size: 24px;
    margin-top: 8px;
    letter-spacing: -.02em;
}

.stat .trend {
    margin-top: 8px;
}

/* Filter bar */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid var(--line-soft);
}

.filters .search {
    max-width: 320px;
    flex: 1 1 240px;
}

.chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 12px;
    border-radius: 99px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--fg-muted);
    border: 1px solid var(--line);
    background: var(--s-chip);
    transition: all .16s ease;
}

.chip:hover {
    color: var(--fg);
    border-color: var(--line-strong);
    transform: translateY(-1px);
}

.chip.on {
    color: var(--on-brand);
    background: var(--grad-brand);
    border-color: transparent;
    box-shadow: 0 10px 22px -14px rgba(46, 168, 255, .9);
}

/* Checkbox cell */
.cbx {
    width: 16px;
    height: 16px;
    accent-color: var(--brand-2);
    cursor: pointer;
}

/* Definition list / detail rows */
.dl {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 22px;
}

.dl div span {
    display: block;
    font-size: 11.5px;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--fg-dim);
}

.dl div b {
    display: block;
    font-size: 13.8px;
    font-weight: 600;
    margin-top: 5px;
}

/* Toggle switch */
.switch {
    position: relative;
    width: 42px;
    height: 24px;
    flex: none;
}

.switch input {
    position: absolute;
    opacity: 0;
    inset: 0;
    cursor: pointer;
    z-index: 2;
}

.switch i {
    position: absolute;
    inset: 0;
    border-radius: 99px;
    background: var(--s-2);
    border: 1px solid var(--line);
    transition: all .2s ease;
}

.switch i::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 99px;
    background: var(--fg-muted);
    transition: all .2s ease;
}

.switch input:checked+i {
    background: var(--grad-brand);
    border-color: transparent;
}

.switch input:checked+i::after {
    left: 20px;
    background: #fff;
}

/* Empty state / info tile */
.tile {
    padding: 16px;
    border-radius: 14px;
    background: var(--s-row);
    border: 1px solid var(--line-soft);
}

.tile+.tile {
    margin-top: 10px;
}

/* Org / user avatar group */
.stack {
    display: flex;
}

.stack .avatar {
    margin-left: -10px;
    border: 2px solid var(--bg-elev);
}

.stack .avatar:first-child {
    margin-left: 0;
}

/* Drawer */
.drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(4, 8, 16, .6);
    backdrop-filter: blur(3px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s ease;
    z-index: 60;
}

.drawer {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: min(460px, 100%);
    background: var(--grad-surface);
    border-left: 1px solid var(--line);
    transform: translateX(100%);
    transition: transform .28s cubic-bezier(.22, .8, .24, 1);
    z-index: 61;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-md);
}

body.drawer-open .drawer-backdrop {
    opacity: 1;
    pointer-events: auto;
}

body.drawer-open .drawer {
    transform: translateX(0);
}

.drawer-head {
    padding: 18px 20px;
    border-bottom: 1px solid var(--line-soft);
    display: flex;
    align-items: center;
    gap: 12px;
}

.drawer-head>div {
    min-width: 0;
}

.drawer-head>div>b,
.drawer-head>div>span {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.drawer-body {
    flex: 1 1 auto;
    min-height: 0;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* Detail rows inside the drawer: never let long values (emails, ids) spill out */
.drawer-body .dl {
    gap: 16px 20px;
}

.drawer-body .dl div {
    min-width: 0;
}

.drawer-body .dl div b {
    font-size: 13.4px;
    line-height: 1.35;
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Owner / contact holds an email — give it the full row so it never wraps mid-address */
.drawer-body .dl div:nth-child(4) {
    grid-column: 1 / -1;
}

.drawer-foot {
    margin-top: auto;
    padding: 16px 20px calc(16px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line-soft);
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: stretch;
    gap: 10px;
}

/* Both actions share the row equally, same height, single line */
.drawer-foot>.btn {
    width: 100%;
    min-width: 0;
    height: 44px;
    padding: 0 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    line-height: 44px;
    text-align: center;
}

@media (max-width: 420px) {
    .drawer-foot {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1100px) {
    .stat-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dl {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 620px) {
    .stat-strip {
        grid-template-columns: 1fr;
    }
}

/* ---------- Phase 2 components: pricing, meters, toggles, pulses, timeline ---------- */
.card-sub {
    margin: 2px 0 0;
    color: var(--fg-muted);
    font-size: 12.5px;
}

.muted {
    color: var(--fg-muted);
}

.search.sm {
    height: 34px;
    max-width: 220px;
    padding: 0 10px;
}

.search.sm input {
    font-size: 12.5px;
}

.price-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.card.price {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 22px;
    overflow: hidden;
}

.card.price h3 {
    margin: 0;
    font-size: 15px;
    letter-spacing: .3px;
    text-transform: uppercase;
    color: var(--fg-muted);
}

.card.price.featured {
    border-color: var(--line-strong);
    box-shadow: var(--shadow-glow);
}

.card.price.featured::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 3px;
    background: var(--grad-brand);
}

.ribbon {
    position: absolute;
    top: 14px;
    right: -34px;
    transform: rotate(38deg);
    background: var(--grad-brand);
    color: var(--on-brand);
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: .6px;
    padding: 4px 38px;
    text-transform: uppercase;
}

.price-amount {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.price-amount b {
    font-size: 34px;
    letter-spacing: -1px;
}

.price-amount span {
    color: var(--fg-muted);
    font-size: 12.5px;
}

.ticks {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 9px;
}

.ticks li {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 13px;
    color: var(--fg-soft);
}

.ticks .icon {
    width: 16px;
    height: 16px;
    color: var(--brand);
    flex: none;
}

.price-foot {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-top: 14px;
    border-top: 1px solid var(--line-soft);
    font-size: 12.5px;
}

.kv-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    padding: 4px 2px 2px;
}

.kv {
    display: grid;
    gap: 7px;
}

.kv>span {
    color: var(--fg-muted);
    font-size: 12px;
}

.kv>b {
    font-size: 17px;
}

.kv em {
    font-style: normal;
    font-size: 12.5px;
}

.meter {
    height: 8px;
    border-radius: 99px;
    background: var(--s-2);
    border: 1px solid var(--line-soft);
    overflow: hidden;
}

.meter i {
    display: block;
    height: 100%;
    border-radius: 99px;
    background: var(--grad-brand);
    animation: grow 1s cubic-bezier(.2, .8, .2, 1) both;
}

.meter.ok i {
    background: linear-gradient(90deg, #35d07f, #38e0b0);
}

.meter.warn i {
    background: linear-gradient(90deg, #ffb547, #ff8f5f);
}

.meter.danger i {
    background: linear-gradient(90deg, #ff5f6d, #ff8f98);
}

.toggle-list {
    display: grid;
}

.row-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 13px 2px;
    border-bottom: 1px solid var(--line-soft);
}

.row-toggle:last-child {
    border-bottom: 0;
}

.row-toggle b {
    display: block;
    font-size: 13.5px;
}

.row-toggle span {
    display: block;
    color: var(--fg-muted);
    font-size: 12px;
    margin-top: 2px;
}

.pulse-list {
    display: grid;
    gap: 10px;
}

.pulse {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--line-soft);
    border-radius: 12px;
    background: var(--s-1);
    transition: .18s;
}

.pulse:hover {
    background: var(--s-row-hover);
    transform: translateX(2px);
}

.pulse .who {
    flex: 1;
    min-width: 0;
}

.pulse .who b {
    display: block;
    font-size: 13.5px;
}

.pulse .who span {
    color: var(--fg-muted);
    font-size: 12px;
}

.spark-mini {
    width: 92px;
    height: 26px;
    flex: none;
    color: var(--brand);
}

.spark-mini path {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
}

.timeline {
    display: grid;
    gap: 0;
    padding-left: 6px;
}

.tl {
    position: relative;
    padding: 0 0 18px 22px;
    border-left: 2px solid var(--line-soft);
}

.tl:last-child {
    border-left-color: transparent;
    padding-bottom: 0;
}

.tl::before {
    content: "";
    position: absolute;
    left: -7px;
    top: 2px;
    width: 12px;
    height: 12px;
    border-radius: 99px;
    background: var(--brand);
    box-shadow: 0 0 0 4px var(--avatar-ring);
}

.tl.warn::before {
    background: var(--warn);
}

.tl.danger::before {
    background: var(--danger);
}

.tl.info::before {
    background: var(--brand-2);
}

.tl b {
    display: block;
    font-size: 13.5px;
}

.tl p {
    margin: 3px 0 0;
    color: var(--fg-muted);
    font-size: 12.5px;
}

.tl time {
    color: var(--fg-dim);
    font-size: 11.5px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    padding: 4px 2px;
}

.field {
    display: grid;
    gap: 7px;
}

.field label {
    font-size: 12px;
    color: var(--fg-muted);
}

.field input,
.field select,
.field textarea {
    height: 40px;
    padding: 0 12px;
    border-radius: 11px;
    border: 1px solid var(--line);
    background: var(--s-btn);
    color: var(--fg);
    font: inherit;
    font-size: 13.5px;
    outline: none;
    transition: .18s;
}

.field textarea {
    height: auto;
    padding: 10px 12px;
    min-height: 84px;
    resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: var(--brand-2);
    box-shadow: 0 0 0 3px rgba(46, 168, 255, .16);
}

.field.full {
    grid-column: 1 / -1;
}

@media (max-width: 1100px) {
    .price-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .kv-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 620px) {
    .price-grid {
        grid-template-columns: 1fr;
    }
}

/* ---------- Sidebar logout button ---------- */
.logout-btn {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    margin-top: 10px;
    padding: 10px;
    border-radius: 14px;
    background: var(--s-btn);
    border: 1px solid var(--line);
    color: var(--fg-soft);
    font: inherit;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color .18s ease, background .18s ease, color .18s ease;
}

.logout-btn .icon {
    width: 18px;
    height: 18px;
    flex: none;
    color: var(--nav-icon);
}

.logout-btn:hover {
    background: var(--danger-bg);
    border-color: var(--danger-bd);
    color: var(--danger-fg);
}

.logout-btn:hover .icon {
    color: var(--danger-fg);
}

.logout-btn:disabled {
    opacity: .6;
    cursor: default;
}

.app.collapsed .sidebar .logout-btn {
    justify-content: center;
}

.app.collapsed .sidebar .logout-btn>span {
    display: none;
}

/* ==========================================================
   Plans page layout fixes
   ========================================================== */

/* Footer belongs to the main column; never let it become a
   flex sibling of .main and steal horizontal space. */
.app>.footer {
    display: none;
}

.main>.footer {
    display: flex;
    width: 100%;
}

/* Content should always fill the main column */
.main>.content {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
}

/* Stat strip: fluid so 6 cards distribute instead of 4 + 2 stragglers */
.stat-strip {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

/* Pricing grid: fit the real number of plans, no phantom 4th column */
.price-grid {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    align-items: stretch;
}

/* Price typography must shrink instead of overflowing the card */
.card.price {
    min-width: 0;
}

.card.price h3 {
    padding-right: 84px;
    /* keep the room the ribbon occupies */
    overflow-wrap: anywhere;
}

.price-amount {
    flex-wrap: wrap;
    min-width: 0;
}

.price-amount b {
    font-size: clamp(24px, 2.4vw, 34px);
    overflow-wrap: anywhere;
}

.price-amount span {
    white-space: nowrap;
}

.ticks li {
    overflow-wrap: anywhere;
}

/* Ribbon: keep it inside the card corner */
.ribbon {
    top: 16px;
    right: -40px;
    max-width: 150px;
    padding: 4px 40px;
    text-align: center;
    pointer-events: none;
}

@media (max-width: 900px) {
    .ribbon {
        display: none;
    }
}

/* ==========================================================
   Card header / table wrapper aliases
   The markup uses .card-head / .card-tools / .table-wrap while the
   design system only styled .table-head / .table-tools / .table-scroll.
   Without these, the "Records" heading rendered unstyled on top of the
   table instead of inside a proper card header bar.
   ========================================================== */
.card-head {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 18px 20px;
    border-bottom: 1px solid var(--line-soft);
}

.card-head h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: .2px;
    color: var(--fg);
}

.card-tools {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.card-tools .search {
    width: 260px;
    max-width: 100%;
}

/* Horizontal scroll container for wide tables (table has min-width:820px) */
.table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* .table-card sets overflow:hidden, which kills sticky headers and clips the
   scrollbar; let the wrapper own the scrolling instead. */
.card.table-card {
    overflow: visible;
}

.card.table-card>*:first-child {
    border-top-left-radius: var(--radius);
    border-top-right-radius: var(--radius);
}

.card.table-card>*:last-child {
    border-bottom-left-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
}

.table-wrap table {
    min-width: 900px;
}

.table-wrap thead th {
    white-space: nowrap;
}

.table-wrap tbody td {
    vertical-align: middle;
}

/* Last column holds the row action button - keep it tight and right-aligned.
   Only when it really is an action column (empty header / row button); data
   columns such as "Enforcement" must keep their natural width and alignment. */
.table-wrap thead th:last-child:empty {
    width: 56px;
}

.table-wrap tbody td:last-child:has(.rowbtn) {
    width: 56px;
    text-align: right;
}

.table-foot {
    justify-content: space-between;
    border-top: 1px solid var(--line-soft);
}

.filters .select {
    height: 36px;
}

@media (max-width: 700px) {
    .card-head {
        align-items: flex-start;
    }

    .card-tools {
        margin-left: 0;
        width: 100%;
    }

    .card-tools .search {
        width: 100%;
    }
}


/* ==========================================================
   Entitlements page
   ========================================================== */

/* Two-column section: let each card size to its own content instead of
   stretching the shorter one into a tall empty box. */
.grid-2 {
    align-items: start;
}

.grid-2>.card {
    min-width: 0;
}

/* Quota tiles: fluid so they never squash on narrow columns */
.kv-grid {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    padding: 16px 20px 20px;
}

.kv>b {
    overflow-wrap: anywhere;
}

.toggle-list {
    padding: 4px 20px 12px;
}

/* An empty .card-tools must not add a gap or push the heading around */
.card-tools:empty {
    display: none;
}

/* The entitlements table has 5 real data columns - don't force the 900px
   min-width meant for the wide subscriptions table. */
.table-card[data-table-scope] .table-wrap table {
    min-width: 720px;
}

.table-wrap td code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12.5px;
    padding: 2px 7px;
    border-radius: 6px;
    background: var(--s-2);
    border: 1px solid var(--line-soft);
    white-space: nowrap;
}

@media (max-width: 1100px) {
    .grid-2 {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================
   Entitlements — Organization lookup card + records table
   Fixes: oversized/unpadded lookup copy, result text sitting
   outside the card padding, and the unreadable comma-joined
   "Values by plan" column.
   ========================================================== */

.lookup-card .card-head {
    align-items: flex-start;
}

.lookup-card .card-head-text {
    min-width: 0;
}

.lookup-card .card-head-text .card-sub {
    max-width: 68ch;
    line-height: 1.55;
}

.lookup-body {
    padding: 18px 20px 20px;
    display: grid;
    gap: 16px;
}

.lookup-controls {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.lookup-search.search.sm {
    width: 320px;
    max-width: 100%;
    flex: 0 0 auto;
}

.lookup-note {
    margin: 0;
    flex: 1 1 260px;
    min-width: 0;
    color: var(--fg-dim);
    font-size: 12px;
    line-height: 1.5;
    max-width: 60ch;
}

.lookup-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 96px;
    padding: 18px;
    border: 1px dashed var(--line);
    border-radius: 12px;
    background: var(--s-2);
    color: var(--fg-muted);
    font-size: 13px;
    text-align: center;
}

.lookup-empty p {
    margin: 0;
}

.lookup-empty .icon {
    width: 16px;
    height: 16px;
    color: var(--fg-dim);
}

.lookup-empty.is-error {
    border-style: solid;
    border-color: var(--danger-bd);
    background: var(--danger-bg);
    color: var(--danger-fg);
}

.lookup-result {
    border: 1px solid var(--line-soft);
    border-radius: 12px;
    background: var(--s-1);
    overflow: hidden;
}

.lookup-result-head {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line-soft);
    background: var(--s-2);
}

.lookup-result-head h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--fg);
}

.lookup-result-head p {
    margin: 2px 0 0;
    font-size: 12.5px;
}

.lookup-result-head .badge {
    margin-left: auto;
}

.lookup-result .kv-grid {
    padding: 16px;
    gap: 14px 20px;
}

.lookup-result .kv {
    padding: 12px 14px;
    border: 1px solid var(--line-soft);
    border-radius: 10px;
    background: var(--s-2);
}

.lookup-result .kv>b {
    font-size: 16px;
    color: var(--fg);
}

/* ---------- Records table ---------- */

.table-state {
    text-align: center;
    padding: 28px 20px;
    color: var(--fg-muted);
    font-size: 13px;
}

.table-state.is-error {
    color: var(--danger-fg);
}

.table-wrap th.col-key,
.table-wrap td.col-key {
    width: 34%;
}

.table-wrap th.col-type,
.table-wrap td.col-type {
    width: 130px;
    white-space: nowrap;
}

.table-wrap td.col-values {
    padding-top: 11px;
    padding-bottom: 11px;
}

.type-tag {
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 0 9px;
    border-radius: 999px;
    border: 1px solid var(--line-soft);
    background: var(--s-chip);
    color: var(--fg-muted);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .02em;
}

.val-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.val-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 9px;
    border-radius: 999px;
    border: 1px solid var(--line-soft);
    background: var(--s-2);
    font-size: 12px;
    line-height: 1.4;
    max-width: 100%;
}

.val-chip em {
    font-style: normal;
    color: var(--fg-dim);
    text-transform: uppercase;
    letter-spacing: .06em;
    font-size: 10.5px;
    font-weight: 700;
}

.val-chip b {
    font-weight: 600;
    color: var(--fg-soft);
    overflow-wrap: anywhere;
}

.val-chip.is-true {
    border-color: var(--ok-bd);
    background: var(--ok-bg);
}

.val-chip.is-true b {
    color: var(--ok-fg);
}

.val-chip.is-false b,
.val-chip.is-empty b {
    color: var(--fg-dim);
}

@media (max-width: 760px) {
    .lookup-search.search.sm {
        width: 100%;
    }

    .lookup-note {
        flex-basis: 100%;
    }
}

/* ==========================================================
   FIXES — login theming, topbar cleanup, drawer readability,
   button hover contrast
   ========================================================== */

/* --- Login: theme toggle needs a positioned ancestor --- */
.auth {
    position: relative;
}

.auth-theme {
    background: var(--s-btn);
    border: 1px solid var(--line);
    color: var(--fg-soft);
}

.auth-theme:hover {
    background: var(--s-btn-hover);
    border-color: var(--line-strong);
    color: var(--fg);
}

/* Overlay scrims were hard-coded dark — tie them to the theme */
[data-theme="light"] .modal-backdrop,
[data-theme="light"] .drawer-backdrop {
    background: rgba(16, 26, 43, .34);
}

/* --- Topbar: search removed, keep the layout balanced --- */
.topbar-spacer {
    flex: 1 1 auto;
    min-width: 0;
}

/* --- Buttons: text must stay readable on hover / disabled, both themes --- */
.btn:hover {
    color: var(--fg);
}

.btn-primary,
.btn-primary:hover,
.btn-primary:focus-visible {
    color: var(--on-brand);
}

.btn-primary:hover {
    filter: brightness(1.04);
}

.btn:disabled,
.btn[disabled] {
    opacity: .5;
    cursor: not-allowed;
    transform: none;
    filter: none;
    box-shadow: none;
}

.btn:disabled:hover,
.btn[disabled]:hover {
    transform: none;
    background: var(--s-btn);
    border-color: var(--line);
    color: var(--fg);
}

.btn-danger {
    background: var(--danger-bg);
    border: 1px solid var(--danger-bd);
    color: var(--danger-fg);
}

.btn-danger:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.btn-danger:disabled:hover {
    background: var(--danger-bg);
    border-color: var(--danger-bd);
    color: var(--danger-fg);
}

/* --- Drawer: simpler, calmer, easier to scan --- */
.drawer {
    width: min(480px, 100%);
    background: var(--bg-elev);
}

.drawer-head {
    padding: 20px 22px;
}

.drawer-body {
    padding: 22px;
    gap: 26px;
}

.d-sec>h4 {
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--fg-dim);
    margin-bottom: 6px;
}

.d-rows {
    display: flex;
    flex-direction: column;
}

.d-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 18px;
    padding: 11px 0;
    border-bottom: 1px solid var(--line-soft);
}

.d-row:last-child {
    border-bottom: 0;
}

.d-row>span {
    flex: none;
    font-size: 13px;
    color: var(--fg-muted);
}

.d-row>b {
    min-width: 0;
    font-size: 13.8px;
    font-weight: 600;
    color: var(--fg);
    text-align: right;
    overflow-wrap: anywhere;
}

.d-sec .kv-grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 10px;
}

.drawer-foot {
    padding: 16px 22px calc(16px + env(safe-area-inset-bottom));
}

/* Append to /dash/css/styles.css — Role distribution table */
.role-table table {
    width: 100%;
}

.role-table th.num,
.role-table td.num {
    text-align: right;
    width: 110px;
}

.role-table th.sel,
.role-table td.sel {
    width: 44px;
}

.role-table th.share,
.role-table td.share {
    width: 220px;
}

.role-table td b {
    color: var(--fg);
    font-weight: 600;
}

/* The caveat copy used to sit inside the card header and crowded the title.
   It now reads as its own note strip between the header and the filters. */
.table-note {
    margin: 0;
    padding: 12px 20px;
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--fg-muted);
    background: var(--glass);
    border-bottom: 1px solid var(--line-soft);
}

.role-table tr.on td {
    background: var(--s-row-hover);
}

.share-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.share-bar {
    flex: 1;
    height: 6px;
    border-radius: 99px;
    background: var(--s-2);
    border: 1px solid var(--line-soft);
    overflow: hidden;
}

.share-bar i {
    display: block;
    height: 100%;
    background: var(--grad-brand);
}

.share-pct {
    min-width: 46px;
    text-align: right;
    font-size: 12.5px;
    color: var(--fg-soft);
    font-variant-numeric: tabular-nums;
}

/* Append to styles_v2.css — Sortable role table headers */
.sort-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0;
    margin: 0;
    background: none;
    border: 0;
    font: inherit;
    color: inherit;
    cursor: pointer;
    letter-spacing: inherit;
    text-transform: inherit;
}

.sort-btn:hover {
    color: var(--fg);
}

.sort-btn .sort-icon {
    width: 14px;
    height: 14px;
    color: var(--fg-dim);
    transition: transform .15s ease, color .15s ease;
}

.sort-btn:hover .sort-icon {
    color: var(--fg);
}

.sort-btn.asc .sort-icon {
    transform: rotate(180deg);
    color: var(--brand);
}

.sort-btn.desc .sort-icon {
    color: var(--brand);
}

/* ==========================================================
   LOGIN — v2 (new blue design)
   Light form panel on the right, deep aurora brand panel on
   the left. Theme-independent so the sign-in screen always
   matches the approved design.
   ========================================================== */

.auth {
    --auth-aurora: radial-gradient(90% 70% at 0% 0%, rgba(124, 107, 255, .38), transparent 62%),
        radial-gradient(85% 75% at 100% 100%, rgba(45, 214, 176, .30), transparent 62%),
        linear-gradient(165deg, #101a2b 0%, #0c1727 55%, #0a1a22 100%);
    --auth-panel: #ffffff;
    --auth-card-bd: #e7ecf2;
    --auth-ink: #0f1b2d;
    --auth-ink-soft: #5b6b80;
    --auth-ink-dim: #8593a5;
    --auth-input-bg: #f3f6f9;
    --auth-input-bd: #e4e9ef;
    --auth-blue: #2f8fe0;
    --auth-grad-btn: linear-gradient(90deg, #3ddcb2 0%, #48a9ef 55%, #7c6bff 100%);
    grid-template-columns: 1.02fr 1fr;
}

/* Theme switch stays available on the sign-in screen */
.auth .auth-theme {
    display: inline-flex;
}

/* --- Left brand panel --- */
.auth .auth-aside {
    background: var(--auth-aurora);
    border-right: none;
    color: #eaf0fb;
    padding: 46px 56px;
}

.auth .auth-aside::after {
    display: none;
}

.auth .brand-mark {
    border-radius: 14px;
    background: linear-gradient(140deg, #46e3bd 0%, #3aa9f0 100%);
    color: #06202b;
    box-shadow: 0 14px 30px -16px rgba(58, 169, 240, .95);
}

.auth .brand-name {
    color: #ffffff;
}

.auth .brand-sub {
    color: rgba(228, 238, 252, .62);
}

.auth .auth-hero h1 {
    font-size: 46px;
    letter-spacing: -.01em;
    color: #ffffff;
    max-width: 13ch;
}

.auth .auth-hero h1 span {
    background: linear-gradient(90deg, #3ddcb2 0%, #48a9ef 62%, #8f7bff 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.auth .auth-hero p {
    color: rgba(220, 231, 246, .74);
}

.auth .auth-stat {
    background: rgba(255, 255, 255, .05);
    border: 1px solid rgba(255, 255, 255, .10);
    border-radius: 12px;
}

.auth .auth-stat b {
    color: #ffffff;
}

.auth .auth-stat span {
    color: rgba(214, 226, 243, .66);
}

.auth .auth-foot {
    color: rgba(197, 211, 232, .5);
}

/* --- Right form panel --- */
.auth .auth-main {
    background: var(--auth-panel);
    padding: 40px 32px;
}

.auth .auth-card {
    max-width: 448px;
    padding: 34px 36px 30px;
    background: #ffffff;
    border: 1px solid var(--auth-card-bd);
    border-radius: 16px;
    box-shadow: 0 24px 60px -34px rgba(15, 27, 45, .22),
        0 2px 6px -2px rgba(15, 27, 45, .06);
    color: var(--auth-ink);
}

.auth .auth-card::before {
    display: none;
}

.auth .auth-card .badge.info {
    background: #eaf6f2;
    border-color: #d3ece3;
    color: #1c8f75;
}

.auth .auth-card .badge .dot {
    background: #2bc79f;
}

.auth .auth-card h2 {
    font-size: 27px;
    color: var(--auth-ink);
}

.auth .auth-card .sub {
    color: var(--auth-ink-soft);
}

.auth .auth-card .field label {
    color: var(--auth-ink);
    font-size: 13px;
}

.auth .auth-card .control>.icon {
    color: var(--auth-ink-dim);
}

.auth .auth-card .control input {
    height: 48px;
    border-radius: 12px;
    background: var(--auth-input-bg);
    border: 1px solid var(--auth-input-bd);
    color: var(--auth-ink);
}

.auth .auth-card .control input::placeholder {
    color: var(--auth-ink-dim);
}

.auth .auth-card .control input:focus {
    background: #ffffff;
    border-color: var(--auth-blue);
    box-shadow: 0 0 0 4px rgba(47, 143, 224, .14);
}

.auth .auth-card .control .toggle {
    color: var(--auth-ink-dim);
}

.auth .auth-card .control .toggle:hover {
    color: var(--auth-ink);
    background: #eef2f7;
}

.auth .auth-card .link {
    color: var(--auth-blue);
}

.auth .auth-card .btn-primary {
    height: 48px;
    border-radius: 12px;
    background: var(--auth-grad-btn);
    border: none;
    color: #0b2030;
    font-weight: 700;
    box-shadow: 0 14px 30px -18px rgba(72, 169, 239, .9);
}

.auth .auth-card .btn-primary:hover,
.auth .auth-card .btn-primary:focus-visible {
    color: #0b2030;
    filter: brightness(1.03);
}

.auth .auth-card .auth-note {
    color: var(--auth-ink-dim);
    margin-top: 18px;
}

.auth .auth-card .auth-alert {
    background: #fdecee;
    border-color: #f6ccd2;
    color: #b4283a;
}

@media (max-width: 980px) {
    .auth .auth-main {
        padding: 28px 18px;
    }
}


/* ==========================================================
   LOGIN — theme toggle button + dark-mode variant of the
   sign-in screen. The toggle uses app.js's delegated
   [data-theme-toggle] handler and the "ch-theme" key.
   ========================================================== */

.auth .auth-theme {
    position: absolute;
    top: 20px;
    right: 22px;
    z-index: 6;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    border-radius: 12px;
    background: var(--auth-input-bg);
    border: 1px solid var(--auth-input-bd);
    color: var(--auth-ink-soft);
    transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}

.auth .auth-theme:hover {
    background: #ffffff;
    border-color: var(--auth-blue);
    color: var(--auth-ink);
}

.auth .auth-theme:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px rgba(47, 143, 224, .18);
}

.auth .auth-theme .icon {
    width: 18px;
    height: 18px;
}

/* --- Dark theme: keep the aurora panel, darken the form side --- */
[data-theme="dark"] .auth {
    --auth-panel: #0b1421;
    --auth-card-bd: #1d2a3c;
    --auth-ink: #eef4fb;
    --auth-ink-soft: #9fb0c6;
    --auth-ink-dim: #74869d;
    --auth-input-bg: #111d2c;
    --auth-input-bd: #22303f;
    --auth-blue: #59b0f4;
}

[data-theme="dark"] .auth .auth-card {
    background: #0f1a28;
    box-shadow: 0 28px 70px -38px rgba(0, 0, 0, .8);
}

[data-theme="dark"] .auth .auth-card .badge.info {
    background: rgba(43, 199, 159, .12);
    border-color: rgba(43, 199, 159, .28);
    color: #48d8b4;
}

[data-theme="dark"] .auth .auth-card .control input:focus {
    background: #0d1826;
    box-shadow: 0 0 0 4px rgba(89, 176, 244, .16);
}

[data-theme="dark"] .auth .auth-card .control .toggle:hover {
    background: #182636;
}

[data-theme="dark"] .auth .auth-card .auth-alert {
    background: rgba(180, 40, 58, .14);
    border-color: rgba(246, 204, 210, .22);
    color: #ff9aa6;
}

[data-theme="dark"] .auth .auth-theme:hover {
    background: #16232f;
}

/* ==========================================================
   SIDEBAR — constant aurora panel (matches the sign-in brand
   panel). The sidebar keeps its deep blue/teal gradient in
   BOTH themes; only the main content area follows light/dark.
   Tokens are re-declared on .sidebar so every descendant that
   uses them inherits the dark-on-aurora treatment.
   ========================================================== */

.app>.sidebar {
    background: radial-gradient(90% 55% at 0% 0%, rgba(124, 107, 255, .34), transparent 62%),
        radial-gradient(85% 60% at 100% 100%, rgba(45, 214, 176, .26), transparent 62%),
        linear-gradient(180deg, #101a2b 0%, #0c1727 55%, #0a1a22 100%);
    border-right: 1px solid rgba(255, 255, 255, .08);

    /* surfaces */
    --s-1: rgba(255, 255, 255, .05);
    --s-btn: rgba(255, 255, 255, .05);
    --s-btn-hover: rgba(255, 255, 255, .10);
    --s-nav-hover: rgba(255, 255, 255, .08);
    --s-hover-strong: rgba(255, 255, 255, .12);
    --s-profile-hover: rgba(255, 255, 255, .08);
    --s-deep: #0c1727;

    /* lines */
    --line-soft: rgba(255, 255, 255, .08);
    --line: rgba(255, 255, 255, .12);
    --line-strong: rgba(255, 255, 255, .22);

    /* text */
    --fg: #ffffff;
    --fg-soft: rgba(226, 236, 250, .82);
    --fg-dim: rgba(200, 214, 234, .62);
    --nav-fg: rgba(219, 231, 247, .80);
    --nav-icon: rgba(190, 208, 232, .72);
    --nav-label: rgba(178, 196, 222, .58);
    --count-fg: rgba(232, 241, 253, .88);
    /* The sidebar is deliberately dark in BOTH themes, so it re-declares the
       text tokens above. --fg-muted was missed: .profile-meta span consumes
       it, so in light mode it resolved to the global #5b6c86 and was painted
       on this near-black panel at roughly 2.4:1 — the profile subtitle was
       effectively unreadable for every light-theme admin. */
    --fg-muted: rgba(186, 202, 224, .66);
}

/* Brand block on the aurora background */
.app>.sidebar .brand-mark {
    background: linear-gradient(140deg, #46e3bd 0%, #3aa9f0 100%);
    color: #06202b;
    box-shadow: 0 14px 30px -16px rgba(58, 169, 240, .95);
}

.app>.sidebar .brand-name {
    color: #ffffff;
}

.app>.sidebar .brand-sub {
    color: rgba(228, 238, 252, .62);
}

/* Active item keeps the teal→blue gradient used on the login CTA */
.app>.sidebar .nav-item.active {
    background: linear-gradient(90deg, #3ddcb2 0%, #48a9ef 60%, #7c6bff 100%);
    color: #06202b;
    box-shadow: 0 14px 30px -18px rgba(72, 169, 239, .9);
}

.app>.sidebar .nav-item.active .icon {
    color: #06202b;
}

.app>.sidebar .nav-item.active .count {
    background: rgba(6, 32, 43, .22);
    color: #06202b;
}

.app>.sidebar .nav-item:hover .icon {
    color: #55e0bd;
}

/* Footer profile + logout */
.app>.sidebar .profile {
    background: rgba(255, 255, 255, .05);
    border-color: rgba(255, 255, 255, .12);
}

.app>.sidebar .profile:hover {
    background: rgba(255, 255, 255, .09);
    border-color: rgba(255, 255, 255, .22);
}

.app>.sidebar .profile-name {
    color: #ffffff;
}

.app>.sidebar .logout-btn {
    background: rgba(255, 255, 255, .05);
    border-color: rgba(255, 255, 255, .12);
    color: rgba(226, 236, 250, .82);
}

.app>.sidebar .logout-btn:hover {
    background: rgba(255, 92, 112, .16);
    border-color: rgba(255, 92, 112, .38);
    color: #ff9aa6;
}

.app>.sidebar .logout-btn:hover .icon {
    color: #ff9aa6;
}

/* Collapsed-state tooltips stay legible against the panel */
.app.collapsed>.sidebar .nav-item:hover::after {
    background: #0c1727;
    color: #eef4fb;
    border: 1px solid rgba(255, 255, 255, .14);
}

/* Scrollbar inside the aurora panel */
.app>.sidebar .sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .16);
}

/* ==========================================================
   USER ACCOUNTS & ROLES  (users.html)
   ========================================================== */

/* --- modal size variants + structured modal --- */
.modal.modal-md {
    max-width: 560px;
}

.modal.modal-lg {
    max-width: 820px;
}

.modal.modal-flush {
    padding: 0;
}

.modal-flush .modal-head {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--line-soft);
}

.modal-flush .modal-head h2 {
    font-size: 18px;
    margin: 0;
}

.modal-flush .modal-head p {
    margin-top: 4px;
    font-size: 12.5px;
    color: var(--fg-muted);
}

.modal-flush .modal-head .iconbtn {
    margin-left: auto;
}

.modal-flush .modal-body {
    padding: 20px 24px;
    max-height: min(62vh, 560px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.modal-flush .modal-foot {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--line-soft);
    background: var(--s-2);
}

.modal-flush .modal-foot .spacer {
    margin-left: auto;
}

/* --- grouped form sections --- */
.form-section {
    display: grid;
    gap: 12px;
}

.form-section>.sec-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--th-fg);
    font-weight: 700;
}

.form-section>.sec-title::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--line-soft);
}

.field .hint {
    font-size: 11.5px;
    color: var(--fg-dim);
}

.inline-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--s-row);
    border: 1px solid var(--line-soft);
}

.inline-toggle>div {
    flex: 1;
}

.inline-toggle b {
    display: block;
    font-size: 13.2px;
}

.inline-toggle span {
    font-size: 11.8px;
    color: var(--fg-muted);
}

.collapsible[hidden] {
    display: none;
}

/* --- permission matrix --- */
.perm-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.perm {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 13px;
    border-radius: 12px;
    background: var(--s-row);
    border: 1px solid var(--line-soft);
    cursor: pointer;
    transition: border-color .16s ease, background .16s ease;
}

.perm:hover {
    border-color: var(--line-strong);
    background: var(--s-row-hover);
}

.perm input {
    margin-top: 2px;
    accent-color: var(--brand-2);
    width: 15px;
    height: 15px;
}

.perm b {
    display: block;
    font-size: 13px;
    font-weight: 600;
}

.perm span {
    font-size: 11.5px;
    color: var(--fg-dim);
}

/* --- row action menu --- */
.row-menu-wrap {
    position: relative;
    display: inline-flex;
}

.row-menu {
    position: absolute;
    right: 0;
    top: 34px;
    z-index: 40;
    min-width: 208px;
    padding: 6px;
    border-radius: 13px;
    border: 1px solid var(--line);
    background: var(--bg-elev);
    box-shadow: var(--shadow-md);
    display: grid;
    gap: 2px;
}

.row-menu[hidden] {
    display: none;
}

.row-menu button {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 8px 10px;
    border-radius: 9px;
    font-size: 13px;
    color: var(--fg-soft);
    text-align: left;
    background: transparent;
}

.row-menu button:hover {
    background: var(--s-hover-strong);
    color: var(--fg);
}

.row-menu button.danger {
    color: var(--danger-fg);
}

.row-menu .sep {
    height: 1px;
    margin: 4px 2px;
    background: var(--line-soft);
}

/* --- misc --- */
.empty-state {
    padding: 40px 20px;
    text-align: center;
    color: var(--fg-muted);
    font-size: 13.5px;
}

.toast-stack {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 90;
    display: grid;
    gap: 10px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--bg-elev);
    box-shadow: var(--shadow-md);
    font-size: 13.2px;
    color: var(--fg);
    animation: toast-in .22s ease;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
}

.stat-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.stat {
    padding: 16px 18px;
}

.stat .k {
    font-size: 11.5px;
    color: var(--fg-muted);
}

.stat .v {
    font-size: 24px;
    font-weight: 700;
    margin-top: 6px;
    font-family: var(--font-display, inherit);
}

@media (max-width: 1100px) {
    .stat-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .perm-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .stat-row {
        grid-template-columns: 1fr;
    }
}

.table-tools .search.sm input {
    width: 260px;
}

/* ---- table tools: keep the search field and the status select from
   overlapping. .search.sm capped at 220px while its input was forced to
   260px, so the input spilled over the neighbouring select. ---- */
.table-tools {
    align-items: center;
    flex-wrap: nowrap;
}

.table-tools .search.sm {
    max-width: none;
    flex: 0 1 260px;
    min-width: 180px;
    padding: 0;
}

.table-tools .search.sm input {
    width: 100%;
    height: 34px;
    padding: 0 12px;
}

.table-tools .search.sm .icon+input {
    padding-left: 34px;
}

.table-tools .select {
    flex: 0 0 auto;
}

@media (max-width: 720px) {
    .table-tools {
        width: 100%;
        margin-left: 0;
    }

    .table-tools .search.sm {
        flex: 1 1 100%;
    }
}

/* CSP fix: small spacing utility classes replacing inline style="" attributes */
.mt-14 {
    margin-top: 14px;
}

.mt-10-center {
    margin-top: 10px;
    text-align: center;
}

.mt-22 {
    margin-top: 22px;
}

.mt-24 {
    margin-top: 24px;
}

.mb-14 {
    margin-bottom: 14px;
}

.fs-15-5 {
    font-size: 15.5px;
}

.fs-19 {
    font-size: 19px;
}

.table-summary-note {
    font-size: 12.5px;
    color: var(--fg-muted);
    margin-top: 3px;
}

.legend i.c-brand {
    background: var(--brand);
}

.legend i.c-brand3 {
    background: var(--brand-3);
}

/* CSP fix (organizations page): more small utility classes replacing
   inline style="" attributes and JS .style.* mutations. */
.ml-auto {
    margin-left: auto;
}

.hidden {
    display: none;
}

.w-full {
    width: 100%;
}

/* Utility classes — added to remove inline style="" attributes, which
   Content-Security-Policy's style-src 'self' blocks outright. Composable
   single-purpose classes rather than one bespoke class per element, so
   future pages can reuse them instead of reaching for inline styles. */
.text-muted {
    color: var(--fg-muted);
}

.text-danger {
    color: var(--danger-fg);
}

.border-danger {
    border-color: var(--danger-bd);
}

.tile-full {
    grid-column: 1 / -1;
}

.text-center {
    text-align: center;
}

.opacity-60 {
    opacity: .6;
}

.mb-6 {
    margin-bottom: 6px;
}

.mb-8 {
    margin-bottom: 8px;
}

.mb-16 {
    margin-bottom: 16px;
}

.mt-10 {
    margin-top: 10px;
}

.mt-14 {
    margin-top: 14px;
}

.mt-18 {
    margin-top: 18px;
}

.mt-20 {
    margin-top: 20px;
}

.mt-16 {
    margin-top: 16px;
}

.mt-22 {
    margin-top: 22px;
}

.mt-3 {
    margin-top: 3px;
}

.text-right {
    text-align: right;
}

.text-dim {
    color: var(--fg-dim);
}

.fs-12 {
    font-size: 12px;
}

.fs-115 {
    font-size: 11.5px;
}

.fs-125 {
    font-size: 12.5px;
}

.fs-155 {
    font-size: 15.5px;
}

.lh-155 {
    line-height: 1.55;
}

.min-w-720 {
    min-width: 720px;
}

.p-20 {
    padding: 20px;
}

.ml-auto {
    margin-left: auto;
}

.d-flex {
    display: flex;
}

.flex-row {
    flex-direction: row;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.justify-end {
    justify-content: flex-end;
}

.gap-10 {
    gap: 10px;
}

.gap-12 {
    gap: 12px;
}

.fs-135 {
    font-size: 13.5px;
}

.text-normal {
    color: var(--fg);
}

.text-brand {
    color: var(--brand);
}

.modal-w-520 {
    max-width: 520px;
}

.modal-w-560 {
    max-width: 560px;
}

.no-bullets {
    list-style: none;
    margin-left: -24px;
}

.toggle-list-scroll {
    max-height: 340px;
    overflow: auto;
}

.input-w-120 {
    width: 120px;
    height: 34px;
    border-radius: 9px;
    border: 1px solid var(--line);
    background: var(--s-btn);
    color: var(--fg);
    padding: 0 10px;
}

.input-w-160 {
    width: 160px;
    height: 34px;
    border-radius: 9px;
    border: 1px solid var(--line);
    background: var(--s-btn);
    color: var(--fg);
    padding: 0 10px;
}

/* Native <progress> replacement for the plan-performance meter bar — its
   fill width is a genuinely per-row dynamic value (not a fixed design
   constant like the utilities above), and there is no CSP-compliant way
   to set that via inline style at all (style-src blocks any runtime
   .style. mutation, and a fixed hash can't match a value that changes
   per row). A native <progress value="X" max="100"> needs no style
   attribute — the browser renders the fill from the value attribute
   itself, and the two vendor pseudo-elements below are normal external
   CSS, not inline styles. */
.meter-native {
    -webkit-appearance: none;
    appearance: none;
    display: block;
    width: 100%;
    height: 8px;
    border-radius: 99px;
    overflow: hidden;
    border: 1px solid var(--line-soft);
    background: var(--s-2);
}

.meter-native::-webkit-progress-bar {
    background: var(--s-2);
    border-radius: 99px;
}

.meter-native::-webkit-progress-value {
    background: var(--grad-brand);
    border-radius: 99px;
}

.meter-native::-moz-progress-bar {
    background: var(--grad-brand);
    border-radius: 99px;
}

.drawer-title {
    display: block;
    font-size: 16px;
}

.drawer-sub {
    font-size: 12px;
    color: var(--fg-muted);
}

.table-empty-cell {
    text-align: center;
    color: var(--fg-muted);
    padding: 24px;
}

.table-error-cell {
    text-align: center;
    color: var(--danger-fg, #f66);
}

/* Discrete 0-100% width steps for JS-driven bar fills (entitlement usage,
   subscriptions-by-plan). Percentages are rounded to the nearest whole
   number and applied as a w-N class instead of an inline style, since
   the style-src CSP directive has no unsafe-inline/unsafe-hashes and
   blocks the style attribute regardless of whether it is set from HTML
   or from JS. */
.w-0 {
    width: 0%;
}

.w-1 {
    width: 1%;
}

.w-2 {
    width: 2%;
}

.w-3 {
    width: 3%;
}

.w-4 {
    width: 4%;
}

.w-5 {
    width: 5%;
}

.w-6 {
    width: 6%;
}

.w-7 {
    width: 7%;
}

.w-8 {
    width: 8%;
}

.w-9 {
    width: 9%;
}

.w-10 {
    width: 10%;
}

.w-11 {
    width: 11%;
}

.w-12 {
    width: 12%;
}

.w-13 {
    width: 13%;
}

.w-14 {
    width: 14%;
}

.w-15 {
    width: 15%;
}

.w-16 {
    width: 16%;
}

.w-17 {
    width: 17%;
}

.w-18 {
    width: 18%;
}

.w-19 {
    width: 19%;
}

.w-20 {
    width: 20%;
}

.w-21 {
    width: 21%;
}

.w-22 {
    width: 22%;
}

.w-23 {
    width: 23%;
}

.w-24 {
    width: 24%;
}

.w-25 {
    width: 25%;
}

.w-26 {
    width: 26%;
}

.w-27 {
    width: 27%;
}

.w-28 {
    width: 28%;
}

.w-29 {
    width: 29%;
}

.w-30 {
    width: 30%;
}

.w-31 {
    width: 31%;
}

.w-32 {
    width: 32%;
}

.w-33 {
    width: 33%;
}

.w-34 {
    width: 34%;
}

.w-35 {
    width: 35%;
}

.w-36 {
    width: 36%;
}

.w-37 {
    width: 37%;
}

.w-38 {
    width: 38%;
}

.w-39 {
    width: 39%;
}

.w-40 {
    width: 40%;
}

.w-41 {
    width: 41%;
}

.w-42 {
    width: 42%;
}

.w-43 {
    width: 43%;
}

.w-44 {
    width: 44%;
}

.w-45 {
    width: 45%;
}

.w-46 {
    width: 46%;
}

.w-47 {
    width: 47%;
}

.w-48 {
    width: 48%;
}

.w-49 {
    width: 49%;
}

.w-50 {
    width: 50%;
}

.w-51 {
    width: 51%;
}

.w-52 {
    width: 52%;
}

.w-53 {
    width: 53%;
}

.w-54 {
    width: 54%;
}

.w-55 {
    width: 55%;
}

.w-56 {
    width: 56%;
}

.w-57 {
    width: 57%;
}

.w-58 {
    width: 58%;
}

.w-59 {
    width: 59%;
}

.w-60 {
    width: 60%;
}

.w-61 {
    width: 61%;
}

.w-62 {
    width: 62%;
}

.w-63 {
    width: 63%;
}

.w-64 {
    width: 64%;
}

.w-65 {
    width: 65%;
}

.w-66 {
    width: 66%;
}

.w-67 {
    width: 67%;
}

.w-68 {
    width: 68%;
}

.w-69 {
    width: 69%;
}

.w-70 {
    width: 70%;
}

.w-71 {
    width: 71%;
}

.w-72 {
    width: 72%;
}

.w-73 {
    width: 73%;
}

.w-74 {
    width: 74%;
}

.w-75 {
    width: 75%;
}

.w-76 {
    width: 76%;
}

.w-77 {
    width: 77%;
}

.w-78 {
    width: 78%;
}

.w-79 {
    width: 79%;
}

.w-80 {
    width: 80%;
}

.w-81 {
    width: 81%;
}

.w-82 {
    width: 82%;
}

.w-83 {
    width: 83%;
}

.w-84 {
    width: 84%;
}

.w-85 {
    width: 85%;
}

.w-86 {
    width: 86%;
}

.w-87 {
    width: 87%;
}

.w-88 {
    width: 88%;
}

.w-89 {
    width: 89%;
}

.w-90 {
    width: 90%;
}

.w-91 {
    width: 91%;
}

.w-92 {
    width: 92%;
}

.w-93 {
    width: 93%;
}

.w-94 {
    width: 94%;
}

.w-95 {
    width: 95%;
}

.w-96 {
    width: 96%;
}

.w-97 {
    width: 97%;
}

.w-98 {
    width: 98%;
}

.w-99 {
    width: 99%;
}

.w-100 {
    width: 100%;
}

/* ═══════════════════════════════════════════════════════════════════════
   LIGHT-THEME CORRECTIONS
   Everything below fixes a component that renders wrong (or unreadably)
   when data-theme="light". None of it changes the dark theme.
   ═══════════════════════════════════════════════════════════════════════ */

/* ---------- KPI accent colours ----------
   .kpi.k2/.k3/.k4 set --kpi-color to a dark-mode neon (#2ea8ff, #9c8dff,
   #ffb547). That value is used as the ICON FOREGROUND (.kpi-ico) over
   --s-ico, which in light mode is #f2f7fd — near white. Measured contrast
   there is 2.6:1, 2.7:1 and 1.8:1: the KPI icons were all but invisible on
   every light-theme page. Same hues, darkened to sit on a white card; the
   tints and bars are re-cast for the lighter surface too. */
[data-theme="light"] .kpi {
    --kpi-tint: rgba(15, 164, 124, .16);
}

[data-theme="light"] .kpi.k2 {
    --kpi-tint: rgba(29, 132, 224, .16);
    --kpi-color: #1565b8;
    --kpi-bar: linear-gradient(180deg, #1d84e0, #6a56f0);
}

[data-theme="light"] .kpi.k3 {
    --kpi-tint: rgba(106, 86, 240, .16);
    --kpi-color: #5b46d6;
    --kpi-bar: linear-gradient(180deg, #6a56f0, #e0455a);
}

[data-theme="light"] .kpi.k4 {
    --kpi-tint: rgba(217, 132, 20, .16);
    --kpi-color: #a35c06;
    --kpi-bar: linear-gradient(180deg, #d98414, #e0455a);
}

/* ---------- Glows ----------
   A neon bloom designed to sit on a near-black surface reads as a muddy
   coloured halo on white. Softened, not removed, so the light theme keeps
   the same depth cues at a believable strength. */
[data-theme="light"] .btn-primary {
    box-shadow: 0 8px 18px -12px rgba(29, 132, 224, .55);
}

[data-theme="light"] .btn-primary:hover {
    box-shadow: 0 10px 22px -12px rgba(29, 132, 224, .65);
}

[data-theme="light"] .brand-mark,
[data-theme="light"] .avatar {
    box-shadow: 0 8px 18px -12px rgba(15, 164, 124, .55);
}

[data-theme="light"] .bar-fill,
[data-theme="light"] .bar-fill.b2,
[data-theme="light"] .bar-fill.b3,
[data-theme="light"] .bar-fill.b4 {
    box-shadow: none;
}

/* ---------- Focus rings ----------
   rgba(46,168,255,…) is the dark-mode blue; at 12–16% alpha it all but
   vanishes against a white input, so a keyboard user got no visible focus
   state on any form control in light mode. */
[data-theme="light"] .control input:focus,
[data-theme="light"] .search input:focus,
[data-theme="light"] .field textarea:focus,
[data-theme="light"] .field input:focus,
[data-theme="light"] .field select:focus {
    box-shadow: 0 0 0 3px rgba(29, 132, 224, .18);
}

/* ═══════════════════════════════════════════════════════════════════════
   GROWTH CHART (index.html, system-health.html)
   An inline SVG cannot read var(--token) from a presentation attribute,
   so index.html hardcoded stroke="#38e0b0" / stroke="#7c6bff" and
   <g stroke="#1b2740"> for the gridlines. #1b2740 is a near-black navy:
   on the light theme's white card the chart was drawn over a hard black
   grid. These classes replace those attributes so the chart tracks the
   theme like everything else. stop-color/stop-opacity are real CSS
   properties, so the gradient fills re-tint too.
   ═══════════════════════════════════════════════════════════════════════ */
.ch-gridlines {
    stroke: var(--line);
}

.ch-line-1 {
    stroke: var(--brand);
}

.ch-line-2 {
    stroke: var(--brand-3);
}

.ch-stop-1-from {
    stop-color: var(--brand);
    stop-opacity: .38;
}

.ch-stop-1-to {
    stop-color: var(--brand);
    stop-opacity: 0;
}

.ch-stop-2-from {
    stop-color: var(--brand-3);
    stop-opacity: .30;
}

.ch-stop-2-to {
    stop-color: var(--brand-3);
    stop-opacity: 0;
}


/* ══════ AUDIT LOGS (page-scoped) ══════ */

/* Cornerstone Hub — Audit Logs page
   Deploy as /dash/css/audit-logs.css (loaded after styles.css).

   One rule set only. styles.css has no block-level code/<pre> style —
   the single monospace rule in it is `.table-wrap td code`, an inline
   snippet treatment — and the audit drawer has to show an arbitrary,
   arbitrarily deep `details` payload pretty-printed. Left unstyled, a
   <pre> keeps `white-space: pre` and pushes the drawer sideways on any
   long value (a URL, a stack trace, a base64 blob).

   Every value is a design-system token, so it tracks both themes; no
   colour is hardcoded. */

.json-dump {
    margin: 0;
    padding: 12px 14px;
    max-height: 340px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--s-deep);
    color: var(--fg-soft);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    line-height: 1.55;
    /* pre-wrap + anywhere: keep the JSON's own indentation, but never let
       one long unbroken value force a horizontal scroll on the drawer. */
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}


/* ══════ SYSTEM HEALTH (page-scoped) ══════ */

/* Cornerstone Hub — System Health page
   Only what styles.css does not already provide: SVG chart geometry
   (strokes, fills, gradient stops, gridlines) and the HTML month axis
   under the chart.

   Every colour here is a design-system token. Nothing is hardcoded, and
   nothing is set as an SVG presentation attribute in the markup, so the
   chart re-tints with [data-theme] exactly like the rest of the console.
   index.html's chart does the opposite (stroke="#38e0b0",
   <g stroke="#1b2740">, <stop stop-color="…">) and is unreadable in light
   mode as a result — this file exists to not repeat that. */

/* ---- Growth chart geometry ---- */
.sh-chart {
    overflow: visible;
}

.sh-gridlines line {
    stroke: var(--line);
    stroke-width: 1;
}

.sh-line {
    fill: none;
    stroke-width: 2.5;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.sh-line-orgs {
    stroke: var(--brand);
}

.sh-line-upgrades {
    stroke: var(--brand-3);
    stroke-dasharray: 6 5;
}

.sh-area {
    stroke: none;
}

.sh-area-orgs {
    fill: url(#sh-area-orgs);
}

.sh-area-upgrades {
    fill: url(#sh-area-upgrades);
}

/* stop-color / stop-opacity are genuine CSS properties, so the gradients
   are token-driven too rather than frozen into stop-color="" attributes. */
.sh-stop-orgs-top {
    stop-color: var(--brand);
    stop-opacity: .34;
}

.sh-stop-orgs-bottom {
    stop-color: var(--brand);
    stop-opacity: 0;
}

.sh-stop-upgrades-top {
    stop-color: var(--brand-3);
    stop-opacity: .26;
}

.sh-stop-upgrades-bottom {
    stop-color: var(--brand-3);
    stop-opacity: 0;
}

/* ---- Month labels, rendered as HTML because the SVG above uses
   preserveAspectRatio="none" and would stretch any <text> inside it ---- */
.sh-xaxis {
    display: flex;
    justify-content: space-between;
    gap: 4px;
    margin-top: 6px;
    font-size: 11px;
    color: var(--fg-dim);
}

.sh-xaxis span {
    flex: 1 1 0;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
}

/* Empty / error copy inside a panel that has no table or list to fall back
   on — styles.css only has .empty-state (40px padding, sized for a whole
   card) and .table-empty-cell (a <td>), neither of which fits inline under
   a chart or a bar list. */
.sh-inline-note {
    font-size: 12.5px;
    color: var(--fg-muted);
    padding: 10px 0;
}

.sh-inline-note.is-error {
    color: var(--danger-fg);
}


/* ══════ SUPPORT QUEUE (page-scoped) ══════ */

/* Cornerstone Hub — Support queue page-scoped styles
   Append to /dash/css/styles.css or load after it.

   Everything here exists because styles.css has no equivalent, and every
   colour is a var(--token) so both themes are covered by the same rules:

   - .drawer-wide            styles.css pins .drawer to min(480px,100%); a
                             ticket thread plus a composer is not a 480px
                             object.
   - .page-notice            the only banner style in styles.css is
                             .auth-alert, which is danger-red. "You are
                             read-only" is information, not an error.
   - .thread / .msg / …      there is no message-bubble or conversation
                             component in styles.css at all (.timeline/.tl
                             is a one-line event feed, and has no
                             white-space handling — support message bodies
                             are user-typed multi-line text and MUST keep
                             their line breaks).
   - .msg.is-internal        the whole point of this page. See below.
   - .mode-banner            the composer's current-mode readout.
*/

/* Wider drawer, only on this page. */
.drawer.drawer-wide {
    width: min(720px, 100%);
}

/* Informational page banner (styles.css only has the red .auth-alert). */
.page-notice {
    margin-bottom: 18px;
    padding: 11px 15px;
    border-radius: var(--radius-sm);
    font-size: 13.2px;
    line-height: 1.55;
    color: var(--info-fg);
    border: 1px solid var(--info-bd);
    background: var(--info-bg);
}

/* ── Conversation thread ─────────────────────────────────────────── */

.thread {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 10px;
}

.msg {
    border: 1px solid var(--line-soft);
    border-left: 3px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--s-row);
    padding: 12px 14px;
}

/* A message from the clinic reads as "theirs": brand-2 spine, flatter fill. */
.msg.is-customer {
    border-left-color: var(--brand-2);
    background: var(--s-2);
}

/* A normal staff reply reads as "ours". */
.msg.is-staff {
    border-left-color: var(--brand);
}

/*
   INTERNAL NOTE — the one treatment on this page that must never be
   mistaken for a customer-visible reply.

   Distinguished four ways, on purpose, because any one of them alone can
   fail (colour fails for colour-blind users and in high-contrast modes;
   a border fails in a screenshot cropped past it):
     1. warn-tinted background + warn spine,
     2. a DASHED spine and outline — a shape difference, not a hue
        difference, so it survives greyscale,
     3. the literal words "Internal note — not visible to the clinic",
        rendered as text in the header of every single note (see
        support.js; it is not a ::before, so it is real text for screen
        readers and for copy/paste),
     4. the author line is prefixed "Internal note by …".
*/
.msg.is-internal {
    border-style: dashed;
    border-color: var(--warn-bd);
    border-left: 3px dashed var(--warn);
    background: var(--warn-bg);
}

.msg-head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 7px;
}

.msg-author {
    font-size: 13px;
    font-weight: 600;
    color: var(--fg);
}

.msg-time {
    font-size: 11.5px;
    color: var(--fg-dim);
    margin-left: auto;
}

/* User-authored text. pre-wrap keeps the line breaks the clinic typed;
   overflow-wrap stops a pasted 400-character URL widening the drawer. */
.msg-body {
    margin: 0;
    font-size: 13.4px;
    line-height: 1.6;
    color: var(--fg-soft);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.msg.is-internal .msg-body {
    color: var(--warn-fg);
}

/* ── Composer mode banner ────────────────────────────────────────── */

.mode-banner {
    display: block;
    padding: 10px 13px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--s-row);
}

.mode-banner b {
    display: block;
    font-size: 13px;
    font-weight: 700;
}

.mode-banner span {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    line-height: 1.5;
}

.mode-banner.is-public {
    border-color: var(--info-bd);
    background: var(--info-bg);
}

.mode-banner.is-public b {
    color: var(--info-fg);
}

.mode-banner.is-public span {
    color: var(--fg-muted);
}

/* Internal mode is the "quiet, private" mode — matched to the note
   treatment above so the composer looks like what it will produce. */
.mode-banner.is-internal {
    border-style: dashed;
    border-color: var(--warn-bd);
    background: var(--warn-bg);
}

.mode-banner.is-internal b,
.mode-banner.is-internal span {
    color: var(--warn-fg);
}

/* And the textarea itself picks up the same dashed-warn identity, so the
   box you are typing into looks different from the one that emails a
   clinic — not just the label above it. */
.field textarea.is-internal {
    border-style: dashed;
    border-color: var(--warn);
    background: var(--warn-bg);
    color: var(--warn-fg);
}

.field textarea.is-internal:focus {
    border-color: var(--warn);
    box-shadow: none;
    outline: 2px solid var(--warn);
    outline-offset: 1px;
}
