/* Allokis design system ("stock manifest").
   Brand palette: Ink structure, Paper surfaces, Harbor teal = brand/primary,
   Signal amber = low stock, green = confirmed movement, clay = checkout.
   Numbers/SKUs in mono. */

:root {
  --ink:        #14202B;  /* Ink: kiosk field, headers */
  --ink-2:      #1E2F3F;  /* raised ink panels */
  --paper:      #F6F4EF;  /* Paper: admin field */
  --surface:    #ffffff;  /* cards */
  --line:       #D9D5CC;  /* hairline rules */
  --text:       #1b2530;
  --muted:      #6b7683;
  --signal:     #E8A23A;  /* Signal amber: low stock, warnings */
  --signal-bg:  #fbf0da;
  --go:         #1f9d6b;  /* green: receive / return / confirmed */
  --go-bg:      #e4f4ec;
  --take:       #c65a3a;  /* clay: checkout */
  --take-bg:    #f7e7e0;
  --accent:     #0F5F5C;  /* primary action blue */
  --radius:     10px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  color: var(--text);
  background: var(--paper);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* mono utility for anything countable / scannable */
.mono, .qty, .sku, .badge-code { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* company logo inside any wordmark; scales with the wordmark's own size */
.wordmark .brand-logo { height: 1.25em; width: auto; vertical-align: middle; margin-right: .45em; border-radius: 4px; object-fit: contain; }
.wordmark .brand-name { vertical-align: middle; }
/* default Allokis logo (inline SVG; the wordmark follows the text color) */
.wordmark .allokis-logo { height: 1.3em; width: auto; display: inline-block; vertical-align: middle; }
.kiosk-head .wordmark { color: var(--k-text); }
.admin-top .wordmark { color: #eaf0f6; }

a { color: var(--accent); }
button { font-family: inherit; cursor: pointer; }

/* ---------- shared buttons ---------- */
.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  transition: transform .05s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-go { background: var(--go); border-color: var(--go); color: #fff; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 10px; font-size: 13px; }

/* =========================================================
   KIOSK  (public/kiosk.html): themeable, dark default + light override
   ========================================================= */
body.kiosk {
  /* dark theme (default) */
  --k-bg: #14202B;
  --k-panel: #1E2F3F;
  --k-text: #eaf0f6;
  --k-muted: #8aa0b6;
  --k-line: #2c3a4c;
  --k-line-2: #33475d;
  --k-field: #0f1822;
  --k-take-amt: #f0a58a;
  --k-return-amt: #7fd3ad;
  background: var(--k-bg);
  color: var(--k-text);
  min-height: 100vh;
  transition: background .2s ease, color .2s ease;
}
body.kiosk[data-theme="light"] {
  --k-bg: #f4f4f1;
  --k-panel: #ffffff;
  --k-text: #1b2530;
  --k-muted: #6b7683;
  --k-line: #e2e0d8;
  --k-line-2: #d8d5cc;
  --k-field: #f0efea;
  --k-take-amt: #c65a3a;
  --k-return-amt: #1f9d6b;
}
.kiosk-wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 24px 48px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.kiosk-head {
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--k-line); padding-bottom: 16px; margin-bottom: 28px;
}
.kiosk-head .wordmark { font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.kiosk-head .head-right { display: flex; align-items: center; gap: 14px; }
.kiosk-head .tagline { color: var(--k-muted); font-size: 12px; }
.theme-toggle {
  background: transparent; border: 1px solid var(--k-line-2); color: var(--k-muted);
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-size: 17px;
}
.theme-toggle:hover { color: var(--k-text); }

/* idle state: waiting for a badge */
.scan-prompt { text-align: center; margin: auto 0; }
.scan-prompt .icon {
  width: 96px; height: 96px; margin: 0 auto 24px;
  border: 3px solid var(--k-line-2); border-radius: 20px;
  display: grid; place-items: center; color: var(--k-muted);
}
.scan-prompt h1 { font-size: 30px; margin: 0 0 8px; font-weight: 800; letter-spacing: -.02em; }
.scan-prompt p { color: var(--k-muted); font-size: 17px; margin: 0; }
.scan-prompt .cam-btn { margin-top: 24px; }
.hidden-input { position: absolute; opacity: 0; pointer-events: none; height: 0; width: 0; }

/* session state: a tech is logged in */
.session-head {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--k-panel); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 20px;
}
.session-head .who { font-size: 22px; font-weight: 800; }
.session-head .who small { display:block; color:var(--k-muted); font-size:12px; font-weight:600; letter-spacing:.08em; text-transform:uppercase; }

/* mode toggle: Take vs Return */
.mode-toggle { display: flex; gap: 8px; }
.mode-toggle button {
  border: 2px solid var(--k-line-2); background: transparent; color: var(--k-text);
  padding: 12px 20px; border-radius: var(--radius); font-weight: 800; font-size: 15px;
}
.mode-toggle button.active.take { background: var(--take); border-color: var(--take); color:#fff; }
.mode-toggle button.active.return { background: var(--go); border-color: var(--go); color:#fff; }

.scan-line {
  background: var(--k-field); border: 1px dashed var(--k-line-2); border-radius: var(--radius);
  padding: 16px 20px; text-align: center; color: var(--k-muted); margin-bottom: 20px; font-size: 15px;
}
.scan-line b { color: var(--k-text); }

/* the running list of this session's scans */
.session-list { list-style: none; margin: 0; padding: 0; flex: 1; }
.session-list li {
  display: flex; align-items: center; gap: 14px;
  background: var(--k-panel); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 10px;
  animation: pop .18s ease;
}
@keyframes pop { from { transform: scale(.98); opacity: .4; } to { transform: scale(1); opacity: 1; } }
.session-list .thumb {
  width: 46px; height: 46px; border-radius: 8px; background: var(--k-field); object-fit: cover; flex: none;
}
.session-list .meta { flex: 1; min-width: 0; }
.session-list .meta .nm { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-list .meta .sub { color: var(--k-muted); font-size: 12px; }
.session-list .amt { font-size: 20px; font-weight: 800; }
.session-list .amt.take { color: var(--k-take-amt); }
.session-list .amt.return { color: var(--k-return-amt); }
.session-list .undo { color:var(--k-muted); background:none; border:none; font-size:12px; text-decoration: underline; }

.session-foot { display: flex; gap: 12px; margin-top: 20px; }
.session-foot .btn { flex: 1; padding: 16px; font-size: 17px; }

/* camera scan overlay (reusable) */
.cam-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.9); z-index: 100;
  display: none; flex-direction: column; align-items: center; justify-content: center; padding: 24px;
}
.cam-overlay.show { display: flex; }
.cam-overlay video { width: 100%; max-width: 460px; border-radius: 16px; background: #000; }
.cam-overlay .cam-frame { position: relative; width: 100%; max-width: 460px; }
.cam-overlay .cam-reticle {
  position: absolute; inset: 18% 10%; border: 3px solid rgba(255,255,255,.7); border-radius: 12px; pointer-events: none;
}
.cam-overlay .cam-msg { color: #fff; margin: 18px 0 0; text-align: center; max-width: 460px; font-size: 15px; }
.cam-overlay .cam-actions { margin-top: 20px; display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.cam-overlay .cam-manual { color: #cdd9e5; text-decoration: underline; background: none; border: none; font-size: 14px; cursor: pointer; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: #fff; color: var(--ink); padding: 14px 22px; border-radius: var(--radius);
  font-weight: 700; box-shadow: 0 8px 30px rgba(0,0,0,.35); opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.toast.err { background: var(--take); color: #fff; }


/* =========================================================
   ADMIN  (public/admin.html): paper, dense, workmanlike
   ========================================================= */
.admin-top {
  background: var(--ink); color: #eaf0f6;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px;
}
.admin-top .wordmark { font-weight: 800; letter-spacing: -.02em; font-size: 18px; }
.admin-top nav { display: flex; gap: 4px; flex-wrap: wrap; }
.admin-top nav button {
  background: transparent; border: none; color: #b9c6d4; padding: 8px 14px;
  border-radius: 8px; font-weight: 600; font-size: 14px;
}
.admin-top nav button.active { background: var(--ink-2); color: #fff; }
.admin-top .whoami { font-size: 13px; color: #8aa0b6; }

.admin-body { max-width: 1080px; margin: 0 auto; padding: 28px 24px 64px; }
.page-title { font-size: 24px; font-weight: 800; letter-spacing: -.02em; margin: 0 0 4px; }
.page-sub { color: var(--muted); margin: 0 0 24px; font-size: 14px; }
.tab { display: none; }
.tab.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin-bottom: 20px;
}
.card h3 { margin: 0 0 14px; font-size: 15px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

.grid { display: grid; gap: 16px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.stat .n { font-family: var(--mono); font-size: 34px; font-weight: 700; letter-spacing: -.02em; }
.stat .l { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }

/* low-stock banner */
.banner {
  display: flex; align-items: center; gap: 12px;
  background: var(--signal-bg); border: 1px solid var(--signal); color: #7a5210;
  border-radius: var(--radius); padding: 14px 18px; margin-bottom: 20px; font-weight: 600;
}
.banner .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--signal); flex: none; }

/* forms */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 15px; font-family: inherit; background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15,95,92,.18);
}
.field.mono input { font-family: var(--mono); }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 140px; }

/* tables */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
td.num, th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
tr.is-low td { background: var(--signal-bg); }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.pill.receive { background: var(--go-bg); color: #14603f; }
.pill.return  { background: var(--go-bg); color: #14603f; }
.pill.checkout{ background: var(--take-bg); color: #8f3418; }
.pill.adjustment { background: #eceff3; color: #445; }
.pill.low { background: var(--signal-bg); color: #7a5210; }

.thumb-sm { width: 34px; height: 34px; border-radius: 6px; object-fit: cover; background: var(--paper); vertical-align: middle; }

/* receive preview */
.preview {
  display: flex; gap: 16px; align-items: center;
  background: var(--paper); border-radius: var(--radius); padding: 14px; margin-bottom: 16px;
}
.preview img { width: 72px; height: 72px; border-radius: 8px; object-fit: cover; background: #fff; }
.preview .src { font-size: 12px; color: var(--muted); }

/* badge print card (on-screen preview) */
.badge-print {
  border: 1px dashed var(--line); border-radius: var(--radius); padding: 18px; text-align: center;
  background: #fff;
}
.badge-print .name { font-weight: 800; font-size: 18px; margin-bottom: 4px; }
.badge-print svg { width: 3in; max-width: 100%; height: auto; }

.empty { text-align: center; color: var(--muted); padding: 40px 20px; }

/* generic modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20,28,38,.55); z-index: 80;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius); padding: 24px;
  width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal h3 { margin: 0 0 16px; font-size: 18px; }
.modal .modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.item-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---- printing ----------------------------------------------------------
   All printing happens in an isolated iframe (see public/js/print.js), so the
   admin page itself never prints. This is just a safety net if someone uses
   the browser's own Print menu on the admin page. */
@media print {
  .admin-top, .no-print, .toast, .modal-backdrop { display: none !important; }
}

/* ---- multi-office ------------------------------------------------------ */
body:not(.multi) .office-only { display: none !important; }
.office-switch { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #8aa0b6; }
.office-switch[hidden] { display: none; }
.office-switch select {
  background: var(--ink-2); color: #fff; border: 1px solid #33475d; border-radius: 8px;
  padding: 6px 10px; font-size: 14px; font-weight: 600; font-family: inherit; max-width: 220px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head h3 { margin: 0; }
.check-row { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-size: 14px; }
.check-row input { width: auto; margin-top: 3px; }
.check-row small { color: var(--muted); font-size: 13px; }
.stock-break { display: block; font-size: 12px; color: var(--muted); font-family: var(--sans); white-space: nowrap; }
.stock-break .low { color: #7a5210; font-weight: 700; }
.pill.transfer_in, .pill.transfer_out { background: #e6ecfb; color: #23408f; }
.pill.main { background: var(--ink); color: #fff; }
.office-addr { color: var(--muted); font-size: 12px; }
.kiosk-office { font-size: 12px; font-weight: 700; color: var(--k-muted); text-transform: uppercase; letter-spacing: .06em; }
