/* shadcn base; phone: one column + bottom tabs; desktop: list | detail. Qmeter gradient only where the AI works and on login. */
:root {
  --background: #ffffff; --page: #fafafa; --foreground: #09090b; --card: #ffffff; --muted: #f4f4f5; --muted-foreground: #71717a;
  --border: #e4e4e7; --primary: #18181b; --primary-foreground: #fafafa; --ring: #a1a1aa; --danger: #dc2626; --danger-bg: #fef2f2;
  --warn-bg: #fffbeb; --warn-fg: #92400e; --warn-border: #fcd34d; --warn-mark: #fde68a; --ok-bg: #f0fdf4; --ok-fg: #15803d; --ok-dot: #22c55e;
  --info-bg: #eff6ff; --info-fg: #1d4ed8; --g1: #6a5cff; --g2: #b35cdc; --g3: #ec5a9c; --radius: 10px; --nav-h: 64px;
  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; --mono: "Geist Mono", ui-monospace, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --background: #09090b; --page: #000000; --foreground: #fafafa; --card: #0c0c0f; --muted: #18181b; --muted-foreground: #a1a1aa; --border: #27272a;
    --primary: #fafafa; --primary-foreground: #18181b; --ring: #52525b; --danger: #f87171; --danger-bg: #2a0e0e;
    --warn-bg: #1f1606; --warn-fg: #fcd34d; --warn-border: #854d0e; --warn-mark: #713f12; --ok-bg: #052e16; --ok-fg: #4ade80;
    --info-bg: #0b1a3a; --info-fg: #93c5fd; --g1: #7d71ff; --g2: #c06be6; --g3: #f06aa8; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { background: var(--page); color: var(--foreground); font-family: var(--font); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
svg { flex: none; display: block; }
[hidden] { display: none !important; }
.muted { color: var(--muted-foreground); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 14px; }
h1 { font-size: 22px; font-weight: 600; letter-spacing: -.02em; margin: 0; line-height: 1.25; text-wrap: balance; }
h2 { font-size: 15px; font-weight: 600; margin: 0; letter-spacing: -.01em; }
p { margin: 0; }
a { color: inherit; }
.grad-text { background: linear-gradient(120deg, var(--g1), var(--g2), var(--g3)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(0, 0, 0, .04); }
.card-pad { padding: 16px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 8px; border: 1px solid transparent; font-weight: 500; font-size: 14px; white-space: nowrap; transition: opacity .15s, background .15s; text-decoration: none; }
.btn-primary { background: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover { opacity: .9; }
.btn-outline { background: var(--background); border-color: var(--border); }
.btn-outline:hover { background: var(--muted); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--muted); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-lg { height: 52px; font-size: 16px; border-radius: 10px; width: 100%; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-icon { width: 36px; padding: 0; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.input { width: 100%; height: 42px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--background); }
.input:focus { outline: 2px solid var(--ring); outline-offset: 0; }
.field { display: grid; gap: 6px; font-size: 14px; font-weight: 500; }
.err { color: var(--danger); background: var(--danger-bg); border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.note { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--muted); font-size: 13px; color: var(--muted-foreground); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 32px max(16px, env(safe-area-inset-right, 0px)) 32px max(16px, env(safe-area-inset-left, 0px)); position: relative; overflow: hidden; }
.login::before { content: ""; position: absolute; width: 640px; height: 640px; max-width: 140vw; border-radius: 50%; background: radial-gradient(closest-side, color-mix(in srgb, var(--g1) 22%, transparent), color-mix(in srgb, var(--g3) 10%, transparent) 60%, transparent); top: -260px; left: 50%; transform: translateX(-50%); pointer-events: none; }
.login-card { position: relative; width: min(400px, 100%); padding: 28px 24px; display: grid; gap: 18px; }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.ai-chip { font-size: 13px; font-weight: 600; letter-spacing: .02em; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); }
.login-head { text-align: center; display: grid; gap: 4px; }
.login form { display: grid; gap: 14px; }

/* shell */
.hdr { position: sticky; top: 0; z-index: 30; background: var(--background); border-bottom: 1px solid var(--border); padding-top: env(safe-area-inset-top, 0px); }
.hdr-in { max-width: 1180px; margin: 0 auto; height: 60px; display: flex; align-items: center; gap: 20px; padding: 0 max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px)); }
.brand { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.brand-ai { font-size: 13px; font-weight: 600; padding-left: 10px; border-left: 1px solid var(--border); }
.topnav { display: flex; gap: 4px; }
.topnav button { height: 36px; padding: 0 12px; border-radius: 8px; border: 0; background: none; color: var(--muted-foreground); font-weight: 500; display: inline-flex; align-items: center; gap: 8px; }
.topnav button:hover { color: var(--foreground); }
.topnav button[aria-current="true"] { background: var(--muted); color: var(--foreground); }
.count { font-family: var(--mono); font-size: 12px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--muted); display: inline-grid; place-items: center; }
.topnav button[aria-current="true"] .count { background: var(--background); }
.hdr-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.helper { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted-foreground); border: 1px solid var(--border); border-radius: 999px; height: 30px; padding: 0 12px; white-space: nowrap; background: none; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok-dot); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok-dot) 25%, transparent); }
.dot.off { background: var(--warn-border); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn-border) 30%, transparent); }
.me { width: 32px; height: 32px; border-radius: 50%; background: var(--muted); display: grid; place-items: center; font-size: 13px; font-weight: 600; border: 0; }
.bottomnav { display: none; }
.page { max-width: 1180px; margin: 0 auto; padding: 20px max(16px, env(safe-area-inset-right, 0px)) 40px max(16px, env(safe-area-inset-left, 0px)); }
.split { display: grid; grid-template-columns: 400px minmax(0, 1fr); gap: 20px; align-items: start; }
.listpane { display: grid; gap: 14px; min-width: 0; }
.detailpane { min-width: 0; position: sticky; top: calc(env(safe-area-inset-top, 0px) + 76px); max-height: calc(100vh - 96px); overflow: auto; display: grid; gap: 14px; align-content: start; padding: 2px 2px 4px; }

