/* ============================================================
   Homestead Design System
   Source of truth for colors, type, spacing, components.
   Adapted from the Homestead Design System bundle (Claude Design).
   ============================================================ */

/* ---- Fonts ---------------------------------------------------- */

@font-face {
  font-family: "DM Sans";
  src: url("/assets/DMSans-Regular-35e4cf28.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "DM Sans";
  src: url("/assets/DMSans-Medium-35e4cf28.woff2") format("woff2");
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "DM Sans";
  src: url("/assets/DMSans-SemiBold-35e4cf28.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "DM Sans";
  src: url("/assets/DMSans-Bold-35e4cf28.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}

/* ---- Tokens (light, default) ---------------------------------- */

:root {
  /* Brand palette (raw) */
  --terracotta-50:  #faf1ec;
  --terracotta-100: #f3ddd0;
  --terracotta-200: #ecc4ae;
  --terracotta-300: #dfa07e;
  --terracotta-400: #d28461;
  --terracotta-500: #c97455;  /* primary */
  --terracotta-600: #b25f44;
  --terracotta-700: #8e4a35;
  --terracotta-800: #6a3826;
  --terracotta-900: #432114;

  --clay-50:  #fdfcfa;
  --clay-100: #f8f4ed;
  --clay-200: #f3ebe0;
  --clay-300: #e8dcc9;
  --clay-400: #cdbda4;
  --clay-500: #a89779;
  --clay-600: #7d6e54;
  --clay-700: #574a35;
  --clay-800: #3a3022;
  --clay-900: #2b2419;

  --olive-50:  #f1f3ec;
  --olive-100: #e1e6d4;
  --olive-200: #c8d2b1;
  --olive-300: #aebb8d;
  --olive-400: #94a26f;
  --olive-500: #7a8a6b;
  --olive-600: #5e6c4f;
  --olive-700: #46523c;
  --olive-800: #2f372a;
  --olive-900: #1c2118;

  --tomato-500: #c14a3a;
  --honey-500:  #d99c3d;
  --basil-500:  #6b8e4e;
  --slate-500:  #6b7280;

  /* Semantic surfaces & ink */
  --bg:           var(--clay-50);
  --bg-raised:    #ffffff;
  --bg-sunken:    var(--clay-100);
  --bg-panel:     var(--clay-200);
  --bg-inverse:   var(--clay-900);

  --fg-1: var(--clay-900);
  --fg-2: var(--clay-700);
  --fg-3: var(--clay-600);
  --fg-4: var(--clay-500);
  --fg-on-accent: #ffffff;
  --fg-on-inverse: var(--clay-100);

  --border-subtle:  var(--clay-300);
  --border-default: var(--clay-400);
  --border-strong:  var(--clay-700);
  --border-accent:  var(--terracotta-500);

  /* Interactive accent */
  --accent:            var(--terracotta-500);
  --accent-hover:      var(--terracotta-600);
  --accent-press:      var(--terracotta-700);
  --accent-soft:       var(--terracotta-50);
  --accent-soft-hover: var(--terracotta-100);
  --accent-soft-text:  var(--terracotta-700);

  --secondary:        var(--olive-500);
  --secondary-hover:  var(--olive-600);
  --secondary-soft:   var(--olive-50);
  --secondary-soft-text: var(--olive-700);

  /* Status */
  --success:      var(--basil-500);
  --success-soft: #eaf1de;
  --warning:      var(--honey-500);
  --warning-soft: #fbf1d9;
  --danger:       var(--tomato-500);
  --danger-soft:  #f7e1dc;
  --info:         var(--slate-500);
  --info-soft:    #eef0f3;

  /* Spacing (4px base) */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-7: 32px; --sp-8: 40px;
  --sp-9: 56px; --sp-10: 72px; --sp-11: 96px;

  /* Radii */
  --radius-xs:  4px; --radius-sm:  6px; --radius-md: 10px;
  --radius-lg: 12px; --radius-xl: 16px; --radius-2xl: 24px;
  --radius-pill: 999px;

  /* Shadows (warm-tinted) */
  --shadow-xs: 0 1px 1px rgba(67, 33, 20, 0.04);
  --shadow-sm: 0 1px 2px rgba(67, 33, 20, 0.05), 0 1px 1px rgba(67, 33, 20, 0.03);
  --shadow-md: 0 4px 8px -2px rgba(67, 33, 20, 0.06), 0 2px 4px -1px rgba(67, 33, 20, 0.04);
  --shadow-lg: 0 12px 24px -8px rgba(67, 33, 20, 0.10), 0 4px 8px -2px rgba(67, 33, 20, 0.05);
  --ring-focus: 0 0 0 3px rgba(201, 116, 85, 0.25);

  /* Type */
  --font-sans: "DM Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --fs-xs:   12px; --fs-sm:   13px; --fs-base: 15px; --fs-md:   16px;
  --fs-lg:   18px; --fs-xl:   22px; --fs-2xl:  28px; --fs-3xl:  36px;
  --fs-4xl:  48px;

  --lh-tight:   1.15; --lh-snug:    1.3;
  --lh-normal:  1.5;  --lh-relaxed: 1.65;

  --tracking-tight: -0.02em;
  --tracking-snug:  -0.01em;
  --tracking-wide:   0.04em;

  /* Motion */
  --ease-out:    cubic-bezier(0.22, 1, 0.36, 1);
  --dur-fast: 120ms; --dur-base: 200ms; --dur-slow: 320ms;
}

/* ---- Tokens (dark) -------------------------------------------- */

:root[data-theme="dark"] {
  --bg:           #181410;
  --bg-raised:    #221d17;
  --bg-sunken:    #100d0a;
  --bg-panel:     #2a241d;
  --bg-inverse:   var(--clay-100);

  --fg-1: #f1ece2;
  --fg-2: #cbc1ad;
  --fg-3: #9b9079;
  --fg-4: #6e6553;
  --fg-on-accent: #1b1410;
  --fg-on-inverse: var(--clay-900);

  --border-subtle:  #2e2820;
  --border-default: #3d362c;
  --border-strong:  #5b5240;
  --border-accent:  var(--terracotta-400);

  --accent:            var(--terracotta-400);
  --accent-hover:      var(--terracotta-300);
  --accent-press:      var(--terracotta-500);
  --accent-soft:       #2d211a;
  --accent-soft-hover: #3a2a21;
  --accent-soft-text:  var(--terracotta-200);

  --secondary:        var(--olive-300);
  --secondary-hover:  var(--olive-200);
  --secondary-soft:   #232a1d;
  --secondary-soft-text: var(--olive-100);

  --success-soft: #1f2a1a;
  --warning-soft: #2c2415;
  --danger-soft:  #2c1a17;
  --info-soft:    #1f242c;

  --shadow-xs: 0 1px 1px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 8px -2px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 24px -8px rgba(0, 0, 0, 0.55);
  --ring-focus: 0 0 0 3px rgba(210, 132, 97, 0.35);
}

/* ---- Base ----------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--fg-1);
  background: var(--bg);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5 { color: var(--fg-1); margin: 0 0 var(--sp-4); font-weight: 600; }
h1 { font-size: var(--fs-3xl); line-height: var(--lh-tight); letter-spacing: var(--tracking-tight); }
h2 { font-size: var(--fs-2xl); line-height: var(--lh-tight); letter-spacing: var(--tracking-tight); }
h3 { font-size: var(--fs-xl);  line-height: var(--lh-snug); letter-spacing: var(--tracking-snug); }
h4 { font-size: var(--fs-lg);  line-height: var(--lh-snug); }
h5 { font-size: var(--fs-md);  line-height: var(--lh-snug); }

p { margin: 0 0 var(--sp-4); color: var(--fg-2); line-height: var(--lh-relaxed); }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

small, .caption { font-size: var(--fs-xs); color: var(--fg-3); }
.eyebrow {
  font-size: var(--fs-xs); font-weight: 500; letter-spacing: var(--tracking-wide);
  text-transform: uppercase; color: var(--fg-3);
}
code, .mono { font-family: var(--font-mono); font-size: 0.92em; }

hr { border: 0; border-top: 1px solid var(--border-subtle); margin: var(--sp-6) 0; }

/* ---- Layout primitives --------------------------------------- */

main { max-width: 1080px; margin: var(--sp-6) auto var(--sp-9); padding: 0 var(--sp-5); }

.grid {
  display: grid; gap: var(--sp-5);
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

/* ---- App header / nav ---------------------------------------- */

/* ---- App shell: sidebar + content pane (logged-in) ----------- */

.app-shell { display: grid; grid-template-columns: var(--sidebar-w, 236px) 1fr; min-height: 100vh; }
.app-pane  { display: flex; flex-direction: column; min-width: 0; }

.brand {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  font-weight: 700; color: var(--accent); text-decoration: none;
  letter-spacing: var(--tracking-snug); font-size: var(--fs-md);
}
.brand img { width: 22px; height: 22px; }

/* Sidebar (desktop) */
.sidebar {
  position: sticky; top: 0; align-self: start; height: 100vh;
  display: flex; flex-direction: column; gap: var(--sp-1);
  padding: var(--sp-4) var(--sp-3);
  background: var(--bg-raised); border-right: 1px solid var(--border-subtle);
  overflow-y: auto;
}
.sidebar__brand { padding: 0 var(--sp-2); margin-bottom: var(--sp-3); }
.sidebar__nav { display: flex; flex-direction: column; gap: var(--sp-1); }
.sidebar__group { margin-top: var(--sp-3); display: flex; flex-direction: column; gap: 2px; }
.sidebar__group:first-child { margin-top: 0; }
.sidebar__label, .nav-sheet__label {
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.06em;
  font-weight: 600; color: var(--fg-4); padding: 0 var(--sp-2); margin: 0 0 var(--sp-1);
}
.sidebar__link, .nav-sheet__link {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2); border-radius: var(--radius-md);
  color: var(--fg-2); font-weight: 500; font-size: var(--fs-sm); text-decoration: none;
  transition: color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.sidebar__link .icon, .nav-sheet__link .icon { flex: 0 0 auto; color: var(--fg-4); }
.sidebar__link:hover, .nav-sheet__link:hover { background: var(--bg-sunken); color: var(--fg-1); text-decoration: none; }
.sidebar__link:hover .icon, .nav-sheet__link:hover .icon { color: var(--fg-2); }
.sidebar__link.is-active, .nav-sheet__link.is-active {
  background: var(--accent-soft); color: var(--accent-soft-text); font-weight: 600;
}
.sidebar__link.is-active .icon, .nav-sheet__link.is-active .icon { color: var(--accent); }
.sidebar__footer {
  margin-top: auto; padding-top: var(--sp-3);
  border-top: 1px solid var(--border-subtle);
  display: flex; flex-direction: column; gap: 2px;
}

/* Top bar (utility strip) */
.topbar {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-5); min-height: 56px;
  background: var(--bg-raised); border-bottom: 1px solid var(--border-subtle);
  position: sticky; top: 0; z-index: 20;
}
.topbar .nav-spacer { flex: 1 1 auto; }
.topbar__utils { display: inline-flex; align-items: center; gap: var(--sp-2); }
.topbar__brand-mobile { display: none; }
.topbar--auth { padding: var(--sp-3) var(--sp-5); }
.topbar--auth .nav-link { color: var(--fg-2); text-decoration: none; font-weight: 500; font-size: var(--fs-sm); }
.topbar--auth .locale { display: inline-flex; gap: var(--sp-2); font-size: var(--fs-xs); }
.topbar--auth .locale a { color: var(--fg-3); font-weight: 500; }
.topbar--auth .locale a.active { color: var(--accent); font-weight: 700; }

/* Icon button (bell, theme, account trigger) */
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px;
  border-radius: var(--radius-md); border: none; background: transparent;
  color: var(--fg-2); cursor: pointer; text-decoration: none; font-size: var(--fs-md);
  transition: background var(--dur-fast) var(--ease-out);
}
.icon-btn:hover { background: var(--bg-sunken); color: var(--fg-1); }
#notification_bell {
  display: inline-grid; place-items: center; position: relative;
  width: 38px; height: 38px; border-radius: var(--radius-md);
  color: var(--fg-2); text-decoration: none; font-size: var(--fs-md);
}
#notification_bell:hover { background: var(--bg-sunken); }
#notification_bell .pill { position: absolute; top: 2px; right: 2px; padding: 0 5px; font-size: 10px; }

/* Account menu (native <details>) */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.avatar {
  display: inline-grid; place-items: center; width: 30px; height: 30px;
  border-radius: var(--radius-pill); background: var(--accent-soft);
  color: var(--accent-soft-text); font-weight: 700; font-size: var(--fs-sm);
}
.menu__panel {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px;
  background: var(--bg-raised); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: var(--sp-2); display: grid; gap: 2px; z-index: 50;
}
.menu__email { font-size: var(--fs-xs); color: var(--fg-4); padding: var(--sp-1) var(--sp-2); margin: 0; overflow: hidden; text-overflow: ellipsis; }
.menu__locale { display: flex; gap: var(--sp-3); padding: var(--sp-1) var(--sp-2) var(--sp-2); border-bottom: 1px solid var(--border-subtle); margin-bottom: var(--sp-1); font-size: var(--fs-sm); }
.menu__locale a { color: var(--fg-3); font-weight: 500; text-decoration: none; }
.menu__locale a.active { color: var(--accent); font-weight: 700; }
.menu__item {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2); border-radius: var(--radius-sm);
  color: var(--fg-2); font-size: var(--fs-sm); text-decoration: none;
  width: 100%; border: none; background: transparent; cursor: pointer; text-align: left;
}
.menu__item:hover { background: var(--bg-sunken); color: var(--fg-1); }
.menu__item .icon { color: var(--fg-4); }
.menu__item--button { font-family: inherit; }

/* Bottom tab bar + nav sheet (mobile only — shown via media query) */
.bottom-nav, .nav-sheet { display: none; }
.bottom-nav__tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; padding: var(--sp-1); font-size: 10px; font-weight: 500;
  color: var(--fg-3); text-decoration: none; background: none; border: none; cursor: pointer;
}
.bottom-nav__tab.is-active { color: var(--accent); }
.nav-sheet__backdrop { position: absolute; inset: 0; background: rgba(43, 36, 25, 0.45); opacity: 0; transition: opacity var(--dur-base, 0.2s) var(--ease-out); }
.nav-sheet.is-open .nav-sheet__backdrop { opacity: 1; }
.nav-sheet__panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 82vh; overflow-y: auto;
  background: var(--bg-raised); border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: var(--sp-4) var(--sp-4) calc(var(--sp-5) + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform 0.25s var(--ease-out);
}
.nav-sheet.is-open .nav-sheet__panel { transform: translateY(0); }
.nav-sheet__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-2); }
.nav-sheet__title { font-weight: 700; font-size: var(--fs-md); }
.nav-sheet__group { margin-top: var(--sp-4); display: flex; flex-direction: column; gap: 2px; }
.nav-sheet__link { font-size: var(--fs-base); padding: var(--sp-3) var(--sp-2); }
body.nav-sheet-open { overflow: hidden; }

