/* ==========================================================================
   ITAMS — Al Saeedi Group
   Light / dark theme via [data-theme] on <html> (set by js/theme.js).
   No inline styles anywhere: the CSP only allows this stylesheet.
   ========================================================================== */

:root {
    --brand: #ed2130;            /* Al Saeedi red (logo) */
    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-2: #f1f4f6;        /* inputs, table headers */
    --surface-hover: #f7f9fa;
    --border: #e2e7eb;
    --border-strong: #cfd7dd;
    --text: #1c2328;
    --muted: #5e6b75;
    --primary: #17657d;          /* teal, as in the reference screenshots */
    --primary-hover: #11526a;
    --primary-soft: #e3f0f4;
    --on-primary: #ffffff;
    --success: #23804a;
    --success-soft: #e5f4ea;
    --warning: #a8620a;
    --warning-soft: #fdf1df;
    --danger: #c42b2b;
    --danger-soft: #fbe7e7;
    --info: #17657d;
    --info-soft: #e3f0f4;
    --focus: rgba(23, 101, 125, .35);
    --shadow: 0 1px 2px rgba(16, 24, 32, .05), 0 1px 3px rgba(16, 24, 32, .04);
    --shadow-lg: 0 10px 30px rgba(16, 24, 32, .12);
    --topbar-h: 68px;            /* 3px brand line + 64px bar + 1px border */
    --radius: 10px;
    --radius-sm: 7px;
    --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;
    --mono: Consolas, "SFMono-Regular", Menlo, monospace;
    color-scheme: light;
}

:root[data-theme="dark"] {
    --bg: #0f1518;
    --surface: #161e22;
    --surface-2: #1d272c;
    --surface-hover: #1b2429;
    --border: #2a353b;
    --border-strong: #3a474e;
    --text: #e5eaed;
    --muted: #97a6af;
    --primary: #4cb0ca;
    --primary-hover: #6cc2d8;
    --primary-soft: #16343d;
    --on-primary: #08222a;
    --success: #55c27e;
    --success-soft: #15301f;
    --warning: #e3a447;
    --warning-soft: #33280f;
    --danger: #f07070;
    --danger-soft: #3a1a1a;
    --info: #4cb0ca;
    --info-soft: #16343d;
    --focus: rgba(76, 176, 202, .4);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, .45);
    color-scheme: dark;
}

/* No-JS fallback: follow the OS setting */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --bg: #0f1518; --surface: #161e22; --surface-2: #1d272c; --surface-hover: #1b2429;
        --border: #2a353b; --border-strong: #3a474e; --text: #e5eaed; --muted: #97a6af;
        --primary: #4cb0ca; --primary-hover: #6cc2d8; --primary-soft: #16343d; --on-primary: #08222a;
        --success: #55c27e; --success-soft: #15301f; --warning: #e3a447; --warning-soft: #33280f;
        --danger: #f07070; --danger-soft: #3a1a1a; --info: #4cb0ca; --info-soft: #16343d;
        --focus: rgba(76, 176, 202, .4);
        color-scheme: dark;
    }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 650; }
p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: inline-block; vertical-align: middle; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: .9em; }

.icon { width: 18px; height: 18px; flex: none; }
.icon--sm { width: 14px; height: 14px; }

.container { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 24px; }

.skip-link {
    position: absolute; left: -9999px; top: 8px; z-index: 100;
    background: var(--surface); padding: 8px 12px; border-radius: var(--radius-sm);
}
.skip-link:focus { left: 8px; }

/* Logo: show the variant that matches the theme */
.logo--on-dark { display: none; }
:root[data-theme="dark"] .logo--on-light { display: none; }
:root[data-theme="dark"] .logo--on-dark { display: inline-block; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) .logo--on-light { display: none; }
    :root:not([data-theme]) .logo--on-dark { display: inline-block; }
}

/* Theme toggle icon: moon in light mode, sun in dark mode */
.theme-icon { display: inline-flex; }
.theme-icon--dark { display: none; }
:root[data-theme="dark"] .theme-icon--light { display: none; }
:root[data-theme="dark"] .theme-icon--dark { display: inline-flex; }

