/* MAI Equipment Inventory v2: production screens. Design source of truth: the live portal (Duty Free look).
   Tokens as they stand (spec Part 9 section 11). Colours and small touches are not polished in this block. */
:root {
  --navy: #0F2942; --gold: #C9962B; --gold-mid: #E8C46A; --bg: #F1F5F9; --card: #FFFFFF; --border: #E2E8F0; --text: #0F172A;
  --muted: #475569; --danger: #B91C1C; --danger-bg: #FEF2F2; --ok: #15803D; --ok-bg: #F0FDF4;
  --on-navy: #FFFFFF; --logout: #DC2626; --logout-hover: #B91C1C; color-scheme: light;
}
:root[data-theme="dark"] {
  --navy: #5A8FB8; --gold: #F5C544; --gold-mid: #FCD34D; --bg: #0A0F1A; --card: #152538; --border: #1E3A5F; --text: #F1F5F9;
  --muted: #94A3B8; --danger: #F87171; --danger-bg: #2A1620; --ok: #4ADE80; --ok-bg: #11291E;
  --on-navy: #0A0F1A; --logout: #DC2626; --logout-hover: #B91C1C; color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 14px 40px; }
.narrow { max-width: 760px; }
[hidden] { display: none !important; }

/* ---------- login: the dark glass card on the navy gradient (same as the live login) ---------- */
#loginScreen { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0a1628 0%, #0f2456 50%, #1a3a7c 100%); padding: 20px; position: relative; overflow: hidden; color-scheme: dark; color: #fff; }
#loginScreen::before { content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 20% 50%, rgba(240,165,0,0.08) 0%, transparent 60%), radial-gradient(ellipse at 80% 20%, rgba(26,58,124,0.3) 0%, transparent 50%); pointer-events: none; }
.login-box { background: rgba(255,255,255,0.04); border: 1px solid rgba(240,165,0,0.25); border-radius: 20px; padding: 36px 32px; width: 100%; max-width: 380px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.4); position: relative; z-index: 1; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.login-logo { display: flex; align-items: center; justify-content: center; margin-bottom: 14px; }
.login-badge { width: 52px; height: 52px; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #F0A500, #c98d00);
  border-radius: 13px; font-size: 24px; color: #0a1628; box-shadow: 0 6px 20px rgba(240,165,0,0.28); }
.login-box h1 { margin: 0 0 4px; font-size: 15px; font-weight: 800; color: #fff; letter-spacing: 0.07em; text-transform: uppercase; text-align: center; }
.login-box .sub { margin: 0; font-size: 10px; font-weight: 600; color: #F0A500; letter-spacing: 0.11em; text-transform: uppercase; text-align: center; }
.login-divider { height: 1px; background: rgba(240,165,0,0.2); margin: 18px 0; }
.login-field { margin-bottom: 16px; }
.login-field label { display: block; font-size: 10px; font-weight: 700; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 6px; }
.login-field input, .login-field select { width: 100%; min-height: 44px; padding: 10px 13px; background: rgba(255,255,255,0.07); border: 1.5px solid rgba(255,255,255,0.12);
  border-radius: 9px; font-size: 16px; font-family: 'Inter', sans-serif; color: #fff; }
/* The login screen is one fixed dark design in both themes (as in the live portal). Its controls say so to the browser too:
   color-scheme dark gives the native dropdown list and the autofill a dark background, and the colours below are fixed, never theme tokens. */
.login-field input, .login-field select { color-scheme: dark; color: #fff; }
.login-field input::placeholder { color: #94a3b8; }
.login-field select option { background: #0f2456; color: #fff; }
.login-field input:-webkit-autofill, .login-field input:-webkit-autofill:focus { -webkit-text-fill-color: #fff; caret-color: #fff; box-shadow: 0 0 0 1000px #14264f inset; -webkit-box-shadow: 0 0 0 1000px #14264f inset; transition: background-color 9999s ease-out 0s; }
.login-field input:focus, .login-field select:focus { outline: none; border-color: rgba(240,165,0,0.55); }
.login-pw-wrap { position: relative; display: flex; }
.login-pw-wrap input { padding-right: 64px; }
.login-pw-toggle { position: absolute; top: 50%; right: 6px; transform: translateY(-50%); min-height: 32px; padding: 0 8px; background: transparent; border: 0; border-radius: 6px; color: #94a3b8; font-size: 12px; font-weight: 600; cursor: pointer; }
.login-pw-toggle:hover, .login-pw-toggle:focus-visible { color: #F0A500; outline: none; }
.btn-login { width: 100%; min-height: 46px; background: linear-gradient(135deg, #F0A500, #c98d00); color: #0a1628; border: none; border-radius: 9px; font-size: 13px; font-weight: 800;
  font-family: 'Inter', sans-serif; cursor: pointer; letter-spacing: 0.5px; text-transform: uppercase; }
.btn-login:hover { box-shadow: 0 4px 16px rgba(240,165,0,0.35); }
.btn-login[disabled] { opacity: .6; cursor: wait; }
.login-error { background: rgba(220,38,38,0.15); color: #fca5a5; padding: 9px 13px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.login-note { font-size: 12px; color: #cbd5e1; margin: 0 0 14px; line-height: 1.4; }
.login-banner { width: 100%; max-width: 380px; margin-bottom: 14px; padding: 9px 13px; background: #E8C46A; color: #0a1628; border-radius: 10px; font-size: 12px; font-weight: 700; letter-spacing: .03em; text-align: center; line-height: 1.35; position: relative; z-index: 1; }
.login-footer { margin-top: 20px; padding: 0 20px; text-align: center; font-size: 10px; color: rgba(255,255,255,0.35); letter-spacing: 0.05em; position: relative; z-index: 1; }

/* ---------- header: one line, 56px ---------- */
.app-header { background: var(--navy); color: #fff; display: flex; align-items: center; gap: 12px; padding: 0 16px; height: 56px; position: sticky; top: 0; z-index: 100; box-shadow: 0 2px 12px rgba(0,0,0,0.3); }
.header-title-wrap { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 10px; }
.header-title { font-size: 1rem; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.role-badge { background: var(--gold-mid); color: #0a1628; font-size: 0.65rem; font-weight: 800; letter-spacing: 0.5px; text-transform: uppercase; padding: 3px 9px; border-radius: 999px; white-space: nowrap; flex: 0 0 auto; }
.build-tag { background: #DC2626; color: #fff; font-size: 0.65rem; font-weight: 800; letter-spacing: 0.5px; text-transform: uppercase; padding: 3px 9px; border-radius: 999px; white-space: nowrap; flex: 0 0 auto; }
.header-right { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.user-name { font-size: 13px; font-weight: 600; color: #fff; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif-wrap { position: relative; }
.notif-btn { background: none; border: none; cursor: pointer; color: #fff; padding: 8px; border-radius: 50%; display: flex; align-items: center; min-width: 40px; min-height: 40px; justify-content: center; }
.notif-btn:hover { background: rgba(255,255,255,0.1); }
.notif-btn svg { width: 22px; height: 22px; }
.notif-pop { position: absolute; right: 0; top: 46px; width: 240px; background: var(--card); color: var(--text); border: 1px solid var(--border); border-radius: 12px; padding: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.25); font-size: 14px; }
.theme-pill { background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.25); border-radius: 999px; padding: 6px 14px; font-size: 13px; font-weight: 600; color: #fff; font-family: 'Inter', sans-serif; white-space: nowrap; cursor: pointer; min-height: 36px; }
.theme-pill:hover { background: rgba(255,255,255,0.2); }
.btn-logout { padding: 7px 16px; border: none; background: var(--logout); color: #fff; border-radius: 8px; font-size: 12px; font-weight: 600; cursor: pointer; font-family: 'Inter', sans-serif; letter-spacing: 0.3px; min-height: 36px; }
.btn-logout:hover { background: var(--logout-hover); }
@media (max-width: 560px) {
  .app-header { gap: 8px; padding: 0 10px; }
  .user-name { display: none; }
  .theme-pill { padding: 6px 10px; }
  .btn-logout { padding: 7px 10px; }
}
.banner { background: var(--gold-mid); color: #0a1628; text-align: center; font-weight: 700; font-size: 12px; letter-spacing: .05em; padding: 5px 10px; }
.readonly-note { margin: 12px 0 0; padding: 8px 12px; border: 1px solid var(--gold); border-radius: 10px; background: var(--card); font-size: 14px; color: var(--muted); }

/* ---------- screen tabs ---------- */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 10px 14px; max-width: 1180px; margin: 0 auto; -webkit-overflow-scrolling: touch; }
.tab { flex: 0 0 auto; min-height: 44px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--border); background: var(--card); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.tab[aria-selected="true"] { background: var(--navy); color: var(--on-navy); border-color: var(--navy); }

/* cards and fields */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 16px; margin-top: 12px; }
h2 { margin: 0 0 10px; font-size: 20px; color: var(--navy); }
h3 { margin: 16px 0 8px; font-size: 16px; }
.field { margin-top: 16px; }
.field > label, .lbl { display: block; font-weight: 600; margin-bottom: 6px; }
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=date], input[type=search], input[type=number], select, textarea {
  width: 100%; min-height: 52px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text);
}
textarea { min-height: 84px; resize: vertical; }
/* iOS Safari date-input guard: Safari gives date inputs their own minimum width and ignores width: 100%,
   so the box runs past the card. Same size rules as the selects, and the calendar picker still opens on tap. */
input[type=date] { -webkit-appearance: none; appearance: none; display: block; width: 100%; min-width: 0; max-width: 100%; line-height: normal; }
input[type=date]::-webkit-date-and-time-value { text-align: left; min-height: 1.4em; }
.filters > div { min-width: 0; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 3px solid var(--gold); outline-offset: 1px; }
.locked { min-height: 52px; display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border: 1px dashed var(--border); border-radius: 10px; background: var(--bg); font-weight: 600; }
.locked span { font-weight: 500; font-size: 12px; color: var(--muted); }
.hint { font-size: 14px; color: var(--muted); margin-top: 6px; }
.err { color: var(--danger); font-size: 14px; margin-top: 6px; font-weight: 600; }
.btn { min-height: 52px; padding: 0 20px; border-radius: 10px; border: 1px solid var(--navy); background: var(--navy); color: var(--on-navy); font-weight: 700; cursor: pointer; }
.btn.block { width: 100%; margin-top: 20px; }
.btn.ghost { background: transparent; color: var(--navy); }
.btn.small { min-height: 44px; padding: 0 14px; font-size: 14px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg button { min-height: 52px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); font-weight: 600; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--navy); color: var(--on-navy); border-color: var(--navy); }
.warn { background: var(--danger-bg); border: 1px solid var(--danger); color: var(--text); border-radius: 10px; padding: 10px 12px; margin-top: 16px; font-size: 14px; }
.box-ok { background: var(--ok-bg); border: 1px solid var(--ok); border-radius: 12px; padding: 14px; margin-top: 12px; }
.box-bad { background: var(--danger-bg); border: 1px solid var(--danger); border-radius: 12px; padding: 14px; margin-top: 12px; }
.box-ok strong, .box-bad strong { display: block; margin-bottom: 4px; }

/* item rows */
.rowcard { border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-top: 16px; background: var(--bg); }
.rowcard input, .rowcard select, .rowcard textarea { background: var(--card); }
.rowcard .field:first-of-type { margin-top: 10px; }

/* item picker */
.picker { border: 1px solid var(--border); border-radius: 10px; max-height: 280px; overflow-y: auto; margin-top: 8px; background: var(--bg); }
.picker .cat { position: sticky; top: 0; background: var(--card); padding: 6px 12px; font-size: 12px; font-weight: 700; letter-spacing: .05em; color: var(--muted); text-transform: uppercase; }
.picker button { display: block; width: 100%; text-align: left; min-height: 52px; padding: 10px 12px; border: 0; border-top: 1px solid var(--border); background: transparent; cursor: pointer; font-weight: 600; }
.chip { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 52px; padding: 6px 6px 6px 12px; border-radius: 10px; border: 1px solid var(--navy); background: var(--bg); font-weight: 700; }

/* tables */
.scroll { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 8px; border-bottom: 2px solid var(--border); white-space: nowrap; }
.tbl td { padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tr.cat td { background: var(--bg); font-weight: 700; font-size: 12px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; border: 1px solid var(--border); }
.badge.rev { border-color: var(--gold); color: var(--gold); }
.badge.ok { border-color: var(--ok); color: var(--ok); }
.badge.off { border-color: var(--muted); color: var(--muted); }
.moves div { white-space: nowrap; }
.filters { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 700px) { .filters { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 760px) {
  table.stack, .stack thead, .stack tbody, .stack tr, .stack td { display: block; width: 100%; }
  .stack thead { display: none; }
  .stack tr { border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px; margin-top: 10px; background: var(--card); }
  .stack td { border: 0; padding: 4px 0; display: flex; gap: 10px; justify-content: space-between; text-align: right; }
  .stack td::before { content: attr(data-label); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); text-align: left; flex: 0 0 38%; }
  .stack td.nolabel::before { content: none; }
}

/* dialog */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.overlay[hidden] { display: none; } /* without this, display:flex above beats the hidden attribute and the overlay blocks every click */
@media (min-width: 700px) { .overlay { align-items: center; } }
.dialog { background: var(--card); width: 100%; max-width: 560px; border-radius: 16px 16px 0 0; padding: 18px; max-height: 92vh; overflow-y: auto; border: 1px solid var(--border); }
@media (min-width: 700px) { .dialog { border-radius: 16px; } }
.dialog .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
footer { margin-top: 28px; text-align: center; font-size: 13px; color: var(--muted); }
.muted { color: var(--muted); }

/* IFS Store (Part 4) and printing */
.print-only { display: none; }
@media print {
  /* Always the light style on paper, whatever theme is on screen */
  :root, :root[data-theme="dark"] { --navy: #0F2942; --gold: #C9962B; --bg: #FFFFFF; --card: #FFFFFF; --border: #CBD5E1; --text: #0F172A; --muted: #475569; --danger: #B91C1C; --danger-bg: #FFFFFF; --ok: #15803D; --ok-bg: #FFFFFF; --on-navy: #FFFFFF; color-scheme: light; }
  body { background: #FFFFFF; color: #0F172A; }
  .app-header, .banner, .readonly-note, .tabs, footer, .overlay, .no-print, .no-print-card, .btn { display: none !important; }
  .wrap, body.wide .wrap { max-width: none; padding: 0; }
  .card { border: 0; padding: 0; margin: 0 0 14px; break-inside: avoid; }
  .print-only { display: block; }
  .scroll { overflow: visible; }
  table.tbl, .stack { font-size: 12px; }
}

/* SLA (Part 5): status badge, 12-month strip */
.badge.bad { border-color: var(--danger); color: var(--danger); background: var(--danger-bg); }
.strip { display: flex; flex-wrap: wrap; gap: 6px; }
.strip .cell { min-width: 62px; padding: 4px 6px; border: 1px solid var(--border); border-radius: 8px; text-align: center; font-size: 12px; line-height: 1.3; }
.strip .cell span { display: block; color: var(--muted); }
.strip .cell strong { display: block; font-size: 13px; }
.strip .cell.clean { border-color: var(--ok); color: var(--ok); background: var(--ok-bg); }
.strip .cell.breach { border-color: var(--danger); color: var(--danger); background: var(--danger-bg); }
.strip .cell.nocount { border-style: dashed; color: var(--muted); }
/* Replenishment (Part 6): an Order row stands out */
.tbl tr.flag td { background: var(--danger-bg); }