/* ---- Card ---------------------------------------------------- */

.card {
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  margin-bottom: var(--sp-5);
  box-shadow: var(--shadow-sm);
}
.card-elev { box-shadow: var(--shadow-md); border-color: transparent; }
.card-flat { box-shadow: none; background: var(--bg-sunken); }
.card-warn { border-color: var(--warning); background: var(--warning-soft); }

/* ---- Buttons ------------------------------------------------- */

.btn {
  font-family: var(--font-sans); font-size: var(--fs-sm); font-weight: 500;
  padding: 9px 16px; border-radius: var(--radius-md);
  border: 1px solid transparent; cursor: pointer;
  display: inline-flex; align-items: center; gap: var(--sp-2);
  background: var(--accent); color: var(--fg-on-accent);
  text-decoration: none; line-height: 1.2;
  transition: background var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}
.btn:hover  { background: var(--accent-hover); color: var(--fg-on-accent); text-decoration: none; }
.btn:active { background: var(--accent-press); }
.btn:focus-visible { outline: none; box-shadow: var(--ring-focus); }

.btn.secondary, .btn-secondary {
  background: var(--bg-raised); color: var(--fg-1); border-color: var(--border-subtle);
}
.btn.secondary:hover, .btn-secondary:hover { background: var(--bg-sunken); color: var(--fg-1); }

