/* Kholosh Admin — dark editorial theme.
   Fonts: Fraunces (display) + JetBrains Mono (UI). 8px spacing grid.
   Palette: charcoal bg, warm off-white text, single amber accent. */

:root {
    --bg:           #0E0D0B;
    --surface:      #161513;
    --surface-alt:  #1C1A17;
    --border:       #2A2823;
    --border-soft:  #211F1B;
    --text:         #E8E2D5;
    --text-muted:   #948C7C;
    --text-faint:   #5C564C;
    --accent:       #E0A24A;
    --accent-soft:  rgba(224, 162, 74, 0.12);
    --danger:       #C75D5D;
    --ok:           #7FA37A;

    --grid: 8px;
    --max-w: 1280px;

    --display: 'Fraunces', 'Times New Roman', serif;
    --mono:    'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100%;
}

body {
    font-feature-settings: 'ss01', 'cv02', 'cv11';
    letter-spacing: 0.01em;
}

a {
    color: var(--text);
    text-decoration: none;
    border-bottom: 1px solid var(--border);
    transition: border-color 120ms ease, color 120ms ease;
}
a:hover { border-color: var(--accent); color: var(--accent); }

::selection { background: var(--accent); color: var(--bg); }

button, input, textarea, select {
    font: inherit;
    color: inherit;
    background: transparent;
    border: none;
    outline: none;
}

/* ---------------------------------------------------------------------
   Shell — fixed left rail with rotated wordmark + main content.
   --------------------------------------------------------------------- */

.shell {
    display: grid;
    grid-template-columns: 56px 1fr;
    min-height: 100vh;
}

.rail {
    border-right: 1px solid var(--border);
    background: var(--bg);
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 24px 0;
}

.rail__mark {
    font-family: var(--display);
    font-weight: 600;
    font-size: 18px;
    letter-spacing: 0.18em;
    color: var(--text);
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    text-transform: uppercase;
    border: none;
}

.rail__date {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--text-faint);
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

.main {
    padding: 32px 48px 64px;
    max-width: var(--max-w);
    width: 100%;
}

/* ---------------------------------------------------------------------
   Top nav — editorial section numerals.
   --------------------------------------------------------------------- */

.topnav {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    padding-bottom: 16px;
    margin-bottom: 48px;
    gap: 32px;
    flex-wrap: wrap;
}

.topnav__brand {
    font-family: var(--display);
    font-weight: 500;
    font-size: 22px;
    letter-spacing: -0.01em;
    border: none;
    color: var(--text);
}
.topnav__brand em {
    font-style: italic;
    color: var(--accent);
    font-weight: 400;
}

.topnav__links {
    display: flex;
    gap: 24px;
    align-items: baseline;
    list-style: none;
}
.topnav__links a {
    border: none;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 11px;
    color: var(--text-muted);
    padding-bottom: 4px;
}
.topnav__links a.is-active {
    color: var(--text);
    border-bottom: 1px solid var(--accent);
}
.topnav__links a:hover {
    color: var(--text);
}
.topnav__links .num {
    color: var(--text-faint);
    margin-right: 6px;
}

.topnav__user {
    font-size: 11px;
    color: var(--text-faint);
    display: flex;
    gap: 16px;
    align-items: baseline;
    text-transform: uppercase;
    letter-spacing: 0.18em;
}
.topnav__user form { display: inline; }
.topnav__user button {
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 11px;
    padding: 0;
}
.topnav__user button:hover { color: var(--accent); }

/* ---------------------------------------------------------------------
   Section header.
   --------------------------------------------------------------------- */

.section-head {
    display: grid;
    grid-template-columns: 80px 1fr auto;
    gap: 24px;
    align-items: end;
    margin-bottom: 40px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-soft);
}
.section-head__num {
    font-family: var(--display);
    font-weight: 300;
    font-size: 56px;
    line-height: 0.9;
    color: var(--accent);
    font-feature-settings: 'lnum';
}
.section-head__num::before { content: '— '; color: var(--text-faint); }
.section-head__title {
    font-family: var(--display);
    font-weight: 400;
    font-size: 36px;
    line-height: 1;
    letter-spacing: -0.015em;
}
.section-head__title em { font-style: italic; color: var(--text-muted); font-weight: 300; }
.section-head__meta {
    font-size: 11px;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.18em;
    text-align: right;
    line-height: 1.6;
}
.section-head__meta strong { color: var(--text); font-weight: 500; }

