:root {
  --ink: #17211d;
  --muted: #68736d;
  --line: #d7dcd7;
  --paper: #f5f6f3;
  --surface: #ffffff;
  --accent: #d9ff55;
  --accent-dark: #b7dc37;
  --danger: #a33a31;
  --shadow: 0 18px 60px rgba(17, 27, 22, .14);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; }
body { background: var(--paper); }
button, input, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid rgba(104, 142, 0, .38); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 8px; color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .14em; }

.login-view { min-height: 100%; display: grid; grid-template-columns: minmax(320px, 560px) minmax(440px, 1fr); background: var(--ink); }
.login-mark { position: relative; overflow: hidden; grid-column: 2; grid-row: 1; background: #202c27; }
.login-mark::before, .login-mark::after, .login-mark span { content: ""; position: absolute; height: 36px; background: var(--accent); border-radius: 20px; }
.login-mark::before { width: 45%; left: 12%; top: 63%; }
.login-mark span { width: 36px; height: 35%; left: 54%; top: 31%; }
.login-mark::after { width: 40%; left: 54%; top: 31%; }
.login-card { grid-column: 1; grid-row: 1; align-self: center; width: min(420px, calc(100% - 56px)); margin: auto; color: #f8faf7; }
.login-card h1 { margin: 0; max-width: 360px; font-size: clamp(38px, 5vw, 58px); line-height: .98; letter-spacing: -.045em; }
.login-card .muted { margin: 20px 0 42px; max-width: 340px; color: #aeb8b2; line-height: 1.5; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 650; }
input, textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 11px 12px; color: var(--ink); background: var(--surface); font-size: 15px; }
textarea { resize: vertical; }
.login-card label { color: #b8c0bc; margin-bottom: 18px; }
.login-card input { padding: 14px; border-color: #506059; background: #26342e; color: white; }
.form-error { min-height: 20px; margin: -5px 0 10px; color: #ffaaa1; font-size: 13px; }
.primary { min-height: 44px; border: 0; border-radius: 9px; padding: 0 18px; background: var(--accent); color: #18200d; font-weight: 750; cursor: pointer; }
.primary:hover { background: var(--accent-dark); }
.primary:disabled { opacity: .45; cursor: wait; }
.wide { width: 100%; }
.demo-accounts { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 26px; color: #87948e; font-size: 11px; }
.demo-accounts button { border: 1px solid #47564f; border-radius: 99px; padding: 5px 9px; background: transparent; color: #b9c3be; cursor: pointer; }
.language-button { position: fixed; top: 22px; right: 22px; border: 1px solid #5b6862; border-radius: 8px; padding: 8px 10px; background: transparent; color: white; cursor: pointer; }

.app { height: 100%; }
.app-header { height: 54px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); padding: 0 16px; background: rgba(255,255,255,.94); position: relative; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; border: 0; background: transparent; font-weight: 760; cursor: pointer; }
.brand-icon { width: 25px; height: 25px; display: inline-block; border: 6px solid var(--ink); border-top: 0; border-right: 0; position: relative; }
.brand-icon::after { content: ""; position: absolute; width: 21px; height: 6px; left: 14px; top: -1px; background: var(--accent-dark); border-radius: 4px; }
.header-actions { display: flex; align-items: center; gap: 6px; }
.text-button, .icon-button { min-height: 36px; border: 0; border-radius: 7px; padding: 0 10px; background: transparent; cursor: pointer; font-weight: 650; }
.text-button:hover, .icon-button:hover { background: #edf0ec; }
.connection-state { display: flex; align-items: center; gap: 6px; margin-right: 8px; color: var(--muted); font-size: 12px; }
.connection-state i { width: 7px; height: 7px; border-radius: 50%; background: #429560; }
.connection-state.offline i { background: #be7b30; }

.worker-app { height: calc(100% - 54px); position: relative; }
.draw-view { height: 100%; position: relative; overflow: hidden; background: #f3f4f1; touch-action: none; }
.draw-view::after { content: ""; position: absolute; inset: 0; border: 0 solid rgba(113,144,0,.34); pointer-events: none; transition: border-width .12s ease; }
.draw-view.edge-fit-active::after { border-width: 4px; }
.profile-canvas { width: 100%; height: 100%; display: block; color: #d9ddd8; cursor: crosshair; }
.drag-origin { position: absolute; z-index: 2; width: 16px; height: 16px; box-sizing: border-box; border: 2px solid #719000; border-radius: 50%; background: rgba(243,244,241,.82); box-shadow: 0 0 0 2px rgba(243,244,241,.72); transform: translate(-50%, -50%); pointer-events: none; }
.drag-origin::after { content: ""; position: absolute; width: 4px; height: 4px; left: 4px; top: 4px; border-radius: 50%; background: #17211d; }
.drag-origin[hidden] { display: none; }
.profile-line { fill: none; stroke: var(--ink); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.profile-preview { fill: none; stroke: #719000; stroke-width: 3; stroke-dasharray: 8 7; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.dimension-bg, .bend-bg { fill: rgba(243,244,241,.97); stroke: rgba(243,244,241,.97); stroke-width: 3; }
.dimension-text { fill: #53605a; font-size: 12px; font-weight: 700; text-anchor: middle; dominant-baseline: middle; }
.cad-extension { stroke: #7d8882; stroke-width: .8; vector-effect: non-scaling-stroke; }
.cad-dimension { stroke: #53605a; stroke-width: 1; vector-effect: non-scaling-stroke; }
.cad-arrow { fill: #53605a; }
.bend-text { fill: #5f6b65; font-size: 11px; font-weight: 750; text-anchor: middle; dominant-baseline: middle; }
.bend-leader { stroke: #7d8882; stroke-width: .8; stroke-dasharray: 2 2; vector-effect: non-scaling-stroke; }
.full-bend { fill: none; stroke: #719000; stroke-width: 4; vector-effect: non-scaling-stroke; }
.start-point { fill: var(--surface); stroke: var(--ink); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.canvas-summary { position: absolute; left: 16px; top: 16px; display: grid; gap: 3px; border: 0; padding: 10px 12px; border-radius: 9px; background: rgba(245,246,243,.86); backdrop-filter: blur(8px); text-align: left; cursor: pointer; }
.canvas-summary strong { font-size: 12px; }
.canvas-summary > span { color: #66716b; font-size: 12px; font-variant-numeric: tabular-nums; }
.canvas-summary small { margin-top: 3px; color: #88918d; font-size: 10px; }
.canvas-tools { position: absolute; top: 16px; right: 16px; display: flex; gap: 8px; }
.tool-button { width: 46px; height: 46px; border: 1px solid rgba(23,33,29,.1); border-radius: 12px; background: rgba(255,255,255,.9); box-shadow: 0 4px 20px rgba(23,33,29,.06); font-size: 22px; cursor: pointer; }
.tool-button:disabled { opacity: .35; }
.desktop-zoom { display: none; align-items: stretch; height: 46px; overflow: hidden; border: 1px solid rgba(23,33,29,.1); border-radius: 12px; background: rgba(255,255,255,.94); box-shadow: 0 4px 20px rgba(23,33,29,.06); }
.zoom-button, .zoom-level { border: 0; background: transparent; cursor: pointer; }
.zoom-button { width: 40px; color: #53605a; font-size: 19px; }
.zoom-button:hover, .zoom-level:hover { background: #edf0ec; }
.zoom-level { min-width: 62px; display: grid; place-items: center; align-content: center; gap: 1px; border-left: 1px solid var(--line); border-right: 1px solid var(--line); color: var(--ink); }
.zoom-level span { font-size: 11px; font-weight: 800; font-variant-numeric: tabular-nums; }
.zoom-level small { color: var(--muted); font-size: 8px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.draw-hud { position: absolute; z-index: 2; left: 16px; bottom: 78px; display: grid; gap: 5px; pointer-events: none; }
.live-measurement { display: flex; align-items: center; gap: 5px; color: var(--ink); font-variant-numeric: tabular-nums; }
.live-measurement[hidden] { display: none; }
.live-measurement label { height: 32px; display: flex; align-items: center; gap: 2px; box-sizing: border-box; padding: 0 6px; border: 1px solid rgba(23,33,29,.12); border-radius: 7px; background: rgba(255,255,255,.92); box-shadow: 0 2px 10px rgba(23,33,29,.06); }
.live-measurement input { width: var(--field-ch, 3ch); min-width: 0; border: 0; padding: 0; background: transparent; color: var(--ink); font: inherit; font-size: 16px; font-weight: 750; line-height: 1; text-align: right; font-variant-numeric: tabular-nums; outline: none; -moz-appearance: textfield; }
.live-measurement input::-webkit-inner-spin-button { display: none; }
.live-measurement.editable label { border-color: #aeb7b2; pointer-events: auto; }
.live-measurement.editable label:focus-within { border-color: #719000; box-shadow: 0 0 0 2px rgba(113,144,0,.16); }
.live-measurement.full-bend-value label:last-child::before { content: "U"; color: #719000; font-size: 11px; font-weight: 800; }
.live-measurement small { color: #69736e; font-size: 10px; font-weight: 700; }
.live-measurement > i { display: none; }
.snap-hud { display: flex; align-items: center; gap: 8px; color: #737d78; font-size: 11px; font-weight: 700; }
.snap-hud i { width: 3px; height: 3px; border-radius: 50%; background: currentColor; }
.fab { position: absolute; right: 18px; bottom: 74px; width: 64px; height: 64px; border: 0; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: white; box-shadow: 0 10px 30px rgba(23,33,29,.28); cursor: pointer; }
.fab i { font-size: 24px; font-style: normal; }
.fab span { position: absolute; right: -1px; top: -1px; min-width: 22px; height: 22px; display: grid; place-items: center; border: 2px solid var(--paper); border-radius: 99px; background: var(--accent); color: var(--ink); font-size: 10px; font-weight: 800; }
.fab-menu { position: absolute; right: 20px; bottom: 148px; display: grid; gap: 8px; }
.fab-menu button { min-width: 190px; height: 48px; display: flex; align-items: center; justify-content: flex-end; gap: 12px; border: 1px solid var(--line); border-radius: 11px; padding: 0 8px 0 16px; background: white; box-shadow: 0 8px 28px rgba(23,33,29,.12); font-weight: 700; cursor: pointer; }
.fab-menu i { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; background: #eff1ed; font-style: normal; }

.mobile-nav { position: absolute; z-index: 10; left: 0; right: 0; bottom: 0; height: calc(62px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: 1fr 1fr; padding-bottom: env(safe-area-inset-bottom); border-top: 1px solid var(--line); background: rgba(255,255,255,.96); }
.mobile-nav button { position: relative; border: 0; display: grid; place-items: center; align-content: center; gap: 3px; background: transparent; color: #76807b; cursor: pointer; }
.mobile-nav span { font-size: 19px; line-height: 1; }
.mobile-nav b { font-size: 10px; }
.mobile-nav button.active { color: var(--ink); }
.mobile-nav button.active::before { content: ""; position: absolute; top: 0; width: 40px; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent-dark); }

.orders-view { height: 100%; overflow: auto; padding: 42px max(20px, calc((100vw - 940px)/2)) 100px; }
.page-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 30px; }
.page-heading h1 { margin: 0; font-size: 38px; letter-spacing: -.04em; }
.order-list { display: grid; gap: 8px; }
.order-row { width: 100%; display: grid; grid-template-columns: minmax(140px, 1.5fr) 1fr auto; align-items: center; gap: 16px; border: 1px solid var(--line); border-radius: 10px; padding: 16px; background: white; text-align: left; cursor: pointer; }
.order-row:hover { border-color: #aeb7b1; }
.order-row strong, .order-row small { display: block; }
.order-row small { margin-top: 4px; color: var(--muted); }
.status-pill { width: fit-content; border-radius: 99px; padding: 5px 9px; background: #e9ede9; color: #4c5852; font-size: 11px; font-weight: 750; white-space: nowrap; }
.status-pill.ready { background: #e8f6b9; color: #3c5200; }
.status-pill.needs-information { background: #fff0ce; color: #74520d; }
.empty-list { padding: 54px 20px; border: 1px dashed #c7cdc8; border-radius: 12px; text-align: center; color: var(--muted); }

.production-app { height: calc(100% - 54px); display: grid; grid-template-columns: 370px 1fr; }
.production-nav { min-width: 0; border-right: 1px solid var(--line); padding: 30px 16px 16px; overflow: auto; background: #f7f8f5; }
.production-nav > h1 { margin: 0 0 22px; font-size: 28px; letter-spacing: -.035em; }
.queue-filters { display: flex; gap: 4px; margin-bottom: 16px; padding: 3px; border-radius: 8px; background: #e8ebe7; }
.queue-filters button { flex: 1; height: 34px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 700; cursor: pointer; }
.queue-filters button.active { background: white; color: var(--ink); box-shadow: 0 1px 4px rgba(23,33,29,.08); }
.production-orders { display: grid; gap: 6px; }
.queue-row { width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 10px; border: 1px solid transparent; border-radius: 9px; padding: 13px; background: transparent; text-align: left; cursor: pointer; }
.queue-row:hover, .queue-row.active { border-color: var(--line); background: white; }
.queue-row strong, .queue-row small { display: block; }
.queue-row small { margin-top: 4px; color: var(--muted); }
.queue-row time { color: var(--muted); font-size: 10px; }
.production-detail { overflow: auto; background: white; }
.empty-state { height: 100%; display: grid; place-items: center; align-content: center; text-align: center; color: var(--muted); }
.empty-state h2 { margin: 24px 0 8px; color: var(--ink); }
.empty-state p { margin: 0; max-width: 320px; }
.empty-angle { width: 86px; height: 86px; border: 12px solid #dce1dc; border-top: 0; border-right: 0; }
.production-workspace { min-height: 100%; display: grid; grid-template-rows: auto 1fr; }
.workspace-header { position: sticky; top: 0; z-index: 4; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 20px 28px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.95); }
.workspace-header h2 { margin: 0; font-size: 22px; }
.workspace-header p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.workspace-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.secondary { min-height: 40px; border: 1px solid var(--line); border-radius: 8px; padding: 0 13px; background: white; font-weight: 700; cursor: pointer; }
.workspace-body { display: grid; grid-template-columns: minmax(380px, 1.4fr) minmax(270px, .6fr); min-height: 0; }
.technical-sheet { margin: 24px; padding: 30px; border: 1px solid var(--line); background: #fcfcfa; box-shadow: 0 7px 24px rgba(23,33,29,.06); }
.technical-sheet svg { width: 100%; height: 420px; }
.technical-sheet h3 { margin: 0; font-size: 18px; }
.technical-sheet .sheet-meta { display: flex; flex-wrap: wrap; gap: 24px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.order-sidebar { border-left: 1px solid var(--line); padding: 26px; }
.order-sidebar h3 { margin: 0 0 16px; font-size: 12px; letter-spacing: .1em; color: var(--muted); }
.detail-list { display: grid; grid-template-columns: 110px 1fr; gap: 10px; margin-bottom: 28px; font-size: 13px; }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; font-weight: 650; }
.profile-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 20px; }
.profile-tabs button { border: 1px solid var(--line); border-radius: 7px; padding: 7px 10px; background: white; cursor: pointer; }
.profile-tabs button.active { border-color: var(--ink); background: var(--ink); color: white; }

dialog { border: 0; padding: 0; background: transparent; color: var(--ink); }
dialog::backdrop { background: rgba(15,22,19,.48); backdrop-filter: blur(3px); }
.sheet-dialog { width: min(640px, 100%); max-width: none; height: 100%; max-height: none; margin: 0 0 0 auto; }
.sheet-card { height: 100%; overflow: auto; padding: 26px; background: var(--surface); box-shadow: var(--shadow); }
.sheet-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.sheet-header h2 { margin: 0; font-size: 26px; letter-spacing: -.03em; }
.close-button { width: 40px; height: 40px; border: 0; border-radius: 9px; background: #eff1ee; font-size: 24px; cursor: pointer; }
.form-section { margin-top: 30px; padding-top: 23px; border-top: 1px solid var(--line); }
.form-section h3 { margin: 0 0 16px; font-size: 14px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field-grid .full { grid-column: 1 / -1; }
.danger-row { display: flex; justify-content: space-between; gap: 10px; margin: 30px 0 18px; padding-top: 20px; border-top: 1px solid var(--line); }
.danger-button { border: 0; background: transparent; color: var(--danger); font-size: 12px; font-weight: 700; cursor: pointer; }
.preview-dialog { width: min(900px, calc(100% - 24px)); max-width: none; max-height: calc(100% - 24px); border-radius: 14px; }
.preview-card { max-height: calc(100vh - 24px); display: grid; grid-template-rows: auto 1fr auto; padding: 25px; background: white; }
.preview-profiles { overflow: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin: 24px 0; }
.preview-profile { border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.preview-profile svg { width: 100%; height: 170px; background: #f7f8f5; }
.preview-profile h3 { margin: 12px 0 4px; font-size: 14px; }
.preview-profile p { margin: 0; color: var(--muted); font-size: 12px; }
.preview-footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.preview-footer p { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--muted); font-size: 12px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #4a9a62; }
.order-dialog { width: min(650px, calc(100% - 24px)); max-width: none; border-radius: 13px; }
.order-detail-card { padding: 25px; background: white; }
.timeline { margin: 24px 0; padding: 0; list-style: none; }
.timeline li { position: relative; padding: 0 0 20px 25px; color: var(--muted); font-size: 12px; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 4px; width: 8px; height: 8px; border: 2px solid white; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.timeline li:not(:last-child)::after { content: ""; position: absolute; left: 8px; top: 14px; bottom: 0; width: 1px; background: var(--line); }
.timeline strong { display: block; color: var(--ink); }
.detail-actions { display: flex; justify-content: flex-end; gap: 8px; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: 28px; transform: translateX(-50%); max-width: min(420px, calc(100% - 32px)); border-radius: 9px; padding: 12px 16px; background: var(--ink); color: white; box-shadow: var(--shadow); font-size: 13px; }

@media (min-width: 900px) {
  .worker-app { padding-left: 78px; background: #eef0ed; }
  .mobile-nav { top: 0; right: auto; bottom: 0; width: 78px; height: 100%; grid-template-columns: 1fr; grid-template-rows: 84px 84px; align-content: start; padding: 12px 7px; border-top: 0; border-right: 1px solid var(--line); background: rgba(255,255,255,.97); }
  .mobile-nav button { border-radius: 10px; }
  .mobile-nav button:hover { background: #f0f2ef; color: var(--ink); }
  .mobile-nav button.active { background: #edf0e7; }
  .mobile-nav button.active::before { top: 50%; left: -7px; width: 3px; height: 38px; border-radius: 0 3px 3px 0; transform: translateY(-50%); }
  .mobile-nav span { font-size: 22px; }
  .mobile-nav b { font-size: 11px; }
  .draw-view { border-radius: 12px 0 0 0; box-shadow: inset 1px 1px 0 rgba(255,255,255,.7); }
  .canvas-summary { left: 24px; top: 24px; min-width: 174px; padding: 13px 14px; border: 1px solid rgba(23,33,29,.08); background: rgba(255,255,255,.9); box-shadow: 0 5px 22px rgba(23,33,29,.06); }
  .canvas-tools { top: 24px; right: 24px; }
  .desktop-zoom { display: flex; }
  .draw-hud { left: 24px; bottom: 24px; }
  .fab { right: 24px; bottom: 24px; }
  .fab-menu { right: 26px; bottom: 100px; }
  .orders-view { padding-top: 48px; padding-bottom: 48px; }
}

@media (max-width: 760px) {
  .login-view { display: block; padding-top: 110px; }
  .login-mark { display: none; }
  .login-card { width: calc(100% - 40px); }
  .login-card h1 { font-size: 42px; }
  .app-header { height: 48px; padding: 0 10px; }
  .brand > span:last-child { display: none; }
  .connection-state > span { display: none; }
  .worker-app { height: calc(100% - 48px); }
  .canvas-summary { left: 8px; top: 8px; padding: 8px 9px; }
  .canvas-tools { top: 8px; right: 8px; }
  .tool-button { width: 44px; height: 44px; }
  .sheet-dialog { width: 100%; height: min(88%, 720px); margin: auto 0 0; }
  .sheet-card { border-radius: 16px 16px 0 0; padding: 20px 18px calc(22px + env(safe-area-inset-bottom)); }
  .field-grid { grid-template-columns: 1fr; gap: 13px; }
  .field-grid .full { grid-column: auto; }
  .danger-row { align-items: flex-start; }
  .order-row { grid-template-columns: 1fr auto; }
  .order-row > span { display: none; }
  .production-app { height: calc(100% - 48px); grid-template-columns: 1fr; }
  .production-nav { border-right: 0; }
  .production-detail { position: fixed; inset: 48px 0 0; z-index: 15; display: none; }
  .production-detail.open { display: block; }
  .workspace-body { grid-template-columns: 1fr; }
  .order-sidebar { border-left: 0; border-top: 1px solid var(--line); }
  .technical-sheet { margin: 12px; padding: 18px; }
  .technical-sheet svg { height: 310px; }
}

@media (prefers-reduced-motion: no-preference) {
  .fab-menu, .toast { animation: rise .16s ease-out; }
  @keyframes rise { from { transform: translateY(6px); opacity: 0; } }
}
