/* =====================================================================
   BETHESDHA SISTEMAS · Sistema de Inventario y Personal
   ===================================================================== */

/* Paleta clara (por defecto y cuando se elige el tema claro) */
:root, [data-theme="light"] {
    --bg: #f2f5fa;
    --surface: #ffffff;
    --surface-2: #f7f9fc;
    --surface-3: #eef2f8;
    --input-bg: #ffffff;
    --topbar-bg: rgba(255, 255, 255, .88);
    --row-hover: #f3f7ff;
    --border: #e3e8f1;
    --border-strong: #d3dbe8;
    --border-soft: #eef1f6;
    --ink: #101c2e;
    --ink-2: #56657c;
    --ink-3: #8492a6;
    --primary: #1e5eff;
    --primary-dark: #1647c6;
    --primary-soft: #e9effe;
    --primary-fg: #1e5eff;
    --sidebar: #0b1524;
    --sidebar-2: #122239;
    --green: #0d8f4f;
    --green-bg: #e5f7ed;
    --green-fg: #0a6b3c;
    --amber: #a9660f;
    --amber-bg: #fdf1de;
    --amber-fg: #8a5209;
    --red: #cc3333;
    --red-bg: #fdeaea;
    --red-fg: #a02828;
    --cyan: #0b8a99;
    --cyan-bg: #e2f6f8;
    --cyan-fg: #0b6d79;
    --blue-bg: #e8efff;
    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 1px 2px rgba(16, 28, 46, .05), 0 8px 24px -18px rgba(16, 28, 46, .35);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

/* Paleta oscura: por sistema operativo o por eleccion explicita del usuario */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0b1524;
        --surface: #122239;
        --surface-2: #16283e;
        --surface-3: #1c3049;
        --input-bg: #0e1c2f;
        --topbar-bg: rgba(18, 34, 57, .92);
        --row-hover: rgba(59, 138, 242, .14);
        --border: #2b3d53;
        --border-strong: #3a4f6a;
        --border-soft: #223350;
        --ink: #dbe6f1;
        --ink-2: #a3b2c6;
        --ink-3: #7f90a5;
        --primary: #3b8af2;
        --primary-dark: #2c6da4;
        --primary-soft: #1b3358;
        --primary-fg: #7cb6ff;
        --sidebar: #0b1524;
        --sidebar-2: #142239;
        --green: #2f9e63;
        --green-bg: #12301f;
        --green-fg: #6ee7a8;
        --amber: #b47a1f;
        --amber-bg: #3a2a0c;
        --amber-fg: #f3c07a;
        --red: #c94545;
        --red-bg: #3d1717;
        --red-fg: #ff9d9d;
        --cyan: #17929f;
        --cyan-bg: #10333a;
        --cyan-fg: #6ee0ec;
        --blue-bg: #1b3358;
        --shadow: 0 1px 2px rgba(0, 0, 0, .45), 0 10px 26px -18px rgba(0, 0, 0, .9);
    }
}

[data-theme="dark"] {
    --bg: #0b1524;
    --surface: #122239;
    --surface-2: #16283e;
    --surface-3: #1c3049;
    --input-bg: #0e1c2f;
    --topbar-bg: rgba(18, 34, 57, .92);
    --row-hover: rgba(59, 138, 242, .14);
    --border: #2b3d53;
    --border-strong: #3a4f6a;
    --border-soft: #223350;
    --ink: #dbe6f1;
    --ink-2: #a3b2c6;
    --ink-3: #7f90a5;
    --primary: #3b8af2;
    --primary-dark: #2c6da4;
    --primary-soft: #1b3358;
    --primary-fg: #7cb6ff;
    --sidebar: #0b1524;
    --sidebar-2: #142239;
    --green: #2f9e63;
    --green-bg: #12301f;
    --green-fg: #6ee7a8;
    --amber: #b47a1f;
    --amber-bg: #3a2a0c;
    --amber-fg: #f3c07a;
    --red: #c94545;
    --red-bg: #3d1717;
    --red-fg: #ff9d9d;
    --cyan: #17929f;
    --cyan-bg: #10333a;
    --cyan-fg: #6ee0ec;
    --blue-bg: #1b3358;
    --shadow: 0 1px 2px rgba(0, 0, 0, .45), 0 10px 26px -18px rgba(0, 0, 0, .9);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--ink);
    font-size: 14.5px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.015em; text-align: left; }
