:root {
  --bg: #f4f5f7; --card: #fff; --text: #1d2229; --muted: #6b7280; --line: #e2e5ea;
  --accent: #1f6feb; --ok: #15803d; --warn: #b45309; --bad: #b91c1c;
}
* { box-sizing: border-box; min-width: 0; }
html, body { margin: 0; }
body { font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); 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 .6rem; }
h3 { font-size: 1rem; margin: 1.25rem 0 .5rem; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
code { font-size: .9em; word-break: break-all; }
pre { white-space: pre-wrap; word-break: break-word; }

/* ------------------------------------------------------------- layout: full width */
.container { width: 100%; max-width: 1920px; margin: 0 auto; padding: 1.25rem clamp(1rem, 2vw, 2rem) 3rem; }

.topbar { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; background: #111827; color: #fff; padding: .6rem clamp(1rem, 2vw, 2rem); }
.topbar .brand { color: #fff; font-weight: 700; white-space: nowrap; }
.topbar nav { display: flex; gap: .2rem; flex-wrap: wrap; }
.topbar nav a { color: #cbd5e1; padding: .35rem .6rem; border-radius: 6px; white-space: nowrap; }
.topbar nav a.active, .topbar nav a:hover { background: #1f2937; color: #fff; text-decoration: none; }
.topbar .user { margin-left: auto; color: #cbd5e1; font-size: .9rem; white-space: nowrap; }
.topbar .user a { color: #fff; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.25rem; margin-bottom: 1rem; overflow-x: auto; }

/* Cards side by side; each at least 320px, as many across as fit. */
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); align-items: start; }
.grid > .card { margin-bottom: 0; }
/* Main + side column (e.g. a big form next to small panels). */
.layout { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 960px) { .layout { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); } .layout.even { grid-template-columns: 1fr 1fr; } }
.layout > .card { margin-bottom: 0; }
.stack > .card { margin-bottom: 1rem; }
.stack > .card:last-child { margin-bottom: 0; }
.wide { grid-column: 1 / -1; }

/* Form fields: a responsive grid, so nothing overlaps at any width. */
.fields { display: grid; gap: .6rem 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); margin-bottom: .75rem; }
.field { display: flex; flex-direction: column; gap: .2rem; }
.field.span-2 { grid-column: span 2; }
.field.span-all { grid-column: 1 / -1; }
@media (max-width: 480px) { .field.span-2 { grid-column: span 1; } }
.checks { display: flex; flex-wrap: wrap; gap: .3rem 1rem; padding: .45rem 0; }

/* Older inline rows (filters, short forms) */
.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 180px; margin: 0 0 .5rem; }
.row > .shrink { flex: 0 0 auto; }
form p { margin: 0 0 .75rem; }

/* ------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
th, td { text-align: left; padding: .55rem .75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #f9fafb; font-weight: 600; font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; white-space: nowrap; }
/* Long lists: the heading row stays visible while scrolling down. Needs the wrapper not to
   be a scroll container, so on wide screens .table-wrap.sticky lets the table use the page. */
table.sticky { overflow: visible; }
.sticky th { position: sticky; top: 0; z-index: 2; box-shadow: 0 1px 0 var(--line); }
@media (min-width: 1100px) { .table-wrap.sticky { overflow: visible; } }
td.wrap { word-break: break-word; }
td.nowrap { white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.weekend td { background: #fafafa; }
.card table { border-radius: 6px; }

/* ------------------------------------------------------------- controls */
label { display: block; font-size: .85rem; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=datetime-local], input[type=month], input[type=number], input[type=tel], input[type=file], select, textarea {
  width: 100%; max-width: 100%; padding: .5rem .6rem; border: 1px solid #cbd2db; border-radius: 6px; font: inherit; background: #fff; color: var(--text);
}
input[type=file] { padding: .35rem; }
textarea { min-height: 60px; resize: vertical; }
.check { display: inline-flex; align-items: center; gap: .45rem; font-size: .95rem; color: var(--text); }
.check input { flex: 0 0 auto; }
.checks .check { white-space: nowrap; }
.check input { width: auto; margin: 0; }

button, .btn { display: inline-block; padding: .5rem .9rem; border-radius: 6px; border: 1px solid var(--accent); background: var(--accent); color: #fff; font: inherit; cursor: pointer; white-space: nowrap; line-height: 1.3; }
button:hover, .btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn-secondary { background: #fff; color: var(--text); border-color: #cbd2db; }
.btn-danger { background: var(--bad); border-color: var(--bad); }
.btn-sm { padding: .25rem .55rem; font-size: .85rem; }
form.inline { display: inline; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-top: .5rem; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge-in { background: #dcfce7; color: var(--ok); }
.badge-out { background: #e5e7eb; color: #374151; }
.badge-warn { background: #fef3c7; color: var(--warn); }
.badge-bad { background: #fee2e2; color: var(--bad); }
.badge-src { background: #e0e7ff; color: #3730a3; }
.badge-brk { background: #fde68a; color: #92400e; }

.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid; }
.flash-ok { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.flash-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

.stat { font-size: 2rem; font-weight: 700; }
.login-box { max-width: 380px; margin: 4rem auto; }
.toolbar { display: flex; gap: .5rem 1rem; flex-wrap: wrap; align-items: center; margin-bottom: .75rem; }
.toolbar .spacer { flex: 1; }

/* ------------------------------------------------------------- kiosk */
body.kiosk { background: #0b1220; color: #fff; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; user-select: none; }
.kbar { display: flex; justify-content: space-between; align-items: center; gap: .5rem 1.5rem; flex-wrap: wrap; padding: .8rem 1.25rem; color: #93a4c3; font-size: clamp(.95rem, 2.2vw, 1.2rem); border-bottom: 1px solid #1c2740; }
.kbar strong { color: #e5e9f2; font-weight: 600; }
.kbar-dev { margin-left: .6rem; opacity: .7; }
.kbar-clock { display: flex; gap: .8rem; font-variant-numeric: tabular-nums; white-space: nowrap; margin-left: auto; }
.kbar-clock #clock { color: #e5e9f2; }
.kmain { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 1.5rem; }
.kiosk .prompt { font-size: clamp(2.2rem, 9vw, 4rem); font-weight: 700; margin: 0 0 .5rem; line-height: 1.1; }
.kiosk .status { font-size: clamp(1.1rem, 3.5vw, 1.6rem); color: #93a4c3; }
.kiosk .hint { margin-top: 1.5rem; color: #4b5b78; font-size: .95rem; max-width: 28rem; }
.kiosk .result { display: none; padding: clamp(1.25rem, 5vw, 2.5rem) clamp(1.25rem, 6vw, 3.5rem); border-radius: 24px; width: min(92vw, 44rem); }
.kiosk .result.show { display: block; }
.kiosk .result.in { background: #14532d; }
.kiosk .result.out { background: #1e3a8a; }
.kiosk .result.error { background: #7f1d1d; }
.kiosk .result.brk { background: #92400e; }
/* "Break or clock out?" question after a tap */
.choice { display: none; width: min(94vw, 46rem); background: #111c33; border: 2px solid #2b3a5c; border-radius: 24px; padding: clamp(1rem, 4vw, 2rem); }
.choice.show { display: block; }
.choice-name { font-size: clamp(1.6rem, 7vw, 2.8rem); font-weight: 700; line-height: 1.15; }
.choice-state { color: #93a4c3; font-size: clamp(1rem, 3.5vw, 1.3rem); margin: .3rem 0 1.2rem; }
.choice-buttons { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); gap: 1rem; }
.choice-btn { font-size: clamp(1.3rem, 5vw, 2rem); font-weight: 700; padding: clamp(1rem, 4vw, 1.6rem) 1rem; border-radius: 18px; border: 3px solid transparent; color: #fff; }
.choice-btn.c-out { background: #1e3a8a; }
.choice-btn.c-brk { background: #b45309; }
.choice-btn.c-in { background: #14532d; }
.choice-btn:first-child { border-color: rgba(255,255,255,.55); }
.choice-bar { height: 6px; background: #1c2740; border-radius: 3px; margin-top: 1.2rem; overflow: hidden; }
.choice-bar div { height: 100%; background: #93a4c3; width: 100%; transition: width .1s linear; }
.choice-hint { color: #6b7a99; font-size: .9rem; margin-top: .5rem; }
.kiosk .result .name { font-size: clamp(1.8rem, 8vw, 3.4rem); font-weight: 700; line-height: 1.15; overflow-wrap: anywhere; }
.kiosk .result .action { font-size: clamp(1.3rem, 5vw, 2.2rem); margin-top: .5rem; }
.kiosk .result .time { font-size: clamp(1rem, 4vw, 1.6rem); color: #d1d5db; margin-top: .25rem; }
.kiosk .nfc-btn { margin-top: 1.5rem; font-size: 1.3rem; padding: .9rem 1.6rem; }
.kiosk .uidinput { position: absolute; opacity: 0; width: 1px; height: 1px; }
.kfoot { padding: 1rem; text-align: center; color: #4b5b78; font-size: .85rem; }
