:root {
    --brand: #1B4965;
    --brand-dark: #143a52;
    --accent: #5FA8D3;
    --ink: #1c2733;
    --muted: #5b6b78;
    --line: #d9e0e6;
    --bg: #f4f6f8;
    --surface: #ffffff;
    --ok: #2e7d32;
    --warn: #b3261e;
    --crit: #b3261e;
    --high: #d17a00;
    --med: #1B4965;
    --low: #5b6b78;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font: 15px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif;
    color: var(--ink);
    background: var(--bg);
}

a { color: var(--brand); }

.topbar {
    display: flex; align-items: center; gap: 24px;
    background: var(--brand); color: #fff;
    padding: 0 24px; height: 56px;
}
.topbar__brand { color: #fff; font-weight: 600; text-decoration: none; font-size: 16px; }
.topbar__nav { display: flex; gap: 18px; flex: 1; }
.topbar__nav a { color: #dbe7ef; text-decoration: none; }
.topbar__nav a:hover { color: #fff; }
.topbar__user { display: flex; align-items: center; gap: 12px; color: #dbe7ef; }
.inline { display: inline; margin: 0; }
.linkbtn { background: none; border: 0; color: #dbe7ef; cursor: pointer; font: inherit; padding: 0; }
.linkbtn:hover { color: #fff; text-decoration: underline; }
.linkbtn--danger { color: var(--warn); }
.linkbtn--danger:hover { color: var(--warn); }

.content { max-width: 1040px; margin: 24px auto; padding: 0 24px; }
.sitefoot { max-width: 1040px; margin: 32px auto; padding: 0 24px; color: var(--muted); font-size: 13px; }

h1 { font-size: 24px; margin: 0 0 4px; }
h2.entry__legend { font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 24px 0 10px; }
h3.subhead { font-size: 13px; color: var(--ink); margin: 16px 0 6px; font-weight: 600; }

.toast {
    max-width: 1040px; margin: 12px auto 0; padding: 10px 16px;
    background: #e7f2e7; border: 1px solid var(--ok); border-radius: 6px; color: #1e561f;
}

.alert { padding: 10px 14px; border-radius: 6px; margin: 0 0 16px; }
.alert--error { background: #fbeceb; border: 1px solid var(--warn); color: #7a1a15; }
.alert:empty { display: none; }

/* forms */
.entry, .auth, .home, .queue, .detail { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 24px; }
.auth { max-width: 420px; margin: 40px auto; }
.entry__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.entry__hint, .home__lead { color: var(--muted); }
.entry__block { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 8px; }

.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 18px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field--wide { grid-column: span 2; }
.field--full { grid-column: 1 / -1; }
.field label, .field__label, .field > span { font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea,
.stack input, .stack select, .stack textarea {
    padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px;
    font: inherit; color: var(--ink); background: #fff; width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.field__error { color: var(--warn); font-size: 12px; }
.field__note { color: var(--muted); font-size: 12px; }

.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; }

.entry__actions { display: flex; align-items: center; gap: 12px; margin-top: 20px; }

.btn { display: inline-block; padding: 9px 16px; border-radius: 6px; border: 1px solid transparent;
       font: inherit; cursor: pointer; text-decoration: none; }
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-dark); }
.btn--quiet { background: #fff; border-color: var(--line); color: var(--brand); }
.btn--quiet:hover { border-color: var(--accent); }

.priority { font-weight: 600; }
.priority[data-level="critical"] { color: var(--crit); }
.priority[data-level="high"] { color: var(--high); }
.priority[data-level="medium"] { color: var(--med); }
.priority[data-level="low"] { color: var(--low); }

.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; background: #eef2f5; color: var(--muted); font-size: 13px; }
.pill--warn { background: #fbeceb; color: var(--warn); }
.pill--use { background: #e7f2e7; color: var(--ok); }

/* used-by expander on shared peripherals */
.usedby summary { cursor: pointer; color: var(--brand); white-space: nowrap; }
.usedby summary:hover { text-decoration: underline; }
.usedby ul { margin: 6px 0 2px; padding-left: 16px; max-height: 220px; overflow-y: auto; }
.usedby li { font-size: 13px; }

/* tables */
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
.table-scroll .grid-table { margin-top: 0; white-space: nowrap; }
.table-scroll .grid-table th, .table-scroll .grid-table td { padding: 8px 12px; }
.grid-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.grid-table th, .grid-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 14px; }
.grid-table th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.row--breached td { background: #fdf3f2; }
.row--hidden td { background: #f6f2f8; opacity: .7; }

/* row action links (users, departments) */
.rowactions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; white-space: nowrap; }
.rowactions .linkbtn { color: var(--brand); }
.rowactions .linkbtn--danger { color: var(--warn); }

/* internal notes */
.notes__form { display: grid; gap: 10px; margin: 8px 0 16px; max-width: 640px; }
.notes { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 12px; }
.note { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; background: var(--card, #fff); }
.note__meta { display: flex; gap: 10px; align-items: baseline; }
.note__body { margin: 6px 0 0; white-space: pre-wrap; }
.note__shots { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.note__thumb { max-width: 180px; max-height: 140px; border: 1px solid var(--line); border-radius: 6px; display: block; }

/* detail */
.detail__cols { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; }
.detail__side { border-left: 1px solid var(--line); padding-left: 24px; }
.detail__badges { display: flex; gap: 8px; align-items: center; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.facts__inline { color: var(--muted); }
.detail__desc { white-space: pre-wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.home__actions { display: flex; gap: 12px; margin-top: 16px; }

/* filter bar */
.filterbar { display: flex; gap: 10px; align-items: center; margin: 4px 0 16px; flex-wrap: wrap; }
.filterbar input[type="text"], .filterbar input:not([type]), .filterbar select {
    padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font: inherit; min-width: 220px;
}

/* dashboard tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin: 20px 0; }
.tile { display: flex; flex-direction: column; gap: 4px; padding: 18px; background: #fff;
        border: 1px solid var(--line); border-radius: 8px; text-decoration: none; color: var(--ink); }
a.tile:hover { border-color: var(--accent); }
.tile__num { font-size: 30px; font-weight: 700; color: var(--brand); line-height: 1; }
.tile__label { font-size: 13px; color: var(--muted); }
.tile--warn .tile__num { color: var(--warn); }

/* settings editor */
.settings { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.settings__head, .settings__row {
    display: grid; grid-template-columns: 1.4fr 1.4fr 2fr auto; gap: 10px; align-items: center;
}
.settings__head { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: 0 2px 4px; }
.settings__row { margin: 0; }
.settings__row code { font-size: 13px; word-break: break-all; }
.settings__row input { padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; font: inherit; }

/* pager */
.pager { display: flex; gap: 12px; align-items: center; margin-top: 16px; }

/* executive dashboard */
.home__hint { color: var(--muted); margin: 0; }
.dash-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin: 20px 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 18px; }
.card .entry__legend { margin-top: 0; }

.bars { display: flex; flex-direction: column; gap: 8px; }
.bar { display: grid; grid-template-columns: 130px 1fr 40px; align-items: center; gap: 10px; }
.bar__label { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar__track { background: #eef2f5; border-radius: 5px; height: 16px; overflow: hidden; }
.bar__fill { display: block; height: 100%; background: var(--brand); border-radius: 5px; min-width: 2px; }
.bar__fill[data-level="critical"] { background: var(--crit); }
.bar__fill[data-level="high"] { background: var(--high); }
.bar__fill[data-level="medium"] { background: var(--med); }
.bar__fill[data-level="low"] { background: var(--low); }
.bar__val { font-size: 13px; font-weight: 600; text-align: right; }

.trend { display: flex; align-items: flex-end; gap: 6px; height: 140px; margin-top: 6px; }
.trend__col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; }
.trend__bars { flex: 1; display: flex; align-items: flex-end; gap: 3px; width: 100%; justify-content: center; }
.trend__bar { width: 42%; border-radius: 3px 3px 0 0; min-height: 1px; }
.trend__bar--c { background: var(--accent); }
.trend__bar--r { background: var(--brand); }
.trend__day { font-size: 10px; color: var(--muted); }
.trend__key { display: flex; gap: 16px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; }
.swatch--c { background: var(--accent); }
.swatch--r { background: var(--brand); }

@media (max-width: 720px) {
    .dash-grid { grid-template-columns: 1fr; }
    .bar { grid-template-columns: 100px 1fr 32px; }
}

@media (max-width: 720px) {
    .grid, .detail__cols { grid-template-columns: 1fr; }
    .detail__side { border-left: 0; padding-left: 0; }
    .field--wide { grid-column: auto; }
    .settings__head { display: none; }
    .settings__row { grid-template-columns: 1fr; }
}
