/* ============================================================
   AxoDB Bitemporal Platform — enterprise design system
   ------------------------------------------------------------
   1. Design tokens          8. Cards & panels      15. Drawer
   2. Reset & base           9. Stat cards          16. Toasts
   3. Typography            10. Tables              17. Timeline
   4. App shell             11. Badges & chips      18. Skeletons/empty
   5. Sidebar               12. Tabs & segmented    19. Command palette
   6. Topbar / status bar   13. Forms              20. Page styles
   7. Buttons               14. Modal              21. Responsive
   ============================================================ */

/* 1. ---------- Design tokens -------------------------------- */
:root {
    color-scheme: light;

    --bg: #eef1f6;
    --bg-grad-a: #eef1f6;
    --bg-grad-b: #e7ebf2;
    --surface: #ffffff;
    --surface-2: #f6f8fb;
    --surface-3: #eef2f7;
    --surface-inset: #f3f5f9;

    --ink: #0c1828;
    --ink-soft: #29384c;
    --muted: #5b6b80;
    --muted-soft: #8a99ad;
    --faint: #b3bfce;

    --line: #e4e9f0;
    --line-soft: #eef1f6;
    --line-strong: #cdd6e2;

    --accent: #0d9488;
    --accent-hover: #0f766e;
    --accent-deep: #115e59;
    --accent-ink: #0a5b53;
    --accent-soft: #d6f3ef;
    --accent-softer: #ecf9f7;
    --accent-ring: rgba(13, 148, 136, 0.22);

    --brand: #0b1f38;
    --brand-soft: #14304f;

    --info: #2563eb;
    --info-soft: #dbe7fe;
    --info-ink: #1d4ed8;
    --success: #15803d;
    --success-soft: #d8f2e1;
    --success-ink: #166534;
    --warning: #b45309;
    --warning-soft: #fdedd3;
    --warning-ink: #92400e;
    --danger: #c2342f;
    --danger-soft: #fbe0df;
    --danger-ink: #991b1b;
    --violet: #7c3aed;
    --violet-soft: #ece4fd;

    --sidebar-bg: #0b1f38;
    --sidebar-bg-2: #0d243f;
    --sidebar-fg: #e9eef5;
    --sidebar-fg-muted: #8ba0b9;
    --sidebar-fg-faint: #5d7491;
    --sidebar-line: rgba(255, 255, 255, 0.08);
    --sidebar-active-bg: rgba(45, 212, 191, 0.14);
    --sidebar-active-fg: #5eead4;
    --sidebar-hover-bg: rgba(255, 255, 255, 0.05);

    --shadow-xs: 0 1px 2px rgba(12, 24, 40, 0.05);
    --shadow-sm: 0 1px 2px rgba(12, 24, 40, 0.06), 0 1px 3px rgba(12, 24, 40, 0.04);
    --shadow-md: 0 2px 6px rgba(12, 24, 40, 0.07), 0 8px 20px rgba(12, 24, 40, 0.07);
    --shadow-lg: 0 6px 14px rgba(12, 24, 40, 0.1), 0 18px 44px rgba(12, 24, 40, 0.14);
    --shadow-pop: 0 10px 24px rgba(12, 24, 40, 0.12), 0 28px 64px rgba(12, 24, 40, 0.2);

    --radius-xs: 5px;
    --radius-sm: 7px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    --mono: "JetBrains Mono", "Cascadia Mono", "SF Mono", Consolas, monospace;
    --sans: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, Arial, sans-serif;

    --sidebar-w: 254px;
    --sidebar-w-collapsed: 68px;
    --topbar-h: 58px;
    --statusbar-h: 30px;

    --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    color-scheme: dark;

    --bg: #070d18;
    --bg-grad-a: #070d18;
    --bg-grad-b: #0a1322;
    --surface: #111c2e;
    --surface-2: #0e1828;
    --surface-3: #182437;
    --surface-inset: #0c1626;

    --ink: #eef2f8;
    --ink-soft: #d3dbe6;
    --muted: #93a2b8;
    --muted-soft: #677890;
    --faint: #45556d;

    --line: #1f2c41;
    --line-soft: #182539;
    --line-strong: #2c3c56;

    --accent: #2dd4bf;
    --accent-hover: #14b8a6;
    --accent-deep: #5eead4;
    --accent-ink: #5eead4;
    --accent-soft: rgba(45, 212, 191, 0.16);
    --accent-softer: rgba(45, 212, 191, 0.09);
    --accent-ring: rgba(45, 212, 191, 0.28);

    --brand: #0a1322;
    --brand-soft: #111c2e;

    --info: #60a5fa;
    --info-soft: rgba(96, 165, 250, 0.16);
    --info-ink: #93c5fd;
    --success: #4ade80;
    --success-soft: rgba(74, 222, 128, 0.15);
    --success-ink: #86efac;
    --warning: #fbbf24;
    --warning-soft: rgba(251, 191, 36, 0.15);
    --warning-ink: #fcd34d;
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, 0.16);
    --danger-ink: #fca5a5;
    --violet: #a78bfa;
    --violet-soft: rgba(167, 139, 250, 0.16);

    --sidebar-bg: #080f1c;
    --sidebar-bg-2: #0b1525;
    --sidebar-fg: #e4ebf4;
    --sidebar-fg-muted: #7e91ab;
    --sidebar-fg-faint: #51637e;
    --sidebar-line: rgba(255, 255, 255, 0.06);
    --sidebar-active-bg: rgba(45, 212, 191, 0.16);
    --sidebar-active-fg: #5eead4;
    --sidebar-hover-bg: rgba(255, 255, 255, 0.04);

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.45);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.5), 0 8px 22px rgba(0, 0, 0, 0.42);
    --shadow-lg: 0 8px 20px rgba(0, 0, 0, 0.55), 0 22px 48px rgba(0, 0, 0, 0.6);
    --shadow-pop: 0 12px 30px rgba(0, 0, 0, 0.6), 0 30px 70px rgba(0, 0, 0, 0.7);
}

/* 2. ---------- Reset & base --------------------------------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--sans);
    font-feature-settings: "cv02", "cv03", "cv04", "cv11";
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5 {
    margin: 0;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: -0.012em;
}

p {
    margin: 0;
}

a {
    color: var(--accent-ink);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

code,
.mono {
    font-family: var(--mono);
    font-size: 0.82em;
}

button,
input,
select,
textarea {
    font: inherit;
}

::selection {
    background: var(--accent-ring);
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 3px;
}

/* headings are focused programmatically on navigation — no ring */
h1:focus,
h1:focus-visible,
[tabindex="-1"]:focus,
[tabindex="-1"]:focus-visible {
    outline: none;
}

/* Scrollbars */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--line-strong) transparent;
}

*::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

*::-webkit-scrollbar-thumb {
    background: var(--line-strong);
    border-radius: 6px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
    background: var(--muted-soft);
    background-clip: padding-box;
}

