/* ============================================================
   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: 100dvh; overflow: hidden; }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  position: fixed; left: 0; top: 0; height: 100dvh; 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;
  display: flex; align-items: center; gap: 12px;
}
.toast-msg { flex: 1; }
.toast-close {
  flex-shrink: 0; background: none; border: none; cursor: pointer; padding: 0;
  font-size: 20px; line-height: 1; color: inherit; opacity: .7;
  width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
}
.toast-close:hover { opacity: 1; }
.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; }

/* ── Hamburger button (mobile only, hidden on desktop) ───── */
.topbar-hamburger {
  display: none;
  width: 44px; height: 44px; flex-shrink: 0;
  align-items: center; justify-content: center;
  background: none; border: none;
  color: var(--text); cursor: pointer;
  border-radius: 8px; margin-right: 4px; padding: 0;
}
.topbar-hamburger:hover { background: var(--bg); }

/* ── Mobile sidebar backdrop ─────────────────────────────── */
.sidebar-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(28,18,8,0.5); z-index: 299;
}
.sidebar-backdrop.visible { display: block; }

/* ── 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 becomes off-canvas overlay — transform is reliable, doesn't fight left:0 */
  .sidebar {
    width: 240px !important;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 300; box-shadow: none;
    overscroll-behavior: contain;
    padding-top: max(0px, env(safe-area-inset-top)) !important;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 6px 0 32px rgba(28,18,8,0.3);
  }
  /* Body scroll lock while drawer is open */
  body.sidebar-open { overflow: hidden; }
  /* Force labels/layout visible inside the overlay regardless of collapsed state */
  .sidebar .sidebar-label    { max-width: none !important; opacity: 1 !important; overflow: visible !important; }
  .sidebar .sidebar-nav      { padding: 16px 10px !important; }
  .sidebar .nav-item         { justify-content: flex-start !important; gap: 12px !important; padding: 10px 12px !important; border-left: 3px solid transparent !important; }
  .sidebar .nav-item.active  { border-left-color: var(--accent) !important; }
  .sidebar .nav-item-soon    { justify-content: flex-start !important; gap: 12px !important; padding: 10px 12px !important; }
  .sidebar .sidebar-logo     { justify-content: flex-start !important; padding: 24px 20px 20px !important; }
  .sidebar .sidebar-footer   { padding: 16px 16px 20px !important; }
  .sidebar .sidebar-divider  { opacity: 1 !important; height: 14px !important; margin: 4px 0 !important; }
  .sidebar .sidebar-farm-name { display: block !important; }
  /* BARB drawer full-width on mobile */
  .fl-drawer { width: 100vw !important; }

  /* Main fills full viewport — no sidebar offset */
  .main                   { margin-left: 0 !important; overflow-x: hidden; }
  .main.sidebar-animating { transition: none; }

  /* Hide desktop collapse toggle, show hamburger */
  .sidebar-toggle    { display: none !important; }
  .topbar-hamburger  { display: flex !important; }

  /* Hide org name in topbar to save space — hamburger takes that slot */
  .topbar-farm { display: none; }

  /* Tighter padding on mobile + safe-area top for notch/Dynamic Island */
  .topbar  { padding: 0 12px; padding-top: env(safe-area-inset-top, 0px); min-height: 60px; height: auto; }
  .content { padding: 16px 12px 104px; }

  /* Grid adjustments */
  .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; }

  /* ── 16px inputs everywhere — prevents iOS zoom on focus ── */
  .form-input, .form-select, .form-textarea { font-size: 16px !important; }

  /* ── Topbar mobile layout ── */
  .topbar-page-title {
    display: block !important;
    font-family: var(--font-head); font-size: 17px; font-weight: 600;
    color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    flex: 1; min-width: 0;
  }
  /* Avatar moves to drawer — hide from topbar */
  .topbar-right .user-avatar { display: none !important; }
  /* Messages button hidden on mobile (low-freq action) */
  .topbar-right #topbar-msgs-btn { display: none !important; }

  /* ── BARB topbar button ── */
  #topbar-barb-slot { display: flex !important; }
  .barb-topbar-btn {
    width: 44px; height: 44px; border-radius: 50%;
    border: 2px solid var(--accent); background: #F6EFDF;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; flex-shrink: 0;
    transition: background .15s;
    color: var(--accent);
  }
  .barb-topbar-btn:hover { background: #F0E6D0; }

  /* ── Topbar: hide desktop dropdowns, show context pills instead ── */
  .topbar-center { display: none !important; }
  #topbar-trial-pill { display: none !important; }

  /* ── Mobile context pills (#mob-ctx-pills) — crop year + entity ── */
  #mob-ctx-pills {
    display: flex; align-items: center; gap: 5px; flex-shrink: 0;
    margin-right: 4px;
  }
  .mob-ctx-pill {
    display: flex; align-items: center;
    background: rgba(200,169,110,.14); border: 1px solid rgba(200,169,110,.35);
    border-radius: 999px; padding: 5px 10px; cursor: pointer;
    font-family: var(--font-mono); font-size: 11px; font-weight: 500;
    color: var(--accent); min-height: 34px; white-space: nowrap;
    max-width: 96px; overflow: hidden;
  }
  .mob-pill-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mob-ctx-filter-icon {
    display: flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 50%; border: none;
    background: rgba(200,169,110,.14); color: var(--accent); cursor: pointer; flex-shrink: 0;
  }

  /* ── Mobile dashboard: show #mob-this-year, hide all desktop-only sections ── */
  #mob-this-year           { display: block !important; }
  .dash-main .dash-two-col   { display: none !important; }
  .dash-main .dash-three-col { display: none !important; }
  .dash-main #alerts-section { display: none !important; }
  #season-progress-section { display: none !important; }
  #activity-section        { display: none !important; }

  /* ── Hide FDS band on mobile — unreadable on small screens ── */
  #fds-band { display: none !important; }
  #fds-nudge { display: none !important; }

  /* ── Prevent any content from causing horizontal scroll ── */
  body { overflow-x: hidden; }

  /* ── BARB floating FAB — hidden on mobile (topbar button takes over) ── */
  #fl-fab { display: none !important; }

  /* ── Sidebar mobile header (avatar + wordmark) ── */
  .sidebar-mobile-header {
    display: flex !important;
  }
  /* Hide the static logo on mobile — mobile header replaces it */
  .sidebar .sidebar-logo { display: none !important; }

  /* ── Sidebar entity footer (shown mobile only) ── */
  .sidebar-entity-footer { display: flex !important; }

  /* ── Sidebar safe-area bottom padding ── */
  .sidebar-footer { padding-bottom: calc(16px + env(safe-area-inset-bottom)) !important; }

  /* ── Bottom-sheet modal override ── */
  /* Excluded: gs-modal-overlay (onboarding, full-screen)
               fds-overlay (FDS/setup modal, full-screen)
               import-wizard-overlay (CSV import wizard, full-screen) */
  /* #lv-event-modal-overlay and #srm-overlay are excluded — they become full-screen steppers via .lv-mob-step-overlay / .srm-mob-step-overlay */
  [id$="-overlay"]:not(#gs-modal-overlay, #fds-overlay, #import-wizard-overlay, #lv-event-modal-overlay, #srm-overlay) {
    align-items: flex-end !important;
    padding: 0 !important;
  }
  [id$="-overlay"]:not(#gs-modal-overlay, #fds-overlay, #import-wizard-overlay, #lv-event-modal-overlay, #srm-overlay) > *:first-child {
    border-radius: 18px 18px 0 0 !important;
    max-height: 88dvh !important;
    max-width: 100% !important;
    width: 100% !important;
    overflow-y: auto !important;
    padding-bottom: max(16px, env(safe-area-inset-bottom)) !important;
    will-change: transform;
  }
  [id$="-overlay"]:not(#gs-modal-overlay, #fds-overlay, #import-wizard-overlay, #lv-event-modal-overlay, #srm-overlay) > *:first-child::before {
    content: '';
    display: block;
    width: 40px; height: 4px;
    background: var(--border-mid);
    border-radius: 2px;
    margin: 12px auto 4px;
    flex-shrink: 0;
  }

  /* ── Left-panel pages: flip layout + show pill bar ── */
  .rpt-layout, .qb-layout, .ff-layout-wrap, .lv-shell-wrap, .la-layout {
    flex-direction: column !important;
  }
  /* Settings uses CSS grid — collapse to single column when nav is hidden */
  .stg-shell { grid-template-columns: 1fr !important; }
  .rpt-left, .qb-left, #ff-nav, #lv-nav, .stg-nav, #la-nav { display: none !important; }
  .mobile-pill-bar { display: flex !important; }

  /* grain-marketing: column layout + hide left panel + show mobile stats strip */
  .grain-layout { flex-direction: column !important; }
  .grain-left { display: none !important; }
  .gm-mob-stats { display: flex !important; }
  /* pill buttons also get gm-nav-item active class — override sidebar active style */
  .mobile-pill.gm-nav-item.active {
    background: var(--sage) !important; color: white !important;
    border-color: var(--sage) !important; border-left-width: 1.5px !important;
  }

  /* Cash Flow Budget: prevent iOS Safari flex+overflow clipping on the chart wrap */
  .cfb-wrap { overflow-y: visible !important; padding: 16px 14px !important; }

  /* input-inventory: column layout + hide left panel */
  .in-layout { flex-direction: column !important; }
  #in-left { display: none !important; }

  /* Entity chip shown on mobile inside filter bars */
  .entity-chip { display: inline-flex !important; }
}