/* ---------- Top bar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 20;
    background: var(--surface);
    border-top: 3px solid var(--brand);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.topbar__inner { display: flex; align-items: center; gap: 16px; min-height: 64px; padding: 0 20px; }
.topbar .topbar__menu { display: none; }

.brand { display: flex; align-items: center; gap: 12px; color: var(--text); flex: none; }
.brand:hover { text-decoration: none; }
.brand__logo { height: 42px; width: auto; }
.brand__text { display: flex; flex-direction: column; line-height: 1.2; padding-left: 12px; border-left: 1px solid var(--border); }
.brand__text strong { font-size: 15px; font-weight: 650; }
.brand__text small { font-size: 12.5px; color: var(--muted); }

.topbar__actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

/* User menu (<details>) */
.usermenu { position: relative; }
.usermenu__trigger {
    display: flex; align-items: center; gap: 8px; list-style: none; cursor: pointer;
    padding: 4px 8px 4px 4px; border-radius: 999px; border: 1px solid var(--border);
}
.usermenu__trigger::-webkit-details-marker { display: none; }
.usermenu__trigger:hover { background: var(--surface-2); }
.usermenu__name { font-weight: 550; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usermenu__panel {
    position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); padding: 6px; z-index: 30;
}
.usermenu__meta { display: flex; flex-direction: column; padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.usermenu__meta span { font-size: 13px; color: var(--muted); }
.usermenu__item {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 8px 10px; border: 0; border-radius: var(--radius-sm); background: none;
    color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.usermenu__item:hover { background: var(--surface-2); text-decoration: none; }
.usermenu form { margin: 0; }

.avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--brand); color: #fff; font-size: 12px; font-weight: 700; letter-spacing: .02em;
}

/* ---------- Shell: sidebar + main ---------- */
.shell { display: flex; align-items: flex-start; min-height: calc(100vh - var(--topbar-h)); }
.sidebar {
    position: sticky; top: var(--topbar-h); flex: none; width: 236px;
    height: calc(100vh - var(--topbar-h)); overflow-y: auto;
    background: var(--surface); border-right: 1px solid var(--border);
    padding: 16px 12px;
}
.sidenav { display: flex; flex-direction: column; gap: 2px; }
.sidenav__link, .sidenav__heading {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: var(--radius-sm);
    color: var(--muted); font-weight: 550; white-space: nowrap;
}
.sidenav__link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.sidenav__link.is-active { background: var(--primary-soft); color: var(--primary); }
.sidenav__link.is-active::before {
    content: ""; position: absolute; left: 0; width: 3px; height: 22px; border-radius: 0 3px 3px 0; background: var(--brand);
}
.sidenav__link { position: relative; }
.sidenav__link.is-disabled { opacity: .55; cursor: not-allowed; }
.sidenav__link.is-disabled:hover { background: none; color: var(--muted); }
.sidenav__soon {
    margin-left: auto; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
    padding: 1px 6px; border-radius: 999px; background: var(--surface-2);
}
.sidenav__group { margin: 10px 0; padding: 6px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.sidenav__heading { font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; padding-top: 6px; padding-bottom: 4px; }
.sidenav__group.is-active .sidenav__heading { color: var(--text); }
.sidenav__group .sidenav__link { padding-left: 40px; }
.sidebar-backdrop { display: none; }

.shell__main { flex: 1; min-width: 0; padding: 0 28px; }
.main { padding-top: 24px; padding-bottom: 32px; display: flex; flex-direction: column; gap: 20px; max-width: 1280px; }
.footer { padding-bottom: 24px; color: var(--muted); font-size: 13px; }

.page-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.page-head__icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 48px; height: 48px; border-radius: 12px; background: var(--primary); color: var(--on-primary); flex: none;
}
.page-head__icon .icon { width: 24px; height: 24px; }
.page-head__text { flex: 1; min-width: 200px; }
.page-head__text h1 { font-size: 24px; }
.page-head__text p { color: var(--muted); margin-top: 2px; }
.page-head__actions { display: flex; gap: 8px; flex-wrap: wrap; }

.grid { display: grid; gap: 20px; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); }

