/* ─────────────────────────────────────────────────────────
   Panel Pedidos · El Ganso v2  ·  premium dark/light
   ───────────────────────────────────────────────────────── */
:root {
    --gold:      #BE8A3D;
    --gold-soft: #D9B775;
    --gold-bg:   #F7EDD8;
    --bg:        #FAFAF8;
    --bg-soft:   #F2F0EA;
    --bg-elev:   #FFFFFF;
    --bg-side:   #1A1814;
    --bg-side-h: #25221C;
    --text:      #1A1A1A;
    --text-soft: #4A4A4A;
    --text-on-side: #E8E5DC;
    --text-on-side-soft: #8C8779;
    --muted:     #767676;
    --line:      #E5E2D8;
    --line-soft: #F0EEE6;
    --line-side: #2E2A22;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow:    0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.05);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.08), 0 16px 48px rgba(0,0,0,0.06);
    --good:      #2F8F4E; --good-bg: #E5F3EB;
    --warn:      #C97A1F; --warn-bg: #FBEFD9;
    --bad:       #B23232; --bad-bg:  #F8E0E0;
    --info:      #2A5ECC; --info-bg: #E0E9F8;
    --purple:    #7C3AED; --purple-bg: #EDE6FB;
    --radius:    8px;
    --radius-lg: 12px;
}
[data-theme=dark] {
    --bg:        #0E0D0A;
    --bg-soft:   #18170F;
    --bg-elev:   #1F1D14;
    --bg-side:   #0A0908;
    --bg-side-h: #16140E;
    --text:      #F2EFE4;
    --text-soft: #C9C5B8;
    --text-on-side: #E8E5DC;
    --muted:     #8C8779;
    --line:      #2A271E;
    --line-soft: #1F1C15;
    --line-side: #2E2A22;
    --gold-bg:   #2F2614;
    --good-bg: #14271A; --warn-bg: #2A1F0C; --bad-bg: #2A1414;
    --info-bg: #14202F; --purple-bg: #1F1430;
    --shadow:    0 1px 3px rgba(0,0,0,0.4), 0 4px 12px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
}

* { box-sizing: border-box; }
html, body {
    margin: 0; padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    font-feature-settings: 'cv11','ss01','ss03';
}
a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--text); }
code { font-family: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace; font-size: 12px; }
::selection { background: var(--gold-bg); }

/* ─── Layout: sidebar + main ─── */
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

aside.side {
    background: var(--bg-side);
    color: var(--text-on-side);
    padding: 22px 14px;
    position: sticky; top: 0; height: 100vh;
    display: flex; flex-direction: column; gap: 4px;
    border-right: 1px solid var(--line-side);
}
aside.side .brand {
    display: flex; align-items: center; gap: 10px;
    padding: 4px 10px 22px 10px;
    font-weight: 700; font-size: 14px; letter-spacing: 0.04em;
}
aside.side .brand .logo {
    width: 28px; height: 28px; border-radius: 6px; background: var(--gold);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 800; font-size: 14px;
}
aside.side .brand .name { font-size: 13px; }
aside.side .brand .name .sub { display: block; font-size: 10px; color: var(--text-on-side-soft); font-weight: 500; letter-spacing: 0.1em; }

aside.side .group { color: var(--text-on-side-soft); font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; padding: 16px 10px 6px 10px; font-weight: 600; }
aside.side a.menu {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: 6px;
    color: var(--text-on-side-soft); font-size: 13px; font-weight: 500;
    transition: background 0.12s, color 0.12s;
}
aside.side a.menu:hover { background: var(--bg-side-h); color: var(--text-on-side); }
aside.side a.menu.active {
    background: var(--bg-side-h); color: var(--text-on-side);
    box-shadow: inset 2px 0 0 var(--gold);
}
aside.side a.menu svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.7; }
aside.side a.menu.active svg { opacity: 1; color: var(--gold); }
aside.side a.menu .badge-mini { margin-left: auto; background: var(--gold); color: #fff; padding: 1px 6px; border-radius: 8px; font-size: 10px; font-weight: 600; }

aside.side .footer { margin-top: auto; padding: 10px; border-top: 1px solid var(--line-side); display: flex; align-items: center; gap: 10px; font-size: 12px; }
aside.side .footer .avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--gold); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; }
aside.side .footer a { color: var(--text-on-side-soft); }
aside.side .footer a:hover { color: var(--text-on-side); }

main { padding: 28px 32px; max-width: 1700px; margin: 0 auto; width: 100%; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 22px; gap: 14px; }
.page-head h1 { font-size: 22px; font-weight: 700; margin: 0 0 4px 0; letter-spacing: -0.015em; }
.page-head .sub { color: var(--muted); font-size: 13px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

h2 { font-size: 14px; font-weight: 600; margin: 0 0 12px 0; color: var(--text); display: flex; align-items: center; gap: 8px; }
h2 .small { color: var(--muted); font-weight: 400; font-size: 12px; }
h3 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 10px 0; }

