/* ==========================================================================
   RUTA FÁCIL — Sistema Logístico
   Paleta:  --ink #101828   --paper #EEF1EF   --teal(accent) #0E7C7B
            --amber #F2A93B  --alert #E75A4C   --line rgba(16,24,40,.10)
   Tipografía: Space Grotesk (display) · Inter (texto) · IBM Plex Mono (datos)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root {
    --ink: #101828;
    --ink-soft: #475467;
    --paper: #EEF1EF;
    --surface: #ffffff;
    --line: rgba(16,24,40,0.10);
    --accent: #0E7C7B;
    --accent-amber: #F2A93B;
    --accent-alert: #E75A4C;
    --radius: 10px;
    --shadow-card: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
    --shadow-pop: 0 12px 32px rgba(16,24,40,.18);
    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'Inter', sans-serif;
    --font-mono: 'IBM Plex Mono', monospace;
}

[data-theme="dark"] {
    --ink: #EDF1F5;
    --ink-soft: #A2ADBB;
    --paper: #0B1220;
    --surface: #131B2C;
    --line: rgba(255,255,255,0.10);
    --shadow-card: 0 1px 2px rgba(0,0,0,.4);
    --shadow-pop: 0 20px 40px rgba(0,0,0,.55);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font-body);
    background: var(--paper);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

a { color: inherit; }

button { font-family: inherit; }

::selection { background: var(--accent); color: #fff; }

/* Focus visibility for accessibility */
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, [tabindex]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ---------------------------------------------------------------- */
/* Auth screens (index.html)                                        */
/* ---------------------------------------------------------------- */
.auth-body {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    background: var(--ink);
}
@media (max-width: 860px) { .auth-body { grid-template-columns: 1fr; } }

.auth-showcase {
    position: relative;
    padding: 56px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    color: #fff;
    overflow: hidden;
    background:
        radial-gradient(120% 140% at 0% 0%, rgba(42, 190, 181, 0.42), transparent 62%),
        linear-gradient(160deg, #48677E 0%, #5A7890 60%, #47667D 100%);
}
@media (max-width: 860px) { .auth-showcase { display: none; } }

.route-line {
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(255,255,255,0.14) 1.5px, transparent 1.5px);
    background-size: 22px 22px;
    mask-image: linear-gradient(180deg, transparent, black 30%, black 70%, transparent);
    opacity: .5;
}
.auth-showcase .brand-mark {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 20px;
    letter-spacing: .01em;
    z-index: 1;
}
.auth-showcase .brand-mark img {
    display: block; width: 360px; height: auto;
}
.auth-showcase .brand-mark span { color: var(--accent-amber); }

.showcase-copy { z-index: 1; max-width: 420px; }
.showcase-copy .eyebrow {
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--accent-amber);
    display: block;
    margin-bottom: 14px;
}
.showcase-copy h1 {
    font-family: var(--font-display);
    font-size: 40px;
    line-height: 1.12;
    font-weight: 700;
    margin-bottom: 16px;
}
.showcase-copy p { color: #C9D2DE; font-size: 15px; line-height: 1.6; }

.showcase-stats { display: flex; gap: 28px; z-index: 1; }
.showcase-stats div { font-family: var(--font-mono); }
.showcase-stats strong { display: block; font-size: 26px; color: #fff; }
.showcase-stats span { font-size: 11px; color: #8B97A8; text-transform: uppercase; letter-spacing: .06em; }
.showcase-social { display: flex; gap: 12px; z-index: 1; }
.social-link { display: inline-flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; border: 1px solid rgba(255,255,255,.2); border-radius: 9px; padding: 9px 12px; font-size: 12px; font-weight: 700; transition: background .15s ease, border-color .15s ease; }
.social-link:hover { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.45); }
.social-link svg { width: 18px; height: 18px; fill: currentColor; }
.social-link.whatsapp { color: #71e59a; }
.social-link.facebook { color: #8bb8ff; }

.auth-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    background: var(--paper);
}
.auth-container {
    background: var(--surface);
    padding: 36px;
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--line);
}
.auth-header { margin-bottom: 24px; }
.auth-header h2 { font-family: var(--font-display); font-size: 22px; margin-bottom: 6px; }
.auth-header p { font-size: 13px; color: var(--ink-soft); }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; color: var(--ink-soft); }
.form-group input, .form-group textarea, .form-group select {
    width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
    font-size: 14px; font-family: inherit; background: var(--surface); color: var(--ink);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
    border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); outline: none;
}
.form-hint { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }

.btn-primary {
    width: 100%; background: var(--accent); color: #fff; padding: 11px; border: none;
    border-radius: 8px; font-weight: 600; cursor: pointer; font-size: 14px; margin-top: 6px;
    transition: filter .15s ease, transform .05s ease;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: translateY(1px); }

.btn-secondary {
    background: transparent; color: var(--ink); border: 1px solid var(--line);
    padding: 10px 14px; border-radius: 8px; font-weight: 600; cursor: pointer; font-size: 13.5px;
}
.btn-secondary:hover { background: var(--paper); }
.settings-actions { display: flex; gap: 10px; margin-top: 6px; }
.settings-actions .btn-primary { margin-top: 0; }
.settings-actions .btn-secondary { flex: 0 0 auto; }

.btn-ghost {
    background: none; border: none; color: var(--ink-soft); cursor: pointer; font-size: 13px; font-weight: 600;
}
.btn-ghost:hover { color: var(--accent); }

.auth-switch { text-align: center; font-size: 13px; margin-top: 16px; color: var(--ink-soft); }
.auth-switch a { color: var(--accent); text-decoration: none; font-weight: 600; }

.auth-demo-note {
    margin-top: 18px; padding: 10px 12px; border-radius: 8px; background: color-mix(in srgb, var(--accent) 10%, transparent);
    font-size: 12px; color: var(--ink-soft); font-family: var(--font-mono);
}

/* ---------------------------------------------------------------- */
/* Navbar (dashboard.html)                                          */
/* ---------------------------------------------------------------- */
.navbar {
    background: var(--ink); color: #fff; padding: 14px 28px;
    display: flex; justify-content: flex-start; align-items: center; gap: 24px;
    position: sticky; top: 0; z-index: 40;
}

