/* ============================================================
   TallyAg Design System — Full Component Library
   ============================================================ */

/* Self-hosted fonts — eliminates ~14 cross-origin requests per page load */
@font-face {
  font-family: 'DM Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/dm-mono-400-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'DM Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/dm-mono-400.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'DM Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/dm-mono-500-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'DM Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/dm-mono-500.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'DM Sans';
  font-style: normal;
  font-weight: 300 600;
  font-display: swap;
  src: url('/fonts/dm-sans-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'DM Sans';
  font-style: normal;
  font-weight: 300 600;
  font-display: swap;
  src: url('/fonts/dm-sans.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Playfair Display';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/playfair-italic-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Playfair Display';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/playfair-italic.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Playfair Display';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/playfair-normal-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Playfair Display';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/playfair-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

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

/* ── Tokens ──────────────────────────────────────────────── */
:root {
  --bg:            #FAF7F2;
  --sidebar:       #2C1810;
  --sidebar-hover: #3a2015;
  --sidebar-w:     232px;
  --accent:        #C8A96E;
  --accent-dark:   #a98c52;
  --sage:          #3D5C42;
  --sage-bg:       #EBF2EC;
  --rust:          #C4622D;
  --rust-bg:       #FAEEE7;
  --text:          #1C1208;
  --text-muted:    #6B5A3E;
  --border:        #C8BFAE;
  --border-mid:    #A89880;
  --card-bg:       #FFFFFF;
  --font-head:     'Playfair Display', Georgia, serif;
  --font-body:     'DM Sans', system-ui, sans-serif;
  --font-mono:     'DM Mono', 'Courier New', monospace;
  --radius:        12px;
  --radius-sm:     8px;
  --shadow:        0 1px 4px rgba(44,24,16,.06), 0 4px 16px rgba(44,24,16,.06);
  --shadow-sm:     0 1px 3px rgba(44,24,16,.08);
}

html, body {
  height: 100%;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Typography ──────────────────────────────────────────── */
h1, h2, h3, .heading { font-family: var(--font-head); }
.mono { font-family: var(--font-mono); }
.text-muted { color: var(--text-muted); }
.text-sage  { color: var(--sage); }
.text-rust  { color: var(--rust); }
.text-accent{ color: var(--accent); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 10px 20px; border: none; border-radius: var(--radius-sm);
  font-family: var(--font-body); font-size: 14px; font-weight: 500;
  cursor: pointer; text-decoration: none; transition: all .15s; white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary  { background: var(--sidebar); color: var(--accent); font-weight: 600; }
.btn-primary:hover:not(:disabled)  { background: #3a2015; transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-secondary { background: white; color: var(--text); border: 1px solid var(--border-mid); }
.btn-secondary:hover:not(:disabled){ background: var(--bg); }
.btn-accent { background: var(--accent); color: var(--sidebar); font-weight: 600; }
.btn-accent:hover:not(:disabled)   { background: var(--accent-dark); }
.btn-text   { background: none; color: var(--text-muted); font-size: 13px; padding: 8px 12px; }
.btn-text:hover { color: var(--text); }
.btn-sm     { padding: 7px 14px; font-size: 13px; }
.btn-lg     { padding: 13px 28px; font-size: 15px; }
.btn-full   { width: 100%; }
.btn-icon   { padding: 8px; border-radius: 6px; background: none; border: none; cursor: pointer;
              color: var(--text-muted); transition: all .15s; }
.btn-icon:hover { background: var(--border); color: var(--text); }

/* ── Forms ───────────────────────────────────────────────── */
.form-group   { display: flex; flex-direction: column; gap: 6px; }
.form-row     { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-label   { font-size: 13px; font-weight: 500; color: var(--text); }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 10px 14px; border: 1px solid #A89880;
  border-radius: var(--radius-sm); background: white; color: var(--text);
  font-family: var(--font-body); font-size: 14px; transition: border-color .15s;
  outline: none;
}
.form-input::placeholder, .form-textarea::placeholder { color: #B5A088; }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: #8B7355; box-shadow: 0 0 0 3px rgba(200,169,110,.15);
}
.form-input.error, .form-select.error { border-color: var(--rust); }
.form-textarea { resize: vertical; min-height: 90px; }
.form-error   { font-size: 12px; color: var(--rust); display: flex; align-items: center; gap: 4px; }
.form-error::before { content: '⚠'; font-size: 11px; }
.form-hint    { font-size: 12px; color: var(--text-muted); }

/* checkbox */
.checkbox-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border: 1.5px solid var(--border-mid); border-radius: var(--radius-sm);
  cursor: pointer; transition: all .15s; background: white;
}
.checkbox-item:hover { border-color: var(--accent); background: #fdf9f3; }
.checkbox-item input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }
.checkbox-item span { font-size: 13px; font-weight: 400; }
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; padding: 3px 10px;
  border-radius: 20px; font-size: 12px; font-weight: 500; white-space: nowrap;
}
.badge-default  { background: var(--border); color: var(--text-muted); }
.badge-sage     { background: var(--sage-bg); color: var(--sage); }
.badge-rust     { background: var(--rust-bg); color: var(--rust); }
.badge-accent   { background: rgba(200,169,110,.18); color: #8a6a2a; }
.badge-soil     { background: var(--sidebar); color: var(--accent); }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--card-bg); border-radius: var(--radius);
  border: 1px solid var(--border); box-shadow: 0 2px 8px rgba(44,24,16,0.08), 0 1px 2px rgba(44,24,16,0.04); overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; border-bottom: 1px solid var(--border);
}
.card-header-soil {
  background: var(--sidebar); color: var(--accent);
  padding: 14px 20px; display: flex; align-items: center; justify-content: space-between;
}
.card-header-soil .card-title { color: var(--accent); font-size: 15px; }
.card-header-soil .btn-text   { color: rgba(200,169,110,.7); font-size: 13px; }
.card-header-soil .btn-text:hover { color: var(--accent); }
.card-title  { font-family: var(--font-head); font-size: 17px; font-weight: 600; color: var(--text); }
.card-body   { padding: 20px 24px; }
.card-footer { padding: 14px 24px; border-top: 1px solid var(--border); background: var(--bg); }

/* ── Modal Shadow ────────────────────────────────────────── */
.modal { box-shadow: 0 8px 32px rgba(44,24,16,0.16), 0 2px 8px rgba(44,24,16,0.08); }

/* ── Divider ──────────────────────────────────────────────── */
.divider { display: flex; align-items: center; gap: 12px; color: var(--text-muted); font-size: 13px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border-mid); }

/* ── Progress Bar (onboarding) ───────────────────────────── */
.progress-bar {
  display: flex; gap: 6px; margin-bottom: 40px;
}
.progress-step {
  flex: 1; height: 4px; border-radius: 2px; background: var(--border-mid);
  transition: background .3s;
}
.progress-step.active   { background: var(--accent); }
.progress-step.complete { background: var(--sage); }
.progress-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.progress-label { font-size: 13px; color: var(--text-muted); }
.progress-count { font-size: 13px; color: var(--text-muted); font-family: var(--font-mono); }

/* ── Auth Layout ─────────────────────────────────────────── */
.auth-page {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 32px 16px;
  background: var(--bg);
}
.auth-card {
  width: 100%; max-width: 460px; background: white;
  border-radius: var(--radius); border: 1px solid var(--border);
  box-shadow: var(--shadow); overflow: hidden;
}
.auth-card-header {
  padding: 32px 36px 28px; text-align: center; border-bottom: 1px solid var(--border);
}
.auth-brand {
  font-family: var(--font-head); font-size: 32px; font-weight: 700;
  color: var(--sidebar); letter-spacing: .02em; display: block; margin-bottom: 6px;
}
.auth-brand-cfo { color: var(--accent); }
.auth-tagline { font-size: 14px; color: var(--text-muted); }
.auth-card .btn-primary { background: var(--accent); color: var(--sidebar); }
.auth-card .btn-primary:hover:not(:disabled) { background: var(--accent-dark); color: var(--sidebar); transform: translateY(-1px); box-shadow: var(--shadow); }
.auth-card-body { padding: 28px 36px; display: flex; flex-direction: column; gap: 18px; }
.auth-card-footer { padding: 18px 36px; border-top: 1px solid var(--border); text-align: center; background: var(--bg); }
.auth-footer-text { font-size: 13px; color: var(--text-muted); }
.auth-footer-text a { color: var(--accent); font-weight: 500; text-decoration: none; }
.auth-footer-text a:hover { text-decoration: underline; }
.auth-error {
  padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--rust-bg); border: 1px solid rgba(196,98,45,.2);
  color: var(--rust); font-size: 13px; display: none;
}
.auth-error.visible { display: block; }
.auth-forgot { font-size: 13px; color: var(--text-muted); text-align: right; text-decoration: none; }
.auth-forgot:hover { color: var(--accent); }

/* ── Onboarding Layout ───────────────────────────────────── */
.onboarding-page {
  min-height: 100vh; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; padding: 40px 24px;
}
.onboarding-inner { width: 100%; max-width: 760px; }
.onboarding-logo {
  font-family: var(--font-head); font-size: 22px; font-weight: 700;
  color: var(--accent); margin-bottom: 36px; display: block; text-align: center;
}
.onboarding-heading { font-family: var(--font-head); font-size: 28px; font-weight: 700; margin-bottom: 8px; }
.onboarding-sub    { font-size: 15px; color: var(--text-muted); margin-bottom: 32px; line-height: 1.5; }
.onboarding-card   { background: white; border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); padding: 32px; }
.onboarding-actions{
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--border);
}
.skip-link { font-size: 13px; color: var(--text-muted); text-decoration: none; }
.skip-link:hover { color: var(--text); }

