/*
  ARX Multi — sistema visual
  1. Claridad: etiquetas, estados y cifras con contexto.
  2. Consistencia: mismos radios, botones, campos y tablas.
  3. Jerarquía: lo importante es más grande y tiene más contraste.
  4. Feedback: hover, foco, página activa y avisos.
  5. Control: menú, salir, cerrar aviso y mostrar contraseña.
  6. Accesibilidad: contraste, foco visible, áreas de 40px, reduced motion.
  7. Eficiencia: navegación agrupada, accesos del día y filtros en una fila.
*/

:root {
    color-scheme: light;
    --ink: #1c1714;
    --ink-soft: #5e564e;
    --paper: #f4f0e8;
    --paper-2: #e8e1d6;
    --surface: #fffdf9;
    --line: #e3dbd0;
    --line-strong: #d3c8b8;
    --sidebar: #241c17;
    --sidebar-2: #312820;
    --sidebar-text: #f7f1e8;
    --sidebar-muted: #c4b8ab;
    --copper: #9a431f;
    --copper-deep: #7c3518;
    --copper-soft: #f8ebe3;
    --sage: #215c45;
    --sage-soft: #e5f3ec;
    --amber: #8a5a10;
    --amber-soft: #fbf3e2;
    --danger: #8f2d2d;
    --danger-soft: #fdeeee;
    --shadow: 0 1px 2px rgba(36, 28, 23, 0.04), 0 16px 40px rgba(36, 28, 23, 0.06);
    --radius: 16px;
    --font: "Manrope", "Segoe UI", sans-serif;
    --display: "Outfit", "Segoe UI", sans-serif;
    --sidebar-w: 260px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--paper);
}

body.is-app {
    background:
        radial-gradient(880px 380px at 100% -8%, rgba(154, 67, 31, 0.08), transparent 55%),
        var(--paper);
}

::selection { background: #f0d2c2; color: var(--ink); }

:focus { outline: none; }

:focus-visible {
    outline: 2px solid var(--copper);
    outline-offset: 2px;
}

.skip {
    position: absolute;
    left: 1rem;
    top: -3rem;
    z-index: 80;
    background: var(--ink);
    color: #fff;
    padding: 0.6rem 0.9rem;
    border-radius: 8px;
    text-decoration: none;
}

.skip:focus { top: 0.75rem; }

.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;
}

a { color: var(--copper-deep); text-underline-offset: 3px; }

a:hover { color: var(--copper); }

h1, h2, h3 { color: var(--ink); line-height: 1.2; }

h1 {
    margin: 0 0 0.35rem;
    font-family: var(--display);
    font-size: clamp(1.7rem, 2vw, 2.15rem);
    font-weight: 560;
    letter-spacing: -0.03em;
}

h2 {
    margin: 0 0 0.85rem;
    font-size: 1.05rem;
    font-weight: 680;
    letter-spacing: -0.01em;
}

p { margin: 0.35rem 0; }

img { max-width: 100%; height: auto; }

.shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 28%),
        var(--sidebar);
    color: var(--sidebar-text);
}

.brand-row {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin: 0.85rem 0.7rem 0.15rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    flex: 1;
    padding: 0.35rem;
    color: inherit;
    text-decoration: none;
    border-radius: 12px;
}

.brand > span:last-child { min-width: 0; }

.brand:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }

