/* Flowbite - one hand-written stylesheet, design tokens in :root. */
:root {
  --bg: #f4f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --muted: #5b6678;
  --line: #e2e8f0;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --on-primary: #ffffff;
  --success: #15803d;
  --success-soft: #f0fdf4;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --r-card: 12px;
  --r-input: 10px;
  --shadow-1: 0 1px 2px rgb(15 23 42 / .06), 0 1px 3px rgb(15 23 42 / .06);
  --shadow-2: 0 12px 32px rgb(15 23 42 / .16);
  --focus: 0 0 0 3px rgb(79 70 229 / .4);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --nav-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1020; --surface: #131a2e; --surface-2: #19223a; --text: #e8ecf8; --muted: #9aa6bf; --line: #27324f;
    --primary: #6366f1; --primary-hover: #7c7ff5; --primary-soft: #1d2447;
    --success: #4ade80; --success-soft: #12261b; --warn: #fbbf24; --warn-soft: #2a2110; --danger: #f87171; --danger-soft: #2c1517;
    --shadow-1: 0 1px 2px rgb(0 0 0 / .4); --shadow-2: 0 12px 32px rgb(0 0 0 / .5);
  }
}
:root[data-theme="dark"] {
  --bg: #0b1020; --surface: #131a2e; --surface-2: #19223a; --text: #e8ecf8; --muted: #9aa6bf; --line: #27324f;
  --primary: #6366f1; --primary-hover: #7c7ff5; --primary-soft: #1d2447;
  --success: #4ade80; --success-soft: #12261b; --warn: #fbbf24; --warn-soft: #2a2110; --danger: #f87171; --danger-soft: #2c1517;
  --shadow-1: 0 1px 2px rgb(0 0 0 / .4); --shadow-2: 0 12px 32px rgb(0 0 0 / .5);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 400 16px/1.5 var(--font); color: var(--text); background: var(--bg); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.0625rem; font-weight: 650; }
p { margin: 0 0 .75rem; }
a { color: var(--primary); }
img, svg { max-width: 100%; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 8px; }
[hidden] { display: none !important; }
.tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.skip { position: absolute; left: 8px; top: -48px; z-index: 100; background: var(--primary); color: var(--on-primary); padding: 8px 14px; border-radius: 8px; }
.skip:focus { top: 8px; }

.ic { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ic-lg { width: 32px; height: 32px; }
.ic-state { width: 22px; height: 22px; flex: none; }

/* ---------- App shell ---------- */
.app { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
.sidebar { display: none; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 56px; padding: env(safe-area-inset-top, 0) 16px 0; background: var(--surface); border-bottom: 1px solid var(--line);
}
.topbar-store { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-user { display: flex; align-items: center; gap: 8px; }
.topbar-name { display: none; color: var(--muted); font-size: .9rem; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: .9rem; }
.main { padding: 16px 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom, 0px)); }
.container { max-width: 1080px; margin: 0 auto; }

.nav-item {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 8px 12px; border: 0; border-radius: 10px;
  background: none; color: var(--muted); text-decoration: none; cursor: pointer; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.is-active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-item.is-soon { opacity: .6; }

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px)); background: var(--surface); border-top: 1px solid var(--line);
}
.bottomnav .nav-item { flex-direction: column; justify-content: center; gap: 2px; padding: 6px 2px; font-size: .72rem; text-align: center; min-height: 52px; }
.bottomnav .nav-label { display: block; }
/* Billing sits in the centre and carries the primary action */
.bottomnav .nav-item:nth-child(3) { color: var(--on-primary); }
.bottomnav .nav-item:nth-child(3) .ic { width: 46px; height: 46px; padding: 11px; margin-top: -22px; border-radius: 50%; background: var(--primary); box-shadow: var(--shadow-2); stroke: var(--on-primary); }
.bottomnav .nav-item:nth-child(3) .nav-label { color: var(--muted); }
.bottomnav .nav-item:nth-child(3).is-soon { opacity: 1; }