p { margin: 0; }

.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--ink-2); }
.small { font-size: 12.5px; }
.strong { font-weight: 600; }
.num { text-align: right; white-space: nowrap; }
.text-in { color: var(--green-fg); font-weight: 600; }
.text-out { color: var(--red-fg); font-weight: 600; }
.text-ok { color: var(--green-fg); }
.text-warn { color: var(--amber-fg); }

/* ------------------------------------------------------------------ */
/* Shell                                                              */
/* ------------------------------------------------------------------ */

.shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 252px;
    flex: 0 0 252px;
    background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
    color: #c8d3e2;
    display: flex;
    flex-direction: column;
    padding: 18px 14px 14px;
    position: static;
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 6px 8px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    margin-bottom: 14px;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 11px;
    background: linear-gradient(135deg, #2b6bff, #12b3c9);
    color: #fff;
    flex: 0 0 auto;
}

.brand-mark .ico { width: 21px; height: 21px; }

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { color: #fff; font-size: 15px; letter-spacing: -.01em; }
.brand-text small { color: #8ba0bd; font-size: 11px; text-transform: uppercase; letter-spacing: .09em; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav-title {
    display: block;
    margin: 16px 10px 6px;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: #6d82a1;
    font-weight: 700;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 11px;
    border-radius: 10px;
    color: #c2cdde;
    font-weight: 500;
    font-size: 13.6px;
    transition: background .15s ease, color .15s ease;
}

.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav-link.active { background: rgba(46, 107, 255, .18); color: #fff; box-shadow: inset 2px 0 0 #4d8bff; }
.nav-link .ico { width: 18px; height: 18px; opacity: .9; flex: 0 0 auto; }

.sidebar-foot {
    border-top: 1px solid rgba(255, 255, 255, .08);
    padding-top: 12px;
    margin-top: 14px;
}

.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 6px 10px; }

.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .12);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12.5px;
    font-weight: 700;
    flex: 0 0 auto;
}

