/* PPMS_Light UI. Self-contained: no CDN or external fonts. */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --ink: #1d2430;
  --muted: #667085;
  --line: #d9dee6;
  --accent: #1f4e79;
  --accent-ink: #ffffff;
  --accent-soft: #e6eef6;
  --ok: #1e7b4f;
  --warn: #9a6200;
  --err: #b42318;
  --radius: 6px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 15px;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--accent); }
h1 { font-size: 1.45rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); }

.topbar { display: flex; align-items: center; gap: 1.5rem; padding: .6rem 1.25rem; background: var(--accent); color: var(--accent-ink); }
.topbar a, .topbar button.link { color: var(--accent-ink); }
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; font-weight: 600; white-space: nowrap; }
.brand img { height: 30px; width: auto; border-radius: 4px; }
.topnav { display: flex; gap: .25rem; flex: 1; }
.menu-link { padding: .35rem .7rem; border-radius: var(--radius); text-decoration: none; }
.menu-link:hover, .menu-link.on { background: rgba(255,255,255,.15); }
.user { display: flex; align-items: center; gap: .75rem; white-space: nowrap; }

.page { max-width: 1100px; margin: 0 auto; padding: 1.25rem; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.btn { display: inline-block; padding: .45rem .9rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); text-decoration: none; font: inherit; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; }

