:root {
    --bg: #f5f7fa;
    --surface: #ffffff;
    --ink: #20242a;
    --muted: #667085;
    --border: #d7dce3;
    --border-soft: #e8ebef;
    --black: #141414;
    --black-soft: #1f1f1f;
    --amber: #d97706;
    --amber-soft: #fff7ed;
    --green: #2f9b63;
    --red: #b42318;
    --shadow: 0 18px 44px rgba(20, 20, 20, 0.07);
    --control-bg: #fafbfc;
    --topbar-bg: #ffffff;
    --table-head-bg: #fafbfc;
    --row-border: #eef0f3;
    --button-secondary-bg: #ffffff;
    --button-dark-bg: #20242a;
    --button-dark-text: #ffffff;
    --guardrail-bg: #fff7ed;
    --guardrail-border: #fed7aa;
    --guardrail-text: #92400e;
    --log-bg: #141414;
    --log-border: #2b2b2b;
    --log-text: #d4d4d4;
    --font-sans: "Inter", "Segoe UI", Arial, sans-serif;
    --font-mono: "Geist Mono", "Cascadia Mono", Consolas, monospace;
}

:root[data-theme="dark"] {
    --bg: #0f1115;
    --surface: #171a21;
    --ink: #f2f4f7;
    --muted: #a5adba;
    --border: #303744;
    --border-soft: #252b35;
    --black: #090b0f;
    --black-soft: #141821;
    --amber: #f59e0b;
    --amber-soft: #2a1d0d;
    --green: #35b979;
    --red: #ef6258;
    --shadow: 0 18px 44px rgba(0, 0, 0, 0.36);
    --control-bg: #11151c;
    --topbar-bg: #151922;
    --table-head-bg: #11151c;
    --row-border: #252b35;
    --button-secondary-bg: #151922;
    --button-dark-bg: #f2f4f7;
    --button-dark-text: #11151c;
    --guardrail-bg: #251a0d;
    --guardrail-border: #6f4514;
    --guardrail-text: #f8c983;
    --log-bg: #090b0f;
    --log-border: #242a34;
    --log-text: #d6dbe4;
}

* {
    box-sizing: border-box;
}

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

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

.is-hidden {
    display: none !important;
}

.theme-toggle {
    height: 42px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 9px;
    padding: 0 12px;
    border: 1px solid #343434;
    border-radius: 8px;
    background: var(--black-soft);
    color: #ffffff;
    box-shadow: none;
    font-size: 13px;
    font-weight: 800;
}

