/* Iconic Forge Cloud web app. Dark theme in the brand's gold. */
:root {
  --bg: #14110d;
  --panel: #1f1b16;
  --panel-2: #2a251e;
  --panel-3: #332d25;
  --line: #3a3329;
  --line-soft: #2c2720;
  --text: #f2ece2;
  --muted: #b3a894;
  --faint: #8a806f;
  --gold: #c9a24a;
  --gold-2: #e3c473;
  --bar: #b8923c;           /* chart bars: validated against --panel */
  --danger: #e8806b;
  --ok: #8cc788;
  --green: #6fbf73;
  --yellow: #e2c552;
  --red: #e8806b;
  --blue: #6aa6e8;
  --pending: #a99f8f;
  --radius: 14px;
  --sidebar: 256px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--gold-2); }
h1, h2, h3 { line-height: 1.25; }
.mono, code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .92em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { flex: none; }
[hidden] { display: none !important; }

/* --- Controls ------------------------------------------------------------- */
button, .button {
  appearance: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 14px;
  font: inherit; font-size: .95rem;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
button:hover, .button:hover { border-color: var(--gold); }
button:focus-visible, .button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--gold); outline-offset: 2px;
}
button.primary, .button.primary { background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: #1b150c; border: 0; font-weight: 600; }
button.danger, .button.danger { color: var(--danger); }
button.danger:hover { border-color: var(--danger); }
button.small, .button.small { padding: 5px 10px; font-size: .85rem; border-radius: 8px; }
button.wide { width: 100%; margin-top: 18px; padding: 12px; }
button.link { background: none; border: 0; color: var(--gold-2); padding: 4px 0; }
button:disabled { opacity: .55; cursor: default; }
.icon-btn { padding: 6px; border-radius: 8px; background: transparent; border-color: transparent; color: var(--muted); }
.icon-btn:hover { color: var(--text); border-color: var(--line); background: var(--panel-2); }
.icon-btn.danger:hover { color: var(--danger); }

input[type=email], input[type=password], input[type=text], input[type=search], input[type=date], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
}
textarea { resize: vertical; min-height: 70px; }
select { appearance: auto; }
label { display: block; font-size: .85rem; color: var(--muted); margin: 14px 0 6px; }
label.check { display: flex; gap: 8px; align-items: center; color: var(--text); margin: 0; font-size: .95rem; }
progress { width: 100%; height: 10px; accent-color: var(--gold); }

.msg { margin-top: 12px; font-size: .9rem; min-height: 1.2em; color: var(--danger); }
.msg.ok { color: var(--ok); }
.msg.error { color: var(--danger); }