.route-point-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 18px 0 10px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.route-point-head h3 { margin: 0; font-size: 16px; }
.saved-address-picker { width: min(310px, 55%); display: flex; align-items: center; gap: 7px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink-soft); }
.saved-address-picker:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent); }
.saved-address-picker input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); padding: 8px 0; font-size: 13px; }
.route-point-extra { margin-top: 22px; padding: 0 14px 14px; border: 1px dashed var(--line); border-radius: 10px; }
.save-address-option { display: inline-flex; align-items: center; gap: 7px; margin: 2px 0 12px; color: var(--muted); font-size: 13px; }
.add-point-btn { width: auto; margin: 4px 0 16px; }
@media (max-width: 600px) { .route-point-head { align-items: flex-start; flex-direction: column; } .saved-address-picker { width: 100%; } }
.navbar-brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; font-size: 17px; }
.nav-session-name { margin-left: 28px; color: #CBD5E1; font-family: var(--font-body); font-size: 13px; font-weight: 600; white-space: nowrap; }
@media (max-width: 760px) { .nav-session-name { margin-left: 14px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; } }
.session-company { margin-left: auto; margin-right: 18px; display: flex; align-items: center; gap: 8px; min-width: 0; }
.session-company > img, .session-company > span { width: 30px; height: 30px; flex: 0 0 30px; border-radius: 8px; object-fit: cover; background: rgba(255,255,255,.12); display: inline-flex; align-items: center; justify-content: center; color: var(--accent-amber); font-size: 11px; font-weight: 700; }
.session-company div { display: flex; flex-direction: column; min-width: 0; }
.session-company small { font-size: 9px; letter-spacing: .08em; color: #98A2B3; font-weight: 700; }
.session-company strong { max-width: 155px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: #fff; }
@media (max-width: 960px) { .session-company { display: none; } }
.brand-logo {
    width: 32px; height: 32px; border-radius: 8px; background: var(--accent);
    display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; overflow: hidden;
}
.brand-logo img { width: 100%; height: 100%; object-fit: cover; }

.nav-toggle {
    display: inline-flex; align-items: center; gap: 7px; border: 1px solid rgba(255,255,255,.2);
    background: rgba(255,255,255,.07); color: #fff; border-radius: 7px; padding: 8px 11px;
    font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
}
.nav-toggle:hover, .nav-toggle[aria-expanded="true"] { background: rgba(255,255,255,.14); }
.navbar-menu {
    display: none; position: absolute; top: calc(100% - 2px); left: 28px; min-width: 210px;
    flex-direction: column; align-items: stretch; gap: 2px; padding: 8px;
    background: var(--ink); border: 1px solid rgba(255,255,255,.14); border-radius: 0 0 10px 10px;
    box-shadow: 0 14px 28px rgba(11,18,32,.26);
}
.navbar-menu.is-open { display: flex; }
.nav-link {
    background: none; border: none; color: #98A2B3; padding: 9px 12px;
    cursor: pointer; font-size: 13.5px; font-weight: 600; border-radius: 7px;
    width: 100%; text-align: left;
}
.nav-link.active { color: #fff; background: rgba(255,255,255,0.08); }
.nav-link:hover { color: #fff; }

.icon-btn {
    background: none; border: 1px solid rgba(255,255,255,0.14); color: #cfd6df;
    width: 34px; height: 34px; border-radius: 8px; cursor: pointer; font-size: 15px;
    display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }

.nav-logout { color: var(--accent-alert); font-size: 13px; text-decoration: none; margin: 7px 12px; font-weight: 600; }
@media (max-width: 600px) {
    .navbar { padding: 12px 16px; gap: 12px; }
    .navbar-menu { left: 16px; right: 16px; min-width: 0; }
    .nav-toggle { padding: 8px 9px; }
}

/* ---------------------------------------------------------------- */
/* Layout                                                            */
/* ---------------------------------------------------------------- */
.container { max-width: 1240px; margin: 28px auto; padding: 0 24px 60px; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 22px; flex-wrap: wrap; gap: 12px; }
.page-head h1 { font-family: var(--font-display); font-size: 24px; }
.page-head p { color: var(--ink-soft); font-size: 13.5px; margin-top: 4px; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.bulk-actions { display: flex; gap: 10px; width: 100%; }
.bulk-actions .btn-primary,
.bulk-actions .btn-secondary { width: auto; flex: 1; margin-top: 0; }
.search-box { position: relative; }
.search-box input {
    padding: 9px 12px 9px 32px; border-radius: 8px; border: 1px solid var(--line);
    background: var(--surface); font-size: 13.5px; width: 230px; color: var(--ink);
}
.search-box::before {
    content: "⌕"; position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
    color: var(--ink-soft); font-size: 15px;
}
.toolbar select {
    padding: 9px 10px; border-radius: 8px; border: 1px solid var(--line);
    background: var(--surface); font-size: 13px; color: var(--ink);
}

/* ---------------------------------------------------------------- */
/* Métricas                                                          */
/* ---------------------------------------------------------------- */
.metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 26px; }
.metric-card {
    background: var(--surface); padding: 16px 18px; border-radius: var(--radius);
    border: 1px solid var(--line); box-shadow: var(--shadow-card); position: relative; overflow: hidden;
}
.metric-card::before {
    content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--dot, var(--accent));
}
.metric-card h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); margin-bottom: 6px; font-weight: 700; }
.metric-card p { font-family: var(--font-mono); font-size: 26px; font-weight: 600; color: var(--ink); }

/* ---------------------------------------------------------------- */
/* Tablero Kanban — el elemento distintivo                          */
/* ---------------------------------------------------------------- */
.board-wrap { position: relative; }
.board-road {
    position: absolute; left: 0; right: 0; top: 44px; height: 2px;
    background-image: linear-gradient(90deg, var(--line) 0 8px, transparent 8px 16px);
    background-size: 16px 2px; z-index: 0;
}
.board {
    display: grid; grid-auto-flow: column; grid-auto-columns: minmax(270px, 1fr);
    gap: 16px; overflow-x: auto; padding-bottom: 12px; position: relative; z-index: 1;
}
.board-col {
    background: transparent; display: flex; flex-direction: column; min-width: 270px;
}
.board-col-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.board-dot { width: 22px; height: 22px; border-radius: 50%; background: var(--dot); display: flex; align-items: center; justify-content: center;
    font-family: var(--font-mono); font-size: 10px; color: #fff; font-weight: 700; box-shadow: 0 0 0 4px var(--paper); }
.board-col-head h3 { font-size: 13.5px; font-weight: 700; }
.board-col-head .count { margin-left: auto; font-family: var(--font-mono); font-size: 12px; color: var(--ink-soft); background: var(--surface); border: 1px solid var(--line); padding: 1px 8px; border-radius: 20px; }

.board-drop {
    background: color-mix(in srgb, var(--dot) 6%, var(--paper));
    border: 1.5px dashed color-mix(in srgb, var(--dot) 35%, var(--line));
    border-radius: 12px; padding: 10px; min-height: 120px; flex: 1;
    display: flex; flex-direction: column; gap: 10px; transition: background .15s ease, border-color .15s ease;
}
.board-drop.drag-over { background: color-mix(in srgb, var(--dot) 16%, var(--paper)); border-color: var(--dot); }

/* Tarjeta con forma de etiqueta de envío */
.parcel-card {
    background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
    padding: 14px 14px 12px; box-shadow: var(--shadow-card); cursor: grab; position: relative;
    border-top: 3px solid var(--dot);
}
.parcel-card:active { cursor: grabbing; }
.parcel-card::before {
    content: ""; position: absolute; top: -1px; left: 50%; transform: translateX(-50%);
    width: 12px; height: 12px; background: var(--paper); border: 1px solid var(--line); border-top: none; border-radius: 0 0 8px 8px;
}
.parcel-card .pc-id { font-family: var(--font-mono); font-size: 11px; color: var(--dot); font-weight: 600; letter-spacing: .02em; }
.parcel-card .pc-name { font-weight: 700; font-size: 14.5px; margin: 4px 0 2px; }
.parcel-card .pc-address { font-size: 12.5px; color: var(--ink-soft); line-height: 1.4; margin-bottom: 8px; }
.parcel-card .pc-meta { display: flex; justify-content: space-between; align-items: center; font-size: 11.5px; color: var(--ink-soft); }
.parcel-card .pc-phone { font-family: var(--font-mono); }
.parcel-card.dragging { opacity: .4; }
.parcel-card .pc-actions { display: flex; gap: 6px; margin-top: 10px; }
.parcel-card .pc-actions button {
    flex: 1; font-size: 11.5px; padding: 6px; border-radius: 6px; border: 1px solid var(--line);
    background: var(--paper); cursor: pointer; font-weight: 600; color: var(--ink-soft);
}
.parcel-card .pc-actions button:hover { color: var(--ink); border-color: var(--dot); }

.board-empty { font-size: 12px; color: var(--ink-soft); text-align: center; padding: 18px 6px; font-family: var(--font-mono); }

/* ---------------------------------------------------------------- */
/* Formularios de contenido                                          */
/* ---------------------------------------------------------------- */
.form-box { background: var(--surface); padding: 28px; border-radius: var(--radius); box-shadow: var(--shadow-card); border: 1px solid var(--line); max-width: 760px; }
.form-box h2 { font-family: var(--font-display); font-size: 19px; margin-bottom: 20px; }
.shipment-entry-layout { display: grid; grid-template-columns: minmax(0, 760px) minmax(260px, 340px); gap: 22px; align-items: start; }
.shipment-form-box { max-width: none; }
.saved-addresses-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-card); padding: 20px; position: sticky; top: 84px; }
.saved-addresses-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; padding-bottom: 13px; border-bottom: 1px solid var(--line); }
.saved-addresses-head h3 { font-size: 16px; margin: 0 0 4px; }
.saved-addresses-head p { margin: 0; color: var(--ink-soft); font-size: 12.5px; line-height: 1.35; }
.saved-address-target-label { display: block; margin-top: 10px; color: var(--ink-soft); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.saved-addresses-head select { width: 100%; margin-top: 4px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--paper); color: var(--ink); font-size: 12px; }
.address-count { min-width: 27px; height: 27px; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 13%, transparent); color: var(--accent); border-radius: 999px; font-weight: 700; font-size: 12px; }
.saved-address-list { display: grid; gap: 9px; margin-top: 14px; max-height: 540px; overflow: auto; padding-right: 2px; }
.saved-address-item { width: 100%; text-align: left; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); padding: 12px; display: grid; gap: 4px; color: var(--ink); }
.saved-address-item:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, var(--paper)); }
.saved-address-item strong { font-size: 13px; }
.saved-address-item span, .saved-address-item small { color: var(--ink-soft); font-size: 12px; line-height: 1.35; }
.saved-address-actions { display: flex; gap: 8px; margin-top: 7px; flex-wrap: wrap; }
.saved-address-actions button { border: 0; background: transparent; padding: 0; color: var(--accent); font-size: 11px; font-weight: 700; cursor: pointer; }
.saved-address-actions .delete-saved-address { color: var(--accent-alert); }
.saved-address-empty { color: var(--ink-soft); font-size: 13px; line-height: 1.5; padding: 8px 0; }
@media (max-width: 1050px) { .shipment-entry-layout { grid-template-columns: 1fr; } .saved-addresses-panel { position: static; max-width: 760px; } .saved-address-list { max-height: 280px; } }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
@media (max-width: 600px) { .form-grid-2 { grid-template-columns: 1fr; } }
.form-help { display: block; margin-top: 6px; color: var(--ink-soft); font-size: 12px; line-height: 1.35; }

