/* Shared styles for every page. Colours are tokens; the dark set follows the system setting. */
:root {
  --bg:#f4f5f7; --fg:#16181d; --muted:#626873; --card:#ffffff; --raised:#f9fafb; --line:#e2e5ea; --line-strong:#cdd2da;
  --accent:#2f5fd0; --accent-hover:#244db0; --accent-fg:#ffffff; --accent-soft:#e8eefc; --focus:rgb(47 95 208 / .35);
  --add:#1c7a3d; --del:#b42318; --spec:#b54708; --price:#2f5fd0; --addbg:#e6f4ea; --delbg:#fde8e6; --specbg:#fff3e0;
  --ai:#6941c6; --aibg:#f2eefc;
  --radius:12px; --radius-sm:8px; --shadow:0 1px 2px rgb(16 24 40 / .05), 0 1px 3px rgb(16 24 40 / .06);
  --shadow-lg:0 12px 32px rgb(16 24 40 / .14);
  --font:"Inter", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme:light;
}
@media (prefers-color-scheme: dark) { :root {
  --bg:#0f1115; --fg:#e8eaee; --muted:#9aa1ad; --card:#171a20; --raised:#1d2129; --line:#272c35; --line-strong:#353b46;
  --accent:#7aa2ff; --accent-hover:#97b6ff; --accent-fg:#0b1430; --accent-soft:#1b2540; --focus:rgb(122 162 255 / .35);
  --add:#5fd18b; --del:#ff8b80; --spec:#ffb35c; --price:#7aa2ff; --addbg:#15301f; --delbg:#3a1a17; --specbg:#36260f;
  --ai:#c2aefc; --aibg:#251e3d;
  --shadow:0 1px 2px rgb(0 0 0 / .3); --shadow-lg:0 16px 40px rgb(0 0 0 / .5);
  color-scheme:dark;
} }

* { box-sizing:border-box; }
html { -webkit-text-size-adjust:100%; }
body { margin:0; font:15px/1.5 var(--font); background:var(--bg); color:var(--fg); -webkit-font-smoothing:antialiased; }
main { max-width:1440px; margin:0 auto; padding:28px 24px 56px; }
@media (max-width: 640px) { main { padding:20px 16px 40px; } }
h1 { font-size:24px; line-height:1.25; letter-spacing:-.01em; margin:0 0 6px; font-weight:700; }
h2 { font-size:17px; line-height:1.3; margin:0 0 12px; font-weight:650; }
h3 { font-size:14px; margin:0 0 8px; font-weight:650; }
p.lead { color:var(--muted); margin:0 0 22px; max-width:880px; }
a { color:var(--accent); text-underline-offset:2px; }
:focus-visible { outline:3px solid var(--focus); outline-offset:2px; }

/* Top bar */
nav.top { position:sticky; top:0; z-index:50; display:flex; flex-wrap:wrap; align-items:center; gap:4px 6px; padding:10px 24px;
  background:color-mix(in srgb, var(--card) 88%, transparent); backdrop-filter:saturate(1.4) blur(8px); border-bottom:1px solid var(--line); }
