/* IP Elements MRP — redesigned stylesheet (drop-in replacement for app/static/style.css).
   Tokens from the IP Elements design system: ink/white two-tone + ultramarine accent.
   Fonts: Oxanium (display), Barlow (body), IBM Plex Mono (data) — load via the <link>
   tags shown in README.md. Class names match the existing Jinja templates; the only
   markup change needed is the grouped topbar nav (snippet in README.md). */

:root {
  /* palette */
  --ink: #23242B; --ink-2: #3B3D47; --ink-3: #5D606D;
  --steel-1: #8A8D99; --steel-2: #C6C9D2; --steel-3: #E4E6EB;
  --paper: #F4F5F7; --white: #FFFFFF;
  --blue: #130AAE; --blue-hover: #0D077E; --blue-tint: #EAE9F9;
  --ok: #1D7A4F; --ok-tint: #E7F2EC;
  --warn: #9A6A00; --warn-tint: #F6EFDC;
  --danger: #B42D22; --danger-tint: #F8E9E7;
  /* type */
  --font-display: 'Oxanium', system-ui, sans-serif;
  --font-body: 'Barlow', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
  /* legacy variable names used across the old sheet, remapped */
  --muted: var(--steel-1);
  --line: var(--steel-3);
  --card: var(--white);
  --accent: var(--blue);
  --accent-soft: var(--blue-tint);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--ink);
  background: var(--white);
}

/* ---- topbar (ink band, grouped dropdown nav — markup in README.md) ---- */
.topbar {
  display: flex; align-items: center; gap: 6px;
  padding: 0 24px; min-height: 56px;
  background: var(--ink); color: #fff;
  position: sticky; top: 0; z-index: 60;
}
.topbar .brand {
  display: flex; align-items: center; gap: 10px; margin-right: 16px;
  font-family: var(--font-display); font-weight: 600; font-size: 14px;
  letter-spacing: .14em; text-transform: uppercase;
}
.topbar .brand img { height: 26px; display: block; }
.topbar nav { display: flex; align-items: stretch; flex-wrap: wrap; flex: 1; }
.topbar a {
  display: flex; align-items: center; min-height: 56px; padding: 0 13px;
  font-family: var(--font-display); font-size: 12px; font-weight: 500;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--steel-2); text-decoration: none;
}
.topbar a:hover { color: #fff; text-decoration: none; }
.topbar a.active, .topbar details[open] > summary { color: #fff; box-shadow: inset 0 -2px 0 0 #fff; }
.topbar .spacer { flex: 1; }
.topbar .topbar-user {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .06em;
  text-transform: uppercase; color: var(--steel-2);
}
.topbar a.muted { color: var(--steel-1); }
/* grouped dropdowns */
.topbar details { position: relative; }
.topbar summary {
  display: flex; align-items: center; min-height: 56px; padding: 0 13px;
  font-family: var(--font-display); font-size: 12px; font-weight: 500;
  letter-spacing: .08em; text-transform: uppercase; color: var(--steel-2);
  cursor: pointer; list-style: none; user-select: none;
}
.topbar summary::-webkit-details-marker { display: none; }
.topbar summary::after { content: "\25BE"; font-size: 9px; margin-left: 6px; opacity: .65; }
.topbar summary:hover { color: #fff; }
.topbar details > div {
  position: absolute; top: 100%; left: 0; min-width: 232px; z-index: 50;
  background: var(--white); border: 1px solid var(--steel-3);
  border-radius: 0 0 2px 2px; padding: 6px 0;
  box-shadow: 0 2px 8px rgba(35,36,43,.10), 0 12px 40px rgba(35,36,43,.16);
}
.topbar details > div a {
  display: block; min-height: 0; padding: 9px 16px;
  font-family: var(--font-body); font-size: 14px; font-weight: 400;
  letter-spacing: 0; text-transform: none; color: var(--ink);
}
.topbar details > div a:hover { background: var(--paper); color: var(--blue); box-shadow: none; }

main { max-width: 1140px; margin: 0 auto; padding: 36px 32px 96px; }

/* ---- headings: Oxanium, sentence case ---- */
h1 { font-family: var(--font-display); font-size: 31px; font-weight: 600; letter-spacing: -.01em; margin: 4px 0 16px; }
h2 { font-family: var(--font-display); font-size: 17px; font-weight: 600; margin: 40px 0 12px; }
h3 { font-family: var(--font-display); font-size: 14px; font-weight: 600; margin: 28px 0 10px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ---- tables: datasheet register ---- */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border: 1px solid var(--steel-3);
  border-radius: 4px;
}
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--steel-3); font-size: 14px; }
th {
  background: var(--paper);
  font-family: var(--font-display); font-size: 11px; font-weight: 500;
  letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3);
  border-bottom: 1px solid var(--steel-2); white-space: nowrap;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--paper); }
