/* RFID assetTrace — corporate theme: navy + brass */
:root {
  --navy-900: #0B1A33;
  --navy-800: #11264A;
  --navy-700: #1A3561;
  --navy-600: #24477E;
  --brass: #B8913A;
  --brass-soft: #F4EBD6;
  --ink: #15233B;
  --ink-2: #4A5A75;
  --ink-3: #7B88A0;
  --line: #E1E6EF;
  --line-2: #EEF1F6;
  --bg: #F3F5F9;
  --card: #FFFFFF;
  --primary: #1F4FBF;
  --primary-ink: #FFFFFF;
  --primary-soft: #E7EEFC;
  --ok: #1E8A5A;   --ok-soft: #E3F4EC;
  --warn: #B7791F; --warn-soft: #FBF1DE;
  --bad: #C2372F;  --bad-soft: #FBE7E5;
  --info: #2D6FA8; --info-soft: #E4EFF9;
  --muted-soft: #EEF0F4;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(11,26,51,.05), 0 2px 8px rgba(11,26,51,.04);
  --font: "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  --c1: #1F4FBF; --c2: #B8913A; --c3: #2A9D8F; --c4: #7A5CC4; --c5: #D1603D; --c6: #5B7A99;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: 14px; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.right { text-align: right; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--navy-900); color: #C9D3E6; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { padding: 20px 20px 16px; border-bottom: 1px solid rgba(255,255,255,.07); }
.brand .logo { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.brand .mark { width: 30px; height: 30px; border-radius: 7px; background: linear-gradient(135deg, var(--brass), #D9B866); display: grid; place-items: center; color: var(--navy-900); font-weight: 800; font-size: 13px; }
.org-switch { margin-top: 10px; background: var(--navy-800); color: #fff; border: 1px solid rgba(255,255,255,.15); font-size: 12.5px; font-weight: 600; padding: 7px 9px; }
.brand .org-type { margin-top: 6px; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: #6F7F9C; }
.brand .hotel { margin-top: 8px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--brass); }
.nav { padding: 12px 10px; overflow-y: auto; flex: 1; }
.nav .grp { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: #6F7F9C; padding: 14px 12px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: #C9D3E6; font-weight: 500; text-decoration: none; }
.nav a svg { width: 17px; height: 17px; opacity: .8; flex: none; }
.nav a:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav a.on { background: var(--navy-700); color: #fff; box-shadow: inset 3px 0 0 var(--brass); }
.nav a .badge { margin-left: auto; }
.side-foot { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.07); font-size: 12px; }
.side-foot .who { color: #fff; font-weight: 600; }
.side-foot button { margin-top: 8px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 28px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar .title { flex: 1; min-width: 0; }
.topbar .crumb { font-size: 12px; color: var(--ink-3); }
.topbar .menu-btn { display: none; }
.content { padding: 24px 28px 60px; max-width: 1440px; width: 100%; }
.banner { padding: 10px 28px; font-size: 13px; font-weight: 500; }
.banner.bad { background: var(--bad-soft); color: var(--bad); }
.banner.warn { background: var(--warn-soft); color: var(--warn); }

/* ---------- primitives ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card > .hd { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.card > .hd h2 { flex: 1; }
.card > .bd { padding: 16px 18px; }
.card > .bd.flush { padding: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.g-dash { grid-template-columns: 2fr 1fr; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 16px; }

.btn { appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-weight: 550; padding: 8px 14px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; line-height: 1.2; }
.btn:hover { border-color: #C8D1E0; background: #FAFBFD; text-decoration: none; }
.btn svg { width: 15px; height: 15px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { background: #1A44A6; }
.btn.navy { background: var(--navy-800); border-color: var(--navy-800); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.danger.solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn.lg { padding: 12px 20px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.side .btn { background: transparent; color: #C9D3E6; border-color: rgba(255,255,255,.15); }

label.f { display: block; }
label.f > span { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
input, select, textarea { font: inherit; color: var(--ink); background: #fff; border: 1px solid #D3DAE6; border-radius: 8px; padding: 8px 11px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(31,79,191,.25); border-color: var(--primary); }
input[type=checkbox] { width: auto; }
textarea { resize: vertical; min-height: 70px; }
.form { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px 16px; }
.form .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.s-in_place, .s-found, .s-closed, .s-approved, .s-done { background: var(--ok-soft); color: var(--ok); }
.s-checked_out, .s-open, .s-misplaced, .s-pending { background: var(--info-soft); color: var(--info); }
.s-under_repair, .s-warn, .s-overdue { background: var(--warn-soft); color: var(--warn); }
.s-missing, .s-unknown, .s-rejected, .s-bad { background: var(--bad-soft); color: var(--bad); }
.s-disposed, .s-muted { background: var(--muted-soft); color: var(--ink-3); }
.badge { background: var(--bad); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 700; padding: 1px 7px; }
.badge.warn { background: var(--brass); color: var(--navy-900); }

table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 11.5px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--ink-3); padding: 10px 14px; border-bottom: 1px solid var(--line); background: #FAFBFD; white-space: nowrap; position: sticky; top: 0; }
table.t td { padding: 10px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: #F7F9FC; }
table.t tfoot td { font-weight: 700; background: #FAFBFD; border-top: 1px solid var(--line); }
.tbl-wrap { overflow: auto; max-height: 70vh; }
.empty { padding: 40px 20px; text-align: center; color: var(--ink-3); }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0,1fr)); gap: 12px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi .l { font-size: 11.5px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; }
.kpi .v { white-space: nowrap; font-size: 24px; font-weight: 700; margin-top: 6px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.kpi.hero { background: linear-gradient(135deg, var(--navy-800), var(--navy-600)); color: #fff; border-color: var(--navy-800); }
.kpi.hero .l, .kpi.hero .s { color: #AFC0DD; }
.kpi.hero .v { color: #fff; }
.kpi.alert .v { color: var(--bad); }
.kpi.warn .v { color: var(--warn); }
.kpi a.cover { position: absolute; inset: 0; }

.alert-list { list-style: none; margin: 0; padding: 0; }
.alert-list li { display: flex; align-items: center; gap: 10px; padding: 10px 18px; border-bottom: 1px solid var(--line-2); }
.alert-list li:last-child { border-bottom: 0; }
.alert-list .ico { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: none; }
.alert-list .ico svg { width: 16px; height: 16px; }
.alert-list .tx { flex: 1; min-width: 0; }
.alert-list .tx b { display: block; font-weight: 600; }
.alert-list .tx span { font-size: 12px; color: var(--ink-3); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.chart svg { display: block; width: 100%; height: auto; }
.chart text { font-family: var(--font); fill: var(--ink-3); font-size: 11px; }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { padding: 9px 18px; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.feed li:last-child { border-bottom: 0; }
.feed .meta { font-size: 11.5px; color: var(--ink-3); }

/* ---------- scan console ---------- */
.modes { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 10px; }
.mode { border: 1px solid var(--line); background: var(--card); border-radius: var(--radius); padding: 14px; cursor: pointer; text-align: left; font: inherit; color: var(--ink); }
.mode b { display: block; font-size: 14px; }
.mode span { font-size: 12px; color: var(--ink-3); }
.mode.on { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(31,79,191,.15); background: var(--primary-soft); }
.scanbox { border: 2px dashed #C3CDDF; border-radius: 12px; padding: 18px; background: #FAFBFD; display: flex; gap: 16px; align-items: center; }
.scanbox.live { border-color: var(--ok); background: var(--ok-soft); }
.scanbox .count { font-size: 40px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; min-width: 70px; text-align: center; color: var(--navy-800); }
.scanbox input { font-family: var(--mono); font-size: 15px; }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 rgba(30,138,90,.5); animation: pulse 1.5s infinite; display: inline-block; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(30,138,90,.5); } 70% { box-shadow: 0 0 0 10px rgba(30,138,90,0); } 100% { box-shadow: 0 0 0 0 rgba(30,138,90,0); } }
.tally { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; }
.tally > div { border-radius: 10px; padding: 12px 14px; }
.tally .v { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.tally .l { font-size: 12px; font-weight: 600; }

/* ---------- asset detail ---------- */
.detail-head { display: flex; gap: 20px; align-items: flex-start; }
.photo { width: 160px; height: 160px; border-radius: 10px; background: var(--line-2); border: 1px solid var(--line); object-fit: cover; flex: none; display: grid; place-items: center; color: var(--ink-3); font-size: 12px; overflow: hidden; }
.photo img { width: 100%; height: 100%; object-fit: cover; }
dl.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; margin: 0; }
dl.kv dt { color: var(--ink-3); font-size: 12.5px; }
dl.kv dd { margin: 0; font-weight: 500; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { appearance: none; border: 0; background: none; font: inherit; font-weight: 600; color: var(--ink-3); padding: 10px 14px; border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--brass); }

/* ---------- modal / toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(11,26,51,.45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--card); border-radius: 14px; width: min(640px, 100%); max-height: 92vh; overflow: auto; box-shadow: 0 20px 60px rgba(11,26,51,.3); }
.modal .hd { padding: 18px 22px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; }
.modal .hd h2 { flex: 1; }
.modal .bd { padding: 20px 22px; }
.modal .ft { padding: 14px 22px; border-top: 1px solid var(--line-2); display: flex; justify-content: flex-end; gap: 10px; }
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--navy-900); color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: 380px; font-size: 13.5px; }
.toast.err { background: var(--bad); }
.toast.ok { background: var(--ok); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login .art { background: radial-gradient(1200px 600px at 10% 10%, var(--navy-600), var(--navy-900)); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login .art h1 { font-size: 34px; line-height: 1.15; max-width: 440px; }
.login .art p { color: #AFC0DD; max-width: 420px; line-height: 1.6; }
.login .art .rings { position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px; opacity: .18; }
.login .panel { display: grid; place-items: center; padding: 40px; background: var(--card); }
.login form { width: min(360px, 100%); }
.login form > * + * { margin-top: 14px; }

/* ---------- wall (TV) mode ---------- */
body.wall .side, body.wall .topbar { display: none; }
body.wall .shell { grid-template-columns: 1fr; }
body.wall .content { max-width: none; padding: 24px 32px; }
.wall-head { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.wall-head .clock { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--navy-800); }

/* ---------- print ---------- */
.print-only { display: none; }
@media print {
  body { background: #fff; }
  .side, .topbar, .no-print, .toasts, .banner { display: none !important; }
  .shell { display: block; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 0; }
  .tbl-wrap { max-height: none; overflow: visible; }
  .print-only { display: block; }
  table.t th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  table.t td, table.t th { padding: 5px 7px; font-size: 10.5px; }
}

/* ---------- responsive ----------
   ≥1280  desktop: sidebar, 6 KPI tiles
   1024–1279 laptop / iPad landscape: sidebar, 3 KPI tiles, dashboard keeps 2 columns
   701–1023 iPad portrait: slide-out menu, 2-column forms and grids
   ≤700  phone: single column, tables become cards, header actions scroll sideways
*/
@media (max-width: 1279px) { .kpis { grid-template-columns: repeat(3, minmax(0,1fr)) !important; } }
@media (max-width: 1100px) { .g-dash { grid-template-columns: 1fr; } .g3 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 1023px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 270px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .side { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(11,26,51,.35); z-index: 35; }
  .topbar .menu-btn { display: inline-flex; }
  .hide-md { display: none !important; }
  .topbar { padding: 12px 20px; }
  .content { padding: 20px 20px 60px; }
  .modes { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .login { grid-template-columns: 1fr; }
  .login .art { display: none; }
}
@media (max-width: 700px) {
  .kpis { grid-template-columns: repeat(2, minmax(0,1fr)) !important; gap: 10px; }
  .kpi { padding: 12px 14px; }
  .kpi .v { font-size: 22px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .form { grid-template-columns: 1fr; }
  .modes { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .tally { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .detail-head { flex-direction: column; }
  dl.kv { grid-template-columns: 120px 1fr; }
  .hide-sm { display: none !important; }

  /* header: title on its own line, actions in a sideways-scrolling strip */
  .topbar { flex-wrap: wrap; padding: 10px 14px; gap: 8px; }
  .topbar .title { flex: 1 1 calc(100% - 60px); }
  .topbar .crumb { display: none; }
  .topbar h1 { font-size: 18px; line-height: 1.25; }
  #pageActions { flex: 1 1 100%; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
  #pageActions:empty { display: none; }
  #pageActions .btn { flex: none; }
  .content { padding: 14px 12px 70px; }
  .card > .hd { padding: 12px 14px; flex-wrap: wrap; }
  .card > .bd { padding: 14px; }

  /* tables → stacked cards */
  .tbl-wrap { max-height: none; overflow: visible; }
  table.t.cards thead { display: none; }
  table.t.cards, table.t.cards tbody, table.t.cards tr, table.t.cards td { display: block; width: 100%; }
  table.t.cards tr { padding: 10px 14px; border-bottom: 1px solid var(--line); }
  table.t.cards td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 3px 0; border: 0; text-align: right; }
  table.t.cards td::before { content: attr(data-label); font-size: 11.5px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .03em; text-align: left; flex: none; }
  table.t.cards td[data-label=""]::before { content: none; }
  table.t.cards td[data-label=""] { justify-content: flex-start; }
  table.t.cards td:first-child { font-size: 15px; }
  table.t.cards td .cv { min-width: 0; text-align: right; }
  table.t.cards td[data-label=""] .cv { text-align: left; width: 100%; }
  table.t.cards tfoot tr { display: block; padding: 10px 14px; }
  table.t.cards tfoot td { display: inline; padding: 0 6px 0 0; }
  .scanbox { flex-direction: column; align-items: stretch; padding: 14px; gap: 8px; }
  .scanbox .count { font-size: 32px; text-align: left; }
  .wall-head { flex-wrap: wrap; }
}
@media (max-width: 380px) { .modes { grid-template-columns: 1fr; } }

/* touch screens (phones, iPads, handheld scanners): bigger tap targets */
@media (pointer: coarse) {
  .btn { min-height: 40px; }
  .btn.sm { min-height: 36px; }
  input, select { min-height: 44px; font-size: 16px; }   /* 16px stops iOS zoom-on-focus */
  textarea { font-size: 16px; }
  .nav a { padding: 12px 12px; }
  .tabs button { padding: 12px 16px; }
  .check input[type=checkbox] { width: 20px; height: 20px; }
}
