/* Facturación de líneas — layout E8.1, CAST branding. Light theme. Fonts self-hosted, no external assets. */
@font-face {
    font-family: "Dosis";
    src: url("/fonts/dosis-latin-var.woff2") format("woff2");
    font-weight: 200 800;
    font-style: normal;
    font-display: swap;
}
:root {
    color-scheme: light;
    /* CAST brand (cast.com.py): blue #51a7db, green #a2c659, orange #f58220, logo ink #2b2a29.
       The bright brand hues are decorative only; text and controls use darker shades (WCAG AA). */
    --brand-blue: #51a7db;
    --brand-green: #a2c659;
    --brand-orange: #f58220;
    --ink: #2b2a29;          /* headings, logo grey */
    --ink-2: #f1f6fa;        /* sidebar hover */
    --blue: #1b6a9c;         /* primary accent, 5.9:1 on white */
    --blue-strong: #14547c;
    --blue-soft: #e8f3fa;
    --paper: #f5f7f8;        /* page background */
    --surface: #ffffff;
    --line: #dfe5ea;
    --line-soft: #eef1f4;
    --text: #22272c;
    --muted: #5b6570;
    --ok: #3d6b14;      --ok-bg: #eef6e2;
    --warn: #8a4a00;    --warn-bg: #fdefe0;
    --bad: #9b2226;     --bad-bg: #f8e3e3;
    --grey: #4a5566;    --grey-bg: #eceff3;
    --radius: 6px;
    --sidebar: 15.5rem;
    --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-brand: "Dosis", "Segoe UI", system-ui, sans-serif;
    --stripe: linear-gradient(90deg, var(--brand-orange) 0 33.3%, var(--brand-green) 33.3% 66.6%, var(--brand-blue) 66.6%);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font: 15px/1.5 var(--font);
    background: var(--paper);
    color: var(--text);
}
a { color: var(--blue); }
a:hover { color: var(--blue-strong); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
code { font-size: 0.85em; }
.tnum { font-variant-numeric: tabular-nums; white-space: nowrap; }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ------------------------------------------------------------------ shell */
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
    background: var(--surface);
    color: var(--text);
    border-right: 1px solid var(--line);
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
    padding: 0 0.75rem 1rem;
}
.sidebar::before { content: ""; display: block; height: 4px; margin: 0 -0.75rem 1.25rem; background: var(--stripe); }
.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 0.5rem; padding: 0 0.5rem 1.25rem; color: var(--ink); text-decoration: none; }
.brand:hover { color: var(--ink); }
.brand-logo { display: block; width: 8.5rem; height: auto; }
.brand-text { line-height: 1.2; font-family: var(--font-brand); }
.brand-text strong { display: block; font-size: 1.05rem; font-weight: 600; }
.brand-text span { font-size: 0.85rem; color: var(--muted); font-weight: 500; }

.nav { display: flex; flex-direction: column; gap: 2px; font-family: var(--font-brand); font-size: 1.02rem; }
.nav a {
    display: flex; align-items: center; gap: 0.65rem;
    padding: 0.5rem 0.75rem; border-radius: 5px;
    color: var(--text); text-decoration: none; font-weight: 500;
    border-left: 3px solid transparent;
}
.nav a:hover { background: var(--ink-2); color: var(--blue-strong); }
.nav a[aria-current="page"] { background: var(--blue-soft); color: var(--blue-strong); border-left-color: var(--brand-blue); font-weight: 600; }
.nav svg { width: 1.1rem; height: 1.1rem; flex: none; opacity: 0.85; }