.csv-hint {
    font-size: 13px; color: var(--ink-soft); margin-bottom: 15px; background: var(--paper);
    border: 1px solid var(--line); padding: 10px 12px; border-radius: 8px; font-family: var(--font-mono); line-height: 1.6;
}
.csv-hint b { color: var(--ink); }

.template-banner {
    display: flex; justify-content: space-between; align-items: center; gap: 16px;
    background: color-mix(in srgb, var(--accent) 8%, var(--surface));
    border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line));
    border-radius: 10px; padding: 14px 16px; margin-bottom: 18px; flex-wrap: wrap;
}
.template-banner strong { font-size: 13.5px; }
.template-banner p { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }
.template-banner .btn-secondary { white-space: nowrap; }

/* ---------------------------------------------------------------- */
/* Ajustes / personalización                                         */
/* ---------------------------------------------------------------- */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 860px) { .settings-grid { grid-template-columns: 1fr; } }
.settings-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-card); }
.settings-card h3 { font-family: var(--font-display); font-size: 15.5px; margin-bottom: 4px; }
.settings-card .sub { font-size: 12.5px; color: var(--ink-soft); margin-bottom: 16px; }

.swatch-row { display: flex; gap: 10px; align-items: center; }
.swatch-row input[type="color"] { width: 42px; height: 34px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; cursor: pointer; }