.flash { padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid; }
.flash-success, .flash-info { background: #ecf7f1; border-color: #a6dcc0; color: var(--ok); }
.flash-warning { background: #fff7e6; border-color: #f2d08a; color: var(--warn); }
.flash-error { background: #fdeeec; border-color: #f2b8b2; color: var(--err); }

input, select, textarea { font: inherit; padding: .45rem .55rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); width: 100%; }
input[type=checkbox] { width: auto; }
.check { display: inline-flex; gap: .4rem; align-items: center; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.grid { width: 100%; border-collapse: collapse; }
.grid th, .grid td { padding: .5rem .7rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.grid th { background: #eef1f5; font-weight: 600; font-size: .9rem; }
.grid tr.inactive td { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem 1.25rem; background: var(--surface); padding: 1.25rem; border: 1px solid var(--line); border-radius: var(--radius); }
.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
.field.wide { grid-column: 1 / -1; }
.field .hint { margin: .3rem 0 0; color: var(--muted); font-size: .85rem; }
.field .error { margin: .3rem 0 0; color: var(--err); font-size: .85rem; }
.field.has-error input, .field.has-error select { border-color: var(--err); }
.form-actions { grid-column: 1 / -1; display: flex; gap: .6rem; }
.logo-preview { max-height: 60px; display: block; margin-bottom: .4rem; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; margin-top: 1rem; }
.tile { display: flex; flex-direction: column; gap: .3rem; padding: 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink); }
.tile:hover { border-color: var(--accent); }
.tile strong { color: var(--accent); }

.login { max-width: 360px; margin: 10vh auto; background: var(--surface); padding: 2rem; border: 1px solid var(--line); border-radius: var(--radius); text-align: center; }
.login img { height: 56px; margin-bottom: .5rem; }
.login h1 { color: var(--accent); }
.stack { display: flex; flex-direction: column; gap: .9rem; text-align: left; }
.stack label { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; font-size: .9rem; }

.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600; border: 1px solid var(--line); background: #f2f4f7; color: var(--muted); }
.badge-ok { color: var(--ok); border-color: #a6dcc0; background: #ecf7f1; }
.badge-err { color: var(--err); border-color: #f2b8b2; background: #fdeeec; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 1rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; margin: 1rem 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; }
.stat-label { color: var(--muted); font-size: .88rem; }
.stat-value { font-size: 1.9rem; font-weight: 600; margin-top: .15rem; }
.stat-sub { color: var(--muted); font-size: .82rem; margin-top: .2rem; }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 1rem; margin-bottom: 1rem; }

form.inline { display: inline; }
.row-actions { display: flex; gap: .8rem; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filters input, .filters select { width: auto; min-width: 180px; }
.pager { display: flex; gap: 1rem; }
.details { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1.5rem; margin: 0 0 .75rem; }
.details dt { font-weight: 600; color: var(--muted); }
.details dd { margin: 0; }
h2 { font-size: 1.15rem; margin: 1.25rem 0 .5rem; }

/* QR label sheet: A4, 3 columns x 8 rows of 70 x 37 mm labels */
.label-body { background: #fff; }
.label-toolbar { display: flex; gap: 1rem; align-items: center; padding: .75rem 1rem; border-bottom: 1px solid var(--line); }
.label-sheet { display: grid; grid-template-columns: repeat(3, 70mm); grid-auto-rows: 37mm; width: 210mm; margin: 0 auto; }
.label { display: flex; align-items: center; gap: 3mm; padding: 3mm; overflow: hidden; border: 1px dashed #ccc; break-inside: avoid; }
.label-qr { flex: 0 0 28mm; height: 28mm; }
.label-qr svg { width: 100%; height: 100%; display: block; }
.label-text { min-width: 0; font-size: 9pt; line-height: 1.25; }
.label-title { font-weight: 700; font-size: 12pt; word-break: break-all; }
.label-line { overflow: hidden; text-overflow: ellipsis; }
@page { size: A4; margin: 0; }
@media print {
  .no-print { display: none; }
  .label { border-color: transparent; }
  .label-sheet { margin: 0; }
}

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: .5rem; }
}

/* Station scan screens: large touch targets, colour + text feedback */
.station-menu { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; margin-top: 1rem; }
.big-btn { display: flex; align-items: center; justify-content: center; min-height: 64px; padding: .9rem 1.2rem; font-size: 1.35rem; font-weight: 600; border: 0; border-radius: 10px; color: #fff; background: var(--accent); text-decoration: none; cursor: pointer; text-align: center; }
.station-menu .big-btn { min-height: 130px; font-size: 1.7rem; }
.big-btn:disabled { opacity: .55; cursor: default; }
.big-in { background: var(--ok); }
.big-reg { background: var(--accent); }
.big-pause { background: var(--warn); }
.big-out { background: #5b4b8a; }
.big-cam, .big-go { background: var(--accent); }
.big-submit { background: var(--ok); width: 100%; margin-top: 1rem; }
.scan-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.scan-menu { min-height: 48px; display: inline-flex; align-items: center; }
.banner { padding: 1rem 1.2rem; border-radius: 10px; font-size: 1.25rem; font-weight: 600; margin: .75rem 0; }
.banner-info { background: var(--accent-soft); color: var(--accent); }
.banner-ok { background: #d9f2e4; color: #0f5a37; border: 2px solid var(--ok); }
.banner-err { background: #fde4e1; color: #8a1a10; border: 2px solid var(--err); }
.worker-card { padding: .6rem 1rem; background: var(--accent-soft); border-radius: 10px; font-size: 1.15rem; margin-bottom: .75rem; }
.state-pill { margin-left: .5rem; padding: .15rem .6rem; border-radius: 999px; font-size: .9rem; color: #fff; background: var(--muted); }
.state-clocked_in { background: var(--ok); }
.state-paused { background: var(--warn); }
.step-label { font-size: 1.1rem; font-weight: 600; margin: .5rem 0; }
.cam { max-width: 480px; margin: .5rem 0; background: #000; border-radius: 10px; overflow: hidden; }
.cam video { width: 100%; display: block; }
.big-cam { margin: .5rem 0; width: 100%; max-width: 480px; }
.manual-form { display: flex; gap: .6rem; margin-top: .5rem; }
.manual-form input, .note-label input, .qty-row input { font-size: 1.3rem; padding: .8rem; min-height: 60px; border: 2px solid var(--line); border-radius: 10px; width: 100%; }
.manual-form input { flex: 1; }
.manual-form .big-btn { min-width: 100px; }
.note-label { display: block; margin-top: .75rem; font-weight: 600; }
.qty-area label { font-weight: 600; display: block; margin-top: .75rem; }
.item-card { font-size: 1.3rem; font-weight: 600; padding: .6rem 1rem; background: var(--accent-soft); border-radius: 10px; }
.item-figure { margin: 0 0 .6rem; display: flex; justify-content: center; }
.item-img, .item-noimg { width: 100%; max-width: 360px; height: 220px; border-radius: 10px; }
.item-img { object-fit: contain; background: #f4f5f7; border: 1px solid var(--border, #d9dce1); }
.item-img[hidden], .item-noimg[hidden] { display: none; }
.item-noimg { display: flex; align-items: center; justify-content: center; color: var(--muted); background: #f4f5f7; border: 2px dashed #c5c9d1; }
.item-thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 4px; vertical-align: middle; }
.item-thumb-lg { width: auto; height: auto; max-width: 240px; max-height: 240px; object-fit: contain; display: block; margin-bottom: .5rem; }
.inline-form { display: flex; gap: .5rem; align-items: center; margin-top: .5rem; flex-wrap: wrap; }
.qty-row { display: flex; gap: .6rem; align-items: stretch; margin-top: .4rem; }
.qty-row input { text-align: center; font-size: 1.8rem; }
.qty-btn { min-width: 80px; font-size: 2rem; }
.recent-list { list-style: none; padding: 0; margin: .4rem 0 0; font-family: ui-monospace, Consolas, monospace; font-size: 1rem; }
.recent-list li { padding: .4rem 0; border-bottom: 1px solid var(--line); }
.recent-list li.cancelled { text-decoration: line-through; color: var(--muted); }
.done-area, #retry-area { margin-top: 1rem; }

/* Reports */
.tabs { display: flex; gap: .25rem; flex-wrap: wrap; }
.tabs a { padding: .35rem .8rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); text-decoration: none; }
.tabs a.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.report-nav { margin-bottom: .75rem; }
.rpt-filters { align-items: center; gap: 1rem; }
.rpt-filters label { display: inline-flex; align-items: center; gap: .3rem; }
.rpt-filters input[type=date] { min-width: 0; }
.rpt-range { font-weight: 400; font-size: 1rem; }
.grid tfoot th { background: #eef1f5; border-top: 2px solid var(--line); }