/* ---------- Cards ---------- */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px;
}
.card--narrow { max-width: 520px; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card__head form { margin: 0; }
.card__title { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.card > .card__title { margin-bottom: 12px; }
.card__head .card__title { margin-bottom: 0; }

/* KPI tiles (coloured left edge, as in the reference) */
.kpis { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.kpi {
    display: flex; flex-direction: column; gap: 4px;
    background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--primary);
    border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
}
.kpi__value { font-size: 28px; font-weight: 700; line-height: 1.1; }
.kpi__label { color: var(--muted); font-size: 14px; }
.kpi--success { border-left-color: var(--success); }
.kpi--warning { border-left-color: var(--warning); }
.kpi--warning .kpi__value { color: var(--warning); }
.kpi--danger { border-left-color: var(--danger); }
.kpi--danger .kpi__value { color: var(--danger); }
.kpi--muted { border-left-color: var(--border-strong); }

/* Key/value list */
.kv { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 8px 20px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* Requirement checklist */
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist__item { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.checklist__item:last-child { border-bottom: 0; }
.checklist__status { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; flex: none; }
.checklist__status.is-ok { background: var(--success-soft); color: var(--success); }
.checklist__status.is-fail { background: var(--danger-soft); color: var(--danger); }
.checklist__label { flex: 1; }
.checklist__detail { color: var(--muted); font-size: 13px; text-align: right; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 40px; padding: 8px 16px;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text);
    font: inherit; font-weight: 550; line-height: 1.2; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn--primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn--primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--ghost { border-color: transparent; background: transparent; }
.btn--ghost:hover { background: var(--surface-2); }
.btn--icon { width: 40px; padding: 0; }
.btn--block { width: 100%; }

/* ---------- Forms ---------- */
.form-stack { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 14px; font-weight: 550; color: var(--muted); }
.input, select, textarea {
    width: 100%; min-height: 42px; padding: 9px 12px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface-2); color: var(--text); font: inherit;
}
.input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--primary); background: var(--surface);
    box-shadow: 0 0 0 3px var(--focus);
}
.input[aria-invalid="true"] { border-color: var(--danger); }
.field__error { color: var(--danger); font-size: 13.5px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.form-actions--center { justify-content: center; }

/* ---------- Alerts / flash ---------- */
.flash-stack { display: flex; flex-direction: column; gap: 10px; }
.alert {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 11px 14px; border-radius: var(--radius-sm);
    border: 1px solid transparent; border-left-width: 4px; font-size: 14.5px;
}
.alert__text { flex: 1; }
.alert__close {
    border: 0; background: none; color: inherit; cursor: pointer; padding: 2px;
    opacity: .7; border-radius: 4px; line-height: 0;
}
.alert__close:hover { opacity: 1; }
.alert__close .icon { width: 16px; height: 16px; }
.alert--success { background: var(--success-soft); border-color: var(--success); color: var(--text); }
.alert--error { background: var(--danger-soft); border-color: var(--danger); color: var(--text); }
.alert--warning { background: var(--warning-soft); border-color: var(--warning); color: var(--text); }
.alert--info { background: var(--info-soft); border-color: var(--info); color: var(--text); }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 10px; border-radius: 999px; border: 1px solid currentColor;
    font-size: 13px; font-weight: 600; line-height: 1.5; white-space: nowrap;
}
.badge--success { color: var(--success); background: var(--success-soft); }
.badge--warning { color: var(--warning); background: var(--warning-soft); }
.badge--danger { color: var(--danger); background: var(--danger-soft); }
.badge--muted { color: var(--muted); background: var(--surface-2); }
.badge--info { color: var(--info); background: var(--info-soft); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.table th {
    text-align: left; font-weight: 600; color: var(--muted); font-size: 13.5px;
    background: var(--surface-2); padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-hover); }

/* ---------- Page furniture ---------- */
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.breadcrumbs { display: flex; flex-wrap: wrap; gap: 6px; font-size: 13.5px; color: var(--muted); margin-bottom: -10px; }
.code-chip {
    display: inline-block; padding: 1px 8px; border-radius: 6px; vertical-align: middle;
    background: var(--primary-soft); color: var(--primary); font-family: var(--mono); font-size: .8em; font-weight: 700;
}
.page-head__text h1 .code-chip { font-size: 15px; margin-left: 6px; }
.page-head__text p { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pre-line { white-space: pre-line; }
.section-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Search / filter bar */
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.toolbar .input { background: var(--surface); }
.toolbar__search { flex: 1 1 240px; width: auto; min-width: 0; }
.toolbar__select { flex: 0 1 190px; width: auto; min-width: 0; }
.toolbar__field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 550; flex: 0 1 190px; }

/* Cards: variants */
.card--flush { padding: 0; overflow: hidden; }
.card--flush .table-wrap { border: 0; border-radius: 0; }
.card--form { max-width: 860px; }
.card__note { padding: 14px 20px; color: var(--muted); border-top: 1px solid var(--border); }
.kv--cols { grid-template-columns: max-content 1fr; }
.placeholder { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 40px 20px; text-align: center; color: var(--muted); }
.placeholder > .icon { width: 32px; height: 32px; }
.placeholder .card__title { margin: 0; color: var(--text); }

/* Tabs (branch page) */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; margin-bottom: -6px; }
.tabs__link {
    display: inline-flex; align-items: center; gap: 6px; padding: 10px 14px; white-space: nowrap;
    color: var(--muted); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs__link:hover { color: var(--text); text-decoration: none; }
.tabs__link.is-active { color: var(--primary); border-bottom-color: var(--primary); }
.tabs__count { font-size: 12px; padding: 0 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }

/* Form layout */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.field--wide { grid-column: 1 / -1; }
.field__help { color: var(--muted); font-size: 13px; }
.req { color: var(--danger); }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 8px 0; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.form-grid + .form-actions { margin-top: 20px; }
[data-upper] { text-transform: uppercase; }
.input[readonly] { opacity: .75; cursor: not-allowed; }
textarea.input { resize: vertical; min-height: 84px; }

/* Inline "add" row under a table (locations) */
.inline-add { padding: 16px 20px 20px; border-top: 1px solid var(--border); background: var(--surface-hover); }
.inline-add .card__title { margin-bottom: 10px; font-size: 15px; }
.inline-add__fields { display: grid; grid-template-columns: 2fr 1fr auto; gap: 12px; align-items: start; }
.inline-add__submit { padding-top: 27px; }
.inline-add .input { background: var(--surface); }

/* Small buttons & inline forms in table rows */
.btn--sm { min-height: 32px; padding: 4px 10px; font-size: 13.5px; gap: 6px; }
.btn--danger-outline { color: var(--danger); }
.btn--danger-outline:hover { background: var(--danger-soft); border-color: var(--danger); }
.inline-form { display: inline; margin: 0; }

/* Table extras */
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; width: 1%; }
.table .actions .btn + .inline-form, .table .actions .inline-form + .btn { margin-left: 6px; }
.table td.empty { text-align: center; color: var(--muted); padding: 32px 14px; }
.table .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.table tr.is-inactive td { color: var(--muted); }
.table tr.is-inactive td a:not(.btn) { color: var(--muted); }
.table .nowrap, .nowrap { white-space: nowrap; }
.table .dot { margin: 0 6px; color: var(--border-strong); }
.table--audit td { font-size: 14px; }
.tag-link { font-weight: 650; font-family: var(--mono); }
.icon--ok { color: var(--success); }
.sub-label { font-size: 12.5px; color: var(--muted); }
.table-wrap--plain { border: 0; border-radius: 0; }

