:root {
  --ink: #0F172A; --muted: #475569; --line: #E2E8F0; --line2: #CBD5E1; --bg: #F4F5F7; --card: #FFFFFF;
  --accent: #1D4ED8; --accent-soft: #EFF4FF; --accent-dark: #1E3A8A;
  --urgent: #B42318; --urgent-soft: #FEF3F2; --ok: #047857; --ok-soft: #ECFDF5;
  --warn-ink: #9A3412; --warn-soft: #FFF7ED; --warn-line: #FED7AA;
  --head: #0F172A; --head2: #1E293B; --head-muted: #CBD5E1;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-text-size-adjust: 100%; }
a { color: var(--accent); } a:hover { color: var(--accent-dark); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid #93C5FD; outline-offset: 2px; }
.muted { color: var(--muted); }
.loading { padding: 48px 20px; text-align: center; color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* App shell: phone-width column, centred on desktop */
.shell { max-width: 560px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; background: var(--bg); }
@media (min-width: 600px) { .shell { border-left: 1px solid var(--line); border-right: 1px solid var(--line); } }

/* Header */
.top { background: var(--head); color: #fff; padding: calc(16px + env(safe-area-inset-top)) 20px 16px; display: flex; flex-direction: column; gap: 14px; }
.top-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.brand { display: flex; flex-direction: column; gap: 2px; }
.brand b { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.brand span { font-size: 13px; color: var(--head-muted); }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; border: 1px solid #334155; background: transparent; color: #fff; display: inline-flex; align-items: center; justify-content: center; position: relative; }
.icon-btn .dot { position: absolute; top: 9px; right: 9px; width: 8px; height: 8px; border-radius: 99px; background: #FCA5A5; }
.top-actions { display: flex; gap: 8px; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat { background: var(--head2); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.stat b { font-size: 22px; font-weight: 700; }
.stat b.hot { color: #FCA5A5; }
.stat span { font-size: 12px; color: var(--head-muted); }

/* Tabs + chips */
.tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.tab { height: 48px; border: 0; background: transparent; font-size: 14px; font-weight: 600; color: var(--ink); }
.tab span { font-weight: 500; color: var(--muted); }
.tab[aria-selected="true"] { color: var(--accent); box-shadow: inset 0 -3px 0 var(--accent); }
.chips { display: flex; gap: 8px; padding: 12px 16px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex-shrink: 0; height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line2); background: #fff; font-size: 13px; font-weight: 500; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

/* List + cards */
.list { flex: 1; padding: 0 16px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 24px; }
.bidno { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 0.01em; }
.card-top-right { display: flex; align-items: center; gap: 4px; }
.badge { font-size: 12px; font-weight: 600; border-radius: 999px; padding: 3px 9px; white-space: nowrap; }
.badge.urgent { color: var(--urgent); background: var(--urgent-soft); }
.badge.new { color: var(--accent); background: var(--accent-soft); }
.badge.corr { color: var(--warn-ink); background: var(--warn-soft); }
.badge.closed { color: var(--muted); background: #F1F5F9; }
.share-btn { width: 44px; height: 44px; margin: -10px -8px -10px 0; border: 0; background: transparent; color: var(--accent); border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; }
.title-btn { all: unset; cursor: pointer; font-size: 16px; font-weight: 600; line-height: 1.35; color: var(--ink); }
.title-btn:focus-visible { outline: 3px solid #93C5FD; outline-offset: 2px; border-radius: 4px; }
.meta { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--muted); }
.meta strong { color: var(--ink); font-weight: 600; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: 12px; font-weight: 500; color: var(--accent); background: var(--accent-soft); border-radius: 6px; padding: 3px 8px; }
.actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.btn { height: 44px; border-radius: 10px; border: 1px solid var(--line); background: #fff; font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; color: var(--ink); padding: 0 12px; }
.btn.on-saved { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.btn.on-applied { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.btn.quiet { color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-size: 14px; }
.btn.primary:hover { background: var(--accent-dark); color: #fff; }
.btn.big { height: 52px; font-size: 16px; border-radius: 12px; }
.btn.outline { border-color: var(--line2); }
.empty { background: #fff; border: 1px dashed var(--line2); border-radius: 14px; padding: 32px 20px; text-align: center; font-size: 14px; color: var(--muted); }
.alert-card { background: var(--accent-soft); border: 1px solid #BFDBFE; border-radius: 14px; padding: 12px 14px; display: flex; align-items: center; gap: 12px; font-size: 14px; }
.alert-card span { flex: 1; color: var(--accent-dark); font-weight: 500; }

/* Detail */
.bar { background: #fff; border-bottom: 1px solid var(--line); padding: calc(10px + env(safe-area-inset-top)) 12px 10px; display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 5; }
.bar .back { width: 44px; height: 44px; border-radius: 10px; border: 0; background: transparent; display: inline-flex; align-items: center; justify-content: center; color: var(--ink); }
.bar h1 { margin: 0; font-size: 16px; font-weight: 600; flex: 1; }
.detail { padding: 16px 16px calc(32px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.panel h2 { margin: 0; font-size: 19px; line-height: 1.3; font-weight: 700; }
.panel h3 { margin: 0; font-size: 15px; font-weight: 700; }
.rows { padding: 6px 16px; }
.row { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid #F1F5F9; font-size: 14px; }
.row:last-child { border-bottom: 0; }
.row span:first-child { color: var(--muted); }
.row span:last-child { font-weight: 600; text-align: right; }
.row .red { color: var(--urgent); font-weight: 700; }
.row .na { color: var(--muted); font-weight: 500; }
.warn { background: var(--warn-soft); border: 1px solid var(--warn-line); border-radius: 14px; padding: 12px 14px; display: flex; gap: 10px; align-items: flex-start; }
.warn b { display: block; font-size: 14px; color: var(--warn-ink); }
.warn p { margin: 2px 0 8px; font-size: 13px; color: #7C2D12; line-height: 1.4; }
.share-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
label.lbl { font-size: 13px; font-weight: 600; color: var(--muted); }
.field { min-height: 44px; border-radius: 10px; border: 1px solid var(--line2); background: #fff; padding: 10px 12px; font-size: 15px; width: 100%; }
textarea.field { resize: vertical; line-height: 1.45; }
.saved-hint { font-size: 12px; color: var(--ok); min-height: 16px; }
.activity { display: flex; flex-direction: column; gap: 8px; padding: 0 4px; }
.activity b { font-size: 13px; color: var(--muted); }
.activity span { font-size: 13px; color: var(--muted); line-height: 1.4; }

/* Bottom sheet (share) */
.scrim { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.55); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 560px; background: #fff; border-radius: 22px 22px 0 0; padding: 10px 20px calc(28px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 18px; max-height: 92vh; overflow-y: auto; }
.grab { width: 40px; height: 5px; border-radius: 99px; background: var(--line2); align-self: center; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-head b { font-size: 18px; }
.preview { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 13px; line-height: 1.5; color: #334155; white-space: pre-line; word-break: break-word; }
.targets { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.target { display: flex; flex-direction: column; align-items: center; gap: 8px; border: 0; background: transparent; padding: 0; font-size: 12px; font-weight: 500; color: var(--ink); text-decoration: none; }
.target i { width: 56px; height: 56px; border-radius: 16px; display: flex; align-items: center; justify-content: center; font-style: normal; }
.t-wa i { background: var(--ok-soft); color: var(--ok); }
.t-mail i { background: var(--urgent-soft); color: var(--urgent); }
.t-more i { background: var(--accent-soft); color: var(--accent); }
.t-copy i { background: #F1F5F9; color: #334155; }
.check { display: flex; align-items: center; gap: 12px; min-height: 44px; font-size: 14px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 60; }

/* Alerts / install screen */
.onboard { background: #fff; min-height: 100vh; min-height: 100dvh; padding: calc(48px + env(safe-area-inset-top)) 24px calc(32px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 24px; max-width: 560px; margin: 0 auto; }
.onboard .mark { width: 64px; height: 64px; border-radius: 16px; background: var(--ink); color: #fff; display: flex; align-items: center; justify-content: center; }
.onboard h1 { margin: 0; font-size: 28px; line-height: 1.2; letter-spacing: -0.02em; }
.onboard p { margin: 0; font-size: 15px; line-height: 1.5; color: var(--muted); }
.steps { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 14px; }
.steps li { display: flex; gap: 14px; align-items: flex-start; }
.steps .n { width: 28px; height: 28px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-size: 14px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.steps b { display: block; font-size: 15px; }
.steps small { font-size: 13px; color: var(--muted); line-height: 1.4; }
.spacer { flex: 1; }
.linkish { height: 44px; border: 0; background: transparent; font-size: 14px; font-weight: 600; color: var(--muted); }

/* Login + plain pages */
.login { max-width: 420px; margin: 0 auto; padding: 72px 24px; display: flex; flex-direction: column; gap: 16px; }
.login h1 { margin: 0; font-size: 28px; letter-spacing: -0.02em; }
.login p { margin: 0; line-height: 1.5; }
.login-mark { width: 64px; height: 64px; border-radius: 16px; background: var(--ink); color: #fff; display: flex; align-items: center; justify-content: center; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack label { font-size: 13px; font-weight: 600; color: var(--muted); }
.stack input, .stack textarea { min-height: 48px; border-radius: 10px; border: 1px solid var(--line2); padding: 10px 12px; font-size: 16px; background: #fff; }
.stack textarea { font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
.notice { border-radius: 10px; padding: 12px 14px; font-size: 14px; line-height: 1.45; }
.notice.ok { background: var(--ok-soft); color: var(--ok); border: 1px solid #A7F3D0; }
.notice.err { background: var(--urgent-soft); color: var(--urgent); border: 1px solid #FECACA; }
body.plain { background: #fff; }
.plain-wrap { max-width: 640px; margin: 0 auto; padding: 40px 20px; display: flex; flex-direction: column; gap: 14px; }
.plain-wrap h1 { margin: 0; font-size: 24px; }
.plain-wrap h2 { margin: 12px 0 0; font-size: 17px; }
.keybox { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px; font-size: 15px; word-break: break-all; white-space: pre-wrap; }
