/* Inbound Tracker · NYC1 — design tokens aligned with the sibling app */
:root {
  --navy: #1a2140;
  --navy-soft: #232b52;
  --amber: #f5a623;
  --bg: #f1f4f9;
  --card: #ffffff;
  --border: #e5e7eb;
  --title: #111827;
  --desc: #6b7280;
  --micro: #9ca3af;
  --blue: #2563eb;
  --green: #22c55e;
  --red: #dc2626;
  --radius-card: 18px;
  --radius-btn: 12px;
  --shadow: 0 1px 3px rgba(17, 24, 39, 0.08), 0 4px 14px rgba(17, 24, 39, 0.05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--title);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Top bar ---------- */
.topbar {
  background: var(--navy);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #fff; }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: 0.2px; }
.brand-site {
  background: var(--amber);
  color: var(--navy);
  font-weight: 800;
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: 0.6px;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.online-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: #d1d5db;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 999px;
  padding: 5px 11px;
}
.online-pill .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px rgba(34,197,94,0.9);
}
.lang-toggle {
  display: flex;
  background: rgba(255,255,255,0.12);
  border-radius: 999px;
  padding: 3px;
}
.lang-toggle button {
  border: 0;
  background: transparent;
  color: #cbd5e1;
  font: 700 12.5px var(--font);
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.lang-toggle button.active { background: #fff; color: var(--navy); }

/* ---------- Layout ---------- */
.container { max-width: 960px; margin: 0 auto; padding: 28px 16px 64px; }
h1 { font-size: 24px; font-weight: 800; margin: 0 0 8px; color: var(--title); }
h2 { font-size: 19px; font-weight: 700; margin: 28px 0 10px; color: var(--title); }
.desc { color: var(--desc); font-size: 14.5px; margin: 0 0 20px; line-height: 1.55; }
.micro { font-family: var(--mono); font-size: 11.5px; color: var(--micro); text-transform: uppercase; letter-spacing: 0.8px; margin: 0 0 8px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 16px;
}

/* ---------- Buttons / inputs ---------- */
.btn-primary {
  display: block;
  width: 100%;
  background: var(--navy);
  color: #fff;
  border: 0;
  border-radius: var(--radius-btn);
  padding: 14px 18px;
  font: 700 15px var(--font);
  cursor: pointer;
}
.btn-primary:hover { background: var(--navy-soft); }
.btn-primary:disabled { opacity: 0.55; cursor: default; }
.btn-secondary {
  display: inline-block;
  background: #fff;
  color: var(--title);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  padding: 11px 16px;
  font: 600 14px var(--font);
  cursor: pointer;
}
.btn-secondary:hover { background: #f8fafc; }
.btn-danger {
  background: #fff;
  color: var(--red);
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 8px 12px;
  font: 600 13px var(--font);
  cursor: pointer;
}
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.btn-row .btn-secondary { flex: 1; min-width: 140px; }

input[type="text"], input[type="date"], input[type="password"], select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  padding: 13px 14px;
  font: 400 15px var(--font);
  color: var(--title);
  background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: 0; border-color: var(--blue); }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font: 600 13px var(--font); color: var(--title); margin-bottom: 6px; }

/* ---------- Home hub ---------- */
.role-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .role-grid { grid-template-columns: 1fr; } }
.role-card { text-align: left; display: flex; flex-direction: column; gap: 6px; }
.role-icon { font-size: 40px; line-height: 1; margin-bottom: 4px; }
.role-card h2 { margin: 0; font-size: 19px; }
.role-card p { color: var(--desc); font-size: 14px; margin: 0 0 12px; line-height: 1.5; flex: 1; }

/* ---------- Operator ---------- */
.scan-row { display: flex; gap: 10px; }
.scan-row input { flex: 1; font-size: 17px; padding: 15px 14px; }
.cam-btn {
  flex: 0 0 60px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: var(--radius-btn);
  font-size: 24px;
  cursor: pointer;
}
.cam-btn.live { background: var(--navy); border-color: var(--navy); }
#video { width: 100%; border-radius: var(--radius-card); background: #000; display: none; margin-top: 12px; max-height: 320px; object-fit: cover; }
#video.on { display: block; }

.scan-list { list-style: none; margin: 12px 0 0; padding: 0; }
.scan-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: #fff;
}
.scan-list .trk { font-family: var(--mono); font-size: 13.5px; font-weight: 600; flex: 1; word-break: break-all; }
.carrier-pill {
  font: 700 11px var(--font);
  padding: 4px 9px;
  border-radius: 999px;
  background: #eff6ff;
  color: var(--blue);
  white-space: nowrap;
}
.scan-list .time { font-size: 12px; color: var(--micro); white-space: nowrap; }
.count-pill {
  display: inline-block;
  background: var(--blue);
  color: #fff;
  font: 700 13px var(--font);
  border-radius: 999px;
  padding: 5px 14px;
  margin-bottom: 6px;
}
.empty-note { color: var(--micro); font-size: 14px; padding: 18px 4px; text-align: center; }
.closed-card { border-left: 5px solid var(--green); }
.close-hint { display: flex; align-items: center; gap: 12px; border-left: 5px solid var(--amber); }
.close-hint .ch-icon { font-size: 26px; line-height: 1; }

