/* Crop Planner — plan.cooncreek.farm
 *
 * Themes, chosen per user and applied as [data-color-scheme] on <html> and
 * <body>. Every color in the app is a token defined in one of the blocks
 * below; nothing else hardcodes a color, so a new theme is one block here plus
 * a line in ThemeService - both front ends pick it up with no further change.
 *
 * Each block is a marque's own two colors on a shared ladder of neutral
 * lightnesses, tinted toward the brand hue. Reds stay on untinted grey: a
 * red-tinted grey reads pink.
 *
 * These are color palettes inspired by familiar equipment liveries. No
 * manufacturer marks, logos or wordmarks are used anywhere.
 */

/* --------------------------------------------------------------------------
   Themes
   -------------------------------------------------------------------------- */

:root,
[data-color-scheme="john-deere"] {
  --brand:          #367C2B;
  --brand-dark:     #2A6322;
  --brand-ink:      #1F371B;
  --accent:         #FFCC00;
  --accent-ink:     #4A3B00;

  --bg:             #F4F6F2;
  --surface:        #FFFFFF;
  --surface-2:      #F8FAF6;
  --surface-3:      #EEF2EA;
  --border:         #DCE3D8;
  --border-strong:  #C3CDBC;

  --text:           #1F2A1C;
  --text-soft:      #5F6B5A;
  --text-faint:     #8B9586;
  --on-brand:       #FFFFFF;

  --ok:             #2F7D32;
  --ok-bg:          #EAF4EA;
  --warn:           #A95900;
  --warn-bg:        #FBF0E2;
  --bad:            #B3261E;
  --bad-bg:         #FBEAE8;

  --shadow:         0 1px 2px rgba(24, 51, 20, .06), 0 8px 24px rgba(24, 51, 20, .06);
  --shadow-sm:      0 1px 2px rgba(24, 51, 20, .08);
  --radius:         10px;
  --radius-sm:      6px;
}

[data-color-scheme="john-deere-dark"] {
  --brand:          #467C3D;
  --brand-dark:     #386331;
  --brand-ink:      #CBE3C4;
  --accent:         #FFCC00;
  --accent-ink:     #3A2E00;

  --bg:             #12160F;
  --surface:        #1B2018;
  --surface-2:      #222922;
  --surface-3:      #2B332A;
  --border:         #333C31;
  --border-strong:  #47523F;

  --text:           #E6EADF;
  --text-soft:      #A6B09E;
  --text-faint:     #78826F;
  --on-brand:       #FFFFFF;

  --ok:             #6FBF6A;
  --ok-bg:          #1E2B1D;
  --warn:           #E0A458;
  --warn-bg:        #2E2517;
  --bad:            #E5766D;
  --bad-bg:         #33201E;

  --shadow:         0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
  --shadow-sm:      0 1px 2px rgba(0, 0, 0, .4);
}

[data-color-scheme="case-ih"] {
  --brand:          #C8102E;
  --brand-dark:     #A20D25;
  --brand-ink:      #3A0A11;
  --accent:         #1A1A1A;
  --accent-ink:     #FFFFFF;

  --bg:             #F5F5F5;
  --surface:        #FFFFFF;
  --surface-2:      #FAFAFA;
  --surface-3:      #F0F0F0;
  --border:         #E0E0E0;
  --border-strong:  #C7C7C7;

  --text:           #1F1F1F;
  --text-soft:      #616161;
  --text-faint:     #8C8C8C;
  --on-brand:       #FFFFFF;

  --ok:             #2F7D32;
  --ok-bg:          #EAF4EA;
  --warn:           #A95900;
  --warn-bg:        #FBF0E2;
  --bad:            #B3261E;
  --bad-bg:         #FBEAE8;

  --shadow:         0 1px 2px rgba(0, 0, 0, .06), 0 8px 24px rgba(0, 0, 0, .07);
  --shadow-sm:      0 1px 2px rgba(0, 0, 0, .08);
}