/* 3. ---------- Typography helpers --------------------------- */
.muted {
    color: var(--muted);
}

.faint {
    color: var(--muted-soft);
}

.tnum {
    font-variant-numeric: tabular-nums;
}

.eyebrow {
    text-transform: uppercase;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    color: var(--muted-soft);
}

/* 4. ---------- App shell ------------------------------------ */
.app-shell {
    display: flex;
    min-height: 100vh;
    background:
        radial-gradient(1100px 520px at 88% -8%, var(--accent-softer), transparent 70%),
        linear-gradient(180deg, var(--bg-grad-a), var(--bg-grad-b));
}

.app-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    margin-left: var(--sidebar-w);
    transition: margin-left 200ms var(--ease);
}

.app-shell.nav-collapsed .app-body {
    margin-left: var(--sidebar-w-collapsed);
}

.app-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    scroll-padding-top: 20px;
}

.app-content-inner {
    max-width: 1640px;
    margin: 0 auto;
    padding: 26px 30px 44px;
}

/* 5. ---------- Sidebar -------------------------------------- */
.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, var(--sidebar-bg-2), var(--sidebar-bg));
    border-right: 1px solid var(--sidebar-line);
    z-index: 60;
    transition: width 200ms var(--ease);
}

.app-shell.nav-collapsed .app-sidebar {
    width: var(--sidebar-w-collapsed);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    height: var(--topbar-h);
    padding: 0 18px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--sidebar-line);
    color: var(--sidebar-fg);
    text-decoration: none;
    overflow: hidden;
    white-space: nowrap;
}

.sidebar-brand:hover {
    text-decoration: none;
}

.brand-mark {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 8px;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1), 0 4px 12px rgba(13, 148, 136, 0.35);
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    min-width: 0;
}

.brand-text b {
    font-size: 0.96rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.brand-text span {
    font-size: 0.66rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--sidebar-fg-muted);
}

.app-shell.nav-collapsed .brand-text {
    display: none;
}

.sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 12px 16px;
}

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

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

.nav-group-label {
    padding: 6px 12px;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--sidebar-fg-faint);
    white-space: nowrap;
}

.app-shell.nav-collapsed .nav-group-label {
    text-align: center;
    padding: 6px 0;
    overflow: hidden;
    text-overflow: clip;
    color: transparent;
    height: 13px;
}

.app-shell.nav-collapsed .nav-group-label::after {
    content: "";
    display: block;
    width: 18px;
    height: 1px;
    margin: 6px auto 0;
    background: var(--sidebar-line);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 8px 12px;
    margin: 2px 0;
    border-radius: var(--radius-sm);
    color: var(--sidebar-fg-muted);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    position: relative;
    transition: background 120ms var(--ease), color 120ms var(--ease);
}

.nav-item:hover {
    background: var(--sidebar-hover-bg);
    color: var(--sidebar-fg);
    text-decoration: none;
}

.nav-item.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-fg);
    font-weight: 600;
}

.nav-item.active::before {
    content: "";
    position: absolute;
    left: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    border-radius: 0 3px 3px 0;
    background: var(--sidebar-active-fg);
}

.nav-item-icon {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    display: inline-flex;
}

.nav-item-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-item-badge {
    flex-shrink: 0;
    min-width: 19px;
    height: 18px;
    padding: 0 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    font-size: 0.66rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    background: rgba(255, 255, 255, 0.09);
    color: var(--sidebar-fg);
}

.nav-item-badge.warn {
    background: var(--warning);
    color: #20140a;
}

.nav-item-badge.danger {
    background: var(--danger);
    color: #fff;
}

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

.app-shell.nav-collapsed .nav-item-label,
.app-shell.nav-collapsed .nav-item-badge {
    display: none;
}

.app-shell.nav-collapsed .nav-item.active::before {
    left: -12px;
}

.app-shell.nav-collapsed .nav-item-dot {
    position: absolute;
    top: 6px;
    right: 12px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
}

.nav-item-dot {
    display: none;
}

.sidebar-foot {
    flex-shrink: 0;
    padding: 10px 12px;
    border-top: 1px solid var(--sidebar-line);
}

.sidebar-card {
    padding: 11px 12px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--sidebar-line);
}

.app-shell.nav-collapsed .sidebar-card {
    display: none;
}

.sidebar-card-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.72rem;
    color: var(--sidebar-fg-muted);
}

.sidebar-card-row + .sidebar-card-row {
    margin-top: 6px;
}

.sidebar-card-row > span {
    flex-shrink: 0;
}

.sidebar-card-row b {
    color: var(--sidebar-fg);
    font-weight: 600;
    font-family: var(--mono);
    font-size: 0.72rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.collapse-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-top: 8px;
    padding: 7px;
    border: 1px solid var(--sidebar-line);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--sidebar-fg-muted);
    font-size: 0.74rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 120ms var(--ease), color 120ms var(--ease);
    min-height: 32px;
    box-shadow: none;
}

.collapse-btn:hover {
    background: var(--sidebar-hover-bg);
    color: var(--sidebar-fg);
}

.collapse-btn .ic {
    transition: transform 200ms var(--ease);
}

.app-shell.nav-collapsed .collapse-btn .label {
    display: none;
}

.app-shell.nav-collapsed .collapse-btn .ic {
    transform: rotate(180deg);
}

/* 6. ---------- Topbar & status bar -------------------------- */
.app-topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    height: var(--topbar-h);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 22px;
    background: color-mix(in srgb, var(--surface) 86%, transparent);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--line);
}

.topbar-crumbs {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
    flex: 1;
}

.crumb {
    font-size: 0.82rem;
    color: var(--muted);
    white-space: nowrap;
}

.crumb.here {
    color: var(--ink);
    font-weight: 600;
}

.crumb-sep {
    color: var(--faint);
    display: inline-flex;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 9px;
    flex-shrink: 0;
}

.cmd-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 34px;
    padding: 0 10px 0 11px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--muted);
    font-size: 0.8rem;
    cursor: pointer;
    box-shadow: none;
    transition: border-color 120ms var(--ease), background 120ms var(--ease);
}

.cmd-trigger:hover {
    border-color: var(--muted-soft);
    background: var(--surface-3);
    color: var(--ink-soft);
}

.cmd-trigger .cmd-trigger-label {
    min-width: 92px;
    text-align: left;
}

kbd {
    display: inline-flex;
    align-items: center;
    gap: 1px;
    padding: 2px 5px;
    border-radius: 4px;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--muted);
    font-family: var(--sans);
    font-size: 0.66rem;
    font-weight: 600;
    line-height: 1;
    box-shadow: 0 1px 0 var(--line-strong);
}

.subject-switch {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 34px;
    padding: 0 6px 0 11px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}

.subject-switch-id {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
}

.subject-avatar {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.66rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-deep));
    text-transform: uppercase;
}

.subject-switch-meta {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
    min-width: 0;
}