nav.top .brand { display:flex; align-items:center; gap:10px; font-weight:700; letter-spacing:-.01em; margin-right:18px; }
nav.top .brand .mark { width:26px; height:26px; border-radius:7px; display:grid; place-items:center; font-size:13px; font-weight:800;
  background:linear-gradient(135deg, var(--accent), var(--ai)); color:#fff; }
nav.top a { text-decoration:none; color:var(--muted); font-weight:550; font-size:14px; padding:6px 12px; border-radius:999px; }
nav.top a:hover { color:var(--fg); background:var(--raised); }
nav.top a.on { color:var(--fg); background:var(--accent-soft); }
nav.top .me { margin-left:auto; color:var(--muted); font-size:13px; display:flex; gap:4px; align-items:center; }
nav.top .me a { font-size:13px; padding:4px 10px; }
@media (max-width: 640px) { nav.top { padding:8px 12px; } nav.top .brand .name { display:none; } nav.top .brand { margin-right:4px; } }

/* Cards and layout */
.card { background:var(--card); border:1px solid var(--line); border-radius:var(--radius); padding:20px; margin-bottom:18px; box-shadow:var(--shadow); }
.card > h2:first-child { margin-top:0; }
.card-head { display:flex; flex-wrap:wrap; align-items:baseline; gap:6px 12px; justify-content:space-between; margin-bottom:14px; }
.card-head h2 { margin:0; }
.row { display:flex; flex-wrap:wrap; gap:14px; align-items:end; }
.stack { display:flex; flex-direction:column; gap:12px; }
hr, .divider { border:0; border-top:1px solid var(--line); margin:16px 0; }

/* Forms */
label { display:flex; flex-direction:column; gap:6px; font-weight:600; font-size:13px; color:var(--fg); }
label.inline { flex-direction:row; align-items:center; font-weight:500; gap:8px; }
input[type=text], input[type=password], input[type=number], input[type=url], input[type=email], select, textarea {
  height:38px; padding:0 11px; border:1px solid var(--line-strong); border-radius:var(--radius-sm); background:var(--card); color:var(--fg);
  font:inherit; font-size:14px; font-weight:400; min-width:0; transition:border-color .15s, box-shadow .15s; }
textarea { height:auto; width:100%; min-height:84px; padding:9px 11px; resize:vertical; }
input:hover, select:hover, textarea:hover { border-color:var(--muted); }
input:focus, select:focus, textarea:focus { outline:none; border-color:var(--accent); box-shadow:0 0 0 3px var(--focus); }
input[type=checkbox], input[type=radio] { accent-color:var(--accent); width:16px; height:16px; margin:0; flex:none; }
input[type=file] { font:inherit; font-size:13px; font-weight:400; color:var(--muted); max-width:100%; }
input[type=file]::file-selector-button { font:inherit; font-weight:600; font-size:13px; margin-right:10px; padding:7px 12px; border-radius:var(--radius-sm);
  border:1px solid var(--line-strong); background:var(--raised); color:var(--fg); cursor:pointer; }
input[type=file]::file-selector-button:hover { border-color:var(--accent); color:var(--accent); }
fieldset { min-width:0; }

/* Buttons */
button, .btn { display:inline-flex; align-items:center; justify-content:center; gap:6px; height:38px; padding:0 16px; border-radius:var(--radius-sm);
  border:1px solid var(--accent); background:var(--accent); color:var(--accent-fg); font:inherit; font-size:14px; font-weight:600; cursor:pointer;
  white-space:nowrap; text-decoration:none; transition:background .15s, border-color .15s, box-shadow .15s; }
button:hover, .btn:hover { background:var(--accent-hover); border-color:var(--accent-hover); }
button.secondary, .btn.secondary { background:var(--card); color:var(--fg); border-color:var(--line-strong); }
button.secondary:hover, .btn.secondary:hover { background:var(--raised); border-color:var(--muted); }
button.link { height:auto; background:none; border:0; color:var(--accent); padding:0; font-weight:550; }
button.link:hover { background:none; text-decoration:underline; }
button:disabled { opacity:.5; cursor:not-allowed; }
button:disabled:hover { background:var(--accent); border-color:var(--accent); }
button.secondary:disabled:hover { background:var(--card); border-color:var(--line-strong); }

/* Text helpers and states */
.muted { color:var(--muted); font-size:12.5px; } .err { color:var(--del); } .ok { color:var(--add); } .warn { color:var(--spec); font-size:13px; }
.notice { display:flex; gap:10px; align-items:flex-start; padding:10px 14px; border-radius:var(--radius-sm); font-size:13.5px; margin:10px 0 0;
  background:var(--specbg); color:var(--spec); border:1px solid color-mix(in srgb, var(--spec) 30%, transparent); }

/* Stat tiles */
.tiles { display:flex; flex-wrap:wrap; gap:12px; }
.tile { background:var(--card); border:1px solid var(--line); border-radius:var(--radius); padding:12px 16px; min-width:130px; box-shadow:var(--shadow); }
.tile b { display:block; font-size:24px; line-height:1.2; letter-spacing:-.01em; font-variant-numeric:tabular-nums; } .tile span { color:var(--muted); font-size:12.5px; }

/* Tables */
table { width:100%; border-collapse:collapse; }
th, td { text-align:left; vertical-align:top; padding:10px 12px; border-bottom:1px solid var(--line); font-size:14px; }
th { font-size:11.5px; font-weight:650; color:var(--muted); text-transform:uppercase; letter-spacing:.05em; background:var(--raised); white-space:nowrap; }
tbody tr:hover td { background:color-mix(in srgb, var(--raised) 70%, transparent); }
tbody tr:last-child td { border-bottom:0; }
.table-wrap { overflow-x:auto; border:1px solid var(--line); border-radius:var(--radius-sm); }
td { font-variant-numeric:tabular-nums; }

/* Diff marks and badges */
ins { background:var(--addbg); color:inherit; text-decoration:none; border-radius:3px; padding:0 2px; }
del { background:var(--delbg); color:inherit; border-radius:3px; padding:0 2px; }
.badge { display:inline-block; font-size:11px; font-weight:700; padding:2px 8px; border-radius:99px; border:1px solid currentColor; white-space:nowrap; }
.Added { color:var(--add); } .Removed { color:var(--del); } .SpecificationChangedPriceUnchanged { color:var(--spec); }
.PriceOnlyChanged, .SpecificationAndPriceChanged { color:var(--price); }

dialog { border:1px solid var(--line); border-radius:var(--radius); background:var(--card); color:var(--fg); max-width:min(900px, calc(100vw - 32px)); width:100%; padding:22px; box-shadow:var(--shadow-lg); }
dialog::backdrop { background:rgb(0 0 0 / .45); }
pre { white-space:pre-wrap; word-break:break-word; background:var(--raised); border:1px solid var(--line); border-radius:var(--radius-sm); padding:12px; font-size:12px; max-height:50vh; overflow:auto; }

/* Sign-in pages */
.auth { max-width:400px; margin:12vh auto 0; padding:28px; }
.auth form { display:flex; flex-direction:column; gap:14px; } .auth button { width:100%; }
.auth .brand { display:flex; align-items:center; gap:10px; margin-bottom:18px; font-weight:700; }
.auth .brand .mark { width:30px; height:30px; border-radius:8px; display:grid; place-items:center; font-weight:800; background:linear-gradient(135deg, var(--accent), var(--ai)); color:#fff; }
.secret { font-family:ui-monospace, "SF Mono", Menlo, monospace; font-size:15px; padding:8px 12px; background:var(--raised); border:1px dashed var(--line-strong); border-radius:var(--radius-sm); user-select:all; display:inline-block; margin-top:6px; }

/* Loading overlay (busy() in app.js) */
.busy { position:fixed; inset:0; z-index:1000; display:flex; align-items:center; justify-content:center; background:rgba(0,0,0,.28); backdrop-filter:blur(1px); }
.busy .box { background:var(--card); color:var(--fg); border:1px solid var(--line); border-radius:12px; padding:22px 26px; min-width:280px; max-width:min(440px, calc(100vw - 32px));
  box-shadow:0 10px 30px rgba(0,0,0,.18); display:flex; gap:16px; align-items:center; }
.busy .spin { flex:none; width:34px; height:34px; border-radius:50%; border:4px solid var(--line); border-top-color:var(--accent); animation:busy-spin .8s linear infinite; }
.busy .title { font-weight:700; }
.busy .step { color:var(--muted); font-size:14px; margin-top:3px; min-height:1.3em; transition:opacity .25s; }
.busy .time { color:var(--muted); font-size:12px; margin-top:6px; font-variant-numeric:tabular-nums; }
.busy .notes .note { margin-top:10px; padding:7px 10px; border-radius:8px; font-size:13px; border:1px solid var(--line); background:var(--bg); }
.busy .bar { height:3px; border-radius:2px; background:var(--line); overflow:hidden; margin-top:10px; }
.busy .bar i { display:block; height:100%; width:35%; background:var(--accent); border-radius:2px; animation:busy-slide 1.4s ease-in-out infinite; }
@keyframes busy-spin { to { transform:rotate(360deg); } }
@keyframes busy-slide { 0% { transform:translateX(-100%); } 100% { transform:translateX(300%); } }
@media (prefers-reduced-motion: reduce) { .busy .spin { animation-duration:2.4s; } .busy .bar i { animation-duration:3s; } }

.engine .scan-reading { margin-top: 4px; }