/* ─── Cards / Panels ─── */
.card {
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 14px;
}
.card.no-pad { padding: 0; overflow: hidden; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }
@media (max-width: 1100px) { .grid-2, .grid-3, .grid-4, .grid-2-1 { grid-template-columns: 1fr; } }

/* ─── KPI ─── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi {
    background: var(--bg-elev); border: 1px solid var(--line);
    border-radius: var(--radius-lg); padding: 16px 18px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
    position: relative; overflow: hidden;
}
.kpi:hover { transform: translateY(-1px); box-shadow: var(--shadow); border-color: var(--gold-soft); }
.kpi .label {
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--muted); font-weight: 600;
    display: flex; align-items: center; gap: 6px;
}
.kpi .label svg { width: 12px; height: 12px; }
.kpi .val { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin-top: 6px; line-height: 1.1; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 4px; display: flex; align-items: center; gap: 6px; }
.kpi .delta { font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 4px; }
.kpi .delta.up { color: var(--good); background: var(--good-bg); }
.kpi .delta.down { color: var(--bad); background: var(--bad-bg); }
.kpi .delta.neutral { color: var(--muted); background: var(--bg-soft); }
.kpi .spark { position: absolute; right: 14px; bottom: 12px; opacity: 0.5; pointer-events: none; }
.kpi.alert::before { content:""; position: absolute; top:0; left:0; right:0; height:2px; background: var(--bad); }
.kpi.warn::before  { content:""; position: absolute; top:0; left:0; right:0; height:2px; background: var(--warn); }
.kpi.good::before  { content:""; position: absolute; top:0; left:0; right:0; height:2px; background: var(--good); }
.kpi.gold::before  { content:""; position: absolute; top:0; left:0; right:0; height:2px; background: var(--gold); }
.kpi.alert .val { color: var(--bad); }
.kpi.good .val  { color: var(--good); }
.kpi.warn .val  { color: var(--warn); }

/* ─── Tablas ─── */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--bg-elev); }
.tbl th {
    background: var(--bg-soft); color: var(--text-soft);
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600;
    text-align: left; padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    cursor: pointer; user-select: none; position: relative;
    white-space: nowrap;
}
.tbl th[data-sort]::after { content: '⇅'; opacity: 0.3; margin-left: 6px; font-size: 10px; }
.tbl th.sort-asc::after  { content: '▲'; opacity: 1; color: var(--gold); }
.tbl th.sort-desc::after { content: '▼'; opacity: 1; color: var(--gold); }
.tbl th:hover { color: var(--text); }
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.tbl tbody tr:hover td { background: var(--bg-soft); }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl td.muted { color: var(--muted); }
.tbl-wrap { overflow-x: auto; max-width: 100%; border-radius: var(--radius-lg); }
tr.alert-row td { box-shadow: inset 3px 0 0 var(--bad); }
tr.warn-row  td { box-shadow: inset 3px 0 0 var(--warn); }

/* ─── Badges ─── */
.badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 9px; border-radius: 12px;
    font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
    white-space: nowrap; line-height: 1.4;
}
.badge::before {
    content: ""; width: 6px; height: 6px; border-radius: 50%;
    background: currentColor; flex-shrink: 0;
}
.badge.ENTREGADO  { background: var(--good-bg); color: var(--good); }
.badge.EN_REPARTO { background: #DCEEF8; color: #1F6E91; }
.badge.EN_TRANSITO { background: var(--info-bg); color: var(--info); }
.badge.SALIDO     { background: var(--info-bg); color: var(--info); }
.badge.PREPARADO  { background: var(--gold-bg); color: var(--gold); }
.badge.EN_PICKING { background: var(--purple-bg); color: var(--purple); }
.badge.PENDIENTE_IDL { background: var(--bg-soft); color: var(--muted); }
.badge.NO_ENVIADO { background: var(--bg-soft); color: var(--muted); }
.badge.FALTANTE   { background: var(--bad-bg); color: var(--bad); }
.badge.EN_PUNTO_RECOGIDA { background: var(--gold-bg); color: var(--gold); }
.badge.NO_RECOGIDO { background: var(--bad-bg); color: var(--bad); }
.badge.CANCELADO  { background: var(--bg-soft); color: var(--muted); text-decoration: line-through; }
.badge.REEMBOLSADO { background: var(--bg-soft); color: var(--muted); text-decoration: line-through; }

[data-theme=dark] .badge.ENTREGADO  { background: rgba(47,143,78,0.15); }
[data-theme=dark] .badge.FALTANTE   { background: rgba(178,50,50,0.15); }
[data-theme=dark] .badge.NO_RECOGIDO { background: rgba(178,50,50,0.15); }

.alert-sla { color: var(--bad); font-weight: 600; font-size: 12px; }
.warn-sla  { color: var(--warn); font-weight: 600; font-size: 12px; }

/* ─── Forms / filters ─── */
.toolbar {
    display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
    background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius-lg);
    padding: 10px 14px; margin-bottom: 14px;
}
.toolbar .group { display: flex; align-items: center; gap: 6px; }
.toolbar .sep { width: 1px; height: 24px; background: var(--line); }
.toolbar label { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }

/* ─── Rich toolbar v2 — corporate navy/gold look ─────────────────────── */
.toolbar.toolbar-rich {
    background: #fff;
    border: 1px solid #e8e8e4;
    border-top: 3px solid #0d233f;
    border-radius: 10px;
    padding: 0;
    margin-bottom: 14px;
    box-shadow: 0 1px 3px rgba(13,35,63,0.04), 0 4px 12px rgba(13,35,63,0.03);
    display: block;
    overflow: hidden;
}
[data-theme=dark] .toolbar.toolbar-rich { background: #1e293b; border-color: #334155; border-top-color: #93c5fd; }

.toolbar-rich .tb-section {
    display: flex; flex-wrap: wrap; align-items: flex-end;
    gap: 10px 14px;
    padding: 10px 16px;
}
.toolbar-rich .tb-section + .tb-section {
    border-top: 1px dashed #e8e8e4;
    background: #fcfcfb;
}
[data-theme=dark] .toolbar-rich .tb-section + .tb-section { border-top-color: #334155; background: rgba(255,255,255,0.02); }

.toolbar-rich .tb-section.tb-actions {
    background: #f7f6f1;
    border-top: 1px solid #e8e8e4;
    justify-content: space-between;
    padding: 8px 16px;
}
[data-theme=dark] .toolbar-rich .tb-section.tb-actions { background: rgba(255,255,255,0.03); border-top-color: #334155; }

.toolbar-rich .tb-label {
    font-size: 10px; font-weight: 800; letter-spacing: 0.08em;
    text-transform: uppercase; color: #0d233f;
    align-self: center;
    margin-right: 6px;
    padding-right: 10px;
    border-right: 2px solid #f5b300;
    line-height: 1.1;
}
[data-theme=dark] .toolbar-rich .tb-label { color: #93c5fd; }

.toolbar-rich .group {
    display: flex; flex-direction: column; align-items: stretch; gap: 3px;
    min-width: 0;
}
.toolbar-rich label {
    font-size: 9.5px; font-weight: 700; letter-spacing: 0.06em;
    text-transform: uppercase; color: #767676;
    line-height: 1.1;
    display: flex; align-items: center; gap: 5px;
}
[data-theme=dark] .toolbar-rich label { color: #94a3b8; }

.toolbar-rich input[type=text],
.toolbar-rich input[type=number],
.toolbar-rich input[type=date],
.toolbar-rich select {
    padding: 6px 10px;
    font-size: 12.5px;
    font-family: inherit;
    border: 1px solid #d4d4cf;
    border-radius: 6px;
    background: #fff;
    color: #1A1A1A;
    transition: border-color .12s, box-shadow .12s, background .12s;
    min-width: 0;
}
[data-theme=dark] .toolbar-rich input[type=text],
[data-theme=dark] .toolbar-rich input[type=number],
[data-theme=dark] .toolbar-rich input[type=date],
[data-theme=dark] .toolbar-rich select { background: #0f172a; color: #f1f5f9; border-color: #334155; }

.toolbar-rich input:focus,
.toolbar-rich select:focus {
    outline: none;
    border-color: #f5b300;
    box-shadow: 0 0 0 3px rgba(245,179,0,0.18);
    background: #fffdf7;
}
[data-theme=dark] .toolbar-rich input:focus,
[data-theme=dark] .toolbar-rich select:focus { background: #1a253a; }

/* Checkbox style — pill verde/dorado */
.toolbar-rich .group-check {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px;
    border: 1px solid #d4d4cf;
    border-radius: 6px;
    background: #fff; cursor: pointer;
    font-size: 12px; font-weight: 600; color: #4A4A4A;
    transition: all .12s;
    align-self: flex-end;
}
.toolbar-rich .group-check:hover { border-color: #0d233f; }
.toolbar-rich .group-check input[type=checkbox] {
    accent-color: #f5b300;
    margin: 0;
}
.toolbar-rich .group-check.checked,
.toolbar-rich .group-check:has(input:checked) {
    background: #fff8e1; border-color: #f5b300; color: #0d233f;
}
[data-theme=dark] .toolbar-rich .group-check { background: #0f172a; color: #cbd5e1; border-color: #334155; }
[data-theme=dark] .toolbar-rich .group-check:has(input:checked) { background: rgba(245,179,0,0.12); color: #f5b300; }

/* Separador entre grupos (vertical) — sutil */
.toolbar-rich .sep {
    width: 1px; height: 32px; background: #e8e8e4;
    align-self: flex-end;
    margin: 0 2px;
}
[data-theme=dark] .toolbar-rich .sep { background: #334155; }

/* Acciones — botones derecha + chip de filtros activos izquierda */
.toolbar-rich .toolbar-actions {
    display: flex; gap: 8px; align-items: center;
}
.toolbar-rich .tb-active-chip {
    display: inline-flex; align-items: center; gap: 5px;
    background: #fff8e1; color: #b27800;
    padding: 4px 10px; border-radius: 999px;
    font-size: 11px; font-weight: 700; letter-spacing: 0.02em;
    border: 1px solid rgba(245,179,0,0.35);
}
.toolbar-rich .tb-active-chip::before {
    content: "●"; font-size: 8px; color: #f5b300;
}
[data-theme=dark] .toolbar-rich .tb-active-chip { background: rgba(245,179,0,0.12); color: #f5b300; }

.toolbar-rich .btn-apply {
    background: #0d233f !important; color: #fff !important;
    border: 1px solid #0d233f !important;
    padding: 7px 18px !important;
    font-weight: 700 !important;
    box-shadow: 0 1px 2px rgba(13,35,63,0.15);
}
.toolbar-rich .btn-apply:hover {
    background: #1a3558 !important;
    box-shadow: 0 3px 8px rgba(13,35,63,0.22);
    transform: translateY(-1px);
}
.toolbar-rich .btn-clear {
    background: #fff !important; color: #767676 !important;
    border: 1px solid #d4d4cf !important;
    padding: 7px 14px !important;
    font-weight: 600 !important;
}
.toolbar-rich .btn-clear:hover {
    border-color: #c62828 !important; color: #c62828 !important;
    background: #fff !important;
}
[data-theme=dark] .toolbar-rich .btn-clear { background: transparent !important; color: #94a3b8 !important; border-color: #334155 !important; }

/* Toggle "Más filtros" — accordion */
.toolbar-rich .tb-advanced { display: none; }
.toolbar-rich.tb-expanded .tb-advanced { display: flex; }
.toolbar-rich .tb-toggle {
    background: transparent; border: none; cursor: pointer;
    color: #0d233f; font-weight: 700; font-size: 11.5px;
    letter-spacing: 0.04em; text-transform: uppercase;
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 8px; border-radius: 6px;
    transition: background .12s;
    font-family: inherit;
}
.toolbar-rich .tb-toggle:hover { background: #f7edd8; }
.toolbar-rich .tb-toggle::after { content: "▾"; font-size: 10px; }
.toolbar-rich.tb-expanded .tb-toggle::after { content: "▴"; }
[data-theme=dark] .toolbar-rich .tb-toggle { color: #93c5fd; }
[data-theme=dark] .toolbar-rich .tb-toggle:hover { background: rgba(245,179,0,0.1); }

/* ─── Paginación corporativa v2 ────────────────────────────────────── */
.pagination {
    display: flex; justify-content: space-between; align-items: center;
    flex-wrap: wrap; gap: 12px;
    padding: 10px 18px; margin: 12px 0;
    background: #fff;
    border: 1px solid #e8e8e4;
    border-left: 3px solid #f5b300;
    border-radius: 8px;
    font-size: 12.5px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
[data-theme=dark] .pagination { background: #1e293b; border-color: #334155; }

.pagination .pag-info {
    color: #4A4A4A; display: flex; align-items: center; gap: 10px;
    font-weight: 500;
}
.pagination .pag-info strong { color: #0d233f; font-weight: 800; font-size: 13.5px; }
[data-theme=dark] .pagination .pag-info { color: #cbd5e1; }
[data-theme=dark] .pagination .pag-info strong { color: #93c5fd; }

.pagination .filters-chip {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px; border-radius: 999px;
    background: #fff8e1; color: #b27800;
    font-weight: 700; font-size: 10.5px;
    letter-spacing: 0.04em; text-transform: uppercase;
    border: 1px solid rgba(245,179,0,0.35);
}
.pagination .filters-chip::before { content: "●"; font-size: 7px; color: #f5b300; }
[data-theme=dark] .pagination .filters-chip { background: rgba(245,179,0,0.12); color: #f5b300; }

.pagination .pag-nav { display: flex; align-items: center; gap: 3px; }
.pagination .pag-btn {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 32px; height: 30px; padding: 0 10px;
    border-radius: 6px;
    border: 1px solid transparent;
    color: #0d233f; text-decoration: none;
    font-weight: 700; font-size: 13px;
    background: transparent;
    transition: all .12s;
    font-family: inherit;
}
.pagination .pag-btn:hover:not(.disabled) {
    background: #0d233f; color: #fff;
    border-color: #0d233f;
}
.pagination .pag-btn.disabled {
    opacity: 0.3; cursor: not-allowed; color: #767676;
}
[data-theme=dark] .pagination .pag-btn { color: #93c5fd; }
[data-theme=dark] .pagination .pag-btn:hover:not(.disabled) { background: #93c5fd; color: #0f172a; border-color: #93c5fd; }

.pagination .pag-cur {
    padding: 4px 12px;
    font-weight: 800; color: #0d233f;
    background: #f7edd8; border-radius: 6px;
    border: 1px solid rgba(245,179,0,0.35);
    white-space: nowrap;
    font-size: 12px; letter-spacing: 0.02em;
}
[data-theme=dark] .pagination .pag-cur { background: rgba(245,179,0,0.12); color: #f5b300; }

.pagination .pag-per {
    display: flex; gap: 8px; align-items: center; color: #767676; font-size: 11px;
    text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
}
.pagination .pag-per select {
    padding: 5px 8px; font-size: 12px; font-weight: 600;
    border-radius: 6px; border: 1px solid #d4d4cf; background: #fff;
    color: #0d233f; cursor: pointer;
}
.pagination .pag-per select:hover { border-color: #0d233f; }
[data-theme=dark] .pagination .pag-per select { background: #0f172a; color: #f1f5f9; border-color: #334155; }

/* Responsive */
@media (max-width: 900px) {
    .toolbar-rich .tb-section { gap: 8px; padding: 8px 12px; }
    .toolbar-rich .tb-label { display: none; }
    .toolbar-rich .group { flex: 1; min-width: 100px; }
    .pagination { padding: 8px 12px; }
    .pagination .pag-info { font-size: 11px; }
}
input[type=text], input[type=number], input[type=password], select {
    padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px;
    font-size: 13px; font-family: inherit; background: var(--bg-elev); color: var(--text);
    transition: border-color 0.12s, box-shadow 0.12s;
}
input:focus, select:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-bg); }

.btn {
    padding: 7px 14px; border-radius: 6px; border: 1px solid transparent;
    background: var(--gold); color: #fff; cursor: pointer; font-weight: 600;
    font-size: 13px; transition: opacity 0.12s, transform 0.06s;
    display: inline-flex; align-items: center; gap: 6px; line-height: 1.4;
    font-family: inherit;
}
.btn:hover { opacity: 0.92; }
.btn:active { transform: scale(0.98); }
.btn.secondary { background: var(--bg-elev); color: var(--text); border-color: var(--line); }
.btn.secondary:hover { background: var(--bg-soft); border-color: var(--text-soft); opacity: 1; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--bg-soft); }
.btn svg { width: 14px; height: 14px; }

.kbd {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 10px; padding: 2px 5px; border-radius: 4px;
    background: var(--bg-soft); border: 1px solid var(--line);
    color: var(--muted);
}

/* ─── Channel cards (dashboard) ─── */
.channel-card {
    background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius-lg);
    padding: 16px 18px; transition: border-color 0.12s, transform 0.12s;
    position: relative; overflow: hidden;
}
.channel-card:hover { border-color: var(--gold-soft); }
.channel-card .head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.channel-card .name { font-size: 14px; font-weight: 700; letter-spacing: 0.02em; }
.channel-card .pct { font-size: 18px; font-weight: 700; color: var(--good); letter-spacing: -0.02em; }
.channel-card .total { font-size: 11px; color: var(--muted); font-weight: 500; }
.channel-card .bar { height: 6px; background: var(--bg-soft); border-radius: 3px; overflow: hidden; margin-bottom: 14px; }
.channel-card .bar-fill { height: 100%; background: linear-gradient(90deg, var(--good), var(--gold)); transition: width 0.5s; }
.channel-card .stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 14px; font-size: 12px; margin-bottom: 12px; }
.channel-card .stats .lbl { color: var(--muted); }
.channel-card .stats .val { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.channel-card .ctas { display: flex; gap: 6px; }
.channel-card .ctas a { font-size: 11px; padding: 4px 10px; }

/* ─── Login ─── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at top right, var(--gold-bg), var(--bg)); }
.login-box {
    background: var(--bg-elev); border-radius: var(--radius-lg); padding: 36px 40px;
    box-shadow: var(--shadow-lg); width: 380px; border: 1px solid var(--line);
}
.login-box h1 { text-align: center; margin: 0 0 4px 0; font-size: 24px; }
.login-box .sub { text-align: center; color: var(--muted); margin-bottom: 24px; font-size: 12px; }
.login-box label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.login-box input { width: 100%; padding: 10px 12px; margin-bottom: 14px; }
.login-box .err { background: var(--bad-bg); color: var(--bad); padding: 10px 12px; border-radius: 6px; font-size: 12px; margin-bottom: 14px; }
.login-box .btn { width: 100%; padding: 11px; justify-content: center; }

/* ─── Detail page ─── */
.stepper { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-bottom: 8px; }
.step {
    background: var(--bg-soft); border-radius: 8px; padding: 12px 14px;
    border-left: 3px solid var(--line); position: relative;
}
.step.done { border-left-color: var(--good); background: var(--good-bg); }
.step.active { border-left-color: var(--gold); background: var(--gold-bg); }
.step.failed { border-left-color: var(--bad); background: var(--bad-bg); }
.step .ttl { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; }
.step .val { font-size: 13px; font-weight: 600; margin-top: 2px; }
.step .meta { font-size: 11px; color: var(--muted); margin-top: 2px; }

.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 14px; font-size: 13px; }
.kv .k { color: var(--muted); font-size: 12px; }
.kv .v { font-weight: 500; }

/* ─── Modal command palette ─── */
.cmdk-bg {
    position: fixed; inset: 0; background: rgba(0,0,0,0.4); backdrop-filter: blur(4px);
    z-index: 200; display: none; align-items: flex-start; justify-content: center; padding-top: 12vh;
}
.cmdk-bg.open { display: flex; }
.cmdk-box {
    background: var(--bg-elev); border-radius: var(--radius-lg); width: 560px; max-width: 90vw;
    box-shadow: var(--shadow-lg); border: 1px solid var(--line); overflow: hidden;
}
.cmdk-input { width: 100%; padding: 16px 18px; border: 0; font-size: 15px; background: transparent; color: var(--text); border-bottom: 1px solid var(--line); }
.cmdk-input:focus { outline: none; }
.cmdk-results { max-height: 380px; overflow-y: auto; padding: 6px; }
.cmdk-item { padding: 10px 12px; border-radius: 6px; font-size: 13px; cursor: pointer; display: flex; align-items: center; gap: 10px; }
.cmdk-item:hover, .cmdk-item.active { background: var(--bg-soft); }
.cmdk-item .icon { color: var(--muted); display: flex; }
.cmdk-item .meta { color: var(--muted); font-size: 11px; margin-left: auto; }

/* ─── Helpers ─── */
.tag {
    display: inline-block; padding: 1px 8px; border-radius: 4px;
    background: var(--bg-soft); color: var(--text-soft); font-size: 11px; font-weight: 500;
}
.tag.gold { background: var(--gold-bg); color: var(--gold); font-weight: 600; }
.muted { color: var(--muted); }
.tnum { font-variant-numeric: tabular-nums; }

@media (max-width: 900px) {
    .layout { grid-template-columns: 1fr; }
    aside.side { position: relative; height: auto; flex-direction: row; flex-wrap: wrap; padding: 12px; }
    aside.side .brand { padding: 6px; }
    aside.side .group { display: none; }
    aside.side .footer { width: 100%; }
    main { padding: 16px; }
}

/* ─── Tabla pedidos compacta ─── */
.tbl-orders { table-layout: fixed; width: 100%; }
.tbl-orders th, .tbl-orders td { overflow: hidden; }
.tbl-orders .col-cod    { width: 13%; min-width: 130px; }
.tbl-orders .col-fecha  { width: 8%;  min-width: 92px; }
.tbl-orders .col-cliente{ width: 24%; min-width: 180px; }
.tbl-orders .col-estado { width: 10%; min-width: 105px; }
.tbl-orders .col-dias   { width: 11%; min-width: 130px; text-align: right; }
.tbl-orders .col-track  { width: 16%; min-width: 145px; }
.tbl-orders .col-total  { width: 9%;  min-width: 90px; }
.tbl-orders .col-alerta { width: 5%;  min-width: 38px; text-align: center; }

.tbl-orders td.col-cliente,
.tbl-orders td.col-track {
    white-space: nowrap; text-overflow: ellipsis; overflow: hidden;
}
.tbl-orders .cell-main { font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.tbl-orders .cell-sub { font-size: 11px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; }
.tbl-orders .track-code { font-size: 11px; letter-spacing: -0.01em; }
.tbl-orders code { background: transparent; }

/* ─── Pill días ─── */
.dias-pill {
    display: inline-flex; align-items: center; gap: 4px;
    background: var(--bg-soft); border-radius: 6px; padding: 3px 8px;
    font-size: 11px; line-height: 1.2; font-variant-numeric: tabular-nums;
    border: 1px solid var(--line);
}
.dias-pill .d-sep { color: var(--line); }
.dias-pill .d-pedido { color: var(--text); font-weight: 600; }
.dias-pill .d-prep { color: var(--gold); }
.dias-pill .d-ent { color: var(--good); }
.dias-pill .empty { color: var(--muted); opacity: 0.5; }
tr.alert-row .dias-pill { background: rgba(178,50,50,0.06); border-color: rgba(178,50,50,0.2); }
tr.alert-row .dias-pill .d-pedido { color: var(--bad); }
tr.warn-row .dias-pill { background: rgba(201,122,31,0.06); border-color: rgba(201,122,31,0.2); }

/* ─── Alerta icon ─── */
.alerta-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; border-radius: 50%;
    background: var(--bad-bg); color: var(--bad); font-weight: 700; font-size: 12px;
    cursor: help;
}
.alerta-icon.warn-sla { background: var(--warn-bg); color: var(--warn); }

/* ─── Tags por canal con color sutil ─── */
.tag-canal-AMAZON   { background: rgba(255,153,0,0.10); color: #B36800; }
.tag-canal-WEB      { background: var(--gold-bg); color: var(--gold); }
.tag-canal-ECI      { background: rgba(0,117,74,0.08); color: #00754A; }
.tag-canal-PRIVALIA { background: rgba(233,30,99,0.08); color: #C2185B; }
.tag-canal-VP       { background: rgba(156,39,176,0.08); color: #7B1FA2; }
.tag-canal-TIENDA   { background: var(--info-bg); color: var(--info); }
[data-theme=dark] .tag-canal-AMAZON   { background: rgba(255,153,0,0.18); color: #FFB84D; }
[data-theme=dark] .tag-canal-ECI      { background: rgba(0,200,120,0.18); color: #66E0AC; }
[data-theme=dark] .tag-canal-PRIVALIA { background: rgba(233,30,99,0.18); color: #FF7BA8; }
[data-theme=dark] .tag-canal-VP       { background: rgba(156,39,176,0.18); color: #D08FE6; }
[data-theme=dark] .tag-canal-TIENDA   { background: rgba(42,94,204,0.18); color: #7FA8F4; }

/* Eliminar overflow horizontal del wrap de tablas */
.tbl-wrap { overflow-x: auto; }
.card.no-pad > .tbl-orders { margin: 0; }

/* Hover row más sutil con highlight izquierda */
.tbl-orders tbody tr { transition: background 0.1s; }
.tbl-orders tbody tr:hover td:first-child { box-shadow: inset 3px 0 0 var(--gold); }

@media (max-width: 1280px) {
    .tbl-orders .col-track { width: 14%; }
    .tbl-orders .col-cliente { width: 22%; }
}
@media (max-width: 1100px) {
    .tbl-orders .col-total, .tbl-orders th[data-col=total] { display: none; }
    .tbl-orders td.col-total, .tbl-orders th.col-total { display: none; }
}

/* ─── SLA tabla compacta dashboard ─── */
.tbl-sla { table-layout: fixed; width: 100%; }
.tbl-sla .col-sla-canal  { width: 14%; min-width: 105px; }
.tbl-sla .col-sla-vol    { width: 12%; min-width: 95px; }
.tbl-sla .col-sla-pct    { width: 11%; min-width: 80px; }
.tbl-sla .col-sla-prep   { width: 14%; min-width: 100px; }
.tbl-sla .col-sla-ent    { width: 16%; min-width: 110px; }
.tbl-sla .col-sla-rango  { width: 11%; min-width: 80px; }
.tbl-sla .col-sla-conf   { width: 9%;  min-width: 60px; }
.tbl-sla .col-sla-status { width: 13%; min-width: 95px; }

/* ─── Sidebar collapsible ─── */
.layout { transition: grid-template-columns 0.18s ease; }
.layout.side-collapsed { grid-template-columns: 64px 1fr; }
.layout.side-collapsed aside.side .menu .label-text,
.layout.side-collapsed aside.side .group,
.layout.side-collapsed aside.side .brand .name,
.layout.side-collapsed aside.side .footer .info,
.layout.side-collapsed aside.side .footer .theme-btn,
.layout.side-collapsed aside.side .menu .badge-mini { display: none; }
.layout.side-collapsed aside.side { padding: 22px 8px; }
.layout.side-collapsed aside.side .brand { padding: 4px 8px 22px; justify-content: center; }
.layout.side-collapsed aside.side a.menu { justify-content: center; padding: 10px 4px; }
.layout.side-collapsed aside.side a.menu svg { width: 18px; height: 18px; }
.layout.side-collapsed aside.side .footer { padding: 10px 8px; flex-direction: column; gap: 6px; }
.layout.side-collapsed aside.side .footer .avatar { margin: 0 auto; }

.side-toggle {
    position: absolute; top: 14px; right: -12px;
    width: 22px; height: 22px; border-radius: 50%;
    background: var(--bg-elev); border: 1px solid var(--line);
    color: var(--muted); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: var(--shadow-sm); z-index: 10;
    font-size: 12px; line-height: 1;
    transition: background 0.12s, color 0.12s;
}
.side-toggle:hover { background: var(--gold); color: white; border-color: var(--gold); }
aside.side { position: relative; }

.layout.side-collapsed aside.side .menu:hover::after {
    content: attr(data-tooltip); position: absolute; left: 60px;
    background: var(--bg-side-h); color: var(--text-on-side);
    padding: 4px 10px; border-radius: 4px; font-size: 11px;
    white-space: nowrap; z-index: 100;
    box-shadow: var(--shadow);
}

/* ─── Sidebar fijo (siempre visible en scroll) ─── */
.layout {
    grid-template-columns: 232px 1fr;
    min-height: 100vh;
    transition: grid-template-columns 0.18s ease;
}
aside.side {
    position: fixed;
    top: 0; left: 0;
    width: 232px; height: 100vh;
    z-index: 50;
    overflow-y: auto;
    transition: width 0.18s ease;
}
aside.side::-webkit-scrollbar { width: 6px; }
aside.side::-webkit-scrollbar-thumb { background: var(--line-side); border-radius: 3px; }
main {
    grid-column: 2;
    margin-left: 0; /* layout grid se encarga */
}
.layout.side-collapsed { grid-template-columns: 64px 1fr; }
.layout.side-collapsed aside.side { width: 64px; }

/* En móvil: colapsa siempre */
@media (max-width: 900px) {
    .layout { grid-template-columns: 1fr; }
    aside.side { position: relative; width: 100%; height: auto; }
    main { grid-column: 1; }
}

/* ─── Config SLA tabla compacta ─── */
.tbl-cfg { table-layout: fixed; width: 100%; }
.tbl-cfg .col-cf-canal     { width: 12%; min-width: 90px; }
.tbl-cfg .col-cf-prep      { width: 10%; min-width: 80px; }
.tbl-cfg .col-cf-total     { width: 10%; min-width: 80px; }
.tbl-cfg .col-cf-vol       { width: 10%; min-width: 75px; }
.tbl-cfg .col-cf-prep-real { width: 12%; min-width: 90px; }
.tbl-cfg .col-cf-ent-real  { width: 13%; min-width: 95px; }
.tbl-cfg .col-cf-mediana   { width: 11%; min-width: 80px; }
.tbl-cfg .col-cf-status    { width: 22%; min-width: 130px; }
.tbl-cfg input[type=number] { padding: 5px 8px; font-size: 13px; }

/* ─── Tabla tracking real compacta ─── */
.tbl-trk { table-layout: fixed; width: 100%; }
.tbl-trk .col-trk-cod     { width: 22%; min-width: 130px; }
.tbl-trk .col-trk-carrier { width: 14%; min-width: 90px; }
.tbl-trk .col-trk-est     { width: 28%; min-width: 150px; }
.tbl-trk .col-trk-fec     { width: 14%; min-width: 95px; }
.tbl-trk .col-trk-rec     { width: 22%; min-width: 130px; }
.tbl-trk td { overflow: hidden; }
.tbl-trk .cell-sub code { font-family: 'JetBrains Mono', ui-monospace, monospace; }

/* ─── Tags por carrier ─── */
.tag-trk-GLS           { background: rgba(190,138,61,0.1); color: var(--gold); font-weight: 600; }
.tag-trk-CHILE-EXPRESS { background: rgba(206,17,38,0.08); color: #b81020; font-weight: 600; }
.tag-trk-UPS           { background: rgba(73,49,28,0.08); color: #5b3d22; font-weight: 600; }

.tag-trk-MRW           { background: rgba(28,53,123,0.10); color: #1C357B; font-weight: 600; }
.tag-trk-SEUR          { background: rgba(199,34,46,0.10); color: #C7222E; font-weight: 600; }
[data-theme=dark] .tag-trk-MRW   { background: rgba(28,53,123,0.22); color: #8AA3DD; }
[data-theme=dark] .tag-trk-SEUR  { background: rgba(199,34,46,0.22); color: #F88894; }
[data-theme=dark] .tag-trk-CHILE-EXPRESS { background: rgba(206,17,38,0.18); color: #ff7a8c; }
[data-theme=dark] .tag-trk-UPS           { background: rgba(180,140,90,0.18); color: #d6b88a; }

.tag-trk-ECI-MIRAKL { background: rgba(0,117,74,0.08); color: #00754A; font-weight: 600; }
[data-theme=dark] .tag-trk-ECI-MIRAKL { background: rgba(0,200,120,0.18); color: #66E0AC; }

/* === Columna Almacén/IDL añadida (rebalanceo de anchos en table-layout:fixed) === */
.tbl-orders .col-cliente { width: 17%; min-width: 150px; }
.tbl-orders .col-track   { width: 13%; }
.tbl-orders .col-alm     { width: 14%; min-width: 120px; white-space: normal; vertical-align: top; }
.tbl-trk .col-trk-est    { width: 18%; }
.tbl-trk .col-trk-rec    { width: 16%; }
.tbl-trk .col-trk-alm    { width: 16%; min-width: 120px; white-space: normal; vertical-align: top; }
.col-alm .tag, .col-trk-alm .tag {
  white-space: normal; display: inline-block; line-height: 1.2; max-width: 100%;
  word-break: break-word;
}

/* === Precio/Importe en una sola línea (tras añadir columna Almacén) === */
td.col-total, th.col-total { white-space: nowrap; }
.tbl-orders .col-total { width: 10%; min-width: 98px; }
.tbl-orders .col-dias  { width: 10%; }
.tbl-orders .col-cliente { width: 16%; }

/* === Tabla de tiendas preparadoras: CABE sin scroll (ancho fijo + compacta) === */
.card.no-pad > .tbl-wrap { margin: 0; overflow-x: auto; }
.tbl-tiendas { width: 100%; table-layout: fixed; min-width: 0; }
.tbl-tiendas th, .tbl-tiendas td { padding: 7px 6px; font-size: 12px; }
.tbl-tiendas td { overflow: hidden; text-overflow: ellipsis; }
.tbl-tiendas th { white-space: normal; line-height: 1.15; font-size: 11px; }
.tbl-tiendas th:first-child, .tbl-tiendas td:first-child { width: 15%; text-align: left; }
.tbl-tiendas th:nth-child(2), .tbl-tiendas td:nth-child(2) { width: 9%; }
.tbl-tiendas .cell-sub { font-size: 10px; }

/* Canal Zalando */
.tag-canal-ZALANDO { background:#FF6900; color:#fff; }