.subject-switch-meta b {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--ink);
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.subject-switch-meta span {
    font-size: 0.62rem;
    color: var(--muted-soft);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    padding: 0;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--muted);
    cursor: pointer;
    box-shadow: none;
    transition: background 120ms var(--ease), color 120ms var(--ease), border-color 120ms var(--ease);
}

.icon-btn:hover:not(:disabled) {
    background: var(--surface-3);
    color: var(--ink);
    border-color: var(--muted-soft);
}

.icon-btn.busy .ic {
    animation: spin 0.7s linear infinite;
}

.env-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 22px;
    padding: 0 8px;
    border-radius: 5px;
    background: var(--warning-soft);
    color: var(--warning-ink);
    border: 1px solid color-mix(in srgb, var(--warning) 32%, transparent);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.06em;
}

.env-tag::before {
    content: "";
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--warning);
}

.app-statusbar {
    flex-shrink: 0;
    height: var(--statusbar-h);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 18px;
    background: var(--surface);
    border-top: 1px solid var(--line);
    font-size: 0.72rem;
    color: var(--muted);
}

.status-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.status-item .ic {
    color: var(--muted-soft);
}

.status-item b {
    color: var(--ink-soft);
    font-weight: 600;
}

.status-item code {
    color: var(--ink-soft);
}

.status-sep {
    width: 1px;
    height: 13px;
    background: var(--line-strong);
}

.status-spacer {
    flex: 1;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--faint);
    flex-shrink: 0;
}

.status-dot.live {
    background: var(--success);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 22%, transparent);
    animation: pulse 2s infinite;
}

.status-dot.warn {
    background: var(--warning);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--warning) 22%, transparent);
}

.status-dot.danger {
    background: var(--danger);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 22%, transparent);
}

.status-dot.connecting {
    background: var(--warning);
    animation: pulse 1s infinite;
}

/* 7. ---------- Buttons -------------------------------------- */
button {
    font-family: var(--sans);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 36px;
    padding: 0 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--accent-hover);
    background: var(--accent);
    color: #fff;
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: var(--shadow-xs);
    transition: background 120ms var(--ease), border-color 120ms var(--ease),
                box-shadow 120ms var(--ease), transform 70ms var(--ease), opacity 120ms var(--ease);
}

.btn:hover:not(:disabled) {
    background: var(--accent-hover);
    border-color: var(--accent-deep);
}

.btn:active:not(:disabled) {
    transform: translateY(1px);
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
    box-shadow: none;
}

.btn.secondary {
    background: var(--surface);
    color: var(--ink-soft);
    border-color: var(--line-strong);
}

.btn.secondary:hover:not(:disabled) {
    background: var(--surface-2);
    border-color: var(--muted-soft);
    color: var(--ink);
}

.btn.ghost {
    background: transparent;
    color: var(--muted);
    border-color: transparent;
    box-shadow: none;
}

.btn.ghost:hover:not(:disabled) {
    background: var(--surface-3);
    color: var(--ink);
}

.btn.danger {
    background: var(--danger);
    border-color: color-mix(in srgb, var(--danger) 80%, black);
}

.btn.danger:hover:not(:disabled) {
    background: color-mix(in srgb, var(--danger) 86%, black);
}

.btn.warning {
    background: var(--warning);
    border-color: color-mix(in srgb, var(--warning) 80%, black);
}

.btn.warning:hover:not(:disabled) {
    background: color-mix(in srgb, var(--warning) 86%, black);
}

.btn.subtle-danger {
    background: var(--danger-soft);
    color: var(--danger-ink);
    border-color: color-mix(in srgb, var(--danger) 28%, transparent);
    box-shadow: none;
}

.btn.subtle-danger:hover:not(:disabled) {
    background: color-mix(in srgb, var(--danger) 22%, transparent);
}

.btn.sm {
    min-height: 28px;
    padding: 0 10px;
    font-size: 0.76rem;
    gap: 5px;
}

.btn.xs {
    min-height: 24px;
    padding: 0 8px;
    font-size: 0.72rem;
    gap: 4px;
    border-radius: var(--radius-xs);
}

.btn.lg {
    min-height: 42px;
    padding: 0 20px;
    font-size: 0.9rem;
}

.btn.block {
    width: 100%;
}

.btn .ic {
    flex-shrink: 0;
}

.btn-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* 8. ---------- Cards & panels ------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.card.flush {
    overflow: hidden;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
}

.card-head.bare {
    border-bottom: 0;
    padding-bottom: 0;
}

.card-title {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--ink);
    min-width: 0;
}

.card-title .ic {
    color: var(--accent-ink);
    flex-shrink: 0;
}

.card-title-sub {
    font-size: 0.78rem;
    color: var(--muted);
    font-weight: 400;
    margin-top: 2px;
}