td.num, th.num { text-align: right; }
td.num { font-family: var(--font-mono); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.inactive td { color: var(--steel-1); }
td.arith, .arith { font-family: var(--font-mono); font-size: 12px; }

a { color: var(--blue); text-decoration: none; font-weight: 500; }
a:hover { color: var(--blue-hover); text-decoration: underline; }

/* ---- buttons: machined 2px corners, uppercase display labels ---- */
.button, button {
  display: inline-block;
  background: var(--ink); color: #fff;
  border: 1px solid var(--ink); border-radius: 2px;
  padding: 10px 18px;
  font-family: var(--font-display); font-size: 12px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
  cursor: pointer; text-decoration: none;
  transition: background 120ms cubic-bezier(.4,0,.2,1), border-color 120ms cubic-bezier(.4,0,.2,1);
}
.button:hover, button:hover { background: var(--blue); border-color: var(--blue); color: #fff; text-decoration: none; filter: none; }
.button:focus-visible, button:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.button.secondary, button.secondary { background: var(--white); color: var(--ink); border: 1px solid var(--ink); }
.button.secondary:hover, button.secondary:hover { background: var(--ink); color: #fff; }
.link-button {
  background: none; border: none; color: var(--danger);
  padding: 0; font-family: var(--font-body); font-size: 13px; font-weight: 400;
  letter-spacing: 0; text-transform: none; text-decoration: none; cursor: pointer;
}
.link-button:hover { text-decoration: underline; background: none; border: none; }

/* ---- KPI cards ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 24px 0; }
.card {
  background: var(--white); border: 1px solid var(--steel-3); border-radius: 4px;
  padding: 16px 18px; min-width: 0;
  font-family: var(--font-display); font-size: 11px; font-weight: 500;
  letter-spacing: .08em; text-transform: uppercase; color: var(--steel-1);
}
.card .big { font-family: var(--font-display); font-size: 31px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.card:hover { border-color: var(--ink); }

/* ---- forms ---- */
.entity-form {
  max-width: 680px; background: var(--white);
  border: 1px solid var(--steel-3); border-radius: 4px; padding: 24px;
}
.entity-form label {
  display: block; margin-bottom: 16px;
  font-family: var(--font-display); font-size: 12px; font-weight: 500;
  letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2);
}
.entity-form input[type="text"], .entity-form input[type="number"], .entity-form input[type="date"],
.entity-form input[type="email"], .entity-form input[type="password"], .entity-form select, .entity-form textarea {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px;
  border: 1px solid var(--steel-2); border-radius: 2px;
  font-family: var(--font-body); font-size: 15px; color: var(--ink); background: var(--white);
  transition: border-color 120ms cubic-bezier(.4,0,.2,1);
}
.entity-form input:hover, .entity-form select:hover, .entity-form textarea:hover { border-color: var(--steel-1); }
.entity-form input:focus, .entity-form select:focus, .entity-form textarea:focus {
  outline: 2px solid var(--blue); outline-offset: 1px; border-color: var(--ink);
}
.entity-form .checkbox { display: flex; align-items: center; gap: 8px; color: var(--ink); text-transform: none; letter-spacing: 0; font-family: var(--font-body); font-size: 14px; }
.form-actions { display: flex; gap: 10px; margin-top: 16px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 24px; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }

.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 12px 0; }
.inline-form input, .inline-form select {
  padding: 9px 10px; border: 1px solid var(--steel-2); border-radius: 2px;
  font-family: var(--font-body); font-size: 14px; background: var(--white); color: var(--ink);
}
.inline-form input:focus, .inline-form select:focus { outline: 2px solid var(--blue); outline-offset: 1px; }

/* ---- flash / error ---- */
.flash {
  background: var(--blue-tint); border: 1px solid var(--blue); color: var(--blue);
  border-radius: 2px; padding: 10px 14px; margin: 16px 0; font-size: 14px;
}
.error {
  background: var(--danger-tint); border: 1px solid var(--danger); color: var(--danger);
  border-radius: 2px; padding: 10px 14px; margin: 16px 0; font-size: 14px;
}
.muted { color: var(--steel-1); }
.top-gap { margin-top: 32px; }
.current { color: var(--ink); font-weight: 600; border-bottom: 2px solid var(--blue); padding-bottom: 3px; }

/* ---- status badges: mono caps, tinted, 2px corners ---- */
.status {
  display: inline-block; padding: 3px 8px; border-radius: 2px;
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  letter-spacing: .04em; text-transform: uppercase; white-space: nowrap;
  background: var(--paper); color: var(--ink-2); border: 1px solid var(--steel-3);
}
.status-confirmed { background: var(--blue-tint); color: var(--blue); border-color: transparent; }
.status-in_progress { background: var(--blue-tint); color: var(--blue); border-color: transparent; }
.status-partially_received, .status-partially_shipped { background: var(--warn-tint); color: var(--warn); border-color: transparent; }
.status-received, .status-completed, .status-shipped { background: var(--ok-tint); color: var(--ok); border-color: transparent; }
.status-cancelled { background: var(--danger-tint); color: var(--danger); border-color: transparent; }

.shortfall { color: var(--danger); font-weight: 600; }

/* ---- login ---- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--paper); }
.login-card {
  background: var(--white); border: 1px solid var(--steel-3); border-radius: 4px;
  box-shadow: 0 1px 2px rgba(35,36,43,.06), 0 4px 16px rgba(35,36,43,.07);
  padding: 36px; width: 360px;
}
.login-card h1 { margin: 0 0 20px; font-size: 20px; }
.login-card label {
  display: block; margin-bottom: 16px;
  font-family: var(--font-display); font-size: 12px; font-weight: 500;
  letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2);
}
.login-card input {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px;
  border: 1px solid var(--steel-2); border-radius: 2px; font-family: var(--font-body); font-size: 15px;
}
.login-card button { width: 100%; }
.login-card form { margin: 0; }
.login-subtitle {
  font-family: var(--font-display); font-size: 11px; font-weight: 500;
  letter-spacing: .08em; text-transform: uppercase; color: var(--steel-1);
  margin: 14px 0 26px; padding-top: 14px; border-top: 1px solid var(--steel-3);
}
.login-note { font-family: var(--font-mono); font-size: 12px; color: var(--steel-1); margin: 18px 0 0; }

/* ---- assembly floor (tablet) ---- */
.floor-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-top: 20px; }
.floor-card {
  display: block; background: var(--white); border: 1px solid var(--steel-3);
  border-radius: 4px; padding: 24px; text-decoration: none; color: var(--ink); font-weight: 400;
}
.floor-card:hover { border-color: var(--ink); box-shadow: 0 1px 2px rgba(35,36,43,.06), 0 4px 16px rgba(35,36,43,.07); text-decoration: none; color: var(--ink); }
.floor-number { font-family: var(--font-display); font-size: 20px; font-weight: 600; }
.floor-product { margin: 8px 0 16px; font-size: 14px; color: var(--ink-3); }
.floor-progress { font-family: var(--font-display); font-size: 25px; font-weight: 600; margin-bottom: 12px; }
.floor-headline { font-size: 20px; }
.floor-actions { display: flex; flex-direction: column; gap: 16px; max-width: 480px; margin-top: 32px; }
.floor-actions form { display: flex; gap: 12px; }
.floor-button { font-size: 16px; padding: 18px 26px; min-height: 64px; flex: 1; }
.floor-input {
  font-family: var(--font-mono); font-size: 20px; padding: 14px; width: 260px;
  border: 1px solid var(--steel-2); border-radius: 2px; color: var(--ink);
}