/* upload */
.upload { border: 1.5px dashed var(--border); border-radius: 14px; padding: 18px; display: flex; align-items: center; gap: 14px; background: var(--card); transition: background .15s, border-color .15s; }
.upload.over { background: var(--muted); border-color: var(--ring); }
.upload-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--muted); display: grid; place-items: center; flex: none; }
.upload-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.upload-text b { font-weight: 600; }
.upload-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.upload-btns label { cursor: pointer; }
@media (hover: hover) and (pointer: fine) { .cam-only { display: none !important; } }
@media (hover: none), (pointer: coarse) { .desk-only { display: none !important; } }
.up-progress { display: grid; gap: 6px; padding: 12px 14px; }

/* AI */
.ai-banner { border-radius: 12px; padding: 1.5px; background: linear-gradient(120deg, var(--g1), var(--g2), var(--g3), var(--g1)); background-size: 300% 100%; animation: flow 4s linear infinite; }
.ai-banner-in { border-radius: 10.5px; background: var(--card); padding: 12px 14px; display: flex; align-items: center; gap: 12px; }
.ai-orb { width: 34px; height: 34px; border-radius: 50%; flex: none; background: conic-gradient(from 0deg, var(--g1), var(--g2), var(--g3), var(--g1)); animation: spin 2.4s linear infinite; display: grid; place-items: center; }
.ai-orb::after { content: ""; width: 24px; height: 24px; border-radius: 50%; background: var(--card); }
.ai-banner b { font-weight: 600; }
@keyframes flow { to { background-position: 300% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* list */
.list { display: flex; flex-direction: column; }
.list-title { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 8px; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border: 0; border-top: 1px solid var(--border); background: none; width: 100%; text-align: left; position: relative; }
button.item:hover { background: var(--muted); }
.item[aria-current="true"] { background: var(--muted); }
.item[aria-current="true"]::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--primary); }
.item.static { cursor: default; }
.av { width: 42px; height: 42px; border-radius: 8px; background: var(--muted); display: grid; place-items: center; font-weight: 600; font-size: 13px; overflow: hidden; flex: none; color: var(--muted-foreground); position: relative; }
.av img { width: 100%; height: 100%; object-fit: cover; }
.item-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.item-main b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-main span { font-size: 13px; color: var(--muted-foreground); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chev { color: var(--muted-foreground); display: flex; }
.empty { padding: 22px 16px; color: var(--muted-foreground); font-size: 14px; border-top: 1px solid var(--border); text-align: center; }
.item.proc .av { background: color-mix(in srgb, var(--g1) 10%, var(--muted)); }
.scanline { position: absolute; left: 0; right: 0; height: 30%; top: -30%; background: linear-gradient(to bottom, transparent, color-mix(in srgb, var(--g2) 55%, transparent), transparent); animation: scan 1.6s ease-in-out infinite; }
@keyframes scan { 0% { top: -30%; } 100% { top: 100%; } }
.shimmer { height: 10px; border-radius: 5px; background: linear-gradient(90deg, var(--muted) 0%, color-mix(in srgb, var(--g1) 18%, var(--muted)) 50%, var(--muted) 100%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.pbar { height: 4px; border-radius: 999px; background: var(--muted); overflow: hidden; margin-top: 4px; }
.pbar i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--g1), var(--g2), var(--g3)); transition: width .6s linear; }
.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; border: 1px solid transparent; flex: none; }
.b-check { background: var(--primary); color: var(--primary-foreground); }
.b-warn { background: var(--warn-bg); color: var(--warn-fg); border-color: var(--warn-border); }
.b-err { background: var(--danger-bg); color: var(--danger); }
.b-ai { color: #fff; background: linear-gradient(120deg, var(--g1), var(--g3)); }
.b-info { background: var(--info-bg); color: var(--info-fg); }
.b-ok { background: var(--ok-bg); color: var(--ok-fg); }
.b-out { border-color: var(--border); color: var(--muted-foreground); }
.spin { width: 12px; height: 12px; border-radius: 50%; border: 2px solid currentColor; border-top-color: transparent; animation: spin .8s linear infinite; flex: none; }

/* detail */
.back { display: none; align-self: flex-start; margin-left: -8px; }
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.detail-head .meta { font-size: 13px; color: var(--muted-foreground); margin-top: 2px; }
.sum { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.sum .wide { grid-column: 1 / -1; }
.sum .card-pad { display: grid; gap: 3px; }
.sum h2 { font-size: 13px; font-weight: 500; color: var(--muted-foreground); margin-bottom: 4px; }
.line { font-size: 15px; overflow-wrap: anywhere; }
.line .lbl { color: var(--muted-foreground); }
.price { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.price b { font-size: 24px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
mark { background: var(--warn-mark); color: inherit; border-radius: 4px; padding: 0 3px; }
.ask { border: 1px solid var(--warn-border); background: var(--warn-bg); color: var(--warn-fg); border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 10px; }
.ask .opts { display: flex; gap: 8px; flex-wrap: wrap; }
.ask .opts .btn { color: var(--foreground); height: auto; min-height: 36px; white-space: normal; text-align: left; padding: 6px 12px; }
.ask form { display: flex; gap: 8px; }
.ask form .input { color: var(--foreground); }
.ask-count { font-size: 12px; font-weight: 600; }
.photo img { width: 100%; display: block; border-radius: var(--radius); background: var(--muted); }
.actbar { position: sticky; bottom: 12px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px; display: grid; gap: 6px; justify-items: center; box-shadow: 0 10px 28px rgba(0, 0, 0, .08); }
.actbar .muted { text-align: center; }
.placeholder { display: grid; place-items: center; text-align: center; gap: 10px; padding: 64px 20px; color: var(--muted-foreground); }
.placeholder .ph-icon { width: 52px; height: 52px; border-radius: 14px; background: var(--muted); display: grid; place-items: center; color: var(--foreground); }
.center { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; padding: 32px 20px; }
.done-icon { width: 56px; height: 56px; border-radius: 50%; background: var(--ok-bg); color: var(--ok-fg); display: grid; place-items: center; }
.steps { text-align: left; display: grid; gap: 12px; margin: 4px 0 0; padding: 0; width: 100%; max-width: 440px; }
.steps li { list-style: none; display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; align-items: center; font-size: 15px; }
.steps li > span { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border); display: grid; place-items: center; font-size: 13px; font-weight: 600; }
.steps.live li { color: var(--muted-foreground); }
.steps.live li.on { color: var(--foreground); }
.steps.live li.on > span { border-color: var(--g1); color: var(--g1); }
.steps.live li.ok { color: var(--foreground); }
.steps.live li.ok > span { background: var(--ok-bg); color: var(--ok-fg); border-color: transparent; }
.kbd { font-family: var(--mono); font-size: 13px; background: var(--muted); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; }
.search { position: relative; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted-foreground); }
.search .input { padding-left: 38px; }
.group-label { padding: 12px 16px 6px; font-size: 12px; font-weight: 600; color: var(--muted-foreground); text-transform: uppercase; letter-spacing: .05em; border-top: 1px solid var(--border); }
.group-label:first-child { border-top: 0; }

/* users, setup, modal */
.narrow { max-width: 760px; display: grid; gap: 16px; }
.urow { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.urow:first-of-type { border-top: 0; }
.urow .item-main { min-width: 160px; }
.add-form { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) 140px auto; gap: 10px; align-items: end; }
.setup-step { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; padding: 14px 16px; border-top: 1px solid var(--border); }
.setup-step:first-of-type { border-top: 0; }
.setup-step > span { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border); display: grid; place-items: center; font-size: 13px; font-weight: 600; }
.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--muted); gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 500; color: var(--muted-foreground); }
.seg button[aria-pressed="true"] { background: var(--background); color: var(--foreground); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.overlay { position: fixed; inset: 0; z-index: 70; background: rgba(0, 0, 0, .45); display: grid; place-items: center; padding: 16px; }
.modal { width: min(440px, 100%); padding: 20px; display: grid; gap: 14px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom, 0px) + 24px); background: var(--primary); color: var(--primary-foreground); padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 500; z-index: 80; max-width: calc(100% - 32px); box-shadow: 0 8px 24px rgba(0, 0, 0, .18); }

