/* ============================================================
   Boreal Delivery — Tema (identidad + refinamiento de UI)
   Se carga DESPUÉS de app.css.
   Fuente: Roboto. Paleta: noche polar + aurora boreal.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700;900&display=swap');

:root {
    --font: 'Roboto', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

    /* Aurora / primarios */
    --brand: #0e8f84;
    --brand-dark: #0a6d65;
    --brand-soft: #e2f4f1;
    --aurora-1: #22d3ee;
    --aurora-2: #2dd4bf;
    --aurora-3: #a78bfa;

    /* Noche polar */
    --night-950: #070f1d;
    --night-900: #0a1526;
    --night-800: #101e33;
    --night-700: #16263f;

    /* Superficies */
    --bg: #eef2f7;
    --bg-grad: radial-gradient(1200px 500px at 85% -10%, #e6f4f7 0%, #eef2f7 55%);
    --card: #ffffff;
    --line: #e3e9f1;
    --line-strong: #d3dce8;

    /* Tinta */
    --ink: #0d1b2e;
    --ink-2: #31435c;
    --muted: #5d6f85;

    /* Semántica */
    --ok: #0f9d5a;
    --ok-soft: #e6f6ee;
    --warn: #d9900a;
    --warn-soft: #fdf3e0;
    --danger: #e5484d;
    --danger-soft: #fdecec;
    --info: #2f6fed;
    --info-soft: #e9f0fe;

    --radius: 14px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 2px rgba(10, 21, 38, .05);
    --shadow: 0 1px 2px rgba(10, 21, 38, .04), 0 8px 24px -12px rgba(10, 21, 38, .14);
    --shadow-lg: 0 20px 45px -20px rgba(10, 21, 38, .28);
}

html { scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--bg-grad);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { color: var(--ink); letter-spacing: -0.01em; }
a { color: var(--brand); }