[data-color-scheme="case-ih-dark"] {
  --brand:          #DB142F;
  --brand-dark:     #AF1026;
  --brand-ink:      #F3C4CB;
  --accent:         #F0F0F0;
  --accent-ink:     #1A1A1A;

  --bg:             #131313;
  --surface:        #1C1C1C;
  --surface-2:      #232323;
  --surface-3:      #2C2C2C;
  --border:         #343434;
  --border-strong:  #484848;

  --text:           #ECECEC;
  --text-soft:      #A8A8A8;
  --text-faint:     #7C7C7C;
  --on-brand:       #FFFFFF;

  --ok:             #6FBF6A;
  --ok-bg:          #1E2B1D;
  --warn:           #E0A458;
  --warn-bg:        #2E2517;
  --bad:            #E5766D;
  --bad-bg:         #33201E;

  --shadow:         0 1px 2px rgba(0, 0, 0, .5), 0 8px 24px rgba(0, 0, 0, .35);
  --shadow-sm:      0 1px 2px rgba(0, 0, 0, .5);
}

[data-color-scheme="fendt"] {
  --brand:          #005E1D;
  --brand-dark:     #004B17;
  --brand-ink:      #183923;
  --accent:         #57A527;
  --accent-ink:     #1A310C;

  --bg:             #F3F6F4;
  --surface:        #FFFFFF;
  --surface-2:      #F8F9F8;
  --surface-3:      #ECF1ED;
  --border:         #DBE3DD;
  --border-strong:  #BECDC1;

  --text:           #1B271D;
  --text-soft:      #59695C;
  --text-faint:     #849487;
  --on-brand:       #FFFFFF;

  --ok:             #2F7D32;
  --ok-bg:          #EAF4EA;
  --warn:           #A95900;
  --warn-bg:        #FBF0E2;
  --bad:            #B3261E;
  --bad-bg:         #FBEAE8;

  --shadow:         0 1px 2px rgba(10, 40, 18, .06), 0 8px 24px rgba(10, 40, 18, .07);
  --shadow-sm:      0 1px 2px rgba(10, 40, 18, .08);
}

[data-color-scheme="fendt-dark"] {
  --brand:          #198039;
  --brand-dark:     #14662E;
  --brand-ink:      #B0DDBE;
  --accent:         #ABCC9B;
  --accent-ink:     #3B582D;

  --bg:             #101411;
  --surface:        #191F1A;
  --surface-2:      #212922;
  --surface-3:      #273229;
  --border:         #2E3B31;
  --border-strong:  #3F5042;

  --text:           #E4ECE6;
  --text-soft:      #A1ADA3;
  --text-faint:     #738276;
  --on-brand:       #FFFFFF;

  --ok:             #6FBF6A;
  --ok-bg:          #1E2B1D;
  --warn:           #E0A458;
  --warn-bg:        #2E2517;
  --bad:            #E5766D;
  --bad-bg:         #33201E;

  --shadow:         0 1px 2px rgba(0, 0, 0, .45), 0 8px 24px rgba(0, 0, 0, .32);
  --shadow-sm:      0 1px 2px rgba(0, 0, 0, .45);
}

[data-color-scheme="new-holland"] {
  --brand:          #0063AC;
  --brand-dark:     #004F8A;
  --brand-ink:      #182B39;
  --accent:         #F1B514;
  --accent-ink:     #5E4B17;

  --bg:             #F3F5F6;
  --surface:        #FFFFFF;
  --surface-2:      #F8F9FA;
  --surface-3:      #ECEFF1;
  --border:         #DBE0E4;
  --border-strong:  #BEC6CE;

  --text:           #1B2228;
  --text-soft:      #58626A;
  --text-faint:     #838D95;
  --on-brand:       #FFFFFF;

  --ok:             #2F7D32;
  --ok-bg:          #EAF4EA;
  --warn:           #A95900;
  --warn-bg:        #FBF0E2;
  --bad:            #B3261E;
  --bad-bg:         #FBEAE8;

  --shadow:         0 1px 2px rgba(8, 40, 70, .06), 0 8px 24px rgba(8, 40, 70, .07);
  --shadow-sm:      0 1px 2px rgba(8, 40, 70, .08);
}

