/* ==========================================================================
   Founded Apps · styles
   Brand tokens are copied from the Founded Subsidy Compass (src/styles.css).
   No blue or purple anywhere: the lime accent does all the colour work.
   ========================================================================== */

:root {
  --background: oklch(100% 0 0);          /* pure white */
  --foreground: oklch(14% 0 0);           /* near-black text */
  --muted-foreground: oklch(45% 0 0);     /* secondary copy, labels */
  --accent: oklch(88% 0.19 128);          /* lime: CTA, badges */
  --accent-foreground: oklch(20% 0.06 128);
  --muted: oklch(96% 0 0);                /* subtle fills, hovers */
  --border: oklch(90% 0 0);               /* thin neutral borders */
  --primary: var(--foreground);
  --primary-foreground: var(--background);
  --danger: oklch(52% 0.19 27);

  --radius-xl: 12px;                      /* inputs, option rows */
  --radius-2xl: 16px;                     /* cards */
  --content: 768px;                       /* max content column (max-w-3xl) */
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--foreground); outline-offset: 2px; }
[hidden] { display: none !important; }

h1, h2, h3 { letter-spacing: -0.02em; font-weight: 600; margin: 0; text-wrap: balance; }
.micro {
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--muted-foreground);
}
.muted { color: var(--muted-foreground); }

/* ---------- Header (h-14, thin bottom border, logo centred) ---------- */
.site-header {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  background: var(--background);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  height: 56px; max-width: var(--content); margin: 0 auto; padding-inline: 16px;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
}
.header-logo { display: flex; align-items: center; }
.header-logo img { height: 22px; width: auto; }
.header-side--end { justify-self: end; }
.back-link {
  background: none; border: 0; padding: 6px 0; cursor: pointer;
  font-size: 14px; font-weight: 500; color: var(--muted-foreground);
}
.back-link:hover { color: var(--foreground); }

/* ---------- Page layout ---------- */
.page {
  flex: 1; width: 100%; max-width: var(--content); margin: 0 auto;
  padding: 48px 16px 64px;
}
.hero-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.hero { display: grid; gap: 10px; margin-bottom: 28px; }
.hero h1 { font-size: 36px; line-height: 1.1; }
.hero p { margin: 0; color: var(--muted-foreground); max-width: 52ch; }

.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 16px; font-size: 13px; color: var(--muted-foreground);
  display: flex; justify-content: center; gap: 16px; flex-wrap: wrap;
}
.site-footer a { color: var(--muted-foreground); text-decoration: none; font-weight: 500; }
.site-footer a:hover { color: var(--foreground); text-decoration: underline; }

/* ---------- Buttons (pill-shaped) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 18px; border-radius: 999px;
  border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  font-size: 14px; font-weight: 500; text-decoration: none;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn-primary { background: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover { opacity: .88; }
.btn-secondary { background: var(--background); border-color: var(--border); }
.btn-secondary:hover { background: var(--muted); }
.btn-ghost { background: none; color: var(--muted-foreground); }
.btn-ghost:hover { color: var(--foreground); background: var(--muted); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { height: 32px; padding: 0 14px; font-size: 13px; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--background); cursor: pointer; display: inline-grid; place-items: center;
  font-size: 13px; color: var(--muted-foreground);
}
.icon-btn:hover { background: var(--muted); color: var(--foreground); }
.icon-btn:disabled { opacity: .35; cursor: default; }

/* ---------- Badges & tags (small rounded pills) ---------- */
.pill {
  display: inline-flex; align-items: center; height: 24px; padding: 0 10px;
  border-radius: 999px; border: 1px solid var(--border);
  font-size: 12px; font-weight: 500; color: var(--muted-foreground); background: var(--background);
}
.pill--lime { background: var(--accent); border-color: var(--accent); color: var(--accent-foreground); font-weight: 600; }
.pill--dark { background: var(--foreground); border-color: var(--foreground); color: var(--background); font-weight: 600; }

