/* Logged-in app theme — same palette as the marketing page (pages#home). */

:root {
  --loam: #2b1d12;
  --trail: #6b4a2b;
  --moss: #3f6b3a;
  --moss-2: #2f5230;
  --lime: #c6f04a;
  --orange: #ff6a2b;
  --cream: #f6f1e7;
  --cream-2: #ece3d2;
  --ink: #1a120a;
  --muted: #7c6a55;
  --card: #fffdf8;
  --danger: #b23c0e;
  --on-lime: #1a120a; /* text on the lime CTA — same in both themes */
  --input-border: #d8ccb4;
  --nav-bg: rgba(246, 241, 231, 0.9);
  --nav-link: var(--loam);
  --radius: 14px;
}

/*
  Dark mode is a palette swap — every rule below reads these vars.
  `system` (no data-theme, or logged out) follows the OS; the account page
  pins light/dark. Same values twice because a media query and a selector
  can't be OR'd in CSS.
*/
:root[data-theme="dark"] {
  color-scheme: dark;
  --loam: #241c14;
  --trail: #8a6a45;
  --moss: #5f9a53;
  --moss-2: #8ec97a;
  --cream: #161311;
  --cream-2: #241f1a;
  --ink: #f2ece2;
  --muted: #a2917a;
  --card: #1e1a16;
  --danger: #ff8a5c;
  --input-border: #4a3f33;
  --nav-bg: rgba(22, 19, 17, 0.9);
  --nav-link: var(--ink);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --loam: #241c14;
    --trail: #8a6a45;
    --moss: #5f9a53;
    --moss-2: #8ec97a;
    --cream: #161311;
    --cream-2: #241f1a;
    --ink: #f2ece2;
    --muted: #a2917a;
    --card: #1e1a16;
    --danger: #ff8a5c;
    --input-border: #4a3f33;
    --nav-bg: rgba(22, 19, 17, 0.9);
    --nav-link: var(--ink);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  background: var(--cream);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px 22px 48px;
}

h1, h2, h3 { line-height: 1.15; letter-spacing: -0.02em; }
h2 { margin-top: 32px; font-size: 1.25rem; }

a { color: var(--moss-2); font-weight: 600; }
a:hover { color: var(--orange); }

.muted { color: var(--muted); }
.danger { color: var(--danger); font-weight: 700; }

code {
  background: var(--cream-2);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.85em;
  word-break: break-all;
}

/* Nav */
nav.topnav {
  display: flex;
  gap: 18px;
  align-items: center;
  flex-wrap: wrap;
  padding: 12px 22px;
  background: var(--nav-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(107, 74, 43, 0.15);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 900;
  font-size: 1.05rem;
  letter-spacing: -0.03em;
  text-decoration: none;
  color: var(--ink);
}
.brand b { color: var(--moss-2); }

nav.topnav a:not(.brand) { text-decoration: none; color: var(--nav-link); font-weight: 600; font-size: 0.92rem; }
nav.topnav a:not(.brand):hover { color: var(--orange); }
.nav-end { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.nav-end .btn, .nav-end .btn:hover { padding: 8px 16px; font-size: 0.88rem; box-shadow: none; }
.btn-secondary, .btn-secondary:hover {
  background: none;
  color: var(--nav-link);
  border: 1px solid var(--input-border);
}
.btn-secondary:hover { color: var(--orange); border-color: var(--orange); }

/* Buttons (covers button_to and form submits) */
button, input[type="submit"] {
  font: inherit;
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--cream);
  background: var(--ink);
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
}
button:hover, input[type="submit"]:hover { background: var(--moss-2); }
form.button_to { display: inline; }

/* Forms */
input:not([type="submit"]), textarea, select {
  font: inherit;
  padding: 8px 12px;
  border: 1px solid var(--input-border);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  max-width: 100%;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--moss); outline-offset: 1px; }
label { font-weight: 600; font-size: 0.9rem; }