.btn.tertiary, .btn-tertiary {
  background: transparent; color: var(--fg-2); border-color: transparent;
}
.btn.tertiary:hover, .btn-tertiary:hover { background: var(--bg-panel); color: var(--fg-1); }

.btn.soft, .btn-soft {
  background: var(--accent-soft); color: var(--accent-soft-text);
}
.btn.soft:hover, .btn-soft:hover { background: var(--accent-soft-hover); color: var(--accent-soft-text); }

.btn.warn, .btn-danger {
  background: var(--danger); color: #fff;
}
.btn.warn:hover, .btn-danger:hover { background: var(--terracotta-700); }

.btn[disabled], .btn.disabled {
  background: var(--bg-panel); color: var(--fg-4);
  cursor: not-allowed; box-shadow: none;
}

.btn-sm { padding: 6px 12px; font-size: var(--fs-sm); border-radius: var(--radius-sm); }
.btn-lg { padding: 12px 20px; font-size: var(--fs-base); border-radius: var(--radius-lg); }

button.btn, input[type="submit"].btn, input[type="button"].btn { font: inherit; font-weight: 500; }

/* button_to renders a tiny <form> wrapper -- keep it inline so buttons sit
   alongside links/buttons without breaking flow. */
form.button_to { display: inline-block; margin: 0; }

