/* =========================================================================
   NITS Web Service - shared theme
   Light/dark via [data-theme] on <html> (set by theme.js, falls back to the OS setting).
   ========================================================================= */

:root {
    --bg: #f4f6fb;
    --bg-accent: radial-gradient(1200px 600px at 100% -10%, rgba(37, 99, 235, .10), transparent 60%),
                 radial-gradient(900px 500px at -10% 110%, rgba(124, 58, 237, .08), transparent 60%);
    --surface: #ffffff;
    --surface-2: #f1f4fa;
    --surface-glass: rgba(255, 255, 255, .72);
    --border: #e2e7f1;
    --border-strong: #cfd7e6;
    --text: #0b1b3a;
    --text-2: #33415f;
    --muted: #64718d;
    --primary: #2563eb;
    --primary-hover: #1d4fd8;
    --primary-soft: #e8efff;
    --accent: #7c3aed;
    --gradient: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
    --success: #15803d;
    --success-soft: #e6f6ec;
    --warning: #b45309;
    --warning-soft: #fdf1e1;
    --danger: #dc2626;
    --danger-soft: #fdeaea;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
    --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 8px 24px -12px rgba(16, 24, 40, .14);
    --shadow-lg: 0 24px 60px -24px rgba(16, 24, 40, .28);
    --ring: 0 0 0 4px rgba(37, 99, 235, .18);
    --radius-sm: 8px;
    --radius: 14px;
    --radius-lg: 20px;
    --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace;
    --ease: cubic-bezier(.2, .8, .2, 1);
    --header-h: 64px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #070b17;
        --bg-accent: radial-gradient(1200px 600px at 100% -10%, rgba(59, 130, 246, .16), transparent 60%),
                     radial-gradient(900px 500px at -10% 110%, rgba(139, 92, 246, .14), transparent 60%);
        --surface: #0f1629;
        --surface-2: #151e36;
        --surface-glass: rgba(15, 22, 41, .72);
        --border: #1f2a47;
        --border-strong: #2c3a60;
        --text: #e7ecf8;
        --text-2: #c3cce2;
        --muted: #8e9bba;
        --primary: #5b8cff;
        --primary-hover: #7aa2ff;
        --primary-soft: rgba(91, 140, 255, .14);
        --accent: #a78bfa;
        --gradient: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
        --success: #4ade80;
        --success-soft: rgba(74, 222, 128, .12);
        --warning: #fbbf24;
        --warning-soft: rgba(251, 191, 36, .12);
        --danger: #f87171;
        --danger-soft: rgba(248, 113, 113, .12);
        --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px -16px rgba(0, 0, 0, .6);
        --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, .7);
        --ring: 0 0 0 4px rgba(91, 140, 255, .25);
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg: #070b17;
    --bg-accent: radial-gradient(1200px 600px at 100% -10%, rgba(59, 130, 246, .16), transparent 60%),
                 radial-gradient(900px 500px at -10% 110%, rgba(139, 92, 246, .14), transparent 60%);
    --surface: #0f1629;
    --surface-2: #151e36;
    --surface-glass: rgba(15, 22, 41, .72);
    --border: #1f2a47;
    --border-strong: #2c3a60;
    --text: #e7ecf8;
    --text-2: #c3cce2;
    --muted: #8e9bba;
    --primary: #5b8cff;
    --primary-hover: #7aa2ff;
    --primary-soft: rgba(91, 140, 255, .14);
    --accent: #a78bfa;
    --gradient: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    --success: #4ade80;
    --success-soft: rgba(74, 222, 128, .12);
    --warning: #fbbf24;
    --warning-soft: rgba(251, 191, 36, .12);
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, .12);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px -16px rgba(0, 0, 0, .6);
    --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, .7);
    --ring: 0 0 0 4px rgba(91, 140, 255, .25);
    color-scheme: dark;
}

/* Smooth cross-page navigation in browsers that support it */
@view-transition { navigation: auto; }

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg-accent), var(--bg);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
    transition: background-color .3s var(--ease), color .3s var(--ease);
}

main { flex: 1; }

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -.02em; color: var(--text); }
h1 { font-size: clamp(1.6rem, 2.4vw, 2.1rem); font-weight: 750; }
h2 { font-size: 1.3rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 650; }
p { margin: 0; }
code, .mono { font-family: var(--mono); font-size: .88em; }

::selection { background: var(--primary-soft); color: var(--text); }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-sm); }

.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 24px; }

.muted { color: var(--muted); }
.text-gradient { background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Animations ---------- */

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: none; }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn {
    from { opacity: 0; transform: scale(.96); }
    to { opacity: 1; transform: none; }
}
@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -40px) scale(1.08); }
    66% { transform: translate(-25px, 20px) scale(.95); }
}
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 currentColor; }
    70% { box-shadow: 0 0 0 8px transparent; }
    100% { box-shadow: 0 0 0 0 transparent; }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shake {
    10%, 90% { transform: translateX(-1px); }
    20%, 80% { transform: translateX(3px); }
    30%, 50%, 70% { transform: translateX(-5px); }
    40%, 60% { transform: translateX(5px); }
}
@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.reveal { animation: fadeUp .65s var(--ease) both; animation-delay: calc(var(--i, 0) * 70ms); }
.reveal-on-scroll { opacity: 0; transform: translateY(18px); transition: opacity .7s var(--ease), transform .7s var(--ease); transition-delay: calc(var(--i, 0) * 70ms); }
.reveal-on-scroll.is-visible { opacity: 1; transform: none; }