.theme-toggle__icon {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.login-screen {
    min-height: 100vh;
    display: flex;
}

.auth-rail {
    width: 520px;
    min-height: 100vh;
    padding: 64px 56px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: var(--black);
    color: #ffffff;
}

.auth-rail__main {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.brand-mark {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--amber);
}

.brand-mark svg {
    width: 28px;
    height: 28px;
    fill: none;
    stroke: var(--black);
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.auth-rail h1 {
    margin: 0 0 16px;
    font-size: 42px;
    line-height: 46px;
    letter-spacing: 0;
}

.auth-rail p {
    width: 360px;
    margin: 0;
    color: #d1d5db;
    font-size: 16px;
    line-height: 24px;
}

.auth-rail__foot {
    display: flex;
    flex-direction: column;
    gap: 10px;
    color: #a3a3a3;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 18px;
}

.health-card {
    width: 100%;
    padding: 18px;
    border: 1px solid #343434;
    border-radius: 8px;
    background: var(--black-soft);
}

.health-card h2 {
    margin: 0 0 14px;
    font-size: 14px;
}

.health-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 24px;
    color: #e5e7eb;
    font-size: 13px;
}

.dot {
    width: 8px;
    height: 8px;
    display: inline-block;
    flex: 0 0 auto;
    border-radius: 999px;
    background: var(--muted);
}

.dot--ok {
    background: var(--green);
}

.dot--warn {
    background: var(--amber);
}

.dot--bad {
    background: var(--red);
}

.login-area {
    flex: 1;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 80px;
}

.login-card {
    width: 470px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    padding: 36px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.login-card h2 {
    margin: 0 0 10px;
    font-size: 30px;
    line-height: 36px;
}

.login-card p {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 21px;
}

.field,
.auto-form label {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.field span,
.auto-form span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.field input,
.auto-form input,
.auto-form select,
.topbar select,
.table-tools input {
    height: 40px;
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--control-bg);
    color: var(--ink);
    padding: 0 12px;
    outline: none;
}

.field input {
    height: 54px;
}

.btn {
    height: 40px;
    border-radius: 6px;
    border: 0;
    padding: 0 14px;
    font-weight: 800;
}

.btn--primary {
    background: var(--amber);
    color: var(--black);
}

.btn--secondary {
    border: 1px solid var(--border);
    background: var(--button-secondary-bg);
    color: var(--ink);
    font-weight: 600;
}

.btn--success {
    background: var(--green);
    color: #ffffff;
}

.btn--danger {
    background: var(--red);
    color: #ffffff;
}

.btn--dark {
    background: var(--button-dark-bg);
    color: var(--button-dark-text);
}

.guardrail {
    padding: 12px;
    border: 1px solid var(--guardrail-border);
    border-radius: 6px;
    background: var(--guardrail-bg);
    color: var(--guardrail-text);
    font-size: 12px;
    line-height: 17px;
}

.form-error {
    min-height: 18px;
    color: var(--red);
    font-size: 13px;
    font-weight: 700;
}

.app-shell {
    min-height: 100vh;
    display: flex;
}

.sidebar {
    width: 260px;
    min-height: 100vh;
    padding: 28px 18px;
    display: flex;
    flex: 0 0 auto;
    flex-direction: column;
    justify-content: space-between;
    background: var(--black);
    color: #ffffff;
}

.sidebar__top {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 10px;
}

.sidebar-brand__mark {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 7px;
    background: var(--amber);
    color: var(--black);
    font-weight: 900;
    font-size: 12px;
}

.sidebar-brand strong {
    display: block;
    font-size: 16px;
}

.sidebar-brand span,
.session-card span {
    color: #a3a3a3;
    font-family: var(--font-mono);
    font-size: 11px;
}

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

.nav__item {
    height: 40px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 12px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #d4d4d4;
    text-align: left;
    font-size: 14px;
}

.nav__icon {
    width: 20px;
    height: 20px;
    display: flex;
    flex: 0 0 20px;
    align-items: center;
    justify-content: center;
    color: #a3a3a3;
}

.nav__icon svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.nav__item.is-active {
    background: #2b2b2b;
    color: #ffffff;
    font-weight: 800;
}

.nav__item.is-active .nav__icon {
    color: var(--amber);
}

.nav__item:hover {
    background: #242424;
    color: #ffffff;
}

.nav__item:hover .nav__icon {
    color: #ffffff;
}

.nav__item.is-active:hover .nav__icon {
    color: var(--amber);
}

.session-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 10px;
    border: 1px solid #343434;
    border-radius: 8px;
    background: var(--black-soft);
}

.sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.session-card strong {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.dashboard {
    flex: 1;
    min-width: 0;
    background: var(--bg);
}

.topbar {
    height: 74px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 34px;
    border-bottom: 1px solid var(--border);
    background: var(--topbar-bg);
}

.topbar__left,
.topbar__actions,
.dashboard-actions,
.table-tools {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar__left span,
.topbar code {
    color: var(--muted);
    font-size: 14px;
}

.topbar code {
    font-family: var(--font-mono);
    font-size: 12px;
}

.topbar select {
    width: 150px;
    height: 36px;
    font-weight: 800;
}

.toolbar-input {
    height: 40px;
    min-width: 190px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--button-secondary-bg);
    color: var(--ink);
    padding: 0 12px;
    outline: none;
}

.dashboard-body {
    display: flex;
    flex-direction: column;
    gap: 22px;
    padding: 28px 34px 34px;
}

.page-view {
    display: none;
    flex-direction: column;
    gap: 22px;
}

.page-view.is-active {
    display: flex;
}

.dashboard-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
}

.dashboard-header h2 {
    margin: 0 0 8px;
    font-size: 32px;
    line-height: 38px;
}

.dashboard-header p {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.metrics article {
    min-height: 104px;
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border-right: 1px solid var(--border-soft);
}

.metrics article:last-child {
    border-right: 0;
}

.metrics span {
    color: var(--muted);
    font-size: 13px;
}

.metrics strong {
    font-family: var(--font-mono);
    font-size: 32px;
    line-height: 34px;
}

.metrics--compact article {
    min-height: 92px;
}

.metric-label {
    font-family: var(--font-sans) !important;
    font-size: 20px !important;
    line-height: 26px !important;
}

.text-ok {
    color: var(--green);
}

.text-warn {
    color: var(--amber);
}

.work-row,
.bottom-row {
    display: grid;
    grid-template-columns: minmax(520px, 1fr) 360px;
    gap: 22px;
}

.feature-grid,
.accounts-grid {
    display: grid;
    grid-template-columns: minmax(360px, 0.9fr) minmax(420px, 1.1fr);
    gap: 22px;
}

.accounts-grid {
    grid-template-columns: minmax(480px, 1fr) minmax(520px, 1fr);
}

.panel,
.log-panel {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.panel__head {
    min-height: 72px;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-soft);
}

.panel__head h3 {
    margin: 0 0 4px;
    font-size: 18px;
}

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

.voucher-panel {
    min-height: 382px;
}

.action-panel {
    min-height: 382px;
}

.panel--large {
    min-height: 520px;
}

.table-tools input {
    width: 210px;
}

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

.table-wrap--full {
    max-height: 560px;
    overflow: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    height: 42px;
    padding: 0 14px;
    border-bottom: 1px solid var(--border-soft);
    background: var(--table-head-bg);
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    text-align: left;
    text-transform: uppercase;
}

td {
    height: 52px;
    padding: 0 14px;
    border-bottom: 1px solid var(--row-border);
    color: var(--ink);
    font-size: 13px;
}

td:first-child,
td:nth-child(4),
td:nth-child(5) {
    font-family: var(--font-mono);
}

td:nth-child(2) {
    font-weight: 800;
}

.auto-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px 18px 18px;
}

.control-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px 18px 18px;
}

