/* =================================================
   Portal de Nóminas · estilos mobile-first
   Paleta y tipografía del Portal DEOM (Kaptur)
   ================================================= */

:root {
    --az-dark:     #14181f;
    --az-medio:    #2747b0;
    --az-claro:    #6da3e0;
    --az-pale:     #b5d4f4;
    --az-bg:       #eef1fc;
    --az-light:    #f4f7fc;

    --bg-page:    #f5f6f8;
    --bg-card:    #ffffff;
    --bg-soft:    #f1f3f6;
    --ink:        #0f172a;
    --ink-soft:   #475569;
    --ink-muted:  #94a3b8;
    --ink-light:  #cbd5e1;
    --line:       #e2e8f0;
    --line-soft:  #eef2f6;

    --ok:        #3b6d11;
    --ok-bg:     #eaf3de;
    --warn:      #854f0b;
    --warn-bg:   #faeeda;
    --danger:    #791f1f;
    --danger-bg: #fcebeb;
    --info:      #0c447c;
    --info-bg:   #e6f1fb;

    --font-serif: 'Plus Jakarta Sans', -apple-system, 'Segoe UI', sans-serif;
    --font-sans:  'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono:  'JetBrains Mono', monospace;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(15,23,42,0.06);
    --shadow-md: 0 4px 16px rgba(15,23,42,0.08);
    --shadow-lg: 0 10px 30px rgba(15,23,42,0.15);

    --sidebar-w: 240px;
    --topbar-h:  56px;
    --safe-top:    env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left:   env(safe-area-inset-left, 0px);
    --safe-right:  env(safe-area-inset-right, 0px);
    --tap-min: 44px;
}