/* ---------- Marca / wordmark ---------- */
.brand { gap: 10px; }
.brand-mark {
    flex: 0 0 auto;
    filter: drop-shadow(0 4px 10px rgba(20, 184, 166, .25));
}
.brand .wordmark { display: flex; flex-direction: column; line-height: 1.05; }
.brand .wordmark .w1 { font-weight: 700; font-size: 16px; color: #fff; letter-spacing: .01em; }
.brand .wordmark .w2 { font-size: 10px; letter-spacing: .24em; text-transform: uppercase; color: #6ee7d8; font-weight: 500; }

/* ---------- Sidebar ---------- */
.sidebar {
    width: 244px;
    background:
        radial-gradient(420px 260px at -20% -10%, rgba(45, 212, 191, .16), transparent 60%),
        radial-gradient(360px 280px at 130% 110%, rgba(167, 139, 250, .12), transparent 60%),
        linear-gradient(180deg, var(--night-900), var(--night-950));
    border-right: 1px solid rgba(255, 255, 255, .05);
}
.sidebar .brand { padding: 22px 18px 18px; border-bottom: 1px solid rgba(255, 255, 255, .06); }
.sidebar nav { padding: 14px 10px; }
.sidebar nav a {
    gap: 11px; padding: 9px 12px; margin: 2px 0;
    border-radius: 10px; color: #8ba0b8; font-weight: 500; font-size: 13.5px;
    transition: color .15s ease, background .15s ease, transform .1s ease;
}
.sidebar nav a svg { color: #6c829c; transition: color .15s ease; }
.sidebar nav a:hover { background: rgba(255, 255, 255, .06); color: #e6f0fa; text-decoration: none; }
.sidebar nav a:hover svg { color: #8ee9dc; }
.sidebar nav a.active {
    background: linear-gradient(90deg, rgba(14, 143, 132, .32), rgba(14, 143, 132, .12));
    color: #fff;
    box-shadow: inset 0 0 0 1px rgba(94, 234, 212, .18);
}
.sidebar nav a.active svg { color: var(--aurora-2); }
.sidebar nav a.active::before {
    content: ''; position: absolute; left: 0; top: 20%; bottom: 20%;
    width: 3px; border-radius: 0 3px 3px 0;
    background: linear-gradient(180deg, var(--aurora-1), var(--aurora-2));
}
.sidebar nav a { position: relative; }
.sidebar .foot { padding: 16px 18px; font-size: 11px; color: #4b5e78; border-top: 1px solid rgba(255,255,255,.05); display:flex; align-items:center; justify-content:space-between; }
.sidebar .foot .pill { display:inline-flex; align-items:center; gap:6px; color:#7ce9d8; background:rgba(45,212,191,.12); border:1px solid rgba(45,212,191,.22); padding:2px 8px; border-radius:999px; font-size:10px; font-weight:600; letter-spacing:.05em; }

/* ---------- Topbar ---------- */
.topbar {
    background: rgba(255, 255, 255, .82);
    backdrop-filter: saturate(140%) blur(10px);
    border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 16px; font-weight: 700; }
.topbar .user { color: var(--ink-2); font-weight: 500; }
.topbar .user-avatar {
    width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
    background: linear-gradient(135deg, var(--aurora-2), var(--aurora-1));
    color: #07312c; font-weight: 700; font-size: 12px;
}

/* ---------- Contenido ---------- */
.content { padding: 26px 28px; max-width: 1280px; }
.card { border-radius: var(--radius); box-shadow: var(--shadow); border-color: var(--line); }
.card .card-h {
    padding: 14px 18px; font-weight: 600; border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, #fcfdfe, #f8fafc);
    border-radius: var(--radius) var(--radius) 0 0;
}
.card .card-b { padding: 18px; }

/* ---------- Estadísticas ---------- */
.stat {
    border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line);
    position: relative; overflow: hidden;
}
.stat::after {
    content: ''; position: absolute; inset: auto -20% -45% auto; width: 150px; height: 150px;
    border-radius: 50%; background: radial-gradient(circle, rgba(34, 211, 238, .10), transparent 70%);
    pointer-events: none;
}
.stat .label { font-weight: 500; letter-spacing: .06em; }
.stat .value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.stat .ico {
    position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; border-radius: 10px;
    display: grid; place-items: center; color: #fff;
}
.stat.info .ico { background: linear-gradient(135deg, #38bdf8, #2f6fed); }
.stat.ok .ico { background: linear-gradient(135deg, #2dd4bf, #0f9d5a); }
.stat.warn .ico { background: linear-gradient(135deg, #fbbf24, #f97316); }

/* ---------- Botones ---------- */
.btn { border-radius: 10px; font-weight: 600; transition: all .14s ease; }
.btn svg { width: 15px; height: 15px; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--aurora-1); outline-offset: 2px; }
.btn.primary {
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    box-shadow: 0 6px 14px -8px rgba(14, 143, 132, .55);
}
.btn.primary:hover { filter: brightness(1.05); box-shadow: 0 8px 18px -8px rgba(14,143,132,.6); }
.btn.success { background: linear-gradient(135deg, #12b76a, #0f9d5a); }
.btn.info { background: linear-gradient(135deg, #3b82f6, #2f6fed); }
.btn.danger { background: linear-gradient(135deg, #f05a5f, #e5484d); }
.btn.ghost { background: #fff; border-color: var(--line-strong); color: var(--ink-2); }
.btn.ghost:hover { border-color: var(--brand); color: var(--brand); background: #fbfefe; }

/* ---------- Formularios ---------- */
.input, .select, .textarea {
    border-radius: 10px; border-color: var(--line-strong); background: #fff;
    transition: border-color .12s ease, box-shadow .12s ease;
}
.input:focus, .select:focus, .textarea:focus {
    outline: none; border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(14, 143, 132, .14);
}
.form-group label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.merge-tags span { background: var(--brand-soft); border-color: #bfe9e0; color: var(--brand-dark); }

/* ---------- Tablas ---------- */
.table th {
    background: #f6f8fb; color: var(--muted); font-weight: 600; letter-spacing: .06em;
    border-bottom: 1px solid var(--line);
}
.table tr:hover td { background: #f8fbfc; }

/* ---------- Badges ---------- */
.badge { font-weight: 600; }
.badge.green { background: var(--ok-soft); color: #0c7a47; }
.badge.amber { background: var(--warn-soft); color: #9a6506; }
.badge.red { background: var(--danger-soft); color: #c12f34; }
.badge.blue { background: var(--info-soft); color: #2457c4; }
.badge.purple { background: #f1ecfe; color: #6d3fd4; }

/* ---------- Alertas ---------- */
.alert { border-radius: var(--radius-sm); }
.alert.success { background: var(--ok-soft); color: #0c6b3f; border-color: #c3ecd5; }
.alert.error { background: var(--danger-soft); color: #a82327; border-color: #f6c9ca; }
.alert.info { background: var(--info-soft); color: #1d4fc0; border-color: #c9dbfa; }

/* ---------- Cabeceras de página ---------- */
.content > .flex-between h2, h2.page { font-size: 20px; font-weight: 700; }

/* ---------- Utilidades para iconos ---------- */
.icon-label { display: inline-flex; align-items: center; gap: 7px; }
.empty svg { opacity: .5; margin-bottom: 8px; }
.stat + .stat, .grid .card { margin-bottom: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    /* Panel lateral como cajón deslizante (#nav-toggle lo abre; app.js añade .open) */
    .nav-toggle { display: inline-flex; }
    .sidebar {
        width: min(288px, 84vw);
        position: fixed; top: var(--topbar-h); left: 0; bottom: 0;
        height: calc(100dvh - var(--topbar-h));
        z-index: 6;
        transform: translateX(-102%);
        transition: transform .24s cubic-bezier(.2, .8, .25, 1);
        box-shadow: 0 24px 60px -20px rgba(7, 15, 29, .6);
        will-change: transform;
    }
    .sidebar.open { transform: translateX(0); }

    /* Barra superior compacta */
    .topbar { padding: 0 12px; }
    .topbar h1 { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .topbar-right { gap: 6px; }
    .topbar .user { gap: 8px; }
    .user-name, .btn-label { display: none; }

    /* Contenido y tarjetas */
    .content { padding: 16px 12px 40px; max-width: 100%; }
    .card .card-b { padding: 14px; }
    .card .card-h { padding: 12px 14px; }
    .stat { padding: 14px; }
    .stat .value { font-size: 24px; }
    .guest-wrap, .public-body { padding: 16px; }
    .guest-card { padding: 26px 20px; }
    .public-card { padding: 20px 16px; }

    /* Objetivos táctiles cómodos */
    .btn { min-height: 42px; padding: 10px 14px; }
    .btn.sm { min-height: 38px; padding: 8px 12px; }
    .card > .actions .btn,
    .card-b > .actions .btn,
    form > .actions .btn { flex: 1 1 auto; justify-content: center; }

    /* Formularios: 16px evita el zoom automático de iOS al enfocar */
    .input, .select, .textarea { font-size: 16px; }
    .textarea { min-height: 160px; }
    .textarea.lg { min-height: 300px; }
}

/* ---------- Login / guest ---------- */
.guest-wrap {
    background:
        radial-gradient(700px 420px at 15% 0%, rgba(34, 211, 238, .18), transparent 60%),
        radial-gradient(700px 500px at 110% 100%, rgba(167, 139, 250, .16), transparent 60%),
        linear-gradient(160deg, #07111f 0%, #0a1526 45%, #0e3a3a 100%);
}
.guest-card { border-radius: 18px; box-shadow: var(--shadow-lg); border: 1px solid var(--line); padding: 34px 32px 30px; }
.guest-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 6px; }
.guest-brand .wordmark { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.guest-brand .wordmark .w1 { font-size: 24px; font-weight: 900; color: var(--night-800); letter-spacing: -.01em; }
.guest-brand .wordmark .w2 { font-size: 11px; letter-spacing: .34em; text-transform: uppercase; color: var(--brand); font-weight: 700; }
.guest-card .tagline { text-align: center; color: var(--muted); font-size: 13px; margin: 0 0 22px; }

/* ---------- Páginas públicas ---------- */
.public-body { background: radial-gradient(800px 420px at 50% -10%, #e6f5f7 0%, #eef2f7 60%); }
.public-brand { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); opacity: .9; z-index: 5; }
.public-card { border-radius: 16px; box-shadow: var(--shadow-lg); margin-top: 46px; }
.public-card h1 { font-weight: 700; }

/* ---------- Detalles ---------- */
input[type="checkbox"], input[type="radio"] { accent-color: var(--brand); }
code, kbd { background: #f1f5fa; border: 1px solid var(--line); padding: 1px 5px; border-radius: 6px; font-size: 12px; color: var(--ink-2); }
.textarea { font-size: 13px; }
.btn[disabled], .btn.disabled { opacity: .55; pointer-events: none; }
.muted { color: var(--muted); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }

/* ---------- Topbar derecha y conmutador de tema ---------- */
.topbar-right { display: flex; align-items: center; gap: 12px; }
.theme-toggle { width: 32px; height: 32px; padding: 0; display: grid; place-items: center; }
.theme-toggle .i-dark { display: none; }
html[data-theme="dark"] .theme-toggle .i-light { display: none; }
html[data-theme="dark"] .theme-toggle .i-dark { display: inline; }

/* ============================================================
   MODO OSCURO — Boreal "noche polar"
   ============================================================ */
html[data-theme="dark"] {
    --bg: #0a1424;
    --bg-grad: radial-gradient(1100px 460px at 85% -10%, #0f2940 0%, #0a1424 60%);
    --card: #0f1b2e;
    --line: #1d2b41;
    --line-strong: #2a3c58;
    --ink: #e6edf7;
    --ink-2: #b7c5d8;
    --muted: #8aa0ba;
    --brand-soft: rgba(45, 212, 191, .10);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 26px -14px rgba(0, 0, 0, .65);
    color-scheme: dark;
}
html[data-theme="dark"] .topbar { background: rgba(15, 27, 46, .85); border-color: var(--line); }
html[data-theme="dark"] .topbar h1 { color: var(--ink); }
html[data-theme="dark"] .card, html[data-theme="dark"] .stat { background: var(--card); border-color: var(--line); box-shadow: var(--shadow); }
html[data-theme="dark"] .card .card-h { background: linear-gradient(180deg, #12213a, #0f1b2e); border-color: var(--line); color: var(--ink); }
html[data-theme="dark"] .table th { background: #101d30; color: var(--muted); border-color: var(--line); }
html[data-theme="dark"] .table td { border-color: var(--line); color: var(--ink); }
html[data-theme="dark"] .table tr:hover td { background: #12233a; }
html[data-theme="dark"] .input, html[data-theme="dark"] .select, html[data-theme="dark"] .textarea {
    background: #0c1626; border-color: var(--line-strong); color: var(--ink);
}
html[data-theme="dark"] .form-group label { color: var(--ink-2); }
html[data-theme="dark"] .btn.ghost { background: rgba(255, 255, 255, .05); border-color: var(--line-strong); color: var(--ink-2); }
html[data-theme="dark"] .btn.ghost:hover { color: #fff; border-color: var(--aurora-2); }
html[data-theme="dark"] .muted, html[data-theme="dark"] .small.muted { color: var(--muted); }
html[data-theme="dark"] .alert.success { background: rgba(15, 157, 90, .16); color: #7be0af; border-color: rgba(15, 157, 90, .35); }
html[data-theme="dark"] .alert.error { background: rgba(229, 72, 77, .16); color: #ffb3b5; border-color: rgba(229, 72, 77, .4); }
html[data-theme="dark"] .alert.info { background: rgba(47, 111, 237, .18); color: #abc6ff; border-color: rgba(47, 111, 237, .45); }
html[data-theme="dark"] .badge.gray { background: #1c2a40; color: #9fb2c9; }
html[data-theme="dark"] .badge.green { background: rgba(15, 157, 90, .18); color: #6fe0a6; }
html[data-theme="dark"] .badge.amber { background: rgba(217, 144, 10, .18); color: #f4c36a; }
html[data-theme="dark"] .badge.red { background: rgba(229, 72, 77, .18); color: #ff9b9e; }
html[data-theme="dark"] .badge.blue { background: rgba(47, 111, 237, .18); color: #9fc0ff; }
html[data-theme="dark"] .badge.purple { background: rgba(167, 139, 250, .18); color: #c4b5fd; }
html[data-theme="dark"] .stat .label { color: var(--muted); }
html[data-theme="dark"] .pagination a, html[data-theme="dark"] .pagination span.page { background: var(--card); border-color: var(--line); color: var(--ink); }
html[data-theme="dark"] .empty { color: var(--muted); }
html[data-theme="dark"] code, html[data-theme="dark"] kbd { background: #14223a; border-color: var(--line-strong); color: #d5e0ef; }
html[data-theme="dark"] .merge-tags span { background: rgba(45, 212, 191, .10); border-color: rgba(45, 212, 191, .3); color: #7de9dd; }
html[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #2a3c58; }
html[data-theme="dark"] .user-avatar { box-shadow: 0 0 0 1px rgba(255,255,255,.08); }

/* ---------- Marca en páginas públicas ---------- */
.public-brand {
    position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 5;
    display: inline-flex; align-items: center; gap: 8px;
    padding: 5px 14px 5px 6px; border-radius: 999px;
    background: rgba(255, 255, 255, .85); border: 1px solid var(--line);
    box-shadow: var(--shadow-sm); backdrop-filter: blur(6px);
    font-weight: 700; color: var(--ink); font-size: 13px;
}
.public-brand .pb-word { letter-spacing: .02em; }
.public-brand .pb-word small { color: var(--brand); font-weight: 700; letter-spacing: .18em; margin-left: 4px; text-transform: uppercase; }

/* ---------- Tarjeta de suscripción pública ---------- */
.sub-card { padding-top: 44px; }
.sub-head { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 4px; }
.sub-head .wordmark { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.sub-head .wordmark .w1 { font-size: 22px; font-weight: 900; color: var(--ink); }
.sub-head .wordmark .w2 { font-size: 10px; letter-spacing: .34em; text-transform: uppercase; color: var(--brand); font-weight: 700; }
.sub-field { position: relative; }
.sub-field .field-ico {
    position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
    color: var(--muted); display: grid; place-items: center; pointer-events: none;
}
.sub-field .input { padding-left: 36px; }
.sub-note { display: flex; align-items: center; gap: 6px; justify-content: center; font-size: 12px; color: var(--muted); margin-top: 14px; }
.sub-foot { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--line-strong); font-size: 11px; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 5px; }

/* ---------- Ayuda / documentación ---------- */
.help-list { display: grid; gap: 8px; }
.help-item {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px;
    border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fcfdff;
}
html[data-theme="dark"] .help-item { background: #0f1b2e; }
.help-item-icon {
    width: 32px; height: 32px; border-radius: 9px; flex: 0 0 auto;
    display: grid; place-items: center; background: var(--brand-soft); color: var(--brand);
}
.help-item .btn { margin-left: auto; }
.code-block {
    background: #0b1220; color: #d7e4f5; border: 1px solid #223048; border-radius: 10px;
    padding: 12px 14px; overflow: auto; cursor: pointer; margin: 12px 0 0;
    transition: border-color .15s ease;
}
.code-block:hover { border-color: var(--aurora-2); }
.code-block code { background: transparent; border: 0; color: inherit; padding: 0; font-size: 12.5px; white-space: pre-wrap; }
.code-block.copied { border-color: var(--aurora-2); color: #c4fff4; }
