:root {
  --bg: #0f172a; --panel: #1e293b; --panel2: #273449; --ink: #f1f5f9;
  --muted: #94a3b8; --line: #334155; --accent: #f59e0b; --accent2: #38bdf8;
  --good: #22c55e; --bad: #ef4444; --warn: #f59e0b;
  --topbar: #0b1220; --inputbg: #0b1220; --onaccent: #111827;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 16px; }
a { color: var(--accent2); }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  background: var(--topbar); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; flex-wrap: wrap; }
.brand { font-weight: 800; font-size: 18px; white-space: nowrap; }
.brand span { display: block; font-size: 12px; font-weight: 600; opacity: .75; }
.brand .logo { height: 28px; vertical-align: middle; margin-right: 8px; }
.login-logo { display: block; max-width: 360px; width: 100%; height: auto; margin: 4px auto 12px; border-radius: 12px; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav a { color: var(--ink); text-decoration: none; padding: 8px 10px; border-radius: 8px; white-space: nowrap; }
.nav a.active, .nav a:hover { background: var(--panel); }
.userbox { font-size: 14px; color: var(--muted); white-space: nowrap; }
.userbox button { margin-left: 8px; }
.app { max-width: 960px; margin: 0 auto; padding: 16px 14px 60px; }
h1 { font-size: 22px; margin: 4px 0 12px; }
h2 { font-size: 18px; margin: 20px 0 8px; }
h3 { font-size: 16px; margin: 14px 0 6px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.card h2, .card h3 { margin-top: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.grid { display: grid; gap: 12px; }
@media (min-width: 640px) { .grid.cols2 { grid-template-columns: 1fr 1fr; } .grid.cols3 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px) {
  .topbar { gap: 8px; padding: 8px 10px; }
  .brand { font-size: 16px; white-space: normal; }
  .nav { order: 3; flex: 1 1 100%; }
}
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.stat[data-go] { cursor: pointer; }
.stat b { font-size: 28px; display: block; }
.stat span { color: var(--muted); font-size: 13px; }
input, select, textarea { width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--inputbg); color: var(--ink); font-size: 16px; margin: 4px 0 10px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent2); }
label { font-size: 14px; color: var(--muted); display: block; margin-top: 6px; }
button, .btn { background: var(--accent); color: var(--onaccent); border: 0; border-radius: 10px;
  padding: 12px 18px; font-size: 16px; font-weight: 700; cursor: pointer; }
button.secondary, .btn.secondary { background: var(--panel2); color: var(--ink); border: 1px solid var(--line); }
button.danger { background: var(--bad); color: #fff; }
button.small { padding: 8px 12px; font-size: 14px; }
button:disabled { opacity: .5; cursor: default; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.listrow { display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 12px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.listrow:last-child { border-bottom: 0; }
.listrow:hover { background: var(--panel2); }
.num { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; }
.badge { display: inline-block; background: var(--panel2); border: 1px solid var(--line);
  border-radius: 999px; padding: 2px 10px; font-size: 13px; margin: 2px 4px 2px 0; }
.badge.primary { background: var(--accent); color: var(--onaccent); border-color: var(--accent); font-weight: 700; }
.badge.low { background: #7f1d1d; border-color: #ef4444; }
.badge.out { background: #7f1d1d; border-color: #ef4444; }
.badge.ok { background: #14532d; border-color: #22c55e; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #111827; color: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 18px; z-index: 50; max-width: 90vw; }
.scanbox { font-size: 22px; text-align: center; letter-spacing: 1px; padding: 16px !important; }
.ready { color: var(--good); font-weight: 700; }
.steps { display: flex; gap: 8px; margin: 10px 0; }
.step { flex: 1; text-align: center; padding: 8px; border-radius: 8px; background: var(--panel2); color: var(--muted); font-size: 14px; }
.step.on { background: var(--accent); color: var(--onaccent); font-weight: 700; }
.typegrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.typebtn { background: var(--panel2); color: var(--ink); border: 2px solid var(--line); padding: 14px; }
.typebtn.sel { border-color: var(--accent); background: #451a03; }
.checkrow { display: flex; align-items: center; gap: 8px; padding: 10px; border: 1px solid var(--line);
  border-radius: 10px; margin: 4px 0; cursor: pointer; }
.checkrow input { width: auto; margin: 0; }
.checkrow.sel { border-color: var(--accent); background: #451a03; }
.preview { background: var(--inputbg); border: 2px dashed var(--accent); border-radius: 10px;
  padding: 14px; text-align: center; margin: 12px 0; }
.preview .num { font-size: 26px; color: var(--accent); }
.barcode-wrap { background: #fff; color: #000; padding: 14px; border-radius: 8px; text-align: center; }
.barcode-wrap canvas { max-width: 100%; }
/* Bin label: 4" x 2.5" landscape, one label per printed page. */
.bin-label { width: 4in; height: 2.5in; background: #fff; color: #000; padding: 0.12in 0.2in;
  border: 1px solid #000; border-radius: 4px; text-align: center; overflow: hidden; margin: 0 auto; }
.bin-company { font-size: 9pt; font-weight: 700; letter-spacing: .5px; }
.bin-name { font-size: 12pt; font-weight: 800; margin: 1px 0 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bin-bc { margin: 2px 0; }
.bin-bc canvas { display: block; margin: 0 auto; max-width: 100%; }
.bin-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; font-size: 10pt; }
.bin-none { font-size: 10pt; font-weight: 700; padding: 6px 0; }
.bin-rows { display: grid; grid-template-columns: 1fr 1fr; gap: 1px 10px; text-align: left;
  font-size: 9.5pt; margin-top: 3px; }
.bin-rows span { color: #444; }
@media print {
  @page { size: 4in 2.5in landscape; margin: 0; }
  body { background: #fff; color: #000; }
  body * { visibility: hidden; }
  .bin-label, .bin-label * { visibility: visible; }
  .bin-label { position: absolute; left: 0; top: 0; border: 0; border-radius: 0; margin: 0; }
  .topbar, .btnrow, .no-print { display: none !important; }
  .app { max-width: none; padding: 0; }
  .card { border: 1px solid #000; background: #fff; }
}
video { width: 100%; border-radius: 12px; background: #000; }
img.part-photo { max-width: 100%; border-radius: 12px; }
/* PM calendar */
.badge.overdue { background: #7f1d1d; border-color: #ef4444; }
.badge.due-soon { background: #78350f; border-color: #f59e0b; }
.badge.open { background: #78350f; border-color: #f59e0b; }
/* Repair notes */
.note-card { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; margin-bottom: 10px; }
.note-card.resolved { opacity: .75; }
.note-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.note-body { margin: 8px 0; }
.note-edit textarea { margin-bottom: 4px; }
.note-replies { margin-left: 12px; border-left: 3px solid var(--line); padding-left: 10px; }
.reply { background: var(--inputbg); border-radius: 8px; padding: 8px 10px; margin: 6px 0; }
.reply-form { margin-top: 8px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-head { font-size: 12px; color: var(--muted); text-align: center; padding: 4px 0; }
.cal-day { min-height: 64px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 4px; font-size: 13px; }
.cal-day.other { opacity: .35; }
.cal-day.today { border-color: var(--accent2); }
.cal-day b { display: block; margin-bottom: 2px; }
.cal-item { display: block; width: 100%; text-align: left; font-size: 12px; line-height: 1.25;
  padding: 3px 5px; margin: 2px 0; border-radius: 6px; background: var(--panel2);
  color: var(--ink); border: 0; font-weight: 600; cursor: pointer; }
.cal-item.overdue { background: #7f1d1d; }
.cal-item.due-soon { background: #78350f; }

/* ------------------------------ themes ------------------------------ */
.theme-presets { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 4px; }
.theme-swatch { display: flex; align-items: center; gap: 8px; background: var(--panel2);
  color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px;
  font-size: 14px; font-weight: 600; cursor: pointer; }
.theme-swatch.on { border-color: var(--accent); outline: 2px solid var(--accent); }
.theme-swatch .dots { display: flex; }
.theme-swatch .dots i { width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--line); margin-left: -4px; }
.theme-swatch .dots i:first-child { margin-left: 0; }
.color-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; }
.color-grid label { display: flex; align-items: center; gap: 8px; }
input[type=color] { width: 56px; height: 40px; padding: 2px; margin: 4px 0; background: var(--inputbg); cursor: pointer; }

/* ------------------------------ footer ------------------------------ */
.app-footer { text-align: center; font-size: 12px; color: var(--muted); padding: 16px 12px 24px; }