/* ---- Form controls ------------------------------------------- */

input, select, textarea {
  font-family: var(--font-sans); font-size: var(--fs-sm);
  padding: 9px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-raised);
  color: var(--fg-1);
  transition: border-color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}
input::placeholder, textarea::placeholder { color: var(--fg-4); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring-focus);
}
input[type="file"] { padding: 6px 8px; }
input[disabled], select[disabled], textarea[disabled] {
  background: var(--bg-sunken); color: var(--fg-4); cursor: not-allowed;
}
label { font-size: var(--fs-xs); color: var(--fg-2); font-weight: 500; }

/* ---- Tables -------------------------------------------------- */

table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  font-size: var(--fs-xs); font-weight: 500;
  letter-spacing: var(--tracking-wide); text-transform: uppercase;
  color: var(--fg-3);
  padding: var(--sp-3) var(--sp-3);
  border-bottom: 1px solid var(--border-subtle);
}
tbody td {
  padding: var(--sp-3); border-bottom: 1px solid var(--border-subtle);
  font-size: var(--fs-sm); color: var(--fg-1);
}
tbody tr:hover td { background: var(--bg-sunken); }

/* ---- Pills, chips, badges ------------------------------------ */

.pill, .chip {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  font-size: var(--fs-xs); font-weight: 500;
  padding: 3px var(--sp-3); border-radius: var(--radius-pill);
  background: var(--bg-panel); color: var(--fg-2);
  border: 1px solid transparent;
}
.pill.warn, .chip.warn  { background: var(--warning-soft); color: var(--clay-700); }
.pill.success, .chip.success { background: var(--success-soft); color: var(--olive-800); }
.pill.danger, .chip.danger { background: var(--danger-soft); color: var(--terracotta-800); }
.pill.info, .chip.info { background: var(--info-soft); color: var(--clay-800); }

