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

:root{
    --bg:         #eef0f3;
    --surface:    #ffffff;
    --surface-2:  #fcfcfd;
    --strong:     #151a21;   /* topbar y barra superior de las tarjetas */
    --text:       #151a21;
    --text-on-strong:       #ffffff;
    --text-on-strong-muted: #b9c0c9;
    --hairline:   #d9dee3;
    --muted:      #5b6470;
    --accent:       #e8432f;   /* luz de "al aire" */
    --accent-hover: #cf3a28;
    --accent-ink:   #ffffff;
    --amber:      #c98a1e;   /* estado "Emitido" */
    --red-soft:      #f6d9d4;
    --red-soft-text: #9c2c1d;
    --green-soft: #dcead9;
    --green-ink:  #2f6b32;
    --focus:      #2f6bd6;
    --badge-bg:     #232a33;
    --badge-border: #39424e;
    --row-hover:  #fafbfc;
    font-size: 16px;
    color-scheme: light;
}

[data-theme="dark"]{
    --bg:         #0a0e1a;
    --surface:    #131a2c;
    --surface-2:  #0f1526;
    --strong:     #0a0d17;
    --text:       #eef2f8;
    --text-on-strong:       #ffffff;
    --text-on-strong-muted: #93a2c2;
    --hairline:   #26304a;
    --muted:      #8b96b0;
    --accent:       #ff5b48;
    --accent-hover: #ff7563;
    --accent-ink:   #ffffff;
    --amber:      #e0a53a;
    --red-soft:      rgba(255,91,72,0.16);
    --red-soft-text: #ff9c8f;
    --green-soft: rgba(60,200,120,0.16);
    --green-ink:  #6fe0a0;
    --focus:      #5b9bff;
    --badge-bg:     #1c2438;
    --badge-border: #2e3a56;
    --row-hover:  rgba(255,255,255,0.03);
    color-scheme: dark;
}

*{ box-sizing:border-box; }

body{
    margin:0;
    background:var(--bg);
    color:var(--text);
    font-family:'Inter', system-ui, sans-serif;
    line-height:1.45;
    transition:background .2s ease, color .2s ease;
}

h1,h2{
    font-family:'Barlow Condensed', sans-serif;
    letter-spacing:0.01em;
    margin:0;
}

/* ---------- topbar ---------- */
.topbar{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:16px;
    padding:18px 28px;
    background:var(--strong);
    color:var(--text-on-strong);
    flex-wrap:wrap;
}
.topbar__brand{ display:flex; align-items:center; gap:14px; }
.topbar__dot{
    width:14px; height:14px; border-radius:50%;
    background:var(--accent);
    box-shadow:0 0 0 4px rgba(232,67,47,0.25);
    flex:none;
}
.topbar h1{ font-size:1.6rem; font-weight:700; }
.topbar p{ margin:2px 0 0; font-size:0.85rem; color:var(--text-on-strong-muted); }
.topbar__medio{ display:flex; flex-direction:column; align-items:flex-end; gap:4px; }
.topbar__medio .label{ font-size:0.72rem; text-transform:uppercase; letter-spacing:0.08em; color:var(--text-on-strong-muted); }
.badge{
    display:inline-block;
    padding:3px 12px;
    border-radius:3px;
    background:var(--badge-bg);
    border:1px solid var(--badge-border);
    color:var(--text-on-strong);
    font-family:'JetBrains Mono', monospace;
    font-size:0.85rem;
}

