/* Amazon Access Board — application shell + admin.
   Keeps the SwissHelvetia identity (DM Sans / Manrope, --ink / --green) but is
   its own serious operations dashboard, not the image-converter UI. */

:root {
  font-family: "DM Sans", sans-serif;
  color: #1e2321;
  background: #f6f7f4;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  --ink: #1e2321;
  --muted: #6f776f;
  --soft: #9aa19a;
  --green: #2f5a4a;
  --green-soft: #eef4ef;
  --line: #e4e7e0;
  --bg: #f6f7f4;
  --card: #ffffff;
  --red: #b4493f;
  --red-soft: #fbeeed;
  --amber: #8a6d1f;
  --amber-soft: #fbf4e4;
  --blue: #2f5b8a;
  --blue-soft: #eef2f8;
  --sidebar: #1c2a24;
  --sidebar-ink: #dfe7e1;
  --sidebar-muted: #8ba394;
}

* { box-sizing: border-box; }

/* CRITICAL: the [hidden] attribute must always win. Without this, class rules
   like `.shell { display: grid }` and `.modal-backdrop { display: grid }`
   override `[hidden]` and leak the dashboard / modal overlays to signed-out
   visitors. */
[hidden] { display: none !important; }

html, body { height: 100%; }
body { margin: 0; min-width: 320px; background: var(--bg); }
button, input, select, textarea { font: inherit; }
a { color: var(--green); }

h1, h2, h3, h4 { font-family: "Manrope", sans-serif; letter-spacing: -.02em; margin: 0; }

/* ── Auth gate (signed out) ─────────────────────────────────────────── */

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 40px 20px;
  background:
    radial-gradient(1100px 500px at 50% -10%, #e8efe9 0%, rgba(246,247,244,0) 60%),
    var(--bg);
}
.gate-inner { max-width: 540px; text-align: center; }
.gate-logo {
  width: 46px; height: 46px; margin: 0 auto 22px;
  display: grid; place-items: center; border-radius: 13px;
  background: var(--green); color: #fff;
  font: 800 22px/1 "Manrope", sans-serif;
}
.gate h1 { font-size: clamp(30px, 4vw, 42px); line-height: 1.1; font-weight: 700; }
.gate p.lead { margin: 14px 0 0; color: var(--muted); font-size: 17px; line-height: 1.65; }
.gate .fineprint { margin-top: 20px; color: var(--soft); font-size: 13px; line-height: 1.6; }

/* ── Boot splash ────────────────────────────────────────────────────── */

.boot {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center;
  background: var(--bg);
}
.boot span { display: flex; align-items: center; gap: 10px; color: var(--soft); font-size: 14px; }
.boot .boot-mark {
  width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center;
  background: var(--green); color: #fff; font: 800 15px/1 "Manrope", sans-serif;
}

/* ── Authentication landing ─────────────────────────────────────────── */

.landing {
  min-height: 100vh;
  display: grid; place-items: center; padding: 40px 20px;
  background:
    radial-gradient(1100px 520px at 50% -12%, #e7efe9 0%, rgba(246,247,244,0) 62%),
    var(--bg);
}
.landing-card {
  width: min(520px, 100%);
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  padding: 40px 36px;
  box-shadow: 0 1px 2px rgb(18 53 42 / .04), 0 30px 70px -46px rgb(18 53 42 / .45);
  text-align: center;
}
.landing-brand {
  display: inline-flex; align-items: center; gap: 10px; margin-bottom: 22px;
  font: 700 13px/1 "Manrope", sans-serif; letter-spacing: .12em; text-transform: uppercase; color: var(--green);
}
.landing-brand .mark {
  width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center;
  background: var(--green); color: #fff; font: 800 14px/1 "Manrope", sans-serif; letter-spacing: 0;
}
.landing h1 { font-size: clamp(26px, 4vw, 34px); line-height: 1.15; font-weight: 700; }
.landing .lead { margin: 14px 0 0; color: var(--muted); font-size: 15.5px; line-height: 1.65; }
.landing-cta { margin-top: 26px; width: 100%; height: 46px; font-size: 15px; }
.landing .fineprint { margin: 16px 0 0; color: var(--soft); font-size: 13px; line-height: 1.7; }
.landing-note {
  margin-top: 26px; padding: 16px; text-align: left;
  background: var(--green-soft); border: 1px solid #d6e5da; border-radius: 12px;
}
.landing-note strong { display: block; font-size: 13px; margin-bottom: 5px; }
.landing-note p { margin: 0; color: #45604f; font-size: 13px; line-height: 1.6; }

/* ── Store picker ───────────────────────────────────────────────────── */

.store-picker { display: flex; flex-direction: column; gap: 2px; }
.store-picker .label { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--soft); }
.store-picker select { height: 34px; max-width: 260px; padding: 0 9px; border: 1px solid var(--line); border-radius: 8px; background: #fbfcfa; font-size: 13.5px; font-weight: 600; }

/* ── Shell ──────────────────────────────────────────────────────────── */

.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-ink);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 18px; border-bottom: 1px solid rgba(255,255,255,.08);
  color: #fff; text-decoration: none;
}
.sidebar-brand .mark {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: #3f7561; color: #fff; font: 800 15px/1 "Manrope", sans-serif;
}
.sidebar-brand strong { font-family: "Manrope", sans-serif; font-size: 15px; letter-spacing: -.02em; }
.sidebar-brand span { display: block; font-size: 11px; color: var(--sidebar-muted); letter-spacing: .08em; text-transform: uppercase; }