.card-tools {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.card-body {
    padding: 18px;
}

.card-body.tight {
    padding: 12px;
}

.card-body.pad-lg {
    padding: 22px;
}

.card-note {
    margin: 0;
    color: var(--muted);
    font-size: 0.83rem;
    line-height: 1.6;
}

.card-foot {
    padding: 12px 18px;
    border-top: 1px solid var(--line);
    background: var(--surface-2);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Page header */
.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
    flex-wrap: wrap;
}

.page-head h1 {
    font-size: 1.5rem;
    line-height: 1.2;
}

.page-head .page-sub {
    margin-top: 6px;
    color: var(--muted);
    font-size: 0.9rem;
    max-width: 76ch;
}

.page-head-actions {
    display: flex;
    align-items: center;
    gap: 9px;
    flex-wrap: wrap;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 26px 0 13px;
    flex-wrap: wrap;
}

.section-head h2 {
    font-size: 1.02rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-head h2 .ic {
    color: var(--accent-ink);
}

/* Generic layout helpers */
.grid {
    display: grid;
    gap: 16px;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

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

.spacer {
    flex: 1;
}

/* 9. ---------- Stat cards ----------------------------------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(216px, 1fr));
    gap: 14px;
}

.stat-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px 17px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: box-shadow 160ms var(--ease), transform 160ms var(--ease), border-color 160ms var(--ease);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: var(--line-strong);
}

.stat-card::after {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent);
    opacity: 0;
    transition: opacity 160ms var(--ease);
}

.stat-card:hover::after {
    opacity: 1;
}

.stat-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.stat-icon {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-soft);
    color: var(--accent-ink);
    flex-shrink: 0;
}

.stat-icon.info { background: var(--info-soft); color: var(--info-ink); }
.stat-icon.violet { background: var(--violet-soft); color: var(--violet); }
.stat-icon.warning { background: var(--warning-soft); color: var(--warning-ink); }
.stat-icon.success { background: var(--success-soft); color: var(--success-ink); }
.stat-icon.danger { background: var(--danger-soft); color: var(--danger-ink); }

.stat-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
}

.stat-value {
    font-size: 1.74rem;
    font-weight: 700;
    color: var(--ink);
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

.stat-value.sm {
    font-size: 1.16rem;
}

.stat-meta {
    font-size: 0.76rem;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 5px;
}

.stat-trend {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-weight: 600;
    font-size: 0.74rem;
}

.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }
.stat-trend.flat { color: var(--muted-soft); }

/* spark bars */
.spark {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 30px;
    margin-top: 4px;
}

.spark-bar {
    flex: 1;
    min-height: 3px;
    border-radius: 2px 2px 0 0;
    background: var(--accent-soft);
}

.spark-bar.hi {
    background: var(--accent);
}

/* 10. ---------- Tables -------------------------------------- */
.table-wrap {
    overflow: auto;
    border-radius: var(--radius-md);
}

table.data,
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
    font-variant-numeric: tabular-nums;
}

table.data thead th,
.data-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
}

th {
    padding: 9px 13px;
    text-align: left;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.045em;
    color: var(--muted);
    background: var(--surface-2);
    border-bottom: 1px solid var(--line-strong);
    white-space: nowrap;
}

td {
    padding: 9px 13px;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid var(--line-soft);
    color: var(--ink-soft);
}

tbody tr {
    transition: background 90ms var(--ease);
}

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

tbody tr.zebra:nth-child(even),
tbody tr:nth-child(even).zebra {
    background: var(--surface-2);
}

.table-hover tbody tr:hover {
    background: var(--accent-softer);
    cursor: pointer;
}

th.sortable {
    cursor: pointer;
    user-select: none;
}

th.sortable:hover {
    color: var(--ink);
    background: var(--surface-3);
}

th.sorted {
    color: var(--accent-ink);
    background: var(--accent-softer);
}

.sort-caret {
    vertical-align: -1px;
    margin-left: 3px;
}

tr.selected td {
    background: var(--accent-softer) !important;
}

tr.selected td:first-child {
    box-shadow: inset 3px 0 0 var(--accent);
}

.table-density-compact td,
.table-density-compact th {
    padding-top: 5px;
    padding-bottom: 5px;
}

.table-density-relaxed td {
    padding-top: 13px;
    padding-bottom: 13px;
}

.cell-empty {
    color: var(--faint);
}

.cell-num {
    font-family: var(--mono);
    font-size: 0.81rem;
    text-align: right;
}

.table-empty td {
    padding: 30px 14px;
    text-align: center;
    color: var(--muted);
}

.table-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 14px;
    border-top: 1px solid var(--line);
    background: var(--surface-2);
    font-size: 0.78rem;
    color: var(--muted);
    flex-wrap: wrap;
}

.pager {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pager button {
    min-width: 28px;
    height: 28px;
    padding: 0 7px;
    border-radius: var(--radius-xs);
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--ink-soft);
    font-size: 0.76rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: none;
}

.pager button:hover:not(:disabled) {
    background: var(--surface-3);
}

.pager button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pager button.current {
    background: var(--accent);
    border-color: var(--accent-hover);
    color: #fff;
}

/* 11. ---------- Badges & chips ------------------------------ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 20px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
    background: var(--surface-3);
    color: var(--muted);
    border: 1px solid var(--line);
}

.badge.accent { background: var(--accent-soft); color: var(--accent-ink); border-color: color-mix(in srgb, var(--accent) 26%, transparent); }
.badge.info { background: var(--info-soft); color: var(--info-ink); border-color: color-mix(in srgb, var(--info) 26%, transparent); }
.badge.success { background: var(--success-soft); color: var(--success-ink); border-color: color-mix(in srgb, var(--success) 26%, transparent); }
.badge.warning { background: var(--warning-soft); color: var(--warning-ink); border-color: color-mix(in srgb, var(--warning) 30%, transparent); }
.badge.danger { background: var(--danger-soft); color: var(--danger-ink); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.badge.violet { background: var(--violet-soft); color: var(--violet); border-color: color-mix(in srgb, var(--violet) 28%, transparent); }

.badge .dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 7px;
    border-radius: var(--radius-xs);
    background: var(--surface-3);
    border: 1px solid var(--line);
    color: var(--muted);
    font-family: var(--mono);
    font-size: 0.68rem;
    font-weight: 500;
    white-space: nowrap;
}

.chip.ref {
    background: var(--accent-softer);
    border-color: color-mix(in srgb, var(--accent) 22%, transparent);
    color: var(--accent-ink);
}

.chip.key {
    background: var(--surface-3);
    color: var(--ink-soft);
}

.code-key {
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--ink-soft);
    background: var(--surface-3);
    border: 1px solid var(--line);
    border-radius: var(--radius-xs);
    padding: 1px 6px;
}

.pill-count {
    display: inline-flex;
    align-items: center;
    height: 19px;
    padding: 0 8px;
    border-radius: 999px;
    background: var(--surface-3);
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    border: 1px solid var(--line);
}

.bool-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
}

.bool-chip.yes { background: var(--success-soft); color: var(--success-ink); }
.bool-chip.no { background: var(--surface-3); color: var(--muted); }

.lock-tag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 6px;
    border-radius: var(--radius-xs);
    background: var(--warning-soft);
    color: var(--warning-ink);
    font-size: 0.64rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.sev {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.sev.error { background: var(--danger-soft); color: var(--danger-ink); }
.sev.warning { background: var(--warning-soft); color: var(--warning-ink); }
.sev.info { background: var(--info-soft); color: var(--info-ink); }
.sev.ok { background: var(--success-soft); color: var(--success-ink); }

/* 12. ---------- Tabs & segmented controls ------------------ */
.segmented {
    display: inline-flex;
    padding: 3px;
    gap: 2px;
    background: var(--surface-3);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
}

.segmented button {
    min-height: 26px;
    padding: 0 11px;
    border: 0;
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: background 110ms var(--ease), color 110ms var(--ease);
}

.segmented button:hover:not(.on) {
    color: var(--ink);
}

.segmented button.on {
    background: var(--surface);
    color: var(--accent-ink);
    box-shadow: var(--shadow-xs);
}

.tabset {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 0;
}

.tab {
    padding: 9px 14px;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    transition: color 110ms var(--ease), border-color 110ms var(--ease);
}

.tab:hover {
    color: var(--ink);
}

.tab.on {
    color: var(--accent-ink);
    border-bottom-color: var(--accent);
}

/* 13. ---------- Forms --------------------------------------- */
.field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.field-label,
label.fl {
    font-size: 0.73rem;
    font-weight: 600;
    color: var(--ink-soft);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    display: flex;
    align-items: center;
    gap: 6px;
}

.field-label .req {
    color: var(--danger);
    font-weight: 700;
}

.field-hint {
    font-size: 0.74rem;
    color: var(--muted);
}

.field-error {
    font-size: 0.74rem;
    color: var(--danger);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}