.btn-tema{
    width:38px; height:38px; flex:none;
    border-radius:50%;
    border:1px solid var(--badge-border);
    background:var(--badge-bg);
    color:var(--text-on-strong);
    display:flex; align-items:center; justify-content:center;
    cursor:pointer;
    transition:background .2s ease, transform .15s ease;
}
.btn-tema:hover{ background:#2b3446; }
.btn-tema:active{ transform:scale(.92); }
.btn-tema svg{ width:19px; height:19px; }
.btn-tema .icono-sol{ display:none; }
.btn-tema .icono-luna{ display:block; }
[data-theme="dark"] .btn-tema .icono-sol{ display:block; }
[data-theme="dark"] .btn-tema .icono-luna{ display:none; }

/* ---------- layout ---------- */
.layout{
    max-width:1080px;
    margin:0 auto;
    padding:24px 20px 60px;
    display:grid;
    gap:20px;
}

.card{
    background:var(--surface);
    border:1px solid var(--hairline);
    border-top:3px solid var(--strong);
    border-radius:6px;
    padding:20px 24px 24px;
    transition:background .2s ease, border-color .2s ease;
}
.card--wide{ grid-column:1 / -1; }
.card h2{ font-size:1.3rem; font-weight:700; }
.card__hint{ margin:4px 0 16px; color:var(--muted); font-size:0.88rem; }

.card__toggle{
    all:unset;
    display:flex;
    align-items:center;
    justify-content:space-between;
    width:100%;
    cursor:pointer;
}
.card__toggle .chev{ color:var(--muted); transition:transform .15s ease; }
.card__toggle[aria-expanded="false"] .chev{ transform:rotate(-90deg); }
#tarjetaConfig.is-collapsed .grid-form,
#tarjetaConfig.is-collapsed .card__hint{ display:none; }

.card__head-row{
    display:flex;
    align-items:center;
    justify-content:space-between;
    flex-wrap:wrap;
    gap:12px;
    margin-bottom:14px;
}
.card__head-actions{ display:flex; align-items:center; gap:10px; }
.filtro-label{ font-size:0.85rem; color:var(--muted); }

/* ---------- forms ---------- */
.grid-form{
    display:grid;
    grid-template-columns:repeat(3, 1fr);
    gap:14px 16px;
}
.field{ display:flex; flex-direction:column; gap:6px; }
.field--wide{ grid-column:span 2; }
.field--full{ grid-column:1 / -1; }
.field--actions{ display:flex; align-items:center; gap:14px; }

label{ font-size:0.82rem; font-weight:500; color:var(--muted); }

input[type=text], input[type=date], input[type=email], input[type=password], select{
    font:inherit;
    width:100%;
    padding:9px 10px;
    border:1px solid var(--hairline);
    border-radius:4px;
    background:var(--surface-2);
    color:var(--text);
}
input::placeholder{ color:var(--muted); opacity:.7; }
input:focus, select:focus{
    outline:2px solid var(--focus);
    outline-offset:1px;
    border-color:var(--focus);
}
#codigo_spot, #codigo_bloque{ font-family:'JetBrains Mono', monospace; }

/* ---------- control de hora compuesto (hh:mm:ss a.m./p.m.) ---------- */
.hora-input{
    display:flex;
    align-items:center;
    gap:2px;
    border:1px solid var(--hairline);
    border-radius:4px;
    background:var(--surface-2);
    padding:0 4px;
}
.hora-input:focus-within{
    outline:2px solid var(--focus);
    outline-offset:1px;
    border-color:var(--focus);
}
.hora-parte{
    width:2.15em;
    border:none;
    background:transparent;
    padding:9px 2px;
    text-align:center;
    font:inherit;
    font-variant-numeric:tabular-nums;
    color:var(--text);
}
.hora-parte:focus{ outline:none; background:rgba(47,107,214,0.12); border-radius:3px; }
.hora-sep{ color:var(--muted); }
.hora-ampm{
    border:none;
    background:transparent;
    font:inherit;
    color:var(--text);
    padding:9px 4px 9px 6px;
    margin-left:2px;
    border-left:1px solid var(--hairline);
    cursor:pointer;
}
.hora-ampm:focus{ outline:none; }

.btn{
    font:inherit;
    font-weight:600;
    border:none;
    border-radius:4px;
    padding:10px 18px;
    cursor:pointer;
    text-decoration:none;
    display:inline-flex;
    align-items:center;
    gap:8px;
}
.btn--primary{ background:var(--strong); color:var(--text-on-strong); }
.btn--primary:hover{ background:#262e39; }
.btn--accent{ background:var(--accent); color:var(--accent-ink); }
.btn--accent:hover{ background:var(--accent-hover); }
.btn--ghost{ background:transparent; color:var(--muted); border:1px solid var(--hairline); }
.btn--danger-text{ background:none; border:none; color:var(--accent); cursor:pointer; font-weight:600; font-size:0.85rem; }

.estado-guardado{ color:var(--green-ink); font-size:0.88rem; font-weight:600; }

/* ---------- tabla ---------- */
.tabla-wrap{ overflow-x:auto; }
.tabla{ width:100%; border-collapse:collapse; font-size:0.9rem; }
.tabla th{
    text-align:left;
    font-size:0.75rem;
    text-transform:uppercase;
    letter-spacing:0.04em;
    color:var(--muted);
    border-bottom:2px solid var(--strong);
    padding:8px 10px;
    white-space:nowrap;
}
.tabla td{
    padding:9px 10px;
    border-bottom:1px solid var(--hairline);
    vertical-align:top;
}
.tabla td:first-child{ font-family:'JetBrains Mono', monospace; color:var(--muted); }
.tabla tbody tr:hover{ background:var(--row-hover); }
.fila-vacia td{ color:var(--muted); text-align:center; padding:24px 0; }

.pill{
    display:inline-block;
    padding:2px 10px;
    border-radius:99px;
    font-size:0.78rem;
    font-weight:600;
}
.pill--emitido{ background:var(--green-soft); color:var(--green-ink); }
.pill--no-emitido{ background:var(--red-soft); color:var(--red-soft-text); }

.fila-acciones{ display:flex; gap:10px; white-space:nowrap; }
.fila-acciones button{ background:none; border:none; cursor:pointer; font-weight:600; font-size:0.85rem; padding:0; }
.fila-acciones .accion-editar{ color:var(--focus); }
.fila-acciones .accion-eliminar{ color:var(--accent); }

@media (max-width: 720px){
    .grid-form{ grid-template-columns:1fr 1fr; }
    .field--wide{ grid-column:span 2; }
    .topbar{ padding:16px; }
}
@media (max-width: 480px){
    .grid-form{ grid-template-columns:1fr; }
    .field--wide{ grid-column:1; }
    .hora-parte{ width:2em; }
}

/* ---------- sesión en la topbar ---------- */
.topbar__usuario{
    display:flex;
    flex-direction:column;
    align-items:flex-end;
    gap:2px;
}
.topbar__usuario .label{ font-size:0.72rem; text-transform:uppercase; letter-spacing:0.08em; color:var(--text-on-strong-muted); }
.topbar__usuario-nombre{ font-family:'JetBrains Mono', monospace; font-size:0.85rem; color:var(--text-on-strong); }
.auth-link{ font-size:0.82rem; color:var(--focus); text-decoration:none; }
.auth-link:hover{ text-decoration:underline; }
.auth-link--topbar{ color:var(--text-on-strong-muted); }
.auth-link--topbar:hover{ color:var(--text-on-strong); }

/* ---------- páginas de login / registro ---------- */
.auth-shell{
    max-width:420px;
    margin:60px auto;
    padding:0 20px;
}
.auth-card h2{ font-size:1.4rem; font-weight:700; margin-bottom:4px; }
.grid-form--auth{ grid-template-columns:1fr; }
.auth-error{
    background:var(--red-soft);
    color:var(--red-soft-text);
    border-radius:4px;
    padding:9px 12px;
    font-size:0.86rem;
    margin:0 0 14px;
}

@media (max-width: 720px){
    .topbar__usuario{ align-items:flex-start; }
}