.brand-mark {
    display: grid;
    place-items: center;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 10px;
    background: linear-gradient(160deg, #d47a45, #8c3d1c);
    color: #fff8f3;
    font-family: var(--display);
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    flex: none;
}

.brand strong {
    display: block;
    overflow: hidden;
    font-size: 0.98rem;
    font-weight: 680;
    letter-spacing: -0.02em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.brand small {
    display: block;
    overflow: hidden;
    color: var(--sidebar-muted);
    font-size: 0.75rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-close {
    display: none;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--sidebar-text);
    cursor: pointer;
    flex: none;
}

.sidenav {
    flex: 1;
    overflow: auto;
    padding: 0.75rem 0.75rem 1.5rem;
}

.nav-label {
    margin: 1rem 0.7rem 0.35rem;
    color: var(--sidebar-muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-height: 2.5rem;
    margin: 0.1rem 0;
    padding: 0.4rem 0.7rem;
    border-radius: 10px;
    color: #efe7de;
    text-decoration: none;
    font-weight: 560;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

.nav-link.is-active {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    box-shadow: inset 3px 0 0 #e39a6a;
}

.nav-icon {
    width: 1.15rem;
    height: 1.15rem;
    flex: none;
}

.nav-backdrop { display: none; }

.workspace { min-width: 0; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 4rem;
    padding: 0.7rem 1.5rem;
    background: rgba(244, 240, 232, 0.88);
    border-bottom: 1px solid transparent;
    backdrop-filter: blur(14px);
}

.topbar-context {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.eyebrow {
    margin: 0;
    color: var(--ink-soft);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.topbar-page {
    margin: 0;
    font-weight: 680;
    letter-spacing: -0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.userbox {
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.avatar {
    display: grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 999px;
    background: var(--ink);
    color: #f7f1e8;
    font-size: 0.78rem;
    font-weight: 700;
    flex: none;
}

.userbox-meta { display: flex; flex-direction: column; line-height: 1.2; }

.userbox-meta strong { font-size: 0.92rem; }

.userbox-meta span {
    color: var(--ink-soft);
    font-size: 0.78rem;
    max-width: 14rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
}

.content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: min(1120px, 100%);
    margin: 0 auto;
    padding: 1.5rem 1.5rem 3rem;
}

.content > .card { margin-top: 0 !important; }

.flash {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: 0;
    padding: 0.8rem 0.95rem;
    border: 1px solid #b7dfc4;
    border-radius: 12px;
    background: var(--sage-soft);
    color: var(--sage);
    font-weight: 600;
}

.flash-close {
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    min-height: 2.25rem;
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem 1.3rem 1.35rem;
    overflow-x: auto;
}

.muted { color: var(--ink-soft); }

.lede {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem 0.65rem;
    margin: 0.15rem 0 0;
    color: var(--ink-soft);
}

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
}

.page-head h1 { margin-bottom: 0.2rem; }

.page-head > div:first-child { min-width: 0; }

.back-link {
    display: inline-flex;
    align-items: center;
    min-height: 2.25rem;
    margin-bottom: 0.45rem;
    font-weight: 680;
    text-decoration: none;
}

.notice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: 1rem 0;
    padding: 0.85rem 0.95rem;
    border: 1px solid #ead7ae;
    border-radius: 12px;
    background: var(--amber-soft);
    color: #5f430f;
}

.notice p { margin: 0; }

.context-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: 1rem 0;
    padding: 0.9rem 1rem;
    border: 1px solid #c9e4d4;
    border-radius: 12px;
    background: var(--sage-soft);
}

.context-card strong,
.context-card span { display: block; }

.context-card span { margin-top: 0.12rem; color: var(--sage); font-size: 0.9rem; }

.detail-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
    margin: 1.1rem 0;
}

.detail-item {
    min-width: 0;
    padding: 0.8rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
}

.detail-item dt {
    color: var(--ink-soft);
    font-size: 0.75rem;
    font-weight: 750;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.detail-item dd {
    margin: 0.25rem 0 0;
    overflow-wrap: anywhere;
    font-weight: 600;
}

.detail-wide { grid-column: 1 / -1; }

.form-section {
    margin: 1rem 0;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fcfaf7;
}

.form-section h2 { margin-bottom: 0.2rem; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 1rem;
    margin-top: 0.85rem;
}

.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.field { min-width: 0; }

.field-full { grid-column: 1 / -1; }

.help {
    display: block;
    margin: -0.55rem 0 0.9rem;
    color: var(--ink-soft);
    font-size: 0.82rem;
    line-height: 1.35;
}

.table-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.55rem;
    white-space: nowrap;
}

.btn-small {
    min-height: 2rem;
    padding: 0.25rem 0.65rem;
    border-radius: 8px;
    font-size: 0.84rem;
}

.money { font-variant-numeric: tabular-nums; white-space: nowrap; }

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.7rem;
    margin: 1rem 0;
}

.summary-item {
    min-width: 0;
    padding: 0.85rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
}

.summary-item span,
.summary-item strong { display: block; }

.summary-item span { color: var(--ink-soft); font-size: 0.78rem; font-weight: 700; }

.summary-item strong { margin-top: 0.2rem; font-size: 1.15rem; }

.summary-primary {
    grid-column: span 2;
    border-color: #c9e4d4;
    background: var(--sage-soft);
}

.summary-primary strong { color: var(--sage); font-family: var(--display); font-size: 1.75rem; }

.sale-lines,
.package-lines {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    margin-top: 0.85rem;
}

.sale-line,
.package-line {
    display: grid;
    grid-template-columns: minmax(14rem, 2fr) minmax(7rem, 0.7fr) minmax(8rem, 0.8fr) auto;
    align-items: end;
    gap: 0.75rem;
    padding: 0.85rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
}

.sale-line[hidden],
.package-line[hidden] { display: none; }

.sale-line input,
.sale-line select,
.package-line input,
.package-line select { margin-bottom: 0; }

.sale-line .error,
.package-line .error { margin: 0.35rem 0 0; }

.sale-line-remove,
.package-line-remove { margin-bottom: 0; }

.balance-cell { min-width: 10rem; }

.balance-cell strong,
.balance-cell span { display: block; }

.balance-cell span { margin-top: 0.15rem; color: var(--ink-soft); font-size: 0.8rem; }

.pill-neutral { background: var(--paper-2); color: var(--ink-soft); }

.pill-cancelled { background: var(--danger-soft); color: var(--danger); }

.actions {
    display: flex;
    gap: 0.65rem;
    flex-wrap: wrap;
    align-items: center;
}

.actions h1, .actions h2 { margin: 0; }

.actions form { display: inline-flex; margin: 0; }

.actions > input,
.actions > select,
.actions > textarea {
    width: auto;
    flex: 1 1 14rem;
    max-width: 20rem;
    margin: 0;
}

.actions > select { flex: 0 1 11rem; max-width: 11rem; }

.actions input,
.actions select,
.actions textarea { margin: 0; }

.actions > label { margin: 0; }

.actions > a:not(.btn) {
    display: inline-flex;
    align-items: center;
    min-height: 2.5rem;
    padding: 0 0.2rem;
    font-weight: 680;
    text-decoration: none;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-height: 2.5rem;
    padding: 0.45rem 0.95rem;
    border: 1px solid var(--copper-deep);
    border-radius: 10px;
    background: var(--copper);
    color: #fffaf6;
    font: inherit;
    font-weight: 680;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.18) inset;
}

.btn:hover { background: var(--copper-deep); color: #fff; }

.btn:active { transform: translateY(1px); }

.btn-ghost {
    background: transparent;
    color: var(--copper-deep);
    box-shadow: none;
}

.btn-ghost:hover { background: var(--copper-soft); color: var(--copper-deep); }

label {
    display: inline-block;
    margin-top: 0.15rem;
    font-size: 0.92rem;
    font-weight: 680;
}

input,
select,
textarea {
    width: 100%;
    margin: 0.3rem 0 0.95rem;
    padding: 0.62rem 0.75rem;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
    font: inherit;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--copper);
    box-shadow: 0 0 0 3px rgba(154, 67, 31, 0.15);
    outline: none;
}

input[type="checkbox"],
input[type="radio"] {
    width: auto;
    margin-right: 0.4rem;
}

input[type="file"] { padding: 0.45rem; background: var(--paper); }

.field-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0.3rem 0 0.95rem;
}

