/* =====================================================================
   WMS-FSSCO Dashboard — Design tokens
   A light, professional working palette: white/soft-gray panels on a
   pale blue-gray ground, each module still keeping its own accent hue
   for quick wayfinding (sidebar dots, page accents, hazard badges) —
   just deepened enough from the original dark-theme brights to stay
   legible as text and borders on a light background.
   ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Condensed:wght@400;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  color-scheme: light;

  --ground:      #F2F4F8;
  --panel:       #FFFFFF;
  --panel-raised:#F6F8FB;
  --line:        #E1E6EE;

  --text:        #1E2733;
  --text-muted:  #5C6B7F;
  --text-faint:  #8B99AC;

  /* Core semantic accents */
  --amber:       #B4690A;
  --amber-dim:   #F1D6A3;
  --rust:        #C1342B;
  --rust-dim:    #F3C4BE;
  --signal:      #157A56;
  --signal-dim:  #BEE8D2;
  --steel:       #14748D;
  --steel-dim:   #BCE7EF;

  /* Extra module/wayfinding hues */
  --violet:      #6D42C7;
  --violet-dim:  #DCC9F5;
  --blue:        #2354C9;
  --blue-dim:    #C7D6F7;
  --pink:        #B32C6C;
  --pink-dim:    #F3C2DC;
  --orange:      #B84E0E;
  --orange-dim:  #F5CBA8;
  --gold:        #8E6D08;
  --gold-dim:    #E8D68A;

  --font-head: 'IBM Plex Sans Condensed', 'Arial Narrow', sans-serif;
  --font-body: 'IBM Plex Sans Condensed', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', monospace;

  --radius: 3px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ground);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}

::selection { background: var(--amber-dim); color: var(--text); }

a { color: var(--amber); text-decoration: none; }

/* ---------------------------------------------------------------- */
/* Shell layout                                                      */
/* ---------------------------------------------------------------- */

.shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 22px 0;
  display: flex;
  flex-direction: column;
}

.brand {
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}

.brand .mark {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.06em;
  background: linear-gradient(90deg, var(--amber), var(--pink) 60%, var(--violet));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand .sub {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 3px;
}

.brand .company {
  font-size: 12px;
  font-weight: 600;
  margin-top: 5px;
  background: linear-gradient(90deg, var(--steel), var(--blue) 70%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand .tagline {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 2px;
  background: linear-gradient(90deg, var(--amber), var(--signal) 80%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 10px;
}

.nav button {
  all: unset;
  cursor: pointer;
  padding: 9px 12px;
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav button .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-faint);
  flex-shrink: 0;
}

/* Each module gets its own wayfinding hue — the dot is always tinted so
   the sidebar reads as a color-coded map, not a flat list; the active
   item additionally gets a matching left border and soft background tint. */
.nav button[data-view="overview"]    .dot { background: var(--amber); }
.nav button[data-view="fefo"]        .dot { background: var(--violet); }
.nav button[data-view="stock"]       .dot { background: var(--steel); }
.nav button[data-view="receipts"]    .dot { background: var(--signal); }
.nav button[data-view="deliveries"]  .dot { background: var(--orange); }
.nav button[data-view="billing"]     .dot { background: var(--pink); }
.nav button[data-view="reports"]     .dot { background: var(--gold); }
.nav button[data-view="master"]      .dot { background: var(--blue); }
.nav button[data-view="admin"]       .dot { background: var(--rust); }

.nav button:hover { background: var(--panel-raised); color: var(--text); }
.nav button.active { background: var(--panel-raised); color: var(--text); border-left: 2px solid var(--amber); padding-left: 10px; }
.nav button[data-view="overview"].active    { border-left-color: var(--amber); }
.nav button[data-view="fefo"].active        { border-left-color: var(--violet); }
.nav button[data-view="stock"].active       { border-left-color: var(--steel); }
.nav button[data-view="receipts"].active    { border-left-color: var(--signal); }
.nav button[data-view="deliveries"].active  { border-left-color: var(--orange); }
.nav button[data-view="billing"].active     { border-left-color: var(--pink); }
.nav button[data-view="reports"].active     { border-left-color: var(--gold); }
.nav button[data-view="master"].active      { border-left-color: var(--blue); }
.nav button[data-view="admin"].active       { border-left-color: var(--rust); }

.sidebar-foot {
  margin-top: auto;
  padding: 14px 20px 0;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

.main {
  padding: 28px 34px 60px;
  max-width: 1180px;
}

.page-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 22px;
  flex-wrap: wrap;
  gap: 10px;
}

.page-head h1 {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 24px;
  margin: 0;
  letter-spacing: -0.01em;
}

.page-head .meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
}

/* ---------------------------------------------------------------- */
/* KPI strip                                                         */
/* ---------------------------------------------------------------- */

.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 26px;
}

.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
}