/* ---------- Header ---------- */

.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    height: var(--header-h);
    background: var(--surface-glass);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--border);
    animation: fadeIn .4s var(--ease) both;
}
.app-header .container { height: 100%; display: flex; align-items: center; gap: 24px; }

.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 750; letter-spacing: -.02em; font-size: 1.02rem; }
.brand:hover { color: var(--text); }
.brand-mark {
    width: 34px; height: 34px; border-radius: 10px;
    display: grid; place-items: center;
    background: var(--gradient); background-size: 200% 200%;
    color: #fff; font-weight: 800; font-size: 1rem;
    box-shadow: 0 6px 16px -6px rgba(37, 99, 235, .6);
    transition: transform .4s var(--ease);
    animation: gradientShift 8s ease infinite;
}
.brand:hover .brand-mark { transform: rotate(-8deg) scale(1.06); }
.brand small { display: block; font-weight: 500; font-size: .72rem; color: var(--muted); letter-spacing: 0; margin-top: -2px; }

.nav { display: flex; align-items: center; gap: 4px; margin-left: 8px; }
.nav a {
    position: relative;
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 12px;
    border-radius: 10px;
    color: var(--muted);
    font-weight: 550; font-size: .92rem;
    transition: color .2s var(--ease), background-color .2s var(--ease);
}
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a.active { color: var(--primary); background: var(--primary-soft); }
.nav a i { font-size: .9em; }

.header-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.icon-btn {
    width: 38px; height: 38px;
    display: inline-grid; place-items: center;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-2);
    cursor: pointer;
    transition: transform .2s var(--ease), background-color .2s var(--ease), color .2s var(--ease);
}
.icon-btn:hover { color: var(--primary); transform: translateY(-1px); }
.icon-btn:active { transform: scale(.94); }
.theme-toggle .fa-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .fa-sun { display: inline; }
:root[data-theme="dark"] .theme-toggle .fa-moon { display: none; }

.nav-toggle { display: none; }