.status-row, .field-row {
    display: flex; align-items: center; gap: 8px; padding: 9px 10px; border: 1px solid var(--line);
    border-radius: 8px; margin-bottom: 8px; background: var(--paper);
}
.status-row input[type="color"] { width: 28px; height: 28px; border: none; padding: 0; border-radius: 6px; cursor: pointer; }
.status-row input[type="text"], .field-row input[type="text"] {
    flex: 1; border: none; background: none; font-size: 13.5px; font-weight: 600; color: var(--ink); padding: 4px;
}
.status-row input[type="text"]:focus, .field-row input[type="text"]:focus { outline: none; }
.row-remove { background: none; border: none; color: var(--ink-soft); cursor: pointer; font-size: 15px; padding: 4px 6px; border-radius: 6px; }
.row-remove:hover { color: var(--accent-alert); background: color-mix(in srgb, var(--accent-alert) 10%, transparent); }

.add-row-form { display: flex; gap: 8px; margin-top: 10px; }
.add-row-form input, .add-row-form select { flex: 1; padding: 8px 10px; border-radius: 7px; border: 1px solid var(--line); font-size: 13px; background: var(--surface); color: var(--ink); }
.add-row-form button { padding: 8px 14px; border-radius: 7px; border: none; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; font-size: 13px; }