.kpi .label {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.kpi .value {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 600;
  color: var(--text);
}

.kpi .value.warn { color: var(--amber); }
.kpi .value.danger { color: var(--rust); }
.kpi .value.ok { color: var(--signal); }

.kpi { border-top: 2px solid var(--line); }
.kpi-row .kpi:nth-child(1) { border-top-color: var(--blue); }
.kpi-row .kpi:nth-child(2) { border-top-color: var(--amber); }
.kpi-row .kpi:nth-child(3) { border-top-color: var(--signal); }
.kpi-row .kpi:nth-child(4) { border-top-color: var(--orange); }

.kpi .bar { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: var(--line); }
.kpi .bar span { display: block; height: 100%; background: var(--steel); }
.kpi-row .kpi:nth-child(1) .bar span { background: var(--blue); }
.kpi-row .kpi:nth-child(4) .bar span { background: var(--orange); }

/* ---------------------------------------------------------------- */
/* Sub-navigation (option list -> details below)                     */
/* ---------------------------------------------------------------- */

.subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.subnav button {
  all: unset;
  cursor: pointer;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--text-muted);
  background: var(--panel);
  border: 1px solid var(--line);
}

.subnav button:hover { color: var(--text); border-color: var(--text-faint); }
.subnav button.active { color: var(--text); background: var(--panel-raised); border-color: var(--amber); }

.subgroup { display: none; }
.subgroup.active { display: block; }

/* ---------------------------------------------------------------- */
/* Panels & tables                                                   */
/* ---------------------------------------------------------------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 22px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  font-family: var(--font-head);
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}

.panel-head .hint { font-size: 12px; color: var(--text-faint); }

/* Reports page — each report gets its own heading color so the stacked
   panels are easy to tell apart at a glance instead of all reading as
   identical plain-white headings. Specificity has to match/beat
   ".panel-head h2" above (0,1,1), so these select on ".panel-head" too
   rather than the class alone. */
.panel-head h2.report-heading-inbound  { color: var(--signal); }
.panel-head h2.report-heading-outbound { color: var(--rust); }
.panel-head h2.report-heading-stock    { color: var(--steel); }
.panel-head h2.report-heading-item     { color: var(--violet); }
.panel-head h2.report-heading-batch    { color: var(--orange); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

thead th {
  text-align: left;
  padding: 9px 18px;
  color: var(--text-faint);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--line);
}

tbody td {
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  color: var(--text-muted);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--panel-raised); color: var(--text); }

td.mono, .mono { font-family: var(--font-mono); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 2px;
  font-size: 11px;
  font-family: var(--font-mono);
  border: 1px solid transparent;
}

/* Every hazard class gets its own hue rather than sharing amber/rust
   between four different classes — makes a mixed batch list scannable
   at a glance instead of everything reading as "orange = careful". */
.badge.hazard-FLAMMABLE                  { color: var(--rust);   border-color: var(--rust-dim);   background: rgba(240,82,79,0.14); }
.badge.hazard-CORROSIVE                  { color: var(--amber);  border-color: var(--amber-dim);  background: rgba(245,165,36,0.14); }
.badge.hazard-TOXIC                      { color: var(--violet); border-color: var(--violet-dim); background: rgba(164,123,245,0.14); }
.badge.hazard-OXIDIZER                   { color: var(--gold);   border-color: var(--gold-dim);   background: rgba(240,208,82,0.14); }
.badge.hazard-COMPRESSED_GAS             { color: var(--steel);  border-color: var(--steel-dim);  background: rgba(52,198,224,0.14); }
.badge.hazard-ENVIRONMENTALLY_HAZARDOUS  { color: var(--signal); border-color: var(--signal-dim); background: rgba(47,212,140,0.14); }
.badge.hazard-NONE                       { color: var(--text-faint); border-color: var(--line); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--text-muted);
}
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--text-faint); }
.pill.ok::before { background: var(--signal); }
.pill.warn::before { background: var(--amber); }
.pill.danger::before { background: var(--rust); }