input[type="text"],
input[type="search"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input:not([type]),
select,
textarea {
    width: 100%;
    min-height: 36px;
    padding: 7px 11px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    transition: border-color 110ms var(--ease), box-shadow 110ms var(--ease);
}

textarea {
    resize: vertical;
    font-family: var(--mono);
    font-size: 0.82rem;
    line-height: 1.55;
}

input:hover:not(:disabled),
select:hover:not(:disabled),
textarea:hover {
    border-color: var(--muted-soft);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

input:disabled,
select:disabled {
    background: var(--surface-2);
    color: var(--muted);
    cursor: not-allowed;
}

input::placeholder {
    color: var(--faint);
}

select {
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%235b6b80' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m4 6 4 4 4-4'/></svg>");
    background-repeat: no-repeat;
    background-position: right 9px center;
    padding-right: 30px;
}

input[type="range"] {
    width: 100%;
    min-height: auto;
    padding: 0;
    border: 0;
    background: transparent;
    accent-color: var(--accent);
    cursor: pointer;
}

input[type="range"]:focus {
    box-shadow: none;
}

input.sm,
select.sm {
    min-height: 30px;
    padding: 4px 9px;
    font-size: 0.8rem;
}

select.sm {
    padding-right: 26px;
}

.input-icon {
    position: relative;
}

.input-icon .ic {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted-soft);
    pointer-events: none;
}

.input-icon input {
    padding-left: 32px;
}

.input-icon .clear-x {
    position: absolute;
    right: 7px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    min-height: 20px;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--muted-soft);
    cursor: pointer;
    box-shadow: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.input-icon .clear-x:hover {
    background: var(--surface-3);
    color: var(--ink);
}

.form-grid {
    display: grid;
    gap: 13px;
}

.form-divider {
    margin: 6px 0 2px;
    padding-top: 13px;
    border-top: 1px dashed var(--line-strong);
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted-soft);
    display: flex;
    align-items: center;
    gap: 7px;
}

.form-divider .ic {
    color: var(--accent-ink);
}

.form-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 4px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.form-actions .btn {
    flex: 1 1 auto;
}

.switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    cursor: pointer;
    user-select: none;
}

.switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.switch-track {
    width: 38px;
    height: 21px;
    border-radius: 999px;
    background: var(--line-strong);
    flex-shrink: 0;
    transition: background 140ms var(--ease);
    position: relative;
}

.switch-track::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    background: #fff;
    box-shadow: var(--shadow-xs);
    transition: transform 140ms var(--ease);
}

.switch input:checked + .switch-track {
    background: var(--accent);
}

.switch input:checked + .switch-track::after {
    transform: translateX(17px);
}

.switch input:focus-visible + .switch-track {
    box-shadow: 0 0 0 3px var(--accent-ring);
}

.switch-label {
    font-size: 0.82rem;
    color: var(--ink-soft);
    font-weight: 500;
}

/* 14. ---------- Modal --------------------------------------- */
.scrim {
    position: fixed;
    inset: 0;
    background: rgba(8, 15, 28, 0.55);
    backdrop-filter: blur(3px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: fade-in 130ms var(--ease);
}

.modal {
    display: block;
    width: 100%;
    max-width: 560px;
    max-height: 88vh;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-pop);
    animation: pop-in 150ms var(--ease);
}

.modal.wide {
    max-width: 760px;
}

.modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--line);
}

.modal-head h2 {
    font-size: 1.06rem;
    display: flex;
    align-items: center;
    gap: 9px;
}

.modal-head .ic-warn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--danger-soft);
    color: var(--danger-ink);
    flex-shrink: 0;
}

.modal-body {
    padding: 18px 20px;
}

.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 20px;
    border-top: 1px solid var(--line);
    background: var(--surface-2);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.choice {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface-2);
    margin-bottom: 11px;
    cursor: pointer;
    transition: border-color 120ms var(--ease), background 120ms var(--ease);
}

.choice:hover {
    border-color: var(--accent);
    background: var(--accent-softer);
}

.choice.on {
    border-color: var(--accent);
    background: var(--accent-softer);
    box-shadow: 0 0 0 1px var(--accent);
}

.choice-radio {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--line-strong);
    flex-shrink: 0;
    margin-top: 1px;
    position: relative;
}

.choice.on .choice-radio {
    border-color: var(--accent);
}

.choice.on .choice-radio::after {
    content: "";
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    background: var(--accent);
}

.choice-body strong {
    display: block;
    font-size: 0.88rem;
    color: var(--ink);
    margin-bottom: 3px;
}

.choice-body p {
    font-size: 0.8rem;
    color: var(--muted);
    line-height: 1.5;
}

/* 15. ---------- Drawer -------------------------------------- */
.drawer-scrim {
    position: fixed;
    inset: 0;
    background: rgba(8, 15, 28, 0.42);
    backdrop-filter: blur(2px);
    z-index: 150;
    animation: fade-in 130ms var(--ease);
}

.drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(560px, 94vw);
    background: var(--surface);
    border-left: 1px solid var(--line);
    box-shadow: var(--shadow-pop);
    z-index: 151;
    display: flex;
    flex-direction: column;
    animation: slide-in 200ms var(--ease);
}

.drawer.lg {
    width: min(760px, 96vw);
}

.drawer-head {
    flex-shrink: 0;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.drawer-eyebrow {
    font-size: 0.66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--accent-ink);
    margin-bottom: 3px;
}

.drawer-head h2 {
    font-size: 1.08rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px 20px;
}

