/* =========================================================
   SteelCutList — styles
   ========================================================= */
:root {
  --bg: #f3f2ef;
  --surface: #ffffff;
  --surface-2: #f8f7f5;
  --ink: #1b1f24;
  --muted: #5b646e;
  --line: #dcd9d3;
  --line-strong: #c3bfb7;
  --accent: #e2560b;
  --accent-ink: #ffffff;
  --accent-soft: #fde9dc;
  --steel: #36424f;
  --ok: #1e7d4f;
  --warn: #b42318;
  --warn-soft: #fdecea;
  --waste: #c9c5bd;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 24, 30, .06), 0 6px 24px rgba(20, 24, 30, .06);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --display: "Barlow Condensed", "Inter", system-ui, sans-serif;
  color-scheme: light;
}
/* Dark theme: follows the device setting unless the visitor picked a theme with the toggle */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111417;
    --surface: #1a1e23;
    --surface-2: #20252b;
    --ink: #e8ebee;
    --muted: #9ba5af;
    --line: #2d343c;
    --line-strong: #3b444e;
    --accent: #ff7a2e;
    --accent-ink: #1a1e23;
    --accent-soft: #3a2518;
    --steel: #b8c3cf;
    --ok: #4cc38a;
    --warn: #ff6b5e;
    --warn-soft: #3a1d1b;
    --waste: #4a525b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111417;
  --surface: #1a1e23;
  --surface-2: #20252b;
  --ink: #e8ebee;
  --muted: #9ba5af;
  --line: #2d343c;
  --line-strong: #3b444e;
  --accent: #ff7a2e;
  --accent-ink: #1a1e23;
  --accent-soft: #3a2518;
  --steel: #b8c3cf;
  --ok: #4cc38a;
  --warn: #ff6b5e;
  --warn-soft: #3a1d1b;
  --waste: #4a525b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 24px rgba(0, 0, 0, .25);
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--bg); }
a { color: inherit; }
h1, h2, h3 { line-height: 1.15; margin: 0; }
.wrap { width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 16px; }
[hidden] { display: none !important; }

/* ---------- header ---------- */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.header-in { display: flex; align-items: center; justify-content: space-between; height: 56px; gap: 16px; }
.logo { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: var(--steel); font-family: var(--display); font-size: 24px; font-weight: 600; letter-spacing: .3px; }
.logo span { color: var(--ink); }
.logo b { color: var(--accent); font-weight: 700; }
.top-nav { display: flex; gap: 4px; }
.top-nav a { text-decoration: none; color: var(--muted); font-weight: 500; font-size: 14px; padding: 6px 10px; border-radius: 6px; }
.top-nav a:hover { color: var(--ink); background: var(--surface-2); }
@media (max-width: 640px) { .top-nav a[href="#how"], .top-nav a[href="#faq"] { display: none; } }

/* ---------- hero ---------- */
.hero { padding-top: 22px; padding-bottom: 12px; }
.hero h1 { font-family: var(--display); font-weight: 700; font-size: clamp(30px, 5vw, 46px); letter-spacing: .2px; text-transform: uppercase; }
.hero .sub { margin: 6px 0 0; color: var(--muted); max-width: 760px; font-size: clamp(14px, 2vw, 16px); }

/* ---------- tabs ---------- */
.tool-shell { padding-bottom: 8px; }
.tabs { display: flex; gap: 6px; margin-top: 10px; }
.tab { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-bottom: none; background: var(--surface-2); color: var(--muted);
  font: 600 15px/1 var(--font); padding: 12px 16px; border-radius: var(--radius) var(--radius) 0 0; cursor: pointer; position: relative; top: 1px; }
.tab[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: inset 0 3px 0 var(--accent); z-index: 1; }
.tab svg { color: var(--accent); }
.tab-hint { font-weight: 400; font-size: 12.5px; color: var(--muted); }
@media (max-width: 560px) { .tab-hint { display: none; } .tab { flex: 1; justify-content: center; } }

.tool-card { background: var(--surface); border: 1px solid var(--line); border-radius: 0 var(--radius) var(--radius) var(--radius); box-shadow: var(--shadow); padding: 16px; }
.noscript { background: var(--warn-soft); color: var(--warn); padding: 12px; border-radius: 8px; }