/* ── Topbar page title (desktop: hidden) ── */
@media (min-width: 701px) { .topbar-page-title { display: none; } }

/* ── Mobile context pills (desktop: hidden) ── */
@media (min-width: 701px) { #mob-ctx-pills { display: none; } }

/* ── BARB topbar button slot (desktop: hidden) ── */
@media (min-width: 701px) { #topbar-barb-slot { display: none; } }

/* ── Sidebar mobile header (desktop: hidden) ── */
.sidebar-mobile-header {
  display: none;
  align-items: center; gap: 12px;
  padding: 18px 20px 16px;
  border-bottom: 1px solid rgba(200,169,110,.15);
  text-decoration: none; cursor: pointer;
}
.sidebar-mobile-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent); color: var(--sidebar);
  font-family: var(--font-head); font-weight: 700; font-size: 15px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.sidebar-mobile-wordmark {
  font-family: var(--font-head); font-size: 15px; font-weight: 700;
  color: var(--accent); line-height: 1.1;
}
.sidebar-mobile-orgname {
  font-size: 11px; color: rgba(200,169,110,.7); margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── Sidebar entity footer (desktop: hidden) ── */
.sidebar-entity-footer {
  display: none;
  align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid rgba(200,169,110,.15);
  flex-shrink: 0;
}
.sidebar-entity-footer-label {
  font-size: 11px; color: rgba(200,169,110,.6); text-transform: uppercase;
  letter-spacing: 0.06em; font-weight: 600;
}
.sidebar-entity-chip-btn {
  display: flex; align-items: center; gap: 5px;
  background: rgba(200,169,110,.12); border: 1px solid rgba(200,169,110,.3);
  border-radius: 20px; padding: 5px 10px;
  color: var(--accent); font-size: 12px; font-weight: 500;
  cursor: pointer; font-family: var(--font-body);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px;
}
.sidebar-entity-chip-btn:hover { background: rgba(200,169,110,.2); }

/* ── Entity chip (list-screen filter rows) ── */
.entity-chip {
  display: none; /* shown at ≤700px only */
  align-items: center; gap: 5px;
  background: #FBF6EA; border: 1.5px solid var(--accent);
  border-radius: 20px; padding: 5px 12px;
  color: #8B6B2E; font-size: 13px; font-weight: 500;
  cursor: pointer; font-family: var(--font-body); flex-shrink: 0;
  white-space: nowrap;
}
.entity-chip:hover { background: #F5EDD6; }

/* ── Entity picker bottom sheet ── */
.entity-picker-overlay {
  position: fixed; inset: 0; z-index: 10500;
  background: rgba(28,18,8,.45);
  display: flex; align-items: flex-end;
}
.entity-picker-sheet {
  width: 100%; background: white;
  border-radius: 18px 18px 0 0;
  max-height: 80dvh; overflow-y: auto;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}
.entity-picker-handle {
  width: 40px; height: 4px; background: var(--border-mid);
  border-radius: 2px; margin: 12px auto 4px;
}
.entity-picker-title {
  font-family: var(--font-head); font-size: 18px; font-weight: 700;
  color: var(--text); padding: 8px 20px 16px;
  border-bottom: 1px solid var(--border); margin-bottom: 4px;
}
.entity-picker-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 20px; min-height: 48px; cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.entity-picker-row:hover { background: var(--bg); }
.entity-picker-row.active { background: rgba(61,92,66,.06); }
.entity-picker-radio {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--border-mid); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.entity-picker-row.active .entity-picker-radio {
  border-color: var(--sage); background: var(--sage);
}
.entity-picker-row.active .entity-picker-radio::after {
  content: ''; width: 8px; height: 8px; border-radius: 50%; background: white;
}
.entity-picker-name { font-size: 15px; font-weight: 500; color: var(--text); }
.entity-picker-desc { font-size: 12px; color: var(--text-muted); margin-top: 1px; }

/* ── Mobile pill bar (left-panel pages) ── */
.mobile-pill-bar {
  display: none; /* shown at ≤700px only */
  overflow-x: auto; gap: 8px; padding: 10px 12px;
  background: white; border-bottom: 1px solid var(--border-mid);
  flex-shrink: 0; -webkit-overflow-scrolling: touch; scrollbar-width: none;
  align-items: center;
}
.mobile-pill-bar::-webkit-scrollbar { display: none; }
.mobile-pill {
  padding: 6px 14px; border: 1.5px solid var(--border-mid);
  border-radius: 999px; font-size: 13px; white-space: nowrap;
  cursor: pointer; color: var(--text-muted); background: white;
  font-family: var(--font-body); flex-shrink: 0; transition: background .1s, color .1s, border-color .1s;
}
.mobile-pill:hover { background: var(--bg); color: var(--text); }
.mobile-pill.active { background: var(--sage); color: white; border-color: var(--sage); }
.mobile-pill-divider {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-muted); white-space: nowrap; padding: 0 4px; flex-shrink: 0;
  opacity: .6;
}

/* ── Left-panel page layout wrappers (for pill-bar flip) ── */
.ff-layout-wrap { display: flex; flex: 1; overflow: hidden; }
.lv-shell-wrap  { display: flex; flex: 1; overflow: hidden; }

/* ── 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); }

/* ══ Quick Log FAB + speed dial (mobile only, rendered via isMobile()) ═══ */
.ql-backdrop {
  position: fixed; inset: 0; background: rgba(28,18,8,.45);
  z-index: 7900; display: none; touch-action: none;
}
.ql-backdrop.open { display: block; }
.ql-fab {
  position: fixed; right: 20px;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--sage); border: none; cursor: pointer;
  z-index: 8001; box-shadow: 0 4px 18px rgba(61,92,66,.40);
  display: flex; align-items: center; justify-content: center;
  transition: transform .22s ease;
}
.ql-fab.open { transform: rotate(45deg); }
.ql-fab svg { width: 28px; height: 28px; flex-shrink: 0; }
.ql-dial {
  position: fixed; right: 20px;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px) + 70px);
  z-index: 8000; display: flex; flex-direction: column-reverse; gap: 14px;
  opacity: 0; pointer-events: none;
  transform: translateY(10px);
  transition: opacity .18s ease, transform .18s ease;
}
.ql-dial.open { opacity: 1; pointer-events: auto; transform: translateY(0); }
.ql-item { display: flex; align-items: center; gap: 10px; justify-content: flex-end; }
.ql-item-label {
  background: white; border-radius: 999px;
  padding: 8px 16px; font-size: 14px; font-family: var(--font-body);
  color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,.13);
  white-space: nowrap; line-height: 1.2;
}
.ql-item-btn {
  width: 46px; height: 46px; border-radius: 50%; background: white; border: none;
  cursor: pointer; font-size: 20px; display: flex; align-items: center;
  justify-content: center; box-shadow: 0 2px 8px rgba(0,0,0,.13); flex-shrink: 0;
}