[data-color-scheme="new-holland-dark"] {
  --brand:          #1272B8;
  --brand-dark:     #0E5B93;
  --brand-ink:      #B0CADD;
  --accent:         #F1B514;
  --accent-ink:     #5E4B17;

  --bg:             #101214;
  --surface:        #181C20;
  --surface-2:      #20252A;
  --surface-3:      #272D32;
  --border:         #2D353B;
  --border-strong:  #3E4851;

  --text:           #E4E8EC;
  --text-soft:      #A0A8AE;
  --text-faint:     #727B83;
  --on-brand:       #FFFFFF;

  --ok:             #6FBF6A;
  --ok-bg:          #1E2B1D;
  --warn:           #E0A458;
  --warn-bg:        #2E2517;
  --bad:            #E5766D;
  --bad-bg:         #33201E;

  --shadow:         0 1px 2px rgba(0, 0, 0, .45), 0 8px 24px rgba(0, 0, 0, .32);
  --shadow-sm:      0 1px 2px rgba(0, 0, 0, .45);
}

[data-color-scheme="massey-ferguson"] {
  --brand:          #C21B26;
  --brand-dark:     #9B161E;
  --brand-ink:      #39181B;
  --accent:         #B4B6B9;
  --accent-ink:     #45474A;

  --bg:             #F5F5F5;
  --surface:        #FFFFFF;
  --surface-2:      #F9F9F9;
  --surface-3:      #EEEEEE;
  --border:         #DFDFDF;
  --border-strong:  #C6C6C6;

  --text:           #231F1F;
  --text-soft:      #616161;
  --text-faint:     #8C8C8C;
  --on-brand:       #FFFFFF;

  --ok:             #2F7D32;
  --ok-bg:          #EAF4EA;
  --warn:           #A95900;
  --warn-bg:        #FBF0E2;
  --bad:            #B3261E;
  --bad-bg:         #FBEAE8;

  --shadow:         0 1px 2px rgba(0, 0, 0, .06), 0 8px 24px rgba(0, 0, 0, .07);
  --shadow-sm:      0 1px 2px rgba(0, 0, 0, .08);
}

[data-color-scheme="massey-ferguson-dark"] {
  --brand:          #D62430;
  --brand-dark:     #AB1D26;
  --brand-ink:      #DDB0B3;
  --accent:         #B4B6B9;
  --accent-ink:     #45474A;

  --bg:             #121212;
  --surface:        #1C1C1C;
  --surface-2:      #252525;
  --surface-3:      #2D2D2D;
  --border:         #343434;
  --border-strong:  #474747;

  --text:           #E9E7E7;
  --text-soft:      #A7A7A7;
  --text-faint:     #7A7A7A;
  --on-brand:       #FFFFFF;

  --ok:             #6FBF6A;
  --ok-bg:          #1E2B1D;
  --warn:           #E0A458;
  --warn-bg:        #2E2517;
  --bad:            #E5766D;
  --bad-bg:         #33201E;

  --shadow:         0 1px 2px rgba(0, 0, 0, .45), 0 8px 24px rgba(0, 0, 0, .32);
  --shadow-sm:      0 1px 2px rgba(0, 0, 0, .45);
}

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

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); }

h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; font-weight: 650; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .9em;
  background: var(--surface-3);
  padding: .1em .35em;
  border-radius: 4px;
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.num { font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------------
   Signed-out pages
   -------------------------------------------------------------------------- */

.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background:
    radial-gradient(circle at 15% 10%, color-mix(in srgb, var(--brand) 14%, transparent), transparent 45%),
    radial-gradient(circle at 85% 90%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 45%),
    var(--bg);
}

.auth-wrap { width: 100%; max-width: 440px; }
.auth-wrap--doc { max-width: 720px; }

.auth-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid var(--border);
}

.auth-card__bar { height: 6px; background: var(--brand); border-bottom: 3px solid var(--accent); }
.auth-card__inner { padding: 1.75rem; }

.auth-brand { display: inline-flex; align-items: center; gap: .55rem; text-decoration: none; margin-bottom: 1.25rem; }
.auth-brand__mark, .app-brand__mark {
  width: 20px; height: 20px; border-radius: 5px;
  background: var(--brand); border-bottom: 4px solid var(--accent);
  flex: none;
}
.auth-brand__text { font-weight: 700; color: var(--text); letter-spacing: -.01em; }

.auth-title { font-size: 1.4rem; color: var(--text); margin-bottom: 1rem; }
.auth-note { color: var(--text-soft); margin: 0 0 1.1rem; }
.auth-hint { color: var(--text-faint); font-size: .82rem; margin: -.5rem 0 .9rem; }