/* last scan status under the input */
.last-scan { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--border); }
.last-scan .ls-label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--micro); font-weight: 700; white-space: nowrap; }
.last-scan .ls-val { flex: 1; font-family: var(--mono); font-weight: 700; font-size: 15px; word-break: break-all; }
.last-scan .ls-tag { font: 800 12px var(--font); padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.last-scan.ok { border-color: var(--green); background: #f0fdf4; }
.last-scan.ok .ls-tag { background: var(--green); color: #fff; }
.last-scan.dup, .last-scan.err { border-color: var(--red); background: #fef2f2; }
.last-scan.dup .ls-tag, .last-scan.err .ls-tag { background: var(--red); color: #fff; }

/* full-screen scan flash */
#flash { position: fixed; inset: 0; z-index: 150; display: none; align-items: center; justify-content: center; pointer-events: none; padding: 20px; }
#flash.show { display: flex; animation: flashIn .12s ease-out; }
#flash.ok { background: rgba(34, 197, 94, .88); }
#flash.cart { background: rgba(26, 33, 64, .94); }
#flash.dup, #flash.err { background: rgba(220, 38, 38, .9); animation: flashIn .12s ease-out, shake .35s ease-in-out .05s; }
.flash-box { text-align: center; color: #fff; max-width: 92vw; }
.flash-icon { font-size: 96px; line-height: 1; font-weight: 900; }
.flash-title { font-size: 34px; font-weight: 850; margin-top: 8px; }
.flash-sub { font-family: var(--mono); font-size: 20px; font-weight: 700; margin-top: 8px; word-break: break-all; opacity: .95; }
#flash.cart .flash-title { color: var(--amber); }
@keyframes flashIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-14px); } 75% { transform: translateX(14px); } }

/* ---------- Manager ---------- */
.tabs { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 18px; padding-bottom: 2px; }
.tab {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 9px 16px;
  font: 600 13.5px var(--font);
  color: var(--desc);
  cursor: pointer;
  white-space: nowrap;
}
.tab.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.pin-card { max-width: 420px; margin: 40px auto; text-align: center; }
.pin-card input { text-align: center; font-size: 22px; letter-spacing: 8px; }

.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
@media (max-width: 640px) { .filters { grid-template-columns: 1fr; } }

table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left;
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--micro);
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data td { padding: 11px 8px; border-bottom: 1px solid #f1f5f9; vertical-align: top; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: #f8fafc; }
.table-wrap { overflow-x: auto; margin: 0 -6px; padding: 0 6px; }
.mono { font-family: var(--mono); font-size: 12.5px; }

.no-receipt {
  border: 2px dashed #f59e0b;
  background: #fffbeb;
  border-radius: var(--radius-card);
  padding: 20px;
  margin: 16px 0;
}
.no-receipt h3 { margin: 0 0 6px; font-size: 16px; }
.no-receipt p { color: var(--desc); font-size: 14px; margin: 0 0 12px; }

.admin-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid #f1f5f9; }
.admin-row:last-child { border-bottom: 0; }
.admin-row .grow { flex: 1; }
.admin-row .name { font-weight: 600; font-size: 14.5px; }
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.status-dot.on { background: var(--green); }
.status-dot.off { background: #d1d5db; }
.role-tag { font: 700 11px var(--font); background: #f1f5f9; border-radius: 6px; padding: 3px 8px; color: var(--desc); }

/* ---------- Modal / toast ---------- */
#modal { display: none; position: fixed; inset: 0; background: rgba(17,24,39,0.55); z-index: 100; padding: 20px; overflow-y: auto; }
#modal.open { display: block; }
.modal-card { background: #fff; border-radius: var(--radius-card); max-width: 560px; margin: 30px auto; padding: 24px; box-shadow: var(--shadow); }
.modal-card h2 { margin-top: 0; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 14px; margin: 14px 0; }
.kv dt { color: var(--micro); font-family: var(--mono); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.5px; padding-top: 2px; }
.kv dd { margin: 0; word-break: break-all; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: var(--navy);
  color: #fff;
  padding: 13px 20px;
  border-radius: 12px;
  font: 600 14px var(--font);
  opacity: 0;
  transition: all 0.25s ease;
  z-index: 200;
  max-width: calc(100vw - 40px);
  text-align: center;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: #7f1d1d; }

/* ---------- Print label (4x6, Zebra ZT231) ---------- */
#print-label { display: none; }
@media print {
  @page { size: 4in 6in; margin: 0; }
  body.printing .topbar, body.printing .container, body.printing #toast, body.printing #modal { display: none !important; }
  body.printing #print-label { display: flex !important; }
}
body.printing #print-label { display: flex; }
.label-4x6 {
  width: 4in;
  height: 6in;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.18in;
  background: #fff;
  color: #000;
  font-family: var(--font);
  page-break-after: always;
}
.label-4x6 .label-qr { width: 2.9in; height: 2.9in; }
.label-4x6 .label-name { font-size: 44px; font-weight: 800; text-align: center; line-height: 1.1; padding: 0 0.25in; }
.label-4x6 .label-id { font-family: var(--mono); font-size: 20px; letter-spacing: 1px; }
.label-4x6 .label-hint { font-size: 15px; color: #333; }

@media (max-width: 480px) {
  h1 { font-size: 22px; }
  .container { padding: 20px 12px 56px; }
  .card { padding: 18px; }
}
