/* ==========================================================
   DaxApp · Tema borgoña (base #78273D)
   ========================================================== */
:root {
    /* Escala borgoña derivada de la base #78273D */
    --brand-950: #3A0F1B;
    --brand-900: #4F1829;
    --brand-800: #632033;
    --brand-700: #78273D;   /* base */
    --brand-600: #923350;
    --brand-500: #A94463;
    --brand-400: #C06A83;
    --brand-300: #D79BAC;
    --brand-200: #E9C6D0;
    --brand-100: #F4E3E8;
    --brand-50:  #FAF3F5;

    /* Acento: botón principal (login, acciones destacadas) */
    --accent: #E3B25B;          /* champagne */
    --accent-hover: #EBC079;
    --accent-text: #3A0F1B;     /* texto sobre el acento */
    /* Alternativas: blanco #FFFFFF / texto #78273D · rosa #D79BAC / texto #3A0F1B · tono de marca #A94463 / texto #FFFFFF */

    /* Neutros (sin tinte azul) */
    --bg: #F3F2F4;
    --surface: #FFFFFF;
    --text: #1F1B1D;
    --muted: #6B6468;
    --line: #E6E2E4;

    /* Semánticos (se conservan) */
    --success: #2E9E3E;
    --success-dark: #247F31;
    --danger: #D32F2F;
    --warning: #F28C1B;

    --radius: 12px;
    --shadow: 0 1px 2px rgba(40, 10, 20, .06), 0 4px 14px rgba(40, 10, 20, .06);
    --sidebar-w: 248px;
    --topbar-h: 60px;
    --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); color: var(--text); background: var(--bg); font-size: 15px; line-height: 1.5; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
a { color: inherit; }
button { font-family: inherit; cursor: pointer; }
.m-0 { margin: 0; }
.muted { color: var(--muted); }

/* ---------------- LOGIN ---------------- */
.auth-body {
    min-height: 100vh; min-height: 100dvh;
    background:
        radial-gradient(900px 500px at 15% 10%, var(--brand-100), transparent 60%),
        radial-gradient(800px 500px at 90% 90%, var(--brand-200), transparent 60%),
        #ECE9EB;
}
.login-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card {
    width: 100%; max-width: 400px; background: var(--brand-700); color: #fff;
    border-radius: 18px; padding: 32px 28px 22px;
    box-shadow: 0 24px 60px rgba(79, 24, 41, .35);
    background-image: linear-gradient(180deg, var(--brand-700), var(--brand-800));
}
.login-brand { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 26px; font-weight: 600; padding-bottom: 20px; border-bottom: 1px solid rgba(255,255,255,.14); }
.login-card h1 { text-align: center; font-size: 24px; margin: 24px 0 22px; font-weight: 700; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; margin-bottom: 6px; color: rgba(255,255,255,.85); font-weight: 500; }
.input-box { display: flex; align-items: center; background: #fff; border-radius: 10px; border: 2px solid transparent; transition: border-color .15s, box-shadow .15s; }
.input-box:focus-within { border-color: var(--brand-300); box-shadow: 0 0 0 4px rgba(215,155,172,.35); }
.input-box > i { padding: 0 6px 0 14px; color: var(--brand-700); font-size: 18px; }
.input-box input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; padding: 14px 12px 14px 6px; font-size: 16px; color: var(--text); font-family: inherit; }
.input-box .eye { border: 0; background: transparent; padding: 0 14px; color: var(--muted); font-size: 18px; }
.login-alert { background: rgba(211,47,47,.2); border: 1px solid rgba(255,160,160,.5); color: #FFE3E3; padding: 10px 12px; border-radius: 10px; font-size: 14px; margin-bottom: 14px; }
.btn-login {
    position: relative; width: 100%; height: 50px; border: 0; border-radius: 10px;
    background: var(--accent); color: var(--accent-text); font-size: 17px; font-weight: 700; letter-spacing: .2px;
    transition: background .15s, transform .05s;
}
.btn-login:hover { background: var(--accent-hover); }
.btn-login:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.btn-login:active { transform: translateY(1px); }
.btn-login:disabled { opacity: .85; cursor: progress; }
.btn-login .spinner { display: none; width: 20px; height: 20px; border: 3px solid rgba(58,15,27,.25); border-top-color: var(--accent-text); border-radius: 50%; animation: spin .7s linear infinite; position: absolute; inset: 0; margin: auto; }
.btn-login.loading .btn-text { visibility: hidden; }
.btn-login.loading .spinner { display: block; }
.login-foot { text-align: center; font-size: 13px; color: rgba(255,255,255,.7); margin: 22px 0 0; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.14); }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 520px) {
    .auth-body { background: var(--brand-800); }
    .login-wrap { padding: 0; align-items: stretch; }
    .login-card { max-width: none; border-radius: 0; box-shadow: none; padding-top: 56px; display: flex; flex-direction: column; background: var(--brand-800); }
    .login-foot { margin-top: auto; }
}

/* Logo de marca (imagen) */
.logo-img { display: block; height: 34px; width: auto; flex: none; }
.login-brand { gap: 14px; }
.login-brand .logo-img { height: 58px; }
.login-brand span { font-size: 30px; letter-spacing: .3px; }