/* ---------- Search + category chips ---------- */
.toolbar { display: grid; gap: 14px; margin-bottom: 28px; }
.search {
  position: relative;
}
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted-foreground); pointer-events: none; }
.input {
  width: 100%; height: 44px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: var(--radius-xl);
  background: var(--background); outline: none;
}
.search .input { padding-left: 40px; }
.input:focus { border-color: var(--foreground); }
textarea.input { height: auto; min-height: 88px; padding: 10px 14px; resize: vertical; line-height: 1.5; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  height: 34px; padding: 0 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--background);
  font-size: 13px; font-weight: 500; color: var(--muted-foreground);
}
.chip:hover { background: var(--muted); color: var(--foreground); }
.chip[aria-pressed="true"] { border-color: var(--foreground); background: var(--muted); color: var(--foreground); }

/* ---------- Product cards ---------- */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card {
  display: flex; flex-direction: column; gap: 12px; padding: 12px 12px 16px;
  border: 1px solid var(--border); border-radius: var(--radius-2xl);
  background: var(--background); text-decoration: none;
  transition: border-color .15s, background .15s;
}
.card:hover { border-color: var(--foreground); }
.card:hover .card-open { background: var(--accent); color: var(--accent-foreground); }
.card-media {
  position: relative; aspect-ratio: 1 / 1; max-width: 100%;
  border-radius: var(--radius-xl); background: var(--muted);
  display: grid; place-items: center; overflow: hidden;
}
.card-media img { width: 100%; height: 100%; object-fit: cover; }
.card-media img.is-default { width: 58%; height: auto; object-fit: contain; }
.card-media .pill { position: absolute; top: 10px; right: 10px; }
.card-body { display: grid; gap: 4px; padding-inline: 4px; }
.card-title { font-size: 17px; }
.card-desc { margin: 0; font-size: 14px; color: var(--muted-foreground); }
.card-foot {
  margin-top: auto; padding-inline: 4px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
}
.card-open { height: 32px; padding: 0 14px; font-size: 13px; }

.empty {
  border: 1px dashed var(--border); border-radius: var(--radius-2xl);
  padding: 40px 20px; text-align: center; color: var(--muted-foreground);
  display: grid; gap: 12px; justify-items: center;
}

/* Two columns of cards on phones */
@media (max-width: 640px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; } .card-title { font-size: 15px; } .card-desc { font-size: 13px; } }

/* ---------- Notice box (lime tint + 2px lime border) ---------- */
.notice {
  border: 2px solid var(--accent); background: oklch(88% 0.19 128 / 0.2);
  border-radius: var(--radius-xl); padding: 14px 16px; font-size: 14px;
  display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  margin-bottom: 24px;
}
.notice p { margin: 0; flex: 1 1 280px; }

/* ---------- Admin ---------- */
.admin-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.admin-head h1 { font-size: 30px; }
.admin-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.admin-list { display: grid; gap: 8px; list-style: none; margin: 0; padding: 0; }
.row {
  display: grid; grid-template-columns: auto 48px 1fr auto; gap: 12px; align-items: center;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-2xl);
  background: var(--background);
}
.row.is-hidden .row-main, .row.is-hidden .row-icon { opacity: .45; }
.row.sortable-ghost { background: var(--muted); border-style: dashed; }
.row.sortable-chosen { border-color: var(--foreground); }
.handle { cursor: grab; color: var(--muted-foreground); padding: 6px 2px; background: none; border: 0; display: grid; place-items: center; touch-action: none; }
.handle:active { cursor: grabbing; }
.row-icon { width: 48px; height: 48px; border-radius: 10px; background: var(--muted); display: grid; place-items: center; overflow: hidden; }
.row-icon img { width: 100%; height: 100%; object-fit: cover; }
.row-icon img.is-default { width: 80%; height: auto; object-fit: contain; }
.row-main { min-width: 0; display: grid; gap: 2px; }
.row-name { font-weight: 600; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-meta { font-size: 13px; color: var(--muted-foreground); overflow-wrap: anywhere; }
.row-tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.row-confirm { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; justify-content: flex-end; flex-wrap: wrap; font-size: 14px; padding-top: 6px; border-top: 1px solid var(--border); }

/* Visibility switch */
.switch {
  position: relative; width: 40px; height: 24px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--border); transition: background .15s; flex: none;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--background); box-shadow: 0 1px 2px oklch(14% 0 0 / .2); transition: transform .15s;
}
.switch[aria-checked="true"] { background: var(--foreground); }
.switch[aria-checked="true"]::after { transform: translateX(16px); }
.switch-label { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted-foreground); }