/* ── Operation Type Cards ────────────────────────────────── */
.op-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px;
}
.op-card {
  display: flex; flex-direction: column; gap: 6px;
  padding: 16px 18px; border: 2px solid var(--border-mid); border-radius: var(--radius);
  cursor: pointer; transition: all .15s; background: white; user-select: none;
}
.op-card:hover  { border-color: var(--accent); background: #fdf9f3; }
.op-card.selected {
  background: var(--sidebar); border-color: var(--accent); color: var(--accent);
}
.op-card.selected .op-card-desc { color: rgba(200,169,110,.7); }
.op-card-icon  { font-size: 22px; }
.op-card-label { font-weight: 600; font-size: 14px; }
.op-card-desc  { font-size: 12px; color: var(--text-muted); line-height: 1.4; }

/* ── Two-Option Expand Cards (fields) ────────────────────── */
.option-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.option-card  {
  border: 2px solid var(--border-mid); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; transition: border-color .15s;
}
.option-card.active { border-color: var(--accent); cursor: default; }
.option-card-header {
  padding: 16px 20px; display: flex; align-items: center; justify-content: space-between;
}
.option-card-label { font-weight: 600; font-size: 15px; }
.option-card-desc  { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.option-card-body  { padding: 0 20px 20px; display: none; }
.option-card.active .option-card-body { display: block; }

/* ── Drop Zone ───────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--accent); border-radius: var(--radius);
  padding: 40px 24px; text-align: center; cursor: pointer; transition: all .15s;
  background: rgba(200,169,110,.04);
}
.drop-zone:hover, .drop-zone.dragover { background: rgba(200,169,110,.1); }
.drop-zone-icon  { font-size: 32px; margin-bottom: 10px; }
.drop-zone-text  { font-size: 14px; color: var(--text-muted); }
.drop-zone-text strong { color: var(--accent); }

/* ── Mapping Table ───────────────────────────────────────── */
.mapping-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 16px; }
.mapping-table th {
  text-align: left; padding: 8px 12px; border-bottom: 2px solid var(--border-mid);
  font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em;
}
.mapping-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.mapping-table tr:last-child td { border-bottom: none; }
.mapping-table select { border: 1px solid var(--border-mid); border-radius: 6px; padding: 5px 8px; font-size: 13px; background: white; outline: none; }

/* ── Field Cards ─────────────────────────────────────────── */
.field-cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 20px; }
.field-card {
  background: white; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; position: relative;
}
.field-card-name  { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.field-card-acres { font-family: var(--font-mono); font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }
.field-card-badges{ display: flex; flex-wrap: wrap; gap: 6px; }
.field-card-actions { position: absolute; top: 12px; right: 12px; display: flex; gap: 4px; }

/* ── Preview Table ───────────────────────────────────────── */
.preview-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 12px; }
.preview-table th {
  text-align: left; padding: 8px 10px; background: var(--sidebar);
  color: var(--accent); font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .05em;
}
.preview-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); }
.preview-table tr:last-child td { border-bottom: none; }
.preview-table tr.row-error td { background: var(--rust-bg); color: var(--rust); }
.preview-table-wrap { max-height: 280px; overflow-y: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); }

