:root {
    --bg: #f5f7fb; --card: #fff; --text: #0f172a; --muted: #64748b; --line: #e2e8f0;
    --brand: #2563eb; --brand-dark: #1d4ed8; --ok: #16a34a; --warn: #d97706; --bad: #dc2626;
    --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .75rem; }
small, .muted { color: var(--muted); }

.topbar { display: flex; align-items: center; gap: 1.5rem; padding: .6rem 1.25rem; background: var(--text); color: #fff; flex-wrap: wrap; }
.topbar a { color: #cbd5e1; }
.topbar .brand { color: #fff; font-weight: 700; font-size: 1.1rem; }
.topbar .brand small { color: #94a3b8; font-weight: 400; font-size: .85rem; margin-left: .4rem; }
.topbar nav { display: flex; gap: 1rem; flex: 1; flex-wrap: wrap; }
.topbar nav a.active { color: #fff; font-weight: 600; }
.topbar .me { display: flex; gap: 1rem; align-items: center; }
.topbar .me form { margin: 0; }

/* Menú lateral (panel de empresa y administración) */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 240px; flex: 0 0 240px; background: #0f172a; color: #cbd5e1; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sb-head { padding: 1.1rem 1.1rem .9rem; border-bottom: 1px solid #1e293b; }
.sb-head .brand { color: #fff; font-weight: 700; font-size: 1.15rem; }
.sb-head .brand:hover { text-decoration: none; }
.sb-sub { color: #94a3b8; font-size: .85rem; margin-top: .1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-nav { flex: 1; padding: .75rem .6rem; }
.sb-title { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: #64748b; padding: 1.1rem .6rem .35rem; }
.sb-link { display: flex; align-items: center; gap: .65rem; width: 100%; padding: .5rem .6rem; margin-bottom: 2px; border: 0; border-radius: 8px; background: none; color: #cbd5e1; font: inherit; font-size: .93rem; text-align: left; cursor: pointer; }
.sb-link:hover { background: #1e293b; color: #fff; text-decoration: none; }
.sb-link.active { background: var(--brand); color: #fff; font-weight: 600; }
.sb-link svg { flex: 0 0 18px; opacity: .9; }
.sb-link .count { margin-left: auto; min-width: 1.4rem; text-align: center; background: var(--bad); color: #fff; border-radius: 99px; font-size: .72rem; font-weight: 700; padding: .05rem .4rem; }
.sb-foot { border-top: 1px solid #1e293b; padding: .6rem; }
.sb-foot form { margin: 0; }
.sb-user { padding: .25rem .6rem .45rem; font-size: .85rem; color: #94a3b8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shell-main { flex: 1; min-width: 0; }
.impersonating { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: .6rem 1.25rem; background: #fef3c7; color: #92400e; border-bottom: 1px solid #fcd34d; font-size: .92rem; }
.impersonating form { margin: 0; }
.impersonating .btn { background: #92400e; }
.mobilebar, .sb-backdrop { display: none; }
@media (max-width: 900px) {
    .sidebar { position: fixed; top: 0; bottom: 0; left: 0; height: auto; z-index: 50; transform: translateX(-100%); transition: transform .2s ease; }
    body.sb-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .35); }
    body.sb-open .sb-backdrop { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .5); z-index: 40; }
    .mobilebar { display: flex; align-items: center; gap: .6rem; padding: .55rem 1rem; background: #0f172a; color: #fff; position: sticky; top: 0; z-index: 30; }
    .mobilebar .brand { font-weight: 700; }
    .mobilebar small { color: #94a3b8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .menu-btn { display: flex; background: none; border: 0; color: #fff; padding: .3rem; cursor: pointer; }
    .menu-btn svg { width: 22px; height: 22px; }
}

.container { max-width: 1150px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }
.narrow { max-width: 460px; margin: 3rem auto; padding: 0 1.25rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; }
.row { display: flex; gap: 1rem; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 180px; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.stat b { display: block; font-size: 1.8rem; }

label { display: block; font-weight: 600; margin-bottom: .25rem; font-size: .9rem; }
input, select, textarea { width: 100%; padding: .55rem .65rem; border: 1px solid #cbd5e1; border-radius: 8px; font: inherit; background: #fff; }
input[type=checkbox] { width: auto; margin-right: .4rem; }
.check { display: flex; align-items: center; font-weight: 400; }
.field { margin-bottom: 1rem; }
.hint { font-size: .85rem; color: var(--muted); margin-top: .2rem; }

.btn, button.btn { display: inline-block; border: 0; border-radius: 8px; padding: .6rem 1rem; font: inherit; font-weight: 600; cursor: pointer; background: var(--brand); color: #fff; text-decoration: none; }
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn.secondary { background: #e2e8f0; color: var(--text); }
.btn.danger { background: var(--bad); }
.btn.small { padding: .3rem .6rem; font-size: .85rem; }
button.link { background: none; border: 0; color: #cbd5e1; cursor: pointer; font: inherit; padding: 0; }

table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { padding: .55rem .6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.voided td { text-decoration: line-through; color: var(--muted); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }

.badge { display: inline-block; padding: .1rem .5rem; border-radius: 99px; font-size: .78rem; font-weight: 600; background: #e2e8f0; }
.badge.ok { background: #dcfce7; color: #166534; }
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.bad { background: #fee2e2; color: #991b1b; }
.badge.info { background: #dbeafe; color: #1e40af; }
.pos { color: var(--ok); } .neg { color: var(--bad); }

.alert { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.alert.ok { background: #dcfce7; color: #166534; }
.alert.error { background: #fee2e2; color: #991b1b; }
.alert.warn { background: #fef3c7; color: #92400e; }

.pagination { margin-top: 1rem; }
code.token { word-break: break-all; font-size: .8rem; background: #f1f5f9; padding: .2rem .35rem; border-radius: 4px; }

/* Fichaje (tablet y móvil) */
.punch-body { background: #0f172a; color: #fff; min-height: 100vh; }
.punch { max-width: 560px; margin: 0 auto; padding: 1.25rem; padding-top: max(1.25rem, env(safe-area-inset-top)); }
.punch header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.punch header a, .punch header button.link { color: #94a3b8; }
.clock { font-size: 3.5rem; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.clock-date { text-align: center; color: #94a3b8; margin-bottom: 1.25rem; text-transform: capitalize; }
.punch .panel { background: #1e293b; border-radius: 14px; padding: 1.25rem; margin-bottom: 1rem; }
.punch input { background: #0f172a; color: #fff; border-color: #334155; font-size: 1.4rem; text-align: center; padding: .75rem; }
.punch label { color: #cbd5e1; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.actions button { border: 0; border-radius: 12px; padding: 1.3rem .5rem; font: inherit; font-size: 1.15rem; font-weight: 700; color: #fff; cursor: pointer; }
.actions button:disabled { opacity: .25; cursor: not-allowed; }
.act-in { background: #16a34a; } .act-out { background: #dc2626; }
.act-break_start { background: #d97706; } .act-break_end { background: #2563eb; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-top: .75rem; }
.keypad button { background: #334155; color: #fff; border: 0; border-radius: 10px; font-size: 1.5rem; padding: .8rem 0; cursor: pointer; }
.msg { border-radius: 12px; padding: 1rem; text-align: center; font-size: 1.1rem; margin-bottom: 1rem; display: none; }
.msg.show { display: block; }
.msg.ok { background: #166534; } .msg.error { background: #991b1b; } .msg.warn { background: #92400e; }
.net { font-size: .85rem; padding: .2rem .6rem; border-radius: 99px; background: #166534; }
.net.off { background: #92400e; }
.queue { font-size: .85rem; color: #fbbf24; text-align: center; margin-top: .5rem; }
.punch table { background: transparent; color: #e2e8f0; }
.punch th, .punch td { border-color: #334155; }
.punch .muted, .punch small { color: #94a3b8; }
.punch a.btn.secondary { background: #334155; color: #fff; }

@media print {
    .topbar, .sidebar, .mobilebar, .impersonating, .sb-backdrop, .no-print, form { display: none !important; }
    .shell { display: block; }
    body { background: #fff; font-size: 11px; }
    .container { padding: 0; max-width: none; }
    .card, .table-wrap { border: 0; padding: 0; }
}