/* ---------------------------------------------------------------------
   Stat cards — quiet labels, oversized numerals.
   --------------------------------------------------------------------- */

.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    border: 1px solid var(--border);
    margin-bottom: 56px;
}
.stat {
    padding: 32px 24px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 168px;
    justify-content: space-between;
    position: relative;
}
.stat:last-child { border-right: none; }
.stat__label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.22em;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}
.stat__label .index {
    color: var(--text-faint);
    font-feature-settings: 'tnum';
}
.stat__value {
    font-family: var(--display);
    font-weight: 300;
    font-size: 72px;
    line-height: 1;
    letter-spacing: -0.02em;
    font-feature-settings: 'lnum', 'tnum';
}
.stat__value.is-attention { color: var(--accent); }
.stat__sub {
    font-size: 10px;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.18em;
}

/* ---------------------------------------------------------------------
   Panels & tables.
   --------------------------------------------------------------------- */

.panel {
    border: 1px solid var(--border);
    margin-bottom: 32px;
}
.panel__head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    gap: 16px;
}
.panel__title {
    font-family: var(--display);
    font-weight: 500;
    font-size: 16px;
    letter-spacing: 0.01em;
}
.panel__title .num {
    color: var(--text-faint);
    margin-right: 8px;
    font-weight: 300;
}
.panel__meta {
    font-size: 10px;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.18em;
}
.panel__body { padding: 0; }
.panel__body--padded { padding: 24px; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.table th {
    text-align: left;
    padding: 12px 24px;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 10px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: var(--surface-alt);
}
.table td {
    padding: 14px 24px;
    border-bottom: 1px solid var(--border-soft);
    vertical-align: top;
    color: var(--text);
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--surface); }
.table .col-num {
    color: var(--text-faint);
    font-feature-settings: 'tnum';
    width: 56px;
}
.table .col-time {
    color: var(--text-muted);
    white-space: nowrap;
    width: 160px;
    font-size: 11px;
}
.table .col-type { width: 120px; }
.table .col-name { font-weight: 500; }
.table .col-meta {
    color: var(--text-muted);
    font-size: 11px;
    max-width: 320px;
}
.table .empty {
    text-align: center;
    padding: 64px 24px;
    color: var(--text-faint);
    font-style: italic;
    font-family: var(--display);
    font-size: 16px;
}

/* ---------------------------------------------------------------------
   Badges, buttons, inputs.
   --------------------------------------------------------------------- */

.badge {
    display: inline-block;
    padding: 4px 10px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    border: 1px solid var(--border);
    color: var(--text-muted);
    background: transparent;
    border-radius: 0;
    line-height: 1.4;
}
.badge--standard {
    color: var(--text);
    border-color: var(--border);
}
.badge--custom {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-soft);
}
.badge--ok    { color: var(--ok);     border-color: var(--ok); }
.badge--warn  { color: var(--accent); border-color: var(--accent); }
.badge--down  { color: var(--danger); border-color: var(--danger); }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    font-family: var(--mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
    border-radius: 0;
}
.btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.btn--primary {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
}
.btn--primary:hover {
    background: var(--accent);
    color: var(--bg);
}
.btn--ghost {
    border-color: transparent;
    color: var(--text-muted);
    padding: 8px 0;
}
.btn--ghost:hover { color: var(--accent); }
.btn[disabled] { opacity: 0.4; cursor: not-allowed; }