/* --- Sign-in pages ---------------------------------------------------------- */
.auth {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 24px 16px 64px;
  background: radial-gradient(1200px 600px at 50% -200px, #2a2218 0%, var(--bg) 60%);
}
.logo { width: min(320px, 80vw); height: auto; margin: 32px 0 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; width: 100%; max-width: 420px; }
.card h1 { margin: 0 0 4px; font-size: 1.25rem; }
.card .sub { margin: 0 0 18px; color: var(--muted); font-size: .95rem; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .8rem; margin: 18px 0 0; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }

/* --- App layout ------------------------------------------------------------- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.mobilebar { display: none; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: #181410; border-right: 1px solid var(--line-soft);
  padding: 14px 10px 0; display: flex; flex-direction: column;
}
.side-logo { display: block; padding: 6px 8px 10px; }
.side-logo img { width: 170px; height: auto; display: block; }
.nav-section { font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); margin: 16px 10px 6px; }
.nav-item, .tree-link {
  display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 8px;
  color: var(--text); text-decoration: none; font-size: .93rem; line-height: 20px; min-height: 32px;
}
/* The sidebar scrolls; its items keep their height instead of squeezing to fit. */
.sidebar > * { flex-shrink: 0; }
.nav-item:hover, .tree-link:hover { background: var(--panel-2); }
.nav-item.active, .tree-row.active .tree-link { background: var(--panel-3); color: var(--gold-2); }
.nav-item .icon, .tree-link .icon { color: var(--muted); }
.nav-item.active .icon, .tree-row.active .tree-link .icon { color: var(--gold-2); }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-badge { background: #5a2a20; color: #ffcbbd; border-radius: 999px; font-size: .75rem; padding: 0 7px; font-variant-numeric: tabular-nums; }
.nav-item.soon { color: var(--faint); cursor: default; }
.nav-item.soon:hover { background: none; }
.nav-soon { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); border: 1px solid var(--line); border-radius: 6px; padding: 0 5px; }
.tree-row { position: relative; }
.tree-row.has-kids .tree-link { padding-right: 34px; }
.tree-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center; width: 26px; height: 26px; padding: 0;
  border: 0; background: none; color: var(--muted); border-radius: 6px; cursor: pointer;
}
.tree-toggle:hover { background: var(--panel-3); color: var(--text); }
.tree-toggle .icon { transition: transform .15s; }
.tree-toggle.open .icon { transform: rotate(90deg); }
.nav-foot { margin-top: auto; position: sticky; bottom: 0; background: #181410; border-top: 1px solid var(--line-soft); padding: 8px 0 10px; }
.nav-user { display: flex; align-items: center; gap: 8px; padding: 4px 10px; color: var(--muted); font-size: .85rem; }
.nav-user .nav-label { flex: 1; }
.content { min-width: 0; padding: 22px clamp(16px, 3vw, 36px) 64px; outline: none; }
.loading { color: var(--muted); padding: 40px 0; }
.scrim { display: none; }

/* --- Page header ------------------------------------------------------------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { margin: 0; font-size: 1.6rem; }
.page-sub { margin: 2px 0 0; color: var(--muted); }
.page-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.search-wrap { position: relative; margin: 0; display: block; }
.search-wrap .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
input.search { padding-left: 34px; width: min(360px, 70vw); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-top: 18px; }
.panel-title { font-size: 1.05rem; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.panel-title.red { color: var(--red); }
.panel-title.ok { color: var(--ok); }
.panel-foot { display: flex; align-items: center; gap: 14px; margin-top: 12px; }
.note { color: var(--muted); font-size: .92rem; margin: 0 0 12px; }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty h2 { color: var(--text); margin: 0 0 6px; }
.empty.small { padding: 28px 16px; }
.empty-hero { background: var(--panel); border: 1px dashed var(--gold); border-radius: var(--radius); padding: 22px; margin-bottom: 18px; }
.empty-hero h2 { margin: 0 0 4px; }
.empty-hero p { color: var(--muted); margin: 0 0 14px; }
.row-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 14px; }
.empty-hero .row-actions, .panel .row-actions { justify-content: flex-start; }

/* --- Dashboard ---------------------------------------------------------------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.tile {
  display: flex; align-items: center; gap: 14px; padding: 18px; min-height: 96px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; color: var(--text); text-decoration: none;
}
.tile.link:hover { border-color: var(--gold); }
.tile-icon { width: 44px; display: flex; justify-content: center; }
.tile-icon.red { color: var(--red); } .tile-icon.orange { color: #e9a15a; } .tile-icon.green { color: var(--green); }
.tile-icon.blue { color: var(--blue); } .tile-icon.teal { color: #5fc4b8; } .tile-icon.purple { color: #b48ce6; }
.tile-icon.indigo { color: #8d97ea; } .tile-icon.gray { color: var(--faint); }
.tile-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.tile-num { font-size: 1.65rem; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-lbl { color: var(--muted); font-size: .9rem; }
.tile-chev { color: var(--faint); }
.low-row {
  display: flex; width: 100%; justify-content: space-between; align-items: center; gap: 12px; text-align: left;
  background: none; border: 0; border-bottom: 1px solid var(--line-soft); border-radius: 0; padding: 10px 2px;
}
.low-row:hover { background: var(--panel-2); border-color: var(--line-soft); }
.low-name { display: flex; flex-direction: column; min-width: 0; }
.low-name strong { font-weight: 600; white-space: normal; }
.low-name .muted { font-size: .85rem; white-space: normal; }
.low-qty { color: var(--red); font-weight: 600; font-variant-numeric: tabular-nums; }

/* Charts */
.chart { margin: 0; }
.chart-title { font-weight: 600; margin-bottom: 14px; }
.hbars { display: grid; gap: 8px; }
.hbar-row { display: grid; grid-template-columns: minmax(90px, 200px) 1fr; gap: 12px; align-items: center; }
.hbar-label { color: var(--text); text-decoration: none; font-size: .9rem; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.hbar-label:hover { color: var(--gold-2); }
.hbar-track { display: flex; align-items: center; gap: 8px; min-width: 0; border-left: 1px solid var(--line); }
.hbar-fill { height: 16px; background: var(--bar); border-radius: 0 4px 4px 0; min-width: 0; }
.hbar-fill:hover, .hbar-fill:focus { filter: brightness(1.15); }
.hbar-value { font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cols { display: grid; grid-template-columns: auto 1fr; gap: 8px; height: 190px; }
.cols-axis { display: flex; flex-direction: column; justify-content: space-between; font-size: .75rem; color: var(--faint); text-align: right; padding-bottom: 22px; margin-top: -7px; }
.cols-plot { position: relative; }
.cols-grid { position: absolute; inset: 0 0 22px 0; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.cols-grid span { border-top: 1px solid var(--line-soft); }
.cols-grid span:last-child { border-top-color: var(--line); }
.cols-bars { position: absolute; inset: 0; display: flex; gap: 2px; }
.col { flex: 1; display: flex; flex-direction: column; align-items: center; min-width: 0; }
.col-slot { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.col-fill { width: min(24px, 70%); background: var(--bar); border-radius: 4px 4px 0 0; }
.col-fill.zero { height: 0 !important; }
.col-fill:hover, .col-fill:focus { filter: brightness(1.15); }
.col-label { height: 22px; line-height: 22px; font-size: .75rem; color: var(--faint); }
.chart-tip {
  position: fixed; z-index: 50; display: none; pointer-events: none;
  background: #0d0b08; color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 5px 9px; font-size: .85rem; box-shadow: 0 6px 20px rgba(0, 0, 0, .45);
}
.chart-table { margin-top: 12px; font-size: .88rem; }
.chart-table summary { color: var(--muted); cursor: pointer; }
.chart-table table { margin-top: 8px; border-collapse: collapse; }
.chart-table th, .chart-table td { padding: 3px 14px 3px 0; text-align: left; font-weight: normal; }
.chart-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* --- Inventory table ------------------------------------------------------- */
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table.parts { width: 100%; border-collapse: collapse; font-size: .93rem; }
table.parts th {
  position: sticky; top: 0; background: var(--panel); z-index: 1;
  text-align: left; font-weight: 600; color: var(--muted); font-size: .8rem; padding: 0 10px; height: 38px;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.parts td { padding: 7px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.parts tbody tr { cursor: pointer; }
table.parts tbody tr:hover { background: #241f19; }
table.parts tbody tr:last-child td { border-bottom: 0; }
.sort { background: none; border: 0; padding: 0; color: inherit; font: inherit; font-weight: 600; gap: 4px; }
.sort-arrow { font-size: .65rem; color: var(--gold-2); }
.c-check { width: 34px; padding-right: 0 !important; }
.c-check input { width: 16px; height: 16px; accent-color: var(--gold); }
.c-num, .c-grade { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
th.c-num .sort, th.c-grade { justify-content: flex-end; width: 100%; }
.c-grade { width: 36px; }
td.low { color: var(--red); font-weight: 700; }
.g-green { color: var(--green); } .g-yellow { color: var(--yellow); } .g-red { color: var(--red); }
.g-blue { color: var(--blue); } .g-pending { color: var(--pending); }
.c-mpn { white-space: nowrap; }
.c-cat { max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: .88rem; }
.c-more { width: 40px; text-align: right; }
.part-cell { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.thumb { width: 34px; height: 34px; border-radius: 6px; object-fit: contain; background: #fff; flex: none; }
.thumb.none { background: var(--panel-2); display: flex; align-items: center; justify-content: center; color: var(--faint); }
.part-text { display: flex; flex-direction: column; min-width: 0; }
.part-name { background: none; border: 0; padding: 0; text-align: left; font-weight: 600; color: var(--text); white-space: normal; justify-content: flex-start; }
.part-name:hover { color: var(--gold-2); }
.part-desc { color: var(--muted); font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 380px; }
.bulk-bar {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px; padding: 8px 12px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
}
.bulk-bar span { margin-right: auto; }

/* Popup menu */
.menu-pop {
  position: fixed; z-index: 60; min-width: 180px; padding: 6px;
  background: #221d17; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 30px rgba(0, 0, 0, .5);
}
.menu-item { display: flex; width: 100%; justify-content: flex-start; background: none; border: 0; border-radius: 6px; padding: 7px 10px; font-size: .92rem; }
.menu-item:hover, .menu-item:focus { background: var(--panel-3); outline: none; }
.menu-item.danger { color: var(--danger); }
.menu-sep { border-top: 1px solid var(--line); margin: 5px 4px; }

/* --- Dialogs ------------------------------------------------------------------ */
dialog.modal {
  border: 1px solid var(--line); border-radius: 16px; padding: 0; background: var(--panel); color: var(--text);
  width: min(460px, calc(100vw - 24px)); max-height: calc(100vh - 32px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55);
}
dialog.modal.wide { width: min(1060px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(5, 4, 3, .65); }
.dialog { padding: 22px; }
.dialog h2 { margin: 0 0 8px; font-size: 1.15rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.toggle-list { display: grid; gap: 4px; margin-top: 10px; }

/* Part editor */
.editor { display: flex; flex-direction: column; max-height: calc(100vh - 34px); }
.editor-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.editor-head h2 { margin: 0; font-size: 1.15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.head-link {
  display: inline-flex; align-items: center; gap: 6px; flex: none; font-size: .88rem; text-decoration: none; white-space: nowrap;
  padding: 5px 11px; border: 1px solid var(--line); border-radius: 8px; color: var(--gold-2);
}
.head-link:hover { border-color: var(--gold); background: var(--panel-2); }
.editor-body { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; padding: 16px 18px; overflow-y: auto; }
.editor-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.editor-foot { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--line); }
.editor-foot .msg { margin: 0; }
.spacer { flex: 1; }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px 14px; margin: 0; background: #1b1713; }
legend { padding: 0 6px; color: var(--gold-2); font-size: .85rem; font-weight: 600; }
.field { margin: 10px 0 0; }
.field:first-of-type { margin-top: 2px; }
.field-label { display: block; margin-bottom: 5px; }
.field-note { color: var(--faint); font-size: .8rem; }
.field-note.block { display: block; margin: 4px 0 0; }
p.field-note { margin: 8px 0 0; }
.inline { display: flex; gap: 6px; align-items: center; }
.toggle { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 10px 0 0; color: var(--text); font-size: .95rem; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle-ui { width: 36px; height: 20px; border-radius: 999px; background: var(--panel-3); border: 1px solid var(--line); position: relative; flex: none; transition: background .15s; }
.toggle-ui::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.toggle input:checked + .toggle-ui { background: var(--gold); border-color: var(--gold); }
.toggle input:checked + .toggle-ui::after { transform: translateX(16px); background: #1b150c; }
.toggle input:focus-visible + .toggle-ui { outline: 2px solid var(--gold); outline-offset: 2px; }
.toggle.compact { margin: 0; font-size: .8rem; color: var(--muted); gap: 6px; }
.grade-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 12px; }
.grade-cell { display: flex; flex-direction: column; align-items: center; gap: 4px; margin: 0; text-align: center; }
.grade-cell input { text-align: center; padding: 7px 4px; }
.grade-name { font-size: .78rem; color: var(--muted); }
.grade-badge { width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .8rem; color: #14110d; }
.grade-badge.green { background: var(--green); } .grade-badge.yellow { background: var(--yellow); } .grade-badge.red { background: var(--red); }
.grade-badge.blue { background: var(--blue); } .grade-badge.pending { background: var(--pending); }
.usable { margin-top: 10px; display: flex; justify-content: space-between; }
.photo-field { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.photo-box {
  width: 170px; height: 170px; border-radius: 12px; border: 1px dashed var(--line); background: var(--panel-2);
  display: flex; align-items: center; justify-content: center; cursor: pointer; overflow: hidden;
}
.photo-box img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.photo-box.drag { border-color: var(--gold); background: var(--panel-3); }
.photo-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--faint); font-size: .8rem; text-align: center; padding: 10px; }
.photo-actions { display: flex; flex-direction: column; gap: 8px; }

/* --- Settings ------------------------------------------------------------------- */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab { display: flex; align-items: center; gap: 6px; padding: 8px 12px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--gold-2); border-bottom-color: var(--gold); }
.settings-body { max-width: 860px; }
.list { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list-row { display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-bottom: 1px solid var(--line-soft); min-height: 46px; }
.list-row:last-child { border-bottom: 0; }
.panel .list-row { padding-left: 0; padding-right: 0; }
.list-row > .icon { color: var(--muted); }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .count { color: var(--muted); font-size: .85rem; white-space: nowrap; font-variant-numeric: tabular-nums; min-width: 54px; text-align: right; }
input.inline-name { flex: 1; min-width: 80px; background: transparent; border-color: transparent; padding: 6px 8px; }
input.inline-name:hover { border-color: var(--line); }
input.inline-name:focus { background: var(--panel-2); border-color: var(--gold); }
.list-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
fieldset.paired { margin-bottom: 14px; background: var(--panel); }
.paired-cols { display: grid; grid-template-columns: 1fr 2fr; gap: 12px; }
.paired-cols .field { margin: 0; }
.stack { display: grid; gap: 12px; }
.stack .field { margin: 0; }
.add-person { margin-top: 12px; }
.add-person summary { cursor: pointer; color: var(--gold-2); margin-bottom: 10px; }

/* --- Bulk import ------------------------------------------------------------------ */
.bulk { max-width: 900px; }
.howto ol { margin: 0; padding-left: 20px; display: grid; gap: 6px; color: var(--muted); }
.dropzone {
  margin-top: 18px; border: 2px dashed var(--line); border-radius: var(--radius); padding: 34px 18px; text-align: center; color: var(--muted);
  background: var(--panel);
}
.dropzone.drag { border-color: var(--gold); background: var(--panel-2); }
.dropzone p { margin: 10px 0 0; }
.summary ul { margin: 0 0 12px; padding-left: 20px; }
.summary .notes summary { cursor: pointer; color: var(--muted); }
.summary .notes ul { font-size: .88rem; }
.error-panel { border-color: #6b3328; }

/* --- Notices ------------------------------------------------------------------------ */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: #221d17; border: 1px solid var(--line); border-left: 3px solid var(--ok); border-radius: 10px; padding: 10px 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .45); transition: opacity .3s, transform .3s; }
.toast.error { border-left-color: var(--danger); }
.toast.leaving { opacity: 0; transform: translateY(6px); }

/* --- Narrow screens ------------------------------------------------------------------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .mobilebar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 20;
    background: #181410; border-bottom: 1px solid var(--line-soft); padding: 8px 12px;
  }
  .mobile-logo { height: 40px; width: auto; }
  .sidebar {
    position: fixed; z-index: 40; left: 0; top: 0; bottom: 0; width: min(300px, 86vw);
    transform: translateX(-105%); transition: transform .2s; box-shadow: 0 0 40px rgba(0, 0, 0, .6);
  }
  .nav-open .sidebar { transform: none; }
  .nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, .5); }
  .editor-body { grid-template-columns: 1fr; }
  .c-min, .c-price, .c-grade { display: none; }
}
@media (max-width: 640px) {
  .content { padding: 16px 12px 64px; }
  .page-head h1 { font-size: 1.35rem; }
  .page-actions { width: 100%; }
  .search-wrap { flex: 1; }
  input.search { width: 100%; }
  .c-mpn, .c-cat, .c-check { display: none; }
  .part-cell { min-width: 0; }
  .part-desc { max-width: 52vw; }
  dialog.modal, dialog.modal.wide { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; margin: 0; }
  .editor { max-height: 100dvh; height: 100%; }
  .grade-grid { gap: 5px; }
  .paired-cols { grid-template-columns: 1fr 1.6fr; }
  .hbar-row { grid-template-columns: minmax(70px, 34%) 1fr; }
  .tiles { grid-template-columns: 1fr 1fr; gap: 10px; }
  .tile { padding: 12px; gap: 8px; min-height: 80px; }
  .tile-icon { width: 28px; }
  .tile-num { font-size: 1.25rem; }
  .tile-chev { display: none; }
}

/* --- Stage 3: shared pieces --------------------------------------------------------- */
.nav-badge.quiet { background: var(--panel-3); color: var(--muted); }
.warn { color: var(--danger); }
.warn-soft { color: #e9a15a; }
.grow { flex: 1; min-width: 0; }
.pad { padding: 12px; }
.scroll { max-height: 50vh; overflow-y: auto; }
.inline.wrap { flex-wrap: wrap; }
.mono.big, input.big { font-size: 1.25rem; font-weight: 700; }
.prefixed { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: 9px; background: var(--panel-2); overflow: hidden; }
.prefixed input { border: 0; border-radius: 0; background: transparent; }
.prefixed .prefix { display: flex; align-items: center; padding: 0 4px 0 11px; color: var(--muted); font-family: ui-monospace, "SF Mono", Menlo, monospace; font-weight: 700; }
.prefixed.big .prefix { font-size: 1.25rem; }
.segmented { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.segmented button { border: 0; background: transparent; padding: 6px 14px; border-radius: 7px; color: var(--muted); }
.segmented button.on { background: var(--panel-3); color: var(--gold-2); }
.row2, .row3 { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.row3 { grid-template-columns: 1fr 80px 120px; }
.row2 .field, .row3 .field { margin-top: 10px; }
tr.static { cursor: default !important; }
.table-wrap.flat { border-radius: 10px; }
.inline-label { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--muted); }

/* Status badges (the Mac's colors) */
.status { display: inline-block; font-size: .78rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.s-scheduled { background: rgba(233, 161, 90, .18); color: #f0b070; }
.s-partOrderPending { background: rgba(232, 128, 107, .18); color: #f09884; }
.s-awaitingParts { background: rgba(176, 132, 90, .22); color: #d2a57a; }
.s-buildInProgress { background: rgba(106, 166, 232, .18); color: #86b8f0; }
.s-qualityCheck { background: rgba(180, 140, 230, .2); color: #c4a3ee; }
.s-built { background: rgba(111, 191, 115, .18); color: #8fd093; }
.s-overdue { background: rgba(232, 128, 107, .25); color: #ffb3a3; }
td.overdue { color: var(--danger); font-weight: 600; }

/* Split views (routines, reports) */
.split { display: grid; grid-template-columns: 280px 1fr; gap: 16px; align-items: start; }
.split-list { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px; max-height: calc(100vh - 160px); overflow-y: auto; position: sticky; top: 16px; }
.split-item { display: flex; flex-direction: column; padding: 9px 11px; border-radius: 9px; color: var(--text); text-decoration: none; }
.split-item:hover { background: var(--panel-2); }
.split-item.active { background: var(--panel-3); }
.split-item.active strong { color: var(--gold-2); }
.detail { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
.detail.empty { padding: 48px 20px; }
.detail-head { padding: 16px 18px; border-bottom: 1px solid var(--line); }
.detail-head h2 { margin: 0 0 4px; }
.detail-head p { margin: 2px 0; }
.title-input { font-size: 1.35rem; font-weight: 650; background: transparent; border-color: transparent; padding: 4px 6px; }
.title-input:hover { border-color: var(--line); }
.notes-input { margin-top: 6px; background: transparent; border-color: transparent; color: var(--muted); min-height: 44px; }
.notes-input:hover, .notes-input:focus { border-color: var(--line); background: var(--panel-2); }
.detail-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 18px; border-top: 1px solid var(--line); }
.line-section { padding: 12px 18px; }
.line-section + .line-section { border-top: 1px solid var(--line-soft); }
.line-title { display: flex; align-items: center; gap: 8px; font-size: .9rem; color: var(--gold-2); margin: 0 0 6px; }
.line-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line-soft); }
.line-row:last-child { border-bottom: 0; }
.line-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.line-text .missing { color: #e9a15a; }
.line-row input.line-note { width: 160px; flex: none; }
.line-row input.line-qty { width: 74px; flex: none; text-align: right; }
.line-row input.count-input { width: 64px; flex: none; }
.line-row .thumb { flex: none; }
.foot-notes p { margin: 0 0 6px; }
.foot-notes:empty { display: none; }
.line-note-ro { width: 160px; font-size: .88rem; }
.line-qty-ro { width: 60px; text-align: right; font-variant-numeric: tabular-nums; }

/* Build detail */
.build-dialog .build-detail { display: flex; flex-direction: column; max-height: calc(100vh - 34px); }
.build-body { overflow-y: auto; }
.editor-head h2 { margin: 0; }
.editor-head p { margin: 4px 0 8px; }
.banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 18px; }
.banner span { flex: 1; min-width: 200px; }
.b-progress { background: rgba(106, 166, 232, .1); color: #a9cbf2; }
.b-qc { background: rgba(180, 140, 230, .1); color: #d2baf2; }
.history-row { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; }
.editor-foot.column { flex-direction: column; align-items: stretch; }
.editor-foot.column p { margin: 0; }
.reclaim-row { padding: 8px 0; border-bottom: 1px solid var(--line-soft); }

/* Part picker */
.picker-dialog { width: min(560px, calc(100vw - 24px)); }
.picker-list { margin-top: 10px; height: min(380px, 50vh); overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; background: #1b1713; }
.picker-row { display: flex; width: 100%; align-items: center; gap: 10px; justify-content: flex-start; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line-soft); border-radius: 0; padding: 7px 10px; }
.picker-row:hover { background: var(--panel-2); }
.picker-row.selected { background: var(--panel-3); outline: 1px solid var(--gold); outline-offset: -1px; }
.picker-text { display: flex; flex-direction: column; flex: 1; min-width: 0; white-space: normal; }
.picker-text .muted { font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-stock { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.picker-stock.low { color: var(--danger); }

/* Scanning */
.scan-card .panel-title { margin: 0; }
.scan-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.scan-form { display: flex; align-items: center; gap: 10px; color: var(--gold-2); }
.scan-input { font: 600 1.25rem ui-monospace, "SF Mono", Menlo, monospace !important; padding: 11px 13px !important; }
.scan-result { display: flex; align-items: center; gap: 6px; margin: 10px 0 0; font-size: .92rem; }
.scan-result.ok { color: var(--ok); }
.scan-result.bad { color: #e9a15a; }
.scan-summary { margin: 12px 2px 0; font-size: .88rem; }
.count-input { text-align: center; font-variant-numeric: tabular-nums; }
.grade-badge.small { display: inline-flex; width: 18px; height: 18px; font-size: .68rem; vertical-align: 1px; }
.empty .icon { color: var(--faint); }

/* Reports */
.report-dialog .detail { border: 0; }
.dialog-actions.pad { padding: 0 18px 16px; margin: 0; }
.report-table td, .report-table th { font-size: .88rem; }

/* Label tools */
.tool-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 440px); gap: 20px; align-items: start; }
.tool-form .note { max-width: 640px; }
.form-panel { margin-top: 0; display: grid; gap: 10px; }
.form-panel .field, .form-panel .check { margin: 0; }
.form-stack { display: grid; gap: 14px; }
.form-stack fieldset { background: var(--panel); }
.form-stack .check { margin-top: 10px; }
.tool-preview { position: sticky; top: 16px; display: grid; gap: 10px; }
.preview-frame { background: #2a251e; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; justify-content: center; overflow: auto; }
.label-preview, .sheet-preview { background: #fff; box-shadow: 0 4px 18px rgba(0, 0, 0, .4); border-radius: 3px; max-width: 100%; height: auto; }
.tool-actions { display: flex; gap: 10px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.tool-actions .msg { margin: 0; flex: 1; }
.label-preview-box { display: flex; justify-content: center; margin-top: 12px; padding: 12px; background: #2a251e; border-radius: 10px; }
.serial-preview { display: block; padding: 8px 10px; background: var(--panel-2); border-radius: 8px; font-size: .95rem; color: var(--gold-2); overflow-wrap: anywhere; }
.sort-box { display: inline-flex; width: 28px; height: 28px; align-items: center; justify-content: center; background: #000; color: #fff; border: 1px solid var(--line); border-radius: 5px; font-weight: 800; }

@media (max-width: 1100px) {
  .tool-grid { grid-template-columns: 1fr; }
  .tool-preview { position: static; }
}
@media (max-width: 900px) {
  .split { grid-template-columns: 1fr; }
  .split-list { position: static; max-height: 260px; }
}
@media (max-width: 640px) {
  .line-row { flex-wrap: wrap; }
  .line-row input.line-note { width: auto; flex: 1; }
  .row3 { grid-template-columns: 1fr 70px; }
  .row3 .field:last-child { grid-column: 1 / -1; }
  .builds-table .c-sched { display: none; }
  .scan-form .icon { display: none; }
}

/* --- Part activity history ------------------------------------------------------------ */
.tile-icon.gold { color: var(--gold-2); }
.history-tiles { margin-bottom: 4px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .history-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.history-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 20px 0 12px; }
table.history tbody tr { cursor: default; }
table.history td { vertical-align: top; }
table.history .c-when { white-space: nowrap; color: var(--muted); }
table.history .c-details { min-width: 240px; }
table.history .c-by { white-space: nowrap; color: var(--muted); }
.act { display: inline-block; font-size: .8rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.act-addition { background: rgba(111, 191, 115, .16); color: #8fd093; }
.act-subtraction { background: rgba(232, 128, 107, .16); color: #f09884; }
.act-verification { background: rgba(106, 166, 232, .16); color: #86b8f0; }
.act-unchanged, .act-edit { background: var(--panel-2); color: var(--muted); }
.history-note { margin-top: 12px; }
.notice { background: rgba(232, 128, 107, .12); border: 1px solid rgba(232, 128, 107, .35); color: #f3b3a5; padding: 10px 14px; border-radius: 10px; }
@media (max-width: 760px) {
  table.history thead { display: none; }
  table.history, table.history tbody, table.history tr, table.history td { display: block; width: 100%; }
  table.history tr { padding: 10px 14px; border-bottom: 1px solid var(--line-soft); }
  table.history tbody tr:last-child { border-bottom: 0; }
  table.history td { border: 0; padding: 2px 0; text-align: left !important; white-space: normal; }
  table.history td::before { content: attr(data-label); display: inline-block; width: 74px; color: var(--faint); font-size: .78rem; }
  table.history .c-details { min-width: 0; }
  table.history td:empty { display: none; }
  .history-bar .segmented { display: flex; width: 100%; }
  .history-bar .segmented button { flex: 1 1 auto; padding: 6px 4px; font-size: .86rem; }
  .history-tiles .tile { padding: 14px; gap: 10px; min-height: 0; }
  .history-tiles .tile-num { font-size: 1.3rem; }
}
