:root {
    --bg: #100d09;
    --panel: rgba(31, 25, 18, 0.86);
    --panel-strong: #231a10;
    --line: rgba(226, 180, 103, 0.18);
    --line-strong: rgba(226, 180, 103, 0.34);
    --text: #f8ead6;
    --muted: #b59c7a;
    --bronze: #d99a44;
    --bronze-2: #8f5b24;
    --danger: #ef5b4f;
    --warning: #f0b84d;
    --success: #55c58a;
    --info: #5db7d8;
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: Montserrat, system-ui, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 10% 0%, rgba(217, 154, 68, 0.22), transparent 34rem),
        radial-gradient(circle at 95% 8%, rgba(93, 183, 216, 0.08), transparent 28rem),
        linear-gradient(135deg, #100d09 0%, #18120b 45%, #0d0b08 100%);
}

button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.access-gate {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.gate-card {
    width: min(520px, 100%);
    padding: 36px;
    border: 1px solid var(--line-strong);
    border-radius: 32px;
    background: linear-gradient(160deg, rgba(35, 26, 16, 0.94), rgba(16, 13, 9, 0.88));
    box-shadow: var(--shadow);
    text-align: center;
}

.gate-icon {
    width: 72px;
    height: 72px;
    display: inline-grid;
    place-items: center;
    border-radius: 24px;
    background: linear-gradient(135deg, var(--bronze), var(--bronze-2));
    color: #1b1207;
    font-size: 42px;
    margin-bottom: 18px;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--bronze);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
.gate-card h1 { margin-bottom: 12px; font-size: clamp(28px, 5vw, 44px); }
.gate-copy { color: var(--muted); line-height: 1.7; }

.gate-loader {
    width: 100%;
    height: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255,255,255,0.08);
}
.gate-loader::after {
    content: '';
    display: block;
    width: 38%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, transparent, var(--bronze), transparent);
    animation: load 1.2s infinite ease-in-out;
}

.admin-login-form {
    display: grid;
    gap: 12px;
    margin-top: 22px;
}

.admin-passcode-input {
    width: 100%;
    padding: 15px 16px;
    border: 1px solid var(--line-strong);
    border-radius: 16px;
    color: var(--text);
    background: rgba(255,255,255,.06);
    outline: none;
    text-align: center;
    font-weight: 900;
    letter-spacing: .08em;
}

.admin-passcode-input:focus {
    border-color: var(--bronze);
    box-shadow: 0 0 0 5px rgba(217,154,68,.14);
}

.login-hint {
    margin: 14px 0 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.6;
}

@keyframes load { from { transform: translateX(-110%); } to { transform: translateX(280%); } }

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

.admin-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 24px;
    border-right: 1px solid var(--line);
    background: rgba(14, 11, 7, 0.72);
    backdrop-filter: blur(18px);
}