.card-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.toolbar-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.job { display: flex; flex-wrap: wrap; gap: 8px; flex: 1 1 420px; }
.job label { display: flex; flex-direction: column; font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; flex: 1 1 140px; }
.job input { margin-top: 3px; }

/* ---------- inputs ---------- */
.grid-inputs { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); grid-template-areas: "parts stock" "parts settings"; gap: 16px; align-items: start; }
.block-parts { grid-area: parts; } .block-stock { grid-area: stock; } .block-settings { grid-area: settings; }
@media (max-width: 980px) { .grid-inputs { grid-template-columns: 1fr; grid-template-areas: "parts" "stock" "settings"; } }
.block { min-width: 0; }
.block h2 { font-family: var(--display); font-size: 21px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; }
.block-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.block-settings h2 { margin-bottom: 8px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 8px 0 0; }

input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 6px; padding: 7px 8px; min-width: 0; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); padding: 0; }
input.bad { border-color: var(--warn); background: var(--warn-soft); }

.table-wrap { border: 1px solid var(--line); border-radius: 8px; overflow-x: auto; max-height: 460px; overflow-y: auto; }
table.edit { width: 100%; border-collapse: collapse; font-size: 14px; }
table.edit th { position: sticky; padding-right: 4px; top: 0; z-index: 1; background: var(--surface-2); text-align: left; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); padding: 7px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.edit td { padding: 3px 4px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.edit tr:last-child td { border-bottom: none; }
table.edit td input:not([type="checkbox"]) { border-color: transparent; background: transparent; padding: 6px; }
table.edit td input:not([type="checkbox"]):hover { border-color: var(--line); }
table.edit td input:not([type="checkbox"]):focus { background: var(--surface); }
table.edit td.c-check { text-align: center; }
table.edit td.c-num input { text-align: right; font-variant-numeric: tabular-nums; }
table.edit .rownum { color: var(--muted); font-size: 12px; text-align: right; width: 40px; padding-right: 2px; white-space: nowrap; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 2px; vertical-align: middle; }
.del { border: none; background: none; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; padding: 4px 6px; border-radius: 4px; }
.del:hover { color: var(--warn); background: var(--warn-soft); }

.settings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.settings label { display: flex; flex-direction: column; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.settings label input, .settings label select { margin-top: 4px; }
.settings .full { grid-column: 1 / -1; }

/* ---------- buttons ---------- */
.btn { font: 600 14px/1 var(--font); border-radius: 8px; padding: 10px 14px; cursor: pointer; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); transition: background .15s, border-color .15s; }
.btn:hover { border-color: var(--ink); }
.btn.sm { padding: 7px 10px; font-size: 13px; }
.btn.ghost { background: transparent; }
.btn.danger:hover { color: var(--warn); border-color: var(--warn); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.big { font-size: 17px; padding: 15px 26px; font-family: var(--display); text-transform: uppercase; letter-spacing: .6px; }
.btn.add { margin-top: 8px; border-style: dashed; background: transparent; color: var(--muted); width: 100%; }
.btn.add:hover { color: var(--ink); }
.btn:disabled { opacity: .55; cursor: progress; }
.run-row { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.run-msg { color: var(--muted); font-size: 14px; }
.run-msg.err { color: var(--warn); font-weight: 600; }

/* ---------- results ---------- */
.results { margin-top: 18px; }
.res-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.res-head h2 { font-family: var(--display); font-size: 26px; text-transform: uppercase; }
.res-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.res-actions .btn.primary { font-size: 15px; padding: 12px 18px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 16px; }
.kpi { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.kpi .k { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.kpi .v { font-family: var(--display); font-size: 30px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .v small { font-size: 16px; font-weight: 600; color: var(--muted); margin-left: 2px; }
.kpi.good .v { color: var(--ok); }
.alert { border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; background: var(--warn-soft); color: var(--warn); font-size: 14px; }
.alert strong { display: block; margin-bottom: 2px; }
.res-section { margin-top: 18px; }
.res-section > h3 { font-family: var(--display); font-size: 21px; text-transform: uppercase; margin-bottom: 8px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.res-section > h3 .meta { font-family: var(--font); font-size: 13px; font-weight: 500; text-transform: none; color: var(--muted); }

table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); padding: 6px 8px; border-bottom: 2px solid var(--line); white-space: nowrap; }
table.data td { padding: 6px 8px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
table.data td.num, table.data th.num { text-align: right; }
.data-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; padding: 2px 6px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); }

.pattern { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; background: var(--surface); }
.pattern-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px; margin-bottom: 8px; font-size: 14px; }
.pattern-head .ttl { font-weight: 700; }
.pattern-head .ttl .x { display: inline-block; background: var(--ink); color: var(--surface); border-radius: 5px; padding: 1px 7px; margin-right: 6px; font-size: 13px; }
.pattern-head .sub { color: var(--muted); font-size: 13px; }
.bar { display: flex; height: 44px; border: 1.5px solid var(--steel); border-radius: 3px; overflow: hidden; background: var(--surface); }
.seg { position: relative; height: 100%; border-right: 2px solid var(--surface); display: flex; flex-direction: column; justify-content: center; align-items: center; overflow: hidden; color: #15191e; font-size: 12px; line-height: 1.15; white-space: nowrap; min-width: 0; }
.seg b { font-size: 13px; }
.seg.trim, .seg.waste { background: repeating-linear-gradient(-45deg, var(--waste), var(--waste) 4px, transparent 4px, transparent 8px); color: var(--muted); }
.seg.rem { background: repeating-linear-gradient(-45deg, rgba(30,125,79,.28), rgba(30,125,79,.28) 4px, transparent 4px, transparent 8px); color: var(--ok); font-weight: 600; }
.cutlist { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.cutlist span b { color: var(--ink); }

.sheets { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.sheet-card { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--surface); }
.sheet-card svg { width: 100%; height: auto; display: block; }
.sheet-card svg text { font-family: var(--font); }

/* ---------- content ---------- */
.privacy { display: flex; align-items: flex-start; gap: 8px; color: var(--muted); font-size: 13px; margin: 12px 2px 0; }
.privacy svg { color: var(--ok); flex: none; margin-top: 2px; }
.ad-slot { min-height: 100px; margin: 24px 0; border: 1px dashed var(--line-strong); border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.ad-content { min-height: 250px; }
.content { padding-bottom: 32px; }
.content > h2, .seo h2, .faq h2 { font-family: var(--display); font-size: 30px; text-transform: uppercase; margin: 28px 0 14px; }
.steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.steps li { display: flex; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.steps .n { flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-family: var(--display); font-size: 20px; font-weight: 700; }
.steps h3 { font-size: 16px; margin-bottom: 4px; }
.steps p { margin: 0; color: var(--muted); font-size: 14px; }
.seo { max-width: 820px; }
.seo h3 { font-size: 18px; margin: 20px 0 6px; }
.seo p { color: var(--ink); opacity: .9; }
.faq { max-width: 820px; }
.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin-bottom: 8px; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq details p { margin: 8px 0 0; color: var(--muted); }
.limits { max-width: 820px; color: var(--muted); font-size: 13.5px; }

.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding: 18px 0; font-size: 13px; color: var(--muted); }
.footer-in { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.footer-in nav { display: flex; gap: 14px; }

/* ---------- modal ---------- */
.modal { border: none; border-radius: 12px; padding: 0; width: min(640px, calc(100% - 32px)); background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.modal::backdrop { background: rgba(10, 12, 15, .55); }
.modal-in { padding: 18px; }
.modal h2 { font-family: var(--display); font-size: 24px; text-transform: uppercase; }
.modal textarea { margin-top: 10px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.check { display: inline-flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 8px; font-size: 14px; z-index: 50; box-shadow: var(--shadow); }

/* legal pages */
.legal { max-width: 820px; padding-top: 24px; padding-bottom: 40px; }
.legal h1 { font-family: var(--display); font-size: 38px; text-transform: uppercase; margin-bottom: 10px; }
.legal h2 { font-size: 19px; margin: 22px 0 6px; }
.todo { background: var(--accent-soft); padding: 0 4px; border-radius: 3px; }

@media print {
  .site-header, .tabs, .card-toolbar, .grid-inputs, .run-row, .ad-slot, .content, .site-footer, .privacy, .res-actions { display: none !important; }
  .tool-card { border: none; box-shadow: none; padding: 0; }
  body { background: #fff; }
}

/* mobile: tables first, job details after them */
@media (max-width: 640px) {
  .tool-card { display: flex; flex-direction: column; }
  .card-toolbar { display: contents; }
  .toolbar-actions { order: 0; margin-bottom: 12px; }
  .grid-inputs { order: 1; }
  .job { order: 2; margin-top: 16px; flex: none; }
  .run-row { order: 3; }
  .results { order: 4; }
  .run-row .btn.big { width: 100%; }
}

/* DXF import */
.head-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.dxf-btn { display: inline-flex; align-items: center; gap: 6px; border-color: var(--accent); color: var(--accent); background: transparent; }
.dxf-btn:hover { background: var(--accent-soft); border-color: var(--accent); }
table.edit td.c-shape { text-align: center; padding: 2px 4px; }
table.edit svg.thumb { width: 38px; height: 26px; display: block; margin: 0 auto; }
.no-shape { color: var(--line-strong); font-size: 18px; line-height: 1; }
table.edit td input.locked { color: var(--muted); cursor: not-allowed; }
.dxf-msg { margin-top: 10px; margin-bottom: 0; }
.tool-card.drop { outline: 3px dashed var(--accent); outline-offset: -6px; background: var(--accent-soft); }

/* dropdown cells */
table.edit td.c-select select { border-color: transparent; background: transparent; padding: 6px 4px; cursor: pointer; }
table.edit td.c-select select:hover { border-color: var(--line); }
table.edit td.c-select select:focus { background: var(--surface); }
table.edit td.c-select select.bad, select.bad { border-color: var(--warn); background: var(--warn-soft); color: var(--warn); }

/* theme toggle */
.header-tools { display: flex; align-items: center; gap: 6px; }
.theme-toggle { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); cursor: pointer; padding: 0; }
.theme-toggle:hover { border-color: var(--line-strong); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .i-moon { display: none; }
}
/* ad slot above the tool tabs */
.ad-top { min-height: 90px; margin: 0; }
@media (max-width: 480px) {
  .top-nav { display: none; }           /* the Lengths / Plates tabs sit just below */
  .header-in { gap: 8px; }
}
.header-tools { min-width: 0; }

/* ad wrappers: label above the slot, clear space from the tool tabs below */
.ad-wrap { margin: 24px 0; }
.ad-wrap-top { margin: 4px 0 28px; }
.ad-wrap .ad-slot { margin: 0; }
.ad-label { margin: 0 0 4px; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.legal .lead { font-size: 17px; color: var(--ink); }
.legal ul { padding-left: 20px; }
.legal li { margin: 6px 0; }
.contact-email { font-size: 18px; font-weight: 600; }

/* guides */
.guide-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-top: 8px; }
.guide-card { display: flex; flex-direction: column; gap: 6px; text-decoration: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.guide-card:hover { border-color: var(--accent); }
.guide-card h2, .guide-card h3 { font-family: var(--font); font-size: 17px; text-transform: none; margin: 0; }
.guide-card p { margin: 0; color: var(--muted); font-size: 14px; flex: 1; }
.guide-card span { color: var(--accent); font-weight: 600; font-size: 14px; }
.home-guides { max-width: 1000px; }
.legal.article { max-width: 760px; }
.legal .meta { color: var(--muted); font-size: 13px; margin-top: 0; }
.legal h2 { margin-top: 26px; }
.legal p, .legal li { line-height: 1.65; }
.legal .data-wrap { margin: 12px 0; }
.guide-cta { background: var(--accent-soft); border-radius: var(--radius); padding: 12px 16px; margin: 28px 0 0; }
.guide-cta p { margin: 0; }
.guide-links { padding-left: 20px; }