.auth-form { display: block; }
.auth-label {
  display: block; font-size: .78rem; font-weight: 650; letter-spacing: .03em;
  text-transform: uppercase; color: var(--text-soft); margin: 0 0 .35rem;
}
.auth-input {
  width: 100%; padding: .6rem .7rem; margin: 0 0 .9rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-size: 1rem;
}
.auth-input:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.auth-input[readonly] { background: var(--surface-3); color: var(--text-soft); }

.auth-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }

.auth-btn {
  display: block; width: 100%; padding: .7rem 1rem; margin-top: .35rem;
  background: var(--brand); color: var(--on-brand);
  border: none; border-radius: var(--radius-sm);
  font-size: 1rem; font-weight: 650; cursor: pointer;
  text-align: center; text-decoration: none;
}
.auth-btn:hover { background: var(--brand-dark); }
.auth-btn--ghost { background: transparent; color: var(--brand); border: 1px solid var(--border-strong); }
.auth-btn--ghost:hover { background: var(--surface-3); }
.auth-btn--link { margin-top: 1rem; }

.auth-alert { padding: .65rem .8rem; border-radius: var(--radius-sm); margin: 0 0 1rem; font-size: .9rem; }
.auth-alert--bad { background: var(--bad-bg); color: var(--bad); }
.auth-alert--ok  { background: var(--ok-bg);  color: var(--ok); }

.auth-links { margin-top: 1.1rem; font-size: .88rem; text-align: center; color: var(--text-soft); }
.auth-links a { color: var(--brand); text-decoration: none; }
.auth-links a:hover { text-decoration: underline; }
.auth-links__sep { margin: 0 .4rem; color: var(--text-faint); }

.auth-foot { text-align: center; color: var(--text-faint); font-size: .78rem; margin-top: 1rem; }

/* --------------------------------------------------------------------------
   Theme picker - shared by /register (server-rendered) and the profile (React)
   --------------------------------------------------------------------------

   Each card carries its own [data-color-scheme], which redefines the palette
   tokens inside it: the card renders as a live sample of its own theme. No
   color is named here, so a new theme needs a palette block and nothing else -
   no swatch table, no markup, in either front end. */

.theme-fieldset { border: 0; padding: 0; margin: 0 0 .35rem; min-width: 0; }
.theme-fieldset > legend { padding: 0; }

/* --picker-edge resolves HERE, outside the cards, so it holds the *page's*
   border color - a dark card on a dark page still has a visible edge. */
.theme-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .5rem;
  --picker-edge: var(--border-strong);
}

.theme-card {
  position: relative; display: flex; align-items: center; gap: .45rem;
  cursor: pointer;
  padding: .5rem .55rem;
  background: var(--surface);
  border: 1px solid var(--picker-edge);
  border-radius: var(--radius-sm);
}
.theme-card:hover { border-color: var(--brand); }
.theme-card:has(.theme-card__radio:checked) {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 45%, transparent);
}
.theme-card:has(.theme-card__radio:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }

.theme-card__radio { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }

.theme-card__chips { display: flex; gap: .15rem; flex: none; }
.theme-card__chip { width: 13px; height: 13px; border-radius: 2px; border: 1px solid var(--border-strong); }
.theme-card__chip--brand  { background: var(--brand); }
.theme-card__chip--accent { background: var(--accent); }
.theme-card__chip--bg     { background: var(--bg); }

.theme-card__name {
  flex: 1; min-width: 0;
  font-size: .78rem; font-weight: 600; color: var(--text); line-height: 1.2;
  letter-spacing: -.01em;
}

.auth-hint--loose { margin-top: .5rem; }

/* Consent row: the box and its wrapping label stay aligned on one baseline. */
.auth-check { display: flex; align-items: flex-start; gap: .6rem; margin: 1.1rem 0 .4rem; }
.auth-check input[type="checkbox"] {
  flex: none; width: 1.05rem; height: 1.05rem; margin-top: .12rem;
  accent-color: var(--brand);
}
.auth-check__text { color: var(--text-soft); font-size: .9rem; line-height: 1.45; }
.auth-check__text a { color: var(--brand); }

