/* Mykor look: the brand palette (navy, rust, teal, cream) and the website's warm off-whites, in DM Sans
   (standing in for the website's Macan). Backgrounds stay light; the graphs use the same colours (src/graphs/Chart.js). */
:root {
  --font: "DM Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --ink: #202334;        /* website navy text */
  --ink-2: #504b4d;      /* palette charcoal */
  --muted: #7a7376;
  --bg: #faf5ee;         /* page */
  --card: #fffcf9;       /* website off-white */
  --cream: #fff4e6;      /* website cream */
  --sand: #f6eee3;       /* table heads, chips */
  --border: #e8ddce;
  --line: #f1e9de;       /* table row rules */
  --accent: #183b5c;     /* palette navy: primary buttons */
  --accent-dark: #0f2a43;
  --link: #1f4e79;
  --rust: #c55439;       /* palette rust: highlights */
  --teal: #2a9d8f;
  --teal-pale: #e3f1ef;
  --navy-pale: #e1e9f1;
  --ochre-pale: #f8ecd0;
  --plum-pale: #f3e8f0;
  --focus: #8fc9c3;
  --danger: #b3261e;
  --warn: #9a6700;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 1024px;
  font-family: var(--font);
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
}
a { color: var(--link); text-underline-offset: 2px; }
a:hover { color: var(--rust); }
h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
h2 { font-size: 18px; font-weight: 600; margin: 0; }
h3 { font-size: 15px; font-weight: 600; margin: 0 0 10px; }
h4 { font-size: 14px; font-weight: 600; margin: 8px 0; }
code { background: var(--sand); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.muted { color: var(--muted); }
.warn { color: var(--warn); font-weight: 600; }
.center { text-align: center; margin-top: 40px; }

/* Nav: light, with the rust wordmark and uppercase links like the website's menu */
.nav { display: flex; align-items: center; gap: 16px; padding: 0 24px; height: 56px; background: var(--card); color: var(--ink); border-bottom: 1px solid var(--border); }
.nav a { color: var(--ink); text-decoration: none; padding: 19px 10px 17px; font-size: 12.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; opacity: .7; border-bottom: 3px solid transparent; }
.nav a:hover { opacity: 1; color: var(--ink); }
.nav a.active { opacity: 1; border-bottom-color: var(--rust); }
.nav nav { display: flex; }
.nav .spacer { flex: 1; }
.nav a.brand { margin-right: 14px; padding: 0; border: none; opacity: 1; font-size: 15px; letter-spacing: normal; text-transform: none; white-space: nowrap; }
.nav .user { color: var(--muted); }
.nav button.link { color: var(--ink-2); }
.wordmark { color: var(--rust); font-weight: 800; letter-spacing: .14em; }
.wordmark + span { color: var(--muted); font-weight: 500; margin-left: 6px; }
main { max-width: 1280px; margin: 0 auto; padding: 24px 24px 60px; }

/* Layout bits */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
/* Button groups at the right of a heading */
.page-head > span { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
/* htm drops the line break between buttons, so side-by-side buttons need their own gap.
   Flex rows that already have a gap undo it. */
button + button, button + .btn, .btn + button, .btn + .btn { margin-left: 8px; }
.page-head > span > .btn, .page-head > span > button, .actions > .btn, .actions > button,
.row > .btn, .row > button, .filters > .btn, .filters > button { margin-left: 0; }
/* Save / Cancel stay in view at the bottom of long forms */
.save-bar { position: sticky; bottom: 0; z-index: 4; background: var(--bg); margin: 0 0 16px; padding: 10px 0; border-top: 1px solid var(--border); }
/* Collapsible help under the sheets */
details.help { margin-top: 8px; font-size: 13px; }
details.help summary { cursor: pointer; color: var(--link); }
details.help p { margin: 6px 0 0; }
/* Small remove buttons (sheet rows, columns) */
button.icon-remove { border: 1px solid transparent; background: none; color: var(--muted); padding: 0 6px; line-height: 22px; border-radius: 5px; font-size: 15px; }
button.icon-remove:hover { color: var(--danger); background: #fbeceb; border-color: #e3b5b1; }
/* Tables whose header stays visible while the page scrolls */
table.data.sticky-head th { position: sticky; top: 0; z-index: 2; }
/* Run cards: the same column widths in every card so they line up */
table.data.steps-table { table-layout: fixed; }
table.data.steps-table td { overflow-wrap: anywhere; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; margin-bottom: 16px; }
/* Card headings get the small rust bar the graphs use */
.card > h3::before, .card > .page-head > h2::before { content: ""; display: inline-block; width: 14px; height: 4px; border-radius: 2px; background: var(--rust); margin-right: 8px; vertical-align: middle; position: relative; top: -2px; }
.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cols-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.cols-2 > .card, .cols-3 > .card { margin-bottom: 0; }
.cols-2, .cols-3 { margin-bottom: 16px; }
.grid-form { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 16px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field.wide { grid-column: 1 / -1; }
.field-label { font-weight: 600; font-size: 12px; color: var(--ink-2); }
.field-error { font-size: 12px; color: var(--danger); }
.field input[aria-invalid="true"] { border-color: var(--danger); }
.hint { font-size: 12px; color: var(--muted); }
.row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; margin: 12px 0 16px; align-items: center; }
.filters { display: flex; gap: 16px; align-items: flex-end; margin-bottom: 14px; flex-wrap: wrap; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.inline-form { background: #fbf6ef; border: 1px solid var(--border); border-radius: 9px; padding: 12px; margin-bottom: 14px; }
.template-editor { margin: 8px 0; }
ul.plain { list-style: none; padding: 0; margin: 0 0 10px; }
ul.plain li { padding: 4px 0; }

/* Controls */
input[type=text], input[type=number], input[type=url], input[type=date], input[type=datetime-local], select, textarea {
  font: inherit; color: var(--ink); padding: 6px 9px; border: 1px solid var(--border); border-radius: 7px; background: #fff; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--teal); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }
textarea { width: 100%; resize: vertical; }
input.narrow, select.narrow { width: 90px; }
.price-row { display: flex; gap: 6px; align-items: center; }
.price-row select:first-child { width: auto; }
select.invalid { border-color: var(--warn); color: var(--warn); }
button, .btn {
  font: inherit; font-weight: 500; padding: 6px 13px; border: 1px solid var(--border); border-radius: 9px; background: var(--card);
  cursor: pointer; text-decoration: none; color: var(--ink); display: inline-block;
}
button:hover, .btn:hover { background: var(--cream); color: var(--ink); }
/* Primary buttons: navy, uppercase like the website's calls to action */
button.primary, .btn.primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
  font-size: 12.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; padding: 7px 14px;
}
button.primary:hover, .btn.primary:hover { background: var(--accent-dark); color: #fff; }
button.danger { color: var(--danger); border-color: #e3b5b1; }
button.danger:hover { background: #fbeceb; }
button.link { border: none; background: none; padding: 0 4px; color: var(--link); text-decoration: underline; text-underline-offset: 2px; font-weight: 400; }
button.link:hover { background: none; color: var(--rust); }
button:disabled { opacity: .5; cursor: default; }
.tag { background: var(--sand); border-radius: 5px; padding: 2px 7px; font-size: 12px; }

/* Tables */
/* Off-white body like the cards, also where a table sits straight on the page (Materials, Recipes, Tests) */
table.data { width: 100%; border-collapse: collapse; background: var(--card); }
table.data th { text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-2); background: var(--sand); padding: 7px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data th:first-child { border-top-left-radius: 7px; }
table.data th:last-child { border-top-right-radius: 7px; }
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { background: #efe4d6; }
table.data th .sort-arrow { margin-left: 4px; font-size: 10px; color: #b3a898; }
table.data th.sorted .sort-arrow { color: var(--rust); }
table.data td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tr:hover td { background: #fcf7f0; }
table.data tr.expired td { background: #fbe6e1; }
table.data tr.soon td { background: #fbf0d8; }
/* Test sheet: spreadsheet-style cells */
.sheet-wrap { overflow-x: auto; padding-bottom: 4px; }
table.sheet { border-collapse: collapse; font-size: 13px; }
table.sheet th, table.sheet td { border: 1px solid #e3d8c9; padding: 0; }
table.sheet th { background: var(--sand); font-size: 12px; font-weight: 600; color: var(--ink-2); padding: 4px 6px; text-align: left; white-space: nowrap; }
table.sheet th.cond, table.sheet td.cond { background: var(--plum-pale); }
table.sheet th.res { background: var(--teal-pale); }
table.sheet th .sheet-sub { display: block; font-size: 11px; font-weight: 400; }
table.sheet tr.sheet-groups th { text-align: center; font-weight: 500; }
table.sheet tr.sheet-groups th:first-child, table.sheet tr.sheet-groups th:last-child { background: transparent; border: none; }
table.sheet thead tr:last-child th:last-child, table.sheet td:last-child { border: none; background: transparent; padding: 0 4px; }
table.sheet td input { border: none; border-radius: 0; width: 100%; min-width: 90px; padding: 5px 6px; background: transparent; font: inherit; }
table.sheet td input:focus { outline: 2px solid var(--teal); outline-offset: -2px; background: #fff; }
table.sheet td input[type=datetime-local] { min-width: 180px; }
table.sheet td.mat-col { min-width: 280px; background: #fff; }
table.sheet td.rep-col, table.sheet th.rep-col { text-align: center; width: 36px; padding: 0 4px; }
table.sheet input.picked-mat { font-weight: 600; }
table.sheet input::placeholder { color: #a79e98; }
table.sheet input.sheet-head { border: 1px solid var(--border); padding: 2px 4px; width: 110px; min-width: 0; font-size: 12px; }
table.sheet input.sheet-head.unit { width: 60px; margin-left: 2px; }
.sheet-mat { position: relative; }
.picker-list li.hi { background: var(--teal-pale); }
.sheet-actions { margin-top: 8px; }
input.name-input { min-width: 260px; }
.label-name { font-weight: 600; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* Pills */
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--sand); }
.pill.active, .pill.unopened { background: var(--teal-pale); }
.pill.open { background: var(--navy-pale); }
.pill.low, .pill.used { background: var(--ochre-pale); }
.pill.empty, .pill.discarded { background: #eeeae6; color: #6b6466; }
.pill.placeholder { background: var(--plum-pale); font-style: italic; }

/* Picker */
.picker { position: relative; display: inline-block; }
.picker-list { position: absolute; z-index: 10; top: 100%; left: 0; min-width: 240px; max-height: 240px; overflow: auto; margin: 2px 0 0; padding: 0; list-style: none; background: #fff; border: 1px solid var(--border); border-radius: 9px; box-shadow: 0 6px 20px rgba(32, 35, 52, .12); }
.picker-list li { padding: 6px 10px; cursor: pointer; }
.picker-list li:hover { background: var(--cream); }
.picked { display: inline-flex; gap: 6px; align-items: center; padding: 5px 9px; background: var(--cream); border-radius: 7px; }

/* Sign-in */
.center-card { max-width: 420px; margin: 120px auto; background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 32px 28px; text-align: center; }
.center-card h1 { margin-bottom: 12px; }
.center-card h1 .wordmark { font-size: 30px; }
.center-card h1 .wordmark + span { font-size: 22px; }

/* Toasts */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { padding: 10px 16px; border-radius: 9px; background: var(--ink); color: #fff; box-shadow: 0 6px 20px rgba(32, 35, 52, .25); max-width: 640px; }
.toast.error { background: var(--danger); }
.error-text { color: var(--danger); }

/* Labels: on screen a preview grid; when printing, one 40 x 30 mm label per sheet. */
.label-toolbar { display: flex; gap: 12px; align-items: center; padding: 16px 24px; }
.labels { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 24px 24px; }
.label { width: 40mm; height: 30mm; box-sizing: border-box; background: #fff; border: 1px dashed #aaa; display: flex; flex-direction: column; padding: 1.5mm; overflow: hidden; color: #000; page-break-inside: avoid; break-inside: avoid; }
/* Clabel CT221B prints at 203 dpi (8 dots/mm): 21 QR cells x 4 dots = 10.5 mm, so cells land on whole dots. */
.label-qr { width: 10.5mm; height: 10.5mm; flex: none; }
.label-qr svg { width: 100%; height: 100%; display: block; }
.label-code { font-size: 17pt; font-weight: 800; line-height: 1; margin-bottom: 0.5mm; white-space: nowrap; }
.label .label-name { font-size: 10pt; font-weight: 700; line-height: 1.05; }
.label-bottom { margin-top: auto; display: flex; align-items: flex-end; gap: 1.5mm; }
.label-lines { flex: 1; min-width: 0; font-size: 9pt; font-weight: 600; line-height: 1.15; }
.label-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Run titles are free text, so this line may wrap to three lines, a little smaller than the others. */
.label-run { font-size: 8pt; line-height: 1.05; white-space: normal; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }

@media print {
  @page { size: 40mm 30mm; margin: 0; }
  body { min-width: 0; background: #fff; }
  .no-print { display: none !important; }
  .labels { display: block; padding: 0; gap: 0; }
  .label { border: none; page-break-after: always; break-after: page; }
}

/* SuggestInput: free text with suggestions from values already in the database */
.suggest { position: relative; display: inline-flex; flex-direction: column; min-width: 0; }
.field > .suggest { display: flex; }
.suggest > input { width: 100%; }
.suggest > input.narrow { width: 90px; }
.suggest-near {
  position: absolute; top: 100%; left: 0; z-index: 5; margin-top: 2px; white-space: nowrap;
  font-size: 12px; font-weight: normal; background: #fff8e1; border: 1px solid #e8c96a; border-radius: 5px; padding: 1px 6px;
}
table.data th .sheet-sub { display: block; font-size: 11px; font-weight: 400; }
table.data tr.group-b td { background: #fcf8f2; }
table.data td.res { text-align: right; font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; }
input.formula { flex: 1; min-width: 280px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
table.sheet th.calc, table.sheet td.calc { background: #fcf3df; }
table.sheet td.calc output { display: block; padding: 5px 6px; min-width: 90px; text-align: right; color: #5b4a1a; font-variant-numeric: tabular-nums; }
table.data td.calc { color: #5b4a1a; background: #fcf3df; }

/* Sheet block selection (sheetGrid.js) */
table.sheet td.sel { background: var(--navy-pale); }
table.sheet td.sel input, table.sheet td.sel output { background: transparent; }

/* Notes boxes grow with their text (browsers without field-sizing keep the rows given) */
textarea { field-sizing: content; min-height: 3.4em; max-height: 50vh; }
/* A second heading in a card (e.g. "Went into" under "Made by") gets room above it */
.card > h3:not(:first-child) { margin-top: 18px; }
/* Materials list */
input.search-input { width: 240px; }
input[type=search] { font: inherit; padding: 6px 9px; border: 1px solid var(--border); border-radius: 7px; background: #fff; }
.count-line { margin: 0 0 6px; font-size: 12px; }

/* Graphs page */
.graph-layout { display: grid; grid-template-columns: 320px 1fr; gap: 16px; align-items: start; }
.graph-layout > .card { margin-bottom: 0; min-width: 0; }
.graph-controls h3:not(:first-child) { margin-top: 16px; }
.graph-controls .field, .graph-controls .field-list { margin-bottom: 10px; }
.graph-controls .field.grow { flex: 1; }
.graph-controls .row label { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; }
.run-checks { display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow: auto; font-size: 13px; }
.run-checks label { display: flex; gap: 6px; align-items: baseline; }
.run-checks strong { white-space: nowrap; }
.field-list { display: flex; flex-direction: column; gap: 4px; }
.filter-row { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-bottom: 6px; }
.filter-row select { max-width: 100%; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.chips select { max-width: 100%; }
.chip { display: inline-flex; align-items: center; gap: 2px; background: var(--sand); border-radius: 12px; padding: 2px 4px 2px 9px; font-size: 12px; }
.chip.missing { background: #fbeceb; color: var(--danger); }
button.chip-btn { border: none; background: none; padding: 0 4px; margin: 0; color: var(--muted); line-height: 18px; border-radius: 8px; }
button.chip-btn:hover { background: var(--border); color: var(--ink); }
.chart-wrap { position: relative; width: 100%; }
.chart-wrap svg { display: block; }
/* Chart hover card: cream, rust edge, and the value large like the website's stat callouts */
.chart-tip {
  position: absolute; transform: translateY(-50%); z-index: 5; pointer-events: none; max-width: 320px;
  font-size: 12px; line-height: 1.5; color: var(--ink);
  background: var(--card); border: 1px solid var(--border); border-left: 3px solid var(--rust); border-radius: 9px;
  box-shadow: 0 6px 20px rgba(32, 35, 52, .14); padding: 9px 12px 10px;
}
.chart-tip-head { display: flex; align-items: center; gap: 5px; font-weight: 600; margin-bottom: 4px; }
.chart-tip-kicker { font-size: 11px; font-weight: 600; color: var(--rust); }
.chart-tip-value { font-size: 22px; font-weight: 600; line-height: 1.15; letter-spacing: -.01em; font-variant-numeric: tabular-nums; margin-bottom: 4px; }
.chart-tip-value span { font-size: 14px; font-weight: 500; color: var(--ink-2); }
.chart-tip-mats { margin-top: 2px; font-size: 11px; }