.empty-state {
  padding: 30px 18px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
}

/* ---------------------------------------------------------------- */
/* Forms                                                              */
/* ---------------------------------------------------------------- */

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 18px;
}

.field { display: flex; flex-direction: column; gap: 5px; }
/* The HTML `hidden` attribute and this rule are both author-origin with
   equal specificity to a bare class selector, so `.field[hidden]` (one
   extra attribute selector) is needed to actually win over `.field`'s own
   `display: flex` above — otherwise toggling `.hidden = true` from JS
   (e.g. the GRN line's expiry field) has no visible effect at all. */
.field[hidden] { display: none; }
.field label { font-size: 11.5px; color: var(--text-faint); }
.field input, .field select, .field textarea {
  background: var(--ground);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  padding: 8px 10px;
  font-family: var(--font-body);
  font-size: 13.5px;
}
.field input:focus, .field select:focus { outline: 1px solid var(--steel); border-color: var(--steel); }

/* Item (SKU) picker — a combobox in place of a plain <select>: the visible
   field is what you type into to filter, matching the .cal-picker date
   field's look (see wireItemCombo in dashboard.js). */
.item-combo { position: relative; }
.item-combo-input {
  box-sizing: border-box;
  width: 100%;
  cursor: text;
  background: var(--ground);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  padding: 8px 10px;
  font-family: var(--font-body);
  font-size: 13.5px;
}
.item-combo-input:hover { border-color: var(--steel); }
.item-combo-input:focus { outline: 1px solid var(--steel); border-color: var(--steel); }
.item-combo-input::placeholder { color: var(--text-faint); }

.item-combo-pop {
  position: absolute;
  z-index: 40;
  top: calc(100% + 6px);
  left: 0;
  width: 100%;
  min-width: 220px;
  max-height: 240px;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px;
  box-shadow: 0 10px 26px rgba(30, 39, 51, 0.12);
}

.item-combo-list { display: flex; flex-direction: column; gap: 2px; }

.item-combo-option {
  all: unset;
  box-sizing: border-box;
  width: 100%;
  cursor: pointer;
  padding: 7px 8px;
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
}
.item-combo-option:hover { background: var(--panel-raised); color: var(--amber); }

.item-combo-empty { padding: 7px 8px; color: var(--text-faint); font-size: 12.5px; }

.form-actions { padding: 0 18px 18px; display: flex; gap: 10px; }

button.primary {
  all: unset;
  cursor: pointer;
  background: var(--amber);
  color: #FFFFFF;
  font-weight: 600;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: var(--radius);
}
button.primary:hover { filter: brightness(1.12); }

.two-col { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 18px; align-items: start; }

/* ---------------------------------------------------------------- */
/* Line-item builders (receipt / delivery forms)                     */
/* ---------------------------------------------------------------- */