.chip-active   { background: var(--accent); color: var(--fg-on-accent); }
.chip-soft     { background: var(--accent-soft); color: var(--accent-soft-text); }
.chip-olive    { background: var(--olive-100); color: var(--olive-700); }

/* Collapsible category sections on /offers. We swap the browser's
   default disclosure triangle for a custom chevron span that rotates
   to indicate state, so the heading row stays clean and on-brand. */
.offer-category > summary { user-select: none; }
.offer-category > summary::-webkit-details-marker { display: none; }
.offer-category > summary .offer-category__chevron {
  display: inline-block;
  transition: transform .15s ease;
  color: var(--clay-600, #6b6b6b);
}
.offer-category:not([open]) > summary .offer-category__chevron {
  transform: rotate(-90deg);
}

/* Watchlist match on /offers — soft terracotta tint + accent border so
   matched offers stand out without screaming. The pill in the top-right
   corner repeats the signal redundantly (color blindness, scanning). */
.offer-card--watched {
  border-left: 4px solid var(--terracotta-500);
  background: linear-gradient(90deg, var(--terracotta-50), transparent 55%);
  position: relative;
}
.offer-card__watched-pill {
  position: absolute;
  top: var(--sp-2);
  right: var(--sp-2);
  background: var(--terracotta-500);
  color: white;
  font-size: var(--fs-xs);
}

.badge {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  font-size: 11px; font-weight: 500;
  padding: 3px var(--sp-2); border-radius: var(--radius-pill);
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; }

/* ---- Flash --------------------------------------------------- */

.flash {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-md);
  margin-bottom: var(--sp-5);
  border: 1px solid transparent;
  font-size: var(--fs-sm);
}
.flash.notice { background: var(--success-soft); color: var(--olive-800); border-color: var(--olive-200); }
.flash.alert  { background: var(--danger-soft);  color: var(--terracotta-800); border-color: var(--terracotta-200); }