/* ================================================================
   Stage B components — page eyebrows, spec strips, tab rows, trace
   trees, progress bars, attention cards, CSV cards. Values taken
   from the redesign mockup so they match the delivered screens.
   ================================================================ */

/* ---- page eyebrow / breadcrumb ---- */
.eyebrow {
  font-family: var(--font-display); font-size: 11px; font-weight: 500;
  letter-spacing: .08em; text-transform: uppercase; color: var(--steel-1);
  margin-bottom: 6px;
}
.eyebrow a { color: var(--steel-1); font-weight: 500; }
.eyebrow a:hover { color: var(--blue); text-decoration: none; }
.title-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.title-row h1 { margin: 0; }

/* ---- spec strip (detail-page meta band) ---- */
.spec {
  display: flex; gap: 40px; flex-wrap: wrap;
  background: var(--paper); border: 1px solid var(--steel-3); border-radius: 2px;
  padding: 14px 18px; margin: 20px 0 0;
}
.spec .k {
  font-family: var(--font-display); font-size: 10px; font-weight: 500;
  letter-spacing: .08em; text-transform: uppercase; color: var(--steel-1);
  margin-bottom: 3px;
}
.spec .v { font-size: 14px; }

/* ---- mono codes (SKUs, order and lot numbers, dates in left columns).
       Table cells resist wrapping; inline codes inside prose wrap normally,
       so long column-name lists cannot push a page wide. ---- */
.code { font-family: var(--font-mono); font-size: 13px; }
td.code { white-space: nowrap; }

/* ---- underline tab rows: Open|All filters and the planning views ---- */
.tabs { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; margin: 18px 0 20px; }
.tabs a {
  font-family: var(--font-mono); font-size: 12px; font-weight: 500;
  letter-spacing: .04em; text-transform: uppercase;
  color: var(--steel-1); padding-bottom: 3px;
}
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.current { color: var(--ink); font-weight: 600; border-bottom: 2px solid var(--blue); }

