:root {
    --bg: #101114;
    --surface: #17191e;
    --surface-2: #20232a;
    --line: #30343d;
    --text: #f2f5f7;
    --muted: #98a2ad;
    --teal: #31c6b3;
    --teal-dark: #208f83;
    --amber: #f0b45a;
    --red: #f06d6d;
    --green: #75d18a;
    --blue: #6ea8fe;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
}

* {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

a {
    color: inherit;
}

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

.app-shell {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 22px;
    border-right: 1px solid var(--line);
    background: #13151a;
    padding: 20px 14px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border: 1px solid rgba(49, 198, 179, 0.45);
    border-radius: 8px;
    background: rgba(49, 198, 179, 0.12);
    color: var(--teal);
    font-weight: 800;
}

.brand strong,
.brand small {
    display: block;
}

.brand small,
.muted {
    color: var(--muted);
}

.nav-list {
    display: grid;
    gap: 5px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding: 9px 10px;
    color: var(--muted);
    border: 1px solid transparent;
    border-radius: 8px;
    text-decoration: none;
}

.nav-item:hover,
.nav-item.active {
    color: var(--text);
    background: var(--surface-2);
    border-color: var(--line);
}

.nav-icon {
    display: grid;
    width: 24px;
    height: 24px;
    place-items: center;
    border-radius: 6px;
    background: #0d0f12;
    color: var(--teal);
    font-size: 0.75rem;
    font-weight: 800;
}

.sidebar-footer {
    margin-top: auto;
}

.main {
    min-width: 0;
    padding: 24px;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 22px;
}

.topbar h1 {
    margin: 0;
    font-size: 1.45rem;
}

.topbar p {
    margin: 3px 0 0;
    color: var(--muted);
}

.topbar-link {
    margin-left: auto;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.metric,
.panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.metric {
    display: grid;
    gap: 8px;
    min-height: 132px;
    padding: 16px;
    text-decoration: none;
}

.metric-label {
    color: var(--muted);
    font-size: 0.84rem;
}

.metric strong {
    font-size: 1.8rem;
}

.metric small {
    color: var(--muted);
    overflow-wrap: anywhere;
}

.metric.ok {
    border-color: rgba(117, 209, 138, 0.45);
}

.metric.warn {
    border-color: rgba(240, 180, 90, 0.5);
}

.metric.bad {
    border-color: rgba(240, 109, 109, 0.55);
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
}

.panel {
    padding: 16px;
    margin-bottom: 18px;
}

.panel.narrow {
    max-width: 760px;
}

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

.panel-heading h2 {
    margin: 0;
    font-size: 1rem;
}

.panel-heading a {
    color: var(--teal);
    text-decoration: none;
}

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

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

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

.field span {
    color: var(--muted);
    font-size: 0.86rem;
}

input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    color: var(--text);
    background: #0d0f12;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 11px;
    outline: none;
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(49, 198, 179, 0.14);
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    border-radius: 8px;
    border: 1px solid transparent;
    padding: 9px 13px;
    cursor: pointer;
    text-decoration: none;
}

.primary-button {
    color: #07100e;
    background: var(--teal);
    border-color: var(--teal);
    font-weight: 800;
}

.primary-button:hover {
    background: #43dac8;
}

.secondary-button {
    color: var(--text);
    background: var(--surface-2);
    border-color: var(--line);
}

.ghost-button {
    color: var(--text);
    background: transparent;
    border-color: var(--line);
}

.ghost-button.danger,
.icon-button.danger {
    color: var(--red);
    border-color: rgba(240, 109, 109, 0.45);
}

.icon-button {
    width: 38px;
    padding: 0;
    font-weight: 800;
    background: #0d0f12;
    color: var(--text);
    border-color: var(--line);
}

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

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

.small {
    min-height: 32px;
    padding: 6px 9px;
    font-size: 0.84rem;
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

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

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

th,
td {
    padding: 12px 10px;
    border-top: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

th {
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
}

.strong {
    font-weight: 750;
}

.truncate {
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.path-cell {
    max-width: 460px;
    color: var(--muted);
    font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
    font-size: 0.82rem;
    overflow-wrap: anywhere;
}

.pill,
.status-chip {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    background: #0d0f12;
    font-size: 0.78rem;
}

.status-chip.ok {
    color: var(--green);
    border-color: rgba(117, 209, 138, 0.45);
}

.status-chip.warn {
    color: var(--amber);
    border-color: rgba(240, 180, 90, 0.45);
}

.status-chip.bad {
    color: var(--red);
    border-color: rgba(240, 109, 109, 0.45);
}

.progress-line {
    display: grid;
    grid-template-columns: minmax(110px, 1fr) 48px;
    align-items: center;
    gap: 8px;
}

progress {
    width: 100%;
    height: 9px;
    overflow: hidden;
    border: 0;
    border-radius: 999px;
    background: var(--surface-2);
}

progress::-webkit-progress-bar {
    background: var(--surface-2);
}

progress::-webkit-progress-value {
    background: var(--teal);
}

progress::-moz-progress-bar {
    background: var(--teal);
}

.compact-select {
    min-width: 150px;
}

.toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    min-height: 40px;
}

.toggle input {
    width: 18px;
    min-height: 18px;
}

.empty-state,
.empty-cell {
    color: var(--muted);
    text-align: center;
}

.empty-state {
    display: grid;
    gap: 8px;
    padding: 44px 16px;
}

.empty-state a {
    color: var(--teal);
}

.flash-stack {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
}

.flash-stack.compact {
    margin-bottom: 0;
}

.flash {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    background: var(--surface-2);
}

.flash.success {
    border-color: rgba(117, 209, 138, 0.5);
}

.flash.danger {
    border-color: rgba(240, 109, 109, 0.55);
}

.flash.warning {
    border-color: rgba(240, 180, 90, 0.5);
}

.flash button {
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 6px;
    color: var(--muted);
    background: transparent;
    cursor: pointer;
}

.kv-list {
    display: grid;
    grid-template-columns: 140px minmax(0, 1fr);
    gap: 10px 14px;
    margin: 0;
}

.kv-list dt {
    color: var(--muted);
}

.kv-list dd {
    margin: 0;
    overflow-wrap: anywhere;
    font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
    font-size: 0.86rem;
}

.log-output {
    max-height: 620px;
    overflow: auto;
    margin: 0 0 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: #b7f5cf;
    background: #060708;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.82rem;
}

.upload-meter {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 52px;
    align-items: center;
    gap: 10px;
}

.hidden {
    display: none;
}

.login-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 20px;
}

.login-panel {
    width: min(420px, 100%);
    display: grid;
    gap: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 24px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

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

.login-brand h1 {
    margin: 0;
    font-size: 1.25rem;
}

.login-brand p {
    margin: 3px 0 0;
    color: var(--muted);
}

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

    .sidebar {
        position: fixed;
        z-index: 20;
        transform: translateX(-105%);
        transition: transform 0.18s ease;
        width: 260px;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .metric-grid,
    .split-grid {
        grid-template-columns: 1fr;
    }

    .topbar-link {
        display: none;
    }
}

@media (max-width: 620px) {
    .main {
        padding: 16px;
    }

    .topbar {
        align-items: flex-start;
    }

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

    th,
    td {
        padding: 10px 8px;
    }
}