/* ---------------- LAYOUT ---------------- */
.topbar {
    position: fixed; inset: 0 0 auto 0; height: var(--topbar-h); z-index: 30;
    background: var(--brand-700); color: #fff; display: flex; align-items: center; gap: 10px; padding: 0 16px;
    box-shadow: 0 2px 8px rgba(40,10,20,.25);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-size: 20px; font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.user-chip { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; border-radius: 10px; padding: 2px 6px; }
.user-chip:hover { background: rgba(255,255,255,.1); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--brand-500); display: inline-grid; place-items: center; font-weight: 700; object-fit: cover; }
.user-meta { display: flex; flex-direction: column; line-height: 1.15; }
.user-meta small { opacity: .75; font-size: 12px; }
.icon-btn { background: transparent; border: 0; color: #fff; font-size: 22px; width: 40px; height: 40px; border-radius: 10px; display: inline-grid; place-items: center; }
.icon-btn:hover { background: rgba(255,255,255,.12); }

.shell { padding-top: var(--topbar-h); min-height: 100vh; }
.sidebar {
    position: fixed; top: var(--topbar-h); bottom: 0; left: 0; width: var(--sidebar-w); z-index: 25;
    background: var(--brand-800); color: #fff; display: flex; flex-direction: column; overflow-y: auto;
    transition: transform .25s ease;
}
.nav-list, .sub-list { list-style: none; margin: 0; padding: 0; }
.nav-list { padding: 12px 10px; flex: 1; }
.nav-link {
    display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 14px; border-radius: 10px;
    color: rgba(255,255,255,.82); text-decoration: none; background: transparent; border: 0; font-size: 15px; text-align: left;
    transition: background .15s, color .15s;
}
.nav-link i { font-size: 18px; }
.nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-link.active { background: var(--brand-500); color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 var(--brand-200); }
.nav-toggle .chev { margin-left: auto; font-size: 14px; transition: transform .2s; }
.nav-group.open > .nav-toggle .chev { transform: rotate(180deg); }
.sub-list { display: none; padding: 2px 0 6px 14px; }
.nav-group.open > .sub-list { display: block; }
.nav-link.sub { padding: 9px 14px; font-size: 14px; }
.sidebar-foot { padding: 14px; font-size: 12px; color: rgba(255,255,255,.5); text-align: center; border-top: 1px solid rgba(255,255,255,.08); }

.content { margin-left: var(--sidebar-w); padding: 24px; max-width: 1400px; }
.sidebar-backdrop { display: none; }

.page-head { margin-bottom: 20px; }
.page-head h1 { font-size: 26px; color: var(--brand-900); }

/* ---------------- COMPONENTES ---------------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { display: block; background: var(--surface); border-radius: var(--radius); padding: 18px; text-decoration: none; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s; }
.stat-card:hover { transform: translateY(-2px); }
.stat-icon { font-size: 22px; color: var(--brand-600); }
.stat-label { color: var(--muted); font-size: 14px; margin-top: 6px; }
.stat-value { font-size: 30px; font-weight: 700; color: var(--brand-900); }
.stat-card.primary { background: linear-gradient(135deg, var(--brand-700), var(--brand-500)); color: #fff; }
.stat-card.primary .stat-icon, .stat-card.primary .stat-label, .stat-card.primary .stat-value { color: #fff; }

.panel { background: var(--surface); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.panel h2 { font-size: 17px; margin-bottom: 14px; color: var(--brand-900); }
.panel.empty { text-align: center; padding: 48px 20px; }
.panel.empty i { font-size: 44px; color: var(--brand-400); }
.panel.empty h2 { margin: 10px 0 6px; }
.quick { display: flex; flex-wrap: wrap; gap: 10px; }
.quick a { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 10px; background: var(--brand-50); color: var(--brand-700); text-decoration: none; font-weight: 600; border: 1px solid var(--brand-100); }
.quick a:hover { background: var(--brand-100); }

/* ---------------- RESPONSIVE ---------------- */
@media (min-width: 992px) {
    .d-lg-none { display: none !important; }
    /* Menú replegado (escritorio): todo el ancho para el contenido */
    .sidebar-collapsed .sidebar { transform: translateX(-100%); visibility: hidden; transition: transform .25s ease, visibility 0s .25s; }
    .sidebar-collapsed .content { margin-left: 0; max-width: none; }
    .content { transition: margin-left .25s ease; }
}
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); width: 270px; visibility: hidden; transition: transform .25s ease, visibility 0s .25s; }
    .menu-open .sidebar { transform: none; visibility: visible; box-shadow: 8px 0 24px rgba(0,0,0,.3); transition: transform .25s ease; }
    .sidebar-backdrop { position: fixed; inset: var(--topbar-h) 0 0 0; background: rgba(30,8,15,.5); z-index: 20; }
    .menu-open .sidebar-backdrop { display: block; }
    .content { margin-left: 0; padding: 16px; }
    .page-head h1 { font-size: 22px; }
}
@media (max-width: 575.98px) { .d-none-sm { display: none !important; } }

/* ==========================================================
   COMPONENTES GENERALES
   ========================================================== */
.btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 18px; border-radius: 10px; border: 1px solid transparent; font-size: 15px; font-weight: 600; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .7; cursor: progress; }
.btn:focus-visible, .icon-act:focus-visible, .pg:focus-visible { outline: 3px solid var(--brand-300); outline-offset: 2px; }
.btn-accent { background: var(--accent); color: var(--accent-text); }
.btn-accent:hover { background: var(--accent-hover); }
.btn-ghost { background: #fff; color: var(--brand-700); border-color: var(--brand-200); }
.btn-ghost:hover { background: var(--brand-50); border-color: var(--brand-300); }
.btn-link { background: transparent; color: var(--danger); padding: 0 8px; }
.btn-link:hover { background: #FDECEC; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 14px; }
.btn .spinner { display: none; position: absolute; inset: 0; margin: auto; width: 18px; height: 18px; border: 3px solid rgba(58,15,27,.25); border-top-color: var(--accent-text); border-radius: 50%; animation: spin .7s linear infinite; }
.btn.loading .btn-text { visibility: hidden; }
.btn.loading .spinner { display: block; }

.page-head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-head-row .actions { display: flex; gap: 10px; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--brand-100); color: var(--brand-800); }
.badge.vendedor { background: #EEF0F2; color: #4A4F55; }
.badge.administrador { background: var(--brand-100); color: var(--brand-800); }
.badge.none { background: #F4F4F4; color: var(--muted); font-weight: 500; }
.tag-chino { display: inline-block; margin-left: 6px; padding: 2px 9px; border-radius: 6px; font-size: 12.5px; font-weight: 700; color: #B3203F; background: #FDECEF; border: 1px solid #F5C2CC; }
.tag-chino.fixed { margin-left: 0; }

/* ---------------- Tabla de datos ---------------- */
.table-panel { padding: 0; overflow: hidden; }
.table-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.search-box { position: relative; flex: 1 1 280px; max-width: 420px; }
.search-box i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.table-tools .search-box input[type="search"] { width: 100%; height: 40px; padding: 0 12px 0 38px; }
.search-box i { pointer-events: none; }
.tools-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.per-page { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.sort-mobile { display: none; gap: 6px; }

input:not([type]), input[type=text], input[type=email], input[type=tel], input[type=password], input[type=search], select {
    font-family: inherit; font-size: 14.5px; color: var(--text); background: #fff;
    border: 1px solid #D9D4D7; border-radius: 9px; padding: 0 10px; height: 40px; min-width: 0;
    transition: border-color .15s, box-shadow .15s;
}
input[type=search] { -webkit-appearance: none; appearance: none; }
input:focus, select:focus { outline: 0; border-color: var(--brand-500); box-shadow: 0 0 0 3px rgba(169,68,99,.2); }
input[type=checkbox] { accent-color: var(--brand-700); width: 18px; height: 18px; cursor: pointer; }

.table-wrap { overflow-x: auto; }
.grid { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.grid th, .grid td { padding: 10px 14px; text-align: left; vertical-align: middle; }
.grid thead .head th { background: var(--brand-50); color: var(--brand-900); font-weight: 700; font-size: 13.5px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.grid thead .filters th { background: #fff; padding: 8px 14px; border-bottom: 2px solid var(--brand-100); }
.grid thead .filters input, .grid thead .filters select { width: 100%; height: 34px; font-size: 13.5px; }
.sortable { cursor: pointer; user-select: none; }
.sortable:hover { background: var(--brand-100) !important; }
.sortable .si { margin-left: 4px; font-size: 11px; color: var(--brand-300); }
.sortable.sorted .si { color: var(--brand-700); }
.sortable:focus-visible { outline: 2px solid var(--brand-500); outline-offset: -2px; }
.grid tbody tr { border-bottom: 1px solid #F0EDEE; transition: background .12s; }
.grid tbody tr:nth-child(even) { background: #FBF9FA; }
.grid tbody tr:hover { background: var(--brand-50); }
.grid tbody tr.empty td { text-align: center; color: var(--muted); padding: 36px 14px; }
.grid tbody tr.empty i { margin-right: 6px; }
.grid.loading tbody { opacity: .5; transition: opacity .15s; }
.col-foto { width: 64px; }
.col-actions { width: 96px; text-align: right !important; white-space: nowrap; }
.av { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; display: block; }
.av.ph { display: grid; place-items: center; background: var(--brand-100); color: var(--brand-600); font-size: 22px; }
.nombre { font-weight: 600; color: var(--text); }
.yo { font-size: 11px; font-weight: 700; color: var(--brand-700); background: var(--brand-100); padding: 1px 7px; border-radius: 999px; vertical-align: 1px; }
.is-inactive td { color: var(--muted); }
.is-inactive .nombre { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--brand-300); }
.is-inactive .av { filter: grayscale(1); opacity: .55; }
.cell-chino, .cell-estado { display: inline-flex; align-items: center; gap: 4px; }
.chk { display: inline-flex; }

/* Interruptor Activo / Inactivo */
.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex: none; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch .slider { position: absolute; inset: 0; background: #C9C3C6; border-radius: 999px; transition: background .2s; }
.switch .slider::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform .2s; }
.switch input:checked + .slider { background: var(--success); }
.switch input:checked + .slider::before { transform: translateX(16px); }
.switch input:disabled { cursor: not-allowed; }
.switch input:disabled + .slider { opacity: .55; }
.switch input:focus-visible + .slider { outline: 3px solid var(--brand-300); outline-offset: 2px; }
.est { margin-left: 8px; font-size: 13px; font-weight: 600; }
.est.on { color: var(--success-dark); }
.est.off { color: var(--muted); }

.icon-act { width: 34px; height: 34px; display: inline-grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--brand-700); font-size: 16px; }
.icon-act:hover { background: var(--brand-100); }

.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--line); }
.pager { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pg { min-width: 34px; height: 34px; padding: 0 8px; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--brand-800); font-weight: 600; font-size: 14px; }
.pg:hover:not(:disabled) { background: var(--brand-100); }
.pg.active { background: var(--brand-700); color: #fff; }
.pg:disabled { opacity: .35; cursor: default; }
.dots { color: var(--muted); padding: 0 4px; }

/* ---------------- Modal ---------------- */
body.modal-open { overflow: hidden; }
.modal-overlay { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-start; justify-content: center; padding: 4vh 16px; background: rgba(30, 8, 15, .55); overflow-y: auto; animation: fade .15s ease; }
.modal-overlay[hidden] { display: none; }
.modal-card { width: 100%; max-width: 640px; background: #fff; border-radius: 16px; box-shadow: 0 24px 60px rgba(30,8,15,.35); animation: pop .18s ease; }
.modal-card.small { max-width: 420px; margin-top: 12vh; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2, .modal-card.small h2 { font-size: 19px; color: var(--brand-900); }
.modal-x { width: 36px; height: 36px; border: 0; background: transparent; border-radius: 8px; font-size: 16px; color: var(--muted); }
.modal-x:hover { background: var(--brand-100); color: var(--brand-700); }
.modal-body { padding: 20px; }
.modal-card.small .modal-body p { margin: 8px 0 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); background: #FBF9FA; border-radius: 0 0 16px 16px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---------------- Formularios ---------------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; margin-top: 16px; }
.fld { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.fld.span2 { grid-column: 1 / -1; }
.fld label { font-size: 13.5px; font-weight: 600; color: var(--brand-900); }
.fld input:not([type="checkbox"]):not([type="radio"]), .fld select { width: 100%; }
.fld .invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(211,47,47,.12); }
.err { color: var(--danger); font-size: 12.5px; min-height: 0; }
.err:empty { display: none; }
.pw { position: relative; }
.pw input { padding-right: 42px; }
.pw-eye { position: absolute; right: 2px; top: 2px; width: 36px; height: 36px; border: 0; background: transparent; color: var(--muted); font-size: 17px; border-radius: 8px; }
.pw-eye:hover { color: var(--brand-700); }
.chk-line { display: flex !important; flex-direction: row !important; align-items: center; gap: 10px; font-weight: 400 !important; padding: 10px 12px; border: 1px dashed var(--brand-200); border-radius: 10px; background: var(--brand-50); cursor: pointer; }
.chk-line small { color: var(--muted); }
.note { margin: 14px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--brand-50); color: var(--brand-800); font-size: 13.5px; }

.foto-field { display: flex; align-items: center; gap: 16px; }
.foto-preview { width: 84px; height: 84px; flex: none; border-radius: 50%; overflow: hidden; display: grid; place-items: center; background: var(--brand-100); color: var(--brand-600); font-size: 44px; border: 3px solid #fff; box-shadow: 0 0 0 2px var(--brand-200); }
.foto-preview img { width: 100%; height: 100%; object-fit: cover; }
.foto-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.foto-btns { display: flex; gap: 6px; flex-wrap: wrap; }

.perfil-panel { max-width: 640px; }
.perfil-badges { margin-bottom: 4px; }
.perfil-badges .tag-chino { margin-left: 6px; }
.form-actions { margin-top: 20px; display: flex; justify-content: flex-end; }

/* ---------------- Avisos ---------------- */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 80; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 32px); }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 12px; color: #fff; font-size: 14.5px; box-shadow: 0 8px 24px rgba(30,8,15,.3); animation: pop .2s ease; transition: opacity .3s, transform .3s; }
.toast.ok { background: var(--brand-800); }
.toast.ok i { color: var(--accent); }
.toast.err { background: #B3261E; }
.toast.out { opacity: 0; transform: translateY(6px); }

/* ---------------- Responsive de la tabla ---------------- */
@media (max-width: 820px) {
    .sort-mobile { display: flex; }
    .table-wrap { overflow: visible; }
    .grid, .grid thead, .grid tbody, .grid tr, .grid th, .grid td { display: block; }
    .grid thead .head { display: none; }
    .grid thead .filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px 14px; border-bottom: 2px solid var(--brand-100); }
    .grid thead .filters th { padding: 0; border: 0; }
    .grid thead .filters th.col-foto { display: none; }
    .grid thead .filters th.col-actions { grid-column: 1 / -1; text-align: right !important; width: auto; }
    .grid tbody tr { margin: 10px 12px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff !important; position: relative; }
    .grid td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 0; text-align: right; }
    .grid td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; text-align: left; }
    .grid td.col-foto { width: auto; justify-content: flex-start; padding-bottom: 2px; }
    .grid td.col-actions { position: absolute; top: 8px; right: 10px; width: auto; padding: 0; }
    .grid tbody tr.empty { border: 0; }
    .grid tbody tr.empty td { display: block; text-align: center; }
    .form-grid { grid-template-columns: 1fr; }
    .modal-overlay { padding: 0; align-items: stretch; }
    .modal-card { max-width: none; border-radius: 0; min-height: 100%; }
    .modal-card.small { min-height: 0; margin: auto 16px; border-radius: 16px; align-self: center; }
    .modal-foot { position: sticky; bottom: 0; border-radius: 0; }
    .page-head-row .actions .btn span { display: none; }
    .page-head-row .actions .btn { padding: 0 14px; }
    .page-head-row #btnNuevo span { display: inline; }
}
@media (max-width: 480px) {
    .foto-field { flex-direction: column; align-items: flex-start; }
}

/* ---- ajustes finos (revisión visual) ---- */
.chk-line input[type="checkbox"] { width: 18px; height: 18px; flex: none; margin: 0; accent-color: var(--brand-600); }
.content, .table-panel { min-width: 0; }
.table-panel { overflow: hidden; }
@media (max-width: 575.98px) {
    .table-tools { padding: 12px; }
    .search-box { max-width: none; flex-basis: 100%; }
    .tools-right { width: 100%; justify-content: space-between; }
    .sort-mobile { flex: 1 1 auto; min-width: 0; }
    .sort-mobile select { min-width: 0; flex: 1 1 auto; }
}

/* ---------------- Rubros ---------------- */
.btn-danger { background: #B3261E; color: #fff; }
.btn-danger:hover:not(:disabled) { background: #8F1E18; }
.btn-danger:disabled { opacity: .45; cursor: not-allowed; }
.btn-danger .spinner { border-color: rgba(255,255,255,.35); border-top-color: #fff; }
.acts { display: inline-flex; gap: 2px; }
.icon-act.danger { color: var(--danger); }
.icon-act.danger:hover { background: #FDECEC; }
.col-num { width: 190px; }
.grid-rubros .col-actions { width: 104px; }
.count-pill { display: inline-block; min-width: 28px; padding: 2px 10px; border-radius: 999px; text-align: center; font-size: 13px; font-weight: 700; background: var(--brand-100); color: var(--brand-800); }

.modal-card.narrow { max-width: 500px; }
.del-resumen { margin: 0 0 6px; font-size: 15px; line-height: 1.5; }
.opt { display: flex; align-items: flex-start; gap: 12px; margin-top: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; transition: border-color .15s, background .15s; }
.opt:hover:not(.disabled) { border-color: var(--brand-300); }
.opt input[type="radio"] { flex: none; width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--brand-700); cursor: pointer; }
.opt-body { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.opt-body select { width: 100%; }
.opt-body small { color: var(--muted); font-size: 13px; }
.opt.selected { border-color: var(--brand-500); background: var(--brand-50); }
.opt.danger.selected { border-color: #E3A09B; background: #FDF1F0; }
.opt.disabled { opacity: .6; cursor: not-allowed; }
.opt.disabled input { cursor: not-allowed; }
.chk-line.danger { margin-top: 12px; border-color: #E3A09B; background: #FDF1F0; }
.chk-line.danger input[type="checkbox"] { accent-color: #B3261E; }
.chk-line[hidden] { display: none !important; }
.note.warn { background: #FFF4E0; color: #7A4B00; border: 1px solid #F3D9A4; }
.note[hidden] { display: none; }

@media (max-width: 820px) {
    .col-num, .grid-rubros .col-actions { width: auto; }
    /* Dos botones (editar/eliminar) arriba a la derecha de la tarjeta: se deja lugar para que no tapen el nombre */
    .grid-rubros td[data-label="Nombre"] { padding-right: 84px; justify-content: flex-start; }
    .grid-rubros td[data-label="Nombre"]::before { display: none; }
    .grid-rubros td[data-label="Nombre"] .nombre { font-size: 15.5px; text-align: left; overflow-wrap: anywhere; }
    .modal-card.narrow { min-height: 0; margin: auto 16px; border-radius: 16px; align-self: center; }
    .modal-card.narrow .modal-foot { position: static; border-radius: 0 0 16px 16px; }
}

/* ---------------- Artículos ---------------- */
.thumb { width: 48px; height: 48px; border-radius: 10px; overflow: hidden; display: grid; place-items: center; padding: 0; border: 1px solid var(--line); background: var(--brand-50); color: var(--brand-300); font-size: 22px; flex: none; }
button.thumb { cursor: zoom-in; transition: box-shadow .15s, transform .15s; }
button.thumb:hover { box-shadow: 0 0 0 3px var(--brand-200); }
button.thumb:focus-visible { outline: 3px solid var(--brand-300); outline-offset: 2px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.grid-articulos .col-foto { width: 72px; }
.grid-articulos .col-precio { width: 150px; white-space: nowrap; }
.grid-articulos .col-exist { width: 150px; }
.grid-articulos .col-chino { width: 120px; }
.grid-articulos .col-actions { width: 104px; }
.precio { font-variant-numeric: tabular-nums; font-weight: 600; }
.grid-articulos tr.is-sin .nombre { color: var(--muted); }

.stock-btn, .stock-pill { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 999px; font: inherit; font-size: 13px; font-weight: 700; border: 1px solid transparent; white-space: nowrap; }
.stock-btn { cursor: pointer; transition: background .15s, box-shadow .15s, opacity .15s; }
.stock-btn.con, .stock-pill.con { background: #E4F4E7; color: var(--success-dark); border-color: #BFE3C6; }
.stock-btn.sin, .stock-pill.sin { background: #FDECEC; color: #A3241D; border-color: #F3C4C1; }
.stock-btn.con:hover { background: #D3EDD8; }
.stock-btn.sin:hover { background: #FADADA; }
.stock-btn:focus-visible { outline: 3px solid var(--brand-300); outline-offset: 2px; }
.stock-btn.busy { opacity: .55; cursor: progress; }
.icon-act.locked { color: var(--muted); }
.icon-act.locked:hover { background: #F1EEF0; }
.filters-clear { display: flex; justify-content: flex-end; padding: 8px 14px 0; }
.grid-articulos .filters .col-precio input { min-width: 0; }

.foto-field.rect .foto-preview { width: 120px; height: 90px; border-radius: 12px; font-size: 38px; }
.foto-field.rect { margin-bottom: 4px; }

/* Zoom de imagen */
.lightbox { position: fixed; inset: 0; z-index: 400; display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(30,8,15,.82); cursor: zoom-out; animation: fadein .15s ease; }
.lightbox figure { margin: 0; max-width: min(92vw, 900px); max-height: 90vh; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.lightbox img { max-width: 100%; max-height: 80vh; object-fit: contain; border-radius: 12px; background: #fff; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.lightbox figcaption { color: #fff; font-weight: 600; text-align: center; }
.lightbox-x { position: absolute; top: 14px; right: 14px; width: 42px; height: 42px; border: 0; border-radius: 50%; background: rgba(255,255,255,.16); color: #fff; font-size: 18px; cursor: pointer; }
.lightbox-x:hover { background: rgba(255,255,255,.3); }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 820px) {
    .grid-articulos .col-foto, .grid-articulos .col-precio, .grid-articulos .col-exist, .grid-articulos .col-chino, .grid-articulos .col-actions { width: auto; }
    .grid-articulos td[data-label="Nombre"] { justify-content: flex-start; padding-right: 84px; }
    .grid-articulos td[data-label="Nombre"]::before { display: none; }
    .grid-articulos td[data-label="Nombre"] .nombre { font-size: 15.5px; text-align: left; overflow-wrap: anywhere; }
    .grid-articulos td.col-foto { padding-right: 84px; }
    .grid-articulos .filters .col-chino, .grid-articulos .filters .col-exist, .grid-articulos .filters .col-precio { display: block; }
}
.foto-btns [hidden] { display: none !important; }

/* ---------------- Clientes ---------------- */
.tag-prospecto, .tag-cliente { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.tag-prospecto { background: #FFF1D6; color: #7A4B00; border: 1px solid #F0CF8A; }
.tag-cliente { background: #EEF0F2; color: #4A4F55; border: 1px solid transparent; font-weight: 600; }
.grid-clientes tr.is-prospecto { box-shadow: inset 3px 0 0 var(--accent); }
.grid-clientes .col-tipo { width: 130px; }
.grid-clientes .col-actions { width: 104px; }
.grid-clientes .mail { display: inline-block; max-width: 250px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
@media (max-width: 820px) {
    .grid-clientes .col-tipo, .grid-clientes .col-actions { width: auto; }
    .grid-clientes td[data-label="Nombre"] { justify-content: flex-start; padding-right: 84px; }
    .grid-clientes td[data-label="Nombre"]::before { display: none; }
    .grid-clientes td[data-label="Nombre"] .nombre { font-size: 15.5px; text-align: left; overflow-wrap: anywhere; }
    .grid-clientes tr.is-prospecto { box-shadow: inset 4px 0 0 var(--accent); }
    .grid-clientes .mail { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
}

/* ---------------- Pedidos ---------------- */
.range-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px 20px; flex-wrap: wrap; padding: 14px 16px 0; }
.range-fields { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.range-fields label { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--brand-900); }
.range-fields input[type="date"] { font-family: inherit; font-size: 14.5px; color: var(--text); background: #fff; border: 1px solid #D9D4D7; border-radius: 9px; padding: 0 10px; height: 38px; }
.range-fields input[type="date"]:focus { outline: 0; border-color: var(--brand-500); box-shadow: 0 0 0 3px rgba(169,68,99,.2); }
.range-txt { margin: 0; font-size: 14px; color: var(--muted); }
.range-txt b { color: var(--text); }
.grid-pedidos .col-id { width: 70px; }
.grid-pedidos th, .grid-pedidos td { padding-left: 8px; padding-right: 8px; }
.grid-pedidos th:first-child, .grid-pedidos td:first-child { padding-left: 14px; }
.grid-pedidos th:last-child, .grid-pedidos td:last-child { padding-right: 12px; }
.grid-pedidos td.col-estado .sel-inline { width: 142px; }
.grid-pedidos td.col-veh .sel-inline { width: 118px; }
.grid-pedidos .col-fecha { width: 112px; white-space: nowrap; }
.grid-pedidos .col-num { width: 106px; text-align: right !important; white-space: nowrap; }
.grid-pedidos .col-estado { width: 158px; }
.grid-pedidos .col-dto { width: 72px; }
.grid-pedidos .col-veh { width: 134px; }
.grid-pedidos .col-arca { width: 96px; }
.grid-pedidos .col-nota { width: 70px; }
.grid-pedidos .col-actions { width: 196px; }
.grid-pedidos .filters .col-num input { text-align: left; }
.grid-pedidos .cli-line { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.grid-pedidos .arca-sub { margin-top: 5px; }
.grid-pedidos .nro { font-weight: 700; color: var(--brand-800); font-variant-numeric: tabular-nums; }
.grid-pedidos .f-hora { color: var(--muted); font-size: 12.5px; }
.grid-pedidos tr.is-facturado { box-shadow: inset 3px 0 0 var(--success); }
.grid-pedidos td.col-actions { white-space: nowrap; }
.grid-pedidos .acts { vertical-align: middle; }
a.icon-act { text-decoration: none; }
.icon-act.locked { color: var(--muted); }
.sel-inline { width: 100%; min-width: 104px; height: 32px !important; font-size: 13px !important; padding: 0 4px !important; font-weight: 600; }
.sel-estado.e0 { background: #fff; color: var(--brand-800); }
.sel-estado.e1 { background: #FFF1D6; color: #7A4B00; border-color: #F0CF8A; }
.sel-inline:disabled { opacity: .7; cursor: not-allowed; }
.est-pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.est-pill.e0 { background: var(--brand-100); color: var(--brand-800); }
.est-pill.e1 { background: #FFF1D6; color: #7A4B00; }
.tag-arca { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 700; background: #E4F4E7; color: var(--success-dark); border: 1px solid #BFE3C6; white-space: nowrap; }
.btn-nota, .btn-dup { font: inherit; font-size: 12px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase; padding: 5px 10px; border-radius: 6px; cursor: pointer; border: 1px solid transparent; }
.btn-nota { background: var(--accent); color: var(--accent-text); }
.btn-nota:hover { filter: brightness(.95); }
.btn-dup { margin-left: 6px; background: #fff; color: var(--brand-700); border-color: var(--brand-300); }
.btn-dup:hover { background: var(--brand-50); }
.nota-texto { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; line-height: 1.55; }

.picker { position: relative; }
.picker > input[type="text"] { width: 100%; }
.picker-list { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px; list-style: none; max-height: 240px; overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 30px rgba(30,8,15,.2); }
.picker-list[hidden] { display: none; }
.picker-list li { padding: 8px 10px; border-radius: 8px; cursor: pointer; display: flex; flex-direction: column; gap: 1px; }
.picker-list li small { color: var(--muted); font-size: 12.5px; }
.picker-list li:hover, .picker-list li.on { background: var(--brand-50); }
.picker-list li.vacio { cursor: default; color: var(--muted); }

.grid-vehiculos .col-id { width: 90px; }
.grid-vehiculos .col-num { width: 120px; text-align: left !important; }
.grid-vehiculos .col-estado { width: 200px; }
.grid-vehiculos .col-actions { width: 104px; }

@media (max-width: 820px) {
    .range-bar { padding: 12px 12px 0; }
    .range-fields { width: 100%; }
    .range-fields label { flex: 1 1 140px; }
    .range-fields input[type="date"] { flex: 1; min-width: 0; }
    .grid-pedidos .col-id, .grid-pedidos .col-fecha, .grid-pedidos .col-num, .grid-pedidos .col-dto, .grid-pedidos .col-estado, .grid-pedidos .col-veh, .grid-pedidos .col-arca, .grid-pedidos .col-nota, .grid-pedidos .col-actions,
    .grid-vehiculos .col-id, .grid-vehiculos .col-num, .grid-vehiculos .col-estado, .grid-vehiculos .col-actions { width: auto; }
    .grid-pedidos td.col-estado .sel-inline, .grid-pedidos td.col-veh .sel-inline { width: 190px; max-width: 60vw; }
    .grid-pedidos td.col-actions { position: static; display: flex; justify-content: flex-start; align-items: center; margin-top: 4px; padding-top: 10px; border-top: 1px dashed var(--line); }
    .grid-pedidos td[data-label="Cliente"] .cli-line { justify-content: flex-end; }
    .grid-pedidos td[data-label="Cliente"] .nombre { text-align: right; overflow-wrap: anywhere; }
    .grid-pedidos tr.is-facturado { box-shadow: inset 4px 0 0 var(--success); }
    .grid-pedidos .filters .col-fecha, .grid-pedidos .filters .col-num:empty, .grid-pedidos .filters .col-nota { display: none; }
    .grid-vehiculos td.col-actions { position: absolute; }
}

/* ==========================================================
   Pedido: toma / edición (móvil primero)
   ========================================================== */
.pe { --pe-bar-h: 66px; padding-bottom: 84px; }
.pe-ver { padding-bottom: 0; }
.pe-bar {
    position: sticky; top: var(--topbar-h); z-index: 20; display: flex; align-items: stretch; gap: 10px;
    margin: -16px -16px 10px; padding: 10px 16px; background: #fff; border-bottom: 1px solid var(--line);
    box-shadow: 0 4px 14px rgba(40, 10, 20, .08);
}
.pe-cli { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 10px; text-align: left; padding: 6px 10px; border-radius: 12px; border: 1px solid var(--brand-200); background: var(--brand-50); color: var(--brand-900); }
button.pe-cli:hover { background: var(--brand-100); }
button.pe-cli:focus-visible { outline: 3px solid var(--brand-300); outline-offset: 2px; }
button.pe-cli.vacio { border-style: dashed; border-color: var(--brand-500); }
.pe-cli.solo { border-color: var(--line); background: #FBF9FA; }
.pe-cli-ico { font-size: 26px; color: var(--brand-600); flex: none; }
.pe-cli-txt { min-width: 0; display: flex; flex-direction: column; line-height: 1.2; flex: 1; }
.pe-cli-txt small { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.pe-cli-txt b { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pe-cli-edit { font-size: 18px; color: var(--brand-700); flex: none; }
.pe-total { flex: none; display: flex; flex-direction: column; justify-content: center; align-items: flex-end; line-height: 1.15; padding-left: 4px; }
.pe-total small { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.pe-total b { font-size: 20px; color: var(--brand-800); font-variant-numeric: tabular-nums; white-space: nowrap; }

.pe-sub { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin: 0 0 12px; }
.pe-back { text-decoration: none; color: var(--brand-700); font-weight: 600; font-size: 14.5px; }
.pe-back:hover { text-decoration: underline; }
.pe-id { font-weight: 700; color: var(--brand-900); }
.pe-aviso { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; margin-bottom: 14px; border-radius: 12px; background: #FFF1D6; color: #5E3B00; border: 1px solid #F0D49A; font-size: 14.5px; }
.pe-aviso i { margin-top: 2px; }

.pe-grid { display: block; }
.pe-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.pe-tools .search-box { flex: 1 1 140px; max-width: none; }
.pe-tools .search-box input[type="search"] { width: 100%; height: 42px; padding: 0 12px 0 38px; }
.pe-tools select { flex: 0 1 172px; height: 42px; }

.pe-cat { display: grid; grid-template-columns: 1fr; gap: 10px; }
.cat-item { display: grid; grid-template-columns: 64px 1fr; gap: 6px 12px; padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.cat-item.en-pedido { border-color: var(--brand-400); box-shadow: 0 0 0 2px var(--brand-100), var(--shadow); }
.cat-item.sin { opacity: .62; }
.cat-item .thumb, .ln .thumb { width: 64px; height: 64px; border-radius: 12px; }
.ci-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ci-nombre { font-size: 15.5px; line-height: 1.25; overflow-wrap: anywhere; }
.ci-info .precio { font-size: 16px; }
.ci-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ci-tags:empty { display: none; }
.ci-en { font-size: 12.5px; font-weight: 700; color: var(--brand-700); }
.ci-form { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.ci-form .js-add { flex: 1 1 110px; height: 42px; }
.ci-form .js-add.ok { background: var(--success); color: #fff; }

.qty { display: inline-flex; align-items: stretch; border: 1px solid #D9D4D7; border-radius: 10px; overflow: hidden; background: #fff; height: 42px; }
.qty button { width: 36px; border: 0; background: var(--brand-50); color: var(--brand-800); font-size: 20px; line-height: 1; font-weight: 700; }
.qty button:active { background: var(--brand-100); }
.qty input { width: 46px; border: 0; border-radius: 0; text-align: center; height: 100%; font-weight: 700; font-size: 16px; padding: 0 2px; }
.qty input:focus { box-shadow: none; background: var(--brand-50); }
.fld-mini { display: flex; flex-direction: column; gap: 2px; font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.fld-mini input { width: 58px; height: 42px; text-align: center; font-size: 16px; font-weight: 600; text-transform: none; letter-spacing: 0; }
.fld-mini.precio-in input { width: 108px; text-align: right; padding-right: 10px; }
input.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(211, 47, 47, .15); }
.pe-mas { text-align: center; margin: 14px 0 6px; }
.pe-vacio { text-align: center; color: var(--muted); padding: 28px 12px; }
.pe-vacio i { font-size: 34px; color: var(--brand-300); }
.pe-vacio p { margin: 8px 0 0; }

/* Detalle del pedido */
.pe-order { background: #fff; display: flex; flex-direction: column; }
.pe-order-head { display: none; align-items: center; justify-content: space-between; padding: 14px 16px; background: var(--brand-700); color: #fff; }
.pe-order-head h2 { font-size: 18px; }
.pe-x { width: 38px; height: 38px; border: 0; border-radius: 10px; background: rgba(255,255,255,.14); color: #fff; font-size: 16px; }
.pe-order-body { padding: 14px 16px; flex: 1; overflow-y: auto; }
.pe-lineas { display: flex; flex-direction: column; }
.ln { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.ln:first-child { padding-top: 0; }
.ln-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.ln-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.ln-nombre { font-size: 15px; line-height: 1.25; overflow-wrap: anywhere; }
.ln-del { flex: none; width: 34px; height: 34px; border-radius: 9px; border: 1px solid #F1C9C6; background: #FFF5F4; color: #B3261E; }
.ln-ctrl { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 10px; }
.ln-ctrl .qty { height: 40px; }
.ln-ctrl .fld-mini input { height: 40px; }
.ln-pu { align-self: center; color: var(--muted); font-size: 13.5px; }
.ln-ro { color: var(--muted); font-size: 14px; }
.ln-sub { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; }
.ln-sub b { font-size: 16px; color: var(--brand-800); font-variant-numeric: tabular-nums; }
.pe-resumen { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: var(--brand-50); }
.pe-resumen > div { display: flex; justify-content: space-between; padding: 2px 0; font-variant-numeric: tabular-nums; }
.pe-resumen .tot { font-size: 19px; font-weight: 800; color: var(--brand-800); }
.pe-nota { margin-top: 14px; }
.pe-nota label { display: block; font-size: 13.5px; font-weight: 600; color: var(--brand-900); margin-bottom: 6px; }
.pe-nota textarea { width: 100%; resize: vertical; min-height: 84px; font: inherit; font-size: 15px; padding: 10px; border: 1px solid #D9D4D7; border-radius: 9px; }
.pe-nota textarea:focus { outline: 0; border-color: var(--brand-500); box-shadow: 0 0 0 3px rgba(169,68,99,.2); }
.pe-order-foot { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); background: #FBF9FA; }
.pe-order-foot .btn { flex: 1 1 auto; }
.pe-ver .pe-order { border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; max-width: 760px; }
.pe-ver .pe-order-body { overflow: visible; }

/* Barra inferior (solo pantallas chicas) */
.pe-dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 35; display: flex; gap: 10px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -6px 18px rgba(40,10,20,.12); }
.pe-ver-btn { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 0 14px; height: 48px; border: 0; border-radius: 12px; background: var(--brand-700); color: #fff; text-align: left; }
.pe-ver-btn > .bi-cart3 { font-size: 20px; }
.pe-dock-txt { flex: 1; display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.pe-dock-txt small { font-size: 14px; opacity: .9; font-variant-numeric: tabular-nums; }
.pe-dock .btn { height: 48px; }
.pe-backdrop { display: none; }
body:has(.pe-dock) .toasts { bottom: 84px; }
body.pe-lock { overflow: hidden; }

@media (max-width: 1099.98px) {
    .pe-order { position: fixed; top: 0; right: 0; bottom: 0; width: min(94vw, 460px); z-index: 45; transform: translateX(105%); transition: transform .25s ease; box-shadow: -10px 0 30px rgba(30,8,15,.3); }
    .pe.open .pe-order { transform: none; }
    .pe-order-head { display: flex; }
    .pe-ver .pe-order { position: static; transform: none; width: auto; box-shadow: var(--shadow); }
    .pe-ver .pe-order-head { display: none; }
    .pe.open .pe-backdrop { display: block; position: fixed; inset: 0; z-index: 44; background: rgba(30,8,15,.5); }
}
@media (min-width: 1100px) {
    .pe { padding-bottom: 0; }
    .pe-bar { margin: -24px -24px 14px; padding: 10px 24px; }
    .pe-dock { display: none; }
    .pe-grid { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 20px; align-items: start; }
    .pe-ver .pe-grid { display: block; }
    .pe-order { position: sticky; top: calc(var(--topbar-h) + 88px); max-height: calc(100vh - var(--topbar-h) - 108px); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
    .pe-cat { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .pe-x { display: none; }
}
@media (min-width: 1500px) { .pe-cat { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* Selector de cliente */
.pe-clientes { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 52vh; overflow-y: auto; }
.pe-clientes .vacio { padding: 14px 4px; }
.pe-cli-op { width: 100%; text-align: left; display: flex; flex-direction: column; gap: 1px; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line); background: #fff; }
.pe-cli-op:hover, .pe-cli-op.on { background: var(--brand-50); border-color: var(--brand-300); }
.pe-cli-op b { color: var(--brand-900); }
.pe-cli-op small { color: var(--muted); }
.pe-cli-hint { font-size: 13px; margin: 10px 0 0; }
.modal-card.narrow .search-box { max-width: none; }
.modal-card.narrow .search-box input[type="search"] { width: 100%; height: 44px; padding: 0 12px 0 38px; }

/* ==========================================================
   Facturación (reparto) y color de vehículos
   ========================================================== */
.veh-chip { display: inline-block; padding: 3px 11px; border-radius: 999px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.veh-chip.sin { background: #ECE9EB; color: var(--muted); font-weight: 600; }
.veh-dot { display: inline-block; width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); vertical-align: middle; }
.color-pick { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.color-pick input[type="color"] { width: 52px; height: 42px; padding: 2px; border: 1px solid #D9D4D7; border-radius: 9px; background: #fff; cursor: pointer; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatches .sw { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); padding: 0; }
.swatches .sw.on { box-shadow: 0 0 0 2px var(--brand-700); }
.fld .hint { font-size: 12.5px; }
.grid-vehiculos .col-color { width: 80px; }

.sel-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; margin: 0 20px 10px; padding: 9px 14px; border-radius: 10px; background: var(--brand-50); border: 1px solid var(--brand-100); color: var(--brand-900); font-size: 14.5px; }
.sel-bar[hidden] { display: none; }
.sel-bar > i { color: var(--brand-600); }
.link-btn { margin-left: auto; background: none; border: 0; color: var(--brand-700); font-weight: 600; text-decoration: underline; padding: 2px 4px; }
.range-txt .warn { color: #B3261E; font-weight: 600; }
.grid-fact .col-chk { width: 52px; text-align: center; }
.grid-fact .col-id { width: 90px; }
.grid-fact .col-fecha { width: 150px; }
.grid-fact .col-veh { width: 170px; }
.grid-fact tbody tr[data-id] { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.grid-fact tbody tr.is-sel td { background: var(--brand-50); }
.chk-all, .chk-row { display: inline-grid; place-items: center; width: 40px; height: 40px; cursor: pointer; }
.chk-all input, .chk-row input { width: 20px; height: 20px; }
.tools-right select { height: 34px; font-size: 14px; }

@media (max-width: 820px) {
    .grid-fact .col-chk, .grid-fact .col-id, .grid-fact .col-fecha, .grid-fact .col-veh { width: auto; }
    .grid-fact thead tr.head .col-chk { display: block; text-align: left; padding: 4px 8px; }
    .grid-fact tbody td.col-chk { position: absolute; top: 6px; right: 6px; width: auto; padding: 0; border: 0; }
    .grid-fact tbody tr { position: relative; }
    .grid-fact tbody td.col-id { padding-right: 52px; }
    .grid-fact tbody tr.is-sel { background: var(--brand-50) !important; border-color: var(--brand-400); }
    .grid-fact tbody tr.is-sel td { background: transparent; }
    .sel-bar { margin: 0 12px 10px; }
}
@media (max-width: 820px) { .page-head-row #btnImprimir span { display: inline; } }
@media (max-width: 820px) {
    .grid-vehiculos .col-color { width: auto; }
    .grid-vehiculos td.col-id { padding-right: 84px; }
}

/* Vehículo editable en Facturación */
.sel-veh { height: 34px; min-width: 140px; max-width: 100%; padding: 0 28px 0 12px; border: 0; border-radius: 999px; font-size: 13.5px; font-weight: 700; cursor: pointer; }
.sel-veh.sin { background-color: #ECE9EB; color: var(--muted); font-weight: 600; }
.sel-veh option { background: #fff; color: var(--text); font-weight: 400; }
.sel-veh:disabled { opacity: .6; cursor: progress; }
@media (max-width: 820px) { .grid-fact td.col-veh { padding: 6px 0; } .sel-veh { min-width: 170px; height: 38px; } }

/* Clientes: datos para facturar (ARCA) */
.arca-box { border: 1px solid var(--brand-100); border-radius: 12px; background: #FDFBFC; overflow: hidden; }
.arca-head { width: 100%; display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--brand-50); border: 0; text-align: left; color: var(--brand-900); font-size: 15px; font-weight: 600; }
.arca-head > i:first-child { color: var(--brand-600); font-size: 18px; }
.arca-title { flex: 1; min-width: 0; }
.arca-chev { transition: transform .2s; color: var(--muted); }
.arca-box.open .arca-chev { transform: rotate(180deg); }
.arca-estado { font-size: 12.5px; font-weight: 700; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.arca-estado.sin { background: #ECE9EB; color: var(--muted); font-weight: 600; }
.arca-estado.parcial { background: #FFF1D6; color: #7A4B00; }
.arca-estado.ok { background: #E4F4E7; color: var(--success-dark); }
.arca-body { padding: 4px 14px 14px; }
.arca-body[hidden] { display: none; }
.arca-body .form-grid { margin-top: 10px; }
.arca-hint { font-size: 13px; margin: 12px 0 0; }
.input-btn { display: flex; gap: 8px; }
.input-btn input { flex: 1; min-width: 0; }
.input-btn .btn { flex: none; height: 40px; }
input.is-off { background: #F3F2F4; }
@media (max-width: 480px) { .input-btn { flex-direction: column; } .input-btn input { flex: none; height: 42px; } .input-btn .btn { width: 100%; height: 42px; } }