.field-row input {
    flex: 1;
    width: auto;
    min-width: 0;
    margin: 0;
}

form .actions { margin-bottom: 0.85rem; }

.login-card .btn { width: 100%; margin-top: 0.35rem; }

.text-btn {
    border: 0;
    background: transparent;
    color: var(--copper-deep);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    min-height: 2.5rem;
    white-space: nowrap;
}

.error {
    margin: -0.45rem 0 0.85rem;
    color: var(--danger);
    font-size: 0.92rem;
    font-weight: 650;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.table-region {
    width: 100%;
    max-width: 100%;
    margin: 0.65rem 0;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-color: var(--line-strong) transparent;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}

.table-region:focus-visible {
    border-radius: 10px;
    outline: 2px solid var(--copper);
    outline-offset: 3px;
}

.table-region table { margin: 0 !important; }

.table-region::-webkit-scrollbar { height: 0.65rem; }

.table-region::-webkit-scrollbar-track { background: var(--paper); border-radius: 999px; }

.table-region::-webkit-scrollbar-thumb {
    border: 2px solid var(--paper);
    border-radius: 999px;
    background: var(--line-strong);
}

.table-scroll-hint { display: none; }

th, td {
    text-align: left;
    padding: 0.72rem 0.55rem;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

th {
    color: var(--ink-soft);
    font-size: 0.75rem;
    font-weight: 750;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

tbody tr:hover td { background: #fbf7f2; }

tbody td[colspan] {
    text-align: center;
    color: var(--ink-soft);
    padding: 1.4rem 0.5rem;
}

tbody th { text-transform: none; letter-spacing: 0; font-size: 0.92rem; color: var(--ink-soft); width: 11rem; }

pre {
    margin: 0.4rem 0 1rem;
    padding: 0.9rem 1rem;
    overflow: auto;
    border-radius: 12px;
    background: #241c17;
    color: #f7f1e8;
    font-size: 0.82rem;
    line-height: 1.45;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.8rem;
}

.kpi {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-height: 7.2rem;
    padding: 1rem 1.05rem 0.95rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.kpi-label {
    margin: 0;
    color: var(--ink-soft);
    font-size: 0.78rem;
    font-weight: 750;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.kpi-value {
    margin: 0.15rem 0 0;
    font-family: var(--display);
    font-size: 1.85rem;
    font-weight: 560;
    letter-spacing: -0.03em;
    line-height: 1.05;
}

.kpi-hint { margin: auto 0 0; color: var(--ink-soft); font-size: 0.88rem; }

.kpi-hero {
    grid-column: span 2;
    border: 0;
    background:
        radial-gradient(90% 120% at 100% 0%, rgba(232, 164, 112, 0.45), transparent 52%),
        linear-gradient(145deg, #2b221c 0%, #7d3b1c 100%);
    color: #fff8f3;
}

.kpi-hero .kpi-label,
.kpi-hero .kpi-hint { color: #f6dccb; }

.kpi-hero .kpi-value { font-size: clamp(2rem, 3vw, 2.7rem); }

.kpi-warn { background: var(--amber-soft); border-color: #ead7ae; }

.kpi-ok { background: var(--sage-soft); border-color: #c9e4d4; }

.kpi-wide {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    min-height: 0;
    gap: 1rem;
}

.kpi-wide .kpi-value { font-size: 1.65rem; }

.kpi-wide .kpi-hint { margin: 0; }

.pill {
    display: inline-flex;
    align-items: center;
    min-height: 1.6rem;
    padding: 0.1rem 0.55rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 750;
}

.pill-warn { background: #f3e0b8; color: var(--amber); }

.pill-ok { background: #d5eddf; color: var(--sage); }

.pill-low { background: var(--danger-soft); color: var(--danger); }

.shortcut-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.panel-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
    margin-bottom: 0.35rem;
}

.section-head h2 { margin: 0; }

.meter {
    height: 0.4rem;
    margin-top: 0.35rem;
    border-radius: 999px;
    background: var(--paper-2);
    overflow: hidden;
}

.meter > span {
    display: block;
    height: 100%;
    width: var(--fill);
    border-radius: inherit;
    background: linear-gradient(90deg, #c46a3a, #8c3d1c);
}

.rank-name { font-weight: 680; }

.report-group { display: flex; flex-direction: column; gap: 0.7rem; }

.report-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.7rem;
}

.report-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    min-height: 4.4rem;
    padding: 0.9rem 1rem;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow);
    color: var(--ink);
    text-decoration: none;
    font-weight: 680;
}

.report-link:hover {
    border-color: #e2c2ae;
    background: #fff8f4;
    color: var(--ink);
}

.report-go {
    color: var(--copper);
    font-family: var(--display);
    font-size: 1.25rem;
}

.login {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
    min-height: 100vh;
}

.login-story {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 2rem;
    padding: 2.5rem 3rem;
    background:
        radial-gradient(520px 280px at 10% 0%, rgba(212, 122, 69, 0.35), transparent 60%),
        linear-gradient(165deg, #2a211c, #4a2d22 55%, #1c1714);
    color: #f7f1e8;
}

.login-kicker {
    margin: 0 0 0.8rem;
    color: #f0c7b0;
    font-size: 0.78rem;
    font-weight: 750;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.login-story h1 {
    max-width: 12ch;
    color: #fffaf6;
    font-size: clamp(2.4rem, 4vw, 3.6rem);
}

.login-points {
    margin: 1.5rem 0 0;
    padding: 0;
    list-style: none;
    max-width: 34rem;
}

.login-points li {
    position: relative;
    margin: 0.7rem 0;
    padding-left: 1.3rem;
    color: #f3e6dc;
}

.login-points li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.55rem;
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 99px;
    background: #e39a6a;
}

.login-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.25rem;
    background: var(--paper);
}

.login-card {
    width: min(100%, 420px);
    padding: 1.6rem 1.5rem 1.4rem;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.login-card h1 { font-size: 1.85rem; }

.login-switch { margin: 1.1rem 0 0; }

@media (max-width: 960px) {
    .shell { grid-template-columns: 1fr; }

    .nav-toggle, .nav-close { display: inline-flex; }

    .sidebar {
        position: fixed;
        z-index: 40;
        width: min(86vw, 300px);
        transform: translateX(-105%);
        transition: transform 0.2s ease;
        box-shadow: var(--shadow);
    }

    body.nav-open .sidebar { transform: none; }

    body.nav-open .nav-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 30;
        background: rgba(28, 23, 18, 0.48);
    }

    body.nav-open { overflow: hidden; }

    .userbox-meta span { display: none; }

    .kpi-grid { grid-template-columns: 1fr 1fr; }

    .panel-grid,
    .report-grid { grid-template-columns: 1fr; }

    .detail-grid,
    .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

    .summary-primary { grid-column: span 2; }

    .sale-line,
    .package-line { grid-template-columns: minmax(12rem, 2fr) minmax(7rem, 1fr); }

    .login { grid-template-columns: 1fr; }

    .login-story { padding: 1.5rem 1.25rem 1.75rem; order: 2; }

    .login-story h1 { max-width: none; font-size: 2.2rem; }

    .login-panel { order: 1; padding-top: 1.25rem; }
}

@media (max-width: 640px) {
    .content { padding: 1rem 0.9rem 2.5rem; }

    .topbar { padding: 0.65rem 0.9rem; }

    .kpi-grid { grid-template-columns: 1fr; }

    .kpi-hero, .kpi-wide { grid-column: auto; }

    .kpi-wide { flex-direction: column; align-items: flex-start; }

    .page-head,
    .context-card,
    .notice { align-items: flex-start; flex-direction: column; }

    .form-grid,
    .form-grid-3,
    .detail-grid,
    .summary-grid,
    .sale-line,
    .package-line { grid-template-columns: 1fr; }

    .summary-primary,
    .detail-wide,
    .field-full { grid-column: auto; }

    .table-actions { justify-content: flex-start; flex-wrap: wrap; }

    .table-region-wide table { min-width: 44rem; }

    .table-region-dense table { min-width: 64rem; }

    .table-region-wide th,
    .table-region-wide td,
    .table-region-dense th,
    .table-region-dense td { white-space: nowrap; }

    .table-scroll-hint {
        position: sticky;
        left: 0;
        z-index: 2;
        display: block;
        width: max-content;
        margin: 0 0 0.45rem;
        padding: 0.28rem 0.55rem;
        border-radius: 999px;
        background: var(--paper-2);
        color: var(--ink-soft);
        font-size: 0.75rem;
        font-weight: 700;
    }

    .userbox-meta { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }

    *, *::before, *::after {
        transition: none !important;
        animation: none !important;
    }
}