/* ---- Misc ---------------------------------------------------- */

.scanner-video {
  width: 100%; max-width: 480px;
  border-radius: var(--radius-lg);
  background: #000;
  display: block;
}

/* ---- Receipt confirm: per-line cards instead of a wide table ---------- */
.receipt-line__head {
  display: flex; gap: var(--sp-3); align-items: flex-start; justify-content: space-between;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: var(--sp-2); margin-bottom: var(--sp-3);
}
.receipt-line__ocr {
  font-size: var(--fs-xs); color: var(--fg-3);
  white-space: pre-wrap; word-break: break-word;
  flex: 1 1 60%;
}
.receipt-line__totals {
  display: flex; gap: var(--sp-2); align-items: baseline; white-space: nowrap;
}
.receipt-line__grid {
  display: grid; gap: var(--sp-3);
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  align-items: end;
}
.receipt-line__field {
  display: flex; flex-direction: column; gap: var(--sp-1); min-width: 0;
}
.receipt-line__field > label {
  font-size: var(--fs-xs); color: var(--fg-3);
}
.receipt-line__field > select,
.receipt-line__field > input[type="number"],
.receipt-line__field > input[type="date"] {
  width: 100%;
}
.receipt-line__field--wide {
  grid-column: span 2;
}
@media (max-width: 640px) {
  .receipt-line__field--wide { grid-column: auto; }
}

details > summary {
  cursor: pointer; font-weight: 500; color: var(--fg-2);
  padding: var(--sp-2) 0;
}
details[open] > summary { color: var(--fg-1); }

pre {
  background: var(--bg-sunken); padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-md); overflow-x: auto;
  font-size: var(--fs-xs); color: var(--fg-2);
}

/* ---- Responsive --------------------------------------------- */