/* User menu */
.user-menu { position: relative; }
.user-menu-btn {
    display: inline-flex; align-items: center; gap: 10px;
    padding: 4px 10px 4px 4px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font: inherit; font-weight: 600; font-size: .9rem;
    cursor: pointer;
    transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.user-menu-btn:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.user-menu-btn .fa-chevron-down { font-size: .7rem; color: var(--muted); transition: transform .25s var(--ease); }
.user-menu.open .user-menu-btn .fa-chevron-down { transform: rotate(180deg); }
.avatar {
    width: 30px; height: 30px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--gradient); color: #fff;
    font-size: .74rem; font-weight: 700; letter-spacing: .02em;
}
.dropdown {
    position: absolute; right: 0; top: calc(100% + 8px);
    min-width: 230px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    opacity: 0; transform: translateY(-6px) scale(.98); transform-origin: top right;
    pointer-events: none;
    transition: opacity .18s var(--ease), transform .18s var(--ease);
}
.user-menu.open .dropdown { opacity: 1; transform: none; pointer-events: auto; }
.dropdown-head { padding: 10px 12px 8px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.dropdown-head strong { display: block; font-size: .92rem; }
.dropdown-head span { font-size: .8rem; color: var(--muted); }
.dropdown a, .dropdown button {
    width: 100%;
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px;
    border: 0; border-radius: 9px;
    background: none;
    color: var(--text-2);
    font: inherit; font-size: .9rem; text-align: left;
    cursor: pointer;
}
.dropdown a:hover, .dropdown button:hover { background: var(--surface-2); color: var(--text); }
.dropdown .danger:hover { color: var(--danger); background: var(--danger-soft); }
.dropdown i { width: 16px; text-align: center; color: var(--muted); }
.dropdown form { margin: 0; }

/* ---------- Footer ---------- */

.app-footer { border-top: 1px solid var(--border); margin-top: 56px; padding: 22px 0; color: var(--muted); font-size: .85rem; }
.app-footer .container { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.app-footer a { color: var(--muted); }
.app-footer a:hover { color: var(--primary); }
.footer-links { display: flex; gap: 18px; flex-wrap: wrap; }

/* ---------- Page layout ---------- */

.page { padding-top: 32px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head p { color: var(--muted); margin-top: 6px; }
.eyebrow {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: .76rem; font-weight: 650; letter-spacing: .08em; text-transform: uppercase;
    color: var(--primary);
    margin-bottom: 8px;
}
.back-link { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 550; font-size: .9rem; margin-bottom: 10px; transition: gap .2s var(--ease), color .2s var(--ease); }
.back-link:hover { color: var(--primary); gap: 12px; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.sep { border: 0; height: 1px; background: var(--border); margin: 24px 0 16px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- Cards ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 24px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-head p { color: var(--muted); font-size: .9rem; margin-top: 4px; }

.card-link {
    position: relative;
    display: flex; flex-direction: column; gap: 10px;
    color: var(--text);
    overflow: hidden;
    transition: transform .35s var(--ease), box-shadow .35s var(--ease), border-color .35s var(--ease);
}
.card-link::after {
    content: "";
    position: absolute; inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: var(--gradient);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor; mask-composite: exclude;
    opacity: 0;
    transition: opacity .35s var(--ease);
    pointer-events: none;
}
.card-link:hover { color: var(--text); transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.card-link:hover::after { opacity: 1; }
.card-link p { color: var(--muted); font-size: .92rem; }
.card-link .go { margin-top: auto; display: inline-flex; align-items: center; gap: 8px; color: var(--primary); font-weight: 600; font-size: .9rem; }
.card-link .go i { transition: transform .3s var(--ease); }
.card-link:hover .go i { transform: translateX(4px); }

.icon-tile {
    width: 44px; height: 44px; border-radius: 12px;
    display: grid; place-items: center;
    background: var(--primary-soft); color: var(--primary);
    font-size: 1.1rem;
    transition: transform .35s var(--ease);
}
.card-link:hover .icon-tile { transform: scale(1.08) rotate(-4deg); }
.icon-tile.violet { background: rgba(124, 58, 237, .12); color: var(--accent); }
.icon-tile.green { background: var(--success-soft); color: var(--success); }
.icon-tile.amber { background: var(--warning-soft); color: var(--warning); }
.icon-tile.red { background: var(--danger-soft); color: var(--danger); }

/* Stat cards */
.stat { padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.stat-top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: .85rem; font-weight: 550; }
.stat-value { font-size: 2rem; font-weight: 750; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.stat-note { font-size: .8rem; color: var(--muted); }
.stat.warn .stat-value { color: var(--warning); }

/* ---------- Buttons ---------- */

.btn {
    position: relative;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 42px; padding: 0 18px;
    border-radius: 11px;
    border: 1px solid transparent;
    font: inherit; font-weight: 600; font-size: .92rem;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    transition: transform .2s var(--ease), box-shadow .2s var(--ease), background-color .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease);
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--gradient); background-size: 160% 160%; color: #fff; box-shadow: 0 8px 20px -10px rgba(37, 99, 235, .7); }
.btn-primary:hover { color: #fff; transform: translateY(-1px); box-shadow: 0 12px 26px -10px rgba(37, 99, 235, .75); background-position: 100% 50%; }
.btn-primary::before {
    content: "";
    position: absolute; top: 0; left: -120%;
    width: 60%; height: 100%;
    background: linear-gradient(110deg, transparent, rgba(255, 255, 255, .35), transparent);
    transition: left .6s var(--ease);
}
.btn-primary:hover::before { left: 140%; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { color: var(--text); border-color: var(--border-strong); transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; box-shadow: 0 8px 20px -10px rgba(220, 38, 38, .7); }
.btn-danger:hover { color: #fff; transform: translateY(-1px); filter: brightness(1.05); }
.btn-sm { height: 34px; padding: 0 12px; font-size: .85rem; border-radius: 9px; }
.btn-lg { height: 50px; padding: 0 24px; font-size: 1rem; border-radius: 13px; }
.btn-block { width: 100%; }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
    content: "";
    position: absolute;
    width: 18px; height: 18px;
    border: 2px solid rgba(255, 255, 255, .5);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
.btn-secondary.is-loading::after { border-color: var(--border-strong); border-top-color: var(--primary); }

/* ---------- Forms ---------- */

.field { display: flex; flex-direction: column; gap: 7px; }
.field label { font-size: .86rem; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: .8rem; color: var(--muted); }
.input, textarea.input, select.input {
    width: 100%;
    height: 46px;
    padding: 0 14px;
    border-radius: 11px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    font: inherit; font-size: .95rem;
    transition: border-color .2s var(--ease), box-shadow .2s var(--ease), background-color .2s var(--ease);
}
textarea.input { height: auto; min-height: 110px; padding: 12px 14px; resize: vertical; }
.input::placeholder { color: var(--muted); opacity: .8; }
.input:hover { border-color: var(--muted); }
.input:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.input-group { position: relative; }
.input-group > i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; transition: color .2s var(--ease); }
.input-group .input { padding-left: 42px; }
.input-group:focus-within > i { color: var(--primary); }
.input-group .reveal-pass {
    position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
    width: 34px; height: 34px; border: 0; border-radius: 8px;
    background: none; color: var(--muted); cursor: pointer;
}
.input-group .reveal-pass:hover { color: var(--text); background: var(--surface-2); }

.code-input {
    height: 64px;
    text-align: center;
    font-family: var(--mono);
    font-size: 1.9rem; font-weight: 700;
    letter-spacing: .5em;
    padding-left: .5em;
}
.shake { animation: shake .5s var(--ease); }

/* ---------- Alerts & badges ---------- */

.alert {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid transparent;
    font-size: .9rem;
    animation: fadeUp .45s var(--ease) both;
}
.alert i { margin-top: 3px; }
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert-success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 25%, transparent); }
.alert-info { background: var(--primary-soft); color: var(--primary); border-color: color-mix(in srgb, var(--primary) 25%, transparent); }
.alert-warning { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 25%, transparent); }

.badge {
    display: inline-flex; align-items: center; gap: 6px;
    height: 24px; padding: 0 9px;
    border-radius: 999px;
    font-size: .74rem; font-weight: 650; letter-spacing: .02em;
    background: var(--surface-2); color: var(--text-2);
    white-space: nowrap;
}
.badge-blue { background: var(--primary-soft); color: var(--primary); }
.badge-green { background: var(--success-soft); color: var(--success); }
.badge-amber { background: var(--warning-soft); color: var(--warning); }
.badge-red { background: var(--danger-soft); color: var(--danger); }
.badge-violet { background: rgba(124, 58, 237, .12); color: var(--accent); }
.method { font-family: var(--mono); min-width: 62px; justify-content: center; border-radius: 7px; }

.status-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; color: var(--success); animation: pulse 2s infinite; display: inline-block; }

/* ---------- Toolbar, chips, tabs ---------- */

.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.search { position: relative; flex: 1; min-width: 220px; max-width: 420px; }
.search i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search .input { padding-left: 40px; height: 42px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
    height: 34px; padding: 0 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-2);
    font: inherit; font-size: .84rem; font-weight: 600;
    cursor: pointer;
    transition: all .2s var(--ease);
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.active { background: var(--text); border-color: var(--text); color: var(--surface); }

.tabs { display: inline-flex; padding: 4px; gap: 4px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); margin-bottom: 18px; }
.tab {
    display: inline-flex; align-items: center; gap: 8px;
    height: 36px; padding: 0 14px;
    border: 0; border-radius: 9px;
    background: none; color: var(--muted);
    font: inherit; font-weight: 600; font-size: .88rem;
    cursor: pointer;
    transition: all .25s var(--ease);
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.tab .count { font-size: .74rem; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); }
.tab.active .count { background: var(--primary-soft); color: var(--primary); }
.tab-panel { animation: fadeUp .4s var(--ease) both; }
.tab-panel[hidden] { display: none; }

/* ---------- Tables ---------- */

.table-card { padding: 0; overflow: hidden; }
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .9rem; }
.table th {
    position: sticky; top: 0; z-index: 1;
    text-align: left;
    padding: 12px 16px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: .74rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table td { padding: 13px 16px; border-bottom: 1px solid var(--border); color: var(--text-2); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color .15s var(--ease); animation: fadeIn .45s var(--ease) both; animation-delay: calc(min(var(--i, 0), 20) * 25ms); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr[data-href] { cursor: pointer; }
.table tbody tr[data-href]:hover td:first-child { box-shadow: inset 3px 0 0 var(--primary); }
.table .strong { color: var(--text); font-weight: 600; }
.table td.strong:first-child { min-width: 200px; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .truncate { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-foot { padding: 12px 16px; border-top: 1px solid var(--border); color: var(--muted); font-size: .82rem; display: flex; justify-content: space-between; }

.empty {
    padding: 48px 24px;
    text-align: center;
    color: var(--muted);
}
.empty i { font-size: 1.8rem; margin-bottom: 12px; display: block; opacity: .6; }
.empty strong { display: block; color: var(--text); margin-bottom: 4px; }

.copy-btn { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 4px 6px; border-radius: 6px; opacity: 0; transition: opacity .2s var(--ease), color .2s var(--ease); }
tr:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; }
.copy-btn:hover { color: var(--primary); background: var(--primary-soft); }
.copy-btn.copied { color: var(--success); opacity: 1; }

/* ---------- Hero / landing ---------- */

.hero { position: relative; padding: 88px 0 72px; overflow: hidden; }
.hero-inner { position: relative; z-index: 1; max-width: 760px; }
.hero h1 { font-size: clamp(2.2rem, 5.2vw, 3.6rem); font-weight: 800; letter-spacing: -.035em; line-height: 1.05; }
.hero .lead { font-size: 1.15rem; color: var(--muted); margin: 20px 0 32px; max-width: 600px; }
.pill {
    display: inline-flex; align-items: center; gap: 10px;
    padding: 6px 14px 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface-glass);
    backdrop-filter: blur(8px);
    font-size: .84rem; font-weight: 550; color: var(--text-2);
    margin-bottom: 24px;
}

.blobs { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.blob { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .55; animation: float 18s ease-in-out infinite; }
.blob-1 { width: 420px; height: 420px; background: #3b82f6; top: -120px; right: -60px; }
.blob-2 { width: 360px; height: 360px; background: #8b5cf6; bottom: -160px; right: 28%; animation-delay: -6s; animation-duration: 22s; }
.blob-3 { width: 260px; height: 260px; background: #06b6d4; top: 30%; right: 10%; animation-delay: -12s; opacity: .35; }
:root[data-theme="dark"] .blob { opacity: .35; }

.feature { padding: 26px; }
.feature h3 { margin: 16px 0 8px; }
.feature p { color: var(--muted); font-size: .93rem; }

.cta-band {
    display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap;
    padding: 28px 32px;
    border-radius: var(--radius-lg);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

/* ---------- Auth (login / 2FA) ---------- */

.auth-shell { flex: 1; display: grid; grid-template-columns: 1.05fr 1fr; min-height: 100vh; }
.auth-aside {
    position: relative; overflow: hidden;
    display: flex; flex-direction: column; justify-content: space-between;
    padding: 40px 48px;
    background: linear-gradient(140deg, #0b1b3a 0%, #142a66 45%, #3b2a8f 100%);
    background-size: 200% 200%;
    animation: gradientShift 16s ease infinite;
    color: #e8eeff;
}
.auth-aside .brand, .auth-aside .brand:hover { color: #fff; }
.auth-aside .brand small { color: rgba(232, 238, 255, .65); }
.auth-aside h2 { color: #fff; font-size: clamp(1.7rem, 2.8vw, 2.4rem); font-weight: 750; max-width: 420px; letter-spacing: -.03em; }
.auth-aside p { color: rgba(232, 238, 255, .75); margin-top: 14px; max-width: 420px; }
.auth-aside .blob { opacity: .45; }
.auth-points { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 14px; }
.auth-points li { display: flex; align-items: center; gap: 12px; color: rgba(232, 238, 255, .88); font-size: .93rem; }
.auth-points i { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: rgba(255, 255, 255, .1); color: #fff; font-size: .82rem; }
.auth-aside > :not(.blobs) { position: relative; z-index: 1; }
.auth-main { display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 40px 24px; position: relative; }
.auth-main .top-actions { position: absolute; top: 20px; right: 24px; display: flex; gap: 8px; }
.auth-card { width: 100%; max-width: 410px; animation: scaleIn .55s var(--ease) both; }
.auth-card h1 { font-size: 1.75rem; }
.auth-card .sub { color: var(--muted); margin: 8px 0 26px; }
.auth-card form { display: flex; flex-direction: column; gap: 16px; }
.auth-icon {
    width: 56px; height: 56px; border-radius: 16px;
    display: grid; place-items: center;
    background: var(--primary-soft); color: var(--primary);
    font-size: 1.4rem;
    margin-bottom: 20px;
}
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .8rem; margin: 6px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.link-btn { border: 0; background: none; padding: 0; color: var(--primary); font: inherit; font-weight: 600; cursor: pointer; }
.link-btn:disabled { color: var(--muted); cursor: default; }
.auth-foot { margin-top: 28px; text-align: center; color: var(--muted); font-size: .86rem; }

/* Centered single-card pages (account removal, verification, errors) */
.center-page { flex: 1; display: grid; place-items: center; padding: 48px 24px; position: relative; overflow: hidden; }
.center-card { width: 100%; max-width: 520px; position: relative; z-index: 1; animation: scaleIn .55s var(--ease) both; }
.center-card.text-center { text-align: center; }
.center-card .auth-icon { margin-left: auto; margin-right: auto; }
.text-center .auth-icon { margin: 0 auto 20px; }
.big-status { font-size: clamp(4rem, 12vw, 7rem); font-weight: 800; letter-spacing: -.05em; line-height: 1; }

/* Dialog */
dialog.modal {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    color: var(--text);
    padding: 28px;
    max-width: 420px; width: calc(100% - 32px);
    box-shadow: var(--shadow-lg);
}
dialog.modal[open] { animation: scaleIn .3s var(--ease) both; }
dialog.modal::backdrop { background: rgba(7, 11, 23, .55); backdrop-filter: blur(4px); animation: fadeIn .3s var(--ease) both; }
dialog.modal h3 { margin: 6px 0 8px; font-size: 1.2rem; }
dialog.modal p { color: var(--muted); }
dialog.modal .row { justify-content: flex-end; margin-top: 24px; }

/* Security page */
.method-card { display: flex; gap: 16px; align-items: flex-start; padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); transition: border-color .25s var(--ease), background-color .25s var(--ease); }
.method-card.current { border-color: var(--primary); background: var(--primary-soft); }
.method-card h3 { display: flex; align-items: center; gap: 10px; }
.method-card p { color: var(--muted); font-size: .9rem; margin: 4px 0 14px; }
.setup { display: grid; grid-template-columns: auto 1fr; gap: 28px; align-items: start; }
.qr-frame { padding: 12px; border-radius: 16px; background: #fff; border: 1px solid var(--border); box-shadow: var(--shadow); animation: scaleIn .5s var(--ease) both; }
.qr-frame img { display: block; width: 200px; height: 200px; image-rendering: pixelated; }
.secret { display: inline-flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: .9rem; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); border: 1px dashed var(--border-strong); word-break: break-all; }
.steps { list-style: none; counter-reset: step; padding: 0; margin: 0; display: grid; gap: 18px; }
.steps > li { counter-increment: step; display: grid; grid-template-columns: 30px 1fr; gap: 12px; }
.steps > li::before { content: counter(step); width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--gradient); color: #fff; font-size: .8rem; font-weight: 700; }

/* QR label printouts */
.label-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; }
.label {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    padding: 16px 12px;
    background: #fff; color: #0b1b3a;
    border: 1px dashed #cfd7e6;
    border-radius: 14px;
    text-align: center; font-weight: 650; font-size: .85rem;
    animation: scaleIn .35s var(--ease) both;
    animation-delay: calc(min(var(--i, 0), 24) * 18ms);
}
.label img { width: 130px; height: 130px; }
.range { width: 220px; accent-color: var(--primary); }
.range-value { font-family: var(--mono); font-weight: 700; min-width: 2.5ch; text-align: center; }

/* ---------- Portal admin: records grid, access pages, toasts ---------- */

/* The hidden attribute wins over display rules like .btn { display: inline-flex } */
[hidden] { display: none !important; }

.small { font-size: .78rem; }
.nowrap { white-space: nowrap; }
.card-pad { padding: 18px 20px 6px; }
.hint-inline { display: inline-flex; align-items: center; gap: 8px; font-size: .84rem; }
.records-group { margin-bottom: 30px; }
.records-group h2 { margin-bottom: 14px; }
.card-link h3 { display: flex; align-items: center; gap: 10px; }

/* Sub navigation (Access pages) */
.subnav { display: flex; width: max-content; max-width: 100%; overflow-x: auto; }
.subnav .tab { text-decoration: none; white-space: nowrap; }
.subnav .tab i { font-size: .85em; }

/* Live indicator */
.live-status { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px; border-radius: 999px;
    font-size: .8rem; font-weight: 650; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.live-status .status-dot { color: var(--muted); animation: none; }
.live-status[data-state="on"] { color: var(--success); background: var(--success-soft); border-color: transparent; }
.live-status[data-state="on"] .status-dot { color: var(--success); animation: pulse 2s infinite; }

/* Small icon buttons and danger variants */
.icon-btn-sm { width: 32px; height: 32px; border-radius: 9px; font-size: .85rem; }
.icon-btn.danger:hover, .btn-ghost.danger:hover { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.btn-ghost.danger { color: var(--danger); }

.spinner { display: inline-block; width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--border-strong);
    border-top-color: var(--primary); animation: spin .8s linear infinite; margin-bottom: 10px; }

/* Editable grid */
.grid-table th { padding: 0; }
.th-sort { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 6px; width: 100%; padding: 12px 16px;
    cursor: pointer; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; white-space: nowrap; }
.th-sort:hover { color: var(--text); }
.th-sort:focus-visible { box-shadow: inset var(--ring); }
.th-sort i { color: var(--primary); font-size: .9em; }
.grid-table td { white-space: nowrap; max-width: 340px; overflow: hidden; text-overflow: ellipsis; }
.grid-table td.truncate { max-width: 260px; }
.grid-table td.strong-ish { color: var(--text); font-weight: 550; }
.grid-table td.editable { cursor: text; position: relative; }
.grid-table td.editable:hover { box-shadow: inset 0 0 0 1px var(--border-strong); background: var(--surface); }
.grid-table td.editable:focus-visible { box-shadow: inset 0 0 0 2px var(--primary); outline: none; }
.grid-table td.is-editing { padding: 4px 6px; overflow: visible; max-width: none; }
.grid-table td.is-editing .input { height: 36px; min-width: 160px; padding: 0 10px; font-size: .88rem; }
.grid-table td.is-editing textarea.input { min-height: 80px; padding: 8px 10px; }
.grid-table td.saving { opacity: .55; pointer-events: none; }
.grid-table .row-actions, .row-actions { white-space: nowrap; text-align: right; overflow: visible; }
.row-actions form { display: inline; margin: 0; }
.row-actions .btn, .row-actions .icon-btn { vertical-align: middle; }
.actions-col { width: 1%; }

/* Grid selection and bulk actions */
.toolbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.grid-table .select-col { width: 1%; padding: 0 4px 0 16px; text-align: center; overflow: visible; }
.grid-table th.select-col { padding: 12px 4px 12px 16px; }
.select-col input { width: 17px; height: 17px; margin: 0; accent-color: var(--primary); cursor: pointer; vertical-align: middle; }
.grid-table tbody tr.is-selected { background: var(--primary-soft); }
.grid-table tbody tr.is-selected:hover { background: color-mix(in srgb, var(--primary-soft) 70%, var(--surface-2)); }
.bulk-bar { position: sticky; top: 12px; z-index: 5; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px;
    padding: 10px 12px 10px 18px; border-radius: 14px; background: var(--surface); border: 1px solid color-mix(in srgb, var(--primary) 35%, var(--border));
    box-shadow: var(--shadow-lg); font-size: .9rem; color: var(--text-2); animation: fadeUp .25s var(--ease) both; }
.bulk-bar strong { color: var(--primary); }
.scope-options { border: 0; padding: 0; margin: 18px 0 0; display: flex; flex-direction: column; gap: 10px; }
.scope-options legend { font-size: .86rem; font-weight: 600; color: var(--text-2); margin-bottom: 8px; padding: 0; }
.bulk-summary { margin-top: 16px; font-weight: 550; color: var(--text) !important; }
.import-file { margin-top: 18px; }
.import-file input[type=file] { padding: 8px 10px; height: auto; }
.import-preview { margin-top: 16px; padding: 14px 16px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border);
    display: flex; flex-direction: column; gap: 8px; max-height: 40vh; overflow-y: auto; }
.import-preview p { margin: 0; }
.import-counts { display: flex; gap: 6px; flex-wrap: wrap; }
.import-list { margin: 0; padding-left: 18px; font-size: .84rem; color: var(--text-2); display: flex; flex-direction: column; gap: 3px; }
.problem-list li { color: var(--danger); }
.problem-list li.muted { color: var(--muted); }
@media (max-width: 640px) {
    .toolbar-actions { margin-left: 0; }
    .bulk-bar .toolbar-actions { width: 100%; }
}

@keyframes flashSaved { from { background: var(--success-soft); box-shadow: inset 0 0 0 1px var(--success); } to { background: transparent; box-shadow: none; } }
@keyframes flashError { from { background: var(--danger-soft); box-shadow: inset 0 0 0 1px var(--danger); } to { background: transparent; box-shadow: none; } }
@keyframes flashLive { from { background: var(--primary-soft); } to { background: transparent; } }
.flash-saved { animation: flashSaved 1.6s var(--ease) both; }
.flash-error { animation: flashError 2.4s var(--ease) both; }
tr.flash-live td, .flash-live { animation: flashLive 2s var(--ease) both; }

/* Toggle switch */
.switch { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: inherit; }
.switch-track { width: 38px; height: 22px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background-color .2s var(--ease); }
.switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s var(--ease); }
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { box-shadow: var(--ring); }
.switch input:disabled { cursor: not-allowed; }
.switch input:disabled + .switch-track { opacity: .5; }

/* Forms in dialogs */
dialog.modal-wide { max-width: 640px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; margin-top: 18px; max-height: 60vh; overflow-y: auto; padding: 2px; }
dialog.modal .alert { margin-top: 14px; }
.check { display: inline-flex; align-items: center; gap: 10px; font-size: .9rem; color: var(--text-2); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }

/* Toasts */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; max-width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; border-radius: 12px; font-size: .88rem; font-weight: 550;
    background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow-lg); animation: fadeUp .35s var(--ease) both; }
.toast i { margin-top: 2px; }
.toast-success i { color: var(--success); }
.toast-error { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.toast-error i { color: var(--danger); }
.toast-info i { color: var(--primary); }
.toast.leaving { opacity: 0; transform: translateY(8px); transition: all .3s var(--ease); }

/* User page */
.user-grid { align-items: start; }
.role-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.role-chip { position: relative; cursor: pointer; }
.role-chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: inherit; }
.role-chip > span { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 14px; border-radius: 999px;
    border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: .86rem; font-weight: 600;
    transition: all .2s var(--ease); }
.role-chip > span i { color: var(--muted); font-size: .85em; }
.role-chip:hover > span { border-color: var(--border-strong); }
.role-chip input:checked + span { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 40%, transparent); color: var(--primary); }
.role-chip input:checked + span i { color: var(--primary); }
.role-chip input:focus-visible + span { box-shadow: var(--ring); }
.role-chip input:disabled { cursor: not-allowed; }
.role-chip input:disabled + span { opacity: .55; }
.role-chip.saving { opacity: .55; pointer-events: none; }
.section-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 10px; font-weight: 700; }
.perm-summary { display: grid; gap: 8px; }
.perm-group { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.perm-group-name { min-width: 130px; font-size: .82rem; color: var(--text-2); font-weight: 600; }
.perm-pill { font-family: var(--mono); font-size: .72rem; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--muted);
    text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 50%, transparent); transition: all .25s var(--ease); }
.perm-pill.on { background: var(--success-soft); color: var(--success); text-decoration: none; }
.action-list { display: flex; flex-direction: column; }
.action-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-top: 1px solid var(--border); margin: 0; }
.action-row:first-child { border-top: 0; padding-top: 4px; }
.action-row > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.action-row > div > strong { font-size: .92rem; }
.action-row > div > span { color: var(--muted); font-size: .84rem; }
.action-row .btn { flex-shrink: 0; }
.danger-zone strong { color: var(--danger); }

/* Roles matrix */
.matrix th, .matrix td { text-align: center; }
.matrix .matrix-perm { text-align: left; min-width: 240px; position: sticky; left: 0; background: var(--surface); z-index: 1; }
.matrix thead .matrix-perm { background: var(--surface-2); }
.matrix .matrix-perm code { color: var(--text); font-weight: 600; }
.matrix-role { min-width: 120px; vertical-align: bottom; }
.role-head { display: flex; flex-direction: column; align-items: center; gap: 4px; text-transform: none; letter-spacing: 0; }
.role-name { font-family: var(--mono); font-size: .82rem; font-weight: 700; color: var(--text); padding: 2px 6px; border-radius: 6px; outline: none; }
.role-name[contenteditable="true"] { cursor: text; }
.role-name[contenteditable="true"]:hover { background: var(--surface); box-shadow: inset 0 0 0 1px var(--border-strong); }
.role-name[contenteditable="true"]:focus { background: var(--surface); box-shadow: var(--ring); }
.role-delete { margin: 2px 0 0; }
.matrix-group td { text-align: left; background: var(--surface-2); color: var(--text-2); font-size: .76rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .06em; padding: 8px 16px; }
.matrix tbody tr.matrix-group:hover { background: var(--surface-2); }
.check-cell { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; cursor: pointer; }
.check-cell:hover { background: var(--surface-2); }
.check-cell input { width: 18px; height: 18px; accent-color: var(--primary); cursor: inherit; }
.check-cell input:disabled { cursor: not-allowed; }
.matrix-cell.saving { opacity: .5; }

@media (max-width: 760px) {
    .form-grid { grid-template-columns: 1fr; }
    .hint-inline { display: none; }
    .action-row { flex-direction: column; align-items: flex-start; }
    .perm-group-name { min-width: 100%; }
    .matrix .matrix-perm { min-width: 180px; }
    .toasts { left: 16px; right: 16px; bottom: 16px; max-width: none; }
    .page-head .row { width: 100%; }
    .card.table-card { padding: 0; }
}

/* ---------- Responsive ---------- */

@media (max-width: 960px) {
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .auth-shell { grid-template-columns: 1fr; }
    .auth-aside { display: none; }
}

@media (max-width: 760px) {
    .container { padding: 0 16px; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .grid-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .stat { padding: 16px; }
    .stat-value { font-size: 1.6rem; }
    .nav-toggle { display: inline-grid; }
    .nav {
        position: absolute; top: var(--header-h); left: 0; right: 0;
        flex-direction: column; align-items: stretch;
        margin: 0; padding: 10px 16px 16px;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow-lg);
        opacity: 0; transform: translateY(-8px); pointer-events: none;
        transition: opacity .2s var(--ease), transform .2s var(--ease);
    }
    .nav.open { opacity: 1; transform: none; pointer-events: auto; }
    .nav a { padding: 12px; }
    .user-menu-btn .name { display: none; }
    .hero { padding: 56px 0 48px; }
    .setup { grid-template-columns: 1fr; }
    .page { padding-top: 20px; }
    .card { padding: 18px; }
    .cta-band { padding: 22px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
    .reveal-on-scroll { opacity: 1; transform: none; }
    @view-transition { navigation: none; }
}

@media print {
    .app-header, .app-footer, .no-print { display: none !important; }
    body { background: #fff; }
    .page { padding: 0; }
    .label { border: 1px dashed #999; break-inside: avoid; animation: none; }
    .label-grid { grid-template-columns: repeat(4, 1fr); gap: 8px; }
}

/* Grid image cells (e.g. product icons) */
.grid-table .cell-thumb { width: 28px; height: 28px; object-fit: contain; border-radius: 7px; background: var(--surface-2);
    border: 1px solid var(--border); vertical-align: middle; margin-right: 10px; }
.grid-table .cell-thumb.is-broken { visibility: hidden; }

/* Record editor (products, customers) */
.editor-grid { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); align-items: start; }
.icon-stage { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.icon-preview { width: 168px; height: 168px; flex: none; border-radius: 18px; border: 1px solid var(--border); display: grid; place-items: center;
    overflow: hidden; background: repeating-conic-gradient(var(--surface-2) 0 25%, var(--surface) 0 50%) 0 0 / 18px 18px; }
.icon-preview img { width: 100%; height: 100%; object-fit: contain; padding: 12px; }
.icon-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--muted); font-size: .85rem; font-weight: 550; }
.icon-empty i { font-size: 2rem; opacity: .6; }
.icon-meta { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 6px; }
.icon-meta strong { color: var(--text); word-break: break-all; }
.icon-actions { margin-top: 8px; gap: 8px; }
.bundled-field { margin-top: 10px; }
.file-btn { position: relative; overflow: hidden; cursor: pointer; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone { margin-top: 18px; display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; text-align: center;
    padding: 18px; border: 2px dashed var(--border-strong); border-radius: 14px; color: var(--text-2); font-size: .88rem;
    transition: background-color .2s var(--ease), border-color .2s var(--ease); }
.dropzone i { color: var(--primary); font-size: 1.2rem; }
.dropzone.is-over { border-color: var(--primary); background: var(--primary-soft); }
.dropzone.is-busy { opacity: .6; pointer-events: none; }
.gallery-title { margin: 22px 0 12px; font-size: 1rem; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.gallery-empty { grid-column: 1 / -1; padding: 24px 12px; }
.gallery-tile { margin: 0; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; background: var(--surface);
    display: flex; flex-direction: column; transition: border-color .2s var(--ease), box-shadow .2s var(--ease); }
.gallery-tile.is-icon { border-color: color-mix(in srgb, var(--primary) 55%, var(--border)); box-shadow: 0 0 0 3px var(--primary-soft); }
.gallery-frame { position: relative; display: grid; place-items: center; aspect-ratio: 1; background: var(--surface-2); }
.gallery-frame img { width: 100%; height: 100%; object-fit: contain; padding: 10px; }
.gallery-badge { position: absolute; top: 8px; left: 8px; }
.gallery-tile figcaption { padding: 8px 10px 4px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.truncate-line { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .84rem; color: var(--text); }
.gallery-actions { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px 6px 8px; }
.gallery-actions .btn { height: 30px; padding: 0 9px; font-size: .78rem; }
.details-grid { max-height: none; overflow: visible; }
.details-grid .field-wide { grid-column: 1 / -1; }
.details-grid .field.is-changed .input { border-color: var(--warning); }
.details-actions { justify-content: flex-end; margin-top: 18px; }
.details-actions [data-dirty] { margin-right: auto; display: inline-flex; align-items: center; gap: 6px; }
@media (max-width: 960px) {
    .editor-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
    .icon-preview { width: 128px; height: 128px; }
    .details-grid { grid-template-columns: minmax(0, 1fr); }
}

/* Row actions stay visible on wide grids (pinned to the right edge while scrolling sideways). Backgrounds are layered
   over the opaque surface because the tints are translucent in dark mode. */
.grid-table td.row-actions { position: sticky; right: 0; z-index: 1; background: var(--surface); box-shadow: -10px 0 12px -12px rgba(15, 23, 42, .35); }
.grid-table th.actions-col { position: sticky; right: 0; top: 0; z-index: 2; }
.grid-table tbody tr:hover td.row-actions { background: linear-gradient(var(--surface-2), var(--surface-2)), var(--surface); }
.grid-table tbody tr.is-selected td.row-actions { background: linear-gradient(var(--primary-soft), var(--primary-soft)), var(--surface); }
.grid-table td.row-actions:empty { box-shadow: none; }

/* Pages with tables use the full window width (header and footer too), keeping the side gutter */
body:has(.table-card) .container { max-width: none; }
@media (min-width: 1400px) {
    body:has(.table-card) .container { padding: 0 32px; }
}

/* Related records on the record editor */
.related { margin-top: 32px; }
.related-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.related-head .tabs { margin-bottom: 0; max-width: 100%; overflow-x: auto; }
.related-tabs .tab { white-space: nowrap; }
.related .grid-block .toolbar { margin-bottom: 12px; }
