:root {
  --bg: #f4f3ef;
  --panel: #ffffff;
  --ink: #1c1d1f;
  --muted: #6b6d72;
  --line: #e2e0da;
  --soft: #f7f6f3;
  --accent: #d9480f;
  --accent-ink: #ffffff;
  --accent-soft: #fff1e8;
  --ok: #2b8a3e;
  --ok-soft: #e9f7ec;
  --warn: #b7791f;
  --warn-soft: #fdf6e3;
  --bad: #c92a2a;
  --bad-soft: #fdecec;
  --cut: #1c1d1f;
  --bend: #d9480f;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141517;
    --panel: #1d1f22;
    --ink: #ececec;
    --muted: #9a9ca1;
    --line: #2f3236;
    --soft: #23262a;
    --accent: #ff7a3d;
    --accent-ink: #1a0d05;
    --accent-soft: #33200f;
    --ok: #69db7c;
    --ok-soft: #17301d;
    --warn: #f2c14e;
    --warn-soft: #2f2714;
    --bad: #ff8787;
    --bad-soft: #3a1c1c;
    --cut: #ececec;
    --bend: #ff7a3d;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5rem; }
h1 { font-size: 1.6rem; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; }
h3 { font-size: 0.95rem; }
p { margin: 0 0 0.75rem; }
code, pre, .mono { font-family: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: 0.85em; }
pre { background: var(--soft); border: 1px solid var(--line); border-radius: 8px; padding: 0.75rem; overflow-x: auto; margin: 0 0 0.75rem; }

/* Header */
.top {
  display: flex; align-items: center; gap: 1.5rem;
  padding: 0.8rem max(16px, calc((100vw - 1240px) / 2));
  background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 750; font-size: 1.15rem; color: var(--ink); text-decoration: none; letter-spacing: -0.02em; display: flex; align-items: center; gap: 0.45rem; }
.brand .mark { width: 22px; height: 22px; border-radius: 5px; background: var(--accent); display: inline-grid; place-items: center; color: var(--accent-ink); font-size: 0.8rem; }
.top nav { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.top nav a { color: var(--muted); text-decoration: none; padding: 0.35rem 0.7rem; border-radius: 6px; font-weight: 500; }
.top nav a.on, .top nav a:hover { color: var(--ink); background: var(--soft); }
.top .spacer { flex: 1; }

main { max-width: 1240px; margin: 0 auto; padding: 1.5rem 16px 4rem; }
.lead { color: var(--muted); max-width: 60ch; margin-bottom: 1.5rem; }

/* Layout */
.grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 1.25rem; align-items: start; }
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } }
.grid > *, .stack > * { min-width: 0; }
.stack { display: grid; gap: 1.25rem; }
.row { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.between { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); }
.card > h2 { display: flex; align-items: center; gap: 0.5rem; }
.step { display: inline-grid; place-items: center; width: 1.4rem; height: 1.4rem; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 0.75rem; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.hidden { display: none !important; }

/* Forms */
label { display: grid; gap: 0.25rem; font-size: 0.82rem; color: var(--muted); font-weight: 500; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--panel);
  border: 1px solid var(--line); border-radius: 7px; padding: 0.45rem 0.6rem; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type="checkbox"] { width: 1rem; height: 1rem; accent-color: var(--accent); }
label.check { display: flex; align-items: center; gap: 0.45rem; color: var(--ink); font-size: 0.9rem; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.75rem; margin-bottom: 0.75rem; }
.fields.two { grid-template-columns: 1fr 1fr; }
textarea { min-height: 4rem; resize: vertical; }