/* Below 900px the sidebar collapses to a fixed bottom tab bar + "More" sheet. */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar { position: sticky; }
  .topbar__brand-mobile { display: inline-flex; }
  /* Keep <main> exactly viewport-wide so the page never scrolls sideways and
     the sticky top bar always fills the top (no gap on the right). The base
     `margin: … auto` centres main on desktop, but auto inline margins on a
     flex item suppress cross-axis stretch — so main would size to its widest
     child (a table) and overflow the pane. Zero the inline margins to restore
     stretch; overflow-x: clip contains any remaining wide child without
     becoming a vertical scroll container. */
  main {
    min-width: 0; margin-inline: 0; overflow-x: clip;
    padding-bottom: calc(64px + env(safe-area-inset-bottom) + var(--sp-4));
  }

  /* Wide data tables then scroll within themselves instead of widening the
     page, so their action columns stay reachable. The anonymous table box
     preserves the row/cell layout. */
  main table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  .bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
    height: 60px; padding-bottom: env(safe-area-inset-bottom);
    background: var(--bg-raised); border-top: 1px solid var(--border-subtle);
  }
  .nav-sheet { display: block; position: fixed; inset: 0; z-index: 40; visibility: hidden; }
  .nav-sheet.is-open { visibility: visible; }
}

@media (max-width: 640px) {
  .topbar { padding: var(--sp-2) var(--sp-3); }
  main { padding-left: var(--sp-3); padding-right: var(--sp-3); }
}

/* ---- PWA offline page --------------------------------------- */
/* Served by the service worker when navigation requests fail. No
   header/main chrome -- just a centred panel with a retry button. */
.pwa-offline {
  min-height: 100vh; display: grid; place-items: center;
  background: var(--bg-1); color: var(--fg-1); padding: var(--sp-5);
}
.pwa-offline__panel {
  max-width: 28rem; text-align: center; display: grid; gap: var(--sp-4);
  padding: var(--sp-5);
}
.pwa-offline__mark { margin: 0 auto; }
.pwa-offline h1 { font-size: var(--fs-xl); }
.pwa-offline p { color: var(--fg-2); }

/* --- Modal (native <dialog> driven by a Turbo Frame) --------------------- */
.modal-dialog {
  margin: auto;
  width: min(480px, calc(100vw - 2 * var(--sp-3, 1rem)));
  max-width: 100%;
  padding: 0;
  border: 1px solid var(--border-subtle, #ccc);
  border-radius: var(--radius-xl, 16px);
  background: var(--bg-raised, #fff);
  color: var(--fg-1, #111);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.35);
}
.modal-dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
.modal-body { padding: var(--sp-4, 1.25rem); }
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-2, 0.5rem);
  margin-bottom: var(--sp-2, 0.5rem);
}
.modal-header h2 { margin: 0; }

/* Mobile: full-width bottom sheet. */
@media (max-width: 560px) {
  .modal-dialog {
    width: 100%;
    max-width: 100%;
    margin: auto auto 0 auto;
    border-radius: var(--radius-xl, 16px) var(--radius-xl, 16px) 0 0;
    border-bottom: none;
  }
}

/* ---- Notification settings form ----------------------------- */
.np-section { border: none; padding: 0; margin: 0 0 var(--sp-5); }
.np-section legend { font-weight: 600; font-size: var(--fs-md); color: var(--fg-1); padding: 0; margin-bottom: var(--sp-1); }
.np-check { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) 0; cursor: pointer; }
.np-quiet { display: flex; gap: var(--sp-4); flex-wrap: wrap; }
.np-quiet label { display: flex; flex-direction: column; gap: var(--sp-1); font-size: var(--fs-sm); color: var(--fg-2); }

