/* Telinekiito MVP styles */
html, body { margin: 0; }
body { min-height: 100vh; -webkit-font-smoothing: antialiased; }
img { max-width: 100%; }
[hidden] { display: none !important; }
/* Layout: dark top bar with three views. Quote = form column + sticky estimate ticket; Office = order table + detail panel. */
:root {
  --bg: #E8ECEB; --surface: #F6F8F7; --raised: #FFFFFF; --ink: #17201E; --muted: #55625E; --line: #C8D1CE;
  --accent: #F4BF1A; --accent-ink: #17201E; --stripe: #17201E;
  --action: #1C5A84; --action-ink: #FFFFFF; --action-soft: #DBE7EF;
  --bar-bg: #17201E; --bar-fg: #E8ECEB; --bar-muted: #93A29E;
  --ok: #2A774A; --ok-soft: #DAEEE1; --warn: #94600E; --warn-soft: #F6E8C8; --crit: #AA2B21; --crit-soft: #F5DCD9;
  --f-display: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --f-body: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --r: 6px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1514; --surface: #151D1B; --raised: #1B2523; --ink: #E3EAE8; --muted: #96A4A0; --line: #2B3734;
    --accent: #F2C230; --accent-ink: #131918; --stripe: #131918;
    --action: #7DB7DE; --action-ink: #0D1514; --action-soft: #1A303E;
    --bar-bg: #090E0D; --bar-fg: #E3EAE8; --bar-muted: #7F8E8A;
    --ok: #63C18B; --ok-soft: #163225; --warn: #E2AB4C; --warn-soft: #382B12; --crit: #EE8379; --crit-soft: #3B1D1A;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F1514; --surface: #151D1B; --raised: #1B2523; --ink: #E3EAE8; --muted: #96A4A0; --line: #2B3734;
  --accent: #F2C230; --accent-ink: #131918; --stripe: #131918;
  --action: #7DB7DE; --action-ink: #0D1514; --action-soft: #1A303E;
  --bar-bg: #090E0D; --bar-fg: #E3EAE8; --bar-muted: #7F8E8A;
  --ok: #63C18B; --ok-soft: #163225; --warn: #E2AB4C; --warn-soft: #382B12; --crit: #EE8379; --crit-soft: #3B1D1A;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body { background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 15px; line-height: 1.5; }
h1, h2, h3, legend { font-family: var(--f-display); font-weight: 700; letter-spacing: .01em; text-wrap: balance; margin: 0; }
h1 { font-size: 34px; line-height: 1.05; }
h2 { font-size: 24px; line-height: 1.1; }
h3 { font-size: 18px; line-height: 1.2; }
p { margin: 0; }
.mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
a { color: var(--action); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; }

/* Top bar */
.bar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--bar-bg); color: var(--bar-fg); }
.bar-in { max-width: 1200px; margin: 0 auto; padding-inline: clamp(16px, 3vw, 32px); display: flex; align-items: center; gap: 20px; min-height: 60px; flex-wrap: wrap; padding-block: 8px; }
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.mark { width: 28px; height: 28px; border-radius: 4px; background: repeating-linear-gradient(-45deg, var(--accent) 0 6px, var(--stripe) 6px 12px); border: 2px solid var(--accent); }
.brand-name { font-family: var(--f-display); font-weight: 700; font-size: 24px; letter-spacing: .06em; text-transform: uppercase; }
.proto { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--bar-muted); border: 1px solid currentColor; border-radius: 3px; padding: 1px 6px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab { background: transparent; border: 0; color: var(--bar-muted); padding: 8px 12px; border-radius: var(--r); cursor: pointer; font-weight: 600; }
.tab:hover { color: var(--bar-fg); }
.tab[aria-current="page"] { color: var(--accent-ink); background: var(--accent); }

.wrap { max-width: 1200px; margin: 0 auto; padding-inline: clamp(16px, 3vw, 32px); padding-block: 28px 64px; }
.view-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.view-head p { max-width: 62ch; color: var(--muted); margin-top: 6px; }

/* Buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: var(--raised); color: var(--ink); border-radius: var(--r); padding: 9px 14px; font-weight: 600; cursor: pointer; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--action); border-color: var(--action); color: var(--action-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.big { padding: 12px 18px; font-size: 16px; }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.btn.ghost { background: transparent; }
.field { display: grid; gap: 5px; min-width: 0; }
.field > span:not(.unit) { font-size: 13px; font-weight: 600; }
.field .hint { font-size: 12px; color: var(--muted); font-weight: 400; }
input[type=text], input[type=tel], input[type=email], input[type=number], input[type=date], select, textarea {
  width: 100%; background: var(--raised); border: 1px solid var(--line); border-radius: var(--r); padding: 9px 11px; min-height: 40px;
}
textarea { min-height: 72px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--action); outline: none; box-shadow: 0 0 0 3px var(--action-soft); }
.unit { position: relative; display: block; }
.unit input { padding-right: 34px; }
.unit::after { content: attr(data-unit); position: absolute; right: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 13px; pointer-events: none; }
.row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--raised); flex-wrap: wrap; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; }
.seg span { display: block; padding: 8px 14px; cursor: pointer; font-weight: 600; border-right: 1px solid var(--line); }
.seg label:last-child span { border-right: 0; }
.seg input:checked + span { background: var(--ink); color: var(--bg); }
.seg input:focus-visible + span { outline: 2px solid var(--action); outline-offset: -3px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-btn { border: 1px solid var(--line); background: var(--raised); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-weight: 500; font-size: 14px; }
.chip-btn[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: var(--bg); }

/* Quote */
.q-grid { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 28px; align-items: start; }
@media (max-width: 960px) { .q-grid { grid-template-columns: minmax(0, 1fr); } }
.steps { display: grid; gap: 18px; }
fieldset.step { border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); padding: 18px 18px 20px; margin: 0; display: grid; gap: 14px; min-width: 0; }
fieldset.step legend { font-size: 20px; padding: 0 6px; margin-left: -6px; display: flex; gap: 10px; align-items: baseline; }
fieldset.step legend .n { font-family: var(--f-mono); font-size: 13px; color: var(--muted); }
.opts { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.opts.opts-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 480px) { .opts.opts-2 { grid-template-columns: minmax(0, 1fr); } }
.opt { position: relative; display: block; }
.opt input { position: absolute; opacity: 0; }
.opt .oc { display: grid; gap: 2px; border: 1px solid var(--line); background: var(--raised); border-radius: var(--r); padding: 11px 13px; cursor: pointer; height: 100%; }
.opt .oc b { font-weight: 600; }
.opt .oc small { color: var(--muted); font-size: 13px; }
.opt input:checked + .oc { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.opt input:focus-visible + .oc { outline: 2px solid var(--action); outline-offset: 2px; }
.opt .tag { justify-self: start; font-size: 12px; font-weight: 600; padding: 1px 7px; border-radius: 3px; margin-top: 4px; background: var(--surface); border: 1px solid var(--line); }
.opt .tag.prem { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.check { display: flex; gap: 10px; align-items: flex-start; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--action); }
.note { font-size: 13px; color: var(--muted); border-left: 3px solid var(--line); padding-left: 10px; }

.ai { border: 1px dashed var(--line); border-radius: var(--r); padding: 12px 14px; display: grid; gap: 10px; background: var(--raised); }
.ai-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.drop { position: relative; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; border: 2px dashed var(--line); border-radius: var(--r); padding: 14px; background: var(--surface); cursor: pointer; }
.drop:hover, .drop.over { border-color: var(--action); }
.drop:focus-within { outline: 2px solid var(--action); outline-offset: 2px; }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-btn { display: inline-flex; border: 1px solid var(--ink); border-radius: var(--r); padding: 8px 14px; font-weight: 600; background: var(--raised); }
.drop-text { font-size: 13px; color: var(--muted); min-width: 0; overflow-wrap: anywhere; }
.ai-msg { font-size: 13px; }
.ai-msg.ok { color: var(--ok); }
.ai-msg.err { color: var(--crit); }
.ai-flag { display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--action); margin-left: 6px; }