.user { margin-top: auto; border-top: 1px solid var(--line); padding: 1rem 0.5rem 0; }
.user-id { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.6rem; }
.avatar {
    width: 2rem; height: 2rem; border-radius: 50%; background: var(--blue-soft); color: var(--blue-strong);
    display: grid; place-items: center; font-weight: 700; font-size: 0.85rem; flex: none; font-family: var(--font-brand);
}
.user-id small { display: block; color: var(--muted); font-size: 0.75rem; }
.user-id strong { color: var(--ink); font-weight: 600; }
.user-actions { display: flex; flex-direction: column; gap: 2px; }
.user-actions a, .user-actions button {
    all: unset; cursor: pointer; display: block;
    padding: 0.4rem 0.5rem; border-radius: 4px; font-size: 0.88rem; color: var(--text);
}
.user-actions a:hover, .user-actions button:hover { background: var(--ink-2); color: var(--blue-strong); }
.user-actions a:focus-visible, .user-actions button:focus-visible { outline: 2px solid var(--blue); }

.app-version { margin: 0.75rem 0 0; padding: 0 0.75rem; font-size: 0.75rem; color: var(--muted); }
.app-version code { font-size: 0.75rem; }
.mobile-bar { display: none; }
#nav-toggle { position: absolute; opacity: 0; pointer-events: none; }
.scrim { display: none; }

.content { padding: 1.75rem 2.25rem 4rem; max-width: 84rem; width: 100%; }

