/* Strontium Licensing — admin UI
   Modern, fast, dependency-free. Palette matched to strontiumhex.com:
   navy --accent #10256a (brand/primary) + orange --accent-2 #ff6b35 (action).
   Themes: light / dark / auto via [data-theme]. Density via [data-density]. */

:root {
    --bg: #f4f6f9;
    --surface: #ffffff;
    --surface-2: #f1f3f6;
    --surface-3: #e8ebf0;
    --border: #e6e8ee;
    --border-strong: #d6dae2;
    --ink: #15203a;
    --ink-2: #3a4458;
    --muted: #5f6675;
    --accent: #ff6b35;
    --accent-2: #e85520;
    --accent-soft: rgba(255, 107, 53, .12);
    --accent-ring: rgba(255, 107, 53, .32);
    --coral: #fc5752;
    --brand-navy: #10256a;
    --brand-navy-2: #0b1a50;
    --peach: #f7c59f;
    --ok: #0a7d44;
    --ok-soft: #e2f6ea;
    --warn: #9a6700;
    --warn-soft: #fbeecb;
    --bad: #c81e3a;
    --bad-soft: #fce8ec;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .05);
    --shadow: 0 4px 14px -4px rgba(16, 24, 40, .12), 0 2px 6px -2px rgba(16, 24, 40, .07);
    --shadow-lg: 0 24px 48px -12px rgba(16, 24, 40, .22);
    --r: 12px;
    --r-sm: 9px;
    --r-lg: 18px;
    --r-pill: 999px;
    --sidebar-w: 248px;
    /* density tokens (comfortable defaults) */
    --fs: 14px;
    --content-py: 22px;
    --content-px: 26px;
    --panel-pad: 18px;
    --card-pad: 16px;
    --cell-py: 12px;
    --gap: 14px;
    --grid-gap: 16px;
    --ctl-h: 40px;
    --btn-h: 38px;
    --nav-py: 9px;
    --topbar-py: 14px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Inter, Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    color-scheme: light;
}

[data-theme="dark"] {
    --bg: #0d1015;
    --surface: #161a22;
    --surface-2: #1c212b;
    --surface-3: #232934;
    --border: #262c38;
    --border-strong: #323948;
    --ink: #e9edf4;
    --ink-2: #c4ccda;
    --muted: #919bad;
    --accent: #ff8554;
    --accent-2: #ff6b35;
    --accent-soft: rgba(255, 133, 84, .16);
    --accent-ring: rgba(255, 133, 84, .36);
    --coral: #ff6b66;
    --brand-navy: #16306f;
    --brand-navy-2: #0e2156;
    --peach: #f7c59f;
    --ok: #3ddc8a;
    --ok-soft: rgba(61, 220, 138, .14);
    --warn: #f2b950;
    --warn-soft: rgba(242, 185, 80, .14);
    --bad: #ff7a8a;
    --bad-soft: rgba(255, 122, 138, .14);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 6px 20px -6px rgba(0, 0, 0, .55);
    --shadow-lg: 0 30px 60px -15px rgba(0, 0, 0, .7);
    color-scheme: dark;
}

/* Compact density overrides */
[data-density="compact"] {
    --fs: 13px;
    --content-py: 14px;
    --content-px: 18px;
    --panel-pad: 13px;
    --card-pad: 13px;
    --cell-py: 7px;
    --gap: 10px;
    --grid-gap: 12px;
    --ctl-h: 34px;
    --btn-h: 32px;
    --nav-py: 7px;
    --topbar-py: 10px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    font-size: var(--fs);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: calc(var(--fs) + 2px); margin-bottom: 14px; }
small { color: var(--muted); font-size: 12px; }
::selection { background: var(--accent-soft); }

code {
    font-family: var(--mono);
    font-size: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    padding: 1px 6px;
    border-radius: 6px;
    color: var(--ink-2);
}

* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }

/* ---------------------------------------------------------------- Sidebar */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    background: linear-gradient(185deg, var(--brand-navy) 0%, var(--brand-navy-2) 100%);
    border-right: 1px solid rgba(255, 255, 255, .08);
    padding: 18px 14px;
    z-index: 40;
}