.brand-block {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 30px;
}
.brand-mark {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    color: #150d05;
    background: linear-gradient(135deg, #ffcf79, #b66b24);
    font-weight: 1000;
    box-shadow: 0 16px 36px rgba(217,154,68,.22);
}
.brand-block strong { display: block; font-size: 16px; }

.admin-nav { display: grid; gap: 9px; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 13px 14px;
    border: 1px solid transparent;
    border-radius: 16px;
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    font-weight: 900;
    text-align: left;
    transition: 180ms ease;
}
.nav-item:hover, .nav-item.active {
    color: var(--text);
    border-color: var(--line-strong);
    background: linear-gradient(135deg, rgba(217,154,68,.16), rgba(255,255,255,.04));
    transform: translateX(3px);
}
.nav-item .material-symbols-outlined { font-size: 21px; }

.sidebar-note {
    position: absolute;
    left: 24px;
    right: 24px;
    bottom: 24px;
    display: flex;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 20px;
    color: var(--muted);
    background: rgba(255,255,255,.035);
    font-size: 12px;
    line-height: 1.55;
}
.sidebar-note p { margin: 0; }

.admin-main { min-width: 0; padding: 28px; }
.admin-header {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: flex-start;
    margin-bottom: 24px;
}
.admin-header h2 { margin-bottom: 8px; font-size: clamp(28px, 4vw, 48px); line-height: 1; }
.admin-header p:not(.eyebrow) { color: var(--muted); font-weight: 700; }
.header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

.status-pill, .ghost-button, .danger-button, .primary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 10px 14px;
    border-radius: 14px;
    border: 1px solid var(--line);
    font-size: 11px;
    font-weight: 1000;
    text-transform: uppercase;
    letter-spacing: .06em;
}
.status-pill.neutral { color: var(--muted); background: rgba(255,255,255,.04); }
.status-pill.good { color: var(--success); background: rgba(85,197,138,.1); border-color: rgba(85,197,138,.28); }
.status-pill.warn { color: var(--warning); background: rgba(240,184,77,.1); border-color: rgba(240,184,77,.28); }
.status-pill.danger { color: var(--danger); background: rgba(239,91,79,.1); border-color: rgba(239,91,79,.28); }
.ghost-button { color: var(--text); background: rgba(255,255,255,.045); }
.ghost-button:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.primary-button { color: #170e05; background: linear-gradient(135deg, #ffd384, #c77829); border: 0; }
.danger-button { color: white; background: linear-gradient(135deg, #ef5b4f, #9b2e27); border: 0; }

.admin-content { display: grid; gap: 18px; }
.card {
    border: 1px solid var(--line);
    border-radius: 24px;
    background: var(--panel);
    box-shadow: 0 16px 48px rgba(0,0,0,.18);
    overflow: hidden;
}
.card.pad { padding: 20px; }
.card-header {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
}
.card-header h3 { margin: 0; }
.card-header p { margin: 5px 0 0; color: var(--muted); font-size: 13px; font-weight: 700; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.metric-card {
    position: relative;
    min-height: 148px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: linear-gradient(155deg, rgba(255,255,255,.07), rgba(255,255,255,.025));
    overflow: hidden;
}
.metric-card::after {
    content: '';
    position: absolute;
    right: -34px;
    bottom: -40px;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(217,154,68,.12);
}
.metric-label { color: var(--muted); font-size: 11px; font-weight: 1000; text-transform: uppercase; letter-spacing: .12em; }
.metric-value { display: block; margin: 16px 0 10px; font-size: 40px; font-weight: 1000; line-height: .9; }
.metric-note { color: var(--muted); font-size: 12px; font-weight: 700; line-height: 1.5; }

.two-column { display: grid; grid-template-columns: 1.1fr .9fr; gap: 18px; align-items: start; }
.alert-list, .table-list { display: grid; gap: 10px; padding: 14px; }
.alert-row, .data-row {
    display: grid;
    gap: 10px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255,255,255,.035);
}
.alert-row { grid-template-columns: auto 1fr auto; align-items: center; }
.alert-dot { width: 12px; height: 12px; border-radius: 999px; }
.alert-dot.danger { background: var(--danger); box-shadow: 0 0 0 6px rgba(239,91,79,.12); }
.alert-dot.warning { background: var(--warning); box-shadow: 0 0 0 6px rgba(240,184,77,.12); }
.alert-dot.info { background: var(--info); box-shadow: 0 0 0 6px rgba(93,183,216,.12); }
.row-title { margin: 0 0 4px; font-weight: 1000; }
.row-meta { margin: 0; color: var(--muted); font-size: 12px; font-weight: 700; line-height: 1.5; }

.search-box { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.editor-row {
    grid-template-columns: minmax(180px, 1.2fr) minmax(90px, .45fr) auto auto auto;
    align-items: center;
}
.editor-row label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 1000;
    text-transform: uppercase;
    letter-spacing: .06em;
}
.editor-row input[type="number"],
.editor-row textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    color: var(--text);
    background: rgba(255,255,255,.055);
    outline: none;
}
.editor-row input[type="number"] { padding: 11px 12px; }
.editor-row textarea {
    min-width: 220px;
    padding: 12px;
    resize: vertical;
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 12px;
    line-height: 1.45;
}
.editor-row input:focus,
.editor-row textarea:focus { border-color: var(--bronze); box-shadow: 0 0 0 4px rgba(217,154,68,.12); }
.editor-row .checkline {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255,255,255,.035);
    text-transform: none;
    letter-spacing: 0;
}
.primary-button.compact { min-height: 38px; padding-inline: 12px; }
.setting-editor { grid-template-columns: minmax(180px, .85fr) minmax(260px, 1.2fr) auto; }
.search-box input {
    width: 100%;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid var(--line);
    color: var(--text);
    background: rgba(255,255,255,.05);
    outline: none;
}
.search-box input:focus { border-color: var(--bronze); box-shadow: 0 0 0 4px rgba(217,154,68,.12); }

.muted { color: var(--muted); }
.empty-state { padding: 26px; text-align: center; color: var(--muted); font-weight: 800; }
.admin-toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    max-width: min(420px, calc(100vw - 40px));
    padding: 14px 16px;
    border: 1px solid var(--line-strong);
    border-radius: 18px;
    color: var(--text);
    background: rgba(30, 22, 13, .95);
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(16px);
    pointer-events: none;
    transition: 180ms ease;
    font-size: 13px;
    font-weight: 800;
}
.admin-toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1060px) {
    .admin-shell { grid-template-columns: 1fr; }
    .admin-sidebar { position: relative; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
    .admin-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .sidebar-note { position: static; margin-top: 18px; }
    .metric-grid, .two-column, .editor-row, .setting-editor { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 700px) {
    .admin-main, .admin-sidebar { padding: 16px; }
    .admin-header, .card-header { flex-direction: column; }
    .admin-nav, .metric-grid, .two-column, .search-box, .editor-row, .setting-editor { grid-template-columns: 1fr; }
    .alert-row { grid-template-columns: auto 1fr; }
    .alert-row .ghost-button, .alert-row .danger-button { grid-column: 1 / -1; }
}
