/* HAL — sistema visual inspirado en el lenguaje de HPE: verde de marca, contraste alto,
   tipografía grotesca firme, botones píldora y mucho aire. */

@font-face {
    font-family: "Inter";
    src: url("fonts/inter-latin.woff2") format("woff2");
    font-weight: 100 900;
    font-display: swap;
}

:root {
    --brand: #01a982;
    --brand-hover: #00936f;
    --brand-ink: #00775b;          /* verde para texto sobre claro (contraste AA) */
    --brand-soft: #e3f6f0;
    --on-brand: #000;

    --bg: #f5f6f7;
    --surface: #ffffff;
    --surface-2: #f7f8f9;
    --surface-hover: #f0f2f3;
    --border: #e1e4e7;
    --border-strong: #c5cad0;
    --text: #16191d;
    --text-weak: #5c6670;
    --focus: #01a982;

    --ok-bg: #e3f6ee;      --ok-fg: #0a6b47;
    --warn-bg: #fff4dc;    --warn-fg: #8a5300;
    --err-bg: #fdeaea;     --err-fg: #b42318;
    --info-bg: #e8f1fd;    --info-fg: #1d5bb8;

    --hero-bg: #0b0f12;
    --shadow-sm: 0 1px 2px rgba(15, 23, 30, .06);
    --shadow-md: 0 6px 24px rgba(15, 23, 30, .08);
    --shadow-lg: 0 16px 48px rgba(15, 23, 30, .16);

    --radius: 12px;
    --radius-sm: 8px;
    --topbar-h: 60px;
    --sidebar-w: 248px;
    --sidebar-w-collapsed: 68px;
    --ease: cubic-bezier(.2, .8, .2, 1);

    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --brand-ink: #3ddbb0;
        --brand-soft: rgba(1, 169, 130, .16);
        --bg: #0e1114;
        --surface: #161a1e;
        --surface-2: #1b2025;
        --surface-hover: #20262c;
        --border: #2a3138;
        --border-strong: #3a434c;
        --text: #e9edf0;
        --text-weak: #98a3ad;
        --ok-bg: rgba(23, 235, 160, .12);   --ok-fg: #4be3b0;
        --warn-bg: rgba(255, 188, 68, .14); --warn-fg: #ffc861;
        --err-bg: rgba(252, 90, 90, .14);   --err-fg: #ff8a8a;
        --info-bg: rgba(66, 140, 255, .14); --info-fg: #8db8ff;
        --hero-bg: #050708;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
        --shadow-md: 0 6px 24px rgba(0, 0, 0, .35);
        --shadow-lg: 0 16px 48px rgba(0, 0, 0, .5);
        color-scheme: dark;
    }
}
:root[data-theme="dark"] {
    --brand-ink: #3ddbb0;
    --brand-soft: rgba(1, 169, 130, .16);
    --bg: #0e1114;
    --surface: #161a1e;
    --surface-2: #1b2025;
    --surface-hover: #20262c;
    --border: #2a3138;
    --border-strong: #3a434c;
    --text: #e9edf0;
    --text-weak: #98a3ad;
    --ok-bg: rgba(23, 235, 160, .12);   --ok-fg: #4be3b0;
    --warn-bg: rgba(255, 188, 68, .14); --warn-fg: #ffc861;
    --err-bg: rgba(252, 90, 90, .14);   --err-fg: #ff8a8a;
    --info-bg: rgba(66, 140, 255, .14); --info-fg: #8db8ff;
    --hero-bg: #050708;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 6px 24px rgba(0, 0, 0, .35);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, .5);
    color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font: 400 14px/1.55 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-feature-settings: "cv11", "ss01";
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
a { color: var(--brand-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { margin: 0; letter-spacing: -.015em; line-height: 1.2; }
small { font-size: 12px; }
kbd {
    font: 500 11px/1 "Inter", sans-serif; padding: 3px 6px; border-radius: 5px;
    border: 1px solid var(--border); color: var(--text-weak); background: var(--surface);
}
.muted { color: var(--text-weak); }
.center { text-align: center; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.icon { width: 18px; height: 18px; flex-shrink: 0; stroke: currentColor; fill: none; }
.only-dark { display: none; }
:root[data-theme="dark"] .only-dark { display: block; }
:root[data-theme="dark"] .only-light { display: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .only-dark { display: block; }
    :root:not([data-theme="light"]) .only-light { display: none; }
}

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

/* ---------- Logo ---------- */
.logo { display: inline-flex; align-items: center; gap: 10px; color: var(--text); }
.logo:hover { text-decoration: none; }
.logo-element {
    display: inline-block; width: 34px; height: 14px; border-radius: 2px;
    border: 3px solid var(--brand);
}
.logo-element-lg { width: 96px; height: 38px; border-width: 7px; }
.logo-text { font-weight: 800; font-size: 20px; letter-spacing: .14em; }

/* ---------- Topbar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 30;
    height: var(--topbar-h);
    display: flex; align-items: center; gap: 16px;
    padding: 0 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.topbar-company {
    padding-left: 16px; border-left: 1px solid var(--border);
    color: var(--text-weak); font-weight: 500;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px;
}
.global-search {
    flex: 1; max-width: 480px; margin-left: auto;
    display: flex; align-items: center; gap: 8px;
    height: 38px; padding: 0 12px;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px;
    color: var(--text-weak);
    transition: border-color .15s, box-shadow .15s;
}
.global-search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.global-search input { border: 0; background: transparent; padding: 0; height: 100%; box-shadow: none !important; }
.global-search input:focus { outline: none; }
.topbar-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.global-search + .topbar-actions { margin-left: 0; }

.icon-btn {
    display: inline-grid; place-items: center;
    width: 38px; height: 38px; border-radius: 999px;
    border: 0; background: transparent; color: var(--text); cursor: pointer;
    transition: background .15s;
}
.icon-btn:hover { background: var(--surface-hover); }
.menu-toggle { display: none; }

.avatar {
    display: inline-grid; place-items: center;
    width: 36px; height: 36px; border-radius: 999px;
    background: var(--brand); color: var(--on-brand);
    font-weight: 700; font-size: 13px; letter-spacing: .02em;
}

/* ---------- Dropdown ---------- */
.dropdown { position: relative; }
.dropdown > summary { list-style: none; cursor: pointer; border-radius: 999px; }
.dropdown > summary::-webkit-details-marker { display: none; }
.dropdown-panel {
    position: absolute; right: 0; top: calc(100% + 8px); min-width: 240px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); padding: 6px; z-index: 40;
    animation: pop .14s var(--ease);
}
.dropdown-head { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.dropdown-head .badge { align-self: flex-start; margin-top: 4px; }
.dropdown-item {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 9px 12px; border: 0; border-radius: var(--radius-sm);
    background: transparent; color: var(--text); font: inherit; cursor: pointer; text-align: left;
}
.dropdown-item:hover { background: var(--surface-hover); }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ---------- Estructura ---------- */
.shell { display: flex; min-height: calc(100vh - var(--topbar-h)); }
.sidebar {
    position: sticky; top: var(--topbar-h);
    height: calc(100vh - var(--topbar-h));
    width: var(--sidebar-w); flex-shrink: 0;
    display: flex; flex-direction: column;
    padding: 12px 10px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    transition: width .2s var(--ease);
}
.sidebar nav { flex: 1; }
.nav-group {
    font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .09em;
    color: var(--text-weak); padding: 16px 12px 6px;
    white-space: nowrap; overflow: hidden;
}
.nav-group:first-child { padding-top: 4px; }
.nav-link {
    position: relative;
    display: flex; align-items: center; gap: 12px;
    width: 100%; padding: 9px 12px; margin: 1px 0;
    border: 0; border-radius: var(--radius-sm);
    background: transparent; color: var(--text); font-family: inherit; font-weight: 500; font-size: 14px; line-height: 1.3; cursor: pointer;
    white-space: nowrap; overflow: hidden;
    transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--surface-hover); text-decoration: none; }
.nav-link .icon { color: var(--text-weak); transition: color .15s; }
.nav-link.active { background: var(--brand-soft); color: var(--text); font-weight: 600; }
.nav-link.active .icon { color: var(--brand-ink); }
.nav-link.active::before {
    content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px;
    width: 4px; border-radius: 0 4px 4px 0; background: var(--brand);
}
.collapse-btn { color: var(--text-weak); margin-top: 8px; border-top: 1px solid var(--border); border-radius: 0; padding-top: 14px; }
.collapse-btn .icon { transition: transform .2s var(--ease); }

.sb-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
.sb-collapsed .sidebar .nav-link span,
.sb-collapsed .sidebar .nav-group span { display: none; }
.sb-collapsed .sidebar .nav-group { padding: 10px 0 4px; border-top: 1px solid var(--border); margin: 6px 8px 0; }
.sb-collapsed .sidebar .nav-group:first-child { border-top: 0; }
.sb-collapsed .sidebar .nav-link { justify-content: center; padding: 10px 0; }
.sb-collapsed .collapse-btn .icon { transform: rotate(180deg); }

.content { flex: 1; min-width: 0; padding: 28px 32px 48px; max-width: 1360px; }
.page-head { margin-bottom: 22px; }
.page-head h1 { font-size: 26px; font-weight: 700; }
.page-head p { margin: 6px 0 0; }

/* ---------- Componentes ---------- */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-head h2 { font-size: 15px; font-weight: 600; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 38px; padding: 0 18px;
    border: 1.5px solid var(--border-strong); border-radius: 999px;
    background: transparent; color: var(--text);
    font-family: inherit; font-weight: 600; font-size: 14px; line-height: 1; cursor: pointer; white-space: nowrap;
    transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-hover); border-color: var(--text-weak); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn .icon { width: 16px; height: 16px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn-danger { color: var(--err-fg); border-color: transparent; }
.btn-danger:hover { background: var(--err-bg); border-color: transparent; }
.btn-ghost { border-color: transparent; }
.btn-sm { height: 32px; padding: 0 14px; font-size: 13px; }
.btn-lg { height: 46px; padding: 0 24px; font-size: 15px; }
.btn-block { width: 100%; }

.alert {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; font-weight: 500;
    animation: pop .2s var(--ease);
}
.alert .icon { margin-top: 1px; }
.alert-ok { background: var(--ok-bg); color: var(--ok-fg); }
.alert-err { background: var(--err-bg); color: var(--err-fg); }

.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 10px; border-radius: 999px;
    background: var(--surface-hover); color: var(--text-weak);
    font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge-brand { background: var(--brand-soft); color: var(--brand-ink); }
.badge-ok { background: var(--ok-bg); color: var(--ok-fg); }
.badge-warn { background: var(--warn-bg); color: var(--warn-fg); }
.badge-err { background: var(--err-bg); color: var(--err-fg); }

/* ---------- Listados ---------- */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.search {
    display: flex; align-items: center; gap: 8px; flex: 1; max-width: 520px;
}
.search input { border-radius: 999px; padding-left: 16px; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th, .table td { padding: 13px 18px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th {
    font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
    color: var(--text-weak); background: var(--surface-2); white-space: nowrap;
}
.table thead tr:first-child th:first-child { border-top-left-radius: var(--radius); }
.table thead tr:first-child th:last-child { border-top-right-radius: var(--radius); }
.table tbody tr { transition: background .1s; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr.inactive td { color: var(--text-weak); }
.table .num { text-align: right; white-space: nowrap; }
.table .actions { text-align: right; white-space: nowrap; width: 1%; }
.table .empty { text-align: center; color: var(--text-weak); padding: 48px 16px; }
.table small { display: block; }

.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 14px; }

/* ---------- Formularios ---------- */
input, select, textarea {
    width: 100%; height: 40px; padding: 0 12px;
    font-family: inherit; font-weight: 400; font-size: 14px; line-height: 1.4; color: var(--text);
    background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; padding: 10px 12px; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: var(--text-weak); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
input[type=checkbox] {
    width: 18px; height: 18px; accent-color: var(--brand); cursor: pointer; box-shadow: none !important;
}
.form { padding: 24px; }
.form.narrow { max-width: 680px; }
.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px 20px; }
.span-2 { grid-column: span 2; }
.span-4 { grid-column: span 4; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; }
.align-end { align-self: end; padding-bottom: 10px; }
.field-error { color: var(--err-fg); font-weight: 500; }
.field:has(.field-error) input, .field:has(.field-error) select { border-color: var(--err-fg); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }
.danger-zone { margin-top: 14px; display: flex; justify-content: flex-end; }

.perm-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin-top: 22px; }
.perm-group { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 16px 14px; margin: 0; background: var(--surface-2); }
.perm-group legend { font-weight: 700; padding: 0 6px; }
.perm-group .check { padding: 4px 0; }

/* ---------- Filtros, detalle y utilidades ---------- */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.filters select, .filters input[type=date] { width: auto; min-width: 160px; }
.filters .search { flex: 1 1 260px; max-width: 420px; }
.push-right { margin-left: auto; }
.toolbar-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 16px; }
.inline { display: inline; }
.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form input { max-width: 320px; }
.span-3 { grid-column: span 3; }
.hint { display: flex; align-items: center; gap: 8px; color: var(--text-weak); margin: 14px 0 0; }
.valuation { color: var(--text-weak); }
.valuation strong { color: var(--text); font-variant-numeric: tabular-nums; }

.row-title { display: block; font-weight: 600; color: var(--text); }
.row-title:hover { color: var(--brand-ink); }
.unit { color: var(--text-weak); font-weight: 400; }
.text-pos { color: var(--ok-fg); font-weight: 600; }
.text-neg { color: var(--err-fg); font-weight: 600; }
.text-warn { color: var(--warn-fg); font-weight: 700; }
.table td .badge { margin-left: 4px; }
.table td:first-child .badge, .table td .badge:first-child { margin-left: 0; }

.badge-type-in, .badge-type-initial, .badge-type-transfer_in { background: var(--ok-bg); color: var(--ok-fg); }
.badge-type-out, .badge-type-transfer_out { background: var(--err-bg); color: var(--err-fg); }
.badge-type-adjust { background: var(--warn-bg); color: var(--warn-fg); }

.form-section {
    font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
    color: var(--text-weak); margin: 28px 0 14px; padding-top: 22px; border-top: 1px solid var(--border);
}
.form-section:first-of-type, .form-section.first { margin-top: 0; padding-top: 0; border-top: 0; }
.form .grid + .grid { margin-top: 18px; }

.segmented { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; margin: 0 0 22px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); }
.segmented label { flex: 1; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; text-align: center; padding: 8px 12px; border-radius: 999px; font-weight: 600; font-size: 13px; color: var(--text-weak); white-space: nowrap; transition: background .15s, color .15s; }
.segmented label:hover span { color: var(--text); }
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented input:focus-visible + span { outline: 2px solid var(--focus); }

.detail-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; align-items: start; }
.detail-grid-wide { grid-template-columns: 2fr 1fr; }
.props { display: grid; grid-template-columns: max-content 1fr; gap: 10px 24px; margin: 0; padding: 18px 20px; }
.props dt { color: var(--text-weak); }
.props dd { margin: 0; font-weight: 500; }
.card-text { margin: 0; padding: 0 20px 18px; color: var(--text-weak); }
.stock-total { font-size: 18px; font-variant-numeric: tabular-nums; }
.stock-bars { list-style: none; margin: 0; padding: 10px 20px 18px; }
.stock-bars li { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 8px 0; }
.stock-bars strong { font-variant-numeric: tabular-nums; }
.stock-bars meter { grid-column: span 2; width: 100%; height: 6px; }
meter::-webkit-meter-bar { background: var(--surface-hover); border: 0; border-radius: 99px; height: 6px; }
meter::-webkit-meter-optimum-value { background: var(--brand); border-radius: 99px; }
meter::-moz-meter-bar { background: var(--brand); border-radius: 99px; }

.matrix th:first-child, .matrix td:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; }
.matrix th:first-child { background: var(--surface-2); }

.empty-icon-warn { background: var(--warn-bg); color: var(--warn-fg); }
.alert-list { list-style: none; margin: 0; padding: 8px; }
.alert-list a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--text); }
.alert-list a:hover { background: var(--surface-hover); text-decoration: none; }
.alert-list .alert-dot { width: 8px; height: 8px; border-radius: 99px; background: var(--warn-fg); flex-shrink: 0; }
.alert-list .alert-meta { margin-left: auto; color: var(--text-weak); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Inicio ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi {
    position: relative; overflow: hidden;
    display: flex; flex-direction: column; gap: 2px;
    padding: 20px 22px; color: var(--text);
    transition: transform .15s var(--ease), box-shadow .15s, border-color .15s;
}
.kpi:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--brand); }
.kpi::after {
    content: ""; position: absolute; right: -18px; bottom: -18px;
    width: 84px; height: 34px; border: 6px solid var(--brand); border-radius: 3px; opacity: .14;
}
.kpi-icon { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--brand-soft); color: var(--brand-ink); margin-bottom: 12px; }
.kpi-value { font-size: 32px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi-label { color: var(--text-weak); font-weight: 500; }

.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.quick-list { padding: 8px; }
.quick {
    display: flex; align-items: center; gap: 12px;
    padding: 12px; border-radius: var(--radius-sm); color: var(--text); font-weight: 500;
}
.quick:hover { background: var(--surface-hover); text-decoration: none; }
.quick-icon { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.quick-arrow { margin-left: auto; color: var(--text-weak); transition: transform .15s var(--ease); }
.quick:hover .quick-arrow { transform: translateX(3px); color: var(--brand-ink); }

.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 36px 24px; }
.empty-state p { margin: 0; max-width: 340px; }
.empty-icon { display: inline-grid; place-items: center; width: 48px; height: 48px; border-radius: 999px; background: var(--ok-bg); color: var(--ok-fg); margin-bottom: 6px; }
.empty-icon .icon { width: 22px; height: 22px; }

/* ---------- Login ---------- */
body.guest { min-height: 100vh; }
.auth { display: grid; grid-template-columns: 1.1fr 1fr; min-height: 100vh; }
.auth-hero {
    position: relative; overflow: hidden;
    background: var(--hero-bg); color: #fff;
    display: flex; align-items: flex-end; padding: 56px;
}
.auth-hero-inner { position: relative; z-index: 1; max-width: 460px; }
.auth-hero h2 { font-size: clamp(32px, 4vw, 52px); font-weight: 800; letter-spacing: -.03em; line-height: 1.05; margin: 32px 0 16px; }
.auth-hero p { color: #b9c2ca; font-size: 16px; margin: 0; }
.auth-hero-shape {
    position: absolute; right: -12%; top: 10%;
    width: 70%; aspect-ratio: 2.4; border: 28px solid var(--brand); border-radius: 6px;
    opacity: .9;
}
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 32px 20px; background: var(--surface); }
.auth-form { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 18px; }
.auth-form h1 { font-size: 28px; font-weight: 700; margin-top: 18px; }
.auth-form p { margin: 6px 0 0; }
.auth-foot { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.auth-foot .icon { width: 14px; height: 14px; }

/* ---------- Errores ---------- */
.error-card { margin: 12vh auto; padding: 40px; text-align: center; max-width: 440px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.error-card.wide { max-width: 1000px; text-align: left; align-items: stretch; }
.error-code { font-size: 64px; font-weight: 800; letter-spacing: -.04em; color: var(--brand); }
.trace { white-space: pre-wrap; font-size: 12px; background: var(--surface-2); padding: 14px; border-radius: var(--radius-sm); overflow-x: auto; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .topbar-company { display: none; }
    .dash-grid, .detail-grid, .detail-grid-wide { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
    .menu-toggle { display: inline-grid; }
    .topbar { gap: 8px; padding: 0 12px; }
    .global-search kbd { display: none; }
    .sidebar {
        position: fixed; left: 0; top: var(--topbar-h); z-index: 25;
        width: var(--sidebar-w) !important;
        transform: translateX(-100%); transition: transform .22s var(--ease);
        box-shadow: var(--shadow-lg);
    }
    .sb-open .sidebar { transform: none; }
    .sb-collapsed .sidebar .nav-link span, .sb-collapsed .sidebar .nav-group span { display: inline; }
    .sb-collapsed .sidebar .nav-link { justify-content: flex-start; padding: 9px 12px; }
    .collapse-btn { display: none; }
    .content { padding: 20px 16px 40px; }
    .page-head h1 { font-size: 22px; }
    .grid { grid-template-columns: 1fr 1fr; gap: 14px; }
    .span-2, .span-3, .span-4 { grid-column: span 2; }
    .filters select, .filters input[type=date] { flex: 1 1 140px; min-width: 0; }
    .push-right { margin-left: 0; }
    .auth { grid-template-columns: 1fr; }
    .auth-hero { display: none; }
}
@media (max-width: 520px) {
    .logo-text { display: none; }
    .grid { grid-template-columns: 1fr; }
    .span-2, .span-3, .span-4 { grid-column: span 1; }
    .segmented label { flex: 1 1 45%; }
    .form { padding: 18px; }
    .table th, .table td { padding: 11px 12px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

.table small.unit { display: inline; }

/* ---------- Ayuda ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.help-btn { flex-shrink: 0; margin-top: 2px; }

.help-drawer {
    position: fixed; top: var(--topbar-h); right: 0; bottom: 0; z-index: 35;
    width: min(520px, 100vw);
    background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
    animation: slide-in .2s var(--ease);
}
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.help-drawer-body { height: 100%; overflow-y: auto; padding: 24px 24px 48px; outline: none; }
.help-close { position: absolute; top: 14px; right: 14px; z-index: 1; }

.help-article { max-width: 920px; container-type: inline-size; }
.help-head { padding-right: 40px; margin-bottom: 8px; }
.help-head h2 { font-size: 22px; font-weight: 700; margin-top: 6px; }
.help-kicker { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--brand-ink); }
.help-kicker .icon { width: 14px; height: 14px; }
.help-summary { font-size: 16px; color: var(--text-weak); margin: 0 0 8px; line-height: 1.6; }
.help-section { margin-top: 28px; }
.help-section h3 { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-weak); margin-bottom: 12px; }
.help-body p { margin: 0 0 10px; line-height: 1.65; }
.help-body ul { margin: 0 0 10px; padding-left: 20px; line-height: 1.65; }
.help-body code, .help-options code { font-size: 13px; background: var(--surface-hover); padding: 1px 6px; border-radius: 4px; }
.help-steps { margin: 0; padding-left: 22px; line-height: 1.65; }
.help-steps li { margin-bottom: 6px; }
.help-steps li::marker { color: var(--brand-ink); font-weight: 700; }
.help-options { margin: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.help-options > div { display: grid; grid-template-columns: minmax(140px, 30%) 1fr; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); }
.help-options > div:first-child { border-top: 0; }
.help-options dt { font-weight: 600; }
.help-options dd { margin: 0; color: var(--text-weak); line-height: 1.55; }
.help-tip { display: flex; gap: 10px; align-items: flex-start; margin: 14px 0 0; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--warn-bg); color: var(--warn-fg); font-weight: 500; }
.help-tip .icon { margin-top: 2px; }
.help-related { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.help-related a { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border: 1px solid var(--border); border-radius: 999px; color: var(--text); font-weight: 500; }
.help-related a:hover { border-color: var(--brand); text-decoration: none; }
.help-related .icon { width: 14px; height: 14px; }
.help-foot { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 13px; }

.help-group { font-size: 15px; font-weight: 700; margin: 26px 0 12px; }
.help-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.help-card { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; color: var(--text); transition: border-color .15s, transform .15s var(--ease); }
.help-card:hover { border-color: var(--brand); transform: translateY(-1px); text-decoration: none; }

/* Diagrama de flujo: vertical por defecto; horizontal si el contenedor es ancho. */
.flow-wrap { container-type: inline-size; }
.flow { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0; }
.flow-step { position: relative; display: flex; flex-direction: column; align-items: stretch; padding-bottom: 26px; }
.flow-step:last-child { padding-bottom: 0; }
.flow-step:not(:last-child)::after {
    content: ""; position: absolute; left: 27px; bottom: 4px; height: 18px; width: 2px; background: var(--border-strong);
}
.flow-step:not(:last-child)::before {
    content: ""; position: absolute; left: 23px; bottom: 2px; border: 5px solid transparent; border-top-color: var(--border-strong); border-bottom: 0;
}
.flow-node {
    display: grid; grid-template-columns: 36px 1fr; column-gap: 12px; align-items: center;
    padding: 12px 14px; background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius-sm);
}
.flow-node strong { font-size: 14px; }
.flow-text { grid-column: 2; color: var(--text-weak); font-size: 13px; line-height: 1.45; }
.flow-badge {
    grid-row: span 2; display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 10px;
    background: var(--surface-hover); color: var(--text); font-size: 13px;
}
.flow-badge .icon { width: 16px; height: 16px; }
.flow-start .flow-node { border-color: var(--brand); }
.flow-start .flow-badge, .flow-end .flow-badge { background: var(--brand); color: var(--on-brand); }
.flow-end .flow-node { border-color: var(--brand); background: var(--brand-soft); }
.flow-decision .flow-node { border-style: dashed; border-color: var(--warn-fg); }
.flow-decision .flow-badge { background: var(--warn-bg); color: var(--warn-fg); }
.flow-note { margin: 6px 0 0 50px; font-size: 12px; color: var(--warn-fg); font-weight: 600; }

@container (min-width: 760px) {
    .flow { flex-direction: row; align-items: stretch; }
    .flow-step { flex: 1 1 0; padding: 0 22px 0 0; min-width: 0; }
    .flow-step:last-child { padding-right: 0; }
    .flow-step:not(:last-child)::after { left: auto; right: 6px; top: 50%; bottom: auto; width: 12px; height: 2px; }
    .flow-step:not(:last-child)::before { left: auto; right: 0; top: calc(50% - 4px); bottom: auto; border: 5px solid transparent; border-left-color: var(--border-strong); border-right: 0; }
    .flow-node { grid-template-columns: 1fr; row-gap: 6px; align-content: start; height: 100%; padding: 14px; }
    .flow-badge { grid-row: auto; }
    .flow-text { grid-column: 1; }
    .flow-note { margin: 6px 0 0; }
    .flow-step:has(.flow-note):not(:last-child)::after, .flow-step:has(.flow-note):not(:last-child)::before { top: 40%; }
}

/* ---------- Envases ---------- */
.mono { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; letter-spacing: .02em; }
.icon-sm { width: 14px; height: 14px; vertical-align: -2px; color: var(--text-weak); }
.status-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.status-tile { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 14px 16px; color: var(--text); }
.status-tile:hover, .status-tile.active { border-color: var(--brand); text-decoration: none; }
.status-n { font-size: 26px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

.op-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; border: 0; padding: 0; margin: 0 0 22px; }
.op-card { cursor: pointer; }
.op-card input { position: absolute; opacity: 0; pointer-events: none; }
.op-body {
    display: grid; grid-template-columns: 22px 1fr; column-gap: 10px; row-gap: 2px; align-items: center; height: 100%;
    padding: 12px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
    transition: border-color .15s, background .15s;
}
.op-body .icon { grid-row: span 2; color: var(--text-weak); }
.op-body small { color: var(--text-weak); font-size: 12px; }
.op-card:hover .op-body { border-color: var(--border-strong); }
.op-card input:checked + .op-body { border-color: var(--brand); background: var(--brand-soft); }
.op-card input:checked + .op-body .icon { color: var(--brand-ink); }
.op-card input:focus-visible + .op-body { outline: 2px solid var(--focus); outline-offset: 2px; }

.serial-input { font-size: 15px; line-height: 1.6; min-height: 150px; }
.span-rows { grid-row: span 3; }
.serial-counter { font-weight: 500; }
.serial-errors { margin-top: 8px; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--err-bg); color: var(--err-fg); font-weight: 500; }
.serial-errors ul { margin: 6px 0 0; padding-left: 18px; }
.first-hint { margin: 0 0 18px; }

.timeline { list-style: none; margin: 0; padding: 14px 20px 18px; }
.timeline li { position: relative; display: grid; grid-template-columns: 14px 1fr; gap: 12px; padding-bottom: 16px; }
.timeline li:not(:last-child)::before { content: ""; position: absolute; left: 6px; top: 16px; bottom: 0; width: 2px; background: var(--border); }
.timeline-dot { width: 14px; height: 14px; margin-top: 3px; border-radius: 99px; border: 3px solid var(--brand); background: var(--surface); }
.timeline-detail { color: var(--text-weak); font-size: 13px; margin-top: 2px; }
@media (max-width: 860px) { .span-rows { grid-row: auto; } }
.alert-list .alert-dot-err { background: var(--err-fg); }
.badge-type-production { background: var(--warn-bg); color: var(--warn-fg); }

/* ---------- Plataforma y soporte ---------- */
.platform .topbar { background: var(--hero-bg); border-bottom-color: #000; color: #fff; }
.platform .topbar .logo { color: #fff; }
.platform .topbar .icon-btn { color: #fff; }
.platform .topbar .icon-btn:hover { background: rgba(255,255,255,.08); }
.platform-tag {
    display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px;
    border: 1.5px solid var(--brand); color: var(--brand); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
    align-self: flex-start;
}
.platform .topbar .topbar-actions { margin-left: auto; }
.auth-platform .auth-hero h2 { margin-top: 28px; }
.totp-secret { font-size: 20px; letter-spacing: .12em; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px dashed var(--border-strong); text-align: center; word-break: break-all; }
.totp-input { font-size: 22px; letter-spacing: .3em; text-align: center; }
.totp-uri { font-size: 12px; margin: 0; }

.support-bar {
    position: relative; z-index: 31; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    padding: 8px 20px; background: #ffbc44; color: #1a1300; font-weight: 600; font-size: 13px;
}
.support-bar .icon { width: 16px; height: 16px; }
.support-bar form { margin-left: auto; }
.support-bar .btn { border-color: #1a1300; color: #1a1300; height: 30px; }
.support-bar .btn:hover { background: rgba(0,0,0,.08); }
.support-notice { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--warn-bg); color: var(--warn-fg); font-weight: 500; }

.mb { margin-bottom: 16px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.card-form { display: flex; flex-direction: column; gap: 12px; padding: 16px 20px 20px; align-items: flex-start; }
.card-form .field, .card-form .segmented { width: 100%; }
.credentials { align-items: flex-start; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.plan-card { display: flex; flex-direction: column; gap: 12px; }
.plan-head { display: flex; justify-content: space-between; align-items: baseline; }
.plan-head h2 { font-size: 20px; }
.alert-list .alert-dot-off { background: var(--border-strong); }
.alert-list .empty { padding: 16px; }
.inline-field { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
.inline-field select { width: auto; }

.thread { list-style: none; margin: 0; padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 85%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); }
.msg-mine { align-self: flex-end; background: var(--brand-soft); border-color: transparent; }
.msg-internal { background: var(--warn-bg); border: 1px dashed var(--warn-fg); }
.msg-system { align-self: center; max-width: 100%; background: transparent; border: 0; padding: 4px; text-align: center; }
.msg-system-text { color: var(--text-weak); font-size: 12px; }
.msg-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 13px; }
.msg-body { line-height: 1.6; overflow-wrap: anywhere; }
.reply-box { padding: 16px 20px 20px; border-top: 1px solid var(--border); }
.reply-box .form-actions { margin-top: 12px; padding-top: 0; border-top: 0; }
.reply-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 12px; }
.reply-actions .btn { margin-left: auto; }
.audit-data summary { cursor: pointer; color: var(--brand-ink); font-weight: 600; }
.audit-data pre { margin: 6px 0 0; max-width: 460px; max-height: 260px; overflow: auto; font-size: 12px; background: var(--surface-2); padding: 8px; border-radius: 6px; }

/* ---------- Autocompletado ---------- */
.lookup { position: relative; }
.lookup-list {
    position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20;
    list-style: none; margin: 0; padding: 4px; max-height: 300px; overflow-y: auto;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
    font-weight: 400;
}
.lookup-list li[role=option] { display: flex; flex-direction: column; gap: 1px; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.lookup-list li[aria-selected=true] { background: var(--brand-soft); }
.lookup-list li strong { font-weight: 600; font-size: 14px; }
.lookup-list li small { color: var(--text-weak); }
.lookup-msg { padding: 10px; color: var(--text-weak); font-size: 13px; }
.filters .lookup { flex: 1 1 220px; max-width: 320px; }
.topbar .platform-tag { align-self: center; }

/* ---------- HAL 9000 ---------- */
.hal-eye {
    width: 88px; height: 88px; border-radius: 50%; margin-bottom: 8px;
    background: radial-gradient(circle at 50% 50%, #fff6c8 0 4%, #ffb000 7%, #ff2a00 16%, #b00000 32%, #3a0000 52%, #111 58%, #2a2a2a 62%, #0b0b0b 66%);
    box-shadow: 0 0 0 6px #1a1a1a, 0 0 0 8px #555, 0 0 28px rgba(255, 40, 0, .45);
    animation: hal-pulse 3.2s ease-in-out infinite;
}
@keyframes hal-pulse { 50% { box-shadow: 0 0 0 6px #1a1a1a, 0 0 0 8px #555, 0 0 44px rgba(255, 40, 0, .7); } }
.hal-quote { font-size: 18px; font-weight: 600; margin: 4px 0 0; }
.hal-toast {
    position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 60;
    display: flex; align-items: center; gap: 14px; max-width: calc(100vw - 32px);
    padding: 14px 20px 14px 14px; border-radius: 999px; background: #0b0b0b; color: #f2f2f2;
    box-shadow: var(--shadow-lg); animation: pop .2s var(--ease); font-weight: 500;
}
.hal-toast .hal-eye { width: 34px; height: 34px; margin: 0; flex-shrink: 0; box-shadow: 0 0 0 3px #1a1a1a, 0 0 0 4px #555, 0 0 16px rgba(255, 40, 0, .5); }

/* ---------- Ingresar con Google ---------- */
.auth-or { display: flex; align-items: center; gap: 12px; color: var(--text-weak); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.btn-google { background: var(--surface); border-color: var(--border-strong); gap: 12px; font-weight: 600; }
.btn-google:hover { text-decoration: none; }
.google-g { width: 20px; height: 20px; flex-shrink: 0; }

/* ---------- Configuración en secciones ---------- */
.settings { display: flex; flex-direction: column; gap: 28px; max-width: 1100px; }
.settings-section { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 24px; align-items: start; scroll-margin-top: calc(var(--topbar-h) + 16px); }
.settings-section + .settings-section { padding-top: 28px; border-top: 1px solid var(--border); }
.settings-intro h2 { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.settings-intro p { margin: 0 0 10px; font-size: 13px; line-height: 1.55; }
.settings-card { overflow: hidden; }
.settings-card > .alert { margin: 16px 20px 0; }
.settings-card .props { border-top: 1px solid var(--border); }
.card-form-split { border-top: 1px solid var(--border); }
.card-form .grid { width: 100%; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 860px) {
    .settings-section { grid-template-columns: 1fr; gap: 12px; }
    .grid-2 { grid-template-columns: 1fr; }
}
.settings-alert { margin: 16px 20px 0; }
.error-message { padding-top: 18px; color: var(--text); font-weight: 500; overflow-wrap: anywhere; }
.trace-block { margin: 0; border-radius: 0; max-height: 480px; overflow: auto; }
.field-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.field-link { font-weight: 500; font-size: 12px; }
.btn:disabled { cursor: not-allowed; }