/* Ticket */
.ticket { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 76px); background: var(--raised); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
@media (max-width: 960px) { .ticket { position: static; } }
.ticket-top { height: 10px; background: repeating-linear-gradient(-45deg, var(--accent) 0 10px, var(--stripe) 10px 20px); }
.ticket-body { padding: 16px 18px 18px; display: grid; gap: 14px; }
.total { font-family: var(--f-display); font-weight: 700; font-size: 44px; line-height: 1; font-variant-numeric: tabular-nums; }
.range { font-size: 13px; color: var(--muted); }
.figs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; border-block: 1px solid var(--line); padding-block: 10px; }
.figs div { display: grid; gap: 0; min-width: 0; }
.figs b { font-family: var(--f-mono); font-size: 15px; font-weight: 500; }
.figs span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.plan svg { width: 100%; height: auto; display: block; }
.pl-house { fill: var(--surface); stroke: var(--ink); stroke-width: 1.5; }
.pl-strip { fill: var(--accent); stroke: var(--ink); stroke-width: .75; }
.pl-catch { stroke: var(--crit); stroke-width: 2; stroke-dasharray: 5 3; fill: none; }
.pl-ridge { stroke: var(--muted); stroke-width: 1.25; stroke-dasharray: 4 3; fill: none; }
.pl-label { fill: var(--muted); font: 500 11px var(--f-mono); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 16px; height: 8px; vertical-align: middle; margin-right: 5px; border-radius: 1px; }
.lg-strip { background: var(--accent); border: 1px solid var(--ink); }
.lg-catch { border-top: 2px dashed var(--crit); height: 0 !important; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
td.r, th.r { text-align: right; }
td.r { font-variant-numeric: tabular-nums; }
.tbl-wrap { overflow-x: auto; }
.lines td { padding: 5px 0; }
.lines td.r { padding-left: 12px; }
.lines tr.sum td { border-bottom: 0; font-weight: 600; }
.lines tr.grand td { border-top: 2px solid var(--ink); border-bottom: 0; font-weight: 700; font-size: 16px; padding-top: 8px; }
.ticket .note { border-left-color: var(--accent); }

.done-box { border: 1px solid var(--ok); background: var(--ok-soft); border-radius: var(--r); padding: 18px; display: grid; gap: 10px; }
.done-box .ref { font-family: var(--f-mono); font-size: 26px; letter-spacing: .04em; }

/* Status chips */
.chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 3px; white-space: nowrap; }
.st-warn { background: var(--warn-soft); color: var(--warn); }
.st-action { background: var(--action-soft); color: var(--action); }
.st-ok { background: var(--ok-soft); color: var(--ok); }
.st-muted { background: var(--surface); color: var(--muted); border: 1px solid var(--line); }
.ex { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); border: 1px dashed var(--line); border-radius: 3px; padding: 0 5px; margin-left: 6px; }