.auth-doc { color: var(--text); font-size: .94rem; line-height: 1.6; }
.auth-doc__lead {
  background: var(--surface-3); border-left: 3px solid var(--accent);
  padding: .8rem .9rem; border-radius: var(--radius-sm); margin: 0 0 1.4rem;
}
.auth-doc h2 { font-size: 1rem; margin: 1.5rem 0 .4rem; color: var(--text); }
.auth-doc p { margin: 0 0 .8rem; }
.auth-doc ul { margin: 0 0 .8rem; padding-left: 1.2rem; }
.auth-doc li { margin-bottom: .3rem; }
.auth-doc a { color: var(--brand); }

/* --------------------------------------------------------------------------
   App shell
   -------------------------------------------------------------------------- */

.app-header {
  background: var(--brand);
  border-bottom: 5px solid var(--accent);
  position: sticky; top: 0; z-index: 40;
}
.app-header__inner {
  max-width: 1600px; margin: 0 auto; padding: .65rem 1.25rem;
  display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
}
.app-brand { display: inline-flex; align-items: center; gap: .55rem; text-decoration: none; }
/* The mark sits ON the brand-colored header, so it takes the accent rather
   than the surface — a dark theme's surface is nearly invisible there. */
.app-brand__mark { background: var(--accent); border-bottom-color: var(--on-brand); }
.app-brand__text { color: var(--on-brand); font-weight: 700; letter-spacing: -.01em; }

.app-nav { display: flex; gap: .25rem; margin-left: auto; flex-wrap: wrap; }
.app-nav__link {
  color: color-mix(in srgb, var(--on-brand) 82%, transparent);
  text-decoration: none; padding: .35rem .7rem; border-radius: 999px;
  font-size: .9rem; font-weight: 550;
}
.app-nav__link:hover { background: rgba(255,255,255,.14); color: var(--on-brand); }
.app-nav__link.is-active { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.app-nav__link--muted { opacity: .78; }

.app-main { max-width: 1600px; margin: 0 auto; padding: 1.25rem; }

.app-buildwarn {
  max-width: 1600px; margin: 1rem auto; padding: .8rem 1rem;
  background: var(--warn-bg); color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
  border-radius: var(--radius-sm);
}

/* --------------------------------------------------------------------------
   Building blocks used by the React app
   -------------------------------------------------------------------------- */

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 1rem 1.1rem; margin-bottom: 1rem;
}
.card__head { display: flex; align-items: baseline; gap: .75rem; margin-bottom: .85rem; flex-wrap: wrap; }
.card__title { font-size: 1rem; font-weight: 650; margin: 0; }
.card__sub { color: var(--text-soft); font-size: .85rem; }
.card__actions { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; }

.hero {
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--brand) 8%, var(--surface)) 0%, var(--surface) 60%);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem 1.25rem; margin-bottom: 1rem;
  display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap;
}
.hero__title { font-size: 1.35rem; margin: 0 0 .15rem; }
.hero__sub { color: var(--text-soft); font-size: .9rem; margin: 0; }
.hero__actions { margin-left: auto; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

.tabs {
  display: flex; gap: .2rem; margin-bottom: 1rem;
  border-bottom: 1px solid var(--border); overflow-x: auto;
}
.tab {
  appearance: none; background: none; border: none; cursor: pointer;
  padding: .6rem .95rem; font-size: .92rem; font-weight: 600;
  color: var(--text-soft); border-bottom: 3px solid transparent;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--brand); border-bottom-color: var(--brand); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.tile {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .8rem .9rem;
}
.tile__label {
  font-size: .7rem; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-soft); font-weight: 700; margin-bottom: .25rem;
}
.tile__value { font-size: 1.45rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; }
.tile__note { font-size: .78rem; color: var(--text-faint); margin-top: .15rem; }
.tile--good .tile__value { color: var(--ok); }
.tile--bad .tile__value  { color: var(--bad); }
.tile--accent { border-color: color-mix(in srgb, var(--brand) 40%, var(--border)); }

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data td { padding: .5rem .6rem; text-align: left; border-bottom: 1px solid var(--border); }
table.data th {
  font-size: .72rem; letter-spacing: .05em; text-transform: uppercase;
  color: var(--text-soft); font-weight: 700; white-space: nowrap;
  background: var(--surface-2); position: sticky; top: 0; z-index: 1;
}
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.num { white-space: nowrap; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tfoot td { font-weight: 700; border-top: 2px solid var(--border-strong); border-bottom: none; background: var(--surface-2); }
table.data .row-sub { font-size: .78rem; color: var(--text-faint); }
.month-slider { display: inline-flex; align-items: center; gap: .5rem; margin-top: .15rem; }
.month-slider__label {
  font-size: .72rem; color: var(--text-soft); white-space: nowrap;
  min-width: 4.5rem; font-variant-numeric: tabular-nums;
}
.month-slider input[type="range"] {
  width: 8rem; height: 1rem; margin: 0; padding: 0;
  background: transparent; cursor: pointer; accent-color: var(--brand);
  -webkit-appearance: none; appearance: none;
}
.month-slider input[type="range"]:disabled { cursor: default; opacity: .5; }
.month-slider input[type="range"]:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 3px; }
.month-slider input[type="range"]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px; background: var(--border-strong);
}
.month-slider input[type="range"]::-moz-range-track {
  height: 4px; border-radius: 2px; background: var(--border-strong);
}
.month-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; margin-top: -5px; border-radius: 50%;
  background: var(--brand); border: 2px solid var(--surface); box-shadow: var(--shadow-sm);
}
.month-slider input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--brand); border: 2px solid var(--surface); box-shadow: var(--shadow-sm);
}

