/* Visual language follows Tender Assistant ("yacht club"): ink on warm paper,
   purple ribbon and actions, amber for progress, brown for data emphasis,
   Bricolage Grotesque titles, mono small-caps labels, hairline tables. */
:root {
  color-scheme: light;
  --paper: #f2f0ef; --ink: #0f172a; --muted: #64748b; --faint: #94a3b8;
  --line: rgba(15, 23, 42, 0.1); --hair: rgba(15, 23, 42, 0.07); --card: #fff; --soft: #f4f4f2;
  --harbor: #4a2c82; --harbor-2: #5b3a99; --harbor-soft: rgba(74, 44, 130, 0.06); --harbor-line: rgba(74, 44, 130, 0.15);
  --amber: #ffb343; --brown: #733e24; --gray: #bbbdbc;
  --warn-bg: #fffbeb; --warn-line: #fcd34d; --warn-ink: #92400e;
  --ok-bg: #ecfdf5; --ok-ink: #047857; --bad-bg: #fff1f2; --bad-ink: #be123c;
  --sans: Geist, "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "PingFang TC", monospace;
  --display: "Bricolage Grotesque", Geist, "PingFang TC", "Microsoft JhengHei", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); }
body { font: 14px/1.55 var(--sans); -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01", "ss03"; }
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
.display { font-family: var(--display); letter-spacing: -0.01em; }
.label-caps { font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.14em; font-size: 10px; color: var(--muted); font-weight: 500; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.err { color: var(--bad-ink); min-height: 1.4em; margin: 6px 0 0; font-size: 13px; }

button { font: 600 13px/1.2 var(--sans); letter-spacing: -0.005em; border: 0; border-radius: 6px; padding: 9px 16px;
  background: var(--harbor); color: #fff; cursor: pointer; transition: background-color 120ms; }
button:hover { background: var(--harbor-2); }
button.ghost { background: #fff; color: var(--harbor); border: 1px solid var(--harbor-line); }
button.ghost:hover { background: var(--harbor-soft); }
button.link { background: none; color: var(--harbor); padding: 2px 4px; font-weight: 600; font-size: 12.5px; }
button.link:hover { text-decoration: underline; text-underline-offset: 2px; background: none; }
button[disabled] { opacity: .45; cursor: not-allowed; }
input, select, textarea { font: inherit; color: inherit; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--harbor) !important; box-shadow: 0 0 0 3px rgba(74, 44, 130, 0.12); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05); margin-bottom: 14px; }
.card h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.card h2.label-caps { font-size: 10px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 12px; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); display: grid; gap: 12px; padding: 24px; }
.login-card h1 { margin: 0; font-size: 22px; font-weight: 600; }
.login-card input { padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 6px; background: #fff; }
.brandrow { display: flex; align-items: center; gap: 10px; }
.mark { width: 32px; height: 32px; flex: none; }

/* ---------- ribbon + nav ---------- */
.ribbon { background: var(--harbor); border-bottom: 1px solid var(--harbor-2); color: #fff; padding-top: env(safe-area-inset-top, 0px); }
.ribbon-in { max-width: 1400px; margin: 0 auto; padding: 9px 16px; display: flex; align-items: center; gap: 18px; overflow-x: auto; }
.ribbon-in > * { flex-shrink: 0; }
.kpi { display: grid; gap: 1px; }
.kpi .label-caps { font-size: 9px; color: #c9b8ea; }
.kpi .label-caps.amber { color: var(--amber); display: flex; align-items: center; gap: 6px; }
.kpi b { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi .sub { font-family: var(--mono); font-size: 9px; letter-spacing: .08em; color: #c9b8ea; }
.kpi input { background: rgba(255,255,255,.08); color: #fff; border: 1px solid rgba(255,255,255,.18); border-radius: 5px; padding: 2px 6px; color-scheme: dark; font-size: 13px; font-weight: 600; }
.kpi.grow { flex: 1 1 200px; min-width: 200px; max-width: 360px; }
.vsep { width: 1px; height: 30px; background: rgba(255,255,255,.12); }
.rbar { height: 6px; background: rgba(255,255,255,.12); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.rbar i { display: block; height: 100%; width: 100%; background: var(--amber); border-radius: 3px; transform: scaleX(0); transform-origin: left; transition: transform 1s linear; }
.pulse { width: 6px; height: 6px; border-radius: 50%; background: var(--amber); display: inline-block; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.top { position: sticky; top: 0; z-index: 10; background: rgba(255,255,255,.85); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line); }
.top-in { max-width: 1400px; margin: 0 auto; padding: 6px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid #f1f5f9; }
.brand { font-size: 19px; font-weight: 600; white-space: nowrap; }
.ver { font-family: var(--mono); font-size: 10px; letter-spacing: .1em; color: var(--faint); }
.navrow { max-width: 1400px; margin: 0 auto; padding: 7px 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.new-run { white-space: nowrap; }
.steps { display: flex; align-items: center; gap: 2px; overflow-x: auto; width: fit-content; max-width: 100%; padding: 2px;
  background: var(--harbor-soft); border: 1px solid var(--harbor-line); border-radius: 12px; }
.steps .grp { padding: 0 8px; font-size: 9px; font-weight: 700; color: var(--faint); }
.steps button { background: transparent; color: #475569; font-weight: 500; font-size: 12.5px; border-radius: 10px; padding: 6px 12px; white-space: nowrap; }
.steps button:hover { background: #fff; color: var(--ink); }
.steps button.on { background: var(--harbor); color: #fff; font-weight: 600; box-shadow: 0 1px 2px rgba(15,23,42,.12); }
.badge { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 9px; background: var(--amber); color: #3b2a00; font: 600 11px/18px var(--mono); text-align: center; }

main { max-width: 1400px; margin: 0 auto; padding: 22px 16px 60px; }
.phead { margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid #e2e8f0; }
.phead h1 { margin: 0; font-size: 24px; font-weight: 600; }
.phead p { margin: 4px 0 0; color: var(--muted); font-size: 13px; max-width: 760px; }

/* ---------- step 1 ---------- */
.drop { border: 1.5px dashed #cbd5e1; border-radius: 12px; padding: 30px 16px; text-align: center; background: #fff; cursor: pointer; transition: border-color 120ms, background 120ms; }
.drop:hover, .drop.over { border-color: var(--harbor); background: var(--harbor-soft); }
.drop strong { color: var(--harbor); }
.small-drop { padding: 18px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin: 16px 0 10px; }
.pcard { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 1px 2px rgba(15,23,42,.05); }
.pcard img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--soft); cursor: zoom-in; border-bottom: 1px solid var(--hair); }
.pcard .body { padding: 10px 12px 12px; display: grid; gap: 5px; }
.pcard .name { font-weight: 600; font-size: 14px; }
.pcard .st { font-size: 12.5px; color: var(--muted); }
.pcard .st.ok { color: var(--ok-ink); }
.pcard .st.bad { color: var(--bad-ink); }
.pcard select { padding: 4px 6px; border: 1px solid #cbd5e1; border-radius: 6px; background: #fff; font-size: 13px; }
.pcard .acts { display: flex; gap: 4px; flex-wrap: wrap; }
.bar { height: 5px; background: #f1f5f9; border-radius: 3px; overflow: hidden; }
.bar > i { display: block; height: 100%; width: 100%; background: var(--amber); transform: scaleX(0); transform-origin: left; transition: transform .4s ease-out; }

/* ---------- step 2 ---------- */
.tabs { display: flex; gap: 2px; flex-wrap: wrap; margin-bottom: 14px; width: fit-content; max-width: 100%; padding: 2px; background: var(--harbor-soft); border: 1px solid var(--harbor-line); border-radius: 12px; }
.tabs button { background: transparent; color: #475569; font-weight: 500; font-size: 12.5px; border-radius: 10px; padding: 6px 12px; }
.tabs button:hover { background: #fff; color: var(--ink); }
.tabs button.on { background: var(--harbor); color: #fff; font-weight: 600; }
.tabs button.done::after { content: ""; display: inline-block; width: 12px; height: 12px; margin-left: 6px; vertical-align: -1px; background: currentColor; opacity: .75;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-7' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-7' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat; }
.tabs button.done:not(.on) { color: #047857; }
.tabs button.missing { color: var(--faint); }
.review { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 16px; align-items: start; }
@media (max-width: 980px) { .review { grid-template-columns: minmax(0, 1fr); } }
.photo { position: sticky; top: 112px; background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: auto; max-height: calc(100vh - 130px); box-shadow: 0 1px 2px rgba(15,23,42,.05); }
@media (max-width: 980px) { .photo { position: static; max-height: 60vh; } }
.photo img { display: block; width: 100%; cursor: zoom-in; }
.photo.zoom img { width: 220%; max-width: none; cursor: zoom-out; }
.photo .hint { position: sticky; left: 0; top: 0; padding: 5px 10px; background: rgba(255,255,255,.92); font: 500 9px/1.4 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--hair); }
.edit { display: grid; gap: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px 12px; }
.fld { display: grid; gap: 3px; font: 500 10px/1.3 var(--mono); letter-spacing: .08em; color: var(--muted); border-radius: 6px; }
.fld input, .fld select { font: 500 14px var(--sans); letter-spacing: 0; padding: 6px 8px; border: 1px solid #cbd5e1; border-radius: 6px; color: var(--ink); background: #fff; width: 100%; font-variant-numeric: tabular-nums; }
.tbl { overflow-x: auto; scrollbar-width: thin; scrollbar-color: #94a3b8 #f1f5f9; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th { font: 500 10px/1.3 var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); background: var(--soft); text-align: left; padding: 7px 6px; white-space: nowrap; border-bottom: 1px solid var(--line); }
td { border-top: 1px solid var(--hair); padding: 3px 6px; vertical-align: middle; }
td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
td input, td select { width: 100%; min-width: 60px; padding: 5px 6px; border: 1px solid transparent; border-radius: 5px; background: transparent; font-variant-numeric: tabular-nums; }
td input:hover, td select:hover { border-color: #e2e8f0; }
td input.n { text-align: right; min-width: 58px; }
td.code input { min-width: 150px; font-weight: 600; }
td select { min-width: 210px; }
tr.itemstart td { border-top: 1px solid rgba(15,23,42,.18); }
.flag { background: var(--warn-bg) !important; box-shadow: inset 0 0 0 1px var(--warn-line); }
.flag.fixed { background: var(--ok-bg) !important; box-shadow: none; }
.alts { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 3px; }
.alt { font: 500 11.5px/1.6 var(--sans); padding: 0 7px; border-radius: 9px; background: #fff; color: var(--warn-ink); border: 1px solid var(--warn-line); cursor: pointer; }
.alt:hover { background: #fef3c7; }
.tag { font: 600 9px/1.6 var(--mono); letter-spacing: .1em; padding: 0 6px; border-radius: 8px; background: #fde7d9; color: var(--brown); white-space: nowrap; }
.chk-ok { color: var(--ok-ink); font-weight: 600; white-space: nowrap; }
.chk-bad { color: var(--bad-ink); font-weight: 600; white-space: nowrap; }
.qs { margin: 0; padding-left: 0; list-style: none; display: grid; gap: 6px; }
.qs li { display: flex; gap: 8px; align-items: flex-start; padding: 7px 9px; border-radius: 8px; background: var(--warn-bg); border: 1px solid #fde68a; font-size: 13px; }
.qs li.done { background: var(--soft); border-color: var(--hair); color: var(--muted); }
.qs input { margin-top: 3px; }
.qs li button { margin-left: auto; white-space: nowrap; }
details summary { cursor: pointer; }
.done-bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
/* totals: computed numbers in brown, like Tender's data marks */
.totals td.num:nth-child(2) { color: var(--brown); font-weight: 600; }

/* ---------- Q&A ---------- */
.chat { display: grid; gap: 8px; margin-bottom: 12px; }
.msg-u { justify-self: end; max-width: 85%; background: var(--harbor); color: #fff; padding: 8px 12px; border-radius: 12px 12px 3px 12px; white-space: pre-wrap; font-size: 13.5px; }
.msg-m { justify-self: start; max-width: 92%; background: var(--soft); border: 1px solid var(--hair); padding: 9px 12px; border-radius: 12px 12px 12px 3px; white-space: pre-wrap; font-size: 13.5px; }
.chg { margin-top: 8px; display: grid; gap: 4px; white-space: normal; }
.chg-row { display: flex; gap: 10px; align-items: center; justify-content: space-between; background: #fff; border: 1px solid var(--warn-line); border-radius: 6px; padding: 4px 8px; font-size: 13px; }
.chg-row.applied { border-color: var(--line); color: var(--muted); }
.qa-in { display: flex; gap: 8px; align-items: flex-end; }
.qa-in textarea { flex: 1; min-width: 0; padding: 9px 10px; border: 1px solid #cbd5e1; border-radius: 8px; resize: vertical; background: #fff; }

/* ---------- step 3 ---------- */
.msg { border-radius: 10px; padding: 10px 14px; margin: 0 0 12px; font-size: 13.5px; border: 1px solid transparent; }
.msg.bad { background: var(--bad-bg); color: var(--bad-ink); border-color: #fecdd3; }
.msg.warn { background: var(--warn-bg); color: var(--warn-ink); border-color: #fde68a; }
.msg.ok { background: var(--ok-bg); color: var(--ok-ink); border-color: #a7f3d0; }
.msg ul { margin: 6px 0 0; padding-left: 20px; }
.sheetprev h3 { font-size: 14px; font-weight: 600; margin: 0 0 8px; }
.sheetprev tr.sum td { background: #faf8f6; font-weight: 600; color: var(--brown); border-top: 1px solid rgba(15,23,42,.18); }
.sheetprev td { white-space: nowrap; }
.sheetprev .rown { color: var(--faint); text-align: right; font: 500 11px var(--mono); }

/* ---------- photo viewer ---------- */
.viewer { position: fixed; inset: 0; z-index: 30; background: rgba(15,23,42,.88); overflow: auto; cursor: zoom-out; padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px); }
.viewer img { display: block; max-width: none; width: 160%; margin: 0 auto; }
@media (max-width: 700px) { .viewer img { width: 260%; } .vsep { display: none; } .brand { font-size: 16px; } .ribbon .sub { display: none; } }

/* ---------- language switch, questions, AI-fixed ---------- */
.langs { display: flex; gap: 2px; padding: 2px; background: var(--harbor-soft); border: 1px solid var(--harbor-line); border-radius: 9px; width: fit-content; }
.langs button { background: transparent; color: #475569; font: 600 11px/1 var(--mono); letter-spacing: .08em; padding: 6px 9px; border-radius: 7px; }
.langs button:hover { background: #fff; color: var(--ink); }
.langs button.on { background: var(--harbor); color: #fff; }
.login-card .langs { justify-self: center; margin-top: 4px; }
.qcard { border-color: var(--warn-line); background: linear-gradient(var(--warn-bg), #fff 60px); }
.qs.resolved li { background: var(--ok-bg); border-color: #a7f3d0; }
.tag.ai { background: #d1fae5; color: var(--ok-ink); }

.num-step { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--harbor); color: #fff; font: 600 11px/1 var(--mono); margin-right: 8px; flex: none; }
.subhead { font-size: 15px; font-weight: 600; margin: 18px 0 10px; display: flex; align-items: center; }
.xfile-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.xfile-row b { font-weight: 600; }
.xfile-row button { margin-left: auto; padding: 6px 12px; }
.drop.has-file { border-style: solid; border-color: var(--harbor-line); background: var(--harbor-soft); }

/* ---------- Excel-like preview ---------- */
.xl { border: 1px solid #c8c8c8; border-radius: 8px; overflow: hidden; background: #fff; box-shadow: 0 1px 2px rgba(15,23,42,.05); margin-bottom: 8px; }
.xl-bar { display: flex; align-items: center; gap: 0; border-bottom: 1px solid #d4d4d4; background: #fff; font: 13px Calibri, "Segoe UI", Arial, "PingFang TC", sans-serif; }
.xl-name { width: 90px; padding: 5px 8px; border-right: 1px solid #d4d4d4; color: #333; }
.xl-fx { padding: 5px 10px; color: #777; font-style: italic; border-right: 1px solid #d4d4d4; }
.xl-formula { padding: 5px 10px; color: #222; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; font-family: Consolas, "Geist Mono", monospace; font-size: 12.5px; }
.xl-wrap { overflow: auto; max-height: 68vh; background: #fff; }
.xl-grid { border-collapse: separate; border-spacing: 0; table-layout: fixed; width: max-content; font: 12px/1.25 Calibri, "Segoe UI", Arial, "PingFang TC", "Microsoft JhengHei", sans-serif; color: #000; }
.xl-grid th, .xl-grid td { border: 0; border-right: 1px solid #e1e1e1; border-bottom: 1px solid #e1e1e1; padding: 1px 4px; overflow: hidden; white-space: nowrap; text-overflow: clip; vertical-align: bottom; }
.xl-grid td.wrap { white-space: normal; vertical-align: middle; word-break: break-word; }
.xl-grid thead th { position: sticky; top: 0; z-index: 3; background: #f3f3f3; color: #444; font: 12px Calibri, "Segoe UI", Arial, sans-serif; text-transform: none; letter-spacing: 0; text-align: center; border-bottom: 1px solid #c8c8c8; padding: 3px 0; }
.xl-grid .xl-corner { left: 0; z-index: 4; }
.xl-grid th.xl-rowh { position: sticky; left: 0; z-index: 2; background: #f3f3f3; color: #444; font-weight: 400; text-align: center; border-right: 1px solid #c8c8c8; font-size: 11.5px; }
.xl-grid tr.xl-old td { color: #6b6b6b; }
.xl-grid tr.xl-new td { background-image: linear-gradient(rgba(124, 92, 196, .13), rgba(124, 92, 196, .13)); }
.xl-grid tr.xl-new th.xl-rowh { background: #e6ddf6; color: var(--harbor); font-weight: 700; }
.xl-grid tr.xl-gap td { background: #fafafa; color: #888; font-style: italic; text-align: center; height: 22px; }
.xl-grid td.fx { color: inherit; }
.xl-grid td.ovf { overflow: visible; position: relative; z-index: 1; }
.xl-wrap { max-height: 74vh; }
.xl-grid td.sel { outline: 2px solid #217346; outline-offset: -2px; }
.xl-tabs { display: flex; gap: 0; border-top: 1px solid #d4d4d4; background: #f3f3f3; padding: 0 6px; overflow-x: auto; }
.xl-tabs button { background: transparent; color: #444; font: 12.5px Calibri, "Segoe UI", Arial, "PingFang TC", sans-serif; border-radius: 0; padding: 6px 14px; border-right: 1px solid #d4d4d4; }
.xl-tabs button:hover { background: #e9e9e9; }
.xl-tabs button.on { background: #fff; color: #217346; font-weight: 700; box-shadow: inset 0 -2px 0 #217346; }
.xl-tabs button span { color: #888; font-weight: 400; font-size: 11px; margin-left: 4px; }

.demo-bar { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; background: #fff7ed; border: 1px dashed #fdba74; border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; }
.demo-bar.on { background: #fef3c7; border-style: solid; border-color: #f59e0b; }

.q-acts { margin-left: auto; display: flex; gap: 6px; align-items: center; flex: none; }
.q-edit { padding: 4px 12px; font-size: 12.5px; }
@keyframes flashrow { 0%, 60% { background: #ede4fb; } 100% { background: transparent; } }
tr.flash td, .card.flash { animation: flashrow 2.2s ease-out; }

/* ---------- bottom step navigation ---------- */
.stepnav { margin-top: 22px; padding-top: 16px; border-top: 1px solid #e2e8f0; }
.navbtns { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.navbtns button { padding: 11px 20px; font-size: 14px; }
.navwarn ul { margin: 6px 0 0; }
.need { outline: 2px solid #f97316 !important; outline-offset: 2px; border-radius: 6px; }
tr.need td { background: #fff1e6 !important; }

.kpi b.over { color: #fca5a5; }

.xl-grid td[data-edit] { cursor: cell; }
.xl-grid td.edited { box-shadow: inset 8px 8px 0 -6px #f97316; }
.xl-grid td.editing { padding: 0; outline: 2px solid #217346; outline-offset: -2px; background: #fff !important; }
.xl-in { width: 100%; height: 100%; border: 0; padding: 1px 4px; font: inherit; background: #fff; outline: none; box-shadow: none !important; }
.xl-editbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.xl-editbar button { padding: 5px 12px; }

/* ---------- browser surfaces ---------- */
::selection { background: #e6ddf6; color: var(--ink); }
input, textarea { caret-color: var(--harbor); }
* { scrollbar-width: thin; scrollbar-color: #b8b3c7 transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #c9c4d6; border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: #9f98b3; }
:focus-visible { outline: 2px solid var(--harbor); outline-offset: 2px; }
button:focus-visible { outline-offset: 2px; }
.num, td.num, .kpi b { font-variant-numeric: tabular-nums; }

/* ---------- icons ---------- */
.ic { width: 14px; height: 14px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -2px; }
button .ic { margin-right: 5px; }
button.link.icon-btn { padding: 4px; border-radius: 6px; color: #94a3b8; }
.icon-btn .ic { margin: 0; }
button.link.icon-btn:hover { color: var(--bad-ink); background: var(--bad-bg) !important; text-decoration: none !important; }
.chk-ok, .chk-bad { display: inline-flex; align-items: center; gap: 4px; }
.chk-ok .ic, .chk-bad .ic { margin: 0; }
tr.row-bad td { background: var(--bad-bg); }
button.copied { color: var(--ok-ink) !important; border-color: #a7f3d0 !important; }

/* ---------- review: pass note, reasons, confirm ---------- */
.pass-note { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; margin-bottom: 14px; border-radius: 12px; background: var(--ok-bg); border: 1px solid #a7f3d0; color: var(--ok-ink); font-size: 13.5px; }
.pass-note .ic { width: 18px; height: 18px; margin-top: 1px; }
.pass-note b { margin-right: 6px; }
details.reasons { margin-top: 14px; border-top: 1px solid var(--hair); padding-top: 10px; }
details.reasons > summary { cursor: pointer; font-weight: 600; font-size: 15px; list-style: none; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
details.reasons > summary::-webkit-details-marker { display: none; }
details.reasons > summary::before { content: ""; width: 7px; height: 7px; border-right: 1.8px solid var(--muted); border-bottom: 1.8px solid var(--muted); transform: rotate(-45deg); transition: transform 150ms ease-out; align-self: center; }
details.reasons[open] > summary::before { transform: rotate(45deg); }
details.reasons[open] > .grid { margin-top: 12px; }
button.is-done { background: var(--ok-ink); }
button.is-done:hover { background: #065f46; }

/* ---------- photo cards ---------- */
.pmeta { display: grid; grid-template-columns: 1fr auto; gap: 6px; }
.pmeta input[type=date] { padding: 4px 6px; border: 1px solid #cbd5e1; border-radius: 6px; background: #fff; font-size: 13px; }
.pdate { font: 500 12px var(--mono); color: var(--muted); margin-left: 4px; }
.qwarn { display: grid; grid-template-columns: auto 1fr; gap: 4px 6px; align-items: start; padding: 8px 9px; border-radius: 8px; background: var(--warn-bg); border: 1px solid #fde68a; color: var(--warn-ink); font-size: 12.5px; }
.qwarn .ic { margin-top: 2px; }
.qwarn button { grid-column: 2; justify-self: start; padding: 0; font-size: 12.5px; }

/* ---------- summary ---------- */
.summary .sum-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.summary .sum-head h2 { margin: 0; }
.summary .sum-head button { padding: 7px 12px; }
.sum-day h3 { font: 600 13px var(--mono); color: var(--muted); margin: 14px 0 6px; letter-spacing: .04em; }
.summary td.num:nth-child(2) { color: var(--brown); font-weight: 600; }

/* ---------- phone ---------- */
@media (max-width: 700px) {
  main { padding: 16px 14px 48px; }
  .phead h1 { font-size: 21px; }
  .card { padding: 14px; border-radius: 10px; }
  .cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .pcard .acts button { padding: 6px 6px; }
  .pmeta { grid-template-columns: 1fr; }
  .grid { grid-template-columns: 1fr 1fr; }
  .tabs { width: 100%; flex-wrap: nowrap; overflow-x: auto; }
  .tabs button { white-space: nowrap; }
  .navbtns { flex-direction: column-reverse; align-items: stretch; }
  .navbtns button { width: 100%; padding: 13px 16px; }
  .navbtns > span:empty { display: none; }
  .qs li { flex-wrap: wrap; }
  .q-acts { margin-left: 26px; }
  .qa-in { flex-direction: column; align-items: stretch; }
  .demo-bar { flex-direction: column; align-items: stretch; }
  .top-in { padding: 6px 14px; }
  .navrow { padding: 6px 14px; }
  .steps { max-width: 100%; overflow-x: auto; }
  .xl-wrap { max-height: 62vh; }
  .xl-name { width: 64px; }
  button, .pmeta select, .pmeta input { min-height: 40px; }
  button.link { min-height: 0; }
}
@media (max-width: 340px) { .cards { grid-template-columns: 1fr; } }
html, body { overflow-x: hidden; }
.edit, .card, .tbl { min-width: 0; }

.summary table { table-layout: fixed; }
.summary th:first-child, .summary td:first-child { width: 34%; }

/* ---------- spot-check note ---------- */
.pass-note.spot { background: var(--warn-bg); border-color: #fde68a; color: var(--warn-ink); }
.sum-btns { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- monthly trend charts (single series each: no legend, title names it) ---------- */
.trend h3 { font-size: 13px; font-weight: 600; margin: 14px 0 4px; color: var(--ink); }
.chart { width: 100%; height: auto; display: block; overflow: visible; max-width: 100%; }
.chart .grid { stroke: #ece9ef; stroke-width: 1; }
.chart .tick { font: 500 11px var(--mono); fill: var(--muted); }
.chart .bar { fill: #6b4bb5; }
.chart .bar.new { fill: #4a2c82; }
.chart .line { fill: none; stroke: #6b4bb5; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: #6b4bb5; stroke: #fff; stroke-width: 2; }
.chart .dot.new { fill: #4a2c82; }
.chart .vlabel { font: 600 11.5px var(--sans); fill: var(--ink); }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .hit.on { fill: rgba(74, 44, 130, 0.06); }
.chart-tip { position: fixed; z-index: 40; pointer-events: none; white-space: pre-line; background: #1f1636; color: #fff; font: 500 12.5px/1.45 var(--sans); padding: 7px 10px; border-radius: 8px; box-shadow: 0 6px 18px rgba(15, 23, 42, .22); max-width: 260px; }
details.trend-table { margin-top: 10px; }
details.trend-table summary { cursor: pointer; font-size: 13px; color: var(--harbor); font-weight: 600; }
details.trend-table tr.is-new td { background: #f5f0fd; }

/* ---------- Theia, the client's Bengal kitten (pet.js) ---------- */
.top-tools { position: relative; display: flex; align-items: center; gap: 8px; }
.pet-toggle { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border-radius: 9px;
  background: var(--harbor-soft); color: var(--faint); border: 1px solid var(--harbor-line); }
.pet-toggle:hover { background: #fff; color: var(--brown); }
.pet-toggle.on { color: #b8987a; }
.pet-toggle[aria-expanded="true"] { background: #fff; border-color: var(--harbor); }
.pet-menu { position: absolute; top: calc(100% + 8px); right: 0; z-index: 25; min-width: 220px; padding: 12px 14px 8px; background: #fff;
  border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 28px rgba(15, 23, 42, .16); }
.pet-menu .label-caps { margin: 0 0 6px; }
.pet-menu label { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 13.5px; cursor: pointer; }
.pet-menu label.sub { padding-left: 24px; }
.pet-menu input { width: 16px; height: 16px; margin: 0; accent-color: var(--harbor); }
.pet-menu input:disabled, .pet-menu button:disabled { cursor: not-allowed; }
.pet-menu label:has(input:disabled) { opacity: .45; }
.pet-quick { display: flex; gap: 10px; padding: 2px 0 2px 20px; }
.pet-note { display: none; margin: 6px 0 0; max-width: 220px; }
@media (max-width: 600px) { .pet-note { display: block; } }
.pet-toggle svg { width: 18px; height: 18px; }
.th-room { --s: 1; }
.th-room > * { position: fixed; bottom: 2px; pointer-events: none; }
.th-room > div > svg { width: 100%; height: 100%; display: block; }
.theia, .theia-ball { left: 0; z-index: 20; }
.theia, .th-fx { width: calc(120px * var(--s)); height: calc(90px * var(--s)); will-change: transform; }
.th-fx { left: 0; z-index: 22; }
.th-sofa { left: 12px; z-index: 19; width: calc(345px * var(--s)); height: calc(146px * var(--s)); } /* backrest level with the tree's middle deck */
.th-brush { left: calc(12px + 372px * var(--s)); z-index: 19; width: calc(64px * var(--s)); height: calc(22px * var(--s)); }
.th-tree { right: 14px; z-index: 19; width: calc(120px * var(--s)); height: calc(230px * var(--s)); }
.th-tree-front { z-index: 21; }
.th-bowl { right: calc(14px + 182px * var(--s)); z-index: 19; width: calc(40px * var(--s)); height: calc(34px * var(--s)); }
.th-fountain { right: calc(14px + 128px * var(--s)); z-index: 19; width: calc(50px * var(--s)); height: calc(60px * var(--s)); }
.th-fountain .tf-drip { animation: th-drip 1.6s ease-in infinite; }
.th-tree .tt-ball { transform-box: fill-box; transform-origin: 50% 50%; }
.th-tree.spin .tt-ball { animation: th-spin .8s cubic-bezier(.2, .7, .3, 1); }
.th-flip, .theia svg { width: 100%; height: 100%; display: block; overflow: visible; }
.theia.left .th-flip { transform: scaleX(-1); }
.theia svg * { pointer-events: none; }
.theia .th-fig * { pointer-events: visiblePainted; cursor: pointer; }
.theia .th-pose { display: none; }
.theia.p-stand .th-stand, .theia.p-sit .th-sit, .theia.p-sleep .th-sleep { display: inline; }
.theia .th-leg, .theia .th-head, .theia .th-tail, .theia .th-ear, .theia .th-fig, .theia .th-breathe { transform-box: fill-box; transition: transform .35s ease; }
.theia .th-leg { transform-origin: 50% 10%; }
.theia .th-head { transform-origin: 50% 90%; }
.theia .th-fig, .theia .th-breathe { transform-origin: 50% 100%; }
.theia .th-stand .th-tail { transform-origin: 100% 100%; animation: th-tail 2.8s ease-in-out infinite; }
.theia .th-tail-sit { transform-origin: 0% 50%; animation: th-tail-sit 3.4s ease-in-out infinite; }
.theia .th-ear-l { transform-origin: 80% 100%; } .theia .th-ear-r { transform-origin: 20% 100%; }
.theia .th-breathe { animation: th-breathe 3.4s ease-in-out infinite; }
.theia.blink .th-eyes, .theia.groom .th-sit .th-eyes { opacity: 0; }
.theia.blink .th-blink, .theia.groom .th-sit .th-blink { opacity: 1; }
.theia.twitch .th-ear-r { animation: th-twitch .4s ease-in-out; }
/* walking and running: diagonal leg pairs swing together, head bobs */
.theia.walk .th-leg, .theia.run .th-leg { animation: th-step .56s ease-in-out infinite; transition: none; }
.theia.walk .th-lf2, .theia.walk .th-lb1, .theia.run .th-lf2, .theia.run .th-lb1 { animation-delay: -.28s; }
.theia.walk .th-stand .th-head { animation: th-bob .28s ease-in-out infinite alternate; }
.theia.run { --swing: 30deg; } .theia.run .th-leg { animation-duration: .3s; } .theia.run .th-lf2, .theia.run .th-lb1 { animation-delay: -.15s; }
/* play: crouch with a bum wiggle, leap, bat the ball */
.theia.crouch .th-stand .th-fig { animation: th-wiggle .16s ease-in-out infinite alternate; }
.theia.leap .th-lf1, .theia.leap .th-lf2 { transform: rotate(-58deg); }
.theia.leap .th-lb1, .theia.leap .th-lb2 { transform: rotate(48deg); }
.theia.bat .th-lf1 { animation: th-bat .36s ease-in-out 2; }
.theia.stretch .th-stand .th-fig { transform: rotate(9deg) translateY(3px); }
.theia.stretch .th-lf1, .theia.stretch .th-lf2 { transform: rotate(-40deg); }
.theia.stretch .th-stand .th-tail { transform: rotate(-24deg); animation: none; }
.theia.groom .th-sf1 { transform: rotate(-162deg) scaleY(.62); }
.theia.groom .th-sit .th-head { animation: th-lick .45s ease-in-out infinite alternate; }
.theia.groom .th-tongue { opacity: 1; }
.theia.eat .th-stand .th-head, .theia.drink .th-stand .th-head { animation: th-eat .42s ease-in-out infinite alternate; }
.theia.drink .th-tongue { opacity: 1; }
/* sleeping: Zzz drifts up */
.th-z { position: absolute; right: 18%; top: 22%; display: none; font: 600 13px/1 var(--display); color: var(--harbor); }
.th-fx.asleep .th-z { display: block; }
.th-z i { position: absolute; font-style: normal; opacity: 0; animation: th-z 3.6s ease-out infinite; }
.th-z i:nth-child(2) { animation-delay: 1.2s; font-size: 11px; } .th-z i:nth-child(3) { animation-delay: 2.4s; font-size: 16px; }
.th-say { position: absolute; left: 50%; top: -12px; transform: translateX(-50%); white-space: nowrap; background: #fff; color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; padding: 3px 9px; font: 600 12px/1.3 var(--sans); box-shadow: 0 2px 8px rgba(15, 23, 42, .12); animation: th-pop 1.9s ease forwards; }
.th-heart { position: absolute; top: 18%; color: #e46a8f; font-size: 14px; opacity: 0; animation: th-heart 1.6s ease-out forwards; }
.theia-ball { width: 18px; height: 18px; transition: opacity .35s; }
.theia-ball.th-fall svg { animation: th-drop .7s cubic-bezier(.3, 0, .6, 1); }
.theia-ball.gone { opacity: 0; }
@keyframes th-step { 0%, 100% { transform: rotate(var(--swing, 17deg)); } 50% { transform: rotate(calc(var(--swing, 17deg) * -1)); } }
@keyframes th-bob { to { transform: translateY(1.5px); } }
@keyframes th-eat { from { transform: translate(3px, 6px) rotate(5deg); } to { transform: translate(3px, 8px) rotate(8deg); } }
@keyframes th-spin { to { transform: rotate(-220deg); } }
@keyframes th-drip { 0% { transform: translate(0, 0); opacity: 0; } 20% { opacity: 1; } 70% { transform: translate(-1px, 2px); opacity: 1; } 100% { transform: translate(-1.5px, 2.4px); opacity: 0; } }
@keyframes th-tail { 0%, 100% { transform: rotate(-5deg); } 50% { transform: rotate(9deg); } }
@keyframes th-tail-sit { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-3deg); } }
@keyframes th-breathe { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(1.05); } }
@keyframes th-twitch { 40% { transform: rotate(14deg); } }
@keyframes th-wiggle { from { transform: translateY(4px) scaleY(.88) rotate(5deg); } to { transform: translate(-1.6px, 4px) scaleY(.88) rotate(6.5deg); } }
@keyframes th-bat { 45% { transform: rotate(-72deg); } }
@keyframes th-lick { from { transform: rotate(7deg); } to { transform: rotate(12deg) translateY(1px); } }
@keyframes th-z { 0% { opacity: 0; transform: translate(0, 0); } 20% { opacity: .9; } 100% { opacity: 0; transform: translate(14px, -34px); } }
@keyframes th-pop { 0% { opacity: 0; transform: translate(-50%, 6px); } 12%, 80% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }
@keyframes th-heart { 0% { opacity: 0; transform: translateY(0) scale(.6); } 25% { opacity: 1; } 100% { opacity: 0; transform: translateY(-38px) scale(1.1); } }
@keyframes th-drop { 0% { transform: translateY(-120px); } 60% { transform: translateY(0); } 80% { transform: translateY(-14px); } 100% { transform: translateY(0); } }
@media (max-width: 600px) { .th-room { --s: .733; } .th-sofa, .th-brush { display: none; } }
@media (prefers-reduced-motion: reduce) { .th-room * { animation: none !important; transition: none !important; } }
body:has(.th-room:not([hidden])) main { padding-bottom: 240px; } /* last buttons can scroll clear of her room */

/* ---------- confirm dialog (start a new run) ---------- */
.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: rgba(15, 23, 42, .45); }
.modal-card { width: min(440px, 100%); background: #fff; border-radius: 14px; padding: 20px 22px 18px; box-shadow: 0 20px 50px rgba(15, 23, 42, .3); }
.modal-card h2 { margin: 0 0 8px; font-size: 19px; }
.modal-card p { margin: 0 0 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
button.danger { background: var(--bad-ink); }
button.danger:hover { background: #9f1239; }