button, .btn {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 7px; padding: 0.5rem 0.95rem;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink); text-decoration: none; display: inline-flex; gap: 0.4rem; align-items: center;
}
button:hover { background: var(--soft); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover { filter: brightness(1.06); }
button.ghost { border-color: transparent; background: transparent; color: var(--muted); padding: 0.35rem 0.5rem; }
button.ghost:hover { color: var(--ink); background: var(--soft); }
button.ok { color: var(--ok); }
button.bad { color: var(--bad); }
button:disabled { opacity: 0.55; cursor: progress; }
button.big { padding: 0.7rem 1.2rem; font-size: 1rem; width: 100%; justify-content: center; }

/* Drop zone and examples */
.drop {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 1.4rem; text-align: center;
  color: var(--muted); cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop strong { color: var(--ink); }
.chips { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.75rem; }
.chip { border: 1px solid var(--line); background: var(--soft); border-radius: 999px; padding: 0.25rem 0.7rem; font-size: 0.82rem; cursor: pointer; font-weight: 500; }
.chip:hover, .chip.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* Preview */
.preview { background: var(--soft); border: 1px solid var(--line); border-radius: 8px; padding: 0.75rem; display: grid; place-items: center; margin: 0.9rem 0; }
.preview svg { max-width: 100%; height: auto; max-height: 300px; }
.preview svg path { fill: none; vector-effect: non-scaling-stroke; }
.preview svg .cut { stroke: var(--cut); stroke-width: 1.4; }
.preview svg .bend { stroke: var(--bend); stroke-width: 1.4; stroke-dasharray: 6 4; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 0.5rem; }
.stat { background: var(--soft); border-radius: 8px; padding: 0.5rem 0.7rem; }
.stat b { display: block; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.stat span { font-size: 0.75rem; color: var(--muted); }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th { text-align: left; font-weight: 600; font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--line); }
td { padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
td input, td select { width: 100%; min-width: 4.5rem; }
td input[type="checkbox"] { width: 1rem; }

/* Tabs */
.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--muted); padding: 0.5rem 0.8rem; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }
.tabs .count { background: var(--accent); color: var(--accent-ink); border-radius: 999px; font-size: 0.7rem; padding: 0 0.4rem; margin-left: 0.2rem; }

/* Offers */
.offers { display: grid; gap: 0.75rem; }
.offer { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.9rem 1rem; background: var(--panel); }
.offer.best { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.offer .head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1rem; align-items: start; }
@media (max-width: 520px) { .offer .head { grid-template-columns: 1fr; } .offer .price { text-align: left; } }
.offer .name { font-weight: 650; }
.offer .price { text-align: right; }
.offer .price b { font-size: 1.45rem; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.offer .price .muted { display: block; font-size: 0.82rem; }
.offer .meta { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.4rem; }
.tag { font-size: 0.74rem; padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--soft); color: var(--muted); font-weight: 500; }
.tag.accent { background: var(--accent-soft); color: var(--accent); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.warnings { margin: 0.6rem 0 0; padding: 0.5rem 0.7rem; background: var(--warn-soft); color: var(--warn); border-radius: 7px; font-size: 0.83rem; list-style: none; }
.reasons { margin: 0.3rem 0 0; padding: 0; list-style: none; font-size: 0.83rem; color: var(--bad); }
.breakdown { margin-top: 0.7rem; }
.breakdown td { font-size: 0.84rem; }
.bar { height: 6px; border-radius: 3px; display: flex; overflow: hidden; margin-top: 0.7rem; background: var(--soft); }
.bar i { display: block; height: 100%; }
.legend { display: flex; gap: 0.7rem; flex-wrap: wrap; font-size: 0.75rem; color: var(--muted); margin-top: 0.35rem; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 0.25rem; }
.cat-material { background: #868e96; }
.cat-cutting { background: #d9480f; }
.cat-bending { background: #1c7ed6; }
.cat-tapping { background: #2b8a3e; }
.cat-setup { background: #ae3ec9; }
.cat-minimum { background: #f59f00; }
.cat-printing { background: #0ca678; }
.cat-milling { background: #1971c2; }
.cat-surface { background: #f08c00; }
.cat-tube { background: #5c940d; }
.cat-welding { background: #c2255c; }
.cat-molding { background: #1098ad; }
.cat-tooling { background: #495057; }
.cat-turning { background: #6741d9; }
.cat-finishing { background: #e64980; }
.blocked { border: 1px dashed var(--line); border-radius: var(--radius); padding: 0.75rem 1rem; }
.blocked summary { cursor: pointer; color: var(--muted); font-weight: 500; }
.empty { text-align: center; color: var(--muted); padding: 3rem 1rem; }
.empty .big { font-size: 2.4rem; display: block; margin-bottom: 0.5rem; opacity: 0.4; }

/* Notices */
.notice { padding: 0.7rem 0.9rem; border-radius: 8px; margin-bottom: 0.9rem; font-size: 0.9rem; }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.notice.bad { background: var(--bad-soft); color: var(--bad); }
.notice.info { background: var(--accent-soft); color: var(--ink); }
.toast { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 0.6rem 1rem; border-radius: 8px; z-index: 50; font-size: 0.9rem; box-shadow: var(--shadow); }
.spinner { width: 1rem; height: 1rem; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Shop portal */
.orders { display: grid; gap: 0.75rem; }
.order { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.9rem 1rem; }
.order.requested { border-left: 3px solid var(--accent); }
.section { border-top: 1px solid var(--line); padding-top: 1rem; margin-top: 1rem; }
.section:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.machine { background: var(--soft); border-radius: 8px; padding: 0.8rem; margin-bottom: 0.75rem; }
.speeds td, .speeds th { padding: 0.2rem 0.3rem; font-size: 0.78rem; }
.speeds input { padding: 0.2rem 0.3rem; font-size: 0.8rem; width: 5.5rem; }
.factor { display: grid; grid-template-columns: 7rem 1fr 3.5rem; align-items: center; gap: 0.6rem; font-size: 0.88rem; }
.factor .track { height: 8px; background: var(--soft); border-radius: 4px; position: relative; }
.factor .track i { position: absolute; top: 0; bottom: 0; background: var(--accent); border-radius: 4px; }
.factor .track .one { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); left: 50%; opacity: 0.5; }
.kpi { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.75rem; margin-bottom: 1rem; }
.kpi div { background: var(--soft); border-radius: 8px; padding: 0.7rem 0.9rem; }
.kpi b { display: block; font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.kpi span { font-size: 0.78rem; color: var(--muted); }
.logins { display: grid; gap: 0.5rem; }
.logins button { justify-content: space-between; width: 100%; }
.token { background: var(--soft); border: 1px solid var(--line); padding: 0.6rem; border-radius: 7px; word-break: break-all; }

/* Hero (agents) */
.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.25rem; }
@media (max-width: 900px) { .hero { grid-template-columns: 1fr; } }
.tools { display: grid; gap: 0.5rem; }
.tools div { display: grid; grid-template-columns: 10rem 1fr; gap: 0.75rem; font-size: 0.9rem; }
@media (max-width: 600px) { .tools div { grid-template-columns: 1fr; gap: 0; } }

/* How it is made */
.how { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 1rem; margin-top: 0.8rem; padding-top: 0.8rem; border-top: 1px solid var(--line); }
.how.single { grid-template-columns: 1fr 1fr; }
.how.single > div { display: contents; }
@media (max-width: 640px) { .how, .how.single { grid-template-columns: 1fr; } }
.nest { margin: 0; }
.nest-svg { background: var(--soft); border-radius: 8px; padding: 0.5rem; }
.nest-svg svg { width: 100%; height: auto; max-height: 220px; display: block; }
.nest-svg .sheet { fill: none; stroke: var(--muted); stroke-width: 0.4%; vector-effect: non-scaling-stroke; }
.nest-svg .slot { fill: none; stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.nest-svg .slot.mine { fill: color-mix(in srgb, var(--accent) 55%, transparent); stroke: var(--accent); }
.nest figcaption { margin-top: 0.4rem; }
.steps-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.55rem; }
.step-row { display: grid; grid-template-columns: 1.6rem 1fr; gap: 0.5rem; }
.step-ic { width: 1.6rem; height: 1.6rem; border-radius: 6px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 0.85rem; }
.setup { margin-top: 0.6rem; font-size: 0.88rem; }
.setup ul { margin: 0.25rem 0 0; padding-left: 1.1rem; color: var(--muted); }

/* Signed in: menu and counts */
.navlink { color: var(--muted); text-decoration: none; padding: 0.35rem 0.7rem; border-radius: 6px; font-weight: 500; display: inline-flex; gap: 0.35rem; align-items: center; }
.navlink:hover, .navlink.on { color: var(--ink); background: var(--soft); }
.count { background: var(--accent); color: var(--accent-ink); border-radius: 999px; font-size: 0.7rem; padding: 0 0.42rem; font-weight: 700; }
.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 0.45rem; padding: 0.25rem 0.5rem; border-radius: 8px; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary:hover { background: var(--soft); }
.avatar { width: 1.7rem; height: 1.7rem; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; font-size: 0.8rem; }
.menu-body { position: absolute; right: 0; top: calc(100% + 0.4rem); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 0.5rem; min-width: 240px; box-shadow: 0 12px 30px rgba(0,0,0,.18); display: grid; gap: 0.15rem; z-index: 30; }
.menu-body a, .menu-body button { color: var(--ink); text-decoration: none; padding: 0.45rem 0.6rem; border-radius: 6px; text-align: left; justify-content: flex-start; font-weight: 500; }
.menu-body a:hover { background: var(--soft); }
.menu-body .muted { padding: 0.3rem 0.6rem 0.5rem; border-bottom: 1px solid var(--line); margin-bottom: 0.2rem; }

/* Sign in */
.auth { max-width: 440px; margin: 2rem auto; }
.auth .card { padding: 1.6rem; }
.auth label { margin-bottom: 0.8rem; }
.auth input { width: 100%; }
.consent { border: 1px solid var(--accent); background: var(--accent-soft); border-radius: 10px; padding: 1rem; margin-bottom: 1rem; }
.demo-people { display: grid; gap: 0.35rem; margin-top: 0.5rem; }
.demo-people button { justify-content: space-between; width: 100%; font-weight: 500; }

/* Tickets */
.tickets { display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
@media (max-width: 860px) { .tickets { grid-template-columns: 1fr; } }
.ticket-list { display: grid; gap: 0.4rem; }
.ticket { text-align: left; display: grid; gap: 0.2rem; padding: 0.7rem 0.8rem; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); cursor: pointer; font: inherit; color: inherit; width: 100%; }
.ticket:hover { border-color: var(--muted); }
.ticket.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.ticket .t1 { display: flex; justify-content: space-between; gap: 0.5rem; align-items: center; font-weight: 600; }
.ticket .t2 { display: flex; justify-content: space-between; gap: 0.5rem; font-size: 0.83rem; color: var(--muted); }
.filters { display: flex; gap: 0.3rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.progress { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.3rem; margin: 0.9rem 0 1rem; }
.progress div { font-size: 0.72rem; color: var(--muted); border-top: 3px solid var(--line); padding-top: 0.3rem; }
.progress div.done { border-color: var(--accent); color: var(--ink); }
.progress div.now { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.thread { display: grid; gap: 0.55rem; margin: 1rem 0; }
.ev-status { font-size: 0.82rem; color: var(--muted); display: flex; gap: 0.5rem; align-items: center; }
.ev-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }
.bubble { max-width: 80%; padding: 0.55rem 0.8rem; border-radius: 12px; background: var(--soft); border: 1px solid var(--line); }
.bubble.mine { justify-self: end; background: var(--accent-soft); border-color: transparent; }
.bubble .who { font-size: 0.75rem; color: var(--muted); margin-bottom: 0.15rem; }
.actions-bar { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; padding: 0.8rem; background: var(--soft); border-radius: 10px; }
.compose { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.compose textarea { flex: 1; min-height: 2.6rem; }
.keyrow { display: grid; grid-template-columns: 1fr auto; gap: 0.5rem; align-items: center; padding: 0.6rem 0; border-bottom: 1px solid var(--line); }