.drawer-foot {
    flex-shrink: 0;
    padding: 13px 20px;
    border-top: 1px solid var(--line);
    background: var(--surface-2);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* definition list */
.dl {
    display: grid;
    grid-template-columns: minmax(110px, max-content) 1fr;
    gap: 1px;
    background: var(--line-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.dl dt {
    padding: 8px 12px;
    background: var(--surface-2);
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    display: flex;
    align-items: center;
}

.dl dd {
    margin: 0;
    padding: 8px 12px;
    background: var(--surface);
    font-size: 0.84rem;
    color: var(--ink-soft);
    word-break: break-word;
}

/* 16. ---------- Toasts -------------------------------------- */
.toast-region {
    position: fixed;
    bottom: calc(var(--statusbar-h) + 14px);
    right: 18px;
    z-index: 250;
    display: flex;
    flex-direction: column;
    gap: 9px;
    max-width: min(400px, calc(100vw - 36px));
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    position: relative;
    display: flex !important;
    opacity: 1 !important;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 13px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: toast-in 200ms var(--ease);
}

.toast.leaving {
    animation: toast-out 180ms var(--ease) forwards;
}

.toast-accent {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--muted-soft);
}

.toast.success .toast-accent { background: var(--success); }
.toast.error .toast-accent { background: var(--danger); }
.toast.info .toast-accent { background: var(--info); }

.toast-ic {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.toast.success .toast-ic { background: var(--success-soft); color: var(--success-ink); }
.toast.error .toast-ic { background: var(--danger-soft); color: var(--danger-ink); }
.toast.info .toast-ic { background: var(--info-soft); color: var(--info-ink); }

.toast-body {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--ink);
}

.toast-msg {
    font-size: 0.79rem;
    color: var(--muted);
    margin-top: 1px;
    word-wrap: break-word;
}

.toast-x {
    width: 20px;
    height: 20px;
    min-height: 20px;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--muted-soft);
    cursor: pointer;
    box-shadow: none;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.toast-x:hover {
    background: var(--surface-3);
    color: var(--ink);
}

.toast-progress {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 2px;
    background: var(--accent);
    opacity: 0.5;
    animation: toast-bar linear forwards;
}

/* 17. ---------- Timeline ------------------------------------ */
.timeline {
    position: relative;
    padding-left: 26px;
}

.timeline::before {
    content: "";
    position: absolute;
    left: 8px;
    top: 4px;
    bottom: 4px;
    width: 2px;
    background: var(--line-strong);
}

.tl-item {
    position: relative;
    padding: 0 0 18px 0;
}

.tl-item:last-child {
    padding-bottom: 0;
}

.tl-node {
    position: absolute;
    left: -26px;
    top: 1px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--surface);
    border: 2px solid var(--accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.tl-node.open {
    border-color: var(--success);
}

.tl-node.open::after {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--success);
}

.tl-node.closed {
    border-color: var(--muted-soft);
}

.tl-node.closed::after {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--muted-soft);
}

.tl-card {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 11px 13px;
}

.tl-card.current {
    border-color: var(--accent);
    background: var(--accent-softer);
}

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

.tl-head strong {
    font-size: 0.84rem;
}

.tl-times {
    display: flex;
    flex-wrap: wrap;
    gap: 5px 14px;
    font-size: 0.76rem;
    color: var(--muted);
    font-family: var(--mono);
}

.tl-times em {
    font-style: normal;
    color: var(--muted-soft);
    text-transform: uppercase;
    font-size: 0.64rem;
    letter-spacing: 0.04em;
    margin-right: 4px;
}

/* bitemporal grid plot */
.bitemporal-plot {
    position: relative;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background:
        repeating-linear-gradient(0deg, transparent, transparent 31px, var(--line-soft) 31px, var(--line-soft) 32px),
        repeating-linear-gradient(90deg, transparent, transparent 47px, var(--line-soft) 47px, var(--line-soft) 48px);
    background-color: var(--surface-2);
    overflow: hidden;
}

/* 18. ---------- Skeletons, empty, loading ------------------ */
.skeleton {
    border-radius: var(--radius-sm);
    background: linear-gradient(100deg, var(--surface-3) 30%, var(--surface-2) 50%, var(--surface-3) 70%);
    background-size: 240% 100%;
    animation: shimmer 1.3s linear infinite;
}

.skeleton.line {
    height: 12px;
    margin: 7px 0;
}

.skeleton.line.w60 { width: 60%; }
.skeleton.line.w40 { width: 40%; }
.skeleton.line.w80 { width: 80%; }

.skeleton-card {
    height: 96px;
    border-radius: var(--radius-lg);
}

.spinner {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2.4px solid var(--line-strong);
    border-top-color: var(--accent);
    animation: spin 0.7s linear infinite;
    flex-shrink: 0;
}

.spinner.lg {
    width: 30px;
    height: 30px;
    border-width: 3px;
}

.loading-block {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 28px;
    color: var(--muted);
}

.empty {
    text-align: center;
    padding: 44px 26px;
}

.empty-ic {
    width: 52px;
    height: 52px;
    margin: 0 auto 14px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-3);
    color: var(--muted-soft);
}

.empty h3 {
    font-size: 1rem;
    margin-bottom: 5px;
}

.empty p {
    color: var(--muted);
    font-size: 0.85rem;
    max-width: 46ch;
    margin: 0 auto 14px;
    line-height: 1.6;
}

.empty .btn-row {
    justify-content: center;
}

/* progress / meter */
.meter {
    height: 7px;
    border-radius: 999px;
    background: var(--surface-3);
    overflow: hidden;
}

.meter-fill {
    height: 100%;
    border-radius: 999px;
    background: var(--accent);
    transition: width 300ms var(--ease);
}

.meter-fill.warning { background: var(--warning); }
.meter-fill.danger { background: var(--danger); }
.meter-fill.success { background: var(--success); }

/* 19. ---------- Command palette ----------------------------- */
.cmdk-scrim {
    position: fixed;
    inset: 0;
    background: rgba(8, 15, 28, 0.5);
    backdrop-filter: blur(3px);
    z-index: 300;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 12vh 20px 20px;
    animation: fade-in 110ms var(--ease);
}

.cmdk {
    width: 100%;
    max-width: 580px;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-pop);
    overflow: hidden;
    animation: pop-in 140ms var(--ease);
}

.cmdk-search {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 16px;
    border-bottom: 1px solid var(--line);
}

.cmdk-search .ic {
    color: var(--muted-soft);
    flex-shrink: 0;
}

.cmdk-search input {
    border: 0;
    padding: 0;
    min-height: auto;
    background: transparent;
    font-size: 0.95rem;
}

.cmdk-search input:focus {
    box-shadow: none;
}

.cmdk-list {
    max-height: 52vh;
    overflow-y: auto;
    padding: 6px;
}

.cmdk-group-label {
    padding: 8px 10px 4px;
    font-size: 0.64rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--muted-soft);
}

.cmdk-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 11px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--ink-soft);
}

.cmdk-item .ic {
    color: var(--muted);
    flex-shrink: 0;
}

.cmdk-item.active {
    background: var(--accent-softer);
    color: var(--accent-ink);
}

.cmdk-item.active .ic {
    color: var(--accent-ink);
}

.cmdk-item-label {
    flex: 1;
    font-size: 0.86rem;
    font-weight: 500;
}

.cmdk-item-hint {
    font-size: 0.72rem;
    color: var(--muted-soft);
}

.cmdk-empty {
    padding: 26px;
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
}

.cmdk-foot {
    display: flex;
    gap: 14px;
    padding: 8px 14px;
    border-top: 1px solid var(--line);
    background: var(--surface-2);
    font-size: 0.7rem;
    color: var(--muted-soft);
}

.cmdk-foot span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

/* 20. ---------- Page-specific ------------------------------- */
/* temporal banner */
.temporal-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 13px 17px;
    border: 1px solid var(--line);
    border-left-width: 4px;
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.temporal-bar.now {
    border-left-color: var(--accent);
}

.temporal-bar.travel {
    border-left-color: var(--warning);
    background: linear-gradient(95deg, var(--warning-soft), var(--surface) 36%);
}

.temporal-ic {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-soft);
    color: var(--accent-ink);
    flex-shrink: 0;
}

.temporal-bar.travel .temporal-ic {
    background: var(--warning-soft);
    color: var(--warning-ink);
}

.temporal-body {
    flex: 1;
    min-width: 0;
}

.temporal-body strong {
    font-size: 0.9rem;
    display: block;
}

.temporal-times {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
    margin-top: 2px;
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--muted);
}

