/* MONOLIT — look taken from the V2 mock-up: dark side menu, white
   cards, dense tables, one green accent. System fonts, no external assets. */

:root {
    --ink: #16191d;
    --ink-2: #2b3138;
    --muted: #8b9198;
    --label: #7d848b;
    --ground: #f4f5f3;
    --surface: #ffffff;
    --rule: #e3e5e1;
    --rule-2: #f1f2ef;
    --field: #dcdfd9;
    --accent: #2f7d52;
    --accent-ink: #22633f;
    --accent-soft: #eef5f1;
    --ok-bg: #e7f1ea;
    --warn-bg: #fcf2e0;
    --warn-ink: #8a5a08;
    --err-bg: #fbeceb;
    --err-ink: #9e2119;
    --neutral-bg: #eef0ec;
    --neutral-ink: #5b6167;
    --side: #16191d;
    --side-item: #9aa1a8;
    --side-active: #23282e;
    --font: "Segoe UI", "IBM Plex Sans", system-ui, -apple-system, sans-serif;
    --mono: "Cascadia Mono", "IBM Plex Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 13px;
    line-height: 1.45;
    background: var(--ground);
    color: var(--ink);
}

a { color: var(--accent-ink); }
a:hover { color: var(--accent); }

.hidden { display: none !important; }

/* ---------- login / password ---------- */

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