.line-items {
  padding: 0 18px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.line-item {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr 1fr 1fr auto;
  gap: 8px;
  align-items: end;
  padding: 10px;
  background: var(--panel-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.line-item .field label { font-size: 10px; }
.line-item input, .line-item select {
  background: var(--ground);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  padding: 7px 8px;
  font-size: 13px;
  width: 100%;
  font-family: var(--font-body);
}

button.remove-line {
  all: unset;
  cursor: pointer;
  color: var(--rust);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 7px 8px;
  border: 1px solid var(--rust-dim);
  border-radius: var(--radius);
  text-align: center;
}
button.remove-line:hover { background: rgba(181,69,44,0.12); }

button.secondary {
  all: unset;
  cursor: pointer;
  border: 1px solid var(--line);
  color: var(--text-muted);
  font-size: 13px;
  padding: 9px 16px;
  border-radius: var(--radius);
}
button.secondary:hover { border-color: var(--steel); color: var(--text); }

button.secondary.sm {
  padding: 5px 10px;
  font-size: 11.5px;
}

a.print-link {
  font-size: 12px;
  color: var(--steel);
  border: 1px solid var(--line);
  padding: 3px 8px;
  border-radius: var(--radius);
}
a.print-link:hover { border-color: var(--steel); color: var(--amber); }
a.label-link { font-size: 12px; color: var(--steel); border: 1px solid var(--line); padding: 3px 8px; border-radius: var(--radius); }
a.label-link:hover { border-color: var(--steel); color: var(--amber); }

.inline-select {
  background: var(--ground);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 7px 10px;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 13px;
}

body.hide-labels .label-cell { display: none; }
body.hide-print-docs .print-link { display: none; }

/* Calendar date picker: click-only, every date chosen with the mouse from
   a shown month grid — no typing, no native OS picker. */

.cal-picker { position: relative; }

.cal-input {
  all: unset;
  box-sizing: border-box;
  cursor: pointer;
  display: block;
  width: 100%;
  background: var(--ground);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  padding: 8px 10px;
  font-family: var(--font-body);
  font-size: 13.5px;
}
.cal-input:hover { border-color: var(--steel); }
.cal-input .cal-placeholder { color: var(--text-faint); }

.cal-pop {
  position: absolute;
  z-index: 40;
  top: calc(100% + 6px);
  left: 0;
  width: 232px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  box-shadow: 0 10px 26px rgba(30, 39, 51, 0.12);
}

.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-title { font-family: var(--font-mono); font-size: 12.5px; color: var(--text); }

.cal-nav {
  all: unset;
  cursor: pointer;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  border-radius: var(--radius);
}
.cal-nav:hover { background: var(--panel-raised); color: var(--amber); }

.cal-dow, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-dow span { font-size: 10px; text-align: center; color: var(--text-faint); padding: 2px 0; }

.cal-cell {
  all: unset;
  box-sizing: border-box;
  width: 100%;
  cursor: pointer;
  text-align: center;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text);
  padding: 6px 0;
  border-radius: var(--radius);
}
.cal-cell.empty { cursor: default; }
.cal-cell.day:hover { background: var(--panel-raised); color: var(--amber); }
.cal-cell.today { border: 1px solid var(--steel); }
.cal-cell.selected { background: var(--amber-dim); color: var(--amber); }

button.secondary.sm.danger { color: var(--rust); border-color: var(--rust); }
button.secondary.sm.danger:hover { filter: brightness(1.15); }

.row-actions { display: flex; gap: 6px; }
.stock-hint { font-size: 12px; color: var(--text-faint); margin-top: 4px; }
.stock-hint.warn { color: var(--amber); }

.form-msg {
  padding: 0 18px 16px;
  font-size: 13px;
  font-family: var(--font-mono);
}
.form-msg.ok { color: var(--signal); }
.form-msg.error { color: var(--rust); }

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .line-item { grid-template-columns: 1fr 1fr; }
}

/* ---------------------------------------------------------------- */
/* Login screen                                                      */
/* ---------------------------------------------------------------- */

#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 15% 10%, rgba(109,66,199,0.08), transparent 45%),
    radial-gradient(circle at 85% 85%, rgba(180,105,10,0.08), transparent 45%),
    radial-gradient(circle at 85% 15%, rgba(20,116,141,0.07), transparent 40%),
    var(--ground);
}

.login-card {
  width: 320px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 3px solid var(--amber);
  border-radius: var(--radius);
  padding: 28px 24px;
  box-shadow: 0 20px 60px rgba(30, 39, 51, 0.14);
}

/* Toggle switches (Admin > Feature toggles) */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-row .label { font-size: 13.5px; color: var(--text); }
.toggle-row .desc { font-size: 11.5px; color: var(--text-faint); }

.switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 20px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--line); border-radius: 20px; transition: 0.15s;
}
.switch .track::before {
  content: ''; position: absolute; height: 14px; width: 14px; left: 3px; bottom: 3px;
  background: var(--text-muted); border-radius: 50%; transition: 0.15s;
}
.switch input:checked + .track { background: var(--signal-dim); }
.switch input:checked + .track::before { transform: translateX(18px); background: var(--signal); }
