@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700;900&display=swap');

:root {
    --bg: #f8f1e8;
    --bg-accent: #ffe6c8;
    --sidebar-start: #3e2925;
    --sidebar-end: #6c3a2b;
    --sidebar-line: rgba(255, 245, 236, 0.16);
    --surface: rgba(255, 250, 244, 0.95);
    --surface-strong: #fffdf9;
    --surface-soft: #fff2e2;
    --border: #e4d3c1;
    --text: #2f2723;
    --muted: #7c675c;
    --accent: #d66a2c;
    --accent-soft: rgba(214, 106, 44, 0.14);
    --teal: #168a74;
    --amber: #c28b16;
    --red: #bf4a36;
    --shadow: 0 18px 45px rgba(88, 52, 33, 0.12);
}

* {
    box-sizing: border-box;
}

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

body {
    font-family: 'Roboto', Arial, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top right, rgba(214, 106, 44, 0.15), transparent 24%),
        radial-gradient(circle at bottom left, rgba(22, 138, 116, 0.12), transparent 24%),
        linear-gradient(180deg, #fffaf3 0%, #f4ece3 100%);
}

a {
    color: inherit;
}

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

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 24px 20px;
    background: linear-gradient(180deg, var(--sidebar-start) 0%, var(--sidebar-end) 100%);
    color: #f8fbff;
}

.brand {
    display: block;
    color: inherit;
    text-decoration: none;
}

.brand-copy {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.brand-copy strong {
    font-size: 1.1rem;
}

.brand-copy small {
    color: rgba(248, 251, 255, 0.7);
}

.sidebar-nav {
    display: grid;
    gap: 8px;
}

.nav-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 12px 14px;
    border: 1px solid transparent;
    text-decoration: none;
    color: inherit;
    background: rgba(255, 255, 255, 0.03);
    transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--sidebar-line);
    transform: translateX(2px);
}

.nav-item span {
    font-weight: 700;
    font-size: 0.96rem;
}

.nav-item small {
    color: rgba(248, 251, 255, 0.65);
    line-height: 1.35;
}

.nav-item.is-active {
    background: rgba(37, 99, 235, 0.22);
    border-color: rgba(96, 165, 250, 0.45);
}

.nav-item.is-disabled {
    opacity: 0.58;
    cursor: not-allowed;
}

.sidebar-footer {
    margin-top: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.sidebar-pill {
    border: 1px solid var(--sidebar-line);
    padding: 8px 10px;
    color: rgba(248, 251, 255, 0.78);
    font-size: 0.82rem;
    background: rgba(255, 255, 255, 0.04);
}

.main-shell {
    padding: 24px 28px 30px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    margin-bottom: 24px;
}

.eyebrow {
    margin-bottom: 8px;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 0.74rem;
    font-weight: 700;
}

h1 {
    margin: 0;
    font-size: 2rem;
    line-height: 1.08;
}

.subtitle {
    margin: 10px 0 0;
    color: var(--muted);
    max-width: 720px;
    line-height: 1.55;
}

.topbar-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.button,
button.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 0 16px;
    border: 1px solid var(--border);
    background: var(--surface-strong);
    color: var(--text);
    text-decoration: none;
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(17, 24, 39, 0.05);
}

.button:hover,
button.button:hover {
    border-color: #b8c6dc;
}