.temporal-times em {
    font-style: normal;
    text-transform: uppercase;
    font-size: 0.62rem;
    letter-spacing: 0.05em;
    color: var(--muted-soft);
    margin-right: 5px;
}

/* time machine controls */
.time-machine {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 16px;
    align-items: end;
}

.time-axis label {
    font-size: 0.68rem;
    margin-bottom: 4px;
}

.time-axis input[type="datetime-local"] {
    min-height: 32px;
    font-size: 0.81rem;
}

.time-axis input[type="range"] {
    margin-top: 8px;
}

/* model summary list */
.model-list {
    display: flex;
    flex-direction: column;
}

.model-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 4px;
    border-top: 1px solid var(--line-soft);
}

.model-row:first-child {
    border-top: 0;
}

.model-row-ic {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--accent-softer);
    color: var(--accent-ink);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.model-row-main {
    flex: 1;
    min-width: 0;
}

.model-row-main b {
    font-size: 0.86rem;
    color: var(--ink);
}

.model-row-main .code-key {
    margin-left: 7px;
}

.model-row-meta {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.model-row-bar {
    margin-top: 5px;
}

/* nav cards */
.launch-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
}

.launch-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 17px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    color: var(--ink);
    text-decoration: none;
    transition: box-shadow 160ms var(--ease), transform 160ms var(--ease), border-color 160ms var(--ease);
}

.launch-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: var(--line-strong);
    text-decoration: none;
}

.launch-card-ic {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-soft);
    color: var(--accent-ink);
}

.launch-card b {
    font-size: 0.98rem;
}

.launch-card p {
    flex: 1;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.55;
}

.launch-card-go {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--accent-ink);
    font-size: 0.8rem;
    font-weight: 600;
}

/* data editor layout */
.editor-layout {
    display: grid;
    grid-template-columns: 372px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.editor-rail {
    position: sticky;
    top: 16px;
}

.editor-mode-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.editor-mode-pill.create {
    background: var(--accent-soft);
    color: var(--accent-ink);
}

.editor-mode-pill.edit {
    background: var(--warning-soft);
    color: var(--warning-ink);
}

.entity-block {
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.entity-block-head {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 15px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
    flex-wrap: wrap;
}

.entity-block-head h3 {
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.entity-block-tools {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ref-cell {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
}

.ref-name {
    color: var(--muted);
    font-size: 0.8rem;
}

.row-actions {
    display: inline-flex;
    gap: 5px;
}

/* designer */
.designer-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 366px;
    gap: 18px;
    align-items: start;
}

.designer-rail {
    position: sticky;
    top: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.schema-card {
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
    overflow: hidden;
}

.schema-card-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
}

.schema-card-ic {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--accent-softer);
    color: var(--accent-ink);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.prop-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    border-top: 1px solid var(--line-soft);
    font-size: 0.83rem;
}

.prop-row .prop-name {
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--ink-soft);
}

.prop-row .req-dot {
    color: var(--danger);
    font-weight: 700;
}

/* realtime feed */
.feed {
    display: flex;
    flex-direction: column;
    max-height: 340px;
    overflow-y: auto;
}

.feed-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 4px;
    border-top: 1px solid var(--line-soft);
}

.feed-row:first-child {
    border-top: 0;
}

.feed-row-ic {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--accent-softer);
    color: var(--accent-ink);
}

.feed-row-ic.create { background: var(--success-soft); color: var(--success-ink); }
.feed-row-ic.update { background: var(--info-soft); color: var(--info-ink); }
.feed-row-ic.delete { background: var(--danger-soft); color: var(--danger-ink); }
.feed-row-ic.close { background: var(--warning-soft); color: var(--warning-ink); }

.feed-row-main {
    flex: 1;
    min-width: 0;
}

.feed-row-main b {
    font-size: 0.8rem;
    color: var(--ink);
}

.feed-row-main .feed-target {
    font-family: var(--mono);
    font-size: 0.74rem;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.feed-row-time {
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--muted-soft);
    flex-shrink: 0;
}

.feed-flash {
    animation: flash-row 1.1s var(--ease);
}

/* connection status inline */
.conn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--muted);
}

.conn .status-dot {
    width: 8px;
    height: 8px;
}

/* integrity */
.integrity-hero {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 20px 22px;
}

.integrity-shield {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.integrity-shield.ok { background: var(--success-soft); color: var(--success-ink); }
.integrity-shield.bad { background: var(--danger-soft); color: var(--danger-ink); }

.integrity-hero h2 {
    font-size: 1.3rem;
}

.checklist {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
}

.checklist-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface-2);
}

.checklist-item .ic {
    color: var(--success);
}

.checklist-item .count {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.checklist-item .lbl {
    font-size: 0.74rem;
    color: var(--muted);
}

/* audit */
.audit-row-ic {
    width: 26px;
    height: 26px;
    border-radius: 7px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* misc */
.kv-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
}

.kv-inline > div {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.kv-inline dt {
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted-soft);
    font-weight: 600;
}

.kv-inline dd {
    margin: 0;
    font-size: 0.83rem;
    color: var(--ink-soft);
    font-weight: 600;
}

hr.rule {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 16px 0;
}

/* responsive grid helpers */
.cols-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: start;
}

.cols-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    align-items: start;
}

.split-main {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(326px, 1fr);
    gap: 16px;
    align-items: start;
}

@media (max-width: 1080px) {
    .split-main {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 880px) {
    .cols-2,
    .cols-3 {
        grid-template-columns: 1fr;
    }
}

.tooltip-host {
    position: relative;
}

/* popovers & menus */
.topbar-pop-wrap {
    position: relative;
}

.pop-scrim {
    position: fixed;
    inset: 0;
    z-index: 90;
    background: transparent;
}

.popover {
    position: absolute;
    top: calc(100% + 7px);
    z-index: 95;
    width: 274px;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-pop);
    overflow: hidden;
    animation: pop-in 130ms var(--ease);
}

.popover.right {
    right: 0;
}

.popover-head {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 10px 13px;
    border-bottom: 1px solid var(--line);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
}

.popover-head .ic {
    color: var(--accent-ink);
}

.popover-search {
    padding: 9px 11px 5px;
}

.popover-search input {
    min-height: 32px;
    font-size: 0.82rem;
}

.popover-list {
    max-height: 260px;
    overflow-y: auto;
    padding: 5px;
}

.popover-foot {
    padding: 8px 13px;
    border-top: 1px solid var(--line);
    background: var(--surface-2);
    font-size: 0.7rem;
    color: var(--muted-soft);
    line-height: 1.45;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 7px 9px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--ink-soft);
    font-size: 0.84rem;
    text-align: left;
    cursor: pointer;
    box-shadow: none;
}

.menu-item:hover {
    background: var(--surface-3);
}

.menu-item.on {
    background: var(--accent-softer);
    color: var(--accent-ink);
}

.menu-item .ic {
    color: var(--accent-ink);
}

.menu-item-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