.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 7px; padding: 4px 6px 18px; }
.logo { display: block; object-fit: contain; }
.brand .wordmark { width: 184px; max-width: 100%; height: auto; }
.brand-tag { font-size: 10px; font-weight: 700; letter-spacing: .24em; text-transform: uppercase; color: rgba(255, 255, 255, .5); padding-left: 3px; }

.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; margin: 4px -4px; padding: 0 4px; }
.nav-group-label {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #6c7488;
    padding: 14px 11px 6px;
    user-select: none;
}
.nav-group-label:first-child { padding-top: 6px; }
.nav-link {
    position: relative;
    display: flex; align-items: center; gap: 11px;
    padding: var(--nav-py) 11px;
    border-radius: var(--r-sm);
    color: #aeb6c6; font-weight: 550; font-size: 13.5px;
    transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(255, 255, 255, .06); color: #eef1f6; }
.nav-link .nav-ic { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav-link.active { background: linear-gradient(90deg, var(--accent-soft), rgba(255, 107, 53, .02)); color: #fff; }
.nav-link.active .nav-ic { opacity: 1; color: var(--accent); }
.nav-link.active::before {
    content: ""; position: absolute; left: -4px; top: 50%;
    transform: translateY(-50%); width: 3px; height: 20px;
    border-radius: 0 3px 3px 0; background: var(--accent); box-shadow: 0 0 12px var(--accent);
}

.side-foot { border-top: 1px solid rgba(255, 255, 255, .07); padding-top: 12px; margin-top: 6px; }
.user-row { display: flex; align-items: center; gap: 10px; }
.user-row .user-meta { flex: 1; min-width: 0; line-height: 1.2; }
.user-meta strong { color: #f0f2f6; font-size: 13px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta span { color: #7e8799; font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }

.avatar {
    flex: none; width: 36px; height: 36px;
    border-radius: var(--r-sm); display: grid; place-items: center;
    font-weight: 700; font-size: 13px; color: #fff;
    background: linear-gradient(135deg, #ff6b35 0%, var(--coral) 55%, #f59e0b 135%);
    box-shadow: 0 4px 12px -2px rgba(255, 107, 53, .5);
}
.avatar.sm { width: 28px; height: 28px; font-size: 11px; border-radius: 8px; }

.icon-btn {
    width: 34px; height: 34px; display: grid; place-items: center;
    border-radius: var(--r-sm); border: 1px solid rgba(255, 255, 255, .1);
    background: rgba(255, 255, 255, .04); color: #c4cad6; cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.icon-btn svg { width: 17px; height: 17px; }

/* Appearance: theme + density segmented controls */
.appearance { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 9px; background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .08); }
.seg button {
    min-height: 28px; width: 30px; padding: 0; border: 0; background: transparent;
    color: #aeb6c6; border-radius: 6px; display: grid; place-items: center; cursor: pointer;
    transition: background .14s, color .14s;
}
.seg button:hover { background: rgba(255, 255, 255, .09); color: #fff; }
.seg button.active { background: var(--accent); color: #fff; box-shadow: 0 2px 7px -1px rgba(255, 107, 53, .55); }
.seg button svg { width: 15px; height: 15px; }

/* ---------------------------------------------------------------- Main + topbar */
.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; gap: 14px;
    padding: var(--topbar-py) var(--content-px);
    background: var(--surface);
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    -webkit-backdrop-filter: saturate(1.4) blur(10px);
    backdrop-filter: saturate(1.4) blur(10px);
    border-bottom: 1px solid var(--border);
}
.page-title { font-size: 20px; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-chip { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 13px; color: var(--ink-2); }
.user-chip .name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-btn { display: none; border-color: var(--border); background: var(--surface); color: var(--ink-2); }
.menu-btn:hover { background: var(--surface-2); color: var(--ink); }

.content { padding: var(--content-py) var(--content-px) calc(var(--content-py) + 18px); flex: 1; width: 100%; min-width: 0; }

/* ---------------------------------------------------------------- Cards */
.cards { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--gap); margin-bottom: 18px; }
.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
    padding: var(--card-pad); box-shadow: var(--shadow-sm);
    transition: transform .15s, box-shadow .15s, border-color .15s;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.card strong { display: block; font-size: 27px; font-weight: 750; letter-spacing: -.02em; line-height: 1.1; }
.card span { color: var(--muted); font-size: 12.5px; font-weight: 550; margin-top: 3px; display: block; }

/* ---------------------------------------------------------------- Panels + tables */
.panel {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
    padding: var(--panel-pad); margin-bottom: 18px; box-shadow: var(--shadow-sm); overflow-x: auto;
}
.panel > h2 { padding: 0 2px; }
table { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 720px; }
thead th {
    position: sticky; top: 0; background: var(--surface); color: var(--muted);
    font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em;
    text-align: left; padding: 0 12px 10px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody td { padding: var(--cell-py) 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--surface-2); }
td small { display: inline-block; }

/* ---------------------------------------------------------------- Buttons */
button, .button {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    min-height: var(--btn-h); padding: 8px 15px;
    border: 1px solid var(--border-strong); border-radius: var(--r-sm);
    background: var(--surface); color: var(--ink);
    font: inherit; font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap;
    transition: background .14s, border-color .14s, transform .06s, box-shadow .14s, color .14s;
}
button:hover, .button:hover { background: var(--surface-2); border-color: var(--muted); }
button:active, .button:active { transform: translateY(1px); }
button:focus-visible, .button:focus-visible, a:focus-visible, .seg button:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }

.primary, button.primary, .button.primary {
    color: #fff; border-color: transparent;
    background: linear-gradient(180deg, #ff6a35, var(--accent));
    box-shadow: 0 4px 14px -4px rgba(255, 107, 53, .55);
}
.primary:hover, button.primary:hover, .button.primary:hover { background: linear-gradient(180deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff; }

button.danger, .button.danger { color: var(--bad); background: transparent; border-color: color-mix(in srgb, var(--bad) 35%, var(--border)); }
button.danger:hover, .button.danger:hover { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }

.row-actions { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.row-actions form { display: inline; margin: 0; }
.row-actions button, .row-actions .button, .row-actions a { min-height: 32px; padding: 5px 11px; font-size: 12.5px; }
.row-actions a:not(.button) { color: var(--accent); font-weight: 600; padding: 5px 4px; }
.actions { display: flex; gap: 10px; align-items: center; }

/* ---------------------------------------------------------------- Forms */
label { display: grid; gap: 6px; font-weight: 600; font-size: 13px; color: var(--ink-2); }
input, select, textarea {
    width: 100%; border: 1px solid var(--border-strong); border-radius: var(--r-sm);
    background: var(--surface); color: var(--ink); min-height: var(--ctl-h); padding: 9px 12px;
    font: inherit; font-size: 13.5px; transition: border-color .14s, box-shadow .14s, background .14s;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
textarea { min-height: 92px; resize: vertical; line-height: 1.5; }
input[type="file"] { padding: 7px 10px; background: var(--surface-2); cursor: pointer; }
input[type="file"]::file-selector-button { margin-right: 10px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); padding: 6px 10px; border-radius: 7px; cursor: pointer; font: inherit; font-weight: 600; font-size: 12px; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23687085' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--grid-gap); }
.wide { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 9px; font-weight: 550; color: var(--ink-2); }
.check input { width: 18px; height: 18px; min-height: auto; accent-color: var(--accent); cursor: pointer; }
.check.inline { display: inline-flex; font-weight: 400; margin-left: 10px; color: var(--muted); font-size: 12px; }

.toolbar { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 16px; align-items: center; flex-wrap: wrap; }
.toolbar form, .inline-form { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.toolbar input, .inline-form input { min-width: 240px; }
.inline-form { background: var(--surface); }

.hint { color: var(--muted); font-weight: 400; font-size: 12.5px; margin: 6px 0 0; }
.hint code { font-size: 11.5px; }

/* ---------------------------------------------------------------- Pills */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: var(--r-pill); font-size: 11.5px; font-weight: 650; line-height: 1.5; border: 1px solid transparent; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--ok); background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 22%, transparent); }
.pill.bad { color: var(--bad); background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 22%, transparent); }
.pill.warn { color: var(--warn); background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 22%, transparent); }

/* ---------------------------------------------------------------- Health panel */
.health.bad { border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); background: var(--bad-soft); }
.health.warn { border-color: color-mix(in srgb, var(--warn) 40%, var(--border)); background: var(--warn-soft); }
.health h2 { display: flex; align-items: center; gap: 12px; }
.health-meta { display: flex; flex-wrap: wrap; gap: 10px 26px; color: var(--muted); font-size: 13px; }
.health-meta strong { color: var(--ink); }

/* Dashboard analytics */
.analytics { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); margin-bottom: 18px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); margin-bottom: 18px; }
.chart { padding-bottom: 10px; }
.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.chart-head h2 { margin: 0; }
.chart-total { font-size: 22px; font-weight: 750; letter-spacing: -.02em; }
.chart-total small { color: var(--muted); font-size: 12px; font-weight: 550; }
.spark { width: 100%; height: 76px; display: block; }
.barrow { margin-bottom: 12px; }
.barlabel { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.barlabel span { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barlabel b { color: var(--ink); }
.bartrack { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.barfill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #ff8a4d, var(--accent)); min-width: 3px; }
@media (max-width: 900px) { .analytics, .two-col { grid-template-columns: 1fr; } }

/* 2FA enrollment + recovery codes */
.recovery-codes { display: grid; grid-template-columns: repeat(2, max-content); gap: 8px 16px; margin: 4px 0 8px; }
.recovery-codes code { font-size: 13.5px; letter-spacing: .04em; padding: 5px 10px; }
.totp-setup { display: flex; flex-wrap: wrap; gap: 22px; align-items: flex-end; padding: 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); }
.totp-setup .hint { margin: 0 0 4px; display: block; }
.totp-key { font-size: 15px; letter-spacing: .08em; font-weight: 600; }

/* ---------------------------------------------------------------- Notice / flash */
.notice {
    display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: var(--r-sm);
    margin-bottom: 18px; font-weight: 550;
    border: 1px solid color-mix(in srgb, var(--ok) 28%, transparent); background: var(--ok-soft); color: var(--ok);
    animation: pop .25s ease;
}
.notice.danger { border-color: color-mix(in srgb, var(--bad) 28%, transparent); background: var(--bad-soft); color: var(--bad); }
.notice::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
@keyframes pop { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- Mobile drawer */
.app-overlay { position: fixed; inset: 0; background: rgba(8, 10, 14, .5); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 35; }
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); transition: transform .25s ease; box-shadow: var(--shadow-lg); }
    body.nav-open .sidebar { transform: none; }
    body.nav-open .app-overlay { opacity: 1; pointer-events: auto; }
    .main { margin-left: 0; }
    .menu-btn { display: grid; }
    .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-grid { grid-template-columns: 1fr; }
    .toolbar input, .inline-form input { min-width: 0; flex: 1; }
}
@media (max-width: 520px) {
    .cards { grid-template-columns: 1fr; }
    .page-title { font-size: 17px; }
    .user-chip .name { display: none; }
}

/* ---------------------------------------------------------------- Auth / login */
.auth-main {
    min-height: 100vh; display: grid; place-items: center; padding: 24px;
    background:
        radial-gradient(900px 520px at 12% -10%, rgba(255, 107, 53, .16), transparent 60%),
        radial-gradient(820px 520px at 100% 110%, rgba(16, 37, 106, .18), transparent 55%),
        var(--bg);
}
.login-box { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 30px 28px; box-shadow: var(--shadow-lg); }
.login-brand { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; margin-bottom: 22px; }
.login-brand .wordmark { width: 234px; max-width: 100%; height: auto; }
.login-brand h1 { font-size: 21px; }
.login-brand p { margin: 0; color: var(--muted); font-size: 13px; }
.login-box form { display: grid; gap: 15px; }
.login-box .primary { width: 100%; min-height: 44px; margin-top: 4px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