/* Audit change lists */
.changes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; font-size: 13.5px; }
.changes__field { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.changes__old { text-decoration: line-through; color: var(--danger); }
.changes__new { color: var(--success); }
.changes-details summary { cursor: pointer; color: var(--primary); font-size: 13.5px; }
.changes-details .changes { margin-top: 6px; }

/* Pagination */
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-top: -6px; }
.pager__info { color: var(--muted); font-size: 13.5px; }
.pager__links { display: flex; flex-wrap: wrap; gap: 4px; }
.pager__link, .pager__gap {
    display: inline-flex; align-items: center; justify-content: center; min-width: 36px; height: 36px; padding: 0 10px;
    border-radius: var(--radius-sm); font-size: 14px; font-weight: 550;
}
.pager__link { border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.pager__link:hover { background: var(--surface-2); text-decoration: none; }
.pager__link.is-current { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.pager__gap { color: var(--muted); }

/* ---------- Assets ---------- */
[hidden] { display: none !important; }
.badge--xs { font-size: 11px; padding: 0 7px; margin-left: 4px; vertical-align: middle; }
.alert__link { font-weight: 600; margin-left: 4px; }
.meta { color: var(--muted); font-size: 13px; margin-top: 12px; }
.mono-title { font-family: var(--mono); letter-spacing: .01em; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: -6px; }
.section-head h2 { font-size: 18px; display: flex; align-items: center; gap: 8px; }

.filters { display: flex; flex-direction: column; gap: 10px; }
.filters__row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filters__search { flex: 1 1 320px; width: auto; min-width: 0; background: var(--surface); }
.filters__row--selects .input { flex: 1 1 160px; width: auto; min-width: 0; background: var(--surface); }
.filters__row--selects .btn { flex: none; }

.bulkbar {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 8px 12px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm);
    background: var(--surface); margin-bottom: -8px;
}
.bulkbar .input { width: auto; flex: 0 1 220px; min-height: 36px; padding: 6px 10px; }
.bulkbar .btn { min-height: 36px; }
.bulkbar__count { color: var(--muted); font-size: 13.5px; font-weight: 600; min-width: 80px; }
.bulkbar.has-selection { border-style: solid; border-color: var(--primary); background: var(--primary-soft); }
.bulkbar.has-selection .bulkbar__count { color: var(--primary); }
.check-col { width: 36px; }
.check-col input { width: 17px; height: 17px; accent-color: var(--primary); }
.sort-link { color: inherit; }
.sort-link.is-active { color: var(--primary); }

.input-group { display: flex; gap: 8px; }
.input-group .input { flex: 1; min-width: 0; }
.input--mono, .input-group .input--mono { font-family: var(--mono); }
.form-grid--inner { gap: 12px; }
.card--form .card__title { margin-bottom: 14px; }
.asset-form { display: flex; flex-direction: column; gap: 16px; }
.form-actions--sticky {
    position: sticky; bottom: 0; z-index: 5; padding: 12px 0;
    background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.tag-check:empty { display: none; }
.tag-check { font-size: 13.5px; }
.tag-check__dupes { padding: 8px 12px; border-radius: var(--radius-sm); background: var(--danger-soft); border-left: 3px solid var(--danger); }
.tag-check__dupes ul { margin: 4px 0 0; padding-left: 18px; }
.tag-check__warn { padding: 6px 12px; margin-top: 6px; border-radius: var(--radius-sm); background: var(--warning-soft); border-left: 3px solid var(--warning); }
.check--warning { color: var(--danger); font-weight: 600; padding: 4px 0; }

/* Detail page */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 380px); gap: 20px; align-items: start; }
.detail-grid__main, .detail-grid__side { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.actions-stack { display: flex; flex-direction: column; gap: 8px; }
.action-panel { border: 1px solid var(--border); border-radius: var(--radius-sm); }
.action-panel > summary {
    display: flex; align-items: center; gap: 8px; padding: 9px 12px; cursor: pointer;
    font-weight: 600; list-style: none;
}
.action-panel > summary::-webkit-details-marker { display: none; }
.action-panel > summary:hover { background: var(--surface-2); }
.action-panel[open] > summary { border-bottom: 1px solid var(--border); }
.action-panel > form { padding: 12px; gap: 10px; }
.credentials .action-panel { margin-top: 14px; }

.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.timeline__item { display: flex; gap: 10px; padding: 0 0 14px; position: relative; }
.timeline__item:not(:last-child)::before {
    content: ""; position: absolute; left: 13px; top: 28px; bottom: 2px; width: 2px; background: var(--border);
}
.timeline__icon {
    flex: none; width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
    background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.timeline__item--created .timeline__icon, .timeline__item--imported .timeline__icon { background: var(--success-soft); color: var(--success); }
.timeline__item--transferred .timeline__icon { background: var(--info-soft); color: var(--info); }
.timeline__item--deleted .timeline__icon, .timeline__item--repair_opened .timeline__icon { background: var(--warning-soft); color: var(--warning); }
.timeline__body { min-width: 0; font-size: 14px; }
.timeline__body > span { color: var(--muted); margin-left: 4px; }
.timeline__details { margin-top: 2px; overflow-wrap: anywhere; }
.timeline__meta { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

.secret { display: inline-block; min-width: 110px; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); margin-right: 6px; }
.secret.is-revealed { background: var(--warning-soft); user-select: all; }
.secret__timer { font-size: 13px; margin-left: 6px; }
.reconfirm { margin-top: 12px; padding: 12px; border-radius: var(--radius-sm); background: var(--surface-2); display: flex; flex-direction: column; gap: 8px; }

/* ---------- Guest pages (login, errors) ---------- */
.guest { min-height: 100vh; display: flex; flex-direction: column; border-top: 3px solid var(--brand); }
.guest__theme { position: absolute; top: 14px; right: 14px; }
.guest__main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 56px 16px 24px; }
.guest__footer { text-align: center; color: var(--muted); font-size: 13px; padding: 16px; }

.auth-card { width: 100%; max-width: 400px; padding: 32px 28px; display: flex; flex-direction: column; gap: 16px; }
.auth-card__brand { text-align: center; }
.auth-card__logo { height: 84px; width: auto; }
.auth-card__title { text-align: center; font-size: 20px; }
.auth-card__subtitle { text-align: center; color: var(--muted); margin-top: -10px; }

.error-card { text-align: center; }
.error-card__code { font-size: 44px; font-weight: 750; color: var(--brand); line-height: 1; }
.error-card .auth-card__subtitle { margin-top: 0; }

/* Development exception page */
.exception { display: flex; flex-direction: column; gap: 12px; }
.exception .badge { align-self: flex-start; }
.exception__message { font-size: 20px; overflow-wrap: anywhere; }
.exception__trace {
    margin: 0; padding: 14px; overflow-x: auto; font-family: var(--mono); font-size: 13px;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .usermenu__name { display: none; }
    .topbar__inner { padding: 0 12px; gap: 8px; }
    .shell { display: block; }
    .shell__main { padding: 0 16px; }

    /* With JS: off-canvas sidebar opened by the menu button. Without JS: stacked above content. */
    .js .topbar .topbar__menu { display: inline-flex; }
    .sidebar { position: static; width: auto; height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
    .js .sidebar {
        position: fixed; top: 0; left: 0; bottom: 0; z-index: 40; width: 270px; height: 100vh;
        border-right: 1px solid var(--border); box-shadow: var(--shadow-lg);
        transform: translateX(-105%); transition: transform .2s ease; visibility: hidden;
    }
    .sidebar-open .sidebar { transform: none; visibility: visible; }
    .sidebar-open .sidebar-backdrop {
        display: block; position: fixed; inset: 0; z-index: 35; background: rgba(10, 16, 20, .45);
    }
    .sidebar-open body { overflow: hidden; }
}
@media (prefers-reduced-motion: reduce) {
    .js .sidebar { transition: none; }
}
@media (max-width: 600px) {
    .container { padding: 0 16px; }
    .brand__text { display: none; }
    .brand__logo { height: 36px; }
    .page-head__text h1 { font-size: 21px; }
    .page-head__icon { width: 42px; height: 42px; }
    .card { padding: 16px; }
    .card--flush { padding: 0; }
    .table td:first-child { min-width: 150px; }
    .kv, .kv--cols { grid-template-columns: 1fr; gap: 2px; }
    .form-grid { grid-template-columns: 1fr; }
    .inline-add__fields { grid-template-columns: 1fr; }
    .inline-add__submit { padding-top: 0; }
    .toolbar__select, .toolbar__field { flex: 1 1 100%; }
    .kv dd { margin-bottom: 8px; }
    .auth-card { padding: 24px 20px; }
}

@media print {
    .topbar, .footer, .flash-stack, .btn { display: none !important; }
    body { background: #fff; }
}

@media (max-width: 1100px) {
    .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
    .filters__row--selects .input { flex-basis: 100%; }
    .bulkbar .input { flex: 1 1 100%; }
    .input-group { flex-wrap: wrap; }
}

/* ---------- Dashboard ---------- */
a.kpi { color: var(--text); transition: border-color .15s, box-shadow .15s; }
a.kpi:hover { text-decoration: none; box-shadow: var(--shadow-lg); }
.kpi--info { border-left-color: var(--info); }
.stack { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.bars__row { display: grid; grid-template-columns: minmax(110px, 38%) 1fr 44px; align-items: center; gap: 12px; font-size: 14.5px; }
.bars__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars__label a { color: var(--text); }
.bars__track { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bars__fill { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--primary); transition: width .4s ease; }
.bars__fill--success { background: var(--success); }
.bars__fill--info { background: var(--info); }
.bars__fill--warning { background: var(--warning); }
.bars__fill--danger { background: var(--danger); }
.bars__fill--muted { background: var(--border-strong); }
.bars__value { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }
.issue-list { list-style: none; margin: 0; padding: 0; }
.issue-list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.issue-list li:last-child { border-bottom: 0; }
.issue-list span { color: var(--muted); font-variant-numeric: tabular-nums; }
.tabs__count--alert { background: var(--danger-soft); color: var(--danger); }
.dup-group__title { display: flex; align-items: center; gap: 8px; padding: 14px 20px 10px; font-size: 16px; }
.page-head__actions .input { width: auto; min-width: 220px; background: var(--surface); }
@media (prefers-reduced-motion: reduce) { .bars__fill { transition: none; } }
.grid { align-items: start; }

/* ---------- Import ---------- */
.kpis--compact { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.kpis--compact .kpi { padding: 12px 14px; }
.kpis--compact .kpi__value { font-size: 22px; }
.input--sm { min-height: 32px; padding: 4px 8px; font-size: 13.5px; }
.table--compact td, .table--compact th { padding: 7px 10px; }
.table--compact .input--sm { min-width: 120px; }
.table--import { font-size: 13.5px; }
.table--import td { padding: 8px 10px; }
.table .small, .small { font-size: 13px; }
.import-row--skip td { color: var(--muted); }
.import-row--skip td:not(:nth-child(2)) { opacity: .7; }
.import-row.has-error td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.import-row.has-warning td:first-child { box-shadow: inset 3px 0 0 var(--warning); }
.decision { width: auto; min-width: 92px; font-weight: 600; }
.decision--import { color: var(--success); }
.decision--merge, .decision--append { color: var(--info); }
.decision--skip { color: var(--muted); }
.decision-form { display: flex; flex-direction: column; gap: 2px; margin: 0; }
.decision-form__state { font-size: 11.5px; color: var(--muted); min-height: 14px; }
.issues-cell { min-width: 220px; }
.issue { display: block; font-size: 12.5px; line-height: 1.35; padding: 3px 7px; margin-bottom: 3px; border-radius: 5px; border-left: 3px solid; }
.issue--error { background: var(--danger-soft); border-color: var(--danger); }
.issue--warning { background: var(--warning-soft); border-color: var(--warning); }
.issue--info { background: var(--info-soft); border-color: var(--info); color: var(--muted); }
.row-edit summary { cursor: pointer; color: var(--primary); font-size: 12.5px; font-weight: 600; margin-top: 2px; }
.row-edit__form { display: grid; grid-template-columns: repeat(2, minmax(110px, 1fr)); gap: 6px 8px; margin-top: 6px; padding: 8px; background: var(--surface-2); border-radius: var(--radius-sm); }
.row-edit__form label { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); font-weight: 600; }
.row-edit__wide { grid-column: 1 / -1; }
.row-edit__form .btn { grid-column: 1 / -1; justify-self: start; }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.issue-list__label { color: var(--text) !important; }
details.card > summary { cursor: pointer; }
.table--compact td { white-space: nowrap; }
.table--compact td .input--sm { display: inline-block; width: 150px; }
.table--compact td .badge { margin-left: 6px; }
details.people > summary { list-style: none; margin-bottom: 0; }
details.people > summary::-webkit-details-marker { display: none; }
details.people[open] > summary { margin-bottom: 14px; }

/* ---------- Attachments, repairs, network, settings ---------- */
.record-list { list-style: none; margin: 0 0 12px; padding: 0; }
.record-list__item { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.record-list__item:last-child { border-bottom: 0; }
.record-list__main { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.record-list__main p { margin-top: 2px; }
.record-list__actions { display: flex; gap: 6px; flex-wrap: wrap; }
.thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); flex: none; }
.thumb--file { display: inline-flex; align-items: center; justify-content: center; background: var(--surface-2); color: var(--muted); }
.upload-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding-top: 12px; border-top: 1px solid var(--border); }
.upload-row .input { flex: 1 1 220px; width: auto; }
.upload-row .field__help, .upload-row .field__error { flex-basis: 100%; }
.cell-dup { background: var(--danger-soft); }
.subhead { font-size: 15px; margin: 20px 0 4px; }
.form-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 12px; }
@media (max-width: 900px) { .form-grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.install-card { max-width: 600px; }
.install-card .checklist { margin-bottom: 4px; }
.page-head__actions .check--warning { padding: 0 6px 0 0; }
.migration-banner .alert__text .icon { margin-right: 4px; vertical-align: -2px; }