.user-meta { display: flex; flex-direction: column; line-height: 1.2; overflow: hidden; }
.user-meta strong { color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta small { color: #8ba0bd; font-size: 11.5px; }

.logout-btn {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 8px 11px;
    border: 0;
    border-radius: 9px;
    background: rgba(255, 255, 255, .05);
    color: #b9c6d9;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: background .15s ease;
}

.logout-btn:hover { background: rgba(255, 70, 70, .18); color: #ffd9d9; }
.logout-btn .ico { width: 17px; height: 17px; }

.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.content {
    padding: 26px 26px 40px;
    max-width: none;
}

.content-bare {
    min-height: 100vh;
    padding: 24px;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 26px;
    background: var(--topbar-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar-theme {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease;
}

.topbar-theme:hover { background: var(--surface-3); border-color: var(--border-strong); }
.topbar-theme svg { width: 18px; height: 18px; fill: none; stroke: var(--ink-2); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.topbar-theme:hover svg { stroke: var(--ink); }

.topbar-title h1 { font-size: 19px; }
.topbar-title p { color: var(--ink-2); font-size: 12.5px; margin-top: 2px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.topbar-actions form { display: inline-flex; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--ink-2);
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.icon-btn:hover { background: var(--surface-3); color: var(--ink); text-decoration: none; }
.icon-btn.danger:hover { background: var(--red-bg); color: var(--red); }
.icon-btn .ico { width: 17px; height: 17px; }

.ico { width: 18px; height: 18px; display: inline-block; vertical-align: middle; }

/* ------------------------------------------------------------------ */
/* Botones e iconos                                                   */
/* ------------------------------------------------------------------ */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 15px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 13.5px;
    font-weight: 550;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s ease, border-color .15s ease, box-shadow .15s ease, transform .06s ease;
}

.btn:hover { background: var(--surface-2); text-decoration: none; border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn .ico { width: 16px; height: 16px; }

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 6px 14px -8px rgba(30, 94, 255, .9);
}

.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }

.btn-danger {
    background: var(--red);
    border-color: var(--red);
    color: #fff;
}

.btn-danger:hover { background: #b02a2a; border-color: #b02a2a; color: #fff; }

.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: rgba(16, 28, 46, .05); border-color: transparent; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; padding: 11px; }

/* ------------------------------------------------------------------ */
/* Tarjetas y rejillas                                                */
/* ------------------------------------------------------------------ */

.grid { display: grid; gap: 18px; margin-bottom: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 18px;
}

.grid .card { margin-bottom: 0; }

.card.narrow { max-width: 880px; }

.card-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
}

.card-head h2 { font-size: 15px; }
.card-head > .muted, .card-head > .badge { margin-left: auto; }
.card-head .badge + .muted { margin-left: 8px; }

.card-body { padding: 18px 20px; }
.card-body.flush { padding: 0; }

.card-foot {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
}

.stat {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 18px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.stat.compact { padding: 15px 18px; }
.stat-ico {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.stat-ico .ico { width: 21px; height: 21px; }
.stat-ico-blue { background: var(--blue-bg); color: var(--primary-fg); }
.stat-ico-green { background: var(--green-bg); color: var(--green-fg); }
.stat-ico-amber { background: var(--amber-bg); color: var(--amber-fg); }
.stat-ico-cyan { background: var(--cyan-bg); color: var(--cyan-fg); }

.stat-label { font-size: 12px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .07em; font-weight: 600; }
.stat-value { font-size: 23px; font-weight: 700; letter-spacing: -.02em; line-height: 1.25; }
.stat-hint { font-size: 12px; color: var(--ink-3); }
.stat.compact .stat-value { font-size: 20px; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.mini-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.mini-card {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 13px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.mini-card > div { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.mini-card strong { font-size: 16px; letter-spacing: -.01em; }
.mini-card small { color: var(--ink-2); font-size: 12px; }

.mini-ico {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.mini-ico .ico { width: 18px; height: 18px; }
.mini-blue { background: var(--blue-bg); color: var(--primary-fg); }
.mini-green { background: var(--green-bg); color: var(--green-fg); }
.mini-amber { background: var(--amber-bg); color: var(--amber-fg); }
.mini-cyan { background: var(--cyan-bg); color: var(--cyan-fg); }

.mini-link { margin-left: auto; font-size: 12.5px; font-weight: 600; }

/* ------------------------------------------------------------------ */
/* Tablas                                                             */
/* ------------------------------------------------------------------ */

.table-wrap { overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.4px;
}

.table th {
    text-align: left;
    padding: 10px 16px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--ink-2);
    font-weight: 700;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table td {
    padding: 11px 16px;
    border-bottom: 1px solid var(--border-soft);
    vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--row-hover); }
.table tfoot td { background: var(--surface-2); font-weight: 600; border-top: 1px solid var(--border); }
.table .num { font-variant-numeric: tabular-nums; }

.row-void td { opacity: .55; text-decoration: line-through; }
.row-void td .badge { text-decoration: none; }

.cell-link { font-weight: 600; color: var(--ink); }
.cell-link:hover { color: var(--primary); }
.cell-sub { display: block; color: var(--ink-3); font-size: 11.5px; margin-top: 1px; font-weight: 400; }

.actions-col { text-align: right; }
.actions { text-align: right; white-space: nowrap; }
.actions form { display: inline-flex; vertical-align: middle; }

.empty {
    padding: 26px 20px;
    color: var(--ink-3);
    font-size: 13px;
    text-align: center;
}

.detail-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 22px;
    margin: 0 0 14px;
}

.detail-list > div { border-bottom: 1px dashed var(--border-soft); padding-bottom: 8px; }
.detail-list dt { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); font-weight: 700; }
.detail-list dd { margin: 3px 0 0; font-weight: 550; }

.note {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 11px 13px;
    font-size: 13px;
    color: var(--ink-2);
}

.big-number { font-size: 32px; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; }
.big-number small { font-size: 14px; color: var(--ink-3); font-weight: 600; }

.warehouse-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 6px; }
.warehouse-list li { display: flex; align-items: center; justify-content: space-between; font-size: 13px; padding: 7px 10px; background: var(--surface-2); border-radius: 8px; }
.warehouse-list li .ico { width: 15px; height: 15px; color: var(--ink-3); vertical-align: -2px; }

.summary-split { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 16px; }
.summary-split > div { background: var(--surface-2); border-radius: 10px; padding: 11px 13px; display: flex; flex-direction: column; }
.summary-split small { color: var(--ink-3); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; font-weight: 700; }
.summary-split strong { font-size: 16px; }

/* ------------------------------------------------------------------ */
/* Badges                                                             */
/* ------------------------------------------------------------------ */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 650;
    letter-spacing: .01em;
    white-space: nowrap;
}

.badge-in, .badge-ok { background: var(--green-bg); color: var(--green-fg); }
.badge-out, .badge-danger { background: var(--red-bg); color: var(--red-fg); }
.badge-adj, .badge-warn { background: var(--amber-bg); color: var(--amber-fg); }
.badge-info { background: var(--blue-bg); color: var(--primary-fg); }
.badge-muted { background: var(--surface-3); color: var(--ink-2); }

/* ------------------------------------------------------------------ */
/* Formularios                                                        */
/* ------------------------------------------------------------------ */

.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 9px;
    margin-bottom: 18px;
    padding: 13px 15px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.filters input[type="search"] { flex: 1 1 240px; min-width: 180px; }
.filters input, .filters select { max-width: 240px; }

input, select, textarea {
    font: inherit;
    font-size: 13.5px;
    color: var(--ink);
    background: var(--input-bg);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 8px 11px;
    width: 100%;
    transition: border-color .15s ease, box-shadow .15s ease;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30, 94, 255, .13);
}

input::placeholder, textarea::placeholder { color: var(--ink-3); }
textarea { resize: vertical; }

.filters input, .filters select { padding: 8px 10px; }
.filters .btn { flex: 0 0 auto; }

.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.check input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.card-body .check { margin-top: 4px; }

.form { display: flex; flex-direction: column; gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field > span em { color: var(--red); font-style: normal; }
.field input[type="checkbox"] { width: auto; }
.hint { color: var(--ink-3); font-size: 11.5px; }
.error { color: var(--red); font-size: 11.5px; font-weight: 600; }

.perm-block {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}

.perm-title { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.perm-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 18px; }
.perm-item { align-items: flex-start; }
.perm-item span { line-height: 1.35; }
.perm-block.is-locked { opacity: .7; }

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

.form-actions { display: flex; gap: 10px; justify-content: flex-end; padding-top: 4px; }
.sticky-actions { position: sticky; bottom: 0; background: linear-gradient(180deg, transparent, var(--bg) 45%); padding: 14px 0 6px; }

.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-form input[type="text"], .inline-form select { flex: 1 1 150px; min-width: 120px; }

/* Alta y edicion de catalogos (Configuracion) */
.catalog-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.catalog-form-actions { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

@media (max-width: 560px) {
    .catalog-form { grid-template-columns: 1fr; }
    .catalog-form-actions .btn { flex: 1 1 auto; justify-content: center; }
}

/* ------------------------------------------------------------------ */
/* Alertas                                                            */
/* ------------------------------------------------------------------ */

.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 14px;
    border-radius: 11px;
    font-size: 13.3px;
    margin-bottom: 16px;
    border: 1px solid transparent;
}

.alert .ico { width: 17px; height: 17px; flex: 0 0 auto; margin-top: 1px; }
.alert-success { background: var(--green-bg); color: var(--green-fg); border-color: rgba(13, 143, 79, .35); }
.alert-error { background: var(--red-bg); color: var(--red-fg); border-color: rgba(204, 51, 51, .35); }
.alert-warning { background: var(--amber-bg); color: var(--amber-fg); border-color: rgba(169, 102, 15, .35); }
.alert-inline { margin: 14px 20px; }

/* ------------------------------------------------------------------ */
/* Pestañas                                                           */
/* ------------------------------------------------------------------ */

.tabs { display: flex; gap: 6px; margin-bottom: 16px; padding: 5px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; width: fit-content; box-shadow: var(--shadow); }

.tab {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    border-radius: 8px;
    color: var(--ink-2);
    font-weight: 600;
    font-size: 13.3px;
}

.tab:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.tab.active { background: var(--primary-soft); color: var(--primary-fg); }
.tab .ico { width: 16px; height: 16px; }

/* ------------------------------------------------------------------ */
/* Paginacion                                                         */
/* ------------------------------------------------------------------ */

.pager { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    color: var(--ink-2);
    font-size: 12.8px;
    font-weight: 600;
    background: var(--surface);
}

.page-link:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.page-link.current { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-link.disabled { opacity: .45; pointer-events: none; }
.page-info { margin-left: auto; font-size: 12px; color: var(--ink-3); }

/* ------------------------------------------------------------------ */
/* Dashboard extras                                                   */
/* ------------------------------------------------------------------ */

.bars { display: grid; gap: 12px; }

.bar-row { display: grid; grid-template-columns: 120px 1fr 84px; align-items: center; gap: 12px; }
.bar-label { font-size: 12.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 9px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #2b6bff, #12b3c9); }
.bar-value { text-align: right; font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }

.rank { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; counter-reset: rank; }
.rank li { display: flex; align-items: center; gap: 10px; font-size: 13.2px; }
.rank-num {
    width: 22px;
    height: 22px;
    border-radius: 7px;
    background: var(--surface-3);
    color: var(--ink-2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11.5px;
    font-weight: 700;
    flex: 0 0 auto;
}
.rank-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-qty { color: var(--ink-2); font-size: 12.5px; font-weight: 600; white-space: nowrap; }

/* ------------------------------------------------------------------ */
/* Reportes                                                           */
/* ------------------------------------------------------------------ */

.report-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    color: var(--ink);
    transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}

.report-card:hover { text-decoration: none; border-color: var(--border-strong); transform: translateY(-2px); box-shadow: 0 12px 28px -20px rgba(16, 28, 46, .6); }
.report-ico {
    width: 40px;
    height: 40px;
    border-radius: 11px;
    background: var(--primary-soft);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
}
.report-card h3 { font-size: 15px; }
.report-card p { color: var(--ink-2); font-size: 13px; }
.report-link { margin-top: auto; font-size: 12.5px; font-weight: 650; color: var(--primary); }

.maintenance { display: flex; align-items: center; justify-content: space-between; gap: 22px; flex-wrap: wrap; }

/* ------------------------------------------------------------------ */
/* Movimientos                                                        */
/* ------------------------------------------------------------------ */

.items-table select { min-width: 240px; }
.items-table input[type="number"] { width: 110px; padding: 7px 9px; }
.stock-hint { display: block; color: var(--ink-3); font-size: 11px; margin-top: 3px; }
.stock-hint.low { color: var(--amber); font-weight: 600; }
.total-foot { display: flex; align-items: center; justify-content: space-between; }
.total-foot strong { font-size: 20px; letter-spacing: -.02em; }

/* ------------------------------------------------------------------ */
/* Login                                                              */
/* ------------------------------------------------------------------ */

.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(1000px 600px at 8% -10%, #1b3a6b 0%, transparent 60%),
        radial-gradient(900px 500px at 100% 0%, #0d4d5c 0%, transparent 55%),
        #070e1a;
}

.login-wrap {
    display: grid;
    grid-template-columns: 1.05fr .95fr;
    width: min(980px, 100%);
    background: #fff;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 40px 80px -40px rgba(0, 0, 0, .75);
}

/* Cambio de contrasena: una sola tarjeta, sin panel lateral */
.login-wrap.single {
    grid-template-columns: 1fr;
    width: min(520px, 100%);
}

.login-side {
    padding: 40px 38px;
    background: linear-gradient(160deg, #0c1a2e, #123a5f 55%, #0d5666);
    color: #dbe6f5;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.login-brand strong { display: block; color: #fff; font-size: 16px; }
.login-brand small { color: #94aac9; font-size: 11.5px; text-transform: uppercase; letter-spacing: .1em; }

.login-side h2 { color: #fff; font-size: 26px; line-height: 1.2; letter-spacing: -.02em; }
.login-side p { font-size: 13.6px; color: #b6c8de; line-height: 1.6; }

.login-list { list-style: none; margin: auto 0 0; padding: 0; display: grid; gap: 10px; font-size: 13.2px; }
.login-list li { display: flex; align-items: center; gap: 9px; color: #cfdcee; }
.login-list .ico { width: 16px; height: 16px; color: #4fd1a5; flex: 0 0 auto; }

/* La tarjeta de acceso es siempre clara, aunque el resto este en tema oscuro */
.login-card {
    padding: 46px 42px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    color: #101c2e;
    --ink: #101c2e;
    --ink-2: #56657c;
    --ink-3: #8492a6;
    --border: #e3e8f1;
    --border-strong: #d3dbe8;
    --surface: #ffffff;
    --surface-2: #f7f9fc;
    --surface-3: #eef2f8;
    --input-bg: #ffffff;
    --red-bg: #fdeaea;
    --red-fg: #a02828;
    --green-bg: #e5f7ed;
    --green-fg: #0a6b3c;
    --amber-bg: #fdf1de;
    --amber-fg: #8a5209;
}
.login-card h1 { font-size: 24px; }
.login-card .muted { margin-top: 5px; font-size: 13.4px; }
.login-form { display: flex; flex-direction: column; gap: 15px; margin-top: 26px; }
.login-form .field > span { color: var(--ink); }
.login-form input { padding: 11px 13px; }
.login-foot { margin-top: 26px; font-size: 11.5px; color: var(--ink-3); text-align: center; }

/* ------------------------------------------------------------------ */
/* Errores                                                            */
/* ------------------------------------------------------------------ */

.error-card { max-width: 520px; margin: 60px auto; padding: 34px; text-align: center; }
.error-code { display: block; font-size: 46px; font-weight: 800; letter-spacing: -.04em; color: var(--primary); line-height: 1; margin-bottom: 8px; }
.error-card h2 { margin-bottom: 8px; }
.error-card p { color: var(--ink-2); margin-bottom: 20px; }

/* ------------------------------------------------------------------ */
/* Avisos emergentes (SweetAlert2)                                    */
/* ------------------------------------------------------------------ */

.swal2-container .swal2-popup.isp-swal {
    font-family: var(--font);
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 26px 24px 20px;
}

.swal2-container .swal2-title {
    color: var(--ink);
    font-size: 19px;
    letter-spacing: -.01em;
}

.swal2-container .swal2-html-container {
    color: var(--ink-2);
    font-size: 13.6px;
    margin-top: 8px;
}

.swal2-container .swal2-html-container p { margin: 0 0 12px; }

.swal-stock-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 6px;
    max-height: 240px;
    overflow-y: auto;
    text-align: left;
}

.swal-stock-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 11px;
    border-radius: var(--radius-sm);
    background: var(--amber-bg);
    color: var(--amber-fg);
    font-size: 13px;
}

.swal-stock-list li strong { font-weight: 600; }
.swal-stock-list li span { font-variant-numeric: tabular-nums; white-space: nowrap; }

.swal2-container .swal2-actions { gap: 8px; margin-top: 20px; }
.swal2-container .swal2-actions .btn { padding: 9px 16px; }

/* ------------------------------------------------------------------ */
/* Responsive                                                         */
/* ------------------------------------------------------------------ */

@media (max-width: 1180px) {
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
    .stats-grid { grid-template-columns: 1fr; }
    .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
    .topbar-title h1 { font-size: 16.5px; }
    .filters input, .filters select { max-width: none; flex: 1 1 100%; }
    .login-card { padding: 30px 22px; }
    .content { padding: 14px 13px 36px; }
}

@media print {
    .sidebar, .topbar, .filters, .topbar-actions, .form-actions { display: none !important; }
    .content { padding: 0; }
    .card { box-shadow: none; border-color: #ccc; }
}
