@import url('https://fonts.googleapis.com/css2?family=Archivo:wght@600;700;800&family=Lato:wght@400;700&display=swap');

:root {
  --primary: #046bd2;
  --primary-2: #1b6ee5;
  --secondary: #00b3ff;
  --navy: #02142a;
  --navy-2: #0d1f3c;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --line: #e2e7ee;
  --text: #1e293b;
  --muted: #64748b;
  --ok: #0f8a5f;     --ok-bg: #e5f6ef;
  --warn: #b45309;   --warn-bg: #fdf3e2;
  --bad: #c0392b;    --bad-bg: #fdecea;
  --info-bg: #e8f1fc;
  --gray-bg: #eef1f5;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(2, 20, 42, .06), 0 4px 14px rgba(2, 20, 42, .05);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 Lato, Inter, sans-serif;
}
h1, h2, h3, .brand { font-family: Archivo, sans-serif; margin: 0; }
a { color: var(--primary); }
button, input, select, textarea { font: inherit; color: inherit; }

/* ── buttons & fields ── */
.btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 700; white-space: nowrap;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); }
.btn.ghost { background: transparent; border-color: rgba(255,255,255,.25); color: #fff; }
.btn.ghost:hover { border-color: #fff; color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }

label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 700; color: var(--muted); }
.input, select.input, textarea.input {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff;
  font-weight: 400; font-size: 14px; color: var(--text); width: 100%;
}
.input:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
textarea.input { min-height: 70px; resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 400; color: var(--text); }

/* ── top bar ── */
.topbar {
  background: var(--navy); color: #fff; padding: 12px 24px;
  display: flex; align-items: center; gap: 16px; position: sticky; top: 0; z-index: 20;
}
.brand { font-size: 18px; font-weight: 800; letter-spacing: .2px; }
.brand span { color: var(--secondary); }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 13px; opacity: .8; }

main { max-width: 1440px; margin: 0 auto; padding: 20px 24px 60px; }