@media (max-width: 560px) {
  .row { grid-template-columns: auto 44px 1fr; }
  .row-tools { grid-column: 1 / -1; justify-content: flex-start; padding-top: 4px; }
  .hero h1 { font-size: 30px; }
  .page { padding-top: 32px; }
}

/* ---------- Sheet (add / edit / export panels) ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50; background: oklch(14% 0 0 / .35);
  display: grid; place-items: center; padding: 16px;
}
.sheet {
  width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow: auto;
  background: var(--background); border: 1px solid var(--border); border-radius: var(--radius-2xl);
  padding: 24px; display: grid; gap: 18px;
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sheet-head h2 { font-size: 20px; }
.field { display: grid; gap: 6px; }
.field label, .field .label { font-size: 13px; font-weight: 600; }
.field .hint { font-size: 12px; color: var(--muted-foreground); }
.field .error { font-size: 12px; color: var(--danger); font-weight: 500; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .field-row { grid-template-columns: 1fr; } .sheet { padding: 18px; } }
.prefix-input { display: flex; align-items: center; border: 1px solid var(--border); border-radius: var(--radius-xl); overflow: hidden; }
.prefix-input:focus-within { border-color: var(--foreground); }
.prefix-input span { padding: 0 4px 0 14px; color: var(--muted-foreground); font-size: 14px; white-space: nowrap; }
.prefix-input .input { border: 0; padding-left: 0; }

.logo-field { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.logo-preview { width: 72px; height: 72px; border-radius: var(--radius-xl); background: var(--muted); display: grid; place-items: center; overflow: hidden; border: 1px solid var(--border); }
.logo-preview img { width: 100%; height: 100%; object-fit: cover; }
.logo-preview img.is-default { width: 80%; height: auto; object-fit: contain; }

/* Option rows (badge picker): selected = near-black border + light grey fill */
.options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.option {
  height: 40px; border: 1px solid var(--border); border-radius: var(--radius-xl);
  background: var(--background); cursor: pointer; font-size: 14px; font-weight: 500;
}
.option:hover { background: var(--muted); }
.option[aria-checked="true"] { border-color: var(--foreground); background: var(--muted); }
.options--2 { grid-template-columns: repeat(2, 1fr); }
.option--tall { height: auto; padding: 12px 14px; text-align: left; display: grid; gap: 2px; }
.option--tall strong { font-weight: 600; font-size: 14px; }
.option--tall span { font-size: 13px; color: var(--foreground); overflow-wrap: anywhere; }
.option--tall em { font-style: normal; font-size: 12px; color: var(--muted-foreground); }
@media (max-width: 480px) { .options--2 { grid-template-columns: 1fr; } }

.sheet-foot { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; padding-top: 4px; }
.code {
  width: 100%; min-height: 150px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
  border: 1px solid var(--border); border-radius: var(--radius-xl); padding: 12px; background: var(--muted);
  resize: vertical; white-space: pre; overflow: auto;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  z-index: 60; background: var(--foreground); color: var(--background);
  padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: 500;
  max-width: calc(100vw - 32px); text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