.login-card {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 10px;
    padding: 28px;
    width: 340px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.login-card .brand {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.login-card .brand b { font-size: 15px; letter-spacing: .12em; }
.login-card .brand span { color: var(--muted); font-size: 12px; }

/* ---------- application shell ---------- */

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

.side {
    width: 232px;
    flex: none;
    background: var(--side);
    display: flex;
    flex-direction: column;
    padding: 16px 12px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.side .brand {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 6px 10px 16px;
}

.side .brand b { color: #fff; font-size: 13.5px; font-weight: 600; letter-spacing: .12em; }
.side .brand span { color: #6f767d; font-size: 10.5px; letter-spacing: .04em; }

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

.nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    color: var(--side-item);
    font-size: 12.5px;
    text-decoration: none;
}

.nav a:hover { color: #fff; }
.nav a.on { background: var(--side-active); color: #fff; box-shadow: inset 2px 0 0 #4fae7c; }

.nav-sep { height: 1px; background: var(--side-active); margin: 11px 10px; }

.who {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 10px;
    border-radius: 6px;
    background: #1c2126;
}

.who .av {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10.5px;
    font-weight: 600;
    flex: none;
    text-transform: uppercase;
}

.who .name { color: #e8eaec; font-size: 12px; font-weight: 500; display: block; }
.who .role { color: #6f767d; font-size: 10.5px; display: block; }

.who .out {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--side-item);
    cursor: pointer;
    font-size: 11px;
    padding: 4px;
}

.who .out:hover { color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.top {
    height: 60px;
    flex: none;
    background: var(--surface);
    border-bottom: 1px solid var(--rule);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px;
}

.top h1 { margin: 0; font-size: 16px; font-weight: 600; }
.top .crumb { font-size: 11px; color: var(--muted); }
.sp { flex: 1; }

.wrap {
    padding: 16px 20px 28px;
    display: flex;
    flex-direction: column;
    gap: 13px;
}

/* ---------- building blocks ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.card > .hd {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 15px;
    border-bottom: 1px solid #eceee9;
    flex-wrap: wrap;
}

.card h2 { margin: 0; font-size: 12.5px; font-weight: 600; }
.card .sub { font-size: 11px; color: var(--muted); }
.pad { padding: 13px 15px; }
.scroll { overflow-x: auto; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 11px; }

.kpi {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 8px;
    padding: 11px 13px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.kpi .lb { font-size: 9.5px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--label); }
.kpi .v { font-family: var(--mono); font-size: 28px; font-weight: 500; line-height: 1.1; letter-spacing: -.02em; }
.kpi .d { font-size: 10.5px; color: var(--muted); }

table { width: 100%; border-collapse: collapse; font-size: 12.5px; }

th {
    text-align: left;
    padding: 7px 11px;
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--label);
    background: #fafbf9;
    border-bottom: 1px solid var(--rule);
    white-space: nowrap;
}

td { padding: 7px 11px; border-bottom: 1px solid var(--rule-2); color: var(--ink-2); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #fafbf9; }
tr.sum td { font-weight: 600; background: #fafbf9; border-top: 1px solid var(--rule); }

.num { font-family: var(--mono); text-align: right; font-variant-numeric: tabular-nums; font-size: 12px; white-space: nowrap; }
th.num { text-align: right; font-family: var(--font); font-size: 9.5px; }
.strong { font-weight: 600; color: var(--ink); }
.mut { color: var(--muted); }
.pos { color: var(--accent-ink); }
.neg { color: var(--err-ink); }
.empty { padding: 22px 15px; color: var(--muted); text-align: center; }

.bg {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 19px;
    padding: 0 7px;
    border-radius: 4px;
    font-size: 10.5px;
    font-weight: 600;
    white-space: nowrap;
}

.ok { background: var(--ok-bg); color: var(--accent-ink); }
.wr { background: var(--warn-bg); color: var(--warn-ink); }
.er { background: var(--err-bg); color: var(--err-ink); }
.nu { background: var(--neutral-bg); color: var(--neutral-ink); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }

.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 10px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 11px; }

/* ---------- forms ---------- */

.fld { display: flex; flex-direction: column; gap: 5px; min-width: 0; }

.fld > label {
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--label);
}

input, select, textarea {
    font: inherit;
    font-size: 12.5px;
    color: var(--ink-2);
    background: var(--surface);
    border: 1px solid var(--field);
    border-radius: 6px;
    padding: 0 10px;
    height: 33px;
    min-width: 0;
}

textarea { height: auto; min-height: 56px; padding: 8px 10px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[type="checkbox"] { height: auto; }
input.num-in { font-family: var(--mono); text-align: right; width: 110px; }

button, .btn {
    font: inherit;
    font-size: 12.5px;
    font-weight: 500;
    height: 32px;
    padding: 0 12px;
    border: 1px solid var(--field);
    border-radius: 6px;
    background: var(--surface);
    color: var(--ink-2);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    text-decoration: none;
}

button:hover, .btn:hover { border-color: #c4c8c1; }
button.pri { background: var(--accent); border-color: var(--accent); color: #fff; }
button.pri:hover { background: var(--accent-ink); }
button.danger { color: var(--err-ink); }
button.sm { height: 27px; padding: 0 9px; font-size: 11.5px; }
button:disabled { opacity: .5; cursor: default; }

.chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 30px;
    padding: 6px 12px;
    border: 1px solid var(--field);
    border-radius: 20px;
    background: var(--surface);
    font-size: 12px;
    color: #4a5158;
    cursor: pointer;
}

.chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
a.chip { text-decoration: none; }

.msg { font-size: 12px; min-height: 16px; }
.msg.error { color: var(--err-ink); }
.msg.success { color: var(--accent-ink); }

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

.pager { display: flex; align-items: center; gap: 8px; padding: 10px 15px; border-top: 1px solid #eceee9; }

/* Narrow screens (e.g. a tablet): the menu becomes a bar on top. */
@media (max-width: 900px) {
    .app { flex-direction: column; }
    .side { width: auto; height: auto; position: static; flex-direction: row; align-items: center; gap: 8px; padding: 8px; overflow-x: auto; }
    .side .brand { display: none; }
    .nav { flex-direction: row; }
    .nav-sep { display: none; }
    .who { margin-top: 0; margin-left: auto; }
    .top { height: auto; min-height: 56px; flex-wrap: wrap; padding: 10px 14px; }
    .wrap { padding: 12px 14px 24px; }
    .grid2, .grid3 { grid-template-columns: 1fr; }
}

/* ---------- detail dialog ---------- */

dialog.detail {
    padding: 0;
    width: min(760px, calc(100vw - 32px));
    max-height: calc(100vh - 64px);
    overflow: auto;
}

dialog.detail::backdrop { background: rgba(20, 24, 27, .35); }
/* .card sets display:flex, which would show a closed dialog. */
dialog.detail:not([open]) { display: none; }

.field-view { display: flex; flex-direction: column; gap: 2px; }
.field-view .k { font-size: 9.5px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--label); }
.field-view .v { color: var(--ink-2); }

/* Column chart (chart.js): the tooltip floats over the columns. */
.chart { position: relative; }
.chart svg { display: block; max-width: 100%; }
.chart svg rect[tabindex]:focus { outline: none; }
.chart svg rect[tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.chart-tip {
    position: absolute;
    transform: translate(-50%, -100%);
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 6px;
    padding: 6px 10px;
    box-shadow: 0 2px 8px rgba(22, 25, 29, 0.12);
    pointer-events: none;
    display: flex;
    flex-direction: column;
    white-space: nowrap;
    font-size: 12px;
    color: var(--muted);
}
.chart-tip strong { color: var(--ink); font-size: 13px; }

/* A long comment in a table: one line, the rest in the tooltip. */
td.note { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