@media (max-width: 959px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .split.has-sel .listpane { display: none; }
  .split:not(.has-sel) .detailpane { display: none; }
  .detailpane { position: static; max-height: none; overflow: visible; padding: 0; }
  .back { display: inline-flex; }
  .helper .lbl-long { display: none; }
}
@media (max-width: 719px) {
  .topnav, .brand-ai-long { display: none; }
  .hdr-in { gap: 12px; height: 56px; }
  .bottomnav { display: grid; grid-template-columns: repeat(var(--tabs, 2), 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--background); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom, 0px); }
  .bottomnav button { height: var(--nav-h); border: 0; background: none; display: grid; justify-items: center; align-content: center; gap: 3px; font-size: 12px; font-weight: 500; color: var(--muted-foreground); position: relative; }
  .bottomnav button[aria-current="true"] { color: var(--foreground); }
  .bottomnav .count { position: absolute; top: 8px; left: calc(50% + 6px); height: 18px; min-width: 18px; font-size: 11px; background: var(--primary); color: var(--primary-foreground); }
  .page { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 24px); }
  .actbar { bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 10px); }
  .toast { bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 16px); }
  .sum { grid-template-columns: minmax(0, 1fr); }
  .upload { flex-direction: column; text-align: center; padding: 22px 16px; }
  .upload .btn { width: 100%; height: 48px; }
  .upload-btns { width: 100%; flex-direction: column; }
  .add-form { grid-template-columns: minmax(0, 1fr); }
  .helper { padding: 0 10px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; } }

/* live ACE page */
.ace-live { overflow: hidden; }
.ace-live-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.ace-live-screen { position: relative; background: #fff; min-height: 200px; }
.ace-live-screen img { display: block; width: 100%; height: auto; cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none; }
.ace-live-wait { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted-foreground); }
.ace-type { display: flex; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--border); }
.ace-type .input { height: 34px; }