/* Tracking */
.track { max-width: 760px; display: grid; gap: 20px; }
.lookup { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto; gap: 12px; align-items: end; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
@media (max-width: 640px) { .lookup { grid-template-columns: minmax(0, 1fr); } }
.lookup input#tr-ref { font-family: var(--f-mono); text-transform: uppercase; letter-spacing: .04em; }
.err { color: var(--crit); font-size: 14px; }
.card { background: var(--raised); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; display: grid; gap: 16px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: start; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; }
.timeline li { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 10px; padding-bottom: 14px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: 10px; top: 18px; bottom: 0; width: 2px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.timeline .dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); background: var(--raised); margin: 3px 0 0 4px; position: relative; z-index: 1; }
.timeline li.done .dot { background: var(--ok); border-color: var(--ok); }
.timeline li.done::before { background: var(--ok); }
.timeline li.now .dot { background: var(--accent); border-color: var(--ink); width: 18px; height: 18px; margin: 1px 0 0 2px; }
.timeline li.todo { color: var(--muted); }
.timeline b { font-weight: 600; }
.timeline .when { font-size: 13px; color: var(--muted); white-space: nowrap; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kv div { display: grid; min-width: 0; }
.kv span { font-size: 12px; color: var(--muted); }
.kv b { font-weight: 600; overflow-wrap: anywhere; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.msgs { display: grid; gap: 8px; }
.msg { border: 1px solid var(--line); border-radius: var(--r); padding: 8px 12px; background: var(--surface); max-width: 90%; }
.msg.office { justify-self: end; background: var(--action-soft); border-color: transparent; }
.msg small { display: block; color: var(--muted); font-size: 12px; }

/* Office */
.stats { display: flex; gap: 24px; flex-wrap: wrap; margin-bottom: 16px; }
.stat { display: grid; }
.stat b { font-family: var(--f-display); font-size: 28px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.toolbar input { max-width: 260px; }
.o-grid { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 20px; align-items: start; }
@media (max-width: 1060px) { .o-grid { grid-template-columns: minmax(0, 1fr); } }
.olist { background: var(--raised); border: 1px solid var(--line); border-radius: var(--r); }
.olist table { min-width: 560px; }
.nowrap { white-space: nowrap; }
.olist .ex { margin-left: 0; }
.olist tbody tr { cursor: pointer; }
.olist tbody tr:hover { background: var(--surface); }
.olist tbody tr[aria-selected="true"] { background: var(--action-soft); }
.olist td { padding: 9px 10px; }
.olist th { padding: 9px 10px; }
.empty { padding: 32px 20px; text-align: center; color: var(--muted); display: grid; gap: 10px; justify-items: center; }
.detail { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 76px); }
@media (max-width: 1060px) { .detail { position: static; } }
.status-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.status-row select { width: auto; flex: 1 1 180px; }
.hist { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; font-size: 13px; }
.hist li { display: flex; gap: 10px; justify-content: space-between; border-bottom: 1px dotted var(--line); padding-bottom: 4px; }
.hist li span:last-child { color: var(--muted); white-space: nowrap; }
details.settings { margin-top: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
details.settings summary { cursor: pointer; padding: 14px 18px; font-family: var(--f-display); font-weight: 700; font-size: 20px; }
.settings-body { padding: 0 18px 18px; display: grid; gap: 16px; }
.set-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.mode { font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.mode i { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); display: inline-block; }
.mode.live i { background: var(--ok); }

.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 20px); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: var(--r); font-weight: 500; z-index: 50; max-width: calc(100% - 32px); }
@media (prefers-reduced-motion: no-preference) { .toast { animation: rise .2s ease-out; } @keyframes rise { from { transform: translate(-50%, 8px); opacity: 0; } } }

/* Server version additions */
.addr-row { display: flex; gap: 10px; flex-wrap: wrap; }
.addr-row input { flex: 1 1 220px; }
.found { border: 1px solid var(--line); border-left: 4px solid var(--ok); border-radius: var(--r); padding: 12px 14px; background: var(--raised); display: grid; gap: 8px; font-size: 14px; }
.found.warn { border-left-color: var(--warn); }
.found ul { margin: 0; padding-left: 18px; display: grid; gap: 2px; }
.found .src { color: var(--muted); font-size: 12px; }
.found-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 12px; }
.found-head b { font-size: 15px; }
.found-head a { font-size: 13px; color: var(--action); }
.found-body { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 14px; align-items: center; }
.found .outline { width: 150px; height: auto; display: block; }
.found .outline .est { stroke-dasharray: 4 3; }
.facts { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px 14px; }
.facts div { min-width: 0; }
.facts dt { font-weight: 600; font-size: 15px; }
.facts dd { margin: 0; color: var(--muted); font-size: 12px; }
.found-notes { margin: 0; padding-left: 18px; font-size: 13px; color: var(--warn); display: grid; gap: 2px; }
@media (max-width: 480px) { .found-body { grid-template-columns: minmax(0, 1fr); } .found .outline { margin: 0 auto; } }
.foot { color: var(--muted); font-size: 13px; padding-block: 0 32px; display: flex; gap: 16px; flex-wrap: wrap; justify-content: space-between; }
.login { max-width: 380px; margin: 40px auto; }
.btn.danger { color: var(--crit); border-color: var(--crit); background: transparent; }
.confirm-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 14px; }
.bar a.tab { text-decoration: none; display: inline-flex; align-items: center; }

/* Language switch in the header */
.lang { display: inline-flex; border: 1px solid var(--bar-muted); border-radius: var(--r); overflow: hidden; }
.lang button { background: transparent; border: 0; color: var(--bar-muted); font: 600 12px/1 var(--f-body, inherit); letter-spacing: .06em; padding: 7px 9px; cursor: pointer; min-width: 34px; }
.lang button + button { border-left: 1px solid var(--bar-muted); }
.lang button:hover { color: var(--bar-fg); }
.lang button[aria-pressed="true"] { background: var(--bar-fg); color: var(--bar-bg); }

/* Contact messages in the office */
.leads { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.leads li { border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; background: var(--raised); display: grid; gap: 6px; justify-items: start; }
.lead-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.leads p { margin: 0; white-space: pre-wrap; }