html[data-theme="dark"] {
    color-scheme: dark;
    --az-dark:     #0b0e14;
    --az-medio:    #5b82e8;
    --az-claro:    #6da3e0;
    --az-pale:     #27354f;
    --az-bg:       #1a2130;
    --az-light:    #e8eef8;

    --bg-page:    #0f1319;
    --bg-card:    #161b23;
    --bg-soft:    #1c222c;
    --ink:        #e7ecf3;
    --ink-soft:   #a4afbd;
    --ink-muted:  #78828f;
    --ink-light:  #454f5b;
    --line:       #2a3340;
    --line-soft:  #222a35;

    --ok:      #97d16b;  --ok-bg:   #1c2a13;
    --warn:    #e5b96b;  --warn-bg: #322510;
    --danger:  #f09a9a;  --danger-bg:#351a1a;
    --info:    #82b8ee;  --info-bg: #132840;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.35);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.45);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.6);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
html, body { height: 100%; }
body {
    max-width: 100vw; overflow-x: clip;
    font-family: var(--font-sans);
    background: var(--bg-page); color: var(--ink);
    font-size: 15px; line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    padding-left: var(--safe-left); padding-right: var(--safe-right);
}
a { color: var(--az-medio); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; height: auto; display: block; }
button { font: inherit; }
html[data-theme="dark"] img { filter: brightness(0.92); }

/* ===== AUTH ===== */
.auth-screen { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.auth-brand {
    background: linear-gradient(135deg, var(--az-dark) 0%, #1c3585 100%);
    color: #f4f7fc;
    padding: calc(20px + var(--safe-top)) 20px 24px;
    position: relative; overflow: hidden; flex-shrink: 0;
}
.auth-brand::before, .auth-brand::after { content: ''; position: absolute; border-radius: 50%; border: 1px solid rgba(244,247,252,0.06); pointer-events: none; }
.auth-brand::before { top: -60px; right: -60px; width: 200px; height: 200px; }
.auth-brand::after  { top: -120px; right: -120px; width: 320px; height: 320px; }
.brand-mark { display: flex; align-items: center; gap: 12px; position: relative; z-index: 1; }
.brand-mark .logo-box, .sidebar-brand .logo-box, .mobile-topbar .logo-box {
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-serif); font-weight: 700; letter-spacing: -0.05em;
    background: linear-gradient(135deg, #f4f7fc, #6da3e0); color: #14181f;
    border-radius: 6px;
}
.brand-mark .logo-box { width: 38px; height: 38px; font-size: 22px; box-shadow: 0 4px 12px rgba(109,163,224,0.3); }
.brand-mark .brand-name { font-family: var(--font-serif); font-weight: 600; font-size: 20px; letter-spacing: -0.01em; line-height: 1; display: block; }
.brand-mark .brand-tag { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.18em; color: #6da3e0; margin-top: 4px; }
.brand-headline { margin-top: 24px; position: relative; z-index: 1; }
.brand-headline .eyebrow { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.2em; color: #6da3e0; margin-bottom: 10px; }
.brand-headline h1 { font-family: var(--font-serif); font-size: 24px; line-height: 1.15; font-weight: 500; letter-spacing: -0.02em; margin-bottom: 10px; }
.brand-headline p { font-size: 13px; line-height: 1.5; color: rgba(244,247,252,0.7); max-width: 380px; }
.brand-foot { margin-top: 16px; font-family: var(--font-mono); font-size: 9px; color: rgba(244,247,252,0.4); display: flex; justify-content: space-between; position: relative; z-index: 1; }
.auth-form {
    padding: 28px 20px calc(28px + var(--safe-bottom));
    background: var(--bg-card); flex: 1;
    display: flex; flex-direction: column; justify-content: center;
    max-width: 520px; width: 100%; margin: 0 auto;
}
.auth-form h2 { font-family: var(--font-serif); font-size: 24px; font-weight: 500; letter-spacing: -0.02em; margin-bottom: 6px; }
.auth-form .sub { color: var(--ink-soft); font-size: 14px; margin-bottom: 24px; }
.footer-brand { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: center; gap: 6px; font-family: var(--font-mono); font-size: 10px; color: var(--ink-muted); letter-spacing: 0.1em; }
.footer-brand strong { color: var(--az-dark); font-family: var(--font-serif); font-weight: 600; font-size: 13px; letter-spacing: -0.01em; }
html[data-theme="dark"] .footer-brand strong { color: var(--az-light); }
.demo-box { margin-top: 18px; padding: 12px 14px; border: 1px dashed var(--line); border-radius: var(--radius-md); background: var(--bg-soft); font-size: 12.5px; color: var(--ink-soft); }
.demo-box strong { color: var(--ink); }
.demo-box .cuentas { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin-top: 8px; }
.demo-box .cuentas a { font-family: var(--font-mono); font-size: 11.5px; }
.demo-box .cuentas span { color: var(--ink-muted); font-size: 11px; }

/* ===== FIELDS / BUTTONS ===== */
.field { margin-bottom: 16px; display: flex; flex-direction: column; }
.field label { display: block; font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 6px; }
.field label .req { color: var(--danger); margin-left: 3px; }
.field input.input-error, .input.input-error { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-bg); }
.field input, .field select, .field textarea, .input {
    width: 100%; padding: 12px 14px; min-height: var(--tap-min);
    border: 1px solid var(--line); background: var(--bg-card); border-radius: var(--radius-sm);
    font-family: inherit; font-size: 16px; color: var(--ink);
    transition: border-color 0.15s, box-shadow 0.15s;
    -webkit-appearance: none; appearance: none;
}
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { outline: none; border-color: var(--az-medio); box-shadow: 0 0 0 3px var(--az-bg); }
.field input:disabled, .field input[readonly] { background: var(--bg-soft); color: var(--ink-muted); }
input[type="checkbox"], input[type="radio"] {
    -webkit-appearance: auto; appearance: auto; width: 18px; height: 18px; min-height: 0; flex: 0 0 auto;
    padding: 0; border: 0; border-radius: 0; background: none; accent-color: var(--az-medio); cursor: pointer;
}
.field select, select.input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23475569' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px;
}
html[data-theme="dark"] .field select, html[data-theme="dark"] select.input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23a4afbd' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
}
.field textarea { min-height: 90px; resize: vertical; }
.field-hint { font-size: 12px; color: var(--ink-muted); margin-top: 4px; }
.field-inline { display: flex; align-items: center; gap: 10px; font-size: 14px; }
/* una casilla con su texto al lado, bien centrados (gana a la regla general de .field label) */
.field label.field-inline, .field .field-inline {
    display: flex; align-items: center; gap: 10px; margin-bottom: 0;
    font-family: inherit; font-size: 14px; text-transform: none; letter-spacing: 0; color: var(--ink);
}
.input-sm { padding: 8px 10px; min-height: 36px; font-size: 14px; }
.input-num { text-align: right; font-family: var(--font-mono); }
/* Campo que no se edita aquí: se pacta en la ficha del trabajador (doble clic para ir) */
.campo-fijo { background: var(--bg-soft); color: var(--ink-muted); cursor: pointer; display: flex; align-items: center; justify-content: flex-end; }
.campo-fijo:hover { border-color: var(--az-claro); color: var(--ink); }

.btn {
    display: inline-flex; align-items: center; gap: 6px; justify-content: center;
    padding: 11px 16px; min-height: var(--tap-min);
    border: 1px solid var(--line); background: var(--bg-card); color: var(--ink);
    border-radius: var(--radius-sm); font-family: inherit; font-size: 14px; font-weight: 500;
    cursor: pointer; text-decoration: none; transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover { background: var(--bg-soft); text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--az-dark); color: #f4f7fc; border-color: var(--az-dark); }
.btn-primary:hover { background: #04142b; }
html[data-theme="dark"] .btn-primary { background: var(--az-medio); border-color: var(--az-medio); color: #fff; }
html[data-theme="dark"] .btn-primary:hover { background: #6f93ee; }
.btn-blue { background: var(--az-medio); color: #fff; border-color: var(--az-medio); }
.btn-blue:hover { background: #1e3a94; color: #fff; }
.btn-danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-bg); }
.btn-ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-bg); }
.btn-warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-bg); }
.btn-block { width: 100%; padding: 14px; font-size: 15px; }
.btn-sm { padding: 8px 12px; font-size: 13px; min-height: 36px; }
.btn-xs { padding: 4px 9px; font-size: 12px; min-height: 28px; gap: 4px; }
.btn:disabled, .btn.disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

.alert { padding: 12px 14px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 16px; display: flex; align-items: flex-start; gap: 10px; }
.alert i { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-error   { background: var(--danger-bg); color: var(--danger); border-left: 3px solid var(--danger); }
.alert-success { background: var(--ok-bg);     color: var(--ok);     border-left: 3px solid var(--ok); }
.alert-info    { background: var(--info-bg);   color: var(--info);   border-left: 3px solid var(--az-medio); }
.alert-warn    { background: var(--warn-bg);   color: var(--warn);   border-left: 3px solid var(--warn); }

/* ===== LAYOUT ===== */
.app { display: grid; grid-template-columns: 1fr; min-height: 100vh; min-height: 100dvh; }
.mobile-topbar {
    display: flex; align-items: center; gap: 6px;
    height: calc(var(--topbar-h) + var(--safe-top)); padding: var(--safe-top) 10px 0 6px;
    background: var(--az-dark); color: var(--az-light);
    position: sticky; top: 0; z-index: 50; box-shadow: var(--shadow-sm);
}
.menu-toggle { width: var(--tap-min); height: var(--tap-min); background: transparent; border: 0; color: #f4f7fc; display: flex; align-items: center; justify-content: center; font-size: 22px; cursor: pointer; border-radius: 4px; }
.mobile-topbar .mtb-brand { display: flex; align-items: center; gap: 8px; flex: 1; text-decoration: none; }
.mobile-topbar .logo-box { width: 28px; height: 28px; font-size: 16px; border-radius: 5px; }
.mobile-topbar .mtb-brand .name { font-family: var(--font-serif); font-weight: 600; font-size: 17px; color: #f4f7fc; letter-spacing: -0.01em; }
.mobile-topbar .mtb-user { width: var(--tap-min); height: var(--tap-min); display: flex; align-items: center; justify-content: center; text-decoration: none; cursor: pointer; }
.mobile-topbar .mtb-user .avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--az-claro); color: #14181f; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; }

.sidebar {
    background: var(--az-dark); color: #f4f7fc;
    width: 80%; max-width: 320px;
    padding: calc(16px + var(--safe-top)) 0 calc(16px + var(--safe-bottom));
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
    transform: translateX(-100%); transition: transform 0.25s ease;
    display: flex; flex-direction: column; overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.sidebar.is-open { transform: translateX(0); box-shadow: var(--shadow-lg); }
.sidebar-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 99; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.sidebar-backdrop.is-visible { opacity: 1; pointer-events: auto; }
.sidebar-brand { padding: 0 18px 16px; border-bottom: 1px solid rgba(244,247,252,0.1); margin-bottom: 10px; }
.sidebar-brand .logo { display: flex; align-items: center; gap: 11px; }
.sidebar-brand .logo-box { width: 32px; height: 32px; font-size: 17px; border-radius: 5px; }
.sidebar-brand .name { font-family: var(--font-serif); font-weight: 600; font-size: 17px; line-height: 1; display: block; color: #f4f7fc; letter-spacing: -0.01em; }
.sidebar-brand .dept { font-family: var(--font-mono); font-size: 8.5px; letter-spacing: 0.18em; color: #6da3e0; margin-top: 4px; display: block; }
.nav-section { padding: 0 12px; margin-bottom: 6px; }
.nav-section-title { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.15em; text-transform: uppercase; color: rgba(244,247,252,0.4); padding: 10px 10px 4px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 12px; min-height: var(--tap-min); color: rgba(244,247,252,0.75); border-radius: var(--radius-sm); font-size: 14px; font-weight: 500; text-decoration: none; transition: background 0.12s, color 0.12s; }
.nav-item:hover { background: rgba(244,247,252,0.06); color: #f4f7fc; text-decoration: none; }
.nav-item.active { background: rgba(109,163,224,0.18); color: #6da3e0; }
.nav-item .ti { font-size: 18px; }
.sidebar-user { margin-top: auto; padding: 14px 18px; border-top: 1px solid rgba(244,247,252,0.1); display: flex; align-items: center; gap: 12px; }
.avatar { width: 38px; height: 38px; background: var(--az-claro); color: #14181f; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; flex-shrink: 0; }
.sidebar-user .info { flex: 1; min-width: 0; }
.sidebar-user .info .name { font-size: 13px; font-weight: 500; color: #f4f7fc; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .info .role { font-family: var(--font-mono); font-size: 9px; color: #6da3e0; letter-spacing: 0.05em; }
.logout-btn { width: var(--tap-min); height: var(--tap-min); background: none; border: none; color: rgba(244,247,252,0.5); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 18px; border-radius: 4px; text-decoration: none; }
.logout-btn:hover { color: #f4f7fc; background: rgba(255,255,255,0.05); }
.sb-collapse, .sb-theme { position: absolute; top: 10px; z-index: 3; width: 26px; height: 26px; min-height: 0; padding: 0; display: none; align-items: center; justify-content: center; background: rgba(255,255,255,.08); color: #cfe0f5; border: 1px solid rgba(255,255,255,.14); border-radius: 7px; cursor: pointer; }
.sb-collapse { right: 8px; } .sb-theme { right: 42px; }
.sb-collapse:hover, .sb-theme:hover { background: rgba(255,255,255,.18); color: #fff; }

.main { padding: 16px; padding-bottom: calc(16px + var(--safe-bottom)); width: 100%; min-width: 0; }
.topbar { margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; }
.topbar .breadcrumb { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.15em; color: var(--ink-soft); text-transform: uppercase; margin-bottom: 4px; }
.topbar h1 { font-family: var(--font-serif); font-size: 22px; font-weight: 600; letter-spacing: -0.02em; color: var(--ink); }
.topbar p { font-size: 13px; color: var(--ink-soft); margin-top: 4px; }
.topbar .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.topbar .actions .btn { flex: 1; min-width: 0; }

/* Selector de mes */
.mes-nav { display: inline-flex; align-items: center; gap: 4px; background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 3px; }
.mes-nav a { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: 4px; color: var(--ink-soft); font-size: 18px; }
.mes-nav a:hover { background: var(--bg-soft); text-decoration: none; }
.mes-nav select { border: 0; background: transparent; font: inherit; font-weight: 600; color: var(--ink); padding: 6px 4px; min-width: 150px; text-align: center; -webkit-appearance: none; appearance: none; }
.mes-nav select:focus { outline: none; }

/* KPIs */
.kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 20px; }
.kpi-card { background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 14px; display: block; text-decoration: none; color: inherit; transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s; }
a.kpi-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); border-color: var(--az-claro); text-decoration: none; }
.kpi-card .label { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.1em; color: var(--ink-soft); text-transform: uppercase; line-height: 1.3; }
.kpi-card .value { font-family: var(--font-serif); font-size: 26px; font-weight: 600; letter-spacing: -0.02em; margin-top: 4px; color: var(--ink); line-height: 1.1; }
.kpi-card .sub { font-size: 12px; color: var(--ink-muted); margin-top: 4px; }
.kpi-card.warn .value { color: var(--warn); }
.kpi-card.danger .value { color: var(--danger); }
.kpi-card.ok .value { color: var(--ok); }
.kpi-card.info .value { color: var(--info); }

/* Tablas (tarjetas en móvil, tabla en escritorio) */
.table-wrap { background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius-md); overflow: hidden; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table thead { display: none; }
.table tbody tr { display: block; padding: 12px 14px; border-bottom: 1px solid var(--line-soft); }
.table tbody tr:last-child { border-bottom: none; }
.table tbody td { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; text-align: right; font-size: 13px; gap: 12px; }
.table tbody td::before { content: attr(data-label); font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); font-weight: 500; text-align: left; }
.table tbody td:not([data-label])::before { content: none; }
.table tbody td:not([data-label]) { justify-content: flex-end; }
.table tbody tr.row-warn { background: var(--danger-bg); }
.table tbody tr.row-soft { background: var(--bg-soft); }
.table tfoot td { font-weight: 600; }
.table .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.table .muted { color: var(--ink-muted); }
.table .cero { color: var(--ink-light); }

/* Tabla compacta siempre en formato tabla (fichas anuales, hojas de cálculo) */
.table-grid { width: 100%; border-collapse: collapse; font-size: 12.5px; white-space: nowrap; }
.table-grid th, .table-grid td { padding: 7px 10px; border-bottom: 1px solid var(--line-soft); text-align: right; font-variant-numeric: tabular-nums; }
.table-grid th { background: var(--bg-soft); font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); font-weight: 500; text-align: right; position: sticky; top: 0; z-index: 1; }
.table-grid th.grp { text-align: center; border-bottom: 1px solid var(--line); color: var(--az-medio); background: var(--bg-card); }
.table-grid th:first-child, .table-grid td:first-child { text-align: left; position: sticky; left: 0; background: var(--bg-card); z-index: 2; }
.table-grid th:first-child { background: var(--bg-soft); z-index: 3; }
.table-grid tbody tr:hover td { background: var(--bg-soft); }
.table-grid tfoot td { font-weight: 700; border-top: 2px solid var(--line); background: var(--bg-soft); }
.table-grid .num { font-family: var(--font-mono); }
.table-grid .cero { color: var(--ink-light); }
.table-grid .sep-l { border-left: 2px solid var(--line); }
.table-grid td.destacado { background: var(--az-bg); font-weight: 600; }
.table-grid tr.total-row td { font-weight: 700; background: var(--bg-soft); }

/* Badges */
.badge { display: inline-block; padding: 2px 10px; border-radius: 10px; font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.05em; font-weight: 500; white-space: nowrap; }
.badge-pending  { background: var(--bg-soft);   color: var(--ink-muted); }
.badge-amber    { background: var(--warn-bg);   color: var(--warn); }
.badge-red      { background: var(--danger-bg); color: var(--danger); }
.badge-info     { background: var(--info-bg);   color: var(--info); }
.badge-green    { background: var(--ok-bg);     color: var(--ok); }
.badge-gray     { background: var(--bg-soft);   color: var(--ink-soft); }

.section-title { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.15em; text-transform: uppercase; color: var(--ink-soft); margin: 20px 0 10px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.form-section { background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 16px; margin-bottom: 14px; }
.form-section-title { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.12em; color: var(--az-medio); margin-bottom: 12px; text-transform: uppercase; display: flex; align-items: center; gap: 8px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.grid-2, .grid-3, .grid-4 { display: grid; grid-template-columns: 1fr; gap: 12px; }
.grid-full { grid-column: 1 / -1; }
.filter-pills { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.filter-pill { padding: 6px 12px; border-radius: 14px; font-size: 12px; font-family: var(--font-mono); background: var(--bg-soft); color: var(--ink-soft); cursor: pointer; text-decoration: none; min-height: 32px; display: inline-flex; align-items: center; gap: 6px; border: 0; }
.filter-pill.active { background: var(--az-dark); color: #f4f7fc; }
html[data-theme="dark"] .filter-pill.active { background: var(--az-medio); }
.filter-pill:hover { text-decoration: none; }
.txt-muted { color: var(--ink-muted); } .txt-soft { color: var(--ink-soft); } .txt-danger { color: var(--danger) !important; } .txt-ok { color: var(--ok); } .txt-warn { color: var(--warn); }
.mono { font-family: var(--font-mono); } .small { font-size: 12px; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0 !important; } .mb-0 { margin-bottom: 0 !important; } .mt-12 { margin-top: 12px; }
.empty { padding: 28px 16px; text-align: center; color: var(--ink-muted); font-size: 14px; }
.empty i { font-size: 30px; display: block; margin-bottom: 6px; color: var(--ink-light); }

/* ===== Parte del mes (operario) ===== */
.parte-estado { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 14px; border-radius: var(--radius-md); border: 1px solid var(--line); background: var(--bg-card); margin-bottom: 14px; font-size: 13px; }
.parte-estado.e-enviado { border-color: var(--warn); background: var(--warn-bg); color: var(--warn); }
.parte-estado.e-validado { border-color: var(--ok); background: var(--ok-bg); color: var(--ok); }
.parte-estado.e-rechazado { border-color: var(--danger); background: var(--danger-bg); color: var(--danger); }
.parte-estado i { font-size: 20px; }
.resumen-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 20px; background: var(--bg-card); border: 1px solid var(--line); font-size: 12.5px; color: var(--ink-soft); }
.chip b { color: var(--ink); font-family: var(--font-mono); font-weight: 600; }
.chip.on { border-color: var(--az-claro); background: var(--az-bg); color: var(--info); }
.chip.on b { color: var(--info); }

.dias-lista { display: flex; flex-direction: column; gap: 6px; }
.dia-card { display: grid; grid-template-columns: 54px 1fr auto; gap: 10px; align-items: center; padding: 10px 12px; background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius-md); text-decoration: none; color: inherit; min-height: 56px; }
.dia-card:hover { border-color: var(--az-claro); text-decoration: none; box-shadow: var(--shadow-sm); }
.dia-card.finde { background: var(--bg-soft); }
.dia-card.hoy { border-color: var(--az-medio); box-shadow: 0 0 0 2px var(--az-bg); }
.dia-card.vacio { color: var(--ink-muted); }
.dia-card .fecha { text-align: center; line-height: 1.1; }
.dia-card .fecha .d { font-family: var(--font-serif); font-size: 20px; font-weight: 700; color: var(--ink); }
.dia-card .fecha .w { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-muted); }
.dia-card.finde .fecha .w { color: var(--danger); }
.dia-card .info { min-width: 0; }
.dia-card .info .cli { font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dia-card .info .tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 4px; }
.tag { font-family: var(--font-mono); font-size: 10px; padding: 1px 7px; border-radius: 8px; background: var(--bg-soft); color: var(--ink-soft); white-space: nowrap; }
.tag.h { background: var(--info-bg); color: var(--info); }
.tag.d { background: var(--ok-bg); color: var(--ok); }
.tag.k { background: var(--warn-bg); color: var(--warn); }
.tag.g { background: var(--danger-bg); color: var(--danger); }
.dia-card .go { color: var(--ink-light); font-size: 18px; }
.dia-card .sin { font-size: 12.5px; color: var(--ink-muted); }

/* Formulario de un día */
.dia-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.dia-head .nav { display: flex; gap: 6px; }
.dia-head h2 { font-family: var(--font-serif); font-size: 20px; font-weight: 600; }
.dia-head h2 small { display: block; font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-soft); font-weight: 500; margin-top: 2px; }
.stepper-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.stepper { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 8px 8px 14px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--bg-card); }
.stepper.has-value { border-color: var(--az-claro); background: var(--az-bg); }
.stepper .lbl { font-size: 14px; font-weight: 500; }
.stepper .lbl small { display: block; font-size: 11px; color: var(--ink-muted); font-weight: 400; }
.stepper .ctl { display: flex; align-items: center; gap: 4px; }
.stepper .ctl button { width: 40px; height: 40px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg-card); color: var(--ink); font-size: 20px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.stepper .ctl button:active { background: var(--bg-soft); }
.stepper .ctl input { width: 58px; height: 40px; text-align: center; border: 1px solid var(--line); border-radius: 8px; font-family: var(--font-mono); font-size: 16px; font-weight: 600; background: var(--bg-card); color: var(--ink); -webkit-appearance: none; appearance: none; }
.stepper .ctl input:focus { outline: none; border-color: var(--az-medio); }
.stepper .ctl .unit { font-size: 11px; color: var(--ink-muted); width: 18px; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg-page); padding: 12px 0 calc(8px + var(--safe-bottom)); margin-top: 8px; display: flex; gap: 8px; z-index: 5; border-top: 1px solid var(--line); }
.sticky-actions .btn { flex: 1; }

/* Gastos */
.gasto-card { display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center; padding: 10px 12px; background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius-md); }
.gasto-card.pendiente { border-color: var(--warn); box-shadow: inset 3px 0 0 var(--warn); }
.gasto-card .thumb { width: 56px; height: 56px; border-radius: 6px; background: var(--bg-soft); overflow: hidden; display: flex; align-items: center; justify-content: center; color: var(--ink-light); font-size: 22px; }
.gasto-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.gasto-card .imp { font-family: var(--font-mono); font-weight: 600; font-size: 15px; text-align: right; }
.gasto-card .desc { font-size: 13.5px; font-weight: 500; }
.gasto-card .meta { font-size: 12px; color: var(--ink-muted); }
.foto-prev { max-width: 100%; max-height: 260px; border-radius: 8px; border: 1px solid var(--line); margin-top: 8px; display: none; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* Resumen de importes (admin) */
.calc-box { background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius-md); overflow: hidden; }
.calc-box .row { display: flex; justify-content: space-between; align-items: baseline; padding: 9px 14px; border-bottom: 1px solid var(--line-soft); font-size: 13.5px; gap: 12px; }
.calc-box .row:last-child { border-bottom: 0; }
.calc-box .row .k { color: var(--ink-soft); }
.calc-box .row .k small { color: var(--ink-muted); font-size: 11.5px; }
.calc-box .row .v { font-family: var(--font-mono); font-weight: 500; white-space: nowrap; }
.calc-box .row.sub { background: var(--bg-soft); font-weight: 600; }
.calc-box .row.sub .v { font-weight: 700; }
.calc-box .row.total { background: var(--az-bg); font-weight: 700; font-size: 15px; }
.calc-box .row.total .v { color: var(--info); font-size: 17px; }
.calc-box .head { padding: 10px 14px; font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--az-medio); border-bottom: 1px solid var(--line); background: var(--bg-card); }
.barra { height: 8px; background: var(--bg-soft); border-radius: 4px; overflow: hidden; margin-top: 8px; }
.barra > span { display: block; height: 100%; background: var(--az-medio); border-radius: 4px; }
.barra.warn > span { background: var(--warn); } .barra.danger > span { background: var(--danger); }

/* Buzón de correo */
.bz { display: grid; grid-template-columns: 1fr; gap: 14px; align-items: start; }
.bz-carpetas { display: flex; flex-direction: row; flex-wrap: wrap; gap: 4px; }
.bz-carp { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 8px; text-decoration: none; color: var(--ink); font-size: 13px; border: 1px solid transparent; }
.bz-carp:hover { background: var(--bg-soft); text-decoration: none; }
.bz-carp.on { background: var(--az-bg); border-color: var(--line); color: var(--az-medio); font-weight: 600; }
.bz-carp .badge { margin-left: auto; }
.bz-panel { background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius-md); min-height: 300px; overflow: hidden; }
.bz-lista { display: flex; flex-direction: column; }
.bz-fila { display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--line-soft); color: var(--ink); font-size: 13px; }
.bz-fila:hover { background: var(--bg-soft); }
.bz-fila.arrastrando { opacity: .45; }
.bz-abrir { flex: 1; min-width: 0; display: grid; grid-template-columns: 1fr 70px; gap: 4px 10px; padding: 10px 4px 10px 14px; text-decoration: none; color: inherit; align-items: center; }
.bz-abrir:hover { text-decoration: none; }
.bz-borrar { border: 0; background: none; color: var(--ink-muted); cursor: pointer; padding: 8px 12px; font-size: 16px; border-radius: 6px; }
.bz-borrar:hover { color: var(--danger); background: var(--danger-bg); }
.bz-carp.soltar { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }
.bz-fila.nuevo { font-weight: 600; }
.bz-fila.nuevo .bz-de::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--az-medio); margin-right: 8px; vertical-align: 1px; }
.bz-de, .bz-asunto { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bz-asunto { grid-column: 1 / -1; font-weight: 400; color: var(--ink-soft); }
.bz-fecha { text-align: right; color: var(--ink-muted); font-family: var(--font-mono); font-size: 11px; }
.bz-pag { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; font-size: 12px; color: var(--ink-soft); flex-wrap: wrap; }
.bz-msg-h { padding: 14px 16px; border-bottom: 1px solid var(--line-soft); }
.bz-msg-h h3 { margin: 0 0 8px; font-size: 17px; font-family: var(--font-serif); font-weight: 500; }
.bz-meta { font-size: 12px; color: var(--ink-soft); margin: 2px 0; word-break: break-word; }
.bz-acciones { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.bz-adj { padding: 8px 16px; border-bottom: 1px solid var(--line-soft); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 12px; }
.bz-adj-it { border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px; text-decoration: none; color: var(--az-medio); background: var(--bg-soft); }
.bz-adj-it small { color: var(--ink-muted); }
.bz-cuerpo { width: 100%; height: 70vh; border: 0; background: #fff; display: block; }
.bz-form { padding: 16px; }
.bz-form .field { margin-bottom: 10px; }
@media (min-width: 900px) {
    .bz { grid-template-columns: 200px minmax(0, 1fr); }
    .bz-carpetas { flex-direction: column; }
    .bz-abrir { grid-template-columns: 230px minmax(0, 1fr) 90px; }
    .bz-asunto { grid-column: auto; font-weight: inherit; color: inherit; }
}

/* Pasos del mes (asesoría) */
.pasos { display: grid; grid-template-columns: 1fr; gap: 8px; margin-bottom: 16px; }
.paso { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius-md); font-size: 13px; }
.paso .n { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-weight: 600; background: var(--bg-soft); color: var(--ink-soft); flex-shrink: 0; }
.paso div { display: flex; flex-direction: column; line-height: 1.25; }
.paso div span { font-size: 12px; color: var(--ink-muted); }
.paso.hecho { border-color: var(--ok); } .paso.hecho .n { background: var(--ok); color: #fff; }
.paso.actual { border-color: var(--az-medio); box-shadow: 0 0 0 2px var(--az-bg); } .paso.actual .n { background: var(--az-medio); color: #fff; }
@media (min-width: 900px) { .pasos { grid-template-columns: repeat(4, 1fr); } }

/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs a { padding: 10px 14px; font-size: 13.5px; font-weight: 500; color: var(--ink-soft); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs a.active { color: var(--az-medio); border-bottom-color: var(--az-medio); }

.app-footer { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--line); font-family: var(--font-mono); font-size: 10px; color: var(--ink-muted); display: flex; flex-direction: column; gap: 4px; letter-spacing: 0.05em; text-align: center; }
.app-footer strong { color: var(--az-dark); font-family: var(--font-serif); font-weight: 600; }
html[data-theme="dark"] .app-footer strong { color: var(--az-light); }

/* Banda "viendo como" */
.sim-bar { position: sticky; top: 0; z-index: 40; background: #EF9F27; color: #2C2C2A; padding: 8px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; flex-wrap: wrap; border-bottom: 1px solid #C97F11; box-shadow: 0 2px 6px rgba(239,159,39,.25); margin: -1px -1px 14px; border-radius: 8px; }
.sim-bar-content { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; min-width: 0; }
.sim-bar-content .ti { font-size: 16px; }
.sim-bar-label { font-weight: 500; }
.sim-bar-badge { background: #fff; padding: 2px 10px; border-radius: 12px; font-family: var(--font-mono); font-size: 11px; letter-spacing: .05em; font-weight: 500; color: #2C2C2A; }
.sim-bar-hint { font-size: 11px; opacity: .7; font-style: italic; }
.sim-bar-actions { display: flex; gap: 6px; flex-shrink: 0; }
.sim-btn { display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px; border: none; border-radius: 6px; font-size: 12px; cursor: pointer; text-decoration: none; font-family: inherit; }
.sim-btn-dark { background: #854F0B; color: #fff; }
.sim-btn-dark:hover { background: #633806; color: #fff; }

/* Print */
@media print {
    .sidebar, .mobile-topbar, .sidebar-backdrop, .app-footer, .topbar .actions, .sim-bar, .sticky-actions, .no-print { display: none !important; }
    .app { display: block; } .main { padding: 0; max-width: none; }
    body { background: #fff; color: #000; }
    .table-wrap, .form-section, .calc-box { border-color: #999; break-inside: avoid; }
}

/* ===== Responsive ===== */
@media (min-width: 600px) {
    body { font-size: 14px; }
    .main { padding: 24px; }
    .topbar { flex-direction: row; justify-content: space-between; align-items: flex-start; }
    .topbar h1 { font-size: 26px; }
    .topbar .actions { flex-wrap: wrap; justify-content: flex-end; }
    .topbar .actions .btn { flex: 0 1 auto; }
    .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
    .grid-2 { grid-template-columns: 1fr 1fr; gap: 12px 16px; }
    .grid-3 { grid-template-columns: 1fr 1fr 1fr; gap: 12px 16px; }
    .grid-4 { grid-template-columns: 1fr 1fr; gap: 12px 16px; }
    .stepper-grid { grid-template-columns: 1fr 1fr; }
    .app-footer { flex-direction: row; justify-content: space-between; text-align: left; }
    .auth-screen { flex-direction: row; }
    .auth-brand { padding: 48px 40px; width: 50%; max-width: 50%; }
    .brand-headline h1 { font-size: 32px; }
    .auth-form { padding: 48px 40px; max-width: 480px; }
    .sticky-actions { position: static; border: 0; padding: 12px 0 0; justify-content: flex-end; }
    .sticky-actions .btn { flex: 0 1 auto; }
}
@media (min-width: 900px) {
    .app { grid-template-columns: var(--sidebar-w) 1fr; }
    .mobile-topbar { display: none; }
    .sidebar { position: sticky; top: 0; height: 100vh; width: var(--sidebar-w); max-width: var(--sidebar-w); transform: none; box-shadow: none; padding-top: 16px; }
    .sidebar-backdrop { display: none; }
    .sb-collapse, .sb-theme { display: flex; }
    body.sb-off .app { grid-template-columns: 56px 1fr; }
    body.sb-off .sidebar { width: 56px; max-width: 56px; padding-left: 6px; padding-right: 6px; overflow: hidden; }
    body.sb-off .sidebar .nav-section-title, body.sb-off .sidebar .nav-item span, body.sb-off .sidebar .sidebar-brand > .logo > div, body.sb-off .sidebar .sidebar-user .info, body.sb-off .sidebar .sidebar-user .logout-btn { display: none; }
    body.sb-off .sidebar .nav-item { justify-content: center; padding-left: 0; padding-right: 0; }
    body.sb-off .sidebar-brand { padding-left: 0; padding-right: 0; }
    body.sb-off .sidebar-brand .logo { justify-content: center; }
    body.sb-off .sidebar-user { justify-content: center; padding-left: 0; padding-right: 0; }
    body.sb-off .sb-collapse { right: 15px; } body.sb-off .sb-collapse i { transform: rotate(180deg); }
    body.sb-off .sb-theme { top: 44px; right: 15px; }
    body.sb-off .main { max-width: none; }
    .main { padding: 28px 36px; max-width: 1400px; }
    .topbar h1 { font-size: 28px; }
    .table { font-size: 13px; }
    .table thead { display: table-header-group; }
    .table thead th { background: var(--bg-soft); padding: 10px 14px; text-align: left; font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-soft); border-bottom: 1px solid var(--line); font-weight: 500; white-space: nowrap; }
    .table thead th.right { text-align: right; }
    .table tbody tr { display: table-row; padding: 0; border-bottom: 1px solid var(--line-soft); }
    .table tbody tr:hover { background: var(--bg-soft); }
    .table tbody tr.row-warn:hover { background: var(--danger-bg); }
    .table tbody td { display: table-cell; text-align: left; padding: 10px 14px; font-size: 13px; justify-content: initial; }
    .table tbody td.right, .table tfoot td.right { text-align: right; }
    .table tbody td::before { content: none; }
    .table tfoot { display: table-footer-group; }
    .table tfoot td { padding: 10px 14px; background: var(--bg-soft); border-top: 2px solid var(--line); }
    .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
    .kpi-card { padding: 16px; } .kpi-card .value { font-size: 30px; }
    .grid-3 { grid-template-columns: 1fr 1fr 1fr; gap: 10px 16px; }
    .grid-4 { grid-template-columns: 1fr 1fr 1fr 1fr; gap: 10px 16px; }
    .form-section { padding: 18px 22px; }
    .stepper-grid { grid-template-columns: repeat(3, 1fr); }
    .dia-card { grid-template-columns: 64px 1fr auto; }
}
/* Los bloques van siempre uno debajo del otro, nunca en dos columnas */
.layout-2 { display: block; }
.layout-2 > div { min-width: 0; }
/* Excepción: bloques pequeños que se emparejan para no dejar cajas vacías */
.cols-2 { display: grid; grid-template-columns: 1fr; gap: 0 16px; align-items: start; }
.cols-2 > * { min-width: 0; }
@media (min-width: 640px) { .cols-2 { grid-template-columns: 1fr 1fr; } }

/* Submenú del lateral (Ajustes → Empresa / Gestoría) */
.nav-submenu { margin: 0 0 4px 12px; padding-left: 10px; border-left: 1px solid rgba(255,255,255,0.12); display: flex; flex-direction: column; }
.nav-subitem { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: var(--radius-sm); color: rgba(255,255,255,0.6); font-size: 12.5px; text-decoration: none; }
.nav-subitem:hover { background: rgba(255,255,255,0.06); color: #fff; text-decoration: none; }
.nav-subitem.active { color: var(--az-claro); background: rgba(109,163,224,0.14); }
.nav-subitem .ti { font-size: 15px; }
body.sb-off .nav-submenu { display: none; }
.campos-cortos .input-num { max-width: 220px; }
@media (min-width: 1200px) {
    .field input, .field select, .field textarea, .input { font-size: 13px; padding: 8px 12px; min-height: auto; }
    .btn { padding: 8px 14px; min-height: auto; font-size: 13px; }
    .btn-sm { padding: 5px 10px; min-height: auto; font-size: 12px; }
    .stepper .ctl button { width: 32px; height: 32px; font-size: 16px; }
    .stepper .ctl input { height: 32px; font-size: 14px; width: 52px; }
}
@media (max-width: 599px) {
    .table tfoot { display: block; padding: 10px 14px; font-size: 13px; }
    .table tfoot tr { display: block; } .table tfoot td { display: flex; justify-content: space-between; padding: 4px 0; }
    .table tfoot td:empty { display: none; }
}
