/* app.css - order-check one-page UI. Apple look: iOS inset-grouped lists, Reminders tiles, apple.com type.
   CSP style-src 'self': no inline styles anywhere; state lives in classes, data-* and [hidden]. */
:root {
  color-scheme: light dark;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Sukhumvit Set", "Thonburi", "Helvetica Neue", "Noto Sans Thai", "Leelawadee UI", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --bg: #f2f2f7; --card: #ffffff; --card-2: #f2f2f7;
  --fill: rgba(118, 118, 128, .12); --fill-2: rgba(118, 118, 128, .20);
  --text: #1d1d1f; --text-2: #6a6a6f; --text-3: #8e8e93;
  --sep: rgba(60, 60, 67, .18); --nav-bg: rgba(249, 249, 251, .78);
  --tint: #0071e3; --link: #0066cc; --tint-bg: rgba(0, 113, 227, .10);
  --red: #ff3b30; --red-text: #d70015; --red-bg: rgba(255, 59, 48, .12);
  --orange: #ff9500; --orange-text: #c93400; --orange-bg: rgba(255, 149, 0, .14);
  --green: #34c759; --green-text: #1f7a35; --green-bg: rgba(52, 199, 89, .14);
  --indigo: #5856d6; --indigo-text: #5856d6; --indigo-bg: rgba(88, 86, 214, .12);
  --blue: #007aff; --grey: #8e8e93;
  --focus: rgba(0, 113, 227, .45);
  --thumb: #ffffff; --sheet-bg: #f2f2f7; --sheet-card: #ffffff; --field: #ffffff;
  --shadow-thumb: 0 3px 8px rgba(0, 0, 0, .12), 0 3px 1px rgba(0, 0, 0, .04);
  --shadow-pop: 0 12px 40px rgba(0, 0, 0, .16), 0 0 0 .5px rgba(0, 0, 0, .06);
  --r-group: 12px; --r-tile: 16px; --r-card: 18px; --r-ctl: 10px; --r-pill: 999px; --nav-h: 52px;
  --gutter: 16px; --hair: 1px;
  --ease-ios: cubic-bezier(.32, .72, 0, 1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #000000; --card: #1c1c1e; --card-2: #2c2c2e;
    --fill: rgba(118, 118, 128, .24); --fill-2: rgba(118, 118, 128, .32);
    --text: #f5f5f7; --text-2: #9a9a9f; --text-3: #8e8e93;
    --sep: rgba(84, 84, 88, .65); --nav-bg: rgba(22, 22, 24, .72);
    --tint: #0071e3; --link: #2997ff; --tint-bg: rgba(41, 151, 255, .15);
    --red: #ff453a; --red-text: #ff6961; --red-bg: rgba(255, 69, 58, .18);
    --orange: #ff9f0a; --orange-text: #ffb340; --orange-bg: rgba(255, 159, 10, .18);
    --green: #30d158; --green-text: #30d158; --green-bg: rgba(48, 209, 88, .18);
    --indigo: #5e5ce6; --indigo-text: #8a88ff; --indigo-bg: rgba(94, 92, 230, .22);
    --blue: #0a84ff; --grey: #8e8e93;
    --focus: rgba(41, 151, 255, .6);
    --thumb: #636366; --sheet-bg: #1c1c1e; --sheet-card: #2c2c2e; --field: #1c1c1e;
    --shadow-thumb: 0 3px 8px rgba(0, 0, 0, .3);
    --shadow-pop: 0 12px 40px rgba(0, 0, 0, .6), 0 0 0 .5px rgba(255, 255, 255, .08);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000; --card: #1c1c1e; --card-2: #2c2c2e;
  --fill: rgba(118, 118, 128, .24); --fill-2: rgba(118, 118, 128, .32);
  --text: #f5f5f7; --text-2: #9a9a9f; --text-3: #8e8e93;
  --sep: rgba(84, 84, 88, .65); --nav-bg: rgba(22, 22, 24, .72);
  --tint: #0071e3; --link: #2997ff; --tint-bg: rgba(41, 151, 255, .15);
  --red: #ff453a; --red-text: #ff6961; --red-bg: rgba(255, 69, 58, .18);
  --orange: #ff9f0a; --orange-text: #ffb340; --orange-bg: rgba(255, 159, 10, .18);
  --green: #30d158; --green-text: #30d158; --green-bg: rgba(48, 209, 88, .18);
  --indigo: #5e5ce6; --indigo-text: #8a88ff; --indigo-bg: rgba(94, 92, 230, .22);
  --blue: #0a84ff; --grey: #8e8e93;
  --focus: rgba(41, 151, 255, .6);
  --thumb: #636366; --sheet-bg: #1c1c1e; --sheet-card: #2c2c2e; --field: #1c1c1e;
  --shadow-thumb: 0 3px 8px rgba(0, 0, 0, .3);
  --shadow-pop: 0 12px 40px rgba(0, 0, 0, .6), 0 0 0 .5px rgba(255, 255, 255, .08);
}
:root[data-theme="light"] { color-scheme: light; }
@media (min-resolution: 2dppx) { :root { --hair: .5px; } }
@media (min-width: 700px) { :root { --gutter: 24px; } }

/* ---- base ---- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--nav-h) + 8px); } /* scroll targets and keyboard focus clear the sticky nav */
body {
  margin: 0; background: var(--bg); color: var(--text); font: 400 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; overflow-wrap: anywhere; text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
h1, h2, h3, h4, p, ol, ul, dl, dd, figure, fieldset { margin: 0; }
p, h1, h2, h3, h4, li, dd, .source-status, .issue-title, .issue-sub { text-wrap: pretty; }
ul, ol { padding: 0; }
strong { font-weight: 600; }
a { color: var(--link); text-decoration: none; }
.mono { font-family: var(--mono); font-size: .9em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.muted { color: var(--text-2); }
.footnote { font-size: 13px; line-height: 1.5; color: var(--text-2); }
.cap { font-size: 13px; font-weight: 600; line-height: 1.45; color: var(--text-2); }
.vh { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
.offscreen { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.ic { width: 20px; height: 20px; flex: none; display: block; }
.ic-ko { stroke: var(--card); }

/* ---- nav bar + large title (iOS large-title behaviour) ---- */
.navbar {
  position: sticky; top: 0; z-index: 30; height: var(--nav-h); background: var(--nav-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 var(--hair) 0 transparent; transition: box-shadow .2s ease;
}
.navbar.is-scrolled { box-shadow: 0 var(--hair) 0 var(--sep); }
.navbar-in {
  max-width: calc(820px + 2 * var(--gutter)); height: 100%; margin: 0 auto; padding: 0 var(--gutter);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.nav-title { font-size: 17px; font-weight: 600; line-height: 1.3; opacity: 0; transform: translateY(6px); transition: opacity .2s ease, transform .2s ease; }
.navbar.is-scrolled .nav-title { opacity: 1; transform: none; }
.role-badge { margin-left: auto; font-size: 13px; font-weight: 600; line-height: 1.5; padding: 3px 11px; border-radius: var(--r-pill); background: linear-gradient(var(--fill), var(--fill)), var(--card); color: var(--text-2); }

.view { max-width: calc(820px + 2 * var(--gutter)); margin: 0 auto; padding: 0 var(--gutter) 24px; }
.hero { padding: 6px 0 0; }
.page-title { font-size: 34px; font-weight: 700; line-height: 1.25; }
.page-sub { margin-top: 2px; font-size: 17px; color: var(--text-2); }

/* ---- sections ---- */
.sec { margin-top: 28px; }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.sec-title { font-size: 22px; font-weight: 700; line-height: 1.3; }
.sec-trail { font-size: 15px; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.group { list-style: none; background: var(--card); border-radius: var(--r-group); overflow: hidden; }
@media (min-width: 700px) { .sec { margin-top: 32px; } }

/* ---- buttons ---- */
.btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 6px 16px; border: 0; border-radius: var(--r-pill);
  font-size: 15px; font-weight: 600; line-height: 1.35; text-align: center; cursor: pointer; user-select: none;
  transition: opacity .12s ease, background-color .12s ease, filter .12s ease;
}
.btn .ic { width: 17px; height: 17px; margin-left: -2px; }
.btn-filled { background: var(--tint); color: #fff; }
.btn-tinted { background: linear-gradient(var(--tint-bg), var(--tint-bg)), var(--card); color: var(--link); }
.btn-plain { background: transparent; color: var(--link); padding-left: 6px; padding-right: 6px; }
.btn-destructive { background: linear-gradient(var(--red-bg), var(--red-bg)), var(--card); color: var(--red-text); }
.btn-sm { min-height: 30px; padding: 4px 12px; font-size: 14px; }
.btn-sm .ic { width: 15px; height: 15px; }
.btn-lg { min-height: 50px; padding: 10px 20px; font-size: 17px; border-radius: 14px; }
.btn-trail-ic { flex-direction: row-reverse; }
.btn-trail-ic .ic { width: 13px; height: 13px; margin: 0 -4px 0 0; }
.btn:active:not(:disabled) { opacity: .7; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .4; cursor: default; }
.btn.is-done { color: var(--green-text); background: linear-gradient(var(--green-bg), var(--green-bg)), var(--card); }
@media (hover: hover) {
  .btn-filled:hover:not(:disabled) { filter: brightness(1.08); }
  .btn-tinted:hover:not(:disabled), .btn-destructive:hover:not(:disabled) { filter: brightness(.97); }
}
label.btn { font-weight: 600; }
.btnrow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.icon-btn {
  appearance: none; width: 30px; height: 30px; flex: none; border: 0; border-radius: 50%; display: inline-grid; place-items: center;
  background: var(--fill); color: var(--text-2); cursor: pointer;
}
.icon-btn .ic { width: 14px; height: 14px; }
.icon-btn:active { background: var(--fill-2); }
.linkish {
  appearance: none; background: none; border: 0; padding: 0; margin: 0; color: var(--link); cursor: pointer; text-align: left;
  font-size: 15px; line-height: 1.5; border-radius: 4px;
}
.linkish.mono { font-size: 14px; }
@media (hover: hover) { .linkish:hover { text-decoration: underline; } }

/* ---- pills / badges ---- */
.pill {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: var(--r-pill); white-space: nowrap;
  font-size: 12px; font-weight: 600; line-height: 1.5;
  background: linear-gradient(var(--fill), var(--fill)), var(--card); color: var(--text-2);
}
.st-checked { background: linear-gradient(var(--tint-bg), var(--tint-bg)), var(--card); color: var(--link); }
.st-reported { background: linear-gradient(var(--indigo-bg), var(--indigo-bg)), var(--card); color: var(--indigo-text); }
.st-fixed { background: linear-gradient(var(--green-bg), var(--green-bg)), var(--card); color: var(--green-text); }
.pill-red { background: linear-gradient(var(--red-bg), var(--red-bg)), var(--card); color: var(--red-text); }
.pill-orange { background: linear-gradient(var(--orange-bg), var(--orange-bg)), var(--card); color: var(--orange-text); }
.sev-badge { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.sev-badge .ic { width: 15px; height: 15px; }
.sev-high { background: var(--red-bg); color: var(--red); }
.sev-medium { background: var(--orange-bg); color: var(--orange); }
.sev-low { background: var(--tint-bg); color: var(--blue); }
.sku { font-family: var(--mono); white-space: normal; overflow-wrap: anywhere; }
.tablewrap .sku { white-space: nowrap; }   /* tables scroll sideways; elsewhere a long SKU wraps instead of being clipped */
.nw { white-space: nowrap; }
.sku-bad { background: linear-gradient(var(--red-bg), var(--red-bg)), var(--card); color: var(--red-text); border-radius: 5px; padding: 0 5px; }

/* ---- callouts / banners / errors ---- */
.callout {
  display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 10px; align-items: start;
  padding: 12px 14px; border-radius: var(--r-group); font-size: 15px; line-height: 1.5; background: var(--card);
}
.callout > .ic { margin-top: 1px; }
.callout-text { display: grid; gap: 6px; justify-items: start; min-width: 0; }
.callout.bad { background: linear-gradient(var(--red-bg), var(--red-bg)), var(--card); }
.callout.bad > .ic, .callout.bad strong { color: var(--red-text); }
.callout.warn { background: linear-gradient(var(--orange-bg), var(--orange-bg)), var(--card); }
.callout.warn > .ic { color: var(--orange); }
.callout.warn strong { color: var(--orange-text); }
.callout.info { background: linear-gradient(var(--tint-bg), var(--tint-bg)), var(--card); }
.callout.info > .ic, .callout.info strong { color: var(--link); }
.callout-btn { margin-left: -6px; }
.banners { display: grid; gap: 10px; margin-top: 16px; }
.banners:empty { display: none; }
.errbox {
  display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 10px; align-items: start; padding: 12px 14px;
  border-radius: var(--r-group); font-size: 15px; background: linear-gradient(var(--red-bg), var(--red-bg)), var(--card); color: var(--red-text);
}
.errbox > .ic { margin-top: 1px; }
.loading { display: flex; align-items: center; gap: 10px; padding: 12px 16px; font-size: 15px; color: var(--text-2); }
.spinner { width: 16px; height: 16px; flex: none; border-radius: 50%; border: 2px solid var(--fill-2); border-top-color: var(--text-2); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { padding: 16px; text-align: center; font-size: 15px; color: var(--text-2); }
.hint { margin-top: 10px; padding: 0 4px; font-size: 13px; color: var(--text-2); }

/* ---- sources ---- */
.sources-sec { margin-top: 20px; }
.sources { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 700px) { .sources { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.source { --c: var(--green); background: var(--card); border-radius: var(--r-card); padding: 16px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.source[data-tone="warn"] { --c: var(--orange); }
.source[data-tone="bad"] { --c: var(--red); }
.source-head { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.glyph { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: var(--c, var(--grey)); color: #fff; }
.glyph .ic { width: 19px; height: 19px; }
.source-id { min-width: 0; }
.source-title { font-size: 17px; font-weight: 600; line-height: 1.35; }
.source-status { font-size: 15px; line-height: 1.4; color: var(--text-2); font-variant-numeric: tabular-nums; }
.source-action { display: flex; align-items: center; }
.source-lines { display: grid; gap: 2px; padding-left: 44px; }
.source-line { font-size: 13px; line-height: 1.5; color: var(--text-2); font-variant-numeric: tabular-nums; }
.source-line.source-state { font-size: 15px; font-weight: 600; color: var(--text); }
.source[data-tone="bad"] .source-state { color: var(--red-text); }
.source[data-tone="warn"] .source-state { color: var(--orange-text); }
.source-foot { padding-left: 44px; font-size: 13px; color: var(--text-2); }
.source-foot:empty { display: none; }
.source-lines .errbox { margin-left: -44px; }
details.mini { margin-top: auto; border-top: var(--hair) solid var(--sep); padding-top: 4px; margin-left: 44px; }
details.mini > summary {
  list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 40px;
  font-size: 15px; color: var(--link); cursor: pointer; border-radius: 6px;
}
details.mini > summary::-webkit-details-marker { display: none; }
details.mini > summary .chev { width: 13px; height: 13px; color: var(--text-3); transition: transform .2s ease; }
details.mini[open] > summary .chev { transform: rotate(90deg); }
.steps { list-style: none; counter-reset: step; display: grid; gap: 8px; margin: 4px 0 10px; font-size: 15px; }
.steps li { counter-increment: step; position: relative; padding-left: 30px; line-height: 1.5; }
.steps li::before {
  content: counter(step); position: absolute; left: 0; top: 1px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; background: var(--fill); color: var(--text);
}
.upload-result:empty { display: none; }
.upload-result { margin-top: 12px; }
.result-card { background: var(--card); border-radius: var(--r-card); padding: 16px; display: grid; gap: 12px; }
.result-card[data-tone="ok"] { --c: var(--green); }
.result-card[data-tone="info"] { --c: var(--blue); }
.result-head { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.result-title { font-size: 17px; font-weight: 600; line-height: 1.4; }
.warnings { display: grid; gap: 6px; }
.warnlist { list-style: none; display: grid; gap: 6px; }
.warnlist li { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 8px; font-size: 15px; }
.warnlist .ic { width: 16px; height: 16px; margin-top: 3px; color: var(--orange); }

/* drop anywhere */
.drop-overlay {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 24px;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(160%); backdrop-filter: blur(18px) saturate(160%);
  animation: fade .18s ease;
}
.drop-overlay * { pointer-events: none; }
.drop-box {
  width: min(560px, 100%); min-height: 240px; padding: 32px 24px; border: 2px dashed var(--tint); border-radius: 28px;
  display: grid; place-items: center; align-content: center; gap: 8px; text-align: center;
  background: color-mix(in srgb, var(--card) 80%, transparent); box-shadow: var(--shadow-pop);
}
.drop-ic { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--tint); color: #fff; margin-bottom: 6px; }
.drop-ic .ic { width: 30px; height: 30px; }
.drop-title { font-size: 20px; font-weight: 600; line-height: 1.45; }
.drop-sub { font-size: 15px; color: var(--text-2); }

/* ---- summary tiles (Reminders smart lists) ---- */
.tiles-sec { margin-top: 24px; }
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 600px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile {
  --c: var(--grey); --cbg: var(--fill);
  appearance: none; border: 0; margin: 0; cursor: pointer; text-align: left; color: var(--text);
  display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto; gap: 8px 8px; align-items: center;
  min-height: 84px; padding: 10px 12px 10px 10px; border-radius: var(--r-tile); background: var(--card);
  transition: box-shadow .12s ease, background-color .12s ease;
}
.tile[data-tone="high"] { --c: var(--red); --cbg: var(--red-bg); }
.tile[data-tone="medium"] { --c: var(--orange); --cbg: var(--orange-bg); }
.tile[data-tone="low"] { --c: var(--blue); --cbg: var(--tint-bg); }
.tile-dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--c); color: #fff; }
.tile-dot .ic { width: 16px; height: 16px; }
.tile-n { justify-self: end; font-size: 28px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile-l { grid-column: 1 / -1; padding-left: 2px; font-size: 15px; font-weight: 600; line-height: 1.35; color: var(--text-2); }
.tile[aria-pressed="true"] { background: linear-gradient(var(--cbg), var(--cbg)), var(--card); box-shadow: inset 0 0 0 2px var(--c); }
.tile[aria-pressed="true"] .tile-l { color: var(--text); }
.tile:active { background: linear-gradient(var(--fill-2), var(--fill-2)), var(--card); }

/* ---- search + filters ---- */
.filters { display: grid; gap: 10px; }
.searchfield { position: relative; display: flex; align-items: center; height: 40px; border-radius: var(--r-ctl); background: var(--field); }
.searchfield .search-ic { position: absolute; left: 10px; width: 18px; height: 18px; color: var(--text-3); pointer-events: none; }
.search-input {
  flex: 1; min-width: 0; height: 100%; border: 0; border-radius: inherit; background: transparent; padding: 0 40px 0 36px;
  font-size: 16px; color: var(--text); outline: none;
}
.search-input::placeholder { color: var(--text-2); opacity: 1; }
.search-input::-webkit-search-cancel-button, .search-input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }
.searchfield:focus-within { box-shadow: 0 0 0 3px var(--focus); }
.search-clear {
  position: absolute; right: 4px; width: 32px; height: 32px; display: grid; place-items: center; border: 0; padding: 0;
  background: none; color: var(--text-3); cursor: pointer; border-radius: 50%;
}
.search-clear .ic { width: 18px; height: 18px; }
.search-clear .ic-ko { stroke: var(--field); }
.filter-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.filter-row .segmented { flex: 1 1 0; min-width: 180px; }
.filters-toggle { flex: none; padding-left: 12px; padding-right: 14px; }
@media (min-width: 600px) { .filter-row { justify-content: space-between; } .filter-row .segmented { flex: 0 1 380px; } }
.filters-toggle.is-on { background: var(--tint); color: #fff; }
.filter-panel { background: var(--card); border-radius: var(--r-group); padding: 12px 0; display: grid; gap: 12px; animation: reveal .2s ease; }
.chipgroup { display: grid; gap: 6px; min-width: 0; }
.chiplabel { padding: 0 16px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.chips { display: flex; gap: 8px; padding: 0 16px; }
.scroller { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
.scroller::-webkit-scrollbar { display: none; }
@media (min-width: 700px) { .chips.scroller { flex-wrap: wrap; overflow: visible; } }
.chip {
  flex: none; appearance: none; border: 0; cursor: pointer; min-height: 32px; padding: 5px 14px; border-radius: var(--r-pill);
  font-size: 14px; font-weight: 500; line-height: 1.4; white-space: nowrap; background: var(--fill); color: var(--text);
  transition: background-color .12s ease, color .12s ease;
}
.chip:active { background: var(--fill-2); }
.chip[aria-pressed="true"] { background: var(--tint); color: #fff; }
.tokens { display: flex; gap: 8px; align-items: center; }
.token {
  flex: none; appearance: none; border: 0; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
  min-height: 30px; padding: 4px 8px 4px 12px; border-radius: var(--r-pill); font-size: 14px; font-weight: 600;
  background: linear-gradient(var(--tint-bg), var(--tint-bg)), var(--card); color: var(--link);
}
.token .ic { width: 14px; height: 14px; }
.tokens > .btn { flex: none; white-space: nowrap; }

/* iOS segmented control: grey track, raised sliding thumb */
.segmented {
  position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); padding: 2px;
  border-radius: 9px; background: var(--fill); min-width: 0;
}
.seg-thumb {
  position: absolute; top: 2px; bottom: 2px; left: 2px; border-radius: 7px; background: var(--thumb); box-shadow: var(--shadow-thumb);
  transition: transform .3s var(--ease-ios);
}
.segmented[data-n="2"] .seg-thumb { width: calc((100% - 4px) / 2); }
.segmented[data-n="3"] .seg-thumb { width: calc((100% - 4px) / 3); }
.segmented[data-i="1"] .seg-thumb { transform: translateX(100%); }
.segmented[data-i="2"] .seg-thumb { transform: translateX(200%); }
.seg-btn {
  position: relative; z-index: 1; appearance: none; border: 0; background: none; cursor: pointer; min-width: 0; min-height: 34px;
  padding: 5px 4px; border-radius: 7px; font-size: 13px; font-weight: 500; line-height: 1.3; color: var(--text);
}
.seg-btn[aria-pressed="true"], .seg-btn[aria-selected="true"] { font-weight: 600; }
.seg-btn:focus-visible { outline-offset: -1px; }

/* ---- orders ---- */
.orders { display: grid; gap: 12px; }
.order-card { background: var(--card); border-radius: var(--r-group); padding: 14px 16px 16px; display: grid; gap: 12px; min-width: 0; }
.order-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.order-id { display: grid; gap: 1px; min-width: 0; }
.order-sn { font-size: 17px; font-weight: 600; color: var(--text); }
.order-oid { font-size: 13px; color: var(--text-2); }
.cols2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.order-col { display: grid; gap: 4px; align-content: start; min-width: 0; }
.order-col .cap { padding-bottom: 2px; border-bottom: var(--hair) solid var(--sep); }
.cmp-item { display: grid; gap: 1px; }
.cmp-name { font-size: 13px; color: var(--text-2); }
.cmp-flag { font-size: 13px; font-weight: 600; color: var(--red-text); white-space: nowrap; }
.cmp-flag-in { display: none; }
@media (max-width: 599px) {
  .tbl.cmp th:last-child, .tbl.cmp td:last-child { display: none; }
  .cmp-flag-in { display: block; margin-top: 2px; }
  .tbl.cmp th, .tbl.cmp td { padding-left: 10px; padding-right: 10px; }
}
.order-inline:not([hidden]) { display: block; }
.order-inline .order-card { padding: 12px; border: var(--hair) solid var(--sep); background: var(--card); }
.empty-state.card-empty { background: var(--card); border-radius: var(--r-group); }

/* ---- issues (inset grouped list, expandable rows) ---- */
.issues .li-pad { padding: 4px 0; }
.issues .li-pad .errbox { margin: 8px 12px; }
.issue { position: relative; }
.issue + .issue::before { content: ""; position: absolute; top: 0; left: 56px; right: 0; height: var(--hair); background: var(--sep); }
.issue-toggle {
  appearance: none; width: 100%; margin: 0; border: 0; background: transparent; cursor: pointer; text-align: left; color: inherit;
  display: grid; grid-template-columns: 28px minmax(0, 1fr) 14px; gap: 12px; align-items: start; padding: 12px 14px 12px 16px;
  transition: background-color .12s ease;
}
.issue-toggle:active { background: var(--fill); }
.issue-toggle:focus-visible { outline-offset: -3px; border-radius: var(--r-group); }
.issue-toggle .chev { align-self: center; width: 14px; height: 14px; color: var(--text-3); transition: transform .2s ease; }
.issue[data-expanded="true"] .issue-toggle .chev { transform: rotate(90deg); }
.issue-toggle .sev-badge { margin-top: 1px; }
.issue-text { display: grid; gap: 2px; min-width: 0; }
.issue-title { font-size: 16px; font-weight: 600; line-height: 1.45; }
.issue-sub { font-size: 14px; line-height: 1.5; color: var(--text-2); }
.issue-sn { color: var(--text); font-size: 14px; font-weight: 500; }
.issue-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; }
.asof { font-size: 12px; line-height: 1.5; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.issue-body { display: grid; gap: 12px; padding: 0 16px 16px 56px; min-width: 0; }
.issue-body.reveal { animation: reveal .2s ease; }
@keyframes reveal { from { opacity: 0; transform: translateY(-4px); } }
.detail { display: grid; gap: 10px; min-width: 0; }
.detail .cap { margin-top: 2px; }
.lastnote { font-size: 14px; line-height: 1.5; }
.lastnote .muted { font-size: 13px; }
.snlist { list-style: none; border-radius: 10px; background: var(--card-2); }
.snlist li { position: relative; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 8px 7px 12px; min-height: 44px; }
.snlist li + li::before { content: ""; position: absolute; top: 0; left: 12px; right: 0; height: var(--hair); background: var(--sep); }
.snlist .btn-tinted, .kv .btn-tinted { background: linear-gradient(var(--tint-bg), var(--tint-bg)), var(--card); }
.empty-state { list-style: none; display: grid; justify-items: center; gap: 2px; padding: 32px 16px 36px; text-align: center; }
.empty-glyph { width: 60px; height: 60px; color: var(--green); margin-bottom: 8px; }
.empty-glyph .ic { width: 60px; height: 60px; }
.empty-glyph.is-grey { width: 40px; height: 40px; color: var(--text-3); }
.empty-glyph.is-grey .ic { width: 40px; height: 40px; }
.empty-glyph .ic-ko { stroke: var(--card); stroke-width: 2.2; }
.empty-title { font-size: 20px; font-weight: 700; line-height: 1.4; }
.empty-sub { font-size: 15px; color: var(--text-2); }

/* key/value cells (iOS value cells) */
.kv { border-radius: 10px; background: var(--card-2); }
.kv:empty { display: none; }
.kv-row { position: relative; display: grid; grid-template-columns: fit-content(58%) minmax(0, 1fr); gap: 16px; align-items: baseline; padding: 9px 12px; font-size: 15px; line-height: 1.45; }
.kv-row + .kv-row::before { content: ""; position: absolute; top: 0; left: 12px; right: 0; height: var(--hair); background: var(--sep); }
.kv dt { color: var(--text-2); }
.kv dd { text-align: right; min-width: 0; font-variant-numeric: tabular-nums; }
.kv.compact { background: none; border-radius: 0; }
.kv.compact .kv-row { display: block; padding: 3px 0; }
.kv.compact .kv-row::before { display: none; }
.kv.compact dt { font-size: 12px; line-height: 1.45; }
.kv.compact dd { text-align: left; font-size: 15px; }

/* tables */
.tablewrap { overflow-x: auto; border-radius: 10px; border: var(--hair) solid var(--sep); -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 1.45; font-variant-numeric: tabular-nums; }
.tbl th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-2); background: var(--card-2); padding: 7px 12px; white-space: nowrap; }
.tbl td { padding: 9px 12px; border-top: var(--hair) solid var(--sep); vertical-align: top; }
.tbl .num { text-align: right; }
.tbl tr.row-bad td { background: linear-gradient(var(--red-bg), var(--red-bg)), var(--card); }
.tbl tr.row-warn td { background: linear-gradient(var(--orange-bg), var(--orange-bg)), var(--card); }
.ok-mark { color: var(--green-text); font-weight: 600; white-space: nowrap; }
.bad-mark { color: var(--red-text); font-weight: 600; white-space: nowrap; }
@media (max-width: 599px) {
  .tbl.stack thead { display: none; }
  .tbl.stack, .tbl.stack tbody, .tbl.stack tr { display: block; }
  .tbl.stack tr { padding: 7px 0; }
  .tbl.stack tr + tr { border-top: var(--hair) solid var(--sep); }
  .tbl.stack td { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; border: 0; padding: 2px 12px; text-align: right; background: none; }
  .tbl.stack td::before { content: attr(data-label); flex: none; max-width: 45%; text-align: left; font-size: 13px; color: var(--text-2); }
  .tbl.stack tr.row-bad { background: linear-gradient(var(--red-bg), var(--red-bg)), var(--card); }
  .tbl.stack tr.row-warn { background: linear-gradient(var(--orange-bg), var(--orange-bg)), var(--card); }
  .tbl.stack tr.row-bad td, .tbl.stack tr.row-warn td { background: none; }
  .tbl.stack td:empty { display: none; }
  .tbl.stack .sku { white-space: normal; min-width: 0; }   /* stacked rows are value lines: wrap there too */
}

/* ---- disclosures (waiting / Carry / activity / settings) ---- */
.more { display: grid; gap: 12px; }
.more > .disclosure { margin-top: 0; }
details.disclosure { --c: var(--blue); background: var(--card); border-radius: var(--r-group); overflow: hidden; }
details.disclosure[data-tone="orange"] { --c: var(--orange); }
details.disclosure[data-tone="indigo"] { --c: var(--indigo); }
details.disclosure[data-tone="grey"] { --c: var(--grey); }
details.disclosure > summary {
  list-style: none; display: grid; grid-template-columns: 30px minmax(0, 1fr) auto 14px; gap: 12px; align-items: center;
  min-height: 52px; padding: 10px 14px 10px 16px; cursor: pointer; user-select: none; transition: background-color .12s ease;
}
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary:active { background: var(--fill); }
details.disclosure > summary:focus-visible { outline-offset: -3px; border-radius: var(--r-group); }
.disc-glyph { width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center; background: var(--c); color: #fff; }
.disc-glyph .ic { width: 18px; height: 18px; }
.disc-title { font-size: 17px; line-height: 1.4; }
.disc-trail { font-size: 15px; color: var(--text-2); font-variant-numeric: tabular-nums; }
details.disclosure > summary .chev { width: 14px; height: 14px; color: var(--text-3); transition: transform .2s ease; }
details.disclosure[open] > summary .chev { transform: rotate(90deg); }
.disc-body { border-top: var(--hair) solid var(--sep); }
details.disclosure[open] > .disc-body { animation: reveal .2s ease; }
.disc-pad { padding: 14px 16px 16px; display: grid; gap: 12px; }
.disc-note { padding: 12px 16px 4px; font-size: 13px; color: var(--text-2); }
.rows { list-style: none; }
.row { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; padding: 10px 16px; }
.row + .row::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; height: var(--hair); background: var(--sep); }
.row-trail { font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; text-align: right; }
.carry-body { display: grid; gap: 10px; min-width: 0; }
.sub-block { border-top: var(--hair) solid var(--sep); padding: 14px 16px 16px; display: grid; gap: 8px; justify-items: start; }
.sub-title { font-size: 17px; font-weight: 600; line-height: 1.4; }
.activity .row { display: grid; gap: 1px; justify-content: stretch; }
.act-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.act-what { font-size: 15px; }
.act-line { font-size: 13px; color: var(--text-2); }
.act-detail { font-size: 14px; color: var(--text); }

/* settings form (iOS form rows) */
.settings-form { display: grid; }
.sub-cap { padding: 14px 16px 6px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.form-rows { border-top: var(--hair) solid var(--sep); border-bottom: var(--hair) solid var(--sep); }
.form-row { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 56px; padding: 10px 16px; }
.form-row + .form-row::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; height: var(--hair); background: var(--sep); }
.form-label { display: grid; gap: 1px; min-width: 0; font-size: 16px; line-height: 1.45; cursor: pointer; }
.form-hint { font-size: 13px; color: var(--text-2); }
.num-field {
  flex: none; width: 84px; height: 36px; padding: 0 10px; border: 0; border-radius: 8px; text-align: right;
  background: var(--card-2); color: var(--text); font-size: 16px; font-variant-numeric: tabular-nums;
}
.form-block { display: grid; gap: 6px; padding: 12px 16px 0; }
.form-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding-bottom: 16px; }
.form-cap { font-size: 13px; font-weight: 600; color: var(--text-2); }
.form-msg:empty { display: none; }
.form-msg.is-bad { color: var(--red-text); }
.input {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 0; border-radius: var(--r-ctl); background: var(--card-2); color: var(--text);
  font-size: 16px; line-height: 1.45;
}
textarea.input { resize: vertical; }
select.input { padding-right: 8px; }
.input::placeholder, textarea::placeholder { color: var(--text-2); opacity: 1; }
.input:focus, .num-field:focus { outline: none; box-shadow: 0 0 0 3px var(--focus); }
.users { border-top: var(--hair) solid var(--sep); padding: 0 16px 16px; display: grid; gap: 10px; }
.users .sub-cap { padding: 14px 0 0; }
.users .cap { margin-top: 6px; }
.users .em { overflow-wrap: anywhere; min-width: 150px; }
.users .cfmark { text-align: center; font-weight: 700; }
.users .tbl td::before { font-weight: 400; }
.field-btn .btn { min-height: 44px; }
.users .act-cell:empty { padding: 0; }
.cf-box { display: grid; gap: 8px; }
.cflist { list-style: none; border-radius: 10px; background: var(--card-2); }
.cflist li { position: relative; display: grid; gap: 8px; padding: 10px 12px; }
.cflist li + li::before { content: ""; position: absolute; top: 0; left: 12px; right: 0; height: var(--hair); background: var(--sep); }
.cflist .btn-tinted, .cflist .btn-destructive { background-color: var(--card); }
.user-add { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); }
.field { display: grid; gap: 6px; min-width: 0; }
@media (min-width: 600px) {
  .user-add { grid-template-columns: minmax(0, 1fr) 150px auto; align-items: end; }
  .cflist li { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
}
@media (max-width: 599px) {
  .users .tbl.stack td.cfmark { text-align: right; }
  .users .em { min-width: 0; }
}

/* ---- sheets (<dialog>) ---- */
dialog.sheet {
  padding: 0; border: 0; color: var(--text); background: var(--sheet-bg);
  width: 100%; max-width: 100%; max-height: 92vh; margin: auto 0 0; border-radius: 14px 14px 0 0; box-shadow: var(--shadow-pop); overflow: hidden;
}
dialog.sheet[open] { display: flex; flex-direction: column; animation: sheet-up .35s var(--ease-ios); }
dialog.sheet::backdrop { background: rgba(0, 0, 0, .4); }
dialog.sheet.closing { animation: sheet-down .2s ease-in forwards; }
dialog.sheet.closing::backdrop { animation: fade-out .2s ease-in forwards; }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes sheet-down { to { transform: translateY(100%); } }
@keyframes sheet-in { from { transform: translateY(12px) scale(.96); } }
@keyframes sheet-out { to { opacity: 0; transform: scale(.96); } }
@keyframes fade { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
.sheet-grab { flex: none; width: 36px; height: 5px; margin: 6px auto 0; border-radius: 3px; background: var(--fill-2); }
.sheet-head { flex: none; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 8px; min-height: 48px; padding: 2px 10px 2px 16px; }
.sheet-head h2 { grid-column: 2; font-size: 17px; font-weight: 600; line-height: 1.4; text-align: center; }
.sheet-close { grid-column: 3; justify-self: end; font-size: 17px; font-weight: 400; }
.sheet-body { overflow: auto; overscroll-behavior: contain; padding: 4px 16px calc(24px + env(safe-area-inset-bottom)); }
@media (min-width: 600px) {
  dialog.sheet { margin: auto; width: 540px; max-height: min(760px, calc(100vh - 64px)); border-radius: 14px; }
  dialog.sheet[open] { animation: sheet-in .3s var(--ease-ios); }
  dialog.sheet.closing { animation: sheet-out .18s ease-in forwards; }
  .sheet-grab { display: none; }
  .sheet-head { min-height: 56px; }
}
.sheet-form { display: grid; gap: 0; }
.sheet-sub { margin: 0 0 16px; text-align: center; font-size: 15px; line-height: 1.5; color: var(--text-2); }
.choice-set { border: 0; padding: 0; min-inline-size: 0; }
.choice-set > .form-cap { padding: 0 16px 6px; }
.choices { background: var(--sheet-card); border-radius: var(--r-group); overflow: hidden; }
.choice { position: relative; display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 16px; font-size: 17px; cursor: pointer; transition: background-color .12s ease; }
.choice + .choice::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; height: var(--hair); background: var(--sep); }
.choice:active { background: var(--fill); }
.choice-t { flex: 1; min-width: 0; line-height: 1.4; }
.choice-check { width: 20px; height: 20px; color: var(--link); visibility: hidden; }
.choice input:checked ~ .choice-check { visibility: visible; }
.choice input:checked ~ .choice-t { font-weight: 600; }
.choice:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: -3px; border-radius: var(--r-group); }
.form-cap-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 20px 16px 6px; }
.counter { font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.field-card { background: var(--sheet-card); border-radius: var(--r-group); }
.field-card:focus-within { box-shadow: 0 0 0 3px var(--focus); }
textarea.note { display: block; width: 100%; min-height: 112px; border: 0; border-radius: inherit; background: transparent; padding: 12px 16px; font-size: 16px; line-height: 1.5; color: var(--text); resize: vertical; outline: none; }
textarea.note::placeholder { color: var(--text-2); opacity: 1; }
.sheet-form .errbox { margin-top: 12px; }
.sheet-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
@media (min-width: 600px) { .sheet-actions { flex-direction: row-reverse; } .sheet-actions .btn { flex: 1; } }
.confirm-text { font-size: 17px; line-height: 1.5; text-align: center; padding: 4px 8px 0; }
.sheet .callout, .sheet .kv { background-color: var(--sheet-card); }

/* history timeline */
.events { padding-bottom: 4px; }
.timeline { list-style: none; position: relative; }
.timeline li { --c: var(--blue); position: relative; padding: 0 0 18px 26px; }
.timeline li[data-kind="created"] { --c: var(--red); }
.timeline li[data-kind="reopened"] { --c: var(--orange); }
.timeline li[data-kind="cleared"] { --c: var(--green); }
.timeline li[data-kind="severity"] { --c: var(--indigo); }
.timeline li::before { content: ""; position: absolute; left: 3px; top: 7px; width: 11px; height: 11px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 3px var(--sheet-bg); }
.timeline li::after { content: ""; position: absolute; left: 8px; top: 22px; bottom: 0; width: 1px; background: var(--sep); }
.timeline li:last-child { padding-bottom: 0; }
.timeline li:last-child::after { display: none; }
.tl-head { font-size: 16px; line-height: 1.45; }
.tl-change { color: var(--text); }
.tl-meta { font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.tl-note { margin-top: 6px; padding: 10px 12px; border-radius: 10px; background: var(--sheet-card); font-size: 15px; line-height: 1.5; }

/* ---- toast (HUD pill) ---- */
.toast-root {
  position: fixed; left: 16px; right: 16px; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 90;
  display: grid; justify-items: center; gap: 8px; pointer-events: none;
}
.toast {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 11px 18px 11px 14px; border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--card) 85%, transparent); color: var(--text);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  box-shadow: var(--shadow-pop); font-size: 15px; font-weight: 500; line-height: 1.4;
  animation: toast-in .35s var(--ease-ios);
}
.toast .ic { width: 20px; height: 20px; color: var(--green); }
.toast-bad .ic { color: var(--orange); }
.toast .ic-ko { stroke: #fff; }
.toast.out { opacity: 0; transform: translateY(8px); transition: opacity .25s ease, transform .25s ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(.96); } }

/* ---- footer ---- */
.footer { margin-top: 40px; padding: 20px 0 8px; border-top: var(--hair) solid var(--sep); display: grid; gap: 2px; text-align: center; font-size: 13px; color: var(--text-2); }

/* ---- boot fallback: app.js removes it, so it stays only when a script failed to load ---- */
.boot-msg { max-width: 420px; margin: 64px auto 0; padding: 0 var(--gutter); text-align: center; font-size: 15px; color: var(--text-2); }
.boot-hint { display: block; margin-top: 6px; visibility: hidden; animation: boot-hint 0s 6s forwards; }
@keyframes boot-hint { to { visibility: visible; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after, ::backdrop { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .boot-hint { visibility: visible; }
}
