/* =====================================================================
   Frutaleza — Estilos de la app (sobre tokens.css)
   Cálido, redondeado, mobile-first. Sin frameworks CSS.
   ===================================================================== */

/* ---------- Topbar ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 18px;
    padding-top: max(12px, env(safe-area-inset-top));
    background: var(--fz-ink-900);
    color: var(--fz-white);
}
.nav-burger {
    display: none;
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
    color: var(--fz-orange-300);
}
.brand { display: flex; flex-direction: column; line-height: 1.1; margin-right: auto; }
.brand-mark { font-weight: 800; font-size: 1.25rem; letter-spacing: -.02em; color: var(--fz-orange-300); }
.brand-sub { font-size: .72rem; color: rgba(255, 255, 255, .78); font-weight: 500; }
.topbar-user { display: flex; align-items: center; gap: 10px; }
.user-chip {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: .82rem; font-weight: 600;
    background: rgba(255, 255, 255, .08); padding: 6px 12px; border-radius: var(--radius-pill);
}
.user-role { font-style: normal; font-weight: 500; color: var(--fz-orange-300); font-size: .72rem; text-transform: uppercase; }
.btn-logout {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, .08); color: var(--fz-white); font-size: 1.05rem;
}
@media (hover: hover) { .btn-logout:hover { background: var(--fz-orange-600); } }

/* ---------- Shell (sidebar + main) ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; align-items: start; }
.sidebar {
    position: sticky; top: 61px; align-self: start;
    height: calc(100vh - 61px); overflow-y: auto;
    background: var(--fz-white); border-right: 1px solid var(--fz-card-border);
    padding: 14px 12px;
}
.nav-group {
    font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
    color: var(--fz-ink-300); padding: 14px 12px 6px;
}
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: var(--radius-sm);
    color: var(--fz-ink-700); font-weight: 600; font-size: .9rem;
}
.nav-item i { font-size: 1.05rem; color: var(--fz-ink-500); width: 20px; text-align: center; }
.nav-item .nav-soon {
    margin-left: auto; font-size: .6rem; font-weight: 700; text-transform: uppercase;
    color: var(--fz-ink-300); background: var(--fz-orange-50); padding: 2px 7px; border-radius: var(--radius-pill);
}
@media (hover: hover) { .nav-item:hover { background: var(--fz-orange-50); } }
.nav-item.is-active { background: var(--fz-orange-500); color: var(--fz-white); }
.nav-item.is-active i { color: var(--fz-white); }
.nav-item.is-active .nav-soon { color: var(--fz-white); background: rgba(255, 255, 255, .2); }

/* Submenú desplegable (Finanzas) */
.nav-parent-btn { width: 100%; background: none; border: 0; cursor: pointer; font: inherit; text-align: left; }
.nav-caret { margin-left: auto; font-size: .8rem !important; transition: transform .18s ease; }
.nav-parent.open > .nav-parent-btn .nav-caret { transform: rotate(180deg); }
.nav-children { display: none; margin: 2px 0 4px; padding-left: 12px; border-left: 2px solid var(--fz-orange-100); }
.nav-parent.open > .nav-children { display: block; }
.nav-child { padding: 7px 12px; font-size: .86rem; }
.nav-child i { font-size: .95rem; }
.nav-parent.open > .nav-parent-btn { color: var(--fz-orange-700); }

/* ---------- Main ---------- */
.main { padding: 22px clamp(18px, 4vw, 34px); min-height: calc(100vh - 61px); }
.page-head { margin-bottom: 20px; }
.page-head h1 { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; }
.page-head p { color: var(--fz-ink-500); margin-top: 2px; }
.page-head .crumb { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--fz-orange-700); }