.control-stack label {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.control-stack span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.control-stack input {
    height: 40px;
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--control-bg);
    color: var(--ink);
    padding: 0 12px;
    outline: none;
}

.split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.auto-form .btn {
    width: 100%;
}

.log-panel {
    min-height: 204px;
    background: var(--log-bg);
    border-color: var(--log-border);
}

.log-panel--page {
    min-height: 320px;
}

.log-panel--full {
    min-height: 640px;
}

.log-panel__head {
    height: 48px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--log-border);
    color: #ffffff;
}

.log-panel__head strong {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
}

.log-panel__head span {
    color: #a3a3a3;
    font-family: var(--font-mono);
    font-size: 11px;
}

.logs {
    max-height: 180px;
    overflow: auto;
    padding: 14px 16px;
    color: var(--log-text);
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 18px;
}

.logs--page {
    max-height: 320px;
}

.logs--full {
    max-height: 640px;
}

.log-line {
    margin-bottom: 7px;
    white-space: nowrap;
}

.log-time {
    color: #858585;
}

.log-source {
    color: var(--muted);
}

.log-level--SUCCESS,
.log-level--INFO {
    color: var(--green);
}

.log-level--WARN {
    color: var(--amber);
}

.log-level--ERROR {
    color: #ff9a93;
}

.health-panel {
    min-height: 204px;
}

.health-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 16px;
}

.status-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 16px;
}

.status-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 28px;
    font-size: 13px;
}

.status-item strong {
    display: flex;
    align-items: center;
    gap: 9px;
}

.status-item code {
    max-width: 62%;
    color: var(--ink);
    font-family: var(--font-mono);
    overflow-wrap: anywhere;
    text-align: right;
}

.health-item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 13px;
}

.health-item strong {
    display: flex;
    align-items: center;
    gap: 9px;
}

.health-item code {
    font-family: var(--font-mono);
}

@media (max-width: 1100px) {
    .login-screen,
    .app-shell {
        flex-direction: column;
    }

    .auth-rail,
    .sidebar {
        width: 100%;
        min-height: auto;
    }

    .sidebar {
        gap: 24px;
    }

    .work-row,
    .bottom-row,
    .feature-grid,
    .accounts-grid,
    .metrics {
        grid-template-columns: 1fr;
    }

    .dashboard-header,
    .topbar {
        align-items: stretch;
        flex-direction: column;
        height: auto;
        gap: 16px;
        padding: 18px;
    }

    .dashboard-body {
        padding: 18px;
    }
}