/* ══ Mobile full-screen stepper shell ══════════════════════════════════════ */
/* Applied to #frm-overlay + #frm-modal by JS on mobile                      */
@media (max-width: 700px) {
  .frm-mob-overlay {
    background: none !important;
    padding: 0 !important;
    align-items: stretch !important;
    justify-content: stretch !important;
  }
  .frm-mob-overlay #frm-modal {
    border-radius: 0 !important;
    max-width: none !important;
    max-height: none !important;
    height: 100dvh !important;
  }
  /* Stepper progress dots */
  .frm-step-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: rgba(200,169,110,.3); display: inline-block;
    transition: background .2s;
  }
  .frm-step-dot.active { background: #C8A96E; }

  /* 48px field rows in mobile stepper */
  #frm-field-list .frm-field-row { min-height: 48px !important; }

  /* Inputs always 16px on mobile to prevent iOS auto-zoom */
  .frm-mob-overlay input,
  .frm-mob-overlay select,
  .frm-mob-overlay textarea { font-size: 16px !important; }

  /* Hide FAB while stepper is open */
  body.frm-stepper-open .ql-fab { display: none !important; }

  /* Type card: tighter padding on mobile */
  #frm-body .frm-type-card { font-size: 12px; padding: 12px 8px !important; }

  /* ── Field Records mobile card list ──────────────────────────── */
  .fr-desktop-header { display: none !important; }
  #ops-list .fr-row    { display: none !important; }
  #btn-log-op { display: none !important; }

  .fr-mob-card {
    display: flex; flex-direction: column; gap: 6px;
    padding: 14px 16px; background: white;
    border-bottom: 1px solid var(--border); cursor: pointer;
  }
  .fr-mob-card:active { background: #FDF8F2; }
  .fr-mob-card-top {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
  }
  .fr-mob-card-headline {
    font-size: 15px; font-weight: 600; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .fr-mob-card-sub {
    font-size: 13px; color: var(--text-muted);
  }
  .fr-mob-card-bottom {
    display: flex; align-items: center; justify-content: space-between;
  }
  .fr-mob-card-cost {
    font-size: 13px; font-family: var(--font-mono); color: var(--text-muted);
  }
  .fr-mob-card-arrow {
    font-size: 13px; color: var(--text-muted);
  }
  .fr-mob-date {
    font-size: 12px; font-family: var(--font-mono); color: var(--text-muted);
    white-space: nowrap;
  }

  /* Hide desktop page header on mobile — topbar already shows page title */
  #fr-page-header { display: none !important; }
  /* Mobile filter row: search input + filter button */
  #filter-bar { padding: 10px 16px !important; background: white; border-bottom: 1px solid var(--border); flex-shrink: 0; }

  /* FAB clearance for inner scroll containers that override .content padding */
  #ops-list, .rpt-right, .qb-center, #ff-content, #la-main, .stg-main, .grain-center, #in-center { padding-bottom: 104px; }
  #lv-panel { padding-bottom: 104px !important; }

  /* Mobile filters bottom sheet */
  #fr-filters-sheet {
    position: fixed; inset: 0; z-index: 8500;
    display: flex; flex-direction: column; justify-content: flex-end;
  }
  #fr-filters-sheet-backdrop {
    position: absolute; inset: 0; background: rgba(28,18,8,.45);
  }
  #fr-filters-sheet-panel {
    position: relative; background: white;
    border-radius: 18px 18px 0 0; max-height: 88dvh;
    display: flex; flex-direction: column; overflow: hidden;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  #fr-filters-sheet-handle {
    width: 40px; height: 4px; border-radius: 2px;
    background: var(--border-mid); margin: 10px auto 0;
  }
  #fr-filters-sheet-body { flex: 1; overflow-y: auto; padding: 16px; }
  #fr-filters-sheet-footer {
    padding: 12px 16px; border-top: 1px solid var(--border);
    display: flex; gap: 10px;
    padding-bottom: max(env(safe-area-inset-bottom, 0px), 12px);
  }

  /* Field record detail view — slide-up sheet on mobile */
  #fr-detail-overlay {
    align-items: flex-end !important;
    padding: 0 !important;
  }
  #fr-detail-modal {
    max-width: 100% !important;
    max-height: 92dvh !important;
    border-radius: 18px 18px 0 0 !important;
    box-shadow: 0 -4px 32px rgba(28,18,8,.18) !important;
  }
  .fr-detail-drag-handle {
    width: 36px; height: 4px; border-radius: 2px;
    background: rgba(255,255,255,.35); margin: 0 auto 10px;
  }
  #fr-detail-modal > div:first-child { border-radius: 18px 18px 0 0 !important; }
  /* Hide print/export on mobile detail */
  #fr-detail-print, #fr-detail-export { display: none !important; }
  /* Footer: safe-area bottom padding */
  #fr-detail-modal > div:last-child {
    padding-bottom: max(env(safe-area-inset-bottom, 0px), 16px) !important;
  }
}