.nav { padding: 12px 10px; overflow-y: auto; flex: 1; }
.nav-section { margin: 12px 8px 6px; font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--sidebar-muted); }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 12px; margin-bottom: 2px;
  border: 0; border-radius: 8px; background: transparent;
  color: var(--sidebar-ink); font-size: 14px; font-weight: 500; text-align: left;
  cursor: pointer;
}
.nav-item:hover { background: rgba(255,255,255,.06); }
.nav-item.active { background: #2f5748; color: #fff; font-weight: 600; }
.nav-item .ico { width: 16px; text-align: center; opacity: .85; }

.sidebar-footer { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; color: var(--sidebar-muted); }
.sidebar-footer .who { color: var(--sidebar-ink); font-size: 13px; font-weight: 600; word-break: break-all; }
.sidebar-footer button { margin-top: 8px; }

/* ── Main ───────────────────────────────────────────────────────────── */

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px 26px; background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar .period {
  display: flex; flex-direction: column;
}
.topbar .period .label { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--soft); }
.topbar .period .range { font-family: "Manrope", sans-serif; font-size: 17px; font-weight: 700; }
.topbar .spacer { flex: 1; }
.topbar select, .topbar input { height: 34px; padding: 0 9px; border: 1px solid var(--line); border-radius: 8px; background: #fbfcfa; font-size: 13px; }

.content { padding: 24px 26px 60px; }
.view { display: none; }
.view.active { display: block; }

.view-head { margin-bottom: 18px; }
.view-head h1 { font-size: 24px; font-weight: 700; }
.view-head p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }

/* ── Cards & stats ──────────────────────────────────────────────────── */

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.card + .card { margin-top: 16px; }
.card-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.card-head h3 { font-size: 14px; font-weight: 700; }
.card-head .spacer { flex: 1; }
.card-body { padding: 18px; }