/* ---- trace trees ---- */
.trace-card { background: var(--white); border: 1px solid var(--steel-3); border-radius: 4px; padding: 20px 24px; }
ul.trace { list-style: none; margin: 0; padding: 0; }
ul.trace li { padding: 4px 0; font-size: 14px; }
ul.trace ul { list-style: none; margin: 4px 0; padding-left: 22px; border-left: 1px solid var(--steel-3); }
.ok { color: var(--ok); font-weight: 600; }

/* ---- floor progress ---- */
.floor-progress .denom { color: var(--steel-1); font-size: 17px; font-weight: 600; }
.progress-track { height: 3px; background: var(--steel-3); margin-top: 12px; }
.progress-track.thick { height: 4px; max-width: 480px; margin: 16px 0 0; }
.progress-fill { height: 100%; background: var(--ink); }

/* ---- dashboard: needs attention ---- */
.attention { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; margin: 12px 0 0; }
.attention .item { background: var(--white); border: 1px solid var(--steel-3); border-radius: 4px; padding: 16px 18px; }
.attention .subject { font-family: var(--font-mono); font-size: 14px; font-weight: 600; margin: 10px 0 4px; }
.attention .why { font-size: 13px; color: var(--ink-3); margin: 0 0 12px; }
.attention .go { font-family: var(--font-display); font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }

/* whole KPI cards are links */
a.card { display: block; }
a.card:hover { text-decoration: none; }

/* status dot for attention-worthy states */
.status.dot::before {
  content: ""; display: inline-block; width: 5px; height: 5px; border-radius: 50%;
  background: currentColor; margin-right: 6px; vertical-align: middle;
}

/* ---- CSV page ---- */
.grid-csv { display: grid; grid-template-columns: 1fr 1.4fr; gap: 24px; }
@media (max-width: 760px) { .grid-csv { grid-template-columns: 1fr; } }
.export-card { background: var(--white); border: 1px solid var(--steel-3); border-radius: 4px; }
.export-card a {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; font-size: 14px; font-weight: 400; color: var(--ink);
  border-bottom: 1px solid var(--steel-3);
}
.export-card a:last-child { border-bottom: none; }
.export-card a:hover { background: var(--paper); color: var(--blue); text-decoration: none; }
.export-card a::after { content: "\2192"; color: var(--steel-1); }
.import-card { background: var(--white); border: 1px solid var(--steel-3); border-radius: 4px; padding: 18px; margin-bottom: 12px; }
.import-card h3 { margin: 0 0 6px; }
.import-card p { margin: 0 0 10px; }

/* ---- handoff details ---- */

/* active nav section (set server-side from the route in base.html) */
.topbar summary.active { color: #fff; box-shadow: inset 0 -2px 0 0 #fff; }

/* totals rows: 1px ink top rule, weight 600 */
tr.total-row td { border-top: 1px solid var(--ink); font-weight: 600; }

/* narrower single-column creation forms */
.entity-form.narrow { max-width: 560px; }

/* planning suggestions: checkbox column and the arithmetic column */
td input[type="checkbox"] { width: 18px; height: 18px; }
td.arith, .arith { min-width: 240px; }

/* planning parameters: compact mono inputs */
.param-input {
  width: 64px; font-family: var(--font-mono); font-size: 13px;
  padding: 6px 8px; border: 1px solid var(--steel-2); border-radius: 2px;
  color: var(--ink); background: var(--white);
}
.param-input:focus { outline: 2px solid var(--blue); outline-offset: 1px; }

/* floor detail headline sits larger than a desk page */
h1.floor-h1 { font-size: 39px; }

/* spec-strip figure (lot on-hand) */
.spec .v.figure { font-family: var(--font-display); font-size: 20px; font-weight: 600; }

/* flagged cost sources */
.gap-note { font-family: var(--font-mono); font-size: 12px; color: var(--steel-1); margin-top: 3px; }

/* wider column gap where the design calls for 32px */
.grid-2.wide-gap { gap: 16px 32px; }

/* ---- phones: the floor control row cannot fit side by side; stack it.
       Tablets (the floor's real device) keep the row layout untouched. ---- */
@media (max-width: 560px) {
  .floor-actions form { flex-wrap: wrap; }
  .floor-input { width: 100%; }
}

/* ---- small screens: wide content scrolls inside its own box, never the page ---- */
@media (max-width: 900px) {
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  select, input, textarea { max-width: 100%; }
  .inline-form { max-width: 100%; }
  .topbar { flex-wrap: wrap; gap: 0; padding: 0 12px; }
  .topbar a, .topbar summary { min-height: 44px; }
  main { padding: 20px 16px 64px; }
}