/* ══ Phase 3: tables→cards, dashboard reorder, QB, planning ════════════════ */
@media (max-width: 700px) {

  /* ── Dashboard: block layout — desktop grid sections are all hidden on mobile ── */
  .dash-main { display: block !important; }

  /* ── Alerts: stacked full-width rows (was 3-col grid) ────────────────── */
  .alerts-grid { grid-template-columns: 1fr !important; gap: 6px !important; }

  /* ── Grain position: per-crop mini-cards (collapse subgrid) ──────────── */
  .grain-grid    { display: block !important; }
  .grain-hdr-row { display: none !important; }
  .grain-row {
    display: grid !important; grid-column: unset !important;
    grid-template-columns: 1fr 1fr !important;
    padding: 10px 14px !important; gap: 2px 12px;
    border-bottom: 1px solid var(--border);
  }
  .grain-row > div { padding: 2px 0 !important; white-space: normal !important; }
  /* Crop name: full width */
  .grain-row > div:first-child  { grid-column: 1 / -1; font-weight: 600; font-size: 14px; }
  /* Planned acres: hidden on mobile (too noisy) */
  .grain-row > div:nth-child(2) { display: none !important; }
  /* Avg price: left col, Unpriced bu: right col */
  .grain-row > div:nth-child(3),
  .grain-row > div:nth-child(4) { font-size: 13px; }
  .grain-row > div:nth-child(4) { text-align: right; }
  /* Value today: full width, muted */
  .grain-row > div:nth-child(5) { grid-column: 1 / -1; font-size: 12px; color: var(--text-muted) !important; }
  .grain-footer { margin: 8px 14px 12px !important; }

  /* ── Equipment: two-panel → single-column full-width ────────────────── */
  .eq-page { height: auto !important; overflow: visible !important; }
  #eq-panel-layout  { flex-direction: column !important; overflow: visible !important; height: auto !important; flex: none !important; }
  #eq-left-panel    { width: 100% !important; border-right: none !important; border-bottom: none !important; overflow: visible !important; flex: none !important; }
  #eq-grid-scroll   { overflow-y: visible !important; padding: 10px !important; padding-bottom: 104px !important; }
  /* Right panel hidden on mobile — no detail pane, cards are self-contained */
  #eq-right-panel   { display: none !important; }
  /* Page header: hide desktop Add button (FAB handles it), smaller title, allow wrap */
  #btn-add-equipment { display: none !important; }
  .eq-page h1 { font-size: 20px !important; }
  /* Tab strip + Form 4562 link: tab strip full width, hide report link on mobile */
  #eq-tabs { overflow-x: auto !important; scrollbar-width: none; gap: 4px !important; flex-wrap: nowrap !important; -webkit-overflow-scrolling: touch; }
  #eq-tabs::-webkit-scrollbar { display: none; }
  .eq-page > div:nth-child(2) > a[href="/reports"] { display: none !important; }

  /* ── Livestock: .lv-table rows → card list ───────────────────────────── */
  .lv-table           { border-collapse: collapse !important; width: 100% !important; }
  .lv-table thead     { display: none !important; }
  .lv-table tbody tr  { display: block !important; border-bottom: 8px solid var(--bg) !important; background: white; }
  .lv-table tbody tr td {
    display: flex !important; align-items: center !important;
    justify-content: space-between !important;
    padding: 8px 14px !important; border-bottom: 1px solid var(--border) !important;
    font-size: 13px !important;
  }
  .lv-table tbody tr td:first-child { font-weight: 600 !important; padding: 11px 14px !important; font-size: 14px !important; }
  .lv-table tbody tr td:last-child  { border-bottom: none !important; }
  .lv-table tbody tr td[colspan]    { justify-content: center !important; font-weight: normal !important; }
  /* Remove overflow clip on the wrapper div so row gaps show */
  :has(> .lv-table) { overflow: visible !important; border-radius: 0 !important; }

  /* ── Contacts: mobile card list (rendered by isMobile() JS branch) ────── */
  .ct-mob-card {
    display: flex; flex-direction: column; gap: 5px;
    padding: 13px 16px; background: white;
    border-bottom: 1px solid var(--border); cursor: pointer;
  }
  .ct-mob-card:active { background: #FDF8F2; }
  .ct-mob-card-name {
    font-size: 15px; font-weight: 600; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .ct-mob-card-loc  { font-size: 12px; color: var(--text-muted); }
  .ct-mob-card-row  { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
  .ct-mob-card-meta { font-size: 12px; font-family: var(--font-mono); color: var(--text-muted); }

  /* ── Contacts: two-panel → mobile layout ── */
  .ct-left { display: none !important; }
  .ct-center { padding-bottom: 104px !important; }
  #ct-mob-controls { display: flex !important; flex-direction: column; background: white; border-bottom: 1px solid var(--border); flex-shrink: 0; }
  .ct-mob-top-row { display: flex; align-items: center; gap: 8px; padding: 10px 12px; }

  /* ── Inventory products: mobile card list (rendered by isMobile() JS) ── */
  .inv-mob-card {
    display: flex; flex-direction: column; gap: 6px;
    padding: 13px 16px; background: white;
    border-bottom: 1px solid var(--border); cursor: pointer;
  }
  .inv-mob-card:active { background: #FDF8F2; }
  .inv-mob-card.low-stock { border-left: 3px solid var(--rust); }
  .inv-mob-card-top  { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
  .inv-mob-card-name { font-size: 15px; font-weight: 600; color: var(--text); flex: 1; }
  .inv-mob-card-row  { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
  .inv-mob-card-qty  { font-family: var(--font-mono); font-size: 13px; color: var(--text); }
  .inv-mob-card-val  { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }

  /* ── QuickBooks: compact sync strip ─────────────────────────────────── */
  .qb-conn-status-card { padding: 8px 12px !important; gap: 6px !important; border-radius: 8px !important; flex-wrap: wrap !important; }
  .qb-conn-company     { font-size: 12px !important; }
  .qb-conn-status-left { gap: 5px !important; }
  #ov-remap-btn        { display: none !important; }
  .qb-filter-bar       { gap: 8px !important; }
  .qb-filter-select    { font-size: 16px !important; flex: 1; min-width: 130px; }

  /* ── Planning: left nav → horizontal pill row, page scrolls naturally ── */
  /* Break fixed height/overflow from plan-shell page <style> so page scrolls */
  .main:has(.plan-shell) { overflow-y: auto !important; }
  .plan-shell { height: auto !important; overflow: visible !important; }
  .plan-body { flex-direction: column !important; overflow: visible !important; height: auto !important; }
  .plan-nav {
    width: auto !important; flex-direction: row !important;
    border-right: none !important; border-bottom: 1px solid var(--border-mid) !important;
    overflow-x: auto !important; -webkit-overflow-scrolling: touch;
    padding: 8px 10px !important; flex-shrink: 0 !important; gap: 6px !important;
    scrollbar-width: none; height: auto !important;
  }
  .plan-nav::-webkit-scrollbar { display: none; }
  .plan-nav-item {
    width: auto !important; text-align: left !important; white-space: nowrap !important;
    border-radius: 999px !important; padding: 6px 14px !important;
    border: 1.5px solid var(--border-mid) !important; flex-shrink: 0 !important;
    background: white !important; color: var(--text-muted) !important;
  }
  .plan-nav-item.active { background: var(--sage) !important; color: white !important; border-color: var(--sage) !important; }
  .plan-work { overflow: visible !important; height: auto !important; padding-bottom: 104px !important; }
  /* Section header rows inside plan-work: wrap so title and CTA button don't overlap */
  .plan-view-hdr { flex-wrap: wrap !important; gap: 8px !important; }
  .purch-header  { flex-wrap: wrap !important; gap: 8px !important; }

  /* ── Planning: sensitivity matrix → horizontal scroll, sticky row label ─ */
  .price-matrix-wrap { overflow-x: auto !important; -webkit-overflow-scrolling: touch; padding: 12px !important; }
  .price-matrix-table { min-width: 340px; }
  .price-matrix-table th.row-label,
  .price-matrix-table td.row-label { position: sticky; left: 0; background: white; z-index: 1; box-shadow: 2px 0 4px rgba(0,0,0,.06); }
}

/* ── 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; }

/* ══ Phase 4: Livestock Event + Service Record steppers ════════════════════ */
@media (max-width: 700px) {
  /* Full-screen stepper overrides — same pattern as .frm-mob-overlay */
  .lv-mob-step-overlay, .srm-mob-step-overlay {
    background: none !important;
    padding: 0 !important;
    align-items: stretch !important;
    justify-content: stretch !important;
  }
  .lv-mob-step-overlay > *:first-child,
  .srm-mob-step-overlay > *:first-child {
    border-radius: 0 !important;
    max-width: none !important;
    max-height: none !important;
    height: 100dvh !important;
    width: 100% !important;
    overflow-y: visible !important; /* body child handles scroll */
    padding-bottom: 0 !important;
    will-change: unset;
  }
  .lv-mob-step-overlay > *:first-child::before,
  .srm-mob-step-overlay > *:first-child::before { display: none !important; }

  /* Hide FAB while steppers are open */
  body.lv-event-stepper-open .ql-fab,
  body.srm-stepper-open .ql-fab { display: none !important; }

  /* Stepper: 48px event-type and group card rows */
  .lv-step-type-card { min-height: 80px; }
  .lv-step-group-row, .srm-step-eq-row { min-height: 48px; }

  /* 16px inputs inside steppers (iOS zoom prevention) */
  .lv-mob-step-overlay input,
  .lv-mob-step-overlay select,
  .lv-mob-step-overlay textarea,
  .srm-mob-step-overlay input,
  .srm-mob-step-overlay select,
  .srm-mob-step-overlay textarea { font-size: 16px !important; }

  /* Stepper: 2×2 grids stack to 1-col on narrow */
  .lv-step-type-grid { grid-template-columns: 1fr 1fr !important; }
  .srm-step-detail-grid { grid-template-columns: 1fr !important; }
}

/* ══ Phase 4: Land Agreements mobile ══════════════════════════════════════ */
@media (max-width: 700px) {
  /* Stat grid 2-col */
  .la-stat-grid { grid-template-columns: 1fr 1fr !important; gap: 8px !important; }

  /* Detail tabs → horizontally scrolling row */
  .la-tabs {
    overflow-x: auto !important; flex-wrap: nowrap !important;
    border-bottom-width: 1px !important;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .la-tabs::-webkit-scrollbar { display: none; }
  .la-tab { white-space: nowrap; flex-shrink: 0; padding: 10px 16px !important; min-height: 44px; display: flex; align-items: center; }

  /* Agreement card grid → 1-col */
  .la-card-grid { grid-template-columns: 1fr !important; }

  /* Detail header: stack on narrow */
  .la-detail-header { flex-direction: column !important; gap: 10px; }
  .la-detail-title { font-size: 18px; }

  /* Tables → card list via data-label display */
  .la-table { border-collapse: collapse !important; width: 100% !important; }
  .la-table thead { display: none !important; }
  .la-table tbody tr {
    display: block !important; background: white;
    border-bottom: 8px solid var(--bg) !important;
    border-radius: 8px; margin-bottom: 0;
  }
  .la-table tbody tr td {
    display: flex !important; align-items: center !important;
    justify-content: space-between !important;
    padding: 9px 14px !important; border-bottom: 1px solid var(--border) !important;
    font-size: 13px !important;
  }
  .la-table tbody tr td:first-child { font-weight: 600 !important; font-size: 14px !important; }
  .la-table tbody tr td:last-child { border-bottom: none !important; }
  .la-table tbody tr td::before {
    content: attr(data-label);
    font-size: 11px; font-weight: 700; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; margin-right: 8px;
  }
  .la-table tbody tr td:first-child::before { display: none; }

  /* Terms table: stack rows */
  .la-terms-table td { display: block !important; padding: 6px 14px !important; }
  .la-terms-table td:first-child { font-size: 11px; padding-bottom: 2px !important; }

  /* Calc box: full width */
  .la-calc-box { margin: 8px 0 !important; }

  /* Filter bar wraps nicely */
  .la-filter-bar { flex-wrap: wrap !important; }

  /* Ensure la-main scrolls properly in column layout */
  #la-main { overflow-y: auto !important; flex: 1; }

  /* 16px inputs in land-agreement modals */
  .modal-overlay input, .modal-overlay select, .modal-overlay textarea { font-size: 16px !important; }
}

/* ══ Phase 4: Advisor Dashboard mobile ════════════════════════════════════ */
@media (max-width: 700px) {
  /* Body becomes a single-column flex */
  body:has(.adv-sidebar) { display: flex !important; flex-direction: column !important; height: 100dvh; overflow: hidden; }

  /* Sidebar → off-canvas drawer */
  .adv-sidebar {
    position: fixed !important; left: 0; top: 0; bottom: 0;
    width: 220px !important; height: 100dvh !important;
    z-index: 8100; overflow-y: auto;
    transform: translateX(-100%);
    transition: transform .22s ease;
    will-change: transform;
  }
  .adv-sidebar.mobile-open { transform: translateX(0) !important; }

  /* Main fills full viewport */
  .adv-main { flex: 1; overflow: hidden; min-width: 0; width: 100%; }

  /* Topbar: add space for hamburger */
  .adv-topbar { padding-left: 50px !important; position: relative; }

  /* Content grid → single column */
  .adv-content { grid-template-columns: 1fr !important; overflow-y: auto !important; }

  /* Task queue full-width */
  .adv-panel { min-height: 0 !important; }

  /* Backdrop */
  .adv-mob-backdrop {
    position: fixed; inset: 0; background: rgba(28,18,8,.45);
    z-index: 8050; display: none;
  }
  .adv-mob-backdrop.visible { display: block; }

  /* Hamburger button */
  .adv-mob-ham {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    background: none; border: none; cursor: pointer;
    color: var(--adv-brown-200); padding: 4px; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    width: 44px; height: 44px;
  }
}

/* ══ Phase 4: Touch-target audit (44px minimum) ════════════════════════════ */
@media (max-width: 700px) {
  /* Pill bar buttons */
  .mobile-pill { min-height: 44px; display: inline-flex !important; align-items: center; }

  /* Modal close / back / nav buttons */
  .modal-close, #frm-close, #frm-back, #frm-next, #frm-save, #frm-cancel { min-height: 44px; min-width: 44px; }

  /* Sidebar nav items */
  .sidebar .nav-item, .sidebar .nav-item-soon { min-height: 44px !important; }

  /* Quick Log dial items */
  .ql-item-btn { min-height: 44px; min-width: 44px; }
}

/* ══ Grower/Farm/Fields: tree-primary drill-down ══════════════════════════ */
@media (max-width: 700px) {
  /* Stack tree above (hidden) center panel; .gff-layout still fills viewport via flex:1 */
  .gff-layout { flex-direction: column !important; }

  /* Tree panel → full-width, takes all remaining height, tree-body scrolls inside it */
  .tree-panel {
    width: 100% !important; flex: 1 !important;
    border-right: none !important; border-bottom: none !important;
  }
  /* Tap target sizing */
  .tree-node { min-height: 44px !important; }
  .tree-hdr-btn { min-height: 44px !important; padding: 0 12px !important; }
  .tree-search { font-size: 16px !important; min-height: 44px !important; }

  /* Center panel: hidden initially; shown full-height via .gff-mob-active when node tapped */
  .center-panel { display: none !important; }
  .center-panel.gff-mob-active {
    display: block !important; flex: 1 !important;
    overflow-y: auto !important; padding: 0 0 104px !important; min-height: 0;
  }
  /* Content wrapper inside active center panel */
  .gff-mob-content { padding: 14px 14px 0; }
  .tree-panel.gff-mob-hidden { display: none !important; }

  /* Mobile back button prepended to center panel by JS */
  .gff-mob-back {
    display: flex !important; align-items: center; gap: 8px; width: 100%;
    min-height: 44px; padding: 10px 16px; flex-shrink: 0;
    background: var(--sidebar); color: var(--accent);
    border: none; border-bottom: 2px solid rgba(200,169,110,.2); cursor: pointer;
    font-family: var(--font-body); font-size: 14px; font-weight: 500; text-align: left;
  }

  /* Stat grids: 4-col → 2-col */
  .cp-stats  { grid-template-columns: repeat(2,1fr) !important; }
  .cp-stats-3 { grid-template-columns: repeat(2,1fr) !important; }
}

/* ══ Context panel — right-slide crop year + entity picker (mobile v3) ══════ */
#ctx-backdrop {
  position: fixed; inset: 0; background: rgba(28,18,8,.45);
  z-index: 400; opacity: 0; pointer-events: none;
  transition: opacity .22s ease;
}
#ctx-backdrop.open { opacity: 1; pointer-events: auto; }
#ctx-panel {
  position: fixed; top: 0; right: -88vw; width: 88vw; height: 100dvh;
  z-index: 401; background: white;
  box-shadow: -4px 0 24px rgba(28,18,8,.18);
  transition: right .25s cubic-bezier(.4,0,.2,1);
  display: flex; flex-direction: column; overflow: hidden;
}
#ctx-panel.open { right: 0; }
.ctx-panel-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 14px;
  padding-top: max(16px, env(safe-area-inset-top, 16px));
  background: var(--sidebar); color: white; flex-shrink: 0;
}
.ctx-panel-title { font-family: var(--font-head); font-size: 17px; font-weight: 600; }
.ctx-panel-close {
  width: 36px; height: 36px; border-radius: 50%; background: rgba(255,255,255,.12);
  border: none; color: white; font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.ctx-panel-body { overflow-y: auto; flex: 1; }
.ctx-section { padding: 18px 16px 10px; }
.ctx-section-label {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .12em;
  color: var(--text-muted); margin-bottom: 12px;
}
.ctx-year-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.ctx-year-pill {
  background: var(--bg); border: 1px solid var(--border-mid); border-radius: 999px;
  padding: 9px 16px; font-size: 14px; font-family: var(--font-body);
  color: var(--text); cursor: pointer; min-height: 44px;
  transition: background .14s, color .14s, border-color .14s;
}
.ctx-year-pill.active { background: var(--accent); color: white; border-color: var(--accent); }
.ctx-divider { height: 1px; background: var(--border); margin: 4px 16px; }
.ctx-entity-row {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 16px; border-bottom: 1px solid var(--border);
  cursor: pointer; min-height: 48px;
}
.ctx-entity-radio {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--border-mid); flex-shrink: 0;
  position: relative; transition: border-color .14s;
}
.ctx-entity-row.active .ctx-entity-radio {
  border-color: var(--sage);
}
.ctx-entity-row.active .ctx-entity-radio::after {
  content: ''; position: absolute; inset: 3px; border-radius: 50%;
  background: var(--sage);
}
.ctx-entity-name { font-size: 15px; color: var(--text); }
.ctx-entity-row.active .ctx-entity-name { font-weight: 600; color: var(--sage); }

/* ══ Mobile dashboard — #mob-this-year section ═══════════════════════════════ */
#mob-this-year { display: none; } /* shown on mobile via @media rule above */
.mob-skel { background: linear-gradient(90deg,#f0ebe0 25%,#e8e0d0 50%,#f0ebe0 75%); background-size: 200% 100%; animation: mob-skel-shimmer 1.4s infinite; }
@keyframes mob-skel-shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }
.mob-card {
  background: white; border-radius: 12px; box-shadow: 0 1px 4px rgba(28,18,8,.08);
  margin-bottom: 12px; overflow: hidden;
}
.mob-card-hdr {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .12em;
  color: var(--text-muted); padding: 12px 14px 8px;
  border-bottom: 1px solid var(--border);
}
.mob-alerts-card .mob-alert-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  text-decoration: none; color: var(--text); min-height: 44px;
}
.mob-alerts-card .mob-alert-row:last-child { border-bottom: none; }
.mob-alert-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.mob-alert-text { flex: 1; font-size: 13.5px; line-height: 1.3; }
.mob-stats-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1px;
  background: var(--border);
}
.mob-stat {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 14px 8px; background: white; text-align: center;
}
.mob-stat-val {
  font-family: var(--font-mono); font-size: 16px; font-weight: 600;
  color: var(--text); line-height: 1.2;
}
.mob-stat-lbl { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

/* ── Mobile position card ───────────────────────────────────────── */
.mob-pos-row { padding: 11px 14px; border-bottom: 1px solid var(--border); }
.mob-pos-row:last-child { border-bottom: none; }
.mob-pos-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 7px; }
.mob-pos-crop { font-size: 14px; font-weight: 600; color: var(--text); }
.mob-pos-price { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }
.mob-pos-bar-wrap { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-bottom: 5px; }
.mob-pos-bar-fill { height: 100%; background: var(--sage); border-radius: 3px; transition: width .4s ease; }
.mob-pos-meta { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); margin-bottom: 2px; }
.mob-pos-unpriced { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); margin-top: 1px; }

/* ── Mobile benchmarks card ─────────────────────────────────────── */
.mob-bench-row { padding: 12px 14px; }
.mob-bench-label { font-size: 11px; color: var(--text-muted); margin-bottom: 3px; }
.mob-bench-val { font-family: var(--font-mono); font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.mob-bench-bar { height: 5px; background: var(--border); border-radius: 3px; position: relative; overflow: visible; margin-bottom: 4px; }
.mob-bench-fill { height: 100%; border-radius: 3px; }
.mob-bench-pin { position: absolute; top: -3px; width: 2px; height: 11px; background: var(--text); border-radius: 1px; transform: translateX(-50%); }
.mob-bench-range { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 9px; color: var(--text-muted); }

/* ── Mobile cash flow widget ─────────────────────────────────────── */
.mob-cfb-footer { display: flex; border-top: 1px solid var(--border); }
.mob-cfb-stat { flex: 1; padding: 10px 14px; }
.mob-cfb-stat + .mob-cfb-stat { border-left: 1px solid var(--border); }
.mob-cfb-stat-lbl { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 2px; }
.mob-cfb-stat-val { font-family: var(--font-mono); font-size: 15px; font-weight: 600; }

/* ── Mobile weather card ─────────────────────────────────────────── */
.mob-wx-today { display: flex; align-items: center; gap: 12px; padding: 12px 14px 8px; }
.mob-wx-icon-lg { font-size: 36px; flex-shrink: 0; line-height: 1; }
.mob-wx-today-temp { font-family: var(--font-mono); font-size: 18px; font-weight: 700; color: var(--text); }
.mob-wx-today-cond { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.mob-wx-spray { margin-left: auto; text-align: right; flex-shrink: 0; }
.mob-wx-strip { display: flex; gap: 0; border-top: 1px solid var(--border); overflow-x: auto; }
.mob-wx-day { flex: 1; min-width: 46px; text-align: center; padding: 8px 2px; border-right: 1px solid var(--border); }
.mob-wx-day:last-child { border-right: none; }
.mob-wx-day-today { background: #FBF6EA; }
.mob-wx-day-today .mob-wx-day-lbl { color: var(--accent-dark); font-weight: 700; }
.mob-wx-day-lbl { font-family: var(--font-mono); font-size: 9px; color: var(--text-muted); letter-spacing: .06em; margin-bottom: 3px; }
.mob-wx-day-icon { font-size: 18px; line-height: 1; margin-bottom: 3px; }
.mob-wx-day-hi { font-family: var(--font-mono); font-size: 12px; font-weight: 600; color: var(--text); }
.mob-wx-day-lo { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.mob-wx-day-precip { font-size: 10px; margin-top: 2px; }
.mob-wx-day-prob { font-size: 9px; color: var(--text-muted); margin-top: 1px; }
.mob-wx-foot { padding: 8px 14px; border-top: 1px solid var(--border); font-size: 11px; color: var(--text-muted); text-align: center; }

/* ── Markets mobile page ─────────────────────────────────────────── */
.mkt-empty-state { padding: 24px 14px; text-align: center; }
.mkt-empty-icon { font-size: 32px; margin-bottom: 8px; }
.mkt-empty-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.mkt-empty-body { font-size: 12px; color: var(--text-muted); line-height: 1.5; }
.mkt-crop-row { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.mkt-crop-row:last-of-type { border-bottom: none; }
.mkt-crop-name { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.mkt-crop-stats { display: flex; flex-wrap: wrap; gap: 6px; }
.mkt-stat-chip { font-family: var(--font-mono); font-size: 11px; background: var(--bg); border: 1px solid var(--border-mid); border-radius: 6px; padding: 3px 7px; color: var(--text-muted); }

/* ── Livestock mobile cards ──────────────────────────────────────── */
@media (max-width: 700px) {
  .lv-mob-wd-strip {
    display: flex; gap: 10px; align-items: flex-start;
    background: #FEF0EC; border: 1px solid #F5C4B3;
    border-radius: 10px; padding: 12px 14px; margin: 10px 12px 4px;
  }
  .lv-mob-wd-title { font-weight: 600; font-size: 13px; color: #8B3A1D; margin-bottom: 3px; }
  .lv-mob-wd-detail { font-size: 11px; color: #993C1D; line-height: 1.5; }
  .lv-mob-group-card {
    background: white; border: 1px solid var(--border); border-radius: 10px;
    margin-bottom: 8px; padding: 12px 14px;
  }
  .lv-mob-group-hdr { display: flex; align-items: flex-start; gap: 10px; }
  .lv-mob-group-name { font-size: 14px; font-weight: 600; color: var(--text); }
  .lv-mob-group-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
  .lv-mob-group-head { font-family: var(--font-mono); font-size: 22px; font-weight: 700; color: var(--text); flex-shrink: 0; }
  .lv-mob-group-meta { font-size: 11px; color: var(--text-muted); margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border); }
  .lv-mob-event-card {
    background: white; border: 1px solid var(--border); border-radius: 10px;
    margin-bottom: 8px; padding: 11px 14px;
  }
  .lv-mob-event-hdr { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
  .lv-mob-event-date { font-size: 12px; color: var(--text-muted); font-family: var(--font-mono); margin-left: auto; }
  .lv-mob-event-body { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
  .lv-mob-event-group { font-size: 13px; font-weight: 500; color: var(--text); flex: 1; }
  .lv-mob-event-count { font-size: 12px; color: var(--text-muted); font-family: var(--font-mono); }
  .lv-mob-event-amt { font-size: 13px; font-weight: 600; color: var(--sage); font-family: var(--font-mono); }
  .lv-mob-event-detail { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
}

/* ── Inventory mobile header + stats ─────────────────────────────── */
@media (max-width: 700px) {
  .mob-list-hdr {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 12px 8px; flex-shrink: 0;
  }
  .mob-type-sel {
    flex-shrink: 0; width: auto; font-size: 13px; padding: 6px 8px;
    border: 1.5px solid var(--border-mid); border-radius: 8px; background: white;
  }
  .mob-inv-stats {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
    padding: 0 12px 10px;
  }
  .mob-inv-stat {
    background: white; border: 1px solid var(--border); border-radius: 10px;
    padding: 10px 14px; display: flex; flex-direction: column; gap: 2px;
  }
  .mob-low-val { color: #EF4444; }
  .mob-low-dot {
    display: inline-block; width: 8px; height: 8px; border-radius: 50%;
    background: #EF4444; margin-right: 5px; flex-shrink: 0; vertical-align: middle;
  }
  .mob-qty-low { color: #EF4444; font-weight: 600; }
}

/* ── Equipment mobile cards + service history ────────────────────── */
@media (max-width: 700px) {
  .eq-mob-card {
    background: white; border: 1px solid var(--border); border-radius: 10px;
    margin-bottom: 8px; overflow: hidden;
  }
  .eq-mob-card-due { border-color: #FDBA74; }
  .eq-mob-card-body { padding: 12px 14px 8px; cursor: pointer; }
  .eq-mob-card-hdr { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 2px; }
  .eq-mob-name { font-size: 14px; font-weight: 600; color: var(--text); flex: 1; line-height: 1.3; }
  .eq-mob-status { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 20px; flex-shrink: 0; }
  .eq-mob-sub { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
  .eq-mob-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
  .eq-mob-svc-due {
    font-size: 11px; font-weight: 700; color: #B45309;
    background: #FEF3C7; padding: 2px 8px; border-radius: 20px;
  }
  .eq-mob-ytd { font-size: 11px; color: var(--rust); font-family: var(--font-mono); }
  .eq-mob-card-foot {
    border-top: 1px solid var(--border); padding: 8px 14px;
    display: flex; align-items: center; justify-content: space-between;
  }
  .eq-mob-log-btn {
    font-size: 13px; font-weight: 600; color: var(--sage);
    background: none; border: 1.5px solid var(--sage); border-radius: 999px;
    padding: 5px 14px; cursor: pointer; font-family: var(--font-body);
  }
  .eq-mob-log-btn:active { background: var(--sage); color: white; }
  .eq-mob-hist-lnk { font-size: 13px; color: var(--accent); cursor: pointer; font-weight: 500; }
  .eq-mob-back {
    display: flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600;
    color: var(--accent); background: none; border: none; padding: 10px 12px 6px;
    cursor: pointer; font-family: var(--font-body);
  }
  .eq-mob-svc-hdr {
    display: flex; align-items: center; justify-content: space-between;
    padding: 4px 12px 10px; border-bottom: 1px solid var(--border-mid); margin-bottom: 10px;
  }
  .eq-mob-svc-name { font-size: 16px; font-weight: 700; font-family: var(--font-head); }
  .eq-mob-svc-row {
    display: grid; grid-template-columns: 90px 1fr auto; gap: 8px;
    align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border);
    min-height: 44px;
  }
  .eq-mob-svc-row:last-child { border-bottom: none; }
  .eq-mob-svc-date { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
  .eq-mob-svc-desc { font-size: 13px; color: var(--text); line-height: 1.3; }
  .eq-mob-svc-cost { font-family: var(--font-mono); font-size: 13px; font-weight: 600; color: var(--rust); text-align: right; }
}

/* ── QBO mobile segmented control ────────────────────────────────── */
@media (max-width: 700px) {
  #qb-pill-bar { padding: 0; gap: 0; border-bottom: none; }
  .mob-seg-btn {
    flex: 1; padding: 8px 4px; border: none; border-radius: 0; background: transparent;
    font-size: 13px; font-family: var(--font-body); color: var(--text-muted);
    cursor: pointer; white-space: nowrap; border-bottom: 2px solid transparent;
    transition: color .15s, border-color .15s;
  }
  .mob-seg-btn.active { color: var(--sage); border-bottom-color: var(--sage); font-weight: 600; }
  .mob-seg-btn:not(.active):hover { color: var(--text); }
  .mob-qb-sync-strip {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 16px 8px; border-bottom: 1px solid var(--border-mid);
    background: var(--bg); flex-shrink: 0;
  }
  .mob-qb-sync-info { font-size: 12px; color: var(--text-muted); }
  .mob-qb-sync-btn {
    font-size: 12px; font-family: var(--font-body); padding: 5px 12px;
    border: 1.5px solid var(--sage); border-radius: 999px; background: transparent;
    color: var(--sage); cursor: pointer; font-weight: 600; flex-shrink: 0;
  }
  .mob-qb-sync-btn:active { background: var(--sage); color: white; }
}

/* ══ Phase 4: prefers-reduced-motion ══════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  /* FAB rotate + dial slide */
  .ql-fab, .ql-dial, .ql-item, .ql-backdrop { transition: none !important; animation: none !important; }
  .ql-fab.open { transform: rotate(45deg); } /* keep visual state, just no animation */

  /* Stepper progress dots */
  .frm-step-dot, .lv-step-dot, .srm-step-dot { transition: none !important; }

  /* Sidebar drawer slide */
  .sidebar, .adv-sidebar { transition: none !important; }
  .sidebar-backdrop { transition: none !important; }

  /* Context panel slide */
  #ctx-panel { transition: none !important; }
  #ctx-backdrop { transition: none !important; }
  .ctx-year-pill { transition: none !important; }
  .ctx-entity-radio { transition: none !important; }

  /* Pill hover */
  .mobile-pill, .pill-opt, .btn { transition: none !important; }

  /* Bottom-sheet will-change cleanup */
  [id$="-overlay"] > *:first-child { will-change: auto !important; }

  /* Page crossfade: disable for reduced-motion users */
  ::view-transition-old(root),
  ::view-transition-new(root) { animation-duration: 0.001s; }
}