.stat-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.stat.accent { border-color: #c6d8cb; background: #f5f9f6; }
.stat.hero { grid-column: span 2; }
.stat .label { font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--soft); font-weight: 700; }
.stat .value { font-family: "Manrope", sans-serif; font-size: 26px; font-weight: 700; margin-top: 6px; }
.stat.hero .value { font-size: 34px; }
.stat .sub { margin-top: 6px; font-size: 12px; color: var(--muted); }
.value.pos { color: #2f6b4f; }
.value.neg { color: var(--red); }

.two-col { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
.kv { margin: 0; }
.kv > div { display: flex; justify-content: space-between; gap: 14px; padding: 7px 0; border-bottom: 1px dashed #edefe9; font-size: 14px; }
.kv > div:last-child { border-bottom: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ── Banners ────────────────────────────────────────────────────────── */

.banner { padding: 13px 16px; border-radius: 10px; font-size: 14px; line-height: 1.55; margin-bottom: 16px; }
.banner ul { margin: 7px 0 0; padding-left: 18px; }
.banner.ok { background: var(--green-soft); border: 1px solid #cfe1d3; color: #2c5741; }
.banner.warn { background: var(--amber-soft); border: 1px solid #eadcb4; color: var(--amber); }
.banner.error { background: var(--red-soft); border: 1px solid #e6c9c6; color: var(--red); }
.banner.info { background: var(--blue-soft); border: 1px solid #cbd8e8; color: var(--blue); }
.banner strong { font-weight: 700; }

/* ── Badges ─────────────────────────────────────────────────────────── */

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.badge.ok { background: #e6f0e9; color: #2f6b4f; }
.badge.warn { background: var(--amber-soft); color: var(--amber); }
.badge.error { background: var(--red-soft); color: var(--red); }
.badge.neutral { background: #eef0ec; color: #5c645c; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.ok { background: #3f8a5f; } .dot.error { background: var(--red); } .dot.warn { background: #c9a227; }

/* ── Buttons ────────────────────────────────────────────────────────── */

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border: 0; border-radius: 8px;
  background: var(--green); color: #fff; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn.ghost { background: #eef0ec; color: #37413a; border: 1px solid var(--line); }
.btn.ghost:hover { background: #e6e9e4; }
.btn.danger { background: var(--red-soft); color: var(--red); border: 1px solid #e6c9c6; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ── Tables ─────────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; background: var(--card); }
table.data th { padding: 9px 12px; text-align: left; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: #626b63; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 9px 12px; font-size: 13.5px; border-bottom: 1px solid #f0f1ec; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.data tbody tr:hover { background: #f8faf7; }
td.pos { color: #2f6b4f; } td.neg { color: var(--red); }
td.empty { text-align: center; color: var(--soft); padding: 22px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar label { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }

/* ── Forms ──────────────────────────────────────────────────────────── */

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
.field input, .field select { height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; background: #fbfcfa; }
.field.inline { flex-direction: row; align-items: center; gap: 8px; }
.form-grid { display: grid; gap: 0 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.settings-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

/* ── Modal ──────────────────────────────────────────────────────────── */

.modal-backdrop { position: fixed; inset: 0; background: rgba(20,26,22,.5); display: grid; place-items: center; padding: 20px; z-index: 100; }
.modal { background: #fff; border-radius: 14px; padding: 24px; width: min(520px, 100%); max-height: 88vh; overflow-y: auto; box-shadow: 0 24px 60px rgb(0 0 0 / 18%); }
.modal h2 { font-size: 19px; margin-bottom: 6px; }
.modal .hint { color: var(--muted); font-size: 13px; margin: 0 0 16px; line-height: 1.5; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }

/* ── Misc ───────────────────────────────────────────────────────────── */

.muted { color: var(--muted); font-size: 13px; line-height: 1.6; }
.mono { font-family: "SF Mono", "Fira Code", monospace; font-size: 12.5px; }
.empty-state { text-align: center; padding: 54px 24px; color: var(--muted); }
.empty-state h2 { font-size: 20px; margin-bottom: 8px; color: var(--ink); }
.empty-state p { max-width: 460px; margin: 0 auto 18px; line-height: 1.65; }
.loading { color: var(--soft); font-size: 14px; padding: 20px 0; }

/* ── Admin ──────────────────────────────────────────────────────────── */

.admin-shell { min-height: 100vh; }
.admin-topbar { display: flex; align-items: center; gap: 14px; padding: 14px 26px; background: var(--card); border-bottom: 1px solid var(--line); }
.admin-topbar .spacer { flex: 1; }
.admin-body { max-width: 1080px; margin: 0 auto; padding: 24px 22px 60px; }
.config-group { margin-bottom: 16px; }
.config-row { display: grid; grid-template-columns: 220px 1fr 130px; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px dashed #edefe9; }
.config-row:last-child { border-bottom: 0; }
.config-row .name { font-size: 13.5px; font-weight: 600; }
.config-row .name small { display: block; font-weight: 400; color: var(--soft); font-size: 11.5px; }
.config-row input { height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13.5px; font-family: "SF Mono", "Fira Code", monospace; }
.config-row input:disabled { background: #f2f3ef; color: var(--soft); }
.test-list { margin: 0; padding: 0; list-style: none; }
.test-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed #edefe9; font-size: 13.5px; }
.test-list li:last-child { border-bottom: 0; }
.test-list .detail { margin-left: auto; color: var(--muted); font-size: 12.5px; }

/* Amazon Integration — mode choice */
.sub-head { margin: 0 0 8px; font: 700 13px/1.3 "Manrope", sans-serif; letter-spacing: .04em; text-transform: uppercase; color: #626b63; }
.mode-choices { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); margin: 0 0 16px; }
.mode-choice {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px;
  background: #fbfcfa; cursor: pointer;
}
.mode-choice:has(input:checked) { border-color: var(--green); background: var(--green-soft); }
.mode-choice input { margin-top: 3px; flex: none; }
.mode-choice strong { display: block; font-size: 14px; }
.mode-choice small { display: block; margin-top: 3px; color: var(--muted); font-size: 12.5px; line-height: 1.5; }

/* Readiness grid */
.readiness-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-top: 14px; }
.readiness-item { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px; background: #fbfcfa; }
.readiness-item .name { font-size: 13.5px; font-weight: 600; }
.readiness-item .detail { margin-left: auto; font-size: 12px; color: var(--muted); text-align: right; }
.light { width: 11px; height: 11px; border-radius: 50%; flex: none; background: #c9cec9; }
.light.ok { background: #3f8a5f; box-shadow: 0 0 0 3px rgb(63 138 95 / .16); }
.light.no { background: #c05046; box-shadow: 0 0 0 3px rgb(192 80 70 / .16); }
.light.opt { background: #c9a227; }

.state-badge { font-family: "SF Mono", "Fira Code", monospace; font-size: 10.5px; padding: 2px 7px; border-radius: 6px; background: #eef0ec; color: #4d564f; letter-spacing: .02em; }
.state-badge.ok { background: #e6f0e9; color: #2f6b4f; }
.state-badge.no { background: var(--red-soft); color: var(--red); }
.state-badge.warn { background: var(--amber-soft); color: var(--amber); }

/* ── Responsive ─────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .nav { display: flex; gap: 6px; overflow-x: auto; padding: 10px; }
  .nav-section { display: none; }
  .nav-item { width: auto; white-space: nowrap; margin-bottom: 0; }
  .sidebar-footer { display: none; }
  .two-col { grid-template-columns: 1fr; }
  .stat.hero { grid-column: span 1; }
  .config-row { grid-template-columns: 1fr; gap: 6px; }
  .content { padding: 18px 16px 60px; }
  .topbar { padding: 12px 16px; }
}
