:root {
  --bg: #0f1720;
  --surface: #ffffff;
  --ink: #1a2430;
  --muted: #667085;
  --line: #e4e8ee;
  --brand: #1f6feb;
  --brand-ink: #ffffff;
  --ok: #1a7f4b;
  --err: #b42318;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: #f5f7fa;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 56px;
  background: var(--bg);
  color: #fff;
}
.brand { color: #fff; text-decoration: none; font-weight: 700; letter-spacing: .2px; }
.topbar-nav { display: flex; align-items: center; gap: 16px; }
.who { color: #b9c2cd; font-size: 13px; }
.logout-form { margin: 0; }
.linkbtn {
  background: none; border: 0; color: #b9c2cd; cursor: pointer;
  font: inherit; text-decoration: underline; padding: 0;
}
.linkbtn:hover { color: #fff; }

/* R5: one page shell for the whole app — wide enough for ERP tables; the
   card contains anything wider with its own scroll region. */
.wrap { max-width: 1200px; margin: 32px auto; padding: 0 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px;
  box-shadow: 0 1px 2px rgba(16,24,40,.04);
  overflow-x: auto;  /* R5: tables never spill past the card edge */
}
.card.auth { max-width: 420px; margin: 48px auto; }

h1 { font-size: 22px; margin: 0 0 6px; }
h2 { font-size: 16px; margin: 24px 0 4px; }
.muted { color: var(--muted); margin-top: 0; }

dl.status {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 20px;
  margin: 12px 0;
}
dl.status dt { color: var(--muted); }
dl.status dd { margin: 0; font-weight: 600; }

.actions { margin-top: 20px; display: flex; gap: 10px; flex-wrap: wrap; }
.btn {
  display: inline-block;
  background: var(--brand);
  color: var(--brand-ink);
  border: 0; border-radius: 8px;
  padding: 9px 16px;
  font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer;
}
.btn.secondary { background: #eef2f7; color: var(--ink); }
.btn:hover { filter: brightness(1.05); }

.field { display: block; margin: 14px 0; font-weight: 600; }
.field input, form p input {
  display: block; width: 100%; margin-top: 6px;
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font: inherit;
}

.qr { width: 200px; height: 200px; display: block; margin: 12px 0; image-rendering: pixelated; }
.secret { display: block; word-break: break-all; background: #f5f7fa; padding: 8px; border-radius: 6px; margin-top: 8px; font-size: 12px; }

.messages { list-style: none; max-width: 1200px; margin: 16px auto 0; padding: 0 16px; }
.msg { padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; }
.msg.success { background: #e7f6ee; color: var(--ok); }
.msg.error { background: #fdeceb; color: var(--err); }

/* --- M1: list/detail page furniture --- */
.wrap.wide { max-width: 1200px; }  /* legacy opt-in — same as default now */

.toolbar { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar form.search { display: flex; gap: 8px; flex: 1; max-width: 360px; margin: 0; }
.toolbar form.search input { flex: 1; padding: 8px 11px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }

table.list { width: 100%; border-collapse: collapse; margin-top: 8px; }
table.list th, table.list td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
table.list th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
table.list tr:hover td { background: #f8fafc; }
table.list a { color: var(--brand); text-decoration: none; font-weight: 600; }
table.list a:hover { text-decoration: underline; }
td.row-actions { text-align: right; white-space: nowrap; }
td.row-actions a, td.row-actions button { font-weight: 400; font-size: 13px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eef2f7; color: var(--ink); }
.badge.ok { background: #e7f6ee; color: var(--ok); }
.badge.warn { background: #fef4e6; color: #b25e09; }
.badge.err { background: #fdeceb; color: var(--err); }
.badge.off { background: #eef2f7; color: var(--muted); }

form p select, form p textarea, .field select, .field textarea {
  display: block; width: 100%; margin-top: 6px;
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font: inherit;
  background: #fff;
}
form p { margin: 12px 0; font-weight: 600; }
form p .helptext { display: block; font-weight: 400; color: var(--muted); font-size: 13px; margin-top: 4px; }
form p input[type="checkbox"] { display: inline-block; width: auto; margin-right: 8px; vertical-align: middle; }
.errorlist { color: var(--err); list-style: none; padding: 0; margin: 4px 0; font-weight: 400; font-size: 13px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
.form-grid .span2 { grid-column: 1 / -1; }

.pagination { display: flex; gap: 12px; margin-top: 16px; align-items: center; color: var(--muted); font-size: 13px; }
.btn.danger { background: var(--err); }
.empty { color: var(--muted); padding: 24px 0; text-align: center; }
.crumbs { font-size: 13px; margin-bottom: 10px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--brand); }
.navlink { color: #b9c2cd; text-decoration: none; font-size: 14px; }
.navlink:hover { color: #fff; }

/* --- M6: kiosk (touch-first; hours only) --- */
.kiosk-loading { padding: 40px; text-align: center; color: var(--muted); font-size: 18px; }
.kiosk-status { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; font-weight: 600; }
.kiosk-errors { margin-bottom: 12px; }
.kiosk-h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 0 0 10px; }
.kiosk-ops { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.kiosk-btn { border: 0; border-radius: 14px; font: inherit; cursor: pointer; padding: 18px; text-align: left; min-height: 96px; }
.kiosk-btn-in { background: #eef4ff; border: 2px solid var(--brand); display: flex; flex-direction: column; gap: 4px; }
.kiosk-btn-in:active { background: var(--brand); color: #fff; }
.kiosk-op-job { font-size: 20px; font-weight: 800; }
.kiosk-op-desc { font-weight: 600; }
.kiosk-op-wc { color: var(--muted); font-size: 13px; }
.kiosk-btn-in:active .kiosk-op-wc { color: #dbe7ff; }
.kiosk-open { text-align: center; padding: 22px; border: 2px solid var(--ok); border-radius: 16px; background: #f2fbf6; }
.kiosk-open-label { color: var(--ok); font-weight: 800; letter-spacing: 1.5px; }
.kiosk-open-job { font-size: 18px; font-weight: 700; margin: 6px 0; }
.kiosk-elapsed { font-size: 56px; font-weight: 800; font-variant-numeric: tabular-nums; margin: 8px 0 16px; }
.kiosk-btn-out { background: var(--err); color: #fff; font-size: 24px; font-weight: 800; width: 100%; max-width: 420px; min-height: 72px; text-align: center; }

/* R6: clickable column sorting */
table.list th a { color: var(--muted); text-decoration: none; font-weight: 600; }
table.list th a:hover { color: var(--text); text-decoration: none; }
table.list th a.sorted { color: var(--text); }

/* --- R40a/R41 a1: kiosk due badges, break/resume --- */
.kiosk-op-due { font-size: 12px; font-weight: 700; }
.kiosk-op-due.late { color: var(--err); }
.kiosk-op-due.soon { color: #b25e09; }
.kiosk-op-due.ok { color: var(--muted); }
.kiosk-btn-in:active .kiosk-op-due { color: #fff; }
.kiosk-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.kiosk-btn-break { background: #b25e09; color: #fff; font-size: 20px; font-weight: 800; min-height: 72px; min-width: 220px; text-align: center; }
.kiosk-resume { margin-bottom: 18px; }
.kiosk-btn-resume { border-color: var(--ok); background: #f2fbf6; width: 100%; }

/* --- R42a: Shop Board --- */
.board-summary { display: flex; gap: 12px; flex-wrap: wrap; margin: 6px 0 16px; }
.board-stat { flex: 1; min-width: 130px; background: #f2f5f9; border-radius: 12px; padding: 12px 14px; }
.board-stat.late { background: #fdeceb; }
.board-stat.soon { background: #fef4e6; }
.board-stat-n { font-size: 28px; font-weight: 800; line-height: 1; }
.board-stat-l { color: var(--muted); font-size: 12px; margin-top: 4px; text-transform: uppercase; letter-spacing: .4px; }
table.list.board .board-job { font-weight: 700; }
table.list.board .board-row.late .board-due { color: var(--err); font-weight: 700; }
table.list.board .board-row.soon .board-due { color: #b25e09; font-weight: 700; }
.board-progress { display: inline-block; width: 90px; height: 10px; border-radius: 999px; background: #e3e8ef; vertical-align: middle; overflow: hidden; }
.board-progress-bar { display: block; height: 100%; background: var(--brand); }

/* Shop Board panels (R42, Wave D) */
.board-panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin-top: 18px; }
.board-panel { background: #f2f5f9; border-radius: 12px; padding: 12px 14px; }
.board-panel h3 { margin: 0 0 8px; font-size: 14px; text-transform: uppercase; letter-spacing: .4px; }
.board-panel h3 .muted { font-weight: 400; text-transform: none; letter-spacing: 0; }
.board-panel ul { list-style: none; margin: 0; padding: 0; }
.board-panel li { padding: 4px 0; border-bottom: 1px solid rgba(0,0,0,.06); font-size: 14px; }
.board-panel li:last-child { border-bottom: 0; }
/* Kiosk (Wave D): auto clock-out warning + badge scan */
.kiosk-warning { background: #fef4e6; border: 1px solid #f0c080; color: #7a4b00; border-radius: 10px; padding: 12px 14px; margin: 10px 0 14px; font-size: 16px; }
.kiosk-scan input[type=password], .kiosk-scan input[type=text] { font-size: 28px; padding: 14px; width: 100%; box-sizing: border-box; }
