:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef1f7;
  --text: #0f172a;
  --muted: #5b6478;
  --border: #e1e6ef;
  --accent: #4f46e5;
  --accent-strong: #4338ca;
  --accent-2: #06b6d4;
  --accent-soft: #eef0ff;
  --on-accent: #ffffff;
  --gradient: linear-gradient(135deg, #4f46e5 0%, #2563eb 55%, #06b6d4 100%);
  --ok: #059669;
  --ok-soft: #e6f7f0;
  --info: #2563eb;
  --info-soft: #e8f0fe;
  --warn: #b45309;
  --warn-soft: #fef5e4;
  --error: #dc2626;
  --error-soft: #fdecec;
  --store: #94a3c4;
  --refresh: #4f46e5;
  --live: #10b981;
  --add: #e6f7f0;
  --del: #fdecec;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px rgba(15, 23, 42, .06);
  --shadow-lift: 0 2px 4px rgba(15, 23, 42, .05), 0 14px 32px rgba(79, 70, 229, .12);
  --glow: radial-gradient(1200px 420px at 50% -120px, rgba(79, 70, 229, .10), transparent 70%);
  --radius: 14px;
  --font: "Segoe UI Variable", "Segoe UI", ui-sans-serif, system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "Cascadia Code", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0f1e;
    --surface: #111830;
    --surface-2: #19223d;
    --text: #e6eaf5;
    --muted: #97a1bb;
    --border: #252f4d;
    --accent: #818cf8;
    --accent-strong: #a5b4fc;
    --accent-2: #22d3ee;
    --accent-soft: #1d2250;
    --on-accent: #0a0f1e;
    --gradient: linear-gradient(135deg, #818cf8 0%, #60a5fa 55%, #22d3ee 100%);
    --ok: #34d399;
    --ok-soft: #0f2e27;
    --info: #60a5fa;
    --info-soft: #132546;
    --warn: #fbbf24;
    --warn-soft: #33270f;
    --error: #f87171;
    --error-soft: #3a1720;
    --store: #475779;
    --refresh: #818cf8;
    --live: #34d399;
    --add: #0f2e27;
    --del: #3a1720;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    --shadow-lift: 0 2px 4px rgba(0, 0, 0, .3), 0 14px 32px rgba(129, 140, 248, .18);
    --glow: radial-gradient(1200px 460px at 50% -140px, rgba(129, 140, 248, .18), transparent 70%);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--glow) no-repeat, var(--bg);
  min-height: 100vh;
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-strong); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 2rem; letter-spacing: -.025em; font-weight: 750; }
h2 { font-size: 1.5rem; letter-spacing: -.02em; font-weight: 700; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; }
code, pre { font-family: var(--mono); font-size: 13px; }

/* Shell */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .7rem 1.5rem; border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 78%, transparent); backdrop-filter: saturate(1.6) blur(14px);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; letter-spacing: -.01em; }
.brand-sub { color: var(--muted); font-weight: 400; font-size: .9rem; }
.logo { display: inline-flex; align-items: flex-end; gap: 3px; height: 26px; padding: 5px 6px; background: var(--gradient); border-radius: 8px; box-shadow: 0 4px 12px rgba(79, 70, 229, .35); }
.logo i { display: block; width: 4px; background: #fff; border-radius: 2px; }
.logo i:nth-child(1) { height: 7px; } .logo i:nth-child(2) { height: 14px; } .logo i:nth-child(3) { height: 10px; }
.topbar-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; }
.who { color: var(--muted); font-size: .85rem; }

.layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 2rem; max-width: 1180px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }
.steps ol { list-style: none; margin: 0; padding: 0; position: sticky; top: 5rem; display: grid; gap: .25rem; }
.step {
  width: 100%; display: flex; align-items: center; gap: .7rem; padding: .55rem .7rem; border: 0; border-radius: 10px;
  background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.step:hover:not(:disabled) { background: var(--surface-2); }
.step.current { background: var(--surface); box-shadow: var(--shadow); font-weight: 650; outline: 1px solid var(--border); }
.step.locked { color: var(--muted); cursor: default; }
.step-num {
  flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; font-weight: 600;
  border: 1.5px solid var(--border); background: var(--surface);
}
.step.current .step-num { border-color: transparent; background: var(--gradient); color: #fff; box-shadow: 0 3px 10px rgba(79, 70, 229, .35); }
.step.done .step-num { border-color: var(--ok); background: var(--ok); color: #fff; }

.panel { min-width: 0; }
.panel > * + * { margin-top: 1rem; }
.lead { color: var(--muted); font-size: 1.02rem; max-width: 70ch; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* Cards & layout */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.35rem 1.5rem; box-shadow: var(--shadow); }
.card-quiet { background: var(--surface-2); box-shadow: none; }
.card-ok { border-color: color-mix(in srgb, var(--ok) 40%, var(--border)); }
.card-accent {
  border: 1px solid transparent;
  background: linear-gradient(var(--surface), var(--surface)) padding-box, var(--gradient) border-box;
  box-shadow: var(--shadow-lift);
}
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.checklist { margin: 0; padding-left: 1.2rem; display: grid; gap: .35rem; }
.nav { display: flex; justify-content: space-between; padding-top: 1rem; border-top: 1px solid var(--border); margin-top: 2rem !important; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 38px; padding: .45rem 1rem;
  border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 550; cursor: pointer; text-decoration: none;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn { transition: background .15s, box-shadow .15s, transform .15s, border-color .15s; }
.btn-primary { background: var(--gradient); border-color: transparent; color: #fff; box-shadow: 0 4px 14px rgba(79, 70, 229, .3); }
.btn-primary:hover:not(:disabled) { background: var(--gradient); filter: brightness(1.07); box-shadow: 0 6px 20px rgba(79, 70, 229, .4); transform: translateY(-1px); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-small { min-height: 32px; padding: .3rem .75rem; font-size: .88rem; }
.btn-large { min-height: 46px; padding: .6rem 1.4rem; font-size: 1.02rem; margin-top: .5rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Pills & alerts */
.pill { display: inline-block; padding: .08rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--surface-2); color: var(--muted); vertical-align: middle; margin-left: .4rem; }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-info { background: var(--info-soft); color: var(--info); }
.pill-error { background: var(--error-soft); color: var(--error); }
.pill-demo { background: var(--accent-soft); color: var(--accent-strong); margin: 0; }
.alert { border-radius: var(--radius); padding: .9rem 1.1rem; border: 1px solid; }
.alert p:last-child { margin-bottom: 0; }
.alert-error { background: var(--error-soft); border-color: color-mix(in srgb, var(--error) 35%, transparent); }
.alert-error strong { color: var(--error); }
.alert-ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.alert-info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.alert-info strong { color: var(--info); }
.alert-warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.tip { font-size: .9rem; }

/* Forms */
.field { display: grid; gap: .35rem; margin-bottom: 1rem; }
.field > span:first-child { font-weight: 600; font-size: .9rem; }
.field small { color: var(--muted); }
.field.nested { margin: .6rem 0 0 1.9rem; max-width: 420px; }
input[type="text"], input[type="search"], input[type="number"], input[type="datetime-local"], select {
  width: 100%; min-height: 40px; padding: .45rem .7rem; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit;
}
input:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 0; border-color: var(--accent); }
.inline { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.inline .num { width: 96px; }
.inline select { width: auto; min-width: 130px; }
.field-error { color: var(--error); font-weight: 550; margin: .25rem 0 0; }
.check { margin: .9rem 0; }
.check label, label.check, .ack { display: flex; gap: .75rem; align-items: flex-start; cursor: pointer; }
.check input, .ack input { width: 18px; height: 18px; margin-top: .2rem; flex: none; accent-color: var(--accent); }
.ack { margin: 1rem 0 .25rem; }
.copy-row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.copy-row code { background: var(--surface-2); padding: .4rem .6rem; border-radius: 7px; overflow-wrap: anywhere; }
.settings { border-color: var(--accent); }

/* Choice cards */
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .75rem; }
.choice {
  display: grid; gap: .2rem; text-align: left; padding: .9rem 1rem; border-radius: var(--radius);
  border: 1.5px solid var(--border); background: var(--surface); color: var(--text); font: inherit; cursor: pointer;
}
.choice { transition: border-color .15s, box-shadow .15s, transform .15s; }
.choice:hover:not(:disabled) { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); box-shadow: var(--shadow); transform: translateY(-1px); }
.choice.selected { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.choice.disabled { opacity: .6; cursor: not-allowed; }
.choice-title { font-weight: 620; }
.choice-title .pill { margin-left: .5rem; }
.choice-sub { font-size: .85rem; color: var(--muted); }

/* Timeline */
.timeline { margin-top: .5rem; padding-top: 1rem; border-top: 1px dashed var(--border); }
.bar { display: flex; height: 18px; border-radius: 999px; overflow: hidden; background: var(--surface-2); }
.seg-store { background: var(--store); }
.seg-refresh { background: var(--gradient); }
.seg-live { width: 14px; background: var(--live); }
.timeline-labels { display: flex; justify-content: space-between; gap: 1rem; font-size: .8rem; color: var(--muted); margin-top: .3rem; }
.legend { list-style: none; padding: 0; margin: .8rem 0 0; display: grid; gap: .3rem; font-size: .9rem; }
.legend li { display: flex; gap: .55rem; align-items: baseline; }
.sw { flex: none; display: inline-block; width: 11px; height: 11px; border-radius: 3px; transform: translateY(1px); }
.sw-store { background: var(--store); } .sw-refresh { background: var(--refresh); } .sw-live { background: var(--live); }
.sw-none { background: transparent; border: 1.5px dashed var(--muted); }

/* Review */
.summary { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .4rem 1.25rem; margin: 0; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; font-weight: 550; overflow-wrap: anywhere; }
.code { background: var(--surface-2); padding: .9rem 1rem; border-radius: 9px; overflow-x: auto; margin: .75rem 0 0; white-space: pre; }
details > summary { cursor: pointer; font-weight: 600; }
.diff { border: 1px solid var(--border); border-radius: 9px; margin-top: .75rem; overflow: hidden; }
.diff > summary { padding: .55rem .8rem; background: var(--surface-2); font-family: var(--mono); font-size: 13px; }
.diff-body { font-family: var(--mono); font-size: 12.5px; overflow-x: auto; padding: .35rem 0; }
.diff-body > div { white-space: pre; padding: 0 .8rem; min-width: max-content; }
.d-sign { display: inline-block; width: 1.4em; color: var(--muted); user-select: none; }
.d-add { background: var(--add); }
.d-del { background: var(--del); }
.d-skip { color: var(--muted); font-style: italic; padding: .2rem .8rem !important; }

/* Done */
.success { display: flex; gap: 1rem; align-items: center; }
.success-icon { flex: none; width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, #10b981, #06b6d4); color: #fff; font-size: 1.6rem; font-weight: 700; box-shadow: 0 6px 18px rgba(16, 185, 129, .35); }

/* Busy overlay */
.busy { position: fixed; inset: 0; background: color-mix(in srgb, var(--bg) 70%, transparent); display: grid; place-items: center; z-index: 20; backdrop-filter: blur(2px); padding: 16px; }
.busy-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem 1.75rem; box-shadow: var(--shadow); display: flex; gap: 1rem; align-items: center; max-width: 440px; }
.busy-card p { margin: 0; }
.spinner { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }

/* Small screens */
@media (max-width: 820px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 1rem; padding: 1rem 16px 3rem; }
  .steps ol { position: static; display: flex; overflow-x: auto; gap: .25rem; padding-bottom: .25rem; }
  .step { white-space: nowrap; width: auto; }
  .step:not(.current) span:last-child { display: none; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .topbar { padding: .6rem 16px; }
  .brand-sub, .who { display: none; }
  h1 { font-size: 1.45rem; }
}

/* Restore-from-backup file picker and first-load refresh settings */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.file-btn { cursor: pointer; }
.file-btn:focus-within { outline: 2px solid currentColor; outline-offset: 2px; }
.refresh-options { margin: .6rem 0 1rem 1.9rem; max-width: 560px; }
.refresh-options .field { margin-top: .6rem; }

/* View tabs */
.tabs { display: flex; gap: .25rem; background: var(--surface-2); padding: .2rem; border-radius: 10px; }
.tab { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: .9rem; padding: .35rem .8rem; border-radius: 8px; cursor: pointer; }
.tab:hover:not(:disabled) { color: var(--text); }
.tab.active { background: var(--surface); color: var(--accent-strong); font-weight: 650; box-shadow: var(--shadow); }
.layout-wide { grid-template-columns: minmax(0, 1fr); max-width: 1000px; }

/* Health check */
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; display: grid; gap: .2rem; box-shadow: var(--shadow); }
.tile strong { font-size: 1.9rem; line-height: 1.1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.tile span { color: var(--muted); font-size: .85rem; }
.tile-problem strong { color: var(--error); }
.tile-warning strong { color: var(--warn); }
.tile-opportunity strong { color: var(--info); }
.health-actions { align-items: center; }
.inline-check { display: flex; align-items: center; gap: .4rem; margin: 0; }
.health-card { border-left-width: 4px; }
.health-problem { border-left-color: var(--error); }
.health-warning { border-left-color: var(--warn); }
.health-opportunity { border-left-color: var(--info); }
.health-ok { border-left-color: var(--ok); }
.health-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.health-head h3 { margin: 0; }
.health-table { border-top: 1px solid var(--border); padding-top: .6rem; margin-top: .6rem; }
.health-table-name { font-weight: 600; margin-bottom: .35rem; }
.finding { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr) auto; gap: .75rem; align-items: start; margin-top: .4rem; }
.finding .pill { margin-left: 0; justify-self: start; }
.finding-text p { margin: .15rem 0 0; }
@media (max-width: 820px) {
  .topbar { flex-wrap: wrap; }
  .finding { grid-template-columns: minmax(0, 1fr); gap: .3rem; }
}
.finding-actions { gap: .4rem; justify-content: flex-end; }
.steps-list { margin: .9rem 0 .4rem; padding-left: 1.3rem; display: grid; gap: .45rem; }

/* Headline accent */
.panel > h1:first-child, .panel > .alert + h1, .panel > section + h1 {
  background: linear-gradient(120deg, var(--text) 30%, var(--accent) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
@media (max-width: 1000px) { .brand-sub { display: none; } }

/* Load counter and savings */
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0 1rem; }
.savings .inline .num { width: 120px; }
.savings-month { background: var(--accent-soft); border-radius: 10px; padding: .7rem .9rem; margin: .9rem 0 .5rem; }
.savings-headline { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .1rem 1rem; align-items: baseline; margin: .6rem 0 1rem; padding: 1rem 1.2rem; border-radius: 12px; background: var(--accent-soft); }
.savings-headline strong { grid-row: span 2; font-size: 2.6rem; line-height: 1; letter-spacing: -.03em; background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.savings-headline span { font-weight: 600; }
.savings-headline small { color: var(--muted); }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
.compare { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.compare th, .compare td { padding: .6rem .85rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.compare tbody tr:last-child th, .compare tbody tr:last-child td { border-bottom: 0; }
.compare thead th { background: var(--surface-2); font-size: .85rem; }
.compare thead small { display: block; font-weight: 400; color: var(--muted); font-size: .75rem; }
.compare tbody th { font-weight: 550; color: var(--muted); }
.compare td.col-inc { font-weight: 700; color: var(--accent-strong); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.compare thead th.col-inc { color: var(--accent-strong); background: color-mix(in srgb, var(--accent) 12%, var(--surface-2)); }
.compare .diff-cell { color: var(--ok); font-weight: 600; }
.pricing { margin: .4rem 0 .2rem; border-top: 1px dashed var(--border); padding-top: .8rem; }
.pricing > summary { color: var(--accent-strong); margin-bottom: .6rem; }
.savings-headline .yearly { font-style: normal; color: var(--ok); }
.price-source { border-left: 3px solid var(--accent); padding: .2rem 0 .2rem .8rem; margin: .2rem 0 .8rem; }
.price-source p { margin: .2rem 0; }
