/* SurfApp PWA: portal del empleado. Mobile-first, sin dependencias. */
:root {
    --bg: #f6f5f2;
    --surface: #ffffff;
    --surface-2: #f1efea;
    --text: #1c1917;
    --muted: #6b6560;
    --border: #e4e0d9;
    --primary: #dc0a0a;
    --primary-strong: #b00808;
    --primary-soft: #fdeaea;
    --on-primary: #ffffff;
    --ink: #1c1917;
    --on-ink: #ffffff;
    --ok: #15803d;
    --ok-soft: #e8f6ec;
    --warn: #b45309;
    --warn-soft: #fdf3dc;
    --danger: #b91c1c;
    --danger-soft: #fdecec;
    --radius: 18px;
    --radius-sm: 12px;
    --nav-height: 64px;
    --shadow: 0 1px 2px rgba(28, 25, 23, 0.05), 0 8px 24px rgba(28, 25, 23, 0.06);
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #141210;
        --surface: #1f1c19;
        --surface-2: #2a2622;
        --text: #f5f2ee;
        --muted: #a8a099;
        --border: #36312c;
        --primary: #ef3b3b;
        --primary-strong: #ff8a8a;
        --primary-soft: #3a1414;
        --on-primary: #ffffff;
        --ink: #f5f2ee;
        --on-ink: #1c1917;
        --ok: #4ade80;
        --ok-soft: #14301f;
        --warn: #fbbf24;
        --warn-soft: #33270d;
        --danger: #f87171;
        --danger-soft: #3a1717;
        --shadow: none;
    }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100dvh;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

a { color: var(--primary-strong); }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }

.shell {
    max-width: 560px;
    margin: 0 auto;
    padding: calc(env(safe-area-inset-top) + 16px) 16px calc(var(--nav-height) + env(safe-area-inset-bottom) + 28px);
}

.shell.no-nav { padding-bottom: calc(env(safe-area-inset-bottom) + 28px); }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: inherit;
    text-decoration: none;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.brand img { width: 34px; height: 34px; border: 1px solid var(--border); border-radius: 9px; background: #fff; }

.topbar-user {
    max-width: 55%;
    overflow: hidden;
    color: var(--muted);
    font-size: 0.82rem;
    text-align: right;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.page-head { margin-bottom: 16px; }
.page-head h1 { font-size: 1.5rem; line-height: 1.2; letter-spacing: -0.02em; text-wrap: balance; }
.page-head p { margin-top: 4px; color: var(--muted); font-size: 0.92rem; }

.card {
    margin-bottom: 14px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.card h2 { font-size: 1rem; letter-spacing: -0.01em; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* Estado y cronometro */
.clock-card { text-align: center; padding: 22px 18px 18px; }

.pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 12px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 600;
}

.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.danger { background: var(--danger-soft); color: var(--danger); }
.pill.plain::before { display: none; }

.timer {
    margin: 14px 0 2px;
    font-size: clamp(2.6rem, 14vw, 3.6rem);
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
}

.timer-caption { color: var(--muted); font-size: 0.88rem; }

.clock-actions { display: grid; gap: 10px; margin-top: 20px; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 52px;
    padding: 12px 18px;
    border: 1px solid transparent;
    border-radius: 14px;
    background: var(--primary);
    color: var(--on-primary);
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.12s ease, opacity 0.12s ease;
}

.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: 0.6; cursor: progress; }
.btn.big { min-height: 64px; font-size: 1.1rem; border-radius: 18px; }
.btn.ink { background: var(--ink); color: var(--on-ink); }
.btn.ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn.danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.btn.inline { width: auto; min-height: 40px; padding: 8px 14px; font-size: 0.88rem; border-radius: 12px; }

:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

.hint { margin-top: 12px; color: var(--muted); font-size: 0.8rem; }

/* Formularios */
.field { display: grid; gap: 6px; min-width: 0; margin-bottom: 14px; font-size: 0.85rem; font-weight: 600; color: var(--muted); }

.field input,
.field select,
.field textarea {
    width: 100%;
    min-height: 48px;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 16px; /* evita el zoom de iOS al enfocar */
    font-weight: 400;
    min-width: 0;
    max-width: 100%;
}

.field textarea { min-height: 84px; resize: vertical; }
.field input[type="file"] { padding: 10px; }
.field-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
@media (max-width: 380px) { .field-row { grid-template-columns: minmax(0, 1fr); gap: 0; } }

.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 14px; padding: 4px; border-radius: 14px; background: var(--surface-2); }
.segmented label { position: relative; display: block; }
.segmented input { position: absolute; inset: 0; opacity: 0; }
.segmented span { display: block; padding: 10px 6px; border-radius: 10px; color: var(--muted); font-size: 0.88rem; font-weight: 700; text-align: center; }
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }
.segmented input:focus-visible + span { outline: 3px solid var(--primary); outline-offset: 1px; }