/* ── App Shell ───────────────────────────────────────────── */
.app-shell { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  position: fixed; left: 0; top: 0; height: 100vh; z-index: 100;
  width: var(--sidebar-w);
  background: var(--sidebar); display: flex; flex-direction: column;
  padding: 0; overflow-y: auto; overflow-x: hidden;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(200,169,110,.15);
}
.logo-text {
  font-family: var(--font-head); font-size: 22px; font-weight: 700;
  color: var(--accent); letter-spacing: .01em;
}
.sidebar-nav   { padding: 16px 10px; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border-radius: var(--radius-sm); color: var(--accent); text-decoration: none;
  font-size: 13px; font-weight: 400; transition: background .15s; border-left: 3px solid transparent;
}
.nav-item:hover  { background: rgba(200,169,110,.12); color: var(--accent); }
.nav-item.active { background: rgba(200,169,110,.15); color: var(--accent); font-weight: 500; border-left-color: var(--accent); }
.nav-icon  { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-label { flex: 1; }
.sidebar-footer {
  padding: 16px 16px 20px; border-top: 1px solid rgba(200,169,110,.15);
}
.sidebar-user-name  { font-size: 13px; font-weight: 500; color: rgba(255,255,255,.9); }
.sidebar-user-email { font-size: 12px; color: rgba(255,255,255,.45); margin-top: 2px; }
.sidebar-signout {
  display: inline-block; margin-top: 8px; font-size: 12px;
  color: rgba(200,169,110,.6); text-decoration: none; cursor: pointer; background: none; border: none; padding: 0;
}
.sidebar-signout:hover { color: var(--accent); }

/* ── Sidebar label (collapsible text) ───────────────────── */
.sidebar-label {
  overflow: hidden;
  white-space: nowrap;
  transition: opacity 0.15s ease;
}

/* ── Sidebar collapsed state ─────────────────────────────── */
.sidebar.collapsed { width: 56px; }
.sidebar.collapsed .sidebar-label        { max-width: 0; }
.sidebar.collapsed .sidebar-nav          { padding-left: 0; padding-right: 0; }
.sidebar.collapsed .nav-item             { justify-content: center; gap: 0; padding-left: 0; padding-right: 0; }
.sidebar.collapsed .nav-item-soon        { justify-content: center; gap: 0; padding-left: 0; padding-right: 0; }
.sidebar.collapsed .sidebar-logo         { justify-content: center; padding-left: 0; padding-right: 0; }
.sidebar.collapsed .sidebar-footer       { padding: 10px 0; }
.sidebar.collapsed .sidebar-divider      { opacity: 0; height: 0; margin: 0; }
.sidebar.collapsed .sidebar-farm-name   { padding: 0; border-bottom: none; margin: 0; }

/* Main area offset tracks sidebar width; animates only on explicit toggle click */
.sidebar.collapsed ~ .main { margin-left: 56px; }
.main.sidebar-animating    { transition: margin-left 0.2s ease; }

/* ── Sidebar toggle button ───────────────────────────────── */
.sidebar-toggle {
  position: fixed;
  top: 70px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: white;
  border: 1px solid #A89880;
  color: #2C1810;
  box-shadow: 0 1px 4px rgba(44,24,16,0.15);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; line-height: 1;
  z-index: 150;
  padding: 0;
  user-select: none;
}
.sidebar-toggle:hover { background: var(--bg); border-color: #8B7355; }

/* ── Sidebar nav tooltip (collapsed state) ───────────────── */
.sidebar-nav-tooltip {
  position: fixed;
  background: white;
  border: 1px solid #A89880;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(44,24,16,0.12);
  font-family: var(--font-body);
  font-size: 12px; font-weight: 500;
  color: #1C1208;
  padding: 5px 10px;
  pointer-events: none;
  z-index: 500;
  opacity: 0;
  transition: opacity 0.1s ease;
  white-space: nowrap;
}
.sidebar-nav-tooltip.visible { opacity: 1; }

/* ── No-transition helper (prevents flash on page load) ─── */
/* Transitions only fire when user explicitly clicks the toggle — never on page load */
.sidebar.sidebar-animating         { transition: width 0.2s ease; }
.sidebar-toggle.sidebar-animating  { transition: left  0.2s ease; }

/* ── Main / Topbar ───────────────────────────────────────── */
.main { flex: 1; margin-left: 232px; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; height: 60px; background: white;
  border-bottom: 1px solid var(--border); flex-shrink: 0; gap: 16px;
}
.topbar-farm  { flex: 1; font-family: var(--font-head); font-size: 18px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-center { flex: 0 0 auto; display: flex; justify-content: center; gap: 8px; }
.crop-year-select {
  padding: 6px 28px; border: 1.5px solid var(--border-mid); border-radius: 20px;
  font-family: var(--font-body); font-size: 13px; font-weight: 500; background: white;
  cursor: pointer; outline: none; color: var(--text);
  appearance: none; -webkit-appearance: none;
  text-align: center; text-align-last: center;
}
.crop-year-select:focus { border-color: var(--accent); }
.topbar-right  { flex: 1; display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--sidebar); color: var(--accent);
  font-family: var(--font-head); font-weight: 700; font-size: 15px;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  position: relative;
}
.user-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0; width: 200px;
  background: white; border-radius: var(--radius); border: 1px solid var(--border);
  box-shadow: var(--shadow); z-index: 100; overflow: hidden; display: none;
}
.user-dropdown.open { display: block; }
.user-dropdown-item {
  display: block; padding: 10px 16px; font-size: 13px; color: var(--text);
  text-decoration: none; cursor: pointer; background: none; border: none; width: 100%; text-align: left;
  transition: background .1s;
}
.user-dropdown-item:hover { background: var(--bg); }
.user-dropdown-item.danger { color: var(--rust); }
.topbar-icon-btn {
  position: relative; background: none; border: none; cursor: pointer;
  padding: 6px 8px; border-radius: 8px; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  transition: color .15s, background .15s; flex-shrink: 0;
}
.topbar-icon-btn:hover { color: var(--text); background: rgba(28,18,8,.06); }
.topbar-msgs-dot {
  position: absolute; top: -3px; right: -3px;
  min-width: 18px; height: 18px; padding: 0 5px; box-sizing: border-box;
  border-radius: 9px; background: #EF4444; border: 2px solid white; display: none;
  color: white; font-size: 10px; font-weight: 700; font-family: var(--font-body);
  align-items: center; justify-content: center; line-height: 1;
}
.topbar-msgs-dot.visible {
  display: flex;
  animation: msgs-badge-pulse 2.5s ease-in-out 3;
}
@keyframes msgs-badge-pulse {
  0%, 100% { transform: scale(1); }
  30%       { transform: scale(1.35); }
  60%       { transform: scale(1); }
}
.topbar-trial-pill {
  display: flex; align-items: center; overflow: hidden;
  background: var(--sage); color: #fff; border-radius: 20px;
  font-size: 12px; font-weight: 600; font-family: var(--font-body); white-space: nowrap;
}
.topbar-trial-pill a {
  color: #fff; text-decoration: none; padding: 5px 8px 5px 13px; display: block;
}
.topbar-trial-pill button {
  background: none; border: none; color: #fff; cursor: pointer;
  padding: 5px 11px 5px 4px; font-size: 16px; line-height: 1; opacity: .75;
  display: flex; align-items: center;
}
.topbar-trial-pill button:hover { opacity: 1; }

/* ── Content Area ────────────────────────────────────────── */
.content { flex: 1; overflow-y: auto; padding: 28px 28px 40px; }

/* ── Welcome Banner ──────────────────────────────────────── */
.welcome-banner {
  margin-bottom: 24px;
}
.welcome-heading {
  font-family: var(--font-head); font-size: 26px; font-weight: 700; color: var(--text);
}
.welcome-sub { font-size: 14px; color: var(--text-muted); margin-top: 2px; }

/* ── Stats Grid ──────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: white; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; box-shadow: 0 2px 8px rgba(44,24,16,0.08), 0 1px 2px rgba(44,24,16,0.04);
}
.stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); margin-bottom: 10px; }
.stat-value { font-family: var(--font-head); font-size: 28px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-value.mono { font-family: var(--font-mono); }
.stat-value.sage { color: var(--sage); }
.stat-value.rust { color: var(--rust); }
.stat-sub   { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.stat-action{ font-size: 12px; color: var(--accent); text-decoration: none; margin-top: 6px; display: inline-block; }

/* ── Dashboard Grid ──────────────────────────────────────── */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.dash-card-full { grid-column: 1 / -1; }

/* ── Placeholder Card ────────────────────────────────────── */
.placeholder-body {
  padding: 48px 32px; text-align: center; display: flex;
  flex-direction: column; align-items: center; gap: 16px;
}
.placeholder-icon { font-size: 48px; }
.placeholder-text { font-size: 14px; color: var(--text-muted); max-width: 420px; line-height: 1.6; }

/* ── Transaction Rows ────────────────────────────────────── */
.transaction-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; border-bottom: 1px solid var(--border);
}
.transaction-row:last-child { border-bottom: none; }
.txn-vendor  { font-size: 13px; font-weight: 500; }
.txn-type    { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.txn-right   { text-align: right; }
.txn-amount  { font-family: var(--font-mono); font-size: 13px; font-weight: 500; }
.txn-amount.income  { color: var(--sage); }
.txn-amount.expense { color: var(--rust); }
.txn-date    { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.empty-state { padding: 32px 20px; text-align: center; font-size: 13px; color: var(--text-muted); }

/* ── Alert Rows ──────────────────────────────────────────── */
.alert-row {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}
.alert-row:last-child { border-bottom: none; }
.severity-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 5px;
}
.severity-dot.info     { background: #60A5FA; }
.severity-dot.medium   { background: var(--accent); }
.severity-dot.high     { background: var(--rust); }
.severity-dot.critical { background: #DC2626; }
.alert-title { font-size: 13px; font-weight: 500; }
.alert-time  { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

/* ── Complete Page Cards ─────────────────────────────────── */
.summary-card { background: var(--bg); border-radius: var(--radius); padding: 24px; margin-bottom: 24px; }
.summary-row  { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border-mid); font-size: 14px; }
.summary-row:last-child { border-bottom: none; }
.summary-row-label { color: var(--text-muted); }
.summary-row-value { font-weight: 500; }
.next-steps-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.next-step-card { background: white; border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; text-align: center; }
.next-step-icon { font-size: 32px; margin-bottom: 12px; }
.next-step-title { font-family: var(--font-head); font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.next-step-desc  { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; line-height: 1.5; }

/* ── QBO Connect ─────────────────────────────────────────── */
.qbo-options { display: grid; grid-template-columns: 1fr; gap: 16px; }
.qbo-option-card {
  border: 2px solid var(--border-mid); border-radius: var(--radius);
  padding: 24px; transition: border-color .15s;
}
.qbo-option-card.primary-option { border-color: var(--accent); }
.qbo-option-title { font-family: var(--font-head); font-size: 17px; font-weight: 600; margin-bottom: 6px; }
.qbo-option-desc  { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; }
.qbo-bullets { list-style: none; display: flex; flex-direction: column; gap: 8px; margin-bottom: 24px; }
.qbo-bullets li { font-size: 13px; color: var(--text-muted); display: flex; gap: 8px; }
.qbo-bullets li::before { content: '✓'; color: var(--sage); font-weight: 600; flex-shrink: 0; }
.qbo-divider { text-align: center; padding: 8px 0; font-size: 13px; color: var(--text-muted); position: relative; }
.qbo-divider::before { content: ''; position: absolute; left: 0; top: 50%; right: 0; height: 1px; background: var(--border-mid); }
.qbo-divider span { position: relative; background: var(--bg); padding: 0 12px; }

/* ── Utilities ───────────────────────────────────────────── */
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }
.flex  { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-center { text-align: center; }
.hidden { display: none !important; }
.loading { opacity: .6; pointer-events: none; }

/* ── Spinner ─────────────────────────────────────────────── */
.spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid rgba(200,169,110,.3); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ───────────────────────────────────────────────── */
.toast-container { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 99999; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  padding: 14px 24px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500;
  box-shadow: 0 8px 32px rgba(28,18,8,0.28); animation: toastPop .2s ease; max-width: 420px; text-align: center; pointer-events: auto;
}
.toast-success { background: var(--sidebar); color: var(--accent); }
.toast-error   { background: #991B1B; color: #FFFFFF; }
.toast-warning { background: #92400E; color: #FEF3C7; }
@keyframes toastPop { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: scale(1); } }
.reveal-row { animation: fadeIn 0.2s ease-in; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }

/* ── Nav Soon Badge ──────────────────────────────────────── */
.nav-soon {
  font-size: 10px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  background: rgba(200,169,110,.2); color: rgba(200,169,110,.7);
  padding: 2px 6px; border-radius: 10px; flex-shrink: 0;
}
.nav-item-soon {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border-radius: var(--radius-sm); color: rgba(200,169,110,.45);
  font-size: 13px; font-weight: 400; border-left: 3px solid transparent;
  cursor: default; user-select: none;
}

/* ── Sidebar Farm Name + Divider ─────────────────────────── */
.sidebar-farm-name {
  font-family: var(--font-head); font-size: 12px; color: rgba(200,169,110,.55);
  padding: 0 20px 14px; line-height: 1.3; letter-spacing: .01em;
  border-bottom: 1px solid rgba(200,169,110,.08); margin-bottom: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-divider {
  height: 1px; background: rgba(200,169,110,.12); margin: 8px 10px;
}
.sidebar-switch-account-btn {
  display: block; font-size: 10px; color: rgba(200,169,110,.5); background: none; border: none;
  padding: 0 20px 0; cursor: pointer; text-align: left; letter-spacing: .04em; text-transform: uppercase;
  transition: color .15s;
}
.sidebar-switch-account-btn:hover { color: rgba(200,169,110,.85); }

/* ── Org Switcher Modal ───────────────────────────────────── */
.org-switcher-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 9000;
  display: flex; align-items: center; justify-content: center;
}
.org-switcher-modal {
  background: #fff; border-radius: 14px; width: 420px; max-width: calc(100vw - 32px);
  max-height: 80vh; display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
}
.org-switcher-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 20px 12px;
}
.org-switcher-header h3 {
  margin: 0; font-family: var(--font-head); font-size: 17px; color: var(--text);
}
.org-switcher-header button {
  background: none; border: none; cursor: pointer; color: var(--text-muted);
  font-size: 18px; line-height: 1; padding: 2px 4px;
}
.org-switcher-search {
  padding: 0 16px 12px;
}
.org-switcher-search input {
  width: 100%; box-sizing: border-box; padding: 9px 12px; border: 1px solid var(--border-mid);
  border-radius: 8px; font-size: 13px; color: var(--text); outline: none;
  background: var(--bg);
}
.org-switcher-search input:focus { border-color: var(--sage); }
.org-switcher-list {
  overflow-y: auto; padding: 4px 8px 12px;
}
.org-switcher-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px;
  cursor: pointer; border: none; background: none; width: 100%; text-align: left;
  transition: background .1s;
}
.org-switcher-item:hover { background: var(--bg); }
.org-switcher-item.current { background: rgba(61,92,66,.06); cursor: default; }
.org-switcher-item-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--sidebar);
  color: var(--accent); font-family: var(--font-head); font-weight: 700; font-size: 14px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.org-switcher-item-info { flex: 1; overflow: hidden; }
.org-switcher-item-name { font-size: 14px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.org-switcher-item-sub { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.org-switcher-item-check { color: var(--sage); font-size: 15px; flex-shrink: 0; }

/* ── Module permission locks ─────────────────────────────── */
.nav-item-locked { opacity: 0.45; pointer-events: none !important; cursor: not-allowed !important; }
.nav-lock { font-size: 10px; margin-left: 4px; opacity: 0.8; }

/* View-only mode — disable write action buttons globally */
body.fl-view-only button[disabled][data-fl-disabled],
body.fl-view-only input[type="submit"][disabled][data-fl-disabled] {
  opacity: 0.4; cursor: not-allowed;
}

/* ── Viewing-another-account banner ──────────────────────── */
.viewing-banner {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 7px 20px; flex-shrink: 0;
  background: #FEF3C7; border-bottom: 1px solid #F59E0B;
  font-size: 13px; color: #92400E;
}
.viewing-banner strong { font-weight: 600; }
.viewing-banner-switch {
  background: none; border: 1px solid #F59E0B; border-radius: 12px;
  padding: 2px 10px; font-size: 12px; font-weight: 500; color: #92400E;
  cursor: pointer; font-family: var(--font-body); margin-left: 4px;
  transition: background 0.15s;
}
.viewing-banner-switch:hover { background: rgba(245,158,11,.15); }

/* ── Page Header ─────────────────────────────────────────── */
.page-header  { margin-bottom: 28px; }
.page-title   { font-family: var(--font-head); font-size: 26px; font-weight: 700; }
.page-subtitle{ font-size: 14px; color: var(--text-muted); margin-top: 4px; line-height: 1.5; }

/* ── Module Placeholder (individual pages) ───────────────── */
.module-placeholder {
  display: flex; flex-direction: column; align-items: center;
  padding: 80px 32px; text-align: center; max-width: 540px; margin: 0 auto; gap: 14px;
}
.placeholder-heading {
  font-family: var(--font-head); font-size: 22px; font-weight: 600;
}

/* ── Module Cards Grid (dashboard) ──────────────────────── */
.module-cards-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px;
}
.module-card {
  background: white; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; box-shadow: 0 2px 8px rgba(44,24,16,0.08), 0 1px 2px rgba(44,24,16,0.04); text-decoration: none; color: var(--text);
  display: flex; flex-direction: column; gap: 6px; transition: all .15s;
}
.module-card:hover {
  border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow);
}
.module-card-icon   { font-size: 22px; }
.module-card-title  { font-family: var(--font-head); font-size: 15px; font-weight: 600; }
.module-card-desc   { font-size: 12px; color: var(--text-muted); line-height: 1.5; }
.module-card-action { font-size: 12px; color: var(--accent); margin-top: 4px; font-weight: 500; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 900px) {
  .stats-grid        { grid-template-columns: repeat(2, 1fr); }
  .dash-grid         { grid-template-columns: 1fr; }
  .next-steps-grid   { grid-template-columns: 1fr; }
  .form-row          { grid-template-columns: 1fr; }
  .option-cards      { grid-template-columns: 1fr; }
  .module-cards-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
  .sidebar         { width: 60px; }
  .logo-text, .nav-label, .sidebar-farm-name, .sidebar-user-name, .sidebar-user-email, .sidebar-signout { display: none; }
  .sidebar-logo    { justify-content: center; padding: 20px 0; }
  .nav-item        { justify-content: center; padding: 12px; border-left: none; }
  .nav-item.active { border-left: none; }
  .nav-item-soon   { justify-content: center; padding: 12px; }
  .nav-soon        { display: none; }
  .content         { padding: 20px 16px; }
  .topbar          { padding: 0 16px; }
  .stats-grid      { grid-template-columns: repeat(2, 1fr); }
  .module-cards-grid { grid-template-columns: repeat(2, 1fr); }
  .op-grid         { grid-template-columns: repeat(2, 1fr); }
  .auth-card-body, .auth-card-header, .auth-card-footer { padding-left: 24px; padding-right: 24px; }
}

/* ── Left-panel page nav (Financial Analysis, Livestock, Reports) ── */
.ff-nav-item {
  display: block; padding: 9px 16px; font-size: 13px;
  color: var(--text-muted); cursor: pointer; text-decoration: none;
  border-left: 3px solid transparent;
  transition: background .12s, color .12s; user-select: none;
}
.ff-nav-item:hover  { background: var(--bg); color: var(--text); }
.ff-nav-item.active {
  border-left-color: var(--accent); background: var(--bg);
  color: var(--text); font-weight: 600;
}
.ff-nav-item.disabled {
  color: var(--border-mid); cursor: not-allowed; pointer-events: none;
}
.ff-nav-div {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .09em; color: var(--text);
  padding: 18px 16px 4px; margin-top: 4px;
  border-top: 1px solid var(--border-mid); cursor: default;
}

/* ── Pill option selectors (species, purpose, origin pickers in modals) ── */
.pill-opt {
  padding: 7px 14px; border: 1px solid var(--border-mid);
  background: white; border-radius: 20px; font-size: 12px;
  font-weight: 500; cursor: pointer; color: var(--text-muted);
  font-family: var(--font-body); transition: background .1s, color .1s;
}
.pill-opt:hover:not(.active) { background: var(--bg); }
.pill-opt.active { background: var(--sage); color: white; border-color: var(--sage); }

/* ── Livestock species badges ── */
.badge-livestock-cattle { background: rgba(200,169,110,.18); color: #8a6a2a; }
.badge-livestock-sheep  { background: #E6F1FB; color: #185FA5; }
.badge-livestock-goat   { background: var(--sage-bg); color: var(--sage); }

/* ── Page navigation crossfade (Chrome 126+, Safari 18+) ────── */
/* Replaces the blank-flash between page navigations with a     */
/* smooth 200ms crossfade. No JS required. Falls back to        */
/* standard navigation on unsupported browsers (Firefox).       */
@view-transition {
  navigation: auto;
}
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.2s;
}
/* Sidebar is excluded from the page crossfade — it never flickers or blends states */
.sidebar { view-transition-name: sidebar; }
::view-transition-old(sidebar),
::view-transition-new(sidebar) { animation: none; }
/* In-page left panels (grain-marketing, input-inventory) also excluded —
   their dark headers visually blend with the sidebar during the crossfade */
.grain-left, #in-left { view-transition-name: left-panel; }
::view-transition-old(left-panel),
::view-transition-new(left-panel) { animation: none; }