fieldset {
  border: 1px solid var(--cream-2);
  border-radius: var(--radius);
  background: var(--card);
  padding: 12px 16px;
  margin: 14px 0;
  max-width: 560px;
}
legend { font-weight: 700; font-size: 0.85rem; padding: 0 6px; }

/* Tables */
table {
  border-collapse: collapse;
  width: 100%;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 10px 28px -22px rgba(26, 18, 10, 0.5);
  font-size: 0.93rem;
  margin: 12px 0;
}
th {
  background: var(--cream-2);
  text-align: left;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
th, td { padding: 10px 12px; border-bottom: 1px solid var(--cream-2); }
tr:last-child td { border-bottom: none; }
tr:first-child th:first-child { border-top-left-radius: var(--radius); }
tr:first-child th:last-child { border-top-right-radius: var(--radius); }
tr:last-child td:first-child { border-bottom-left-radius: var(--radius); }
tr:last-child td:last-child { border-bottom-right-radius: var(--radius); }

details {
  background: var(--card);
  border: 1px solid var(--cream-2);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin: 12px 0;
}
summary { cursor: pointer; font-weight: 600; }

/* Flash */
.flash-notice, .flash-alert {
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 600;
  margin: 14px 0;
}
.flash-notice {
  background: rgba(198, 240, 74, 0.35);
  border: 1px solid rgba(63, 107, 58, 0.35);
  color: var(--moss-2);
}
.flash-alert {
  background: rgba(255, 106, 43, 0.12);
  border: 1px solid rgba(255, 106, 43, 0.4);
  color: var(--danger);
}

/* Link styled as a button (CTAs) */
a.btn {
  display: inline-block; text-decoration: none;
  font-weight: 700; font-size: 0.9rem;
  color: var(--cream); background: var(--ink);
  border-radius: 999px; padding: 11px 22px;
}
a.btn:hover { background: var(--moss-2); color: var(--cream); }
a.btn-primary { background: var(--lime); color: var(--on-lime); box-shadow: 0 10px 24px -10px rgba(168, 217, 47, 0.9); }
a.btn-primary:hover { background: var(--lime); color: var(--on-lime); filter: brightness(1.04); }

/* Hunt header (hunts#show) — title + status left, actions pushed right */
.hunt-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.hunt-head h1 { margin: 0; }
.hunt-head .hunt-actions { margin: 0 0 0 auto; }
.status-chip { font-weight: 600; font-size: 0.7rem; letter-spacing: 0.03em; padding: 3px 10px; border-radius: 999px; }
.status-active { background: rgba(63, 107, 58, 0.14); color: var(--moss-2); }
.status-paused { background: var(--cream-2); color: var(--muted); }

/* Hunt facts grid (hunts#show) */
.hunt-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px 24px; margin: 16px 0 20px; }
.hunt-stats div { margin: 0; }
.hunt-stats dt { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.hunt-stats dd { margin: 2px 0 0; font-size: 0.95rem; font-weight: 500; }

/* Hunt action row (hunts#show) — one solid CTA, ghost secondaries, quiet Delete */
.hunt-actions { display: flex; flex-wrap: wrap; gap: 2px; align-items: center; margin: 0 0 20px; }
.hunt-actions form.button_to { margin: 0; }
.hunt-actions .btn-solid { font-size: 0.85rem; padding: 7px 15px; }
.hunt-actions .btn-icon { display: inline-flex; align-items: center; justify-content: center; padding: 8px 5px; line-height: 0; }
.hunt-actions .btn-icon svg { width: 18px; height: 18px; }
.hunt-actions .btn-quiet.btn-icon,
.hunt-actions .btn-ghost.btn-icon,
.hunt-actions .btn.btn-ghost.btn-icon { padding: 8px 5px; }
.hunt-actions .btn-ghost,
.hunt-actions .btn.btn-ghost {
  background: transparent; color: var(--muted); border: 0;
  font-weight: 600; font-size: 0.85rem; padding: 6px 14px; border-radius: 999px;
  text-decoration: none; display: inline-block;
}
.hunt-actions .btn-ghost:hover, .hunt-actions .btn.btn-ghost:hover { background: none; color: var(--ink); }
.hunt-actions .btn-quiet {
  background: none; color: var(--muted); border: 0; padding: 6px 8px;
  font-weight: 600; font-size: 0.82rem; text-decoration: underline; text-underline-offset: 2px; border-radius: 0;
}
.hunt-actions .btn-quiet:hover { background: none; color: var(--danger); }

/* Dismiss listing (hunts#show listing tables) */
.dismiss-btn button, button.dismiss-btn {
  background: none; border: 0; color: var(--muted, #8a7a68); cursor: pointer;
  font-size: 1rem; line-height: 1; padding: 2px 6px;
}
.dismiss-btn button:hover, button.dismiss-btn:hover { color: var(--ink); }
.reason-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.reason-chip button, button.reason-chip, .reason-chip-other {
  font-size: 0.8rem; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--cream-2); background: var(--card); cursor: pointer;
}
.reason-chip-other { display: flex; gap: 4px; align-items: center; }
.reason-chip-other input[type="text"] { font-size: 0.8rem; padding: 3px 6px; }

/* Hunt row actions menu (hunts#index) — native <details> dropdown, no JS */
.hunt-menu { position: relative; background: none; border: 0; border-radius: 0; padding: 0; margin: 0; width: fit-content; }
.hunt-menu summary { list-style: none; }
.hunt-menu summary::-webkit-details-marker { display: none; }
.hunt-menu-toggle {
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  font-size: 1.25rem; line-height: 1; color: var(--muted, #8a7a68);
}
.hunt-menu-toggle:hover, .hunt-menu[open] .hunt-menu-toggle { color: var(--ink); }
.hunt-menu-items {
  position: absolute; right: 0; z-index: 10;
  display: flex; flex-direction: column; gap: 4px; min-width: 140px;
  margin-top: 4px; padding: 8px;
  background: var(--card); border: 1px solid rgba(107, 74, 43, 0.14);
  border-radius: 10px; box-shadow: 0 18px 40px -24px rgba(26, 18, 10, 0.5);
}
.hunt-menu-items a, .hunt-menu-items form.button_to { margin: 0; }
.hunt-menu-items a, .hunt-menu-items button, .hunt-menu-items input[type="submit"] {
  width: 100%; text-align: left; background: none; color: var(--ink);
  border: none; border-radius: 6px; padding: 8px 10px; font-weight: 600; text-decoration: none;
}
.hunt-menu-items a:hover, .hunt-menu-items button:hover, .hunt-menu-items input[type="submit"]:hover {
  background: var(--cream-2);
}

/* Zero-hunt activation hero (hunts#index empty state) */
.empty-hero {
  max-width: 620px; margin: 28px auto; padding: 42px 32px;
  text-align: center;
  background: var(--card);
  border: 1px solid rgba(107, 74, 43, 0.14);
  border-radius: var(--radius);
  box-shadow: 0 18px 40px -24px rgba(26, 18, 10, 0.5);
}
.empty-hero h2 { margin: 0 0 10px; font-size: 1.6rem; font-weight: 900; }
.empty-hero p { color: var(--muted); margin: 0 auto 18px; max-width: 46ch; }
.empty-hero .btn { margin: 6px 0 20px; padding: 14px 28px; font-size: 1rem; }
.empty-hero p:last-child { margin-bottom: 0; font-size: 0.85rem; }

/* Auth pages (sign in / sign up / forgot + reset password) */
.auth { max-width: 400px; margin: 48px auto; }
.auth-brand {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  font-weight: 900; font-size: 1.3rem; letter-spacing: -0.03em;
  text-decoration: none; color: var(--ink); margin-bottom: 22px;
}
.auth-brand b { color: var(--moss-2); }
.auth-card {
  background: var(--card);
  border: 1px solid rgba(107, 74, 43, 0.14);
  border-radius: var(--radius);
  box-shadow: 0 18px 40px -24px rgba(26, 18, 10, 0.5);
  padding: 30px 28px;
}
.auth-card h1 { font-size: 1.5rem; font-weight: 900; margin: 0 0 6px; }
.auth-lede { color: var(--muted); font-size: 0.95rem; margin: 0 0 22px; }
.auth-card form { display: flex; flex-direction: column; gap: 6px; }
.auth-card label { margin-top: 10px; }
.auth-card input:not([type="submit"]) { width: 100%; padding: 11px 14px; }
.auth-card input[type="submit"], .auth-card button {
  width: 100%; padding: 12px; font-size: 0.95rem; margin-top: 16px;
}
.auth-forgot { align-self: flex-end; font-size: 0.85rem; margin-top: 6px; }
.auth-alt { text-align: center; margin-top: 20px; font-size: 0.9rem; color: var(--muted); }
.field-errors { list-style: none; margin: 0 0 6px; padding: 10px 14px; border-radius: 10px;
  background: rgba(255, 106, 43, 0.1); border: 1px solid rgba(255, 106, 43, 0.4); }
.field-errors li { color: var(--danger); font-weight: 600; font-size: 0.9rem; }

footer.app-footer {
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 22px 28px;
  border-top: 1px solid rgba(107, 74, 43, 0.15);
  font-size: 0.78rem;
  color: var(--muted);
}

svg { vertical-align: middle; }

/* hunt notification prefs */
.notification-mode label { margin-right: 14px; }
.notification-mode .custom-channels { display: none; margin-top: 8px; }
.notification-mode:has(input[value="custom"]:checked) .custom-channels { display: block; }
.silent-badge { color: var(--danger); font-weight: 600; }

/* Sectioned form cards on one spacing scale (hunts#edit / #confirm, accounts#show) */
.form-stack { display: grid; gap: 16px; max-width: 640px; }
/* Only bites on pages whose sections each hold their own form (accounts#show). */
.form-stack form { display: grid; gap: 12px; justify-items: start; }
.form-stack form .field { width: 100%; }
.form-stack .stack > p { margin: 0; }
.form-stack fieldset, .form-stack details { margin: 0; max-width: none; }
.form-stack .stack { display: grid; gap: 14px; }
.form-stack .field { display: grid; gap: 4px; }
.form-stack .field input, .form-stack .field select { width: 100%; }
.form-stack .inline { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; }
.form-stack .inline input { width: 100px; }
.form-stack .hint { font-size: 0.82rem; margin: 0 0 2px; }
.form-stack input[type="submit"] { justify-self: start; padding: 11px 22px; font-size: 0.95rem; }

/* Account settings (accounts#show) */
.account-id { display: flex; align-items: center; gap: 10px; margin: 0; }
.danger-zone input[type="submit"] { background: var(--danger); }
.danger-zone input[type="submit"]:hover { background: var(--danger); filter: brightness(0.9); }

/* Structured constraint editor */
.constraint-preview {
  background: var(--cream-2); border-radius: 10px;
  padding: 10px 14px; margin-bottom: 18px; font-size: 0.9rem;
}
.constraint-preview ul { margin: 0; padding-left: 18px; }
.constraint-preview p { margin: 0; color: var(--muted); }
.rows { display: grid; gap: 6px; margin-bottom: 18px; }
.rows-title { font-weight: 600; font-size: 0.9rem; }
.row { display: flex; gap: 6px; align-items: center; }
.row input[type="text"] { flex: 1; min-width: 0; }
.row-del {
  background: none; color: var(--muted); border: 0;
  padding: 4px 8px; font-size: 1.1rem; line-height: 1;
}
.row-del:hover { background: none; color: var(--danger); }
.row-add {
  justify-self: start; background: none; color: var(--moss-2);
  border: 1px dashed var(--input-border); border-radius: 999px; padding: 5px 14px; font-size: 0.82rem;
}
.row-add:hover { background: var(--cream-2); color: var(--ink); }
.dimension-row .check { display: flex; align-items: center; gap: 4px; font-size: 0.8rem; font-weight: 500; }
@media (max-width: 620px) { .dimension-row { flex-wrap: wrap; } }

/* Feedback widget (bottom-right chat bubble) */
details.feedback-widget {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
}
details.feedback-widget > summary {
  list-style: none;
  cursor: pointer;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--moss-2);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(26, 18, 10, 0.25);
}
details.feedback-widget > summary::-webkit-details-marker { display: none; }
details.feedback-widget > summary:hover { background: var(--orange); }
details.feedback-widget[open] > summary { background: var(--ink); }
.feedback-panel {
  position: absolute;
  right: 0;
  bottom: 64px;
  width: min(320px, calc(100vw - 40px));
  background: var(--card);
  border: 1px solid var(--cream-2);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 12px 32px rgba(26, 18, 10, 0.2);
}
.feedback-panel form { display: grid; gap: 10px; }
.feedback-panel textarea { resize: vertical; }
.feedback-hp { position: absolute; left: -9999px; height: 0; width: 0; opacity: 0; }

/* Admin tabs (CSS-only, radio+label) */
.admin-tabs { position: relative; }
.admin-tabs > input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.admin-tabs > label {
  display: inline-block; padding: 8px 18px; margin-right: 2px;
  font-weight: 700; font-size: 0.88rem; cursor: pointer;
  color: var(--muted); border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.admin-tabs > label:hover { color: var(--ink); }
.admin-tabs > input[type="radio"]:checked + label { color: var(--ink); border-color: var(--moss-2); }
.admin-panel { display: none; padding-top: 18px; }

#tab-sources:checked ~ #panel-sources,
#tab-queue:checked ~ #panel-queue,
#tab-hunts:checked ~ #panel-hunts,
#tab-categories:checked ~ #panel-categories,
#tab-discovery:checked ~ #panel-discovery { display: block; }

.stat-jump { cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

/* The shop's own price, beside ours. nowrap because "CAD 1,849" breaking
   across lines reads as two unrelated numbers. */
.orig-price { white-space: nowrap; }

/* Sits under the shop name rather than running on from it — "bikecomponents.ca
   not monitored" on one wrapped line reads as part of the domain. */
.unmonitored { display: block; }
.source-stat-value.ready { color: var(--moss-2); }

.source-summary {
  display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 18px;
}
.source-stat {
  background: var(--card); border: 1px solid var(--cream-2);
  border-radius: var(--radius); padding: 12px 20px; min-width: 100px;
  display: flex; flex-direction: column; align-items: center;
}
.source-stat-value { font-size: 1.6rem; font-weight: 900; line-height: 1.1; }
.source-stat-label {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); margin-top: 2px;
}

.source-status {
  display: inline-block; font-weight: 700; font-size: 0.75rem;
  padding: 2px 8px; border-radius: 999px; letter-spacing: 0.02em;
}
.source-status-healthy { background: rgba(63, 107, 58, 0.14); color: var(--moss-2); }
.source-status-benched { background: rgba(255, 106, 43, 0.12); color: var(--danger); }
.source-status-disabled { background: var(--cream-2); color: var(--muted); }
.source-status-silent { background: rgba(214, 158, 46, 0.16); color: #8a6206; }

/* Pro upgrade CTAs. Orange separates the pitch from the lime primary actions
   ("New hunt"), so the nav never has two buttons competing to be the one. */
.btn-upgrade, a.btn-upgrade {
  background: var(--orange); color: #fff; border-color: var(--orange);
  box-shadow: 0 10px 24px -12px rgba(255, 106, 43, 0.9);
}
.btn-upgrade:hover, a.btn-upgrade:hover { background: var(--orange); color: #fff; filter: brightness(1.05); }

.plan-nudge {
  background: rgba(255, 106, 43, 0.08); border: 1px solid rgba(255, 106, 43, 0.28);
  border-radius: var(--radius); padding: 12px 16px;
}
.plan-nudge a { color: var(--orange); white-space: nowrap; }

.plan-perks { margin: 4px 0 14px; padding-left: 20px; }
.plan-perks li { margin: 4px 0; }
.plan-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.pro-hint { font-size: 0.78rem; font-weight: 600; color: var(--orange); margin-left: 8px; white-space: nowrap; }