/* Listas */
.list { margin: 0; padding: 0; list-style: none; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.list li:first-child { padding-top: 0; border-top: 0; }
.list li:last-child { padding-bottom: 0; }
.list .main { min-width: 0; }
.list .main strong { display: block; font-size: 0.95rem; }
.list .main span { display: block; color: var(--muted); font-size: 0.83rem; overflow-wrap: anywhere; }
.list .side { flex: none; font-variant-numeric: tabular-nums; font-weight: 700; text-align: right; }
.list a.row-link { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; color: inherit; text-decoration: none; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.stats div { padding: 12px 6px; border-radius: var(--radius-sm); background: var(--surface-2); }
.stats strong { display: block; font-size: 1.45rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stats span { color: var(--muted); font-size: 0.74rem; }
.stats .accent { background: var(--primary-soft); }
.stats .accent strong { color: var(--primary-strong); }

.progress { height: 8px; margin-top: 10px; overflow: hidden; border-radius: 999px; background: var(--surface-2); }
.progress i { display: block; height: 100%; border-radius: inherit; background: var(--primary); }

.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.month-nav strong { font-size: 1.05rem; }
.month-nav a, .month-nav span.off { display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); text-decoration: none; font-size: 1.2rem; }
.month-nav span.off { opacity: 0.35; }

.chips { display: flex; gap: 8px; margin-bottom: 14px; overflow-x: auto; }
.chips a { flex: none; padding: 8px 14px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); font-size: 0.88rem; font-weight: 600; text-decoration: none; }
.chips a.on { border-color: var(--ink); background: var(--ink); color: var(--on-ink); }

.empty { padding: 26px 12px; color: var(--muted); text-align: center; }
.empty strong { display: block; margin-bottom: 4px; color: var(--text); }

.note-box { margin-top: 6px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: 0.83rem; }

.flash { display: flex; gap: 10px; margin-bottom: 14px; padding: 13px 15px; border-radius: 14px; background: var(--ok-soft); color: var(--ok); font-size: 0.92rem; font-weight: 600; }
.flash.error { background: var(--danger-soft); color: var(--danger); }
.flash.warn { background: var(--warn-soft); color: var(--warn); }

details.disclosure > summary { cursor: pointer; list-style: none; color: var(--primary-strong); font-size: 0.88rem; font-weight: 600; padding: 6px 0; }
details.disclosure > summary::-webkit-details-marker { display: none; }

/* Navegacion inferior */
.tabbar {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 10;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    max-width: 560px;
    margin: 0 auto;
    padding: 6px 6px calc(env(safe-area-inset-bottom) + 6px);
    border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(12px);
}

.tabbar a { position: relative; display: grid; justify-items: center; gap: 3px; min-height: 52px; padding: 7px 2px 4px; border-radius: 12px; color: var(--muted); font-size: 0.68rem; font-weight: 600; text-decoration: none; }
.tabbar svg { width: 24px; height: 24px; }
.tabbar a[aria-current="page"] { color: var(--primary-strong); }
.tabbar .dot { position: absolute; top: 5px; left: calc(50% + 8px); width: 9px; height: 9px; border: 2px solid var(--surface); border-radius: 50%; background: var(--primary); }

/* Login */
.auth { display: grid; align-content: center; min-height: 100dvh; max-width: 420px; margin: 0 auto; padding: 24px 20px; }
.auth-brand { display: grid; justify-items: center; gap: 12px; margin-bottom: 26px; text-align: center; }
.auth-brand img { width: 96px; height: 96px; border: 1px solid var(--border); border-radius: 22px; background: #fff; }
.auth-brand h1 { font-size: 1.6rem; letter-spacing: -0.02em; }
.auth-brand p { color: var(--muted); font-size: 0.92rem; }
.auth-foot { margin-top: 16px; font-size: 0.88rem; text-align: center; }

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

/* Desglose de salario */
.salary-head, .salary-row { display: grid; grid-template-columns: minmax(0, 1fr) 88px 96px; gap: 8px; align-items: baseline; }
.salary-head { padding-bottom: 8px; color: var(--muted); font-size: 0.74rem; font-weight: 600; text-align: right; }
.salary-row { padding: 10px 0; border-top: 1px solid var(--border); font-size: 0.9rem; }
.salary-label small { display: block; color: var(--muted); font-size: 0.76rem; }
.salary-num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.salary-row.total { font-weight: 700; }
.salary-row.strong .salary-label, .salary-row.strong .salary-num { font-weight: 700; }
.salary-row.muted { color: var(--muted); }

/* Campana de avisos y casilla de aceptacion */
.topbar .bell { position: relative; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; color: var(--text); }
.topbar .bell svg { width: 24px; height: 24px; }
.bell-count { position: absolute; top: 4px; right: 2px; min-width: 18px; padding: 1px 5px; border-radius: 999px; background: var(--primary); color: var(--on-primary); font-size: 0.68rem; font-weight: 700; line-height: 1.4; text-align: center; }
.check { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 14px; font-size: 0.92rem; }
.check input { width: 22px; height: 22px; margin-top: 1px; flex: none; accent-color: var(--primary); }