.subject-avatar.sm {
    width: 24px;
    height: 24px;
    font-size: 0.62rem;
}

.subject-avatar.new {
    background: var(--surface-3);
    color: var(--muted);
}

.nav-toggle {
    display: none;
}

@media (max-width: 920px) {
    .nav-toggle {
        display: inline-flex;
    }
}

#blazor-error-ui {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: none;
    padding: 11px 20px;
    background: var(--warning-soft);
    color: var(--warning-ink);
    border-top: 1px solid var(--warning);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.12);
    font-size: 0.85rem;
}

#blazor-error-ui .dismiss {
    position: absolute;
    right: 14px;
    top: 9px;
    cursor: pointer;
    font-size: 1.1rem;
}

#blazor-error-ui .reload {
    font-weight: 600;
}

/* ---- charts, diff, matrix, chips, settings ----------------- */
button.chip {
    font: inherit;
    box-shadow: none;
}

.chip.chip-link {
    cursor: pointer;
    transition: border-color 110ms var(--ease), background 110ms var(--ease), color 110ms var(--ease);
}

.chip.chip-link:hover {
    border-color: var(--accent);
    color: var(--accent-ink);
    background: var(--accent-soft);
}

.pop-anchor {
    position: relative;
}

.hbar-chart {
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.hbar-row {
    display: grid;
    grid-template-columns: 124px minmax(0, 1fr) 46px;
    gap: 11px;
    align-items: center;
}

.hbar-label {
    font-size: 0.81rem;
    color: var(--ink-soft);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hbar-track {
    height: 20px;
    border-radius: var(--radius-xs);
    background: var(--surface-3);
    overflow: hidden;
}

.hbar-fill {
    height: 100%;
    border-radius: var(--radius-xs);
    background: linear-gradient(90deg, var(--accent), var(--accent-deep));
    min-width: 3px;
    transition: width 420ms var(--ease);
}

.hbar-fill.violet { background: linear-gradient(90deg, var(--violet), #6d28d9); }
.hbar-fill.info { background: linear-gradient(90deg, var(--info), #1e40af); }
.hbar-fill.warning { background: linear-gradient(90deg, var(--warning), #b45309); }

.hbar-value {
    font-family: var(--mono);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ink-soft);
    text-align: right;
}

.diff-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 7px;
    border-radius: 999px;
    font-size: 0.66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.diff-tag.same { background: var(--surface-3); color: var(--muted); }
.diff-tag.changed { background: var(--warning-soft); color: var(--warning-ink); }
.diff-tag.added { background: var(--success-soft); color: var(--success-ink); }
.diff-tag.removed { background: var(--danger-soft); color: var(--danger-ink); }

tr.diff-changed td { background: color-mix(in srgb, var(--warning) 8%, transparent); }
tr.diff-added td { background: color-mix(in srgb, var(--success) 8%, transparent); }
tr.diff-removed td { background: color-mix(in srgb, var(--danger) 8%, transparent); }

.diff-old { color: var(--muted); text-decoration: line-through; }
.diff-new { color: var(--ink); font-weight: 600; }

.matrix td.mx-cell {
    text-align: center;
}

.mx-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 6px;
}

.mx-mark.rw { background: var(--warning-soft); color: var(--warning-ink); }
.mx-mark.r { background: var(--accent-soft); color: var(--accent-ink); }
.mx-mark.none { color: var(--faint); }

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

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

.setting-row-main b {
    font-size: 0.88rem;
    color: var(--ink);
}

.setting-row-main p {
    font-size: 0.79rem;
    color: var(--muted);
    margin-top: 2px;
    max-width: 60ch;
}

.setting-row-control {
    flex-shrink: 0;
}

/* ---- access policies (ABAC) ------------------------------- */
.policy-verdict {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
}

.policy-verdict.allow {
    background: var(--success-soft);
    border-color: color-mix(in srgb, var(--success) 34%, transparent);
}

.policy-verdict.deny {
    background: var(--danger-soft);
    border-color: color-mix(in srgb, var(--danger) 34%, transparent);
}

.policy-verdict-ic {
    width: 44px;
    height: 44px;
    border-radius: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #fff;
}

.policy-verdict.allow .policy-verdict-ic { background: var(--success); }
.policy-verdict.deny .policy-verdict-ic { background: var(--danger); }

.policy-verdict strong {
    display: block;
    font-size: 0.98rem;
}

.policy-verdict.allow strong { color: var(--success-ink); }
.policy-verdict.deny strong { color: var(--danger-ink); }

.policy-verdict p {
    margin-top: 2px;
    font-size: 0.8rem;
    color: var(--ink-soft);
    line-height: 1.5;
}

.sim-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.sim-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 600;
}

.sim-check.ok {
    background: var(--success-soft);
    color: var(--success-ink);
    border-color: color-mix(in srgb, var(--success) 26%, transparent);
}

.sim-check.bad {
    background: var(--danger-soft);
    color: var(--danger-ink);
    border-color: color-mix(in srgb, var(--danger) 26%, transparent);
}

.cond-row {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) 132px minmax(0, 1fr) 34px;
    gap: 8px;
    align-items: center;
}

/* 21. ---------- Responsive ---------------------------------- */
@media (max-width: 1180px) {
    .editor-layout,
    .designer-grid {
        grid-template-columns: 1fr;
    }

    .editor-rail,
    .designer-rail {
        position: static;
    }
}

@media (max-width: 920px) {
    .app-sidebar {
        transform: translateX(-100%);
        transition: transform 200ms var(--ease);
    }

    .app-shell.nav-open .app-sidebar {
        transform: translateX(0);
        box-shadow: var(--shadow-pop);
    }

    .app-body {
        margin-left: 0 !important;
    }

    .nav-scrim {
        position: fixed;
        inset: 0;
        background: rgba(8, 15, 28, 0.5);
        z-index: 55;
    }

    .time-machine {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 680px) {
    .app-content-inner {
        padding: 18px 16px 36px;
    }

    .app-topbar {
        padding: 0 14px;
        gap: 9px;
    }

    .cmd-trigger .cmd-trigger-label,
    .cmd-trigger kbd,
    .subject-switch-meta span {
        display: none;
    }

    .page-head h1 {
        font-size: 1.26rem;
    }

    .app-statusbar {
        overflow-x: auto;
    }
}

/* 22. ---------- Animations ---------------------------------- */
@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

@keyframes shimmer {
    to { background-position: -240% 0; }
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes pop-in {
    from { opacity: 0; transform: scale(0.97) translateY(6px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes slide-in {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

@keyframes toast-in {
    from { opacity: 0; transform: translateX(28px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
    to { opacity: 0; transform: translateX(28px); height: 0; margin: 0; padding-top: 0; padding-bottom: 0; }
}

@keyframes toast-bar {
    from { width: 100%; }
    to { width: 0%; }
}

@keyframes flash-row {
    0% { background: var(--accent-soft); }
    100% { background: transparent; }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