table.data .group-row td {
  background: var(--surface-3); font-weight: 700; font-size: .78rem;
  letter-spacing: .05em; text-transform: uppercase; color: var(--text-soft);
}

.btn {
  appearance: none; cursor: pointer; font: inherit; font-weight: 600; font-size: .88rem;
  padding: .42rem .85rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  display: inline-flex; align-items: center; gap: .35rem; text-decoration: none;
}
.btn:hover:not(:disabled) { background: var(--surface-3); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn--primary:hover:not(:disabled) { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn--danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); }
.btn--danger:hover:not(:disabled) { background: var(--bad-bg); }
.btn--sm { padding: .22rem .5rem; font-size: .8rem; }
.btn--icon { padding: .22rem .45rem; }

.input, .select, .textarea {
  font: inherit; padding: .38rem .5rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); width: 100%;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 16%, transparent);
}
.input--num { text-align: right; font-variant-numeric: tabular-nums; }
.input--sm { padding: .22rem .4rem; font-size: .85rem; }

.field { margin-bottom: .8rem; }
.field__label {
  display: block; font-size: .75rem; font-weight: 650; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text-soft); margin-bottom: .25rem;
}
.field__hint { font-size: .78rem; color: var(--text-faint); margin-top: .2rem; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem; }

.badge {
  display: inline-block; padding: .1rem .45rem; border-radius: 999px;
  font-size: .72rem; font-weight: 700; letter-spacing: .02em;
  background: var(--surface-3); color: var(--text-soft);
}
.badge--ok   { background: var(--ok-bg);   color: var(--ok); }
.badge--warn { background: var(--warn-bg); color: var(--warn); }
.badge--bad  { background: var(--bad-bg);  color: var(--bad); }
.badge--brand{ background: color-mix(in srgb, var(--brand) 15%, transparent); color: var(--brand); }

.alert { padding: .7rem .85rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-size: .9rem; }
.alert--bad  { background: var(--bad-bg);  color: var(--bad); }
.alert--warn { background: var(--warn-bg); color: var(--warn); }
.alert--ok   { background: var(--ok-bg);   color: var(--ok); }
.alert--info { background: var(--surface-3); color: var(--text-soft); }

.empty { text-align: center; padding: 2.5rem 1rem; color: var(--text-soft); }
.empty__title { font-size: 1.05rem; font-weight: 650; color: var(--text); margin-bottom: .35rem; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem; z-index: 100;
}
.modal {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto; border: 1px solid var(--border);
}
.modal--wide { max-width: 860px; }
.modal__head {
  padding: .9rem 1.1rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: .75rem;
}
.modal__title { font-size: 1.05rem; font-weight: 650; margin: 0; }
.modal__body { padding: 1.1rem; }
.modal__foot {
  padding: .8rem 1.1rem; border-top: 1px solid var(--border);
  display: flex; gap: .5rem; justify-content: flex-end;
  background: var(--surface-2); position: sticky; bottom: 0;
}
.modal__close {
  margin-left: auto; appearance: none; background: none; border: none;
  cursor: pointer; font-size: 1.25rem; line-height: 1; color: var(--text-soft); padding: .1rem .3rem;
}

.spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid color-mix(in srgb, var(--brand) 30%, transparent);
  border-top-color: var(--brand); border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading { display: flex; align-items: center; justify-content: center; gap: .6rem; padding: 3rem; color: var(--text-soft); }

.muted { color: var(--text-soft); }
.faint { color: var(--text-faint); }
.pos { color: var(--ok); }
.neg { color: var(--bad); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.stack > * + * { margin-top: .75rem; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row--tight { gap: .3rem; }
.grow { flex: 1 1 auto; }

/* Cash-flow month grid: the label column pins while months scroll. */
.cf-grid { overflow-x: auto; }
.cf-grid table { min-width: 1100px; }
.cf-grid th:first-child, .cf-grid td:first-child {
  position: sticky; left: 0; background: var(--surface); z-index: 2; min-width: 270px;
}
.cf-grid th:first-child { z-index: 3; background: var(--surface-2); }
.cf-grid tbody tr:hover td:first-child { background: var(--surface-2); }
.cf-cell { font-variant-numeric: tabular-nums; font-size: .82rem; white-space: nowrap; }
.cf-cell--zero { color: var(--text-faint); }

.sens-grid table { width: auto; min-width: 480px; font-size: .8rem; }
.sens-grid th, .sens-grid td { padding: .3rem .45rem; white-space: nowrap; }
.sens-grid th[scope="row"] { position: sticky; left: 0; background: var(--surface); z-index: 1; }
.sens-grid td.cell { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }.sens-grid td.cell--pos { background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--ok); }
.sens-grid td.cell--neg { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); }
.sens-grid td.cell--base { outline: 2px solid var(--brand); outline-offset: -2px; }

.bar { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.bar__fill { height: 100%; background: var(--brand); }
.bar__fill--warn { background: var(--warn); }
.bar__fill--bad { background: var(--bad); }

/* --------------------------------------------------------------------------
   Landing
   -------------------------------------------------------------------------- */

.landing { min-height: 100vh; display: flex; flex-direction: column; }
.landing__hero {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 3rem 1.25rem;
  background:
    radial-gradient(circle at 20% 15%, color-mix(in srgb, var(--brand) 16%, transparent), transparent 45%),
    radial-gradient(circle at 80% 85%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 45%),
    var(--bg);
}
.landing__inner { max-width: 720px; text-align: center; }
.landing__title { font-size: clamp(1.9rem, 5vw, 2.8rem); letter-spacing: -.02em; margin-bottom: .75rem; }
.landing__lede { font-size: 1.1rem; color: var(--text-soft); margin-bottom: 1.75rem; }
.landing__actions { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; margin-bottom: 2.5rem; }
.landing__actions .btn { padding: .6rem 1.3rem; font-size: 1rem; }
.landing__points {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem; text-align: left; margin-top: 1rem;
}
.landing__point {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem;
}
.landing__point h3 { font-size: .95rem; margin-bottom: .3rem; }
.landing__point p { margin: 0; font-size: .88rem; color: var(--text-soft); }
.landing__foot { padding: 1.25rem; text-align: center; color: var(--text-faint); font-size: .8rem; }

/* --------------------------------------------------------------------------
   Phone
   -------------------------------------------------------------------------- */

@media (max-width: 767.98px) {
  .app-main { padding: .85rem; }
  .app-header__inner { padding: .55rem .85rem; gap: .5rem; }
  .app-nav { width: 100%; margin-left: 0; }
  .hero { padding: .9rem; }
  .hero__actions { margin-left: 0; width: 100%; }
  .tiles { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .5rem; }
  .tile__value { font-size: 1.2rem; }
  .card { padding: .8rem; }
  .auth-row { grid-template-columns: 1fr; gap: 0; }
  .modal__foot { flex-direction: column-reverse; }
  .modal__foot .btn { width: 100%; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