@media (min-width: 640px) {
  .app { grid-template-columns: 72px minmax(0, 1fr); }
  .sidebar { display: flex; flex-direction: column; grid-column: 1; grid-row: 1 / -1; position: sticky; top: 0; height: 100dvh; padding: 12px 8px; background: var(--surface); border-right: 1px solid var(--line); }
  .topbar { grid-column: 2; }
  .main { grid-column: 2; padding: 24px; }
  .bottomnav { display: none; }
  .brand { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 6px 4px 14px; text-decoration: none; color: var(--text); font-weight: 700; }
  .side-nav { display: grid; gap: 4px; align-content: start; flex: 1; }
  .side-foot { margin: 0; }
  .sidebar .nav-item { justify-content: center; padding: 10px; }
  .sidebar .nav-label { display: none; }
  .topbar-name { display: inline; }
}
@media (min-width: 1024px) {
  .app { grid-template-columns: 248px minmax(0, 1fr); }
  .sidebar { padding: 16px 12px; }
  .brand { justify-content: flex-start; padding: 6px 8px 16px; }
  .sidebar .nav-item { justify-content: flex-start; padding: 8px 12px; }
  .sidebar .nav-label { display: inline; }
  .main { padding: 32px; }
}

/* ---------- Content ---------- */
.page-head { margin-bottom: 16px; }
.page-head p { margin: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow-1); padding: 16px; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.grid-2 { display: grid; gap: 16px; align-items: start; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 { margin-bottom: 16px; }
@media (min-width: 860px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

.kv { margin: 0 0 16px; display: grid; gap: 0; }
.kv > div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.kv > div:last-child { border-bottom: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-weight: 550; }

.checklist { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 4px; }
.checklist li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.checklist li > span:nth-child(2) { flex: 1; }
.checklist .is-done .ic-state { color: #fff; background: var(--success); border-radius: 50%; padding: 4px; stroke-width: 2.4; }
.ic-empty { border: 2px solid var(--line); border-radius: 50%; }

.list-card { padding: 4px 16px; }
.list-row { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 52px; padding: 8px 0; border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--text); text-decoration: none; text-align: left; cursor: pointer; }
.list-row:last-child { border-bottom: 0; }
.list-row.is-soon { opacity: .6; }

.tabs { display: flex; gap: 4px; overflow-x: auto; margin: 0 -16px 16px; padding: 0 16px 2px; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; min-height: 44px; padding: 10px 14px; border: 0; border-bottom: 3px solid transparent; background: none; color: var(--muted); text-decoration: none; cursor: pointer; white-space: nowrap; }
.tab.is-active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab.is-soon { opacity: .6; }

.badge { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge-neutral { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }

/* ---------- Buttons and forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 20px;
  border: 1px solid transparent; border-radius: 999px; font-weight: 600; text-decoration: none; cursor: pointer; line-height: 1.2;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: none; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-text { color: var(--danger); }
.btn-block { display: flex; width: 100%; }
.btn[disabled], .btn.is-disabled, .btn[aria-busy="true"] { opacity: .55; cursor: not-allowed; pointer-events: none; }
.btn.is-soon { opacity: .6; }
.btn + .btn { margin-left: 0; }
.actions { display: flex; gap: 12px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }
.btn .ic { width: 20px; height: 20px; }

.field { display: block; margin-bottom: 16px; }
.label { display: block; margin-bottom: 6px; font-weight: 600; font-size: .92rem; }
.input {
  display: block; width: 100%; min-height: 46px; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--r-input);
  background: var(--surface); color: var(--text);
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input-wrap { position: relative; display: block; }
.input-wrap .input { padding-right: 48px; }
.icon-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; display: grid; place-items: center; border: 0; background: none; color: var(--muted); border-radius: 8px; cursor: pointer; }
.hint { display: block; margin-top: 4px; font-size: .85rem; color: var(--muted); }
.field-error { display: block; margin-top: 4px; font-size: .88rem; color: var(--danger); }
.check { display: flex; align-items: center; gap: 10px; margin: 12px 0 16px; min-height: 44px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--primary); }

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; font-size: .95rem; }
.alert .ic { margin-top: 1px; width: 20px; height: 20px; }
.alert-danger { background: var(--danger-soft); color: var(--danger); }
.alert-warn { background: var(--warn-soft); color: var(--warn); }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-info { background: var(--primary-soft); color: var(--primary); }
.alert ul { margin: 4px 0 0; padding-left: 18px; }

/* ---------- Upload and progress ---------- */
.drop {
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; padding: 22px 16px; margin: 12px 0;
  border: 2px dashed var(--line); border-radius: var(--r-card); background: var(--surface-2); cursor: pointer; color: var(--muted);
}
.drop:hover, .drop.is-over { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.drop:focus-within { box-shadow: var(--focus); }
.drop-title { font-weight: 600; color: var(--text); word-break: break-all; }
.meter { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; margin: 12px 0; }
.meter > span { display: block; height: 100%; width: var(--p, 0%); background: var(--primary); border-radius: 999px; transition: width .3s ease; }

.steps { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 14px; }
.step { display: grid; grid-template-columns: 28px 1fr; gap: 12px; align-items: center; color: var(--muted); }
.step-dot { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; background: var(--surface); }
.step-dot .ic { width: 16px; height: 16px; stroke-width: 3; }
.step.is-active { color: var(--text); font-weight: 600; }
.step.is-active .step-dot { border-color: var(--primary); }
.step.is-active .step-dot::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); animation: pulse 1.1s ease-in-out infinite; }
.step.is-done { color: var(--text); }
.step.is-done .step-dot { background: var(--success); border-color: var(--success); color: #fff; }
.step.is-failed { color: var(--danger); font-weight: 600; }
.step.is-failed .step-dot { background: var(--danger); border-color: var(--danger); color: #fff; }
@keyframes pulse { 0%, 100% { transform: scale(.7); opacity: .6; } 50% { transform: scale(1.1); opacity: 1; } }
@media (min-width: 640px) { .steps { grid-template-columns: repeat(4, 1fr); } .step { grid-template-columns: 1fr; justify-items: start; gap: 8px; } }

.changelog { margin: 8px 0 16px; padding-left: 20px; }
.changelog li { margin-bottom: 4px; }
.log { margin: 12px 0 0; padding: 12px; max-height: 180px; overflow: auto; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; font: .82rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; }

/* ---------- Table that turns into cards on mobile ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-weight: 600; font-size: .85rem; color: var(--muted); padding: 8px 12px; border-bottom: 1px solid var(--line); }
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; font-variant-numeric: tabular-nums; }
@media (max-width: 639px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: 10px 0; border-bottom: 1px solid var(--line); }
  .table td { display: flex; justify-content: space-between; gap: 16px; padding: 4px 0; border: 0; text-align: right; }
  .table td::before { content: attr(data-label); color: var(--muted); text-align: left; }
}
.subhead { margin: 20px 0 6px; font-size: .95rem; color: var(--muted); font-weight: 600; }

/* ---------- Toast and dialog ---------- */
.toasts { position: fixed; left: 12px; right: 12px; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom, 0px)); z-index: 60; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
@media (min-width: 640px) { .toasts { bottom: 24px; } }
.toast { pointer-events: auto; max-width: 420px; padding: 12px 16px; border-radius: 12px; background: #0f172a; color: #fff; box-shadow: var(--shadow-2); font-size: .95rem; animation: toast-in .18s ease-out; }
.toast.is-error { background: var(--danger); }
.toast.is-success { background: var(--success); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

dialog.dialog { width: min(92vw, 420px); padding: 20px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-2); }
dialog.dialog::backdrop { background: rgb(15 23 42 / .5); }
dialog.dialog h2 { font-size: 1.15rem; }
dialog.dialog .actions { margin-top: 20px; }

/* ---------- Pages without the app shell ---------- */
.bare-main { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card, .notice { width: 100%; max-width: 420px; margin: 0; padding: 24px; }
.auth-logo { display: block; margin-bottom: 16px; border-radius: 12px; }
.notice { text-align: center; }
.notice-code { margin: 0; font-size: 3rem; font-weight: 800; color: var(--primary); line-height: 1; }
.notice h1 { margin-top: 8px; }

.wizard { width: 100%; max-width: 560px; }
.wizard-head { text-align: center; margin-bottom: 16px; }
.wizard-head img { border-radius: 12px; margin-bottom: 8px; }
.wizard-steps { list-style: none; margin: 0 0 16px; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; counter-reset: s; }
.wizard-steps li { counter-increment: s; font-size: .78rem; color: var(--muted); text-align: center; padding-top: 10px; border-top: 3px solid var(--line); }
.wizard-steps li.is-active { color: var(--primary); font-weight: 600; border-top-color: var(--primary); }
.wizard-steps li.is-done { color: var(--text); border-top-color: var(--success); }
.wizard-panel { margin-bottom: 0; }
.req-list { list-style: none; margin: 12px 0 0; padding: 0; }
.req-list li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.req-list li:last-child { border-bottom: 0; }
.req-list .ic { margin-top: 1px; width: 20px; height: 20px; stroke-width: 2.6; }
.req-ok .ic { color: var(--success); }
.req-bad .ic { color: var(--danger); }
.req-warn .ic { color: var(--warn); }
.req-list small { display: block; color: var(--muted); font-size: .85rem; }
.recovery { margin: 12px 0; padding: 16px; text-align: center; font: 700 1.35rem/1.3 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .08em; background: var(--surface-2); border: 1px dashed var(--line); border-radius: 12px; user-select: all; word-break: break-all; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