/* ── KPI tiles ── */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.kpi .label { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .4px; }
.kpi .value { font-family: Archivo, sans-serif; font-size: 26px; font-weight: 800; color: var(--navy); margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.kpi.alert .value { color: var(--bad); }

/* ── migration strip ── */
.panel { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.panel-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.panel-head h2 { font-size: 16px; color: var(--navy); }
.panel-head .muted { font-size: 13px; }
.muted { color: var(--muted); }
.migbar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--gray-bg); gap: 2px; }
.migbar div { height: 100%; }
.miglegend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 10px; font-size: 13px; }
.miglegend button { background: none; border: 0; padding: 0; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.miglegend button:hover b { color: var(--primary); }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ── toolbar ── */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.toolbar .input { width: auto; min-width: 140px; }
.toolbar input[type=search] { min-width: 240px; flex: 1; max-width: 360px; }
.toolbar .spacer { flex: 1; }

/* ── table ── */
.tablewrap { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted);
  background: #fafbfd; position: sticky; top: 0; cursor: pointer; user-select: none; white-space: nowrap;
}
th.sorted { color: var(--primary); }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #f7faff; }
tbody tr.sel { background: var(--info-bg); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td .cust { font-weight: 700; color: var(--navy); }
td .deal { color: var(--muted); font-size: 13px; }
td .small { font-size: 12px; color: var(--muted); }
td.next { max-width: 280px; font-size: 13px; }
tfoot td { font-weight: 700; background: #fafbfd; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

.pill {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap;
  background: var(--gray-bg); color: var(--text);
}
.pill.info { background: var(--info-bg); color: var(--primary); }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.navy { background: var(--navy); color: #fff; }
.late { color: var(--bad); font-weight: 700; }

/* ── drawer ── */
.scrim { position: fixed; inset: 0; background: rgba(2, 20, 42, .35); z-index: 30; display: none; }
.scrim.open { display: block; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(620px, 100vw); background: var(--surface);
  z-index: 31; transform: translateX(100%); transition: transform .18s ease; display: flex; flex-direction: column;
  box-shadow: -8px 0 30px rgba(2, 20, 42, .15);
}
.drawer.open { transform: none; }
.drawer header { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: center; }
.drawer header h2 { font-size: 18px; color: var(--navy); flex: 1; }
.drawer .body { padding: 16px 20px; overflow-y: auto; flex: 1; }
.drawer footer { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; align-items: center; }
.drawer footer .spacer { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.span2 { grid-column: span 2; }
.span3 { grid-column: 1 / -1; }
.section-title { font-family: Archivo, sans-serif; font-size: 13px; color: var(--navy); margin: 18px 0 8px; text-transform: uppercase; letter-spacing: .5px; }
.section-title:first-child { margin-top: 0; }
.err { color: var(--bad); font-size: 13px; min-height: 18px; }

.events { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.events li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.events .meta { color: var(--muted); font-size: 12px; }
.events .chg { margin-top: 2px; }
.events .chg s { color: var(--muted); }
.notebox { display: flex; gap: 8px; margin-bottom: 8px; }
.notebox .input { min-height: 38px; }

/* ── modal (password) ── */
.modal { position: fixed; inset: 0; display: none; place-items: center; z-index: 40; background: rgba(2, 20, 42, .5); }
.modal.open { display: grid; }
.modal .card { background: #fff; border-radius: 14px; padding: 24px; width: min(420px, calc(100vw - 32px)); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; }
.modal h2 { color: var(--navy); font-size: 20px; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff;
  padding: 10px 16px; border-radius: 8px; font-size: 13px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 50;
}
.toast.show { opacity: 1; }

/* ── login ── */
/* ── login ── */
.login-page { background: var(--bg); }
.login-split { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.login-hero {
  background: linear-gradient(160deg, var(--navy) 0%, var(--navy-2) 100%); color: #fff;
  padding: 36px 44px; display: flex; flex-direction: column; gap: 28px; position: relative; overflow: hidden;
}
.login-hero::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--primary-2); }
.login-logo { width: 150px; height: auto; filter: brightness(0) invert(1); }
.login-hero h1 { font-size: 40px; font-weight: 800; letter-spacing: -.5px; }
.login-hero-copy p { margin: 8px 0 0; color: #a9c6f5; font-size: 17px; max-width: 440px; }
.login-lockers { width: 100%; max-width: 620px; margin-top: auto; align-self: center; border-radius: 12px; background: #fff; padding: 18px; }
.login-foot { font-size: 12px; color: #7f93b3; }
.login-main { display: grid; place-items: center; padding: 24px 16px; }
.login-card { background: #fff; border-radius: 14px; box-shadow: var(--shadow); border: 1px solid var(--line); padding: 32px; width: min(400px, 100%); display: flex; flex-direction: column; gap: 14px; }
.login-card[hidden] { display: none; }
.login-card h2 { font-size: 22px; color: var(--navy); }
.login-card p { margin: 0; color: var(--muted); }
.login-row { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--primary); cursor: pointer; font-weight: 700; text-align: left; }
.linkbtn:hover { text-decoration: underline; }
.linkbtn:disabled { color: var(--muted); cursor: default; text-decoration: none; }
.code-input { font: 700 22px/1.2 ui-monospace, monospace; letter-spacing: 6px; }
.topbar .brand-logo { height: 24px; width: auto; filter: brightness(0) invert(1); display: block; }
.topbar .brand { display: flex; align-items: center; gap: 10px; }
@media (max-width: 860px) {
  .login-split { grid-template-columns: 1fr; }
  .login-hero { padding: 24px 16px; gap: 16px; }
  .login-hero h1 { font-size: 28px; }
  .login-lockers { display: none; }
}

@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 700px) {
  main { padding: 16px; }
  .topbar { padding: 12px 16px; flex-wrap: wrap; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .toolbar input[type=search] { min-width: 0; max-width: none; width: 100%; }
}

/* ── v2: tabs, inline edits, PO reader, integrations ── */
.tabs { display: flex; gap: 4px; margin-left: 12px; }
.tabs a {
  color: rgba(255,255,255,.75); text-decoration: none; padding: 7px 12px; border-radius: 8px;
  font-weight: 700; font-size: 14px;
}
.tabs a:hover { color: #fff; background: rgba(255,255,255,.08); }
.tabs a.active { color: #fff; background: var(--primary); }
.view { display: none; }
.view.active { display: block; }
.kpis { grid-template-columns: repeat(6, minmax(0, 1fr)); }

select.inl, input.inl {
  border: 1px solid transparent; background: transparent; border-radius: 6px; padding: 3px 4px;
  font-size: 13px; max-width: 140px; width: auto; cursor: pointer; color: var(--text);
}
select.inl[data-f=owner] { max-width: 92px; }
td.next { max-width: 220px; }
main { max-width: 1520px; }
select.inl:hover, input.inl:hover { border-color: var(--line); background: #fff; }
select.inl:focus, input.inl:focus { outline: 2px solid var(--primary); background: #fff; }
input.inl[type=date] { width: 128px; }
td.late input.inl { color: var(--bad); font-weight: 700; }
.editlink { font-size: 12px; font-weight: 700; color: var(--primary); }

.dropzone {
  border: 1.5px dashed #b9c6d6; border-radius: 10px; padding: 12px; text-align: center; color: var(--muted);
  font-size: 13px; cursor: pointer; background: #fafcff;
}
.dropzone:hover, .dropzone.over { border-color: var(--primary); color: var(--primary); }
.suggest { border: 1px solid #cfe0f6; background: #f5f9ff; border-radius: 10px; padding: 12px; margin-top: 10px; }
.suggest h3 { font-size: 14px; color: var(--navy); margin-bottom: 6px; }
.suggest table th, .suggest table td { padding: 6px 8px; font-size: 13px; background: transparent; position: static; }
.suggest .ev { color: var(--muted); font-size: 11px; max-width: 260px; }
.suggest .cur { color: var(--muted); }
.filelist { list-style: none; padding: 0; margin: 8px 0 0; font-size: 13px; }
.filelist li { padding: 4px 0; }
.readonly { background: var(--gray-bg) !important; }
.linkrow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; }
.mini { font-size: 12px; padding: 4px 9px; }
.status-line { font-size: 13px; margin: 6px 0 0; }
.inv-table td, .inv-table th { font-size: 13px; padding: 6px 8px; }
.banner { border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; font-size: 13px; }
.banner.ok { background: var(--ok-bg); color: var(--ok); }
.banner.bad { background: var(--bad-bg); color: var(--bad); }
.banner.warn { background: var(--warn-bg); color: var(--warn); }

@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } .tabs { order: 3; width: 100%; margin: 6px 0 0; } }
@media (max-width: 700px) { .kpis { grid-template-columns: 1fr 1fr; } }

/* margins */
#drawer { width: min(940px, 100vw); }
.mgrid { display: grid; grid-template-columns: 1fr; gap: 16px; }
#setForm { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
#catBody select.input { min-width: 96px; }
#catBody td { padding: 4px 6px; }
@media (max-width: 1100px) { .mgrid { grid-template-columns: 1fr; } }
table.lines td, table.lines th { padding: 5px 6px; font-size: 12.5px; }
table.lines input.input, table.lines select.input { padding: 4px 6px; font-size: 12.5px; }
table.lines input.n { width: 84px; text-align: right; }
table.lines input.q { width: 52px; text-align: right; }
table.lines input.d { width: 100%; min-width: 170px; }
td.est, span.est { color: var(--muted); font-style: italic; }
.msum { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.msum div { background: var(--bg, #f5f7fa); border-radius: 8px; padding: 8px 10px; font-size: 12px; color: var(--muted); }
.msum b { display: block; font-family: Archivo, sans-serif; font-size: 17px; color: var(--navy); font-variant-numeric: tabular-nums; }
.msum .bad b { color: var(--bad); } .msum .ok b { color: var(--ok); }
.msum .wide { grid-column: span 4; }
table.mtable td { white-space: nowrap; }
table.mtable th { white-space: normal; vertical-align: bottom; max-width: 96px; }
table.mtable td:first-child { white-space: normal; min-width: 180px; }
table.mtable td, table.mtable th { padding-left: 8px; padding-right: 8px; }
.gm-bad { color: var(--bad); font-weight: 700; } .gm-ok { color: var(--ok); font-weight: 700; } .gm-warn { color: var(--warn); font-weight: 700; }
#catBody input.input, #catBody select.input { padding: 4px 6px; font-size: 12.5px; }
#catBody input.n { width: 82px; text-align: right; }
@media (max-width: 760px) { .msum { grid-template-columns: 1fr 1fr; } .msum .wide { grid-column: span 2; } }

table.segs { width: 100%; margin-top: 12px; font-size: 13px; border-collapse: collapse; }
table.segs td:first-child { width: 46%; }
table.segs td .muted { font-size: 12px; }
table.segs th, table.segs td { padding: 5px 8px; border-bottom: 1px solid var(--line); }
table.segs tr.tot td { font-weight: 800; color: var(--navy); border-bottom: 0; }

/* inventory */
table.itable td, table.itable th { padding: 5px 6px; font-size: 12.5px; }
table.itable tbody tr { cursor: default; }
table.itable input.input, table.itable select.input { padding: 4px 6px; font-size: 12.5px; }
table.itable input.n { width: 84px; text-align: right; }
table.itable input.q { width: 52px; text-align: right; }
table.itable input[type=date] { width: 128px; }
table.itable input.w { min-width: 140px; }
table.itable tr.addrow td { background: #f5f9ff; }
.addunits { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.addunits .err { min-height: 0; align-self: center; }
#view-inventory .panel .tablewrap { max-height: 70vh; overflow: auto; }

/* Turnstile widget slot on the sign-in card */
.ts { min-height: 65px; margin: 4px 0 2px; }


/* ── UI polish (Nov 2026) ── */
:root { --muted: #566579; }
th { color: #4a5a70; font-size: 11.5px; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
a:focus-visible, button:focus-visible { outline-offset: 2px; }
tbody tr { cursor: default; }
td.next { min-width: 190px; max-width: 260px; }
.clamp2, .clamp3 { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
.clamp2 { -webkit-line-clamp: 2; line-clamp: 2; }
.clamp3 { -webkit-line-clamp: 3; line-clamp: 3; }
td .deal { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }

/* stage pills: one shape, chevron, never truncated */
select.inl.pill {
  -webkit-appearance: none; appearance: none; max-width: none; white-space: nowrap;
  border: 0; border-radius: 999px; padding: 3px 24px 3px 10px; font-size: 12px; font-weight: 700;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23566579' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; background-color: var(--gray-bg);
}
select.inl.pill.info { background-color: var(--info-bg); }
select.inl.pill.ok { background-color: var(--ok-bg); }
select.inl.pill.warn { background-color: var(--warn-bg); }
select.inl.pill.bad { background-color: var(--bad-bg); }
select.inl.pill:hover { box-shadow: inset 0 0 0 1px rgba(2, 20, 42, .15); }
.pill.sched, select.inl.pill.sched { background-color: #efe9fb; color: #5b3cc4; }

/* quiet row controls: pickers and chevrons show on row hover / focus */
select.inl[data-f=owner] { -webkit-appearance: none; appearance: none; padding-right: 4px; }
tbody tr:hover select.inl[data-f=owner], select.inl[data-f=owner]:focus {
  -webkit-appearance: auto; appearance: auto;
}
input.inl[type=date]::-webkit-calendar-picker-indicator { opacity: 0; transition: opacity .12s; cursor: pointer; }
tbody tr:hover input.inl[type=date]::-webkit-calendar-picker-indicator,
input.inl[type=date]:focus::-webkit-calendar-picker-indicator { opacity: .6; }

/* drawer sections read as sections */
.drawer .section-title { margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--line); }
.drawer .body > .section-title:first-child { margin-top: 0; padding-top: 0; border-top: 0; }

/* KPI alerts get an accent, not just red digits */
.kpi.alert { box-shadow: inset 3px 0 0 var(--bad), var(--shadow); }

/* tabs scroll sideways on small screens */
@media (max-width: 1100px) {
  .tabs { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs a { flex: 0 0 auto; }
}
#tbody td:first-child { min-width: 180px; }
#tbody td, #thead th { padding-left: 9px; padding-right: 9px; }