.button-primary,
button.button-primary {
    background: linear-gradient(135deg, #d66a2c, #168a74);
    border-color: transparent;
    color: white;
}

.button-danger,
button.button-danger {
    background: linear-gradient(135deg, #bf4a36, #8c2f4b);
    border-color: transparent;
    color: white;
}

.button-secondary,
button.button-secondary {
    background: var(--surface-strong);
}

.button-disabled {
    opacity: 0.6;
    pointer-events: none;
}

.page-shell {
    display: grid;
    gap: 18px;
}

.flash {
    padding: 14px 16px;
    border: 1px solid transparent;
    box-shadow: var(--shadow);
}

.flash-success {
    background: rgba(15, 159, 143, 0.12);
    border-color: rgba(15, 159, 143, 0.24);
    color: #0f6e64;
}

.flash-danger {
    background: rgba(220, 38, 38, 0.1);
    border-color: rgba(220, 38, 38, 0.18);
    color: #a22323;
}

.stats-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.snapshot-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.panel-snapshot {
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
}

.snapshot-card {
    min-height: 188px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    border: 0;
    color: #f8fbff;
    overflow: hidden;
    position: relative;
}

.snapshot-card::after {
    content: "";
    position: absolute;
    inset: auto -38px -48px auto;
    width: 136px;
    height: 136px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 50%;
}

.snapshot-card:nth-child(4n + 1) {
    background: linear-gradient(135deg, #0f9f8f, #0b6f84);
}

.snapshot-card:nth-child(4n + 2) {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
}

.snapshot-card:nth-child(4n + 3) {
    background: linear-gradient(135deg, #e85d39, #c83756);
}

.snapshot-card:nth-child(4n + 4) {
    background: linear-gradient(135deg, #0b7285, #2457c5);
}

.snapshot-card .label {
    color: rgba(248, 251, 255, 0.76);
    position: relative;
    z-index: 1;
}

.snapshot-card .value {
    margin-top: 0;
    font-size: 1.35rem;
    line-height: 1.35;
    color: #ffffff;
    position: relative;
    z-index: 1;
}

.snapshot-card .subvalue {
    margin-top: auto;
    color: rgba(248, 251, 255, 0.84);
    position: relative;
    z-index: 1;
}

.snapshot-meta {
    margin-top: 12px;
    display: grid;
    gap: 6px;
    position: relative;
    z-index: 1;
}

.snapshot-meta-row {
    color: rgba(248, 251, 255, 0.84);
    font-size: 0.9rem;
    line-height: 1.45;
}

.snapshot-meta-row strong {
    color: #ffffff;
}

.snapshot-card .time-display-relative,
.snapshot-card .time-display.is-empty {
    color: rgba(248, 251, 255, 0.82);
}

.snapshot-card .time-display {
    gap: 4px;
}

.snapshot-card code {
    color: #ffffff;
    background: rgba(10, 20, 40, 0.16);
    padding: 2px 6px;
}

.snapshot-card .badge {
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
}

.kpi-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.kpi-card {
    min-height: 190px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    border: 0;
    color: #f8fbff;
    overflow: hidden;
    position: relative;
}

.kpi-card::after {
    content: "";
    position: absolute;
    inset: auto -40px -50px auto;
    width: 140px;
    height: 140px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 50%;
}

.kpi-card .label {
    color: rgba(248, 251, 255, 0.76);
}

.kpi-card-success {
    background: linear-gradient(135deg, #0f9f8f, #0b6f84);
}

.kpi-card-primary {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
}

.kpi-card-danger {
    background: linear-gradient(135deg, #e85d39, #c83756);
}

.kpi-card-teal {
    background: linear-gradient(135deg, #0b7285, #2457c5);
}

.kpi-value {
    font-size: 2.3rem;
    line-height: 1;
    font-weight: 900;
    letter-spacing: -0.03em;
    position: relative;
    z-index: 1;
}

.kpi-subvalue {
    color: rgba(248, 251, 255, 0.82);
    line-height: 1.55;
    position: relative;
    z-index: 1;
}

.kpi-meta {
    margin-top: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    position: relative;
    z-index: 1;
}

.kpi-pill {
    display: inline-flex;
    align-items: center;
    padding: 7px 10px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.16);
    font-size: 0.82rem;
    color: rgba(248, 251, 255, 0.92);
}

.chart-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.chart-card {
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    min-width: 0;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
}

.chart-header h2 {
    margin: 6px 0 0;
    font-size: 1.08rem;
}

.chart-meta {
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 700;
    white-space: nowrap;
}

.chart-bars {
    height: 176px;
    display: flex;
    align-items: end;
    gap: 10px;
    padding-top: 8px;
}

.chart-column {
    flex: 1 1 0;
    min-width: 0;
    display: grid;
    gap: 10px;
    align-content: end;
}

.chart-bar {
    width: 100%;
    min-height: 20px;
}

.chart-bar-success {
    background: linear-gradient(180deg, #14b8a6 0%, #0f766e 100%);
}

.chart-bar-warning {
    background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%);
}

.chart-bar-danger {
    background: linear-gradient(180deg, #fb7185 0%, #dc2626 100%);
}

.chart-bar-neutral {
    background: linear-gradient(180deg, #cbd5e1 0%, #94a3b8 100%);
}

.chart-bar-retry {
    background: linear-gradient(180deg, #93c5fd 0%, #2563eb 100%);
}

.chart-bar-retry.is-hot {
    background: linear-gradient(180deg, #f97316 0%, #dc2626 100%);
}

.chart-caption {
    text-align: center;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 700;
}

.legend-row {
    margin-top: 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
}

.legend-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--muted);
    font-size: 0.82rem;
}

.legend-swatch {
    width: 10px;
    height: 10px;
}

.legend-swatch-success {
    background: #0f9f8f;
}

.legend-swatch-warning {
    background: #f59e0b;
}

.legend-swatch-danger {
    background: #dc2626;
}

.legend-swatch-primary {
    background: #2563eb;
}

.legend-swatch-hot {
    background: #ea580c;
}

.line-chart {
    width: 100%;
    height: 176px;
    display: block;
}

.line-chart-stroke {
    fill: none;
    stroke: #2563eb;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.line-chart-dot {
    fill: #ffffff;
    stroke: #2563eb;
    stroke-width: 3;
}

.chart-axis {
    margin-top: 12px;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 700;
}

.stat-card,
.panel,
.login-card,
.bucket-card {
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    min-width: 0;
}

.stat-card {
    padding: 18px;
}

.label {
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.75rem;
    font-weight: 700;
}

.value {
    margin-top: 10px;
    font-size: 1.1rem;
    font-weight: 700;
    word-break: break-word;
}

.subvalue {
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.5;
}

.time-display {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    line-height: 1.5;
}

.time-display-main {
    font-weight: 700;
}

.time-display-relative {
    color: var(--muted);
    font-size: 0.9em;
}

.time-display.is-empty {
    color: var(--muted);
    font-weight: 500;
}

time.timeago {
    white-space: nowrap;
}

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

.panel {
    padding: 20px;
}

.panel h2 {
    margin: 0 0 14px;
    font-size: 1.1rem;
}

.stack {
    display: grid;
    gap: 12px;
}

.list-clean {
    margin: 0;
    padding-left: 18px;
    color: var(--muted);
}

.list-clean li + li {
    margin-top: 8px;
}

.code-block {
    display: block;
    margin: 0;
    max-width: 100%;
    padding: 16px;
    overflow-x: auto;
    overflow-y: hidden;
    background: #15263f;
    color: #eff6ff;
    font-family: Consolas, Monaco, monospace;
    font-size: 0.88rem;
    line-height: 1.55;
    white-space: pre;
}

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

.badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-info {
    background: rgba(214, 106, 44, 0.12);
    color: #b45309;
}

.badge-ok {
    background: rgba(22, 138, 116, 0.14);
    color: #0f766e;
}

.badge-warn {
    background: rgba(194, 139, 22, 0.14);
    color: #9a6708;
}

.badge-danger {
    background: rgba(191, 74, 54, 0.12);
    color: #a13322;
}

.table-wrap {
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 780px;
}

.data-table th,
.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid #e5ebf5;
    text-align: left;
    vertical-align: top;
}

.data-table th {
    background: #f5f8fd;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.74rem;
}

.data-table tr:last-child td {
    border-bottom: 0;
}

.data-table tbody tr:nth-child(even) td {
    background: rgba(148, 163, 184, 0.08);
}

.data-table tbody tr:nth-child(odd) td {
    background: rgba(255, 255, 255, 0.72);
}

.data-table tbody tr:hover td {
    background: rgba(37, 99, 235, 0.08);
}

.table-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

.table-link:hover {
    text-decoration: underline;
}

.breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    color: var(--muted);
    font-size: 0.92rem;
}

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

.empty-state {
    padding: 20px;
    background: var(--surface);
    border: 1px dashed #bfd0ea;
    color: var(--muted);
}

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

.field label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--muted);
}

.field input:not([type="checkbox"]):not([type="radio"]),
.field select,
.field textarea {
    width: 100%;
    min-height: 46px;
    padding: 0 14px;
    border: 1px solid var(--border);
    background: white;
    font: inherit;
    color: var(--text);
}

.checkbox-list {
    display: grid;
    gap: 10px;
}

.checkbox-option {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    color: var(--text);
}

.checkbox-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    min-height: 0;
    margin: 2px 0 0;
    padding: 0;
    flex: 0 0 auto;
    accent-color: var(--accent);
}

.checkbox-option span {
    line-height: 1.45;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 28px;
    background:
        radial-gradient(circle at top right, rgba(214, 106, 44, 0.18), transparent 28%),
        radial-gradient(circle at bottom left, rgba(22, 138, 116, 0.14), transparent 24%),
        linear-gradient(180deg, #fff8ef 0%, #f5e9da 100%);
}

.login-card {
    width: min(960px, 100%);
    display: grid;
    grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
    overflow: hidden;
}

.login-aside {
    padding: 28px;
    background: linear-gradient(180deg, #5b2d24, #8f4a30);
    color: white;
}

.login-aside h1 {
    font-size: 2rem;
    margin: 0 0 12px;
}

.login-aside p {
    margin: 0;
    color: rgba(255, 255, 255, 0.78);
    line-height: 1.6;
}

.login-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 18px;
}

.login-pills span {
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.16);
    font-size: 0.85rem;
}

.login-main {
    padding: 28px;
    background: linear-gradient(180deg, #fff7ee 0%, #fff0de 100%);
}

.login-main h2 {
    margin: 0 0 10px;
    font-size: 1.4rem;
}

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

code {
    font-family: Consolas, Monaco, monospace;
    font-size: 0.88rem;
}

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

    .chart-grid {
        grid-template-columns: 1fr;
    }
}

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

    .sidebar {
        gap: 16px;
    }

    .sidebar-nav {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }

    .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .snapshot-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .main-shell {
        padding: 18px;
    }

    .topbar {
        flex-direction: column;
    }

    .topbar-actions {
        justify-content: flex-start;
    }

    .login-card {
        grid-template-columns: 1fr;
    }

    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .snapshot-grid {
        grid-template-columns: 1fr;
    }

    .chart-bars {
        gap: 7px;
    }
}

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

.panel-head h2 {
    margin: 0;
}

.inline-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.inline-form {
    margin: 0;
}

.field-checkbox {
    display: flex;
    align-items: center;
}

.checkline {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: var(--text);
}

.checkline input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
}

.issue-list {
    margin: 0;
    padding-left: 20px;
    color: var(--text);
}

.issue-list li + li {
    margin-top: 8px;
}

.log-console {
    margin: 0;
    padding: 16px;
    max-height: 360px;
    overflow: auto;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 6px;
    background: #10243f;
    color: #ecf5ff;
    font: 13px/1.6 Consolas, Monaco, monospace;
    white-space: pre;
}

.admin-shell,
.stat-card,
.panel,
.login-card,
.button,
button.button,
.badge,
.sidebar-pill,
.nav-item,
.flash,
.empty-state,
.code-block,
.log-console,
.field input:not([type="checkbox"]):not([type="radio"]),
.field select,
.field textarea,
.login-pills span {
    border-radius: 6px;
}

.login-main .field input:not([type="checkbox"]):not([type="radio"]) {
    border-color: #ddb79a;
    background: rgba(255, 252, 246, 0.95);
}

.login-main .field input:not([type="checkbox"]):not([type="radio"]):focus {
    outline: none;
    border-color: #d66a2c;
    box-shadow: 0 0 0 3px rgba(214, 106, 44, 0.14);
}

.recaptcha-wrap {
    display: flex;
    justify-content: flex-start;
}

.recaptcha-wrap .g-recaptcha {
    transform-origin: left top;
}