/* ------------------------------------------------------------------ page header */
.page-head { margin-bottom: 1.5rem; }
.crumbs { font-size: 0.85rem; color: var(--muted); margin-bottom: 0.35rem; }
.crumbs ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.35rem; }
.crumbs li + li::before { content: "/"; margin-right: 0.35rem; color: #a3adbb; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--blue); text-decoration: underline; }
.page-head-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-family: var(--font-brand); font-size: 1.8rem; line-height: 1.2; color: var(--ink); font-weight: 600; }
.page-head .sub { margin: 0.3rem 0 0; color: var(--muted); }
.page-actions { margin-left: auto; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.page-actions form { margin: 0; display: flex; }

h2 { font-family: var(--font-brand); font-size: 1.25rem; color: var(--ink); margin: 2rem 0 0.75rem; font-weight: 600; }

/* ------------------------------------------------------------------ buttons & forms */
.btn, button.btn {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.5rem 0.95rem; border-radius: 5px; border: 1px solid var(--blue);
    background: var(--blue); color: #fff; font: inherit; font-family: var(--font-brand); font-weight: 600; font-size: 0.98rem; letter-spacing: 0.01em;
    text-decoration: none; cursor: pointer; line-height: 1.2;
}
.btn:hover { background: var(--blue-strong); border-color: var(--blue-strong); color: #fff; }
.btn-ghost, button.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover, button.btn-ghost:hover { background: var(--blue-soft); color: var(--ink); border-color: #c4d2e4; }
.btn svg { width: 1rem; height: 1rem; }
.btn-sm, button.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.88rem; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-ghost:disabled:hover { background: var(--surface); border-color: var(--line); }

/* ------------------------------------------------------------------ xlsx download: service picker */
.download-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin: 1.5rem 0 0.5rem; scroll-margin-top: 1rem; }
.download-card form { margin: 0; }
.download-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.download-head h2 { margin: 0; }
.download-head .sub { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.9rem; }
.download-head .btn { margin-left: auto; }
.picker-count:empty { display: none; }
.picker-count { background: rgba(255, 255, 255, 0.22); border-radius: 999px; padding: 0 0.5rem; font-variant-numeric: tabular-nums; font-size: 0.85rem; }
.picker-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 0.75rem; padding: 0.75rem 1.25rem; border-bottom: 1px solid var(--line-soft); }
.picker-tools input[type=search] { flex: 1 1 16rem; width: auto; }
.picker-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.picker-status { flex-basis: 100%; margin: 0; font-size: 0.82rem; color: var(--muted); }
.picker-status:empty { display: none; }
.picker-list { border: 0; margin: 0; padding: 0.75rem 1.25rem 1rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 0.4rem; max-height: 22rem; overflow-y: auto; }
.picker-item { display: grid; grid-template-columns: auto 1fr; column-gap: 0.55rem; align-items: center; padding: 0.45rem 0.65rem; border: 1px solid var(--line); border-radius: 5px; cursor: pointer; user-select: none; }
.picker-item:hover { border-color: #c4d2e4; background: var(--ink-2); }
.picker-item input { grid-row: span 2; margin: 0; width: 1rem; height: 1rem; accent-color: var(--blue); }
.picker-item:has(input:checked) { background: var(--blue-soft); border-color: var(--blue); }
.picker-item:has(input:focus-visible) { outline: 2px solid var(--blue); outline-offset: 1px; }
.picker-name { font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.picker-meta { font-size: 0.78rem; color: var(--muted); overflow-wrap: anywhere; }
.picker-item[hidden] { display: none; }
.download-card p.empty { text-align: center; color: var(--muted); padding: 1.5rem 1rem; margin: 0; }

.field { margin-bottom: 1rem; }
.field label, .filters label { display: block; font-weight: 600; font-size: 0.85rem; margin-bottom: 0.3rem; color: var(--ink); }
.field .hint { font-size: 0.8rem; color: var(--muted); margin-top: 0.25rem; }
input[type=date], input[type=text], input[type=search], input[type=password], select {
    font: inherit; font-size: 0.92rem; color: var(--text);
    padding: 0.45rem 0.6rem; border: 1px solid #c8d1dc; border-radius: 5px; background: #fff;
    width: 100%; max-width: 22rem;
}
input:focus, select:focus { outline: 2px solid var(--blue); outline-offset: 0; border-color: var(--blue); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem 1.5rem; }
.panel.narrow { max-width: 30rem; }

.alert { padding: 0.7rem 1rem; border-radius: 5px; margin-bottom: 1rem; border: 1px solid; }
.alert-bad { background: var(--bad-bg); color: var(--bad); border-color: #efc7c7; }
.alert-ok { background: var(--ok-bg); color: var(--ok); border-color: #bfdfcb; }
.alert-warn { background: var(--warn-bg); color: var(--warn); border-color: #efd6a8; }

/* ------------------------------------------------------------------ figures (resumen) */
.figures { display: flex; flex-wrap: wrap; gap: 2.5rem; padding: 1.1rem 1.5rem; margin-bottom: 0.5rem;
           background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--brand-blue); border-radius: var(--radius); }
.figure .value { font-family: var(--font-brand); font-size: 2.2rem; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1.1; }
.figure .label { font-size: 0.85rem; color: var(--muted); }

/* ------------------------------------------------------------------ tables */
.table-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table-tools { display: flex; flex-wrap: wrap; align-items: end; gap: 0.75rem 1rem; padding: 0.85rem 1rem; border-bottom: 1px solid var(--line); }
.filters { display: flex; flex-wrap: wrap; align-items: end; gap: 0.75rem; }
.filters input, .filters select { width: auto; min-width: 9rem; }
.filters input[type=search] { min-width: 15rem; }
.tabs { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.tabs a { padding: 0.35rem 0.75rem; border-radius: 999px; text-decoration: none; color: var(--muted); font-size: 0.88rem; border: 1px solid transparent; }
.tabs a:hover { background: var(--line-soft); color: var(--ink); }
.tabs a[aria-current="true"] { background: var(--blue-soft); color: var(--blue-strong); border-color: #c4d2e4; font-weight: 600; }
.tabs .count { font-variant-numeric: tabular-nums; opacity: 0.8; margin-left: 0.2rem; }
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
th, td { padding: 0.55rem 0.85rem; text-align: left; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
thead th {
    background: #f8f9fb; color: var(--muted); font-weight: 600; font-size: 0.8rem;
    border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0;
}
tbody tr:hover td { background: #f7f9fc; }
tbody tr:last-child td { border-bottom: 0; }
tr.not-billable td { color: var(--muted); }
tr.total-row td { font-weight: 700; background: var(--blue-soft); color: var(--ink); border-top: 1px solid #c4d2e4; }
td.empty { text-align: center; color: var(--muted); padding: 2.5rem 1rem; }
td.evidence code { display: block; max-width: 28rem; white-space: pre-wrap; word-break: break-all; color: var(--muted); font-size: 0.78rem; }
.row-link { font-weight: 600; text-decoration: none; }
.row-link:hover { text-decoration: underline; }
.actions a { margin-right: 0.75rem; }

/* ------------------------------------------------------------------ badges */
.badge { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 4px; font-size: 0.75rem; font-weight: 600; line-height: 1.5; white-space: nowrap; border: 1px solid transparent; }
.badge-ok, .badge-activa { background: var(--ok-bg); color: var(--ok); border-color: #c5e2d1; }
.badge-sin-dato { background: var(--bad-bg); color: var(--bad); border-color: #efc7c7; }
.badge-baja { background: var(--grey-bg); color: #7a2e2e; border-color: #e0d2d2; }
.badge-no-factura { background: repeating-linear-gradient(135deg, #f1f3f6 0 6px, #e8ebf0 6px 12px); color: var(--grey); border-color: var(--line); }
.badge-warn { background: var(--warn-bg); color: var(--warn); border-color: #efd6a8; }
.badge-muted { background: var(--grey-bg); color: var(--grey); }
.badge-version { background: var(--blue-soft); color: var(--blue-strong); border-color: #d2deec; font-weight: 600; }

/* ------------------------------------------------------------------ pager */
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem 1.5rem;
         padding: 0.75rem 1rem; border-top: 1px solid var(--line); font-size: 0.87rem; color: var(--muted); }
.pager-count { font-variant-numeric: tabular-nums; }
.pager-count strong { color: var(--ink); font-weight: 600; }
.pager-pages { display: flex; flex-wrap: wrap; gap: 0.2rem; list-style: none; margin: 0; padding: 0; }
.pager-pages a, .pager-pages span {
    display: inline-grid; place-items: center; min-width: 2rem; height: 2rem; padding: 0 0.5rem;
    border-radius: 5px; text-decoration: none; color: var(--ink); font-variant-numeric: tabular-nums;
    border: 1px solid transparent;
}
.pager-pages a:hover { background: var(--blue-soft); border-color: #c4d2e4; }
.pager-pages a[aria-current="page"] { background: var(--blue); color: #fff; font-weight: 600; }
.pager-pages span.disabled { color: #b0b8c4; }
.pager-pages span.gap { min-width: 1.25rem; padding: 0; }
.pager-size { display: flex; align-items: center; gap: 0.4rem; margin: 0; }
.pager-size select { width: auto; padding: 0.25rem 0.4rem; font-size: 0.87rem; }
.pager-size label { font-weight: 400; margin: 0; }
.js .pager-size .btn { display: none; }

/* ------------------------------------------------------------------ login */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: var(--paper); }
.login-box { width: 100%; max-width: 24rem; background: var(--surface); border: 1px solid var(--line);
             border-radius: 8px; padding: 2rem; box-shadow: 0 12px 32px rgba(43, 42, 41, 0.08); position: relative; overflow: hidden; }
.login-box::before { content: ""; position: absolute; inset: 0 0 auto; height: 5px; background: var(--stripe); }
.login-box .brand { padding: 0.25rem 0 1.5rem; gap: 0.9rem; }
.login-box .brand-logo { width: 10.5rem; }
.login-box input { max-width: none; }
.login-box .btn { width: 100%; justify-content: center; padding: 0.65rem; margin-top: 0.5rem; }

/* ------------------------------------------------------------------ logout dialog */
.confirm-dialog { border: 1px solid var(--line); border-radius: 8px; padding: 1.5rem; max-width: 24rem; width: calc(100% - 2rem);
                  color: var(--text); background: var(--surface); box-shadow: 0 20px 48px rgba(43, 42, 41, 0.2); }
.confirm-dialog::backdrop { background: rgba(43, 42, 41, 0.45); }
.confirm-dialog h2 { margin: 0 0 0.5rem; }
.confirm-dialog p { margin: 0 0 1.25rem; color: var(--muted); }
.confirm-actions { display: flex; justify-content: flex-end; gap: 0.5rem; flex-wrap: wrap; }

/* ------------------------------------------------------------------ help */
.help { max-width: 50rem; }
.help-tools { margin-bottom: 1.5rem; }
.help-search { position: relative; margin-bottom: 0.9rem; }
.help-search svg { position: absolute; left: 0.85rem; top: 50%; width: 1.15rem; height: 1.15rem; transform: translateY(-50%);
                   fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; pointer-events: none; }
.help-search input[type=search] { max-width: none; padding: 0.7rem 0.9rem 0.7rem 2.6rem; font-size: 1rem; border-radius: 8px; }
.help-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; }
.help-index { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.help-index a { padding: 0.3rem 0.75rem; border-radius: 999px; border: 1px solid #c9dbe8; background: var(--surface);
                color: var(--blue-strong); text-decoration: none; font-size: 0.86rem; font-weight: 600; }
.help-index a:hover { background: var(--blue-soft); }
.help-toggle-all { display: flex; gap: 0.25rem; }
.help-status { margin: 0.6rem 0 0; font-size: 0.85rem; color: var(--muted); }
.help-status:empty { display: none; }
.help-empty { padding: 1.25rem; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); }
.linklike { all: unset; color: var(--blue); text-decoration: underline; cursor: pointer; }
.linklike:focus-visible { outline: 2px solid var(--blue); }
.help-section { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 1.25rem; scroll-margin-top: 1rem; overflow: hidden; }
.help-section h2 { display: flex; align-items: center; gap: 0.65rem; margin: 0; padding: 0.9rem 1.1rem; border-bottom: 1px solid var(--line); }
.help-icon { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 6px; background: var(--blue-soft); flex: none; }
.help-icon svg { width: 1.15rem; height: 1.15rem; fill: none; stroke: var(--blue); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.help details { border-bottom: 1px solid var(--line-soft); }
.help details:last-child { border-bottom: 0; }
.help summary { cursor: pointer; list-style: none; display: flex; align-items: flex-start; gap: 0.6rem;
                padding: 0.8rem 1.1rem; font-weight: 600; color: var(--ink); }
.help summary::-webkit-details-marker { display: none; }
.help summary:hover { color: var(--blue-strong); background: #fafcfd; }
.help summary:focus-visible { outline-offset: -2px; }
.help .chev { width: 1.1rem; height: 1.1rem; margin-top: 0.15rem; flex: none; fill: none; stroke: var(--blue); stroke-width: 2.2;
              stroke-linecap: round; stroke-linejoin: round; transition: transform 0.15s ease; }
.help details[open] > summary .chev { transform: rotate(90deg); }
.help details[open] > summary { color: var(--blue-strong); }
.help details > :not(summary) { margin: 0 1.1rem 0.9rem 2.8rem; max-width: 70ch; line-height: 1.6; }
.help details > :last-child { margin-bottom: 1.1rem; }
.help ol, .help ul { padding-left: 1.2rem; }
.help li + li { margin-top: 0.3rem; }
.help dl { display: grid; grid-template-columns: max-content 1fr; gap: 0.45rem 1rem; }
.help dt { font-weight: 600; color: var(--ink); }
.help dd { margin: 0; }

/* ------------------------------------------------------------------ users */
.users-table td { vertical-align: middle; }
.user-cell { display: inline-flex; align-items: center; gap: 0.6rem; }
.user-cell strong { color: var(--ink); font-weight: 600; }
.user-cell .avatar { width: 1.9rem; height: 1.9rem; }
tr.is-disabled .user-cell strong, tr.is-disabled .avatar { opacity: 0.55; }
.role-badge { background: var(--grey-bg); color: var(--grey); border-color: var(--line); }
.role-superadmin { background: #fdf0e3; color: #8a4a00; border-color: #f1d3b0; }
.role-admin { background: var(--blue-soft); color: var(--blue-strong); border-color: #cfe1ee; }
.last-change small { color: var(--muted); }
.last-change .none { color: var(--muted); }
th.col-actions { text-align: right; }
.row-actions { display: flex; justify-content: flex-end; flex-wrap: nowrap; gap: 0.25rem; }
.row-actions form { margin: 0; }
.btn-row {
    display: inline-flex; align-items: center; gap: 0.35rem; white-space: nowrap;
    padding: 0.32rem 0.6rem; border-radius: 5px; border: 1px solid transparent; background: transparent;
    color: var(--blue); font: inherit; font-size: 0.85rem; font-weight: 600; text-decoration: none; cursor: pointer; line-height: 1.2;
}
.btn-row svg { width: 0.95rem; height: 0.95rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-row:hover { background: var(--blue-soft); border-color: #cfe1ee; color: var(--blue-strong); }
.btn-row-bad { color: var(--bad); }
.btn-row-bad:hover { background: var(--bad-bg); border-color: #efc7c7; color: var(--bad); }
.btn-row:disabled { color: #9aa4b0; cursor: not-allowed; background: transparent; border-color: transparent; }
.tip { position: relative; display: inline-flex; border-radius: 5px; }
.tip::after {
    content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); right: 0; z-index: 5;
    background: var(--ink); color: #fff; font-size: 0.78rem; font-weight: 500; padding: 0.35rem 0.55rem; border-radius: 4px;
    white-space: nowrap; opacity: 0; visibility: hidden; transition: opacity 0.12s; pointer-events: none;
}
.tip:hover::after, .tip:focus-visible::after { opacity: 1; visibility: visible; }
.btn-bad, button.btn-bad { background: var(--bad); border-color: var(--bad); }
.btn-bad:hover, button.btn-bad:hover { background: #7d1b1f; border-color: #7d1b1f; }
.flash { display: flex; align-items: center; gap: 0.5rem; }

/* Form dialogs: modal with JS; without JS the targeted one shows inline under the table. */
.form-dialog { border: 1px solid var(--line); border-radius: 10px; padding: 1.5rem; width: calc(100% - 2rem); max-width: 26rem;
               color: var(--text); background: var(--surface); box-shadow: 0 20px 48px rgba(43, 42, 41, 0.2); }
.form-dialog::backdrop { background: rgba(43, 42, 41, 0.45); }
.form-dialog h2 { margin: 0 0 1rem; }
.form-dialog input, .form-dialog select { max-width: none; }
.form-dialog .confirm-actions { margin-top: 1.25rem; }
html:not(.has-dialog) .form-dialog:target { display: block; position: static; margin: 1.5rem 0 0; box-shadow: none; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 4.5rem; }
.pw-toggle { display: none; position: absolute; right: 0.3rem; top: 50%; transform: translateY(-50%);
             border: 0; background: transparent; color: var(--blue); font: inherit; font-size: 0.8rem; font-weight: 600;
             padding: 0.25rem 0.5rem; border-radius: 4px; cursor: pointer; }
.pw-toggle:hover { background: var(--blue-soft); }
.js .pw-toggle { display: block; }

/* ------------------------------------------------------------------ narrow screens */
@media (max-width: 900px) {
    .shell { grid-template-columns: minmax(0, 1fr); }
    .mobile-bar {
        display: flex; align-items: center; gap: 0.75rem; position: sticky; top: 0; z-index: 20;
        background: var(--surface); color: var(--ink); padding: 0.6rem 1rem; border-bottom: 1px solid var(--line);
    }
    .mobile-bar .brand { padding: 0; }
    .burger { display: grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: 5px; cursor: pointer; color: var(--ink); }
    .burger:hover { background: var(--ink-2); }
    .burger svg { width: 1.4rem; height: 1.4rem; }
    #nav-toggle:focus-visible + .mobile-bar .burger { outline: 2px solid var(--blue); }
    .mobile-bar .brand { flex-direction: row; align-items: center; }
    .mobile-bar .brand-logo { width: 4.5rem; }
    .sidebar {
        position: fixed; z-index: 30; left: 0; top: 0; width: min(18rem, 85vw);
        transform: translateX(-100%); transition: transform 0.2s ease, visibility 0.2s; visibility: hidden;
    }
    .scrim { display: none; position: fixed; inset: 0; background: rgba(43, 42, 41, 0.45); z-index: 25; }
    #nav-toggle:checked ~ .shell .sidebar { transform: none; visibility: visible; box-shadow: 0 0 40px rgba(0, 0, 0, 0.3); }
    #nav-toggle:checked ~ .scrim { display: block; }
    .content { padding: 1.25rem 1rem 3rem; }
    .page-head h1 { font-size: 1.5rem; }
    .help dl { grid-template-columns: 1fr; }
    .help dd { margin-bottom: 0.5rem; }
    .page-actions { margin-left: 0; }
    .figures { gap: 1.25rem; }
    .figure .value { font-size: 1.6rem; }
    .filters, .filters > div { width: 100%; }
    .filters input, .filters select, .filters input[type=search] { width: 100%; min-width: 0; max-width: none; }
    .pager { justify-content: center; }
    td { white-space: nowrap; }
    td.evidence code { min-width: 16rem; }
}
@media (max-width: 900px) {
    .users-table td.col-actions { white-space: normal; }
    .help details > :not(summary) { margin-left: 1.1rem; }
    .help-toggle-all { width: 100%; justify-content: flex-end; }
}
@media (max-width: 640px) {
    /* Users: each row becomes a compact card, no horizontal scroll. */
    .users-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .users-table, .users-table tbody { display: block; }
    .users-table tr { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.5rem; padding: 0.85rem 1rem; border-bottom: 1px solid var(--line-soft); }
    .users-table tbody tr:last-child { border-bottom: 0; }
    .users-table td { display: block; padding: 0; border: 0; white-space: normal; }
    .users-table tbody tr:hover td { background: none; }
    .users-table td:first-child { flex-basis: 100%; }
    .users-table td.last-change { flex-basis: 100%; font-size: 0.8rem; color: var(--muted); }
    .users-table td.col-actions { flex-basis: 100%; }
    .row-actions { justify-content: flex-start; flex-wrap: wrap; margin-left: -0.6rem; }
    .tip::after { right: auto; left: 0; }
    .page-head-row .page-actions { margin-left: auto; }
}
@media (prefers-reduced-motion: reduce) { .sidebar, .help .chev, .tip::after { transition: none; } }

/* Security screens (E6.11–E6.16) */
.badge-bad { background: var(--bad-bg); color: var(--bad); border-color: #efc7c7; }
.security-cell .badge { margin: 0 0.2rem 0.2rem 0; }
.last-login { font-size: 0.75rem; opacity: 0.8; margin: 0.5rem 0 0; }
.login-title { font-size: 1.15rem; margin: 0 0 0.5rem; }
.login-alt { margin-top: 1rem; font-size: 0.85rem; }
.qr-box { margin: 0.75rem 0; }
.qr-box .qr { width: 200px; height: 200px; display: block; }
.secret { word-spacing: 0.3em; }
.steps > li { margin-bottom: 1.25rem; }
.recovery-codes { columns: 2; font-size: 1rem; padding-left: 1.5rem; }
.recovery-codes li { margin-bottom: 0.35rem; }
.filters { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end; margin-bottom: 1rem; }
.filters .field { margin: 0; }
.audit-detail code { font-size: 0.75rem; white-space: pre-wrap; word-break: break-word; }
.strength { height: 6px; border-radius: 3px; background: var(--line); margin-top: 0.4rem; overflow: hidden; }
.strength > span { display: block; height: 100%; width: 0; transition: width 0.2s; background: var(--bad); }
.strength[data-score="2"] > span { background: var(--warn); }
.strength[data-score="3"] > span, .strength[data-score="4"] > span { background: var(--ok); }
.strength-msg { font-size: 0.8rem; margin: 0.25rem 0 0; min-height: 1.1em; }