.logo-upload { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.logo-preview { width: 52px; height: 52px; border-radius: 10px; background: var(--paper); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; overflow: hidden; font-family: var(--font-display); font-weight: 700; }
.logo-preview img { width: 100%; height: 100%; object-fit: cover; }

.danger-zone { border: 1px dashed color-mix(in srgb, var(--accent-alert) 45%, var(--line)); }
.danger-zone h3 { color: var(--accent-alert); }

/* ---------------------------------------------------------------- */
/* Modal / edición de envío                                          */
/* ---------------------------------------------------------------- */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(8,12,20,0.55); display: flex; align-items: center; justify-content: center;
    z-index: 100; padding: 20px; backdrop-filter: blur(2px);
}
.modal {
    background: var(--surface); border-radius: 14px; padding: 26px; width: 100%; max-width: 480px;
    box-shadow: var(--shadow-pop); max-height: 88vh; overflow-y: auto; border: 1px solid var(--line);
}
.modal h3 { font-family: var(--font-display); font-size: 17px; margin-bottom: 16px; display: flex; justify-content: space-between; align-items: center; }
.modal .close-x { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--ink-soft); }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn-primary, .modal-actions .btn-secondary { margin-top: 0; flex: 1; }
.shipment-id-link { border: 0; background: transparent; color: var(--accent); font: inherit; font-weight: 700; cursor: pointer; padding: 0; text-decoration: none; }
.shipment-id-link:hover { text-decoration: underline; }
.driver-row-inactive td { background: #3F4854 !important; color: #E5E7EB !important; border-color: #566170 !important; }
.driver-row-inactive .mono,
.driver-row-inactive .muted { color: #D1D5DB !important; }
.driver-row-inactive button { background: #566170; color: #F8FAFC; border-color: #718096; }
.driver-row-inactive button:hover { background: #64748B; }
.shipment-details-modal { max-width: 820px; }
.shipment-details-modal input[readonly] { background: var(--paper); color: var(--ink); cursor: default; }
.shipment-detail-point { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.shipment-detail-point h4 { margin: 0 0 12px; font-size: 15px; }
.detail-readonly-note { margin: -8px 0 16px; }

/* ---------------------------------------------------------------- */
/* Toasts                                                            */
/* ---------------------------------------------------------------- */
#toast-stack { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast {
    background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 9px; font-size: 13.5px;
    box-shadow: var(--shadow-pop); display: flex; align-items: center; gap: 10px; min-width: 220px;
    animation: toast-in .18s ease-out;
}
.toast::before { content: "●"; color: var(--accent-amber); }
.toast.error::before { content: "●"; color: var(--accent-alert); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ---------------------------------------------------------------- */
/* Tablas de gestión (Clientes / Envíos)                             */
/* ---------------------------------------------------------------- */
.sub-tab { background: var(--surface); border: 1px solid var(--line); }
.sub-tab.active { background: var(--ink); color: #fff; }

.table-container { background: var(--surface); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow-card); border: 1px solid var(--line); }
.shipments-wide-table {
    /* La lista de envíos concentra más columnas que las demás tablas. */
    width: calc(100vw - 48px);
    margin-left: calc((100% - (100vw - 48px)) / 2);
}
.shipments-wide-table table { min-width: 1320px; }
@media (max-width: 760px) {
    .shipments-wide-table { width: 100%; margin-left: 0; }
    .shipments-wide-table table { min-width: 1180px; }
}
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 13.5px; }
th { background: var(--paper); padding: 11px 16px; font-weight: 700; color: var(--ink-soft); border-bottom: 1px solid var(--line); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.sortable-th { cursor: pointer; user-select: none; }
.sortable-th:hover, .sortable-th.is-sorted { color: var(--accent); }
.sort-icon { display: inline-block; margin-left: 4px; font-size: 10px; opacity: .65; }
.sortable-th.is-sorted .sort-icon { opacity: 1; }
td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
td.mono { font-family: var(--font-mono); font-size: 12.5px; color: var(--accent); font-weight: 600; }
td.muted { color: var(--ink-soft); }
.table-actions { display: flex; gap: 6px; }
.table-actions button {
    font-size: 11.5px; padding: 6px 10px; border-radius: 6px; border: 1px solid var(--line);
    background: var(--paper); cursor: pointer; font-weight: 600; color: var(--ink-soft); white-space: nowrap;
}
.table-actions button:hover { color: var(--ink); border-color: var(--accent); }
.status-pill { padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; gap: 6px; }
.status-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--dot); }
.table-empty-row td { text-align: center; padding: 40px; color: var(--ink-soft); font-family: var(--font-mono); font-size: 12.5px; }

/* ---------------------------------------------------------------- */
/* Estado vacío                                                      */
/* ---------------------------------------------------------------- */
.empty-state { text-align: center; padding: 50px 20px; color: var(--ink-soft); }
.empty-state h3 { font-family: var(--font-display); color: var(--ink); margin-bottom: 6px; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}

/* ---------------------------------------------------------------- */
/* Navegación lateral de la plataforma                               */
/* ---------------------------------------------------------------- */
.app-shell { min-height: 100vh; display: flex; background: #f7f9fb; }
.app-sidebar {
    width: 272px; flex: 0 0 272px; height: 100vh; position: sticky; top: 0; display: flex; flex-direction: column;
    background: linear-gradient(180deg, var(--sidebar-bg, #202938) 0%, #121a27 100%);
    color: #fff; z-index: 50; padding: 0 14px 14px; box-shadow: 10px 0 32px rgba(15, 23, 42, .16); overflow: hidden;
}
.sidebar-brand {
    min-height: 104px; margin: 0 -14px; padding: 0 22px; display: flex; align-items: center; gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,.09); background: rgba(255,255,255,.035);
}
.sidebar-brand-copy { position: relative; padding-left: 16px; }
.sidebar-brand-copy::before { content: ''; position: absolute; left: 0; top: 1px; bottom: 1px; width: 4px; border-radius: 4px; background: var(--accent, #0E7C7B); box-shadow: 0 0 14px color-mix(in srgb, var(--accent, #0E7C7B) 80%, transparent); }
.sidebar-brand strong { display: block; font-size: 20px; line-height: 1; letter-spacing: .045em; }
.sidebar-brand small { display: block; color: #a9b7c8; font-size: 9px; font-weight: 800; letter-spacing: .18em; margin-top: 7px; }
.sidebar-collapse-toggle { margin-left: auto; width: 34px; height: 34px; border: 1px solid rgba(255,255,255,.14); border-radius: 50%; background: transparent; color: #dbeafe; font-size: 23px; line-height: 20px; cursor: pointer; transition: .2s ease; }
.sidebar-collapse-toggle:hover { border-color: var(--accent, #0E7C7B); background: var(--accent, #0E7C7B); color: #fff; transform: rotate(-8deg); }
.sidebar-section-label { display: block; padding: 34px 13px 13px; color: #8492a5; font-size: 10px; font-weight: 800; letter-spacing: .16em; }
.sidebar-menu { display: flex; flex-direction: column; gap: 5px; padding: 0 4px; }
.sidebar-menu .nav-link { width: 100%; min-height: 45px; display: flex; align-items: center; gap: 12px; position: relative; border: 0; border-radius: 9px; padding: 10px 13px; background: transparent; color: #d6deea; font-size: 14px; font-weight: 700; text-align: left; cursor: pointer; transition: background .18s ease, color .18s ease, transform .18s ease; }
.sidebar-menu .nav-link:hover { background: rgba(255,255,255,.065); color: #fff; transform: translateX(3px); }
.sidebar-menu .nav-link.active { background: #fff; color: #152033; box-shadow: 0 8px 20px rgba(0,0,0,.18); }
.nav-icon { width: 19px; text-align: center; color: currentColor; font-size: 15px; font-weight: 500; opacity: .9; }
.sidebar-footer { margin-top: auto; padding: 20px 4px 4px; border-top: 1px solid rgba(255,255,255,.11); }
.sidebar-session { display: flex; align-items: center; padding: 12px 13px; border-radius: 8px; border-left: 3px solid var(--accent, #0E7C7B); background: rgba(255,255,255,.065); font-weight: 700; font-size: 13px; }
.sidebar-footer .nav-session-name { margin: 0; color: #fff; }
.sidebar-footer .nav-logout { display: block; margin: 8px 10px 0; color: #f1a5a5; font-size: 12px; font-weight: 800; padding: 8px 4px; }
.app-workspace { flex: 1; min-width: 0; background: #f7f9fb; }
.app-topbar { height: 64px; padding: 0 28px; display: flex; align-items: center; background: #fff; border-bottom: 1px solid #d8dde5; }
.app-topbar .nav-toggle { display: none; }
.mobile-nav-toggle { display: none; }
.breadcrumbs { display: flex; align-items: center; gap: 12px; color: #687284; font-size: 14px; }
.breadcrumbs strong { color: #1e293b; }
.app-workspace .container { max-width: none; padding: 30px 32px 60px; margin: 0; }
.app-workspace .shipments-wide-table { width: 100%; margin-left: 0; }
.sidebar-collapsed .app-sidebar { width: 76px; flex-basis: 76px; padding: 0 10px 14px; }
.sidebar-collapsed .sidebar-brand { padding: 0; justify-content: center; }
.sidebar-collapsed .sidebar-brand-copy, .sidebar-collapsed .sidebar-section-label, .sidebar-collapsed .nav-label, .sidebar-collapsed .sidebar-session .nav-session-name, .sidebar-collapsed .nav-logout { display: none; }
.sidebar-collapsed .sidebar-collapse-toggle { position: absolute; right: -14px; top: 38px; background: var(--sidebar-bg, #343b49); z-index: 2; }
.sidebar-collapsed .sidebar-menu { padding: 0 1px; }
.sidebar-collapsed .sidebar-menu .nav-link { justify-content: center; padding: 11px 8px; }
.sidebar-collapsed .nav-icon { width: auto; }
.sidebar-collapsed .sidebar-footer { padding: 16px 20px; }
.sidebar-collapsed .sidebar-session { justify-content: center; }

@media (max-width: 960px) {
    .app-sidebar { position: fixed; left: 0; transform: translateX(-100%); transition: transform .2s ease; box-shadow: 8px 0 24px rgba(15,23,42,.25); }
    .app-sidebar.is-open { transform: translateX(0); }
    .mobile-nav-toggle { display: inline-flex; position: fixed; top: 14px; left: 14px; z-index: 40; align-items: center; gap: 8px; border: 1px solid var(--line); padding: 8px 11px; border-radius: 6px; background: #fff; color: var(--ink); cursor: pointer; font-weight: 700; box-shadow: var(--shadow-card); }
    .app-workspace .container { padding: 68px 20px 48px; }
    .sidebar-collapsed .app-sidebar { width: 255px; flex-basis: 255px; }
    .sidebar-collapsed .sidebar-brand { padding: 0 20px; justify-content: flex-start; }
    .sidebar-collapsed .sidebar-brand-copy, .sidebar-collapsed .sidebar-section-label, .sidebar-collapsed .nav-label, .sidebar-collapsed .sidebar-session .nav-session-name, .sidebar-collapsed .nav-logout { display: initial; }
    .sidebar-collapsed .sidebar-menu { padding: 0 12px; }
    .sidebar-collapsed .sidebar-menu .nav-link { justify-content: flex-start; padding: 12px 16px; }
    .sidebar-collapsed .sidebar-footer { padding: 16px; }
    .sidebar-collapsed .sidebar-session { justify-content: flex-start; }
    .sidebar-collapse-toggle { display: none; }
}