/* ---------- Stat cards ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-bottom: 26px; }
.stat {
    display: flex; align-items: center; gap: 14px;
    background: var(--fz-white); border: 1px solid var(--fz-card-border);
    border-radius: var(--radius-md); box-shadow: var(--shadow-sm); padding: 16px 18px;
}
.stat .stat-ico {
    display: grid; place-items: center; width: 46px; height: 46px; flex: none;
    border-radius: var(--radius-sm); background: var(--fz-orange-50); color: var(--fz-orange-500); font-size: 1.3rem;
}
.stat.is-alert .stat-ico { background: var(--fz-error-bg); color: var(--fz-error-text); }
.stat > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.stat-num { display: block; font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; color: var(--fz-ink-900); }
.stat-label { display: block; font-size: .82rem; color: var(--fz-ink-500); font-weight: 600; }
.stat-hint { display: block; font-size: .68rem; color: var(--fz-ink-300); }
@media (hover: hover) { a.stat:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); transition: .15s; } }

/* ---------- Cards / grid ---------- */
.grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 620px) { .grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1180px) { .grid { grid-template-columns: 1fr 1fr 1fr; } }
.card {
    background: var(--fz-white); border: 1px solid var(--fz-card-border);
    border-radius: var(--radius-md); box-shadow: var(--shadow-sm);
    padding: 16px; display: flex; flex-direction: column; gap: 10px;
    content-visibility: auto; contain-intrinsic-size: 180px;
}
.card-nombre { font-weight: 700; font-size: 1.06rem; line-height: 1.25; }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.card-dir { display: flex; align-items: flex-start; gap: 6px; color: var(--fz-ink-700); font-size: .9rem; }
.card-dir i, .card-tel i { color: var(--fz-orange-500); }
.card-tel { font-weight: 700; display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.tel-vacio { color: var(--fz-ink-300); font-weight: 500; }

/* ---------- Chips ---------- */
.chip {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: .74rem; font-weight: 600; padding: 4px 10px; border-radius: var(--radius-pill);
    background: var(--fz-orange-50); color: var(--fz-orange-700);
}
.chip-hora { background: var(--fz-chip-hora-bg); color: var(--fz-green-700); }
.chip-vend { background: var(--fz-orange-50); color: var(--fz-orange-700); }
.chip-muted { background: #F3EEE9; color: var(--fz-ink-500); }
.chip-ok { background: var(--fz-chip-hora-bg); color: var(--fz-green-700); }
.chip-warn { background: var(--fz-error-bg); color: var(--fz-error-text); }

/* Prioridad (colores) */
.prio { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.prio-1 { background: #B8A89E; } .prio-2 { background: #6CD9B0; }
.prio-3 { background: #F2A02A; } .prio-4 { background: #DC4F12; }

/* ---------- Tabla ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--fz-card-border); border-radius: var(--radius-md); background: var(--fz-white); box-shadow: var(--shadow-sm); }
table.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.tbl th {
    text-align: left; font-size: .7rem; text-transform: uppercase; letter-spacing: .05em;
    color: var(--fz-ink-500); font-weight: 700; padding: 12px 14px; border-bottom: 1px solid var(--fz-card-border); white-space: nowrap;
}
table.tbl td { padding: 12px 14px; border-bottom: 1px solid #F5EEE6; vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: 0; }
@media (hover: hover) { table.tbl tbody tr:hover { background: var(--fz-orange-50); } }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.money { font-variant-numeric: tabular-nums; font-weight: 700; }

/* ---------- Toolbar / búsqueda ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }
.searchbar {
    display: flex; align-items: center; gap: 8px; flex: 1 1 260px; max-width: 420px;
    background: var(--fz-white); border: 1.5px solid var(--fz-orange-100);
    border-radius: var(--radius-pill); padding: 8px 14px;
}
.searchbar:focus-within { border-color: var(--fz-orange-500); box-shadow: var(--shadow-md); }
.searchbar i { color: var(--fz-orange-500); }
.searchbar input { border: 0; outline: 0; background: transparent; font: inherit; width: 100%; color: var(--fz-ink-900); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Botones / píldoras ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 7px;
    font: inherit; font-weight: 700; font-size: .88rem; cursor: pointer;
    border: 0; border-radius: var(--radius-pill); padding: 9px 16px;
    background: var(--fz-orange-500); color: var(--fz-white);
}
.btn-ghost { background: var(--fz-orange-50); color: var(--fz-orange-700); }
.pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 14px; border-radius: var(--radius-pill); font-size: .82rem; font-weight: 600;
    background: var(--fz-white); border: 1px solid var(--fz-card-border); color: var(--fz-ink-700);
}
.pill.is-active { background: var(--fz-ink-900); color: var(--fz-white); border-color: var(--fz-ink-900); }
@media (hover: hover) {
    .btn:hover { filter: brightness(1.05); }
    .pill:hover { border-color: var(--fz-orange-300); }
}
.btn:active, .pill:active { transform: scale(.97); }

/* ---------- Estados ---------- */
.alerta {
    background: var(--fz-error-bg); border: 1px solid var(--fz-error-border); color: var(--fz-error-text);
    border-radius: var(--radius-md); padding: 14px 16px; font-weight: 600; margin-bottom: 16px;
    display: flex; align-items: center; gap: 10px;
}
.sin-resultados { text-align: center; color: var(--fz-ink-300); padding: 60px 20px; }
.sin-resultados i { font-size: 3rem; display: block; margin-bottom: 10px; }

/* ---------- Placeholder módulo ---------- */
.soon-hero {
    background: var(--fz-white); border: 1px dashed var(--fz-orange-100);
    border-radius: var(--radius-md); padding: 48px 24px; text-align: center; box-shadow: var(--shadow-sm);
}
.soon-hero .soon-ico { font-size: 3rem; color: var(--fz-orange-300); }
.soon-hero h2 { font-size: 1.4rem; font-weight: 800; margin-top: 12px; letter-spacing: -.02em; }
.soon-hero p { color: var(--fz-ink-500); margin-top: 6px; max-width: 460px; margin-inline: auto; }

/* ---------- Catálogos ---------- */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.cat-card { background: var(--fz-white); border: 1px solid var(--fz-card-border); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); overflow: hidden; }
.cat-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--fz-card-border); }
.cat-head i { color: var(--fz-orange-500); font-size: 1.2rem; }
.cat-head h3 { font-size: 1rem; font-weight: 700; }
.cat-head .count { margin-left: auto; font-size: .75rem; color: var(--fz-ink-300); font-weight: 700; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background:
    radial-gradient(1200px 500px at 100% -10%, #FFE2CC55, transparent),
    var(--fz-cream); }
.login-card {
    width: 100%; max-width: 380px; background: var(--fz-white);
    border: 1px solid var(--fz-card-border); border-radius: var(--radius-md); box-shadow: var(--shadow-md);
    padding: 30px 26px;
}
.login-brand { text-align: center; margin-bottom: 22px; }
.login-brand .logo { font-size: 2rem; font-weight: 800; letter-spacing: -.03em; color: var(--fz-orange-500); }
.login-brand span { display: block; color: var(--fz-ink-500); font-size: .85rem; margin-top: 2px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: .78rem; font-weight: 700; color: var(--fz-ink-700); margin-bottom: 6px; }
.field input {
    width: 100%; font: inherit; padding: 11px 14px; border-radius: var(--radius-sm);
    border: 1.5px solid var(--fz-orange-100); background: var(--fz-white); color: var(--fz-ink-900);
}
.field input:focus { outline: 0; border-color: var(--fz-orange-500); box-shadow: var(--shadow-md); }
.btn-block { width: 100%; justify-content: center; padding: 12px; margin-top: 6px; }

/* ---------- Formularios ---------- */
.order-form { max-width: 820px; display: flex; flex-direction: column; gap: 16px; }
.form-card { background: var(--fz-white); border: 1px solid var(--fz-card-border); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); padding: 18px; }
.form-sub { font-size: 1rem; font-weight: 700; display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.form-sub i { color: var(--fz-orange-500); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 620px) { .form-row { grid-template-columns: 1fr; } }
.order-form .field { margin-bottom: 12px; }
.order-form .field:last-child { margin-bottom: 0; }
.order-form label { display: block; font-size: .78rem; font-weight: 700; color: var(--fz-ink-700); margin-bottom: 6px; }
.order-form .req { color: var(--fz-orange-600); }
.order-form input,
.order-form select,
.order-form textarea {
    width: 100%; font: inherit; padding: 10px 13px; border-radius: var(--radius-sm);
    border: 1.5px solid var(--fz-orange-100); background: var(--fz-white); color: var(--fz-ink-900);
}
.order-form select:focus,
.order-form input:focus,
.order-form textarea:focus { outline: 0; border-color: var(--fz-orange-500); box-shadow: var(--shadow-md); }
.order-form input.qty,
.order-form input.desc { width: 92px; padding: 7px 10px; text-align: right; font-variant-numeric: tabular-nums; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; align-items: center; }
.aviso {
    background: var(--fz-chip-hora-bg); border: 1px solid #BEEBD8; color: var(--fz-green-700);
    border-radius: var(--radius-md); padding: 12px 16px; font-weight: 600; margin-bottom: 16px;
    display: flex; align-items: center; gap: 10px;
}
.aviso.aviso-warn { background: var(--fz-orange-50); border-color: var(--fz-orange-100); color: var(--fz-orange-700); }
.head-actions { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }

/* ---------- Formularios en línea (abono, catálogos, caja, nómina…) ---------- */
.abono-form { display: flex; gap: 8px; align-items: center; }
.abono-form input,
.abono-form select,
.abono-form textarea {
    font: inherit; padding: 7px 10px; border-radius: var(--radius-sm);
    border: 1.5px solid var(--fz-orange-100); background: var(--fz-white); color: var(--fz-ink-900);
    height: 36px; box-sizing: border-box;
}
.abono-form input[type="number"] { text-align: right; font-variant-numeric: tabular-nums; }
.abono-form input:focus, .abono-form select:focus, .abono-form textarea:focus {
    outline: 0; border-color: var(--fz-orange-500); box-shadow: var(--shadow-sm);
}
.abono-form .btn { padding: 8px 13px; }
.abono-form label { font-size: .8rem; font-weight: 600; color: var(--fz-ink-700); display: flex; align-items: center; gap: 5px; }

/* ---------- Selector de estado en línea (pedidos) ---------- */
.status-sel {
    font: inherit; font-size: .78rem; font-weight: 600; padding: 5px 26px 5px 10px;
    border-radius: var(--radius-pill); border: 1.5px solid var(--fz-card-border);
    background: var(--fz-white); color: var(--fz-ink-700); cursor: pointer;
}
.status-sel:focus { outline: 0; border-color: var(--fz-orange-500); }
.status-sel.status-confirmado, .status-sel.status-entregado { background: var(--fz-chip-hora-bg); color: var(--fz-green-700); border-color: #BEEBD8; }
.status-sel.status-cancelado { background: var(--fz-error-bg); color: var(--fz-error-text); border-color: var(--fz-error-border); }
.status-sel.status-en_ruta, .status-sel.status-en_produccion { background: var(--fz-orange-50); color: var(--fz-orange-700); border-color: var(--fz-orange-100); }

/* ---------- Combo buscable (select con buscador) ---------- */
.fz-combo { position: relative; }
.fz-combo-native { display: none !important; }
.fz-combo .fz-combo-input {
    width: 100%; font: inherit; padding: 10px 36px 10px 13px; border-radius: var(--radius-sm);
    border: 1.5px solid var(--fz-orange-100); background: var(--fz-white); color: var(--fz-ink-900);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23F2682A' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001q.044.06.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1 1 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center;
}
.fz-combo .fz-combo-input:focus { outline: 0; border-color: var(--fz-orange-500); box-shadow: 0 0 0 3px rgba(242, 104, 42, .12); }
.fz-combo-panel {
    position: absolute; z-index: 60; top: calc(100% + 4px); left: 0; right: 0;
    max-height: 280px; overflow-y: auto; background: var(--fz-white);
    border: 1.5px solid var(--fz-orange-100); border-radius: var(--radius-sm);
    box-shadow: 0 10px 30px rgba(60, 30, 10, .14); padding: 5px;
}
.fz-combo-opt {
    padding: 8px 11px; border-radius: 8px; cursor: pointer; font-size: .92rem;
    color: var(--fz-ink-900); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fz-combo-opt:hover, .fz-combo-opt.is-active { background: var(--fz-orange-50); }
.fz-combo-opt.is-selected { color: var(--fz-orange-700); font-weight: 600; }
.fz-combo-empty { padding: 10px 11px; color: var(--fz-ink-500); font-size: .88rem; }

/* ---------- Pantalla de carga (AJAX) ---------- */
.fz-loading {
    position: fixed; inset: 0; z-index: 3000; display: flex; align-items: center; justify-content: center;
    background: rgba(255, 250, 245, .62); backdrop-filter: blur(2px);
}
.fz-loading[hidden] { display: none; }
.fz-spinner {
    width: 46px; height: 46px; border-radius: 50%;
    border: 4px solid var(--fz-orange-100); border-top-color: var(--fz-orange-500);
    animation: fz-spin .7s linear infinite;
}
@keyframes fz-spin { to { transform: rotate(360deg); } }

/* ---------- Check "guardar como recurrente" ---------- */
.fz-check {
    display: flex; align-items: center; gap: 10px; margin-top: 14px;
    font-weight: 600; font-size: .9rem; color: var(--fz-ink-900); cursor: pointer; line-height: 1;
}
/* Casilla personalizada (anula el estilo de .order-form input), centrada y de marca. */
.fz-check input[type="checkbox"] {
    -webkit-appearance: none; appearance: none;
    width: 20px; height: 20px; min-width: 20px; flex: 0 0 auto;
    margin: 0; padding: 0; box-shadow: none; cursor: pointer; position: relative;
    border: 1.5px solid var(--fz-orange-100); border-radius: 6px; background: var(--fz-white);
    transition: background .15s, border-color .15s;
}
.fz-check input[type="checkbox"]:hover { border-color: var(--fz-orange-500); }
.fz-check input[type="checkbox"]:checked { background: var(--fz-orange-500); border-color: var(--fz-orange-500); }
.fz-check input[type="checkbox"]:checked::after {
    content: ''; position: absolute; left: 6px; top: 2px; width: 5px; height: 10px;
    border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.fz-check span { line-height: 1.3; }
.fz-check strong { color: var(--fz-orange-700); }

/* ---------- Botón secundario y badges de vuelta (Generar rutas) ---------- */
.btn-ghost { background: var(--fz-white); color: var(--fz-orange-700); border: 1.5px solid var(--fz-orange-100); }
.btn-ghost:hover { background: var(--fz-orange-50); }
.trip-badge { display: inline-block; padding: 4px 12px; border-radius: var(--radius-pill); font-weight: 700; font-size: .82rem; border: 1.5px solid transparent; white-space: nowrap; }
.trip-1 { background: var(--fz-orange-50); color: var(--fz-orange-700); border-color: var(--fz-orange-100); }
.trip-2 { background: #EAF7F0; color: var(--fz-green-700); border-color: #BEEBD8; }
.trip-3 { background: #EAF1FB; color: #2563EB; border-color: #C7DBF7; }
.trip-4 { background: #F3EAFB; color: #7C3AED; border-color: #DDC7F7; }
/* Rubro LOCAL (trip 0): el cliente recoge en el local, no va en ruta. */
.trip-0 { background: #FDF3E3; color: #8A5A12; border-color: #F2DEB8; }
.trip-sel { font: inherit; font-weight: 600; padding: 6px 10px; border-radius: var(--radius-sm); border: 1.5px solid var(--fz-orange-100); background: var(--fz-white); cursor: pointer; }
.trip-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 3px; vertical-align: middle; }
.trip-dot.trip-1 { background: var(--fz-orange-500); }
.trip-dot.trip-2 { background: #22B07D; }
.trip-dot.trip-3 { background: #2563EB; }
.trip-dot.trip-4 { background: #7C3AED; }
.trip-dot.trip-0 { background: #C9922B; }
.agua-chip { display: inline-block; padding: 3px 9px; border-radius: var(--radius-pill); background: #FBF3EC; border: 1px solid var(--fz-orange-100); font-size: .78rem; color: var(--fz-ink-700); white-space: nowrap; }
.agua-chip .agua-fl { font-weight: 700; color: var(--fz-ink-900); }
.agua-chip b { color: var(--fz-orange-700); }
.agua-list { display: flex; flex-wrap: wrap; gap: 5px; }

/* Resumen por vuelta (Generar rutas) */
.rutas-summary { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 18px; }
@media (max-width: 1400px) { .rutas-summary { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 1000px) { .rutas-summary { grid-template-columns: repeat(2, 1fr); } }
.rutas-card { border-radius: 14px; border: 1.5px solid var(--fz-card-border); background: var(--fz-white); padding: 13px 15px; box-shadow: 0 1px 3px rgba(60, 30, 10, .05); border-top-width: 3px; }
.trip-1-soft { border-top-color: var(--fz-orange-500); }
.trip-2-soft { border-top-color: #22B07D; }
.trip-3-soft { border-top-color: #2563EB; }
.trip-4-soft { border-top-color: #7C3AED; }
.trip-0-soft { border-top-color: #C9922B; }
.rutas-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.rutas-card-meta { font-size: .8rem; color: var(--fz-ink-500); }
.rutas-breakdown { display: flex; flex-direction: column; }
.rutas-line { display: flex; justify-content: space-between; gap: 12px; font-size: .82rem; color: var(--fz-ink-700); padding: 4px 0; border-bottom: 1px dashed var(--fz-orange-100); }
.rutas-line:last-child { border-bottom: 0; }
.rutas-line b { color: var(--fz-ink-900); font-variant-numeric: tabular-nums; }

/* Resumen general de Pedidos */
.ped-summary-grid { display: flex; gap: 34px; align-items: stretch; flex-wrap: wrap; }
.ped-stats { display: flex; flex-direction: column; gap: 16px; padding-right: 34px; border-right: 1px dashed var(--fz-orange-100); justify-content: center; }
@media (max-width: 720px) { .ped-stats { border-right: 0; padding-right: 0; border-bottom: 1px dashed var(--fz-orange-100); padding-bottom: 12px; flex-direction: row; gap: 24px; } }
.ped-stat { display: flex; flex-direction: column; }
.ped-stat-num { font-size: 1.5rem; font-weight: 800; color: var(--fz-ink-900); line-height: 1.1; font-variant-numeric: tabular-nums; }
.ped-stat-num.money { color: var(--fz-green-700); }
.ped-stat-lbl { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--fz-ink-500); font-weight: 700; }
.aguas-matrix { border-collapse: collapse; min-width: 340px; }
.aguas-matrix th { padding: 4px 16px; text-align: right; font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--fz-ink-500); font-weight: 700; border-bottom: 1.5px solid var(--fz-orange-100); }
.aguas-matrix th:first-child { text-align: left; }
.aguas-matrix td { padding: 5px 16px; text-align: right; font-variant-numeric: tabular-nums; border-bottom: 1px dashed var(--fz-orange-100); color: var(--fz-ink-700); }
.aguas-matrix td:first-child { text-align: left; font-weight: 700; color: var(--fz-ink-900); }
.aguas-matrix td.col-total { color: var(--fz-orange-700); font-weight: 700; }
.aguas-matrix tfoot td { font-weight: 800; color: var(--fz-ink-900); border-top: 1.5px solid var(--fz-orange-100); border-bottom: 0; }
.aguas-matrix tfoot td:last-child { color: var(--fz-orange-700); }
.devol-chip { display: inline-block; padding: 3px 9px; border-radius: var(--radius-pill); background: var(--fz-error-bg); border: 1px solid var(--fz-error-border); font-size: .78rem; color: var(--fz-error-text); white-space: nowrap; }
.devol-chip b { font-weight: 700; }

/* Input con estilo del sistema para usar dentro de tablas */
.cell-input {
    font: inherit; padding: 7px 11px; border-radius: var(--radius-sm); box-sizing: border-box;
    border: 1.5px solid var(--fz-orange-100); background: var(--fz-white); color: var(--fz-ink-900);
    transition: border-color .15s, box-shadow .15s;
}
.cell-input::placeholder { color: var(--fz-ink-300); }
.cell-input:focus { outline: 0; border-color: var(--fz-orange-500); box-shadow: 0 0 0 3px rgba(242, 104, 42, .12); }
.cell-input[type="number"] { text-align: right; font-variant-numeric: tabular-nums; }

/* Matriz de producción (Orden de trabajo) */
.prod-matrix { border-collapse: collapse; min-width: 500px; }
.prod-matrix th { padding: 5px 14px; text-align: right; font-size: .72rem; color: var(--fz-ink-500); text-transform: uppercase; letter-spacing: .03em; border-bottom: 1.5px solid var(--fz-orange-100); font-weight: 700; }
.prod-matrix thead tr:first-child th { text-align: center; border-bottom: 0; padding-bottom: 2px; }
.prod-matrix th[rowspan] { text-align: left; vertical-align: bottom; }
.prod-matrix td { padding: 5px 14px; text-align: right; font-variant-numeric: tabular-nums; border-bottom: 1px dashed var(--fz-orange-100); color: var(--fz-ink-700); }
.prod-matrix td:first-child { text-align: left; font-weight: 700; color: var(--fz-ink-900); }
.prod-matrix .prod-col { background: var(--fz-orange-50); color: var(--fz-orange-700); font-weight: 700; }
.prod-matrix tfoot td { font-weight: 800; color: var(--fz-ink-900); border-top: 1.5px solid var(--fz-orange-100); border-bottom: 0; }
.prod-matrix tfoot td.prod-col { color: var(--fz-orange-700); }

/* Tabla de rutas */
.tbl-rutas td { vertical-align: middle; transition: background-color .15s; }
.rutas-sub { color: var(--fz-ink-300); font-size: .75rem; margin-top: 2px; }
.rutas-hora { font-size: .85rem; white-space: nowrap; }

/* Fila coloreada según su vuelta */
.tbl-rutas tbody tr.row-trip-1 td { background-color: #FDF2EB; }
.tbl-rutas tbody tr.row-trip-2 td { background-color: #EDF8F2; }
.tbl-rutas tbody tr.row-trip-3 td { background-color: #EDF3FC; }
.tbl-rutas tbody tr.row-trip-4 td { background-color: #F5EFFC; }
.tbl-rutas tbody tr.row-trip-1 td:first-child { box-shadow: inset 4px 0 0 var(--fz-orange-500); }
.tbl-rutas tbody tr.row-trip-2 td:first-child { box-shadow: inset 4px 0 0 #22B07D; }
.tbl-rutas tbody tr.row-trip-3 td:first-child { box-shadow: inset 4px 0 0 #2563EB; }
.tbl-rutas tbody tr.row-trip-4 td:first-child { box-shadow: inset 4px 0 0 #7C3AED; }

/* ---------- Tema SweetAlert2 (naranja/crema) ---------- */
.swal2-popup { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; border-radius: 18px; }
.swal2-title { color: var(--fz-ink-900); }
.fz-swal-confirm, .fz-swal-cancel {
    font: inherit; font-weight: 700; padding: 10px 20px; border-radius: var(--radius-pill);
    border: 1.5px solid transparent; cursor: pointer; margin: 0 6px;
}
.fz-swal-confirm { background: var(--fz-orange-500); color: #fff; }
.fz-swal-confirm:hover { background: var(--fz-orange-700); }
.fz-swal-cancel { background: var(--fz-white); color: var(--fz-ink-700); border-color: var(--fz-card-border); }
.fz-swal-cancel:hover { background: var(--fz-orange-50); }

/* ---------- Responsive: sidebar colapsable ---------- */
@media (max-width: 860px) {
    .shell { grid-template-columns: 1fr; }
    .nav-burger { display: inline-block; }
    .sidebar {
        position: fixed; top: 0; left: 0; bottom: 0; z-index: 40; width: 260px;
        height: 100vh; transform: translateX(-100%); transition: transform .2s ease;
        box-shadow: var(--shadow-md);
    }
    .nav-toggle:checked ~ .shell .sidebar { transform: translateX(0); }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }

/* ------------------------------------------------------------------ */
/* Seguimiento de producción                                           */
/* ------------------------------------------------------------------ */
.seg-bar { height: 8px; border-radius: var(--radius-pill); background: var(--fz-orange-50); overflow: hidden; margin-top: 12px; }
.seg-bar > span { display: block; height: 100%; border-radius: var(--radius-pill); background: linear-gradient(90deg, #34C37D, var(--fz-green-700)); transition: width .35s ease; }
.prod-matrix td.seg-ok { color: var(--fz-green-700); font-weight: 700; }

.seg-list { display: flex; flex-direction: column; gap: 8px; padding: 4px 2px; }
.seg-tanda { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    padding: 10px 12px; border: 1.5px solid var(--fz-orange-100); border-radius: var(--radius-md); background: #fff; transition: border-color .2s, background .2s; }
.seg-tanda-listo { border-color: #BEEBD8; background: var(--fz-chip-hora-bg); }
.seg-tanda-en_proceso { border-color: var(--fz-orange-300); background: var(--fz-orange-50); }
.seg-tanda-info { display: flex; align-items: center; gap: 10px; min-width: 0; }
.seg-dot { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 auto; box-shadow: 0 0 0 3px rgba(0,0,0,.04); }
.seg-tanda-top { font-size: .92rem; color: var(--fz-ink-900); }
.seg-vol { color: var(--fz-ink-500); font-size: .82rem; font-weight: 500; margin-left: 4px; }
.seg-tanda-sub { font-size: .78rem; color: var(--fz-ink-500); margin-top: 2px; }

.seg-ctrl { display: inline-flex; gap: 0; border-radius: var(--radius-pill); border: 1.5px solid var(--fz-orange-100); overflow: hidden; background: #fff; flex: 0 0 auto; }
.seg-ctrl > form { display: inline-flex; }
.seg-btn { appearance: none; border: 0; background: transparent; cursor: pointer; font: inherit; font-size: .78rem; font-weight: 600;
    color: var(--fz-ink-500); padding: 6px 12px; display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
    border-left: 1px solid var(--fz-orange-100); transition: background .15s, color .15s; }
.seg-ctrl > form:first-child .seg-btn, .seg-ctrl > .seg-btn:first-child { border-left: 0; }
.seg-btn:hover { background: var(--fz-orange-50); color: var(--fz-ink-900); }
.seg-btn.is-active { cursor: default; }
.seg-btn.is-active.seg-pend { background: var(--fz-ink-300); color: #fff; }
.seg-btn.is-active.seg-proc { background: var(--fz-orange-600); color: #fff; }
.seg-btn.is-active.seg-listo { background: var(--fz-green-700); color: #fff; }

/* Filas de actividad de la OT (pulpas / limpieza) — como el día completo del Excel */
.seg-activity { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: var(--radius-md);
    background: repeating-linear-gradient(45deg, var(--fz-orange-50), var(--fz-orange-50) 8px, #fff 8px, #fff 16px);
    border: 1px dashed var(--fz-orange-100); color: var(--fz-ink-500); font-size: .8rem; font-weight: 600; }
.seg-activity i { color: var(--fz-orange-600); }
.seg-act-time { font-variant-numeric: tabular-nums; color: var(--fz-ink-300); font-weight: 500; margin-right: 2px; }

/* ---- Generar rutas: orden manual de la ruta (arrastrar o flechas) ---- */
.ruta-orden { white-space: nowrap; }
.ruta-grip { color: var(--fz-ink-soft); cursor: grab; margin-right: 2px; }
.ruta-grip:active { cursor: grabbing; }
.ruta-pos {
    display: inline-block; min-width: 20px; text-align: center;
    font-weight: 800; font-variant-numeric: tabular-nums; color: var(--fz-ink);
}
.ruta-arrows { display: inline-flex; flex-direction: column; gap: 1px; vertical-align: middle; margin-left: 2px; }
.ruta-arrow {
    border: 1px solid var(--fz-orange-100); background: #fff; color: var(--fz-orange-700);
    border-radius: 5px; width: 20px; height: 15px; line-height: 1; padding: 0;
    cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 9px;
}
.ruta-arrow:hover { background: var(--fz-orange-100); }
#rutas-table tbody tr[draggable="true"] { cursor: default; }
.ruta-dragging { opacity: .45; }
.ruta-moved { animation: rutaFlash .5s ease-out; }
@keyframes rutaFlash {
    from { background: var(--fz-orange-100); }
    to   { background: transparent; }
}

/* ---- Filas de tabla clicables (<tr data-row-href>) ---- */
tr[data-row-href] { cursor: pointer; }
tr[data-row-href]:hover { background: var(--fz-orange-50); }
/* Los controles de la fila conservan el cursor normal. */
tr[data-row-href] a,
tr[data-row-href] button,
tr[data-row-href] input,
tr[data-row-href] select { cursor: auto; }
tr[data-row-href] a,
tr[data-row-href] button { cursor: pointer; }
/* Rubro LOCAL: el cliente recoge en el local, no va en ruta. */
.tbl-rutas tbody tr.row-trip-0 td { background-color: #FCF6EA; }
.tbl-rutas tbody tr.row-trip-0 td:first-child { box-shadow: inset 4px 0 0 #C9922B; }

/* ---- Orden de trabajo: matriz Puesto × Horario ---- */
#ot-matriz td.ot-celda { vertical-align: top; padding: 8px; }
.ot-tanda {
    display: flex; flex-direction: column; gap: 1px;
    background: var(--fz-orange-50); border: 1px solid var(--fz-orange-100);
    border-radius: 10px; padding: 7px 9px; margin-bottom: 6px;
}
.ot-tanda:last-child { margin-bottom: 0; }
.ot-tanda strong { font-size: .85rem; color: var(--fz-ink-900); }
.ot-tanda .ot-cant { font-size: .8rem; font-weight: 700; color: var(--fz-orange-700); font-variant-numeric: tabular-nums; }
.ot-tanda .ot-quien { font-size: .75rem; color: var(--fz-ink-soft); }
.ot-tanda .ot-quien em { font-style: italic; opacity: .75; }

/* ---- Encabezados de tabla ordenables (<th data-sort>) ---- */
th[data-sort] { cursor: pointer; user-select: none; white-space: nowrap; }
th[data-sort]:hover { color: var(--fz-orange-700); }
th[data-sort]::after {
    content: '↕'; margin-left: 5px; opacity: .35; font-size: .85em; font-weight: 400;
}
th[data-sort].is-asc::after  { content: '↑'; opacity: 1; color: var(--fz-orange-700); }
th[data-sort].is-desc::after { content: '↓'; opacity: 1; color: var(--fz-orange-700); }