/* ---- Garden map (map mode + lite planner) -------------------- */
.garden-map {
  height: min(70vh, 640px);
  border-radius: var(--radius-lg, 12px);
  border: 1px solid var(--border-default);
  overflow: hidden;
}
.garden-map-drawing { cursor: crosshair; }
.garden-map-toolbar {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  flex-wrap: wrap;
  margin-bottom: var(--sp-2);
}
.garden-map-toolbar label { display: flex; align-items: center; gap: var(--sp-1); cursor: pointer; }
.garden-map-beds-heading { margin-top: var(--sp-4); font-size: var(--fs-md); }
.garden-map-bedlist { list-style: none; padding: 0; margin: 0; }
.garden-map-bedlist li {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-1) 0;
  flex-wrap: wrap;
}
.garden-map-bed-actions { margin-left: auto; display: flex; gap: var(--sp-1); }
.garden-map-bed-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex: none;
  background: var(--accent-soft);
}
/* Leaflet chrome should inherit the app's font; tooltips act as bed labels. */
.leaflet-container { font: inherit; }
.garden-map-label {
  background: none;
  border: none;
  box-shadow: none;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}
.garden-map-custom-wms { border: none; padding: 0; margin: 0 0 var(--sp-3); }

/* Lite planner: to-scale SVG canvas, drag with pointer events. */
.garden-lite-canvas { overflow-x: auto; }
.garden-lite-svg {
  touch-action: none;
  display: block;
  width: 100%;
  min-height: 280px;
  background: var(--bg-sunken);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg, 12px);
}
.garden-lite-svg .bed rect {
  fill: var(--accent-soft);
  stroke: var(--accent);
  stroke-width: 0.06;
  cursor: grab;
}
.garden-lite-svg .bed text {
  fill: var(--fg-1);
  pointer-events: none;
}
.garden-lite-svg .grid line { stroke: var(--border-subtle); stroke-width: 0.02; }

/* ---- Projects: shared color palette chips -------------------- */
/* Named palette for user-managed labels (project statuses/categories,
   ColorPalette::COLORS). Built on the theme's soft variable pairs so both
   themes stay legible; also used as column dots on the kanban board. */
.chip-color-clay       { background: var(--accent-soft);    color: var(--accent-soft-text); }
.chip-color-olive      { background: var(--secondary-soft); color: var(--secondary-soft-text); }
.chip-color-moss       { background: var(--success-soft);   color: var(--success); }
.chip-color-sand       { background: var(--warning-soft);   color: var(--warning); }
.chip-color-terracotta { background: var(--danger-soft);    color: var(--danger); }
.chip-color-sky        { background: var(--info-soft);      color: var(--info); }

/* ---- Project kanban board ------------------------------------ */
/* Own horizontal scroll context: <main> clips overflow-x globally. */
.project-board {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
  overflow-x: auto;
  padding-bottom: var(--sp-2);
}
.board-column {
  flex: 0 0 272px;
  min-width: 0;
  background: var(--bg-sunken);
  border-radius: var(--radius-lg, 12px);
  padding: var(--sp-2);
}
.board-column__header {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 0 var(--sp-1) var(--sp-2);
}
.board-column__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border-strong);
  flex: none;
}
.board-column__cards {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  min-height: 2.5rem; /* empty columns stay droppable */
}
.board-card { padding: var(--sp-3); }
.board-card__head { display: flex; gap: var(--sp-1); align-items: baseline; }
.board-card__title { font-weight: 600; }
.board-card__grip { cursor: grab; touch-action: none; color: var(--fg-2); user-select: none; }
.board-card__meta {
  display: flex;
  gap: var(--sp-1);
  flex-wrap: wrap;
  align-items: center;
  margin: var(--sp-1) 0 0;
}
.board-card__fallback { display: flex; gap: var(--sp-1); margin-top: var(--sp-2); }
.board--js .board-card__fallback { display: none; }
.board-card--dragging { opacity: 0.4; }
.board-card-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 50;
  width: 240px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}
.board-card-placeholder {
  border: 2px dashed var(--border-default);
  border-radius: var(--radius-lg, 12px);
  min-height: 3rem;
}

/* Grundstück outline on the garden planner canvas. */
.garden-lite-svg .property {
  fill: none;
  stroke: var(--accent);
  stroke-width: 0.08;
  stroke-linejoin: round;
}