.input, .select, .textarea {
    width: 100%;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: var(--mono);
    font-size: 13px;
    border-radius: 0;
    transition: border-color 120ms ease;
}
.input:focus, .select:focus, .textarea:focus {
    border-color: var(--accent);
}
.textarea {
    resize: vertical;
    min-height: 480px;
    line-height: 1.6;
    font-size: 13px;
    tab-size: 4;
}
.label {
    display: block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.22em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.row {
    display: flex;
    gap: 16px;
    align-items: flex-end;
    flex-wrap: wrap;
}
.row > .field { flex: 1 1 180px; }

.flash {
    padding: 14px 24px;
    border: 1px solid var(--accent);
    background: var(--accent-soft);
    color: var(--text);
    margin-bottom: 24px;
    font-size: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.flash--err {
    border-color: var(--danger);
    background: rgba(199, 93, 93, 0.08);
    color: var(--text);
}
.flash__num {
    color: var(--accent);
    font-family: var(--display);
    font-weight: 500;
    font-size: 14px;
    letter-spacing: 0.18em;
    margin-right: 12px;
}

/* ---------------------------------------------------------------------
   Login screen — single centered card with editorial detail.
   --------------------------------------------------------------------- */

.login {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr;
    place-items: center;
    padding: 48px 24px;
    position: relative;
    overflow: hidden;
}
.login::before {
    content: 'KHOLOSH';
    position: absolute;
    top: 50%;
    left: -8vw;
    transform: translateY(-50%);
    font-family: var(--display);
    font-weight: 200;
    font-size: clamp(180px, 32vw, 480px);
    line-height: 1;
    color: var(--surface-alt);
    letter-spacing: -0.04em;
    pointer-events: none;
    user-select: none;
    z-index: 0;
}
.login__card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 440px;
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 48px 40px;
}
.login__num {
    font-family: var(--display);
    color: var(--accent);
    font-size: 14px;
    letter-spacing: 0.22em;
    margin-bottom: 24px;
    font-weight: 400;
}
.login__title {
    font-family: var(--display);
    font-weight: 400;
    font-size: 32px;
    line-height: 1.05;
    margin-bottom: 8px;
    letter-spacing: -0.01em;
}
.login__title em { font-style: italic; color: var(--accent); font-weight: 300; }
.login__sub {
    color: var(--text-muted);
    font-size: 12px;
    margin-bottom: 32px;
}
.login__field { margin-bottom: 24px; }
.login__footer {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border-soft);
    font-size: 10px;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.22em;
    display: flex;
    justify-content: space-between;
}

/* ---------------------------------------------------------------------
   Filters bar.
   --------------------------------------------------------------------- */

.filters {
    display: grid;
    grid-template-columns: 160px 200px 200px auto auto;
    gap: 16px;
    align-items: end;
    padding: 24px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}
.filters .field { display: flex; flex-direction: column; }
.filters .actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    grid-column: span 2;
}

/* ---------------------------------------------------------------------
   Knowledge editor.
   --------------------------------------------------------------------- */

.editor {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
}
.editor__bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.18em;
}
.editor__bar .meta { display: flex; gap: 24px; }
.editor__bar .meta strong { color: var(--text); font-weight: 500; }

.editor textarea.textarea {
    border: none;
    border-radius: 0;
    background: var(--bg);
    padding: 24px;
    min-height: 640px;
    font-size: 13px;
    line-height: 1.7;
}

/* ---------------------------------------------------------------------
   Footer.
   --------------------------------------------------------------------- */

.foot {
    margin-top: 64px;
    padding-top: 24px;
    border-top: 1px solid var(--border-soft);
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.22em;
}

/* ---------------------------------------------------------------------
   Responsive.
   --------------------------------------------------------------------- */

@media (max-width: 960px) {
    .shell { grid-template-columns: 1fr; }
    .rail { display: none; }
    .main { padding: 24px 24px 48px; }
    .stats { grid-template-columns: 1fr; }
    .stat { border-right: none; border-bottom: 1px solid var(--border); }
    .stat:last-child { border-bottom: none; }
    .section-head {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    .section-head__meta { text-align: left; }
    .filters { grid-template-columns: 1fr; }
    .filters .actions { grid-column: span 1; justify-content: flex-start; }
    .topnav { gap: 16px; }
    .topnav__links { gap: 16px; }
}
