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

    :root {
      --bg: #F5F8F2;
      --card: #FFFFFF;
      --border: #E0EBD5;
      --accent: var(--brand-theme, #3A7D30);
      --accent-dim: rgba(58,125,48,0.08);
      --amber: #D4883A;
      --amber-dim: #FEF3E7;
      --text: #1A2D18;
      --muted: #5E7854;
      --muted-light: #8FA882;
      --secondary: #7CB069;
      --input-bg: #FFFFFF;
      --input-border: #C8DBBF;
      --sidebar-bg: #EEF3E8;
      --sidebar-border: #D6E4CC;
      --card-shadow: 0 1px 4px rgba(52,100,38,0.07);
      --sidebar-w: 220px;

      /* ── Radius scale ── */
      --radius-sm: 6px;
      --radius-md: 10px;
      --radius-lg: 14px;
      --radius-xl: 18px;
      --radius-full: 9999px;
    }

    * { scrollbar-width: thin; scrollbar-color: rgba(58,125,48,0.2) transparent; }

    body {
      font-family: 'Inter', system-ui, -apple-system, sans-serif;
      background: var(--bg);
      color: var(--text);
      min-height: 100vh;
      overflow-x: hidden;
      font-size: 13px;
      line-height: 1.5;
    }

    /* ── Sidebar ── */
    .sidebar {
      position: fixed;
      top: 0; left: 0; bottom: 0;
      width: var(--sidebar-w);
      background: var(--sidebar-bg);
      border-right: 1px solid var(--sidebar-border);
      display: flex;
      flex-direction: column;
      z-index: 100;
      padding: 24px 0 0;
      transition: transform 150ms ease;
    }
    .sidebar-brand { padding: 0 20px; margin-bottom: 32px; }
    #sidebarBrandLogo {
      width: 145px;
      height: 48px;
      display: flex;
      align-items: center;
      justify-content: flex-start;
    }
    #sidebarBrandLogo > svg,
    #sidebarBrandLogo > img {
      width: 100%;
      height: 100%;
      display: block;
      object-fit: contain;
      object-position: left center;
    }
    .sidebar-brand-name { font-size: 20px; font-weight: 800; color: var(--accent); letter-spacing: 0.04em; }
    .sidebar-brand-sub { font-size: 11px; color: var(--muted); margin-top: 2px; letter-spacing: 0.02em; }
    .sidebar-section-label {
      font-size: 11px; font-weight: 600; text-transform: uppercase;
      letter-spacing: 0.1em; color: var(--muted-light); padding: 16px 20px 8px;
    }
    .sidebar-nav { list-style: none; }
    .sidebar-nav li a {
      display: flex; align-items: center; gap: 10px;
      padding: 10px 20px; font-size: 13px; font-weight: 500;
      color: var(--muted); text-decoration: none;
      transition: background 200ms cubic-bezier(0.4, 0, 0.2, 1), color 200ms cubic-bezier(0.4, 0, 0.2, 1), border-left-color 200ms cubic-bezier(0.4, 0, 0.2, 1);
      border-left: 3px solid transparent;
    }
    .sidebar-nav li a:hover { color: var(--text); background: rgba(58,125,48,0.05); }
    .sidebar-nav li a.active {
      color: var(--accent); background: rgba(58,125,48,0.10);
      animation: sidebarActivePulse 400ms ease forwards;
    }
    .sidebar-nav li a .nav-icon { display: inline-flex; align-items: center; justify-content: center; width: 20px; flex-shrink: 0; }
    .sidebar-nav li a .nav-icon svg { display: inline-block; vertical-align: middle; flex-shrink: 0; }
    #sidebarInkBar {
      position: fixed;
      top: 0;
      left: 0;
      width: 3px;
      height: 36px;
      background: var(--accent);
      border-radius: 0 2px 2px 0;
      transition: top 200ms cubic-bezier(0.4, 0, 0.2, 1), height 200ms cubic-bezier(0.4, 0, 0.2, 1), opacity 160ms ease;
      opacity: 0;
      pointer-events: none;
      z-index: 101;
      will-change: top, height;
    }
    @keyframes sidebarActivePulse {
      0% { background: rgba(58,125,48,0.20); }
      100% { background: rgba(58,125,48,0.10); }
    }
    .sidebar-footer {
      margin-top: auto;
      padding: 16px 20px 0;
      font-size: 12px;
      color: var(--muted);
    }
    .sidebar-footer a {
      color: var(--accent);
      text-decoration: none;
      font-weight: 600;
    }
    .sidebar-footer a:hover { text-decoration: underline; }

    /* ── Main area ── */
    .main-content {
      margin-left: var(--sidebar-w);
      min-height: 100vh;
      padding: 24px 32px 48px;
    }

    /* ── Top bar ── */
    .top-bar {
      display: flex; align-items: center; justify-content: space-between;
      gap: 16px; margin-bottom: 24px; flex-wrap: wrap;
    }
    .top-bar h1 { font-size: 24px; font-weight: 600; color: var(--text); }
    .top-bar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

    /* ── Buttons ── */
    .btn {
      display: inline-flex; align-items: center; justify-content: center;
      padding: 8px 16px; border-radius: var(--radius-md); font-size: 13px; font-weight: 600;
      cursor: pointer; transition: all 150ms ease; border: none; text-decoration: none;
      min-width: 130px;
    }
    .btn-primary { background: var(--accent); color: #FFFFFF; }
    .btn-primary:hover { background: #2E6325; }
    .btn-ghost {
      background: transparent; color: var(--accent);
      border: 1px solid var(--accent);
    }
    .btn-ghost:hover { border-color: #2E6325; background: rgba(58,125,48,0.05); }

    /* ── KPI cards row ── */
    .kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
    .kpi-card {
      background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
      padding: 20px; border-left: 3px solid var(--accent);
      box-shadow: var(--card-shadow);
    }
    .kpi-card-label {
      font-size: 11px; font-weight: 600; text-transform: uppercase;
      letter-spacing: 0.1em; color: var(--muted);
    }
    .kpi-card-value { font-size: 28px; font-weight: 700; color: var(--accent); margin-top: 8px; }
    .kpi-card-note { font-size: 12px; color: var(--muted); margin-top: 6px; }

    /* ── Insight bar ── */
    .insight-bar {
      background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
      padding: 12px 20px; font-size: 13px; color: var(--muted); margin-bottom: 24px;
      box-shadow: var(--card-shadow);
    }

    /* ── Stats grid ── */
    .stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
    .stat-card {
      background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
      padding: 20px; box-shadow: var(--card-shadow);
    }
    .stat-card-label {
      font-size: 11px; font-weight: 600; text-transform: uppercase;
      letter-spacing: 0.1em; color: var(--muted);
    }
    .stat-card-value { font-size: 24px; font-weight: 700; color: var(--text); margin-top: 8px; }
    .stat-card-note { font-size: 12px; color: var(--muted); margin-top: 6px; }

    /* ── Section headers ── */
    .section-header {
      font-size: 11px; font-weight: 600; text-transform: uppercase;
      letter-spacing: 0.1em; color: var(--muted-light); margin-bottom: 12px;
    }
    .section-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 16px; }

    /* ── Filter bar ── */
    .filter-bar {
      background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
      padding: 16px 20px; margin-bottom: 24px; box-shadow: var(--card-shadow);
    }
    .filter-bar-top {
      display: flex; align-items: flex-end; justify-content: space-between;
      gap: 16px; margin-bottom: 16px; flex-wrap: wrap;
    }
    .filter-bar-top-left .section-header { margin-bottom: 4px; }
    .filter-bar-top-left .section-title { margin-bottom: 0; }
    .filter-grid {
      display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px;
    }
    .filter-group { display: flex; flex-direction: column; gap: 6px; }
    .filter-group > span,
    .filter-group > label {
      font-size: 11px; font-weight: 600; text-transform: uppercase;
      letter-spacing: 0.08em; color: var(--muted);
    }
    .filter-group .relative { position: relative; }

    /* ── Inputs ── */
    .field-input {
      width: 100%; border-radius: var(--radius-md);
      border: 1px solid var(--input-border);
      background: var(--input-bg); color: var(--text);
      padding: 8px 12px; font-size: 13px; font-family: inherit;
      transition: border-color 150ms ease, box-shadow 150ms ease;
      appearance: none; -webkit-appearance: none;
    }
    .field-input:focus {
      outline: none; border-color: var(--accent);
      box-shadow: 0 0 0 2px rgba(58,125,48,0.12);
    }
    .field-input::placeholder { color: var(--muted-light); }
    select.field-input { cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%235E7854' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; }
    select.field-input option { background: #FFFFFF; color: var(--text); }

    /* ── Multi-select trigger ── */
    .ms-trigger {
      display: flex; align-items: center; justify-content: space-between;
      gap: 8px; text-align: left; cursor: pointer;
      width: 100%; border-radius: var(--radius-md);
      border: 1px solid var(--input-border);
      background: var(--input-bg); color: var(--text);
      padding: 8px 12px; font-size: 13px; font-family: inherit;
      transition: border-color 150ms ease;
    }
    .ms-trigger:hover { border-color: var(--accent); }
    .ms-trigger--active {
      border-color: var(--accent);
      background: var(--accent-dim);
      color: var(--accent);
    }
    .ms-trigger--active .ms-badge { color: var(--accent); opacity: 0.7; }
    .ms-trigger--active:hover { border-color: var(--accent); background: rgba(58,125,48,0.13); }
    .ms-trigger .ms-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .ms-trigger .ms-badge {
      font-size: 9px; text-transform: uppercase; letter-spacing: 0.16em;
      color: var(--muted); flex-shrink: 0;
    }

    /* ── Multi-select panel ── */
    .multi-select-panel {
      position: absolute; left: 0; right: 0;
      top: calc(100% + 6px); z-index: 70;
      border: 1px solid var(--border); border-radius: var(--radius-lg);
      background: rgba(255,255,255,0.97); backdrop-filter: blur(12px);
      box-shadow: 0 16px 48px rgba(52,100,38,0.12);
      padding: 12px;
      opacity: 0;
      transform: scaleY(0.92) translateY(-6px);
      transform-origin: top center;
      pointer-events: none;
      visibility: hidden;
      transition: opacity 160ms ease, transform 160ms ease, visibility 0s linear 160ms;
    }
    .multi-select-panel.visible {
      opacity: 1;
      transform: scaleY(1) translateY(0);
      pointer-events: auto;
      visibility: visible;
      transition: opacity 160ms ease, transform 160ms ease, visibility 0s linear 0s;
    }
    .ms-panel-header {
      display: flex; align-items: center; justify-content: space-between;
      gap: 8px; margin-bottom: 10px;
    }
    .ms-panel-btn {
      font-size: 11px; font-weight: 600; text-transform: uppercase;
      letter-spacing: 0.12em; cursor: pointer; border: none; background: none; padding: 0;
    }
    .ms-panel-btn.select-all { color: var(--accent); }
    .ms-panel-btn.clear-btn { color: var(--muted); }
    .ms-options { max-height: 240px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
    .multi-select-option {
      display: flex; align-items: center; gap: 8px; cursor: pointer;
      border-radius: var(--radius-sm); padding: 6px 10px; transition: background 150ms ease;
      font-size: 13px; color: var(--text);
    }
    .multi-select-option:hover { background: rgba(58,125,48,0.06); }
    .multi-select-option input[type="checkbox"] { accent-color: var(--accent); cursor: pointer; }
    .ms-group-details {
      border: 1px solid var(--border); border-radius: var(--radius-md);
      padding: 8px 10px; margin-bottom: 4px; background: rgba(58,125,48,0.04);
    }
    .ms-group-details summary {
      cursor: pointer; list-style: none; display: flex; align-items: center;
      justify-content: space-between; font-size: 13px; font-weight: 600; color: var(--text);
      padding: 2px 0;
    }
    .ms-group-details summary::-webkit-details-marker { display: none; }
    .ms-group-items {
      margin-top: 8px; border-top: 1px solid var(--border); padding-top: 8px;
      display: flex; flex-direction: column; gap: 2px;
    }
    .ms-group-item { padding-left: 16px; }

    /* ── Charts ── */
    .charts-grid { display: flex; gap: 16px; margin-bottom: 24px; }
    .chart-card {
      flex: 1; min-width: 0;
      background: #fff; border: 1px solid #E0EBD5; border-radius: var(--radius-lg);
      padding: 16px;
    }
    .chart-card-header {
      display: flex; align-items: flex-start; justify-content: space-between;
      gap: 12px; margin-bottom: 16px;
    }
    .chart-wrap { position: relative; min-height: 220px; }
    .chart-empty {
      position: absolute; inset: 0; display: none;
      align-items: center; justify-content: center;
      text-align: center; color: var(--muted); font-size: 13px; padding: 20px;
    }
    .chart-empty.visible { display: flex; }

    /* ── Cards section ── */
    .cards-header {
      display: flex; align-items: flex-end; justify-content: space-between;
      gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
    }
    .cards-header .result-summary { display: none; }
    .stats-mini-row { display: flex; align-items: center; gap: 0; }
    .stats-mini-item { display: flex; flex-direction: column; padding: 0 2px; }
    .stats-mini-label { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted-light); margin-bottom: 1px; }
    .stats-mini-val { font-size: 14px; font-weight: 800; color: var(--text); line-height: 1.2; }
    .stats-mini-val.filtered { color: var(--accent); }
    .stats-mini-sep { width: 1px; height: 28px; background: var(--border); flex-shrink: 0; margin: 0 12px; }
    .stats-mini-filter { display: flex; align-items: center; }
    .stats-mini-badge { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: var(--radius-full); background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; }
    .stats-mini-filter.hidden { display: none; }

    /* ── Empty state ── */
    .empty-state {
      display: none; text-align: center;
      background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
      padding: 48px 24px; margin-top: 16px; box-shadow: var(--card-shadow);
    }
    .empty-state.visible { display: block; }
    .empty-state h3 { font-size: 18px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
    .empty-state p { font-size: 13px; color: var(--muted); max-width: 480px; margin: 0 auto; }

    /* ── Modal ── */
    .modal-backdrop {
      display: none; position: fixed; inset: 0; z-index: 200;
      background: rgba(26,45,24,0.3); backdrop-filter: blur(4px);
      padding: 24px; overflow-y: auto;
    }
    .modal-backdrop.visible { display: flex; align-items: flex-start; justify-content: center; }
    .modal-sheet {
      width: 100%; max-width: 960px;
      background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-xl);
      box-shadow: 0 24px 64px rgba(52,100,38,0.15);
      position: relative; margin-top: 40px; margin-bottom: 40px;
      max-height: min(92vh, 1100px);
    }
    .modal-close {
      position: absolute; right: 16px; top: 16px; z-index: 10;
      width: 36px; height: 36px; border-radius: var(--radius-sm);
      border: 1px solid var(--border); background: rgba(58,125,48,0.06);
      color: var(--muted); font-size: 18px; font-weight: 700;
      cursor: pointer; transition: all 150ms ease;
      display: inline-flex; align-items: center; justify-content: center;
    }
    .modal-close:hover { color: var(--text); background: rgba(58,125,48,0.10); }
    .modal-body { padding: 24px; overflow-y: auto; max-height: calc(92vh - 48px); overscroll-behavior: contain; }
    .modal-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
    .modal-badge {
      padding: 3px 10px; border-radius: var(--radius-full); font-size: 11px; font-weight: 600;
      border: 1px solid var(--border); color: var(--muted);
    }
    .modal-badge-accent { background: var(--accent-dim); color: var(--accent); border-color: transparent; }
    .modal-title { font-size: 28px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
    .modal-subtitle { font-size: 13px; color: var(--muted); margin-bottom: 20px; }
    .modal-kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 24px; }
    .modal-kpi {
      background: rgba(58,125,48,0.04); border: 1px solid var(--border);
      border-radius: var(--radius-lg); padding: 14px;
    }
    .modal-kpi-label {
      font-size: 10px; font-weight: 600; text-transform: uppercase;
      letter-spacing: 0.1em; color: var(--muted);
    }
    .modal-kpi-value { font-size: 20px; font-weight: 700; color: var(--accent); margin-top: 6px; }
    .modal-kpi-value.plain { color: var(--text); }
    .modal-photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
    .modal-photo-slot {
      border: 1px dashed rgba(58,125,48,0.15); border-radius: var(--radius-lg);
      padding: 20px; text-align: center; min-height: 100px;
      display: flex; flex-direction: column; align-items: center; justify-content: center;
    }
    .modal-photo-slot .plus { font-size: 20px; color: var(--muted); margin-bottom: 6px; }
    .modal-photo-slot .label { font-size: 12px; font-weight: 600; color: var(--muted); }
    .modal-photo-slot .sub { font-size: 11px; color: var(--muted-light); margin-top: 2px; }
    .modal-issues {
      background: var(--amber-dim); border: 1px solid rgba(212,136,58,0.2);
      border-radius: var(--radius-lg); padding: 14px; margin-bottom: 20px;
    }
    .modal-issues-label {
      font-size: 10px; font-weight: 600; text-transform: uppercase;
      letter-spacing: 0.1em; color: var(--amber); margin-bottom: 8px;
    }
    .modal-issues ul { list-style: none; }
    .modal-issues li { font-size: 13px; color: var(--amber); margin-bottom: 4px; }
    .modal-sections { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
    .modal-section {
      background: rgba(58,125,48,0.03); border: 1px solid var(--border);
      border-radius: var(--radius-lg); padding: 16px;
    }
    .modal-section-title {
      font-size: 11px; font-weight: 600; text-transform: uppercase;
      letter-spacing: 0.1em; color: var(--accent); margin-bottom: 10px;
    }
    .modal-section ul { list-style: none; }
    .modal-section li { font-size: 13px; color: var(--muted); margin-bottom: 4px; line-height: 1.6; }

    /* ── Add variety modal ── */
    .add-modal-backdrop {
      display: none; position: fixed; inset: 0; z-index: 210;
      background: rgba(26,45,24,0.3); backdrop-filter: blur(4px);
      padding: 24px; overflow-y: auto;
    }
    .add-modal-backdrop.visible { display: flex; align-items: flex-start; justify-content: center; }
    .add-modal-sheet {
      width: 100%; max-width: 720px;
      background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-xl);
      box-shadow: 0 24px 64px rgba(52,100,38,0.15);
      position: relative; margin-top: 40px; margin-bottom: 40px;
      max-height: min(92vh, 1100px);
    }
    .add-form-body { padding: 24px; overflow-y: auto; max-height: calc(92vh - 48px); overscroll-behavior: contain; }
    .add-form-header { margin-bottom: 24px; }
    .add-form-badge {
      display: inline-block; padding: 3px 10px; border-radius: var(--radius-full);
      font-size: 10px; font-weight: 600; text-transform: uppercase;
      letter-spacing: 0.1em; background: var(--accent-dim); color: var(--accent);
      margin-bottom: 12px;
    }
    .add-form-title { font-size: 24px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
    .add-form-desc { font-size: 13px; color: var(--muted); }
    .add-form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
    .add-form-group { display: flex; flex-direction: column; gap: 6px; }
    .add-form-group label, .add-form-group > span {
      font-size: 12px; font-weight: 600; color: var(--muted);
    }
    .add-form-group.full { grid-column: 1 / -1; }
    .add-form-textarea {
      width: 100%; border-radius: var(--radius-md);
      border: 1px solid var(--input-border);
      background: var(--input-bg); color: var(--text);
      padding: 10px 12px; font-size: 13px; font-family: inherit;
      min-height: 200px; resize: vertical;
      transition: border-color 150ms ease;
    }
    .add-form-textarea:focus {
      outline: none; border-color: var(--accent);
      box-shadow: 0 0 0 2px rgba(58,125,48,0.12);
    }
    .add-form-footer {
      display: flex; align-items: center; justify-content: space-between;
      gap: 12px; border-top: 1px solid var(--border); padding-top: 16px;
      margin-top: 16px; flex-wrap: wrap;
    }
    .add-form-footer p { font-size: 12px; color: var(--muted); flex: 1; }
    .add-form-actions { display: flex; gap: 8px; }

    /* ── Mobile sidebar toggle ── */
    .sidebar-toggle {
      display: none; position: fixed; top: 12px; left: 12px; z-index: 150;
      width: 40px; height: 40px; border-radius: var(--radius-md);
      background: var(--card); border: 1px solid var(--border);
      color: var(--text); cursor: pointer;
      align-items: center; justify-content: center;
    }
    .sidebar-toggle svg,
    .sidebar-close svg {
      width: 20px;
      height: 20px;
      fill: none;
      stroke: currentColor;
      stroke-linecap: round;
      stroke-linejoin: round;
      stroke-width: 2;
    }
    .sidebar-close { display: none; }
    .sidebar-overlay {
      display: none; position: fixed; inset: 0; z-index: 90;
      background: rgba(26,45,24,0.2);
    }

    /* ── Responsive ── */
    @media (max-width: 1024px) {
      .charts-grid { flex-direction: column; }
      .modal-sections { grid-template-columns: repeat(2, 1fr); }
      .modal-kpi-grid { grid-template-columns: repeat(2, 1fr); }
      .filter-grid { grid-template-columns: repeat(3, 1fr); }
    }

    @media (max-width: 768px) {
      .sidebar { transform: translateX(-100%); }
      .sidebar.open { transform: translateX(0); }
      .sidebar-toggle { display: inline-flex; }
      .sidebar-overlay.visible { display: block; }
      .main-content {
        margin-left: 0;
        overflow-x: hidden;
        padding: 16px;
        padding-top: 56px;
        width: 100%;
      }
      .kpi-row { grid-template-columns: repeat(2, 1fr); }
      .stats-grid { grid-template-columns: repeat(2, 1fr); }
      .filter-grid { grid-template-columns: 1fr; }
      .variety-row-main {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
      }
      .variety-row-main > *:first-child { grid-column: 1 / -1; }
      .modal-sections { grid-template-columns: 1fr; }
      .modal-kpi-grid { grid-template-columns: 1fr 1fr; }
      .modal-photos { grid-template-columns: 1fr; }
      .add-form-grid { grid-template-columns: 1fr; }
      .top-bar { flex-direction: column; align-items: flex-start; }

      /* ── Analytics & Planning: responsive additions ── */

      /* 1. Orchard comparison 2-card grid: stack vertically, full width */
      .analytics-comparison { grid-template-columns: 1fr; }
      .analytics-comparison-card { width: 100%; }

      /* 2. Charts grid (3-chart row): stack vertically, each chart full width */
      .charts-grid { flex-direction: column; }
      .charts-grid .chart-card { width: 100%; flex: none; }

      /* 3. Analytics & Planning tables: horizontal scroll so wide tables never break layout */
      .analytics-panel { overflow-x: auto; -webkit-overflow-scrolling: touch; }
      .analytics-table { min-width: 540px; }

      /* 4. Bar rows: truncate long labels instead of overflowing */
      .analytics-bar-label {
        width: 120px;
        max-width: 120px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }

      /* 5. Density heatmap: 2 columns at 768px (600px breakpoint already gives 2;
            this ensures consistency across the full mobile range) */
      .density-grid { grid-template-columns: repeat(2, 1fr); }
    }

    /* Density heatmap: collapse to 1 column on very narrow screens */
    @media (max-width: 400px) {
      .density-grid { grid-template-columns: 1fr; }
    }

    /* ── Loading state text ── */
    .loading-text { color: var(--muted); font-size: 13px; padding: 24px 0; text-align: center; }

    .api-error-banner {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 14px 18px;
      margin-bottom: 20px;
      border: 1px solid rgba(212,136,58,0.24);
      border-radius: var(--radius-lg);
      background: var(--amber-dim);
      color: var(--amber);
      box-shadow: var(--card-shadow);
      flex-wrap: wrap;
    }

    .api-error-banner.hidden {
      display: none;
    }

    .api-error-banner-copy {
      display: flex;
      align-items: center;
      gap: 10px;
      font-size: 13px;
      font-weight: 700;
      flex-wrap: wrap;
    }

    /* hidden helper */
    .hidden { display: none !important; }

    /* ── SPA Views ── */
    .view { display: none; }
    .view.active { display: block; }

    /* ── Analytics view ── */
    .analytics-panel {
      background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
      padding: 20px; margin-bottom: 16px; box-shadow: var(--card-shadow);
    }
    .analytics-panel-title {
      font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 16px;
    }
    .analytics-table {
      width: 100%; border-collapse: collapse; font-size: 13px;
    }
    .analytics-table th {
      text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase;
      letter-spacing: 0.08em; color: var(--muted); padding: 10px 12px;
      border-bottom: 2px solid var(--border); white-space: nowrap;
    }
    .analytics-table td {
      padding: 10px 12px; border-bottom: 1px solid var(--border); color: var(--text);
    }
    .analytics-table tr:last-child td { border-bottom: none; }
    .analytics-table tr:hover td { background: rgba(58,125,48,0.03); }
    .analytics-table .num { text-align: right; font-variant-numeric: tabular-nums; }
    .planning-input {
      width: 90px; padding: 4px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm);
      background: #fff; font-size: 13px; font-family: inherit; color: var(--text);
      text-align: right; outline: none; transition: border-color 150ms, box-shadow 150ms;
    }
    .planning-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(58,125,48,0.15); }
    .planning-input::placeholder { color: var(--muted-light); }
    .planning-group {
      background: var(--card);
      border: 1px solid var(--border);
      border-radius: var(--radius-lg);
      box-shadow: var(--card-shadow);
      margin-bottom: 12px;
      overflow: hidden;
    }
    .planning-group-header {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 14px 20px;
      cursor: pointer;
      user-select: none;
      transition: background 150ms ease;
      border-left: 4px solid transparent;
    }
    .planning-group-header:hover { background: var(--accent-dim); }
    .planning-group-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
    .planning-group-name { font-size: 14px; font-weight: 700; color: var(--text); flex: 1; }
    .planning-group-summary {
      display: flex;
      gap: 20px;
      font-size: 12px;
      color: var(--muted);
      flex-wrap: wrap;
    }
    .planning-group-summary strong { color: var(--text); font-weight: 600; }
    .planning-group-chevron {
      font-size: 12px;
      color: var(--muted-light);
      transition: transform 200ms ease;
      flex-shrink: 0;
    }
    .planning-group.collapsed .planning-group-chevron { transform: rotate(-90deg); }
    .planning-group-body {
      overflow: hidden;
      transition: max-height 300ms ease, opacity 200ms ease;
      opacity: 1;
    }
    .planning-group.collapsed .planning-group-body {
      max-height: 0 !important;
      opacity: 0;
    }
    .planning-group-inner { padding: 0 20px 16px; }
    .planning-group-table-title {
      font-size: 11px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.08em;
      color: var(--muted);
      margin: 12px 0 8px;
    }

    .analytics-bar-row {
      display: flex; align-items: center; gap: 12px; padding: 8px 0;
      border-bottom: 1px solid var(--border);
    }
    .analytics-bar-row:last-child { border-bottom: none; }
    .analytics-bar-label { width: 200px; font-size: 13px; font-weight: 500; color: var(--text); flex-shrink: 0; }
    .analytics-bar-track { flex: 1; height: 22px; background: rgba(58,125,48,0.06); border-radius: var(--radius-sm); overflow: hidden; }
    .analytics-bar-fill { height: 100%; border-radius: var(--radius-sm); transition: width 300ms ease; }
    .analytics-bar-value { width: 80px; text-align: right; font-size: 13px; font-weight: 600; color: var(--muted); flex-shrink: 0; }

    .analytics-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
    @media (max-width: 768px) { .analytics-grid-2 { grid-template-columns: 1fr; } }

    /* ── Age Distribution Section ── */
    .age-cards-row {
      display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px;
    }
    @media (max-width: 900px) { .age-cards-row { grid-template-columns: repeat(2, 1fr); } }
    @media (max-width: 500px) { .age-cards-row { grid-template-columns: 1fr; } }
    .age-card {
      background: var(--card); border: 1px solid var(--border); border-left: 4px solid var(--accent);
      border-radius: var(--radius-md); padding: 14px 16px; box-shadow: var(--card-shadow);
    }
    .age-card-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 4px; }
    .age-card-value { font-size: 20px; font-weight: 700; color: var(--text); }
    .age-card-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
    .age-progress-cell { display: flex; align-items: center; gap: 8px; }
    .age-progress-bar { flex: 1; height: 6px; background: rgba(58,125,48,0.08); border-radius: 3px; overflow: hidden; }
    .age-progress-fill { height: 100%; background: var(--accent); border-radius: 3px; }

    .analytics-orchard-filter {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
      align-items: center;
    }
    .analytics-orchard-pill {
      padding: 5px 14px;
      border-radius: var(--radius-full);
      border: 1.5px solid var(--border);
      background: transparent;
      color: var(--muted);
      font-size: 13px;
      font-weight: 500;
      cursor: pointer;
      transition: background 200ms ease, border-color 200ms ease, color 200ms ease, box-shadow 200ms ease;
      font-family: inherit;
    }
    .analytics-orchard-pill:hover {
      border-color: var(--accent);
      color: var(--accent);
    }
    .analytics-orchard-pill:active {
      transform: scale(0.97);
    }
    .analytics-orchard-pill.active {
      background: var(--accent);
      border-color: var(--accent);
      color: #fff;
      font-weight: 600;
      box-shadow: 0 2px 8px rgba(58,125,48,0.25);
    }


    .analytics-comparison {
      display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px;
    }
    @media (max-width: 768px) { .analytics-comparison { grid-template-columns: 1fr; } }
    .analytics-comparison-card {
      background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
      padding: 20px; box-shadow: var(--card-shadow);
    }
    .analytics-comparison-card h3 {
      font-size: 15px; font-weight: 600; color: var(--accent); margin-bottom: 12px;
    }
    .analytics-stat-row {
      display: flex; justify-content: space-between; padding: 6px 0;
      border-bottom: 1px solid var(--border); font-size: 13px;
    }
    .analytics-stat-row:last-child { border-bottom: none; }
    .analytics-stat-label { color: var(--muted); }
    .analytics-stat-value { font-weight: 600; color: var(--text); }

    .issue-item {
      padding: 10px 14px; background: var(--amber-dim); border: 1px solid rgba(212,136,58,0.2);
      border-radius: var(--radius-md); margin-bottom: 8px;
    }
    .issue-item:last-child { margin-bottom: 0; }
    .issue-item-name { font-weight: 600; color: var(--text); font-size: 13px; margin-bottom: 4px; }
    .issue-item-text { font-size: 12px; color: var(--amber); }

    /* ── Calendar view ── */
    .calendar-header { margin-bottom: 24px; }
    .calendar-header h2 { font-size: 20px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
    .calendar-header p { font-size: 13px; color: var(--muted); }
    .calendar-peak { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px 16px; margin-bottom: 16px; font-size: 13px; font-weight: 600; color: var(--accent); box-shadow: var(--card-shadow); }
    .calendar-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
    .calendar-legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
    .calendar-legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
    .calendar-wrap { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--card-shadow); overflow-x: auto; }
    .calendar-table { width: 100%; border-collapse: collapse; min-width: 700px; }
    .calendar-table th { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 10px 4px; text-align: center; background: #F7F9F5; white-space: nowrap; }
    .calendar-table th:first-child { text-align: left; padding-left: 16px; width: 200px; min-width: 200px; position: sticky; left: 0; background: #F7F9F5; z-index: 1; }
    .calendar-table td { padding: 2px 4px; text-align: center; height: 32px; vertical-align: middle; }
    .calendar-table td:first-child { text-align: left; padding-left: 16px; font-size: 12px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; width: 200px; min-width: 200px; position: sticky; left: 0; background: var(--card); z-index: 1; }
    .calendar-table tr:hover td { background: rgba(58,125,48,0.03); }
    .calendar-table tr:hover td:first-child { background: rgba(58,125,48,0.03); }
    .calendar-group-row td { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted-light); padding: 8px 16px !important; background: #FAFCF8 !important; border-top: 1px solid var(--border); }
    .calendar-pill { display: inline-block; width: calc(100% - 4px); height: 20px; border-radius: 10px; }
    .calendar-nodata { font-size: 11px; color: var(--muted-light); font-style: italic; }

    /* ── Density heatmap ── */
    .density-legend { display: flex; align-items: center; gap: 0; margin-bottom: 16px; border-radius: var(--radius-md); overflow: hidden; }
    .density-legend-item { flex: 1; padding: 8px 4px; text-align: center; font-size: 11px; font-weight: 600; color: #1A2D18; }
    .density-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
    @media (max-width: 900px) { .density-grid { grid-template-columns: repeat(3, 1fr); } }
    @media (max-width: 600px) { .density-grid { grid-template-columns: repeat(2, 1fr); } }
    .density-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 14px; box-shadow: var(--card-shadow); display: flex; flex-direction: column; gap: 4px; }
    .density-card-name { font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .density-card-badge { display: inline-block; font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: var(--radius-full); color: #fff; width: fit-content; }
    .density-card-value { font-size: 22px; font-weight: 800; line-height: 1.2; }
    .density-card-orchard { font-size: 11px; color: var(--muted); }
    .density-card-nodata { font-size: 13px; color: var(--muted-light); font-style: italic; }

    /* ── Settings view ── */
    .settings-section {
      background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
      padding: 24px; margin-bottom: 16px; box-shadow: var(--card-shadow);
    }
    .settings-section-title {
      font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 16px;
      padding-bottom: 12px; border-bottom: 1px solid var(--border);
    }
    .settings-row {
      display: flex; align-items: center; justify-content: space-between;
      padding: 12px 0; border-bottom: 1px solid var(--border); gap: 16px;
    }
    .settings-row:last-child { border-bottom: none; }
    .settings-row-info { flex: 1; }
    .settings-row-label { font-size: 13px; font-weight: 600; color: var(--text); }
    .settings-row-desc { font-size: 12px; color: var(--muted); margin-top: 2px; }
    .btn-danger {
      display: inline-flex; align-items: center; justify-content: center;
      padding: 8px 16px; border-radius: var(--radius-md); font-size: 13px; font-weight: 600;
      cursor: pointer; transition: all 150ms ease; border: none;
      background: #DC3545; color: #FFFFFF;
    }
    .btn-danger:hover { background: #C82333; }
    .about-grid {
      display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 13px;
    }
    .about-label { color: var(--muted); font-weight: 500; }
    .about-value { color: var(--text); font-weight: 600; }

    /* ── Dashboard 2 ── */
    .d2-topbar {
      display: flex; align-items: center; justify-content: space-between;
      margin-bottom: 20px; flex-wrap: wrap; gap: 8px;
    }
    @media (max-width: 600px) {
      .d2-topbar { flex-direction: column; align-items: flex-start; gap: 3px; margin-bottom: 16px; }
      .d2-topbar-right { flex-wrap: wrap; row-gap: 2px; }
    }
    .d2-topbar-title { margin: 0; font-size: 18px; font-weight: 700; color: var(--text); }
    .d2-topbar-right { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
    .d2-topbar-sep { color: var(--border); }

    .d2-harvest-strip {
      background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
      padding: 16px 20px; margin-bottom: 20px; box-shadow: var(--card-shadow); position: relative;
    }
    .d2-harvest-label { font-size: 11px; color: var(--muted); margin-bottom: 10px; font-weight: 500; }
    .d2-months { display: flex; gap: 6px; }
    .d2-month-cell {
      flex: 1; text-align: center; padding: 6px 2px; border-radius: var(--radius-md);
      font-size: 11px; font-weight: 600; cursor: pointer; transition: all 150ms ease;
      position: relative; color: var(--muted-light); background: var(--bg);
      border: 2px solid transparent;
    }
    .d2-month-cell:hover { background: var(--accent-dim); }
    .d2-month-cell.d2-month-active {
      background: rgba(58,125,48,0.12); color: var(--accent);
      border-color: var(--accent); box-shadow: 0 0 0 2px rgba(58,125,48,0.15);
    }
    .d2-month-cell.d2-month-grey { color: #AABBA0; }
    .d2-month-dot {
      display: block; width: 6px; height: 6px; border-radius: 50%;
      margin: 4px auto 0;
    }
    .d2-month-popover {
      display: none; position: absolute; left: 50%; transform: translateX(-50%);
      top: calc(100% - 8px); background: var(--card); border: 1px solid var(--border);
      border-radius: var(--radius-md); padding: 12px 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.12);
      z-index: 50; min-width: 200px; font-size: 12px;
    }
    .d2-month-popover.visible { display: block; }
    .d2-month-popover-title { font-weight: 700; margin-bottom: 6px; color: var(--text); }
    .d2-month-popover-item { padding: 2px 0; color: var(--muted); }
    .d2-month-popover-item .d2-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

    .d2-drying-summary {
      background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
      padding: 20px 24px; margin-bottom: 20px; box-shadow: var(--card-shadow);
      border-left: 4px solid var(--accent); display: grid;
      grid-template-columns: minmax(0, 1fr) auto; align-items: stretch; gap: 24px;
      transition: background 220ms ease, border-color 220ms ease, box-shadow 220ms ease;
    }
    .d2-drying-summary.is-active {
      background: var(--card);
      border-color: rgba(58,125,48,0.30); border-left-color: var(--accent);
      box-shadow: 0 4px 16px rgba(58,125,48,0.08);
    }
    .d2-drying-summary.is-idle {
      background: var(--card);
      border-color: rgba(107,128,97,0.20); border-left-color: #93A58A;
    }
    .d2-drying-summary.is-warning {
      background: linear-gradient(100deg, rgba(212,136,58,0.09), rgba(255,255,255,0.98) 72%);
      border-color: rgba(212,136,58,0.34); border-left-color: var(--amber);
      box-shadow: 0 4px 16px rgba(212,136,58,0.08);
    }
    .d2-drying-summary.is-disabled {
      background: linear-gradient(100deg, rgba(107,114,128,0.05), rgba(255,255,255,0.98) 72%);
      border-color: rgba(107,114,128,0.20); border-left-color: var(--muted-light);
    }
    .d2-drying-summary.is-error { border-left-color: var(--danger); }
    .d2-drying-main { min-width: 0; }
    .d2-drying-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
    .d2-drying-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted-light); }
    .d2-drying-status {
      display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px;
      border-radius: var(--radius-full); background: rgba(58,125,48,0.10);
      color: var(--accent); font-size: 11px; font-weight: 700;
    }
    .d2-drying-status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
    .d2-drying-status.is-warning { background: var(--amber-dim); color: var(--amber); }
    .d2-drying-status.is-idle { background: var(--bg); color: var(--muted); }
    .d2-drying-title { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; font-size: 21px; font-weight: 800; color: var(--text); }
    .d2-drying-title small { font-size: 13px; font-weight: 500; color: var(--muted); }
    .d2-drying-subtitle { margin-top: 3px; color: var(--muted); font-size: 12px; }
    .d2-drying-progress { height: 6px; margin-top: 14px; overflow: hidden; border-radius: var(--radius-full); background: var(--bg); }
    .d2-drying-progress > span { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width 300ms ease; }
    .d2-drying-progress.is-warning > span { background: var(--amber); }
    .d2-drying-metrics { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 13px; }
    .d2-drying-metric { display: inline-flex; align-items: baseline; gap: 5px; min-width: 92px; }
    .d2-drying-metric span { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted-light); }
    .d2-drying-metric strong { font-size: 13px; color: var(--text); }
    .d2-drying-metric.is-temperature strong { color: #C65B36; }
    .d2-drying-metric.is-humidity strong { color: #2F79A7; }
    .d2-drying-aside {
      min-width: 210px; padding-left: 24px; border-left: 1px solid var(--border);
      display: flex; flex-direction: column; align-items: flex-end; justify-content: center; text-align: right;
    }
    .d2-drying-aside-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted-light); }
    .d2-drying-aside-value { margin-top: 2px; font-size: 27px; font-weight: 800; line-height: 1.15; color: var(--accent); }
    .d2-drying-aside.is-warning .d2-drying-aside-value { color: var(--amber); }
    .d2-drying-aside-copy { margin-top: 3px; font-size: 11px; color: var(--muted); }
    .d2-drying-link {
      display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 32px;
      margin-top: 10px; padding: 6px 12px; border: 1px solid var(--accent); border-radius: var(--radius-md);
      color: var(--accent); background: #fff; text-decoration: none; font-size: 11px; font-weight: 700;
      transition: background 150ms ease, color 150ms ease, transform 150ms ease;
    }
    .d2-drying-link:hover { color: #fff; background: var(--accent); transform: translateY(-1px); }
    .d2-drying-error { color: var(--danger); }

    .d2-harvest-summary {
      display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1.15fr) minmax(190px, 0.62fr);
      gap: 10px; margin-bottom: 14px;
    }
    .d2-harvest-summary.without-fridge { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .d2-harvest-summary-card {
      min-width: 0; background: var(--card); border: 1px solid var(--border);
      border-radius: var(--radius-lg); padding: 11px 14px; box-shadow: var(--card-shadow);
    }
    .d2-harvest-summary-card.is-today { border-top: 3px solid var(--accent); }
    .d2-harvest-summary-card.is-progress { border-top: 3px solid #7E9B72; }
    .d2-harvest-summary-card.is-fridge {
      border-top: 3px solid #4B88A8;
      background: linear-gradient(145deg, rgba(75,136,168,0.07), rgba(255,255,255,0.98) 58%);
      display: grid; grid-template-rows: auto minmax(0, 1fr);
    }
    .d2-harvest-summary-head {
      display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px;
    }
    .d2-harvest-summary-title { margin: 0; font-size: 14px; font-weight: 750; color: var(--text); }
    .d2-harvest-summary-year,
    .d2-harvest-report-count {
      flex-shrink: 0; padding: 3px 8px; border-radius: var(--radius-full);
      background: var(--bg); color: var(--muted); font-size: 12px; font-weight: 650;
    }
    .d2-harvest-today-content {
      display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 8px 14px;
    }
    .d2-harvest-today-line { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; }
    .d2-harvest-big-value { font-size: 25px; line-height: 1.08; font-weight: 800; color: var(--text); }
    .d2-harvest-big-value small { margin-left: 3px; font-size: 14px; color: var(--muted); font-weight: 650; }
    .d2-harvest-today-breakdown { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; min-width: 0; }
    .d2-harvest-quality { display: flex; flex-wrap: wrap; gap: 5px; }
    .d2-harvest-quality > span {
      display: inline-flex; align-items: baseline; gap: 4px; min-height: 23px; padding: 3px 7px;
      border: 1px solid var(--border); border-radius: var(--radius-md); color: var(--muted); background: #fff; font-size: 11px;
    }
    .d2-harvest-quality strong { color: var(--text); font-size: 11px; }
    .d2-harvest-quality .is-good { border-color: rgba(58,125,48,.2); background: rgba(58,125,48,.06); }
    .d2-harvest-quality .is-damaged { border-color: rgba(190,89,61,.2); background: rgba(190,89,61,.05); }
    .d2-harvest-quality .is-discarded { border-color: rgba(166,111,28,.22); background: rgba(166,111,28,.06); }
    .d2-harvest-destination { display: flex; flex-wrap: wrap; gap: 5px; }
    .d2-harvest-destination-item {
      display: inline-flex; align-items: baseline; gap: 4px; min-height: 23px; padding: 3px 7px;
      border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg);
      color: var(--muted); font-size: 11px;
    }
    .d2-harvest-destination-item strong { color: var(--text); font-size: 11px; }
    .d2-harvest-latest {
      display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px; align-items: start;
      margin-top: 7px; padding-top: 7px; border-top: 1px solid var(--border);
    }
    .d2-harvest-latest-label {
      color: var(--muted-light); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
    }
    .d2-harvest-latest-copy {
      min-width: 0; display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 7px;
      color: var(--muted); font-size: 12px; line-height: 1.35;
    }
    .d2-harvest-latest-copy strong { color: var(--text); font-size: 13px; }
    .d2-harvest-overall { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
    .d2-harvest-overall strong { font-size: 24px; line-height: 1; color: var(--accent); }
    .d2-harvest-overall span { font-size: 12px; color: var(--muted); }
    .d2-harvest-progress-track {
      height: 7px; overflow: hidden; border-radius: var(--radius-full); background: var(--bg);
    }
    .d2-harvest-progress-track > span {
      display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width 260ms ease;
    }
    .d2-harvest-overall + .d2-harvest-progress-track { margin-top: 6px; }
    .d2-harvest-orchards { display: grid; gap: 5px; margin-top: 8px; }
    .d2-harvest-orchard-row {
      display: grid; grid-template-columns: minmax(74px, auto) minmax(54px, 1fr) 37px;
      align-items: center; gap: 8px;
    }
    .d2-harvest-orchard-name {
      overflow: hidden; color: var(--text); font-size: 12px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap;
    }
    .d2-harvest-orchard-row .d2-harvest-progress-track { height: 5px; }
    .d2-harvest-orchard-percent { color: var(--muted); font-size: 12px; font-weight: 700; text-align: right; }
    .d2-harvest-fridge-metric { align-self: center; }
    .d2-harvest-fridge-label { color: var(--muted); font-size: 12px; }
    .d2-harvest-fridge-value { margin-top: 4px; font-size: 27px; line-height: 1.05; font-weight: 800; color: #315E76; }
    .d2-harvest-fridge-value small { margin-left: 3px; font-size: 14px; color: var(--muted); font-weight: 650; }
    .d2-harvest-summary-empty { color: var(--muted); font-size: 12px; }
    .d2-harvest-summary-error {
      grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 12px;
      padding: 12px 16px; border: 1px solid rgba(220,53,69,0.2); border-radius: var(--radius-lg);
      background: rgba(220,53,69,0.04); color: var(--muted); font-size: 13px;
    }
    .d2-harvest-summary-retry {
      flex-shrink: 0; border: 0; background: none; color: var(--accent); font: inherit; font-weight: 700; cursor: pointer;
    }

    .d2-kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
    .d2-kpi-card {
      background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
      padding: 18px 20px; box-shadow: var(--card-shadow); border-top: 3px solid var(--accent);
    }
    .d2-kpi-card-head { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
    .d2-kpi-card-head svg { color: var(--muted); flex-shrink: 0; }
    .d2-kpi-card-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
    .d2-kpi-card-value { font-size: 28px; font-weight: 700; color: var(--text); }
    .d2-kpi-card-unit { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 4px; }

    /* ── Skeleton shimmer ── */
    @keyframes shimmer {
      0% { background-position: -600px 0; }
      100% { background-position: 600px 0; }
    }
    .skel {
      background: linear-gradient(90deg, #E8F0E2 25%, #F2F8EE 50%, #E8F0E2 75%);
      background-size: 600px 100%;
      animation: shimmer 1.4s ease-in-out infinite;
      border-radius: 6px;
      display: block;
    }
    /* Skeleton sizes derived from actual component measurements */
    .skel-kpi-value { height: 34px; width: 80px; margin: 6px 0 4px; }
    .skel-kpi-label { height: 11px; width: 110px; margin-bottom: 0; }
    .skel-kpi-icon { height: 20px; width: 20px; border-radius: 4px; flex-shrink: 0; }
    .skel-chart { height: 100%; width: 100%; border-radius: 8px; } /* fills .d2-chart-wrap which sets height:280px */
    /* Matches .d2-bottom-item: padding:8px 0 + border-bottom:1px + 13px name + 12px sub */
    .skel-list-item {
      padding: 8px 0;
      border-bottom: 1px solid var(--border);
      display: flex; align-items: center; justify-content: space-between;
      background: transparent !important;
      animation: none !important;
    }
    .skel-list-item:last-child { border-bottom: none; }
    /* harvest skeleton: real cell with text hidden — identical dimensions guaranteed */
    .d2-month-cell.skel { color: transparent; pointer-events: none; border-color: transparent !important; box-shadow: none !important; }
    .d2-month-cell.skel .d2-month-dot { visibility: hidden; }

    /* ── Dashboard content-swap: no opacity dip, just a clean instant swap ── */
    .d2-ready { /* marker class only — no animation */ }

    /* Weather section — compact horizontal layout */
    .d2-weather-section { margin-bottom: 24px; }
    .d2-weather-title { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
    .d2-weather-title-refresh {
      position: relative; background: none; border: 1px solid var(--border); cursor: pointer;
      font-size: 12px; color: var(--muted); padding: 2px 7px; border-radius: 5px;
      line-height: 1.4; transition: all 150ms;
    }
    .d2-weather-title-refresh:hover,
    .d2-weather-title-refresh:focus-visible { background: var(--border); color: var(--text); }
    .d2-weather-title-refresh::after {
      position: absolute; top: calc(100% + 7px); left: 50%; z-index: 30;
      padding: 5px 8px; border-radius: 6px; content: attr(data-weather-tooltip);
      color: #fff; background: #273126; box-shadow: 0 5px 14px rgba(25,35,24,.18);
      font-size: 11px; font-weight: 600; line-height: 1.25; letter-spacing: 0;
      text-transform: none; white-space: nowrap; pointer-events: none;
      opacity: 0; transform: translate(-50%, -3px);
      transition: opacity 140ms ease, transform 140ms ease;
    }
    .d2-weather-title-refresh:hover::after,
    .d2-weather-title-refresh:focus-visible::after {
      opacity: 1; transform: translate(-50%, 0);
    }
    .d2-weather-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: 12px; }
    @media (max-width: 860px) { .d2-weather-row { grid-template-columns: 1fr; } }
    .d2-weather-card {
      --weather-card-bg: var(--card);
      --weather-card-border: var(--border);
      --weather-card-accent: transparent;
      --weather-day-bg: var(--bg);
      --weather-today-bg: var(--accent-dim);
      position: relative;
      overflow: hidden;
      background: var(--weather-card-bg); border: 1px solid var(--weather-card-border); border-radius: var(--radius-lg);
      padding: 12px 16px; box-shadow: var(--card-shadow);
      display: flex; align-items: center; gap: 16px;
      transition: background-color 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
    }
    .d2-weather-card::before {
      position: absolute;
      inset: 0 auto 0 0;
      width: 4px;
      content: "";
      background: var(--weather-card-accent);
    }
    .d2-weather-card[data-weather-state="heat"] {
      --weather-card-bg: #fff9ed;
      --weather-card-border: #efd9a7;
      --weather-card-accent: #e5a12d;
      --weather-day-bg: rgba(255,255,255,.56);
      --weather-today-bg: #ffedc7;
      box-shadow: 0 5px 16px rgba(184,121,25,.09);
    }
    .d2-weather-card[data-weather-state="cold"] {
      --weather-card-bg: #f2f8fd;
      --weather-card-border: #c6dceb;
      --weather-card-accent: #4b91c2;
      --weather-day-bg: rgba(255,255,255,.6);
      --weather-today-bg: #dceefa;
      box-shadow: 0 5px 16px rgba(50,119,165,.08);
    }
    .d2-weather-card[data-weather-state="rain"] {
      --weather-card-bg: #f0f8fa;
      --weather-card-border: #bfdce5;
      --weather-card-accent: #3384a3;
      --weather-day-bg: rgba(255,255,255,.58);
      --weather-today-bg: #d9edf3;
      box-shadow: 0 5px 16px rgba(36,112,141,.08);
    }
    .d2-weather-card[data-weather-state="wind"] {
      --weather-card-bg: #f5f6fa;
      --weather-card-border: #d3d7e3;
      --weather-card-accent: #727b9d;
      --weather-day-bg: rgba(255,255,255,.62);
      --weather-today-bg: #e7e9f2;
      box-shadow: 0 5px 16px rgba(75,84,122,.07);
    }
    @media (max-width: 500px) {
      .d2-harvest-strip {
        padding: 14px 12px 12px;
        margin-bottom: 18px;
      }
      .d2-harvest-label {
        margin-bottom: 8px;
        line-height: 1.35;
      }
      .d2-months {
        margin: 0 -2px;
        padding: 0 2px 4px;
        scroll-snap-type: x proximity;
      }
      .d2-month-cell {
        min-width: 58px;
        padding: 7px 4px;
        scroll-snap-align: start;
      }
      .d2-weather-section {
        margin-bottom: 20px;
      }
      .d2-weather-title {
        justify-content: space-between;
        margin-bottom: 9px;
      }
      .d2-weather-title-refresh {
        align-items: center;
        display: inline-flex;
        justify-content: center;
        min-height: 38px !important;
        padding: 0;
        width: 38px;
      }
      .d2-weather-row {
        gap: 10px;
      }
      .d2-weather-card {
        flex-direction: column;
        align-items: stretch;
        gap: 11px;
        padding: 14px 12px 12px;
      }
    }
    /* Left: orchard name + current conditions */
    .d2-weather-left { display: flex; align-items: center; gap: 10px; flex-shrink: 0; min-width: 180px; }
    .d2-weather-icon { font-size: 26px; line-height: 1; flex-shrink: 0; }
    .d2-weather-info {}
    .d2-weather-card-name { font-size: 13px; font-weight: 700; color: var(--text); }
    .d2-weather-temp { font-size: 22px; font-weight: 800; color: var(--text); line-height: 1.1; }
    .d2-weather-feels { font-size: 10px; color: var(--muted); }
    .d2-weather-meta { font-size: 10px; color: var(--muted); margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; }
    .d2-weather-freshness {
      width: fit-content; max-width: 100%; margin-top: 5px; color: var(--muted);
      font-size: 11px; font-weight: 600; line-height: 1.25;
    }
    .d2-weather-freshness.is-stale {
      padding: 3px 6px; border: 1px solid #e8c87d; border-radius: 6px;
      background: #fff7df; color: #8a5b08;
    }
    .d2-weather-card[data-weather-freshness="stale"] {
      box-shadow: inset 0 0 0 1px rgba(218, 156, 39, .18), var(--card-shadow);
    }
    .d2-weather-card[data-weather-availability="expired"],
    .d2-weather-card[data-weather-availability="unavailable"] {
      --weather-card-accent: #d09a2d;
      align-items: stretch;
    }
    .d2-weather-availability-copy { padding: 2px 0; }
    .d2-weather-availability-title { color: var(--text); font-size: 13px; font-weight: 700; line-height: 1.35; }
    .d2-weather-availability-detail { color: var(--muted); font-size: 12px; line-height: 1.4; margin-top: 3px; }
    /* Right: 7-day forecast strip */
    .d2-weather-forecast { display: flex; flex: 1; min-width: 0; gap: 0; border: 1px solid var(--weather-card-border); border-radius: var(--radius-md); overflow: hidden; }
    .d2-weather-day { flex: 1; text-align: center; padding: 7px 4px; border-right: 1px solid var(--weather-card-border); background: var(--weather-day-bg); min-width: 0; }
    .d2-weather-day:last-child { border-right: none; }
    .d2-weather-day.today { background: var(--weather-today-bg); }
    .d2-weather-day.today .d2-weather-day-name { color: var(--accent); }
    .d2-weather-day[data-weather-state] { position: relative; box-shadow: inset 0 0 0 1px var(--weather-day-alert-border); }
    .d2-weather-day[data-weather-state]::before { position: absolute; inset: 0 0 auto; height: 3px; content: ""; background: var(--weather-day-alert-accent); }
    .d2-weather-day[data-weather-state="heat"] { --weather-day-alert-border: #efcf8f; --weather-day-alert-accent: #e5a12d; background: #fff0cf; }
    .d2-weather-day[data-weather-state="cold"] { --weather-day-alert-border: #b9d5e8; --weather-day-alert-accent: #4b91c2; background: #e5f3fc; }
    .d2-weather-day[data-weather-state="rain"] { --weather-day-alert-border: #abd3df; --weather-day-alert-accent: #3384a3; background: #def1f6; }
    .d2-weather-day[data-weather-state="wind"] { --weather-day-alert-border: #c8cddd; --weather-day-alert-accent: #727b9d; background: #eceef5; }
    .d2-weather-day-name { font-weight: 600; color: var(--muted); margin-bottom: 2px; font-size: 9px; text-transform: uppercase; letter-spacing: 0.04em; display: flex; align-items: center; justify-content: center; gap: 2px; }
    .d2-weather-day-wind-alert { width: 11px; height: 11px; flex: 0 0 11px; color: #727b9d; }
    .d2-weather-day-wind-alert svg { display: block; width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
    .d2-weather-day-icon { font-size: 14px; margin: 2px 0; }
    .d2-weather-day-temps { font-size: 10px; display: flex; justify-content: center; gap: 3px; }
    .d2-weather-day-max { font-weight: 700; color: var(--text); }
    .d2-weather-day-min { color: var(--muted); }
    .d2-weather-muted { color: var(--muted); font-size: 13px; padding: 16px; text-align: center; width: 100%; }
    .d2-weather-error { color: var(--muted); font-size: 13px; padding: 8px 0; width: 100%; }
    .d2-weather-error button { margin-top: 6px; }
    /* Legacy — no longer used but kept for safety */
    .d2-weather-card-header { display: none; }
    .d2-weather-main { display: none; }
    .d2-weather-pills { display: none; }
    .d2-weather-temp-block {}
    .d2-weather-card-location {}
    .d2-weather-refresh { background: none; border: 1px solid var(--border); cursor: pointer; font-size: 11px; color: var(--muted); padding: 2px 6px; border-radius: 5px; margin-left: auto; flex-shrink: 0; }
    .d2-weather-refresh:hover { background: var(--border); }
    @keyframes d2-pulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 0.7; } }
    .d2-weather-skeleton { height: 32px; flex: 1; border-radius: var(--radius-md); }
    /* Option 1+2: real day cells + real temp element with transparent content — zero hardcoded heights */
    .d2-weather-day.skel { color: transparent; pointer-events: none; }
    .d2-weather-day.skel .d2-weather-day-name,
    .d2-weather-day.skel .d2-weather-day-icon,
    .d2-weather-day.skel .d2-weather-day-temps { visibility: hidden; }
    .d2-weather-temp.skel { color: transparent; }
    @media (max-width: 500px) {
      .d2-weather-left {
        min-width: 0;
        padding: 0 4px;
      }
      .d2-weather-forecast {
        flex: 0 0 auto;
        overflow-x: auto;
        overflow-y: hidden;
        overscroll-behavior-x: contain;
        scroll-snap-type: x proximity;
        scrollbar-width: none;
        touch-action: pan-x;
        width: 100%;
        -webkit-overflow-scrolling: touch;
      }
      .d2-weather-forecast::-webkit-scrollbar {
        display: none;
      }
      .d2-weather-day {
        flex: 0 0 68px;
        min-width: 68px;
        padding: 8px 5px;
        scroll-snap-align: start;
      }
      .d2-weather-day-name,
      .d2-weather-day-temps {
        white-space: nowrap;
      }
      .d2-weather-day-icon {
        font-size: 16px;
        margin: 3px 0;
      }
    }

    /* ── Export page ── */
    .export-top { display: flex; align-items: baseline; gap: 12px; margin-bottom: 24px; }
    .export-top h1 { font-size: 24px; font-weight: 600; color: var(--text); }
    .export-top .export-kicker {
      font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em;
      padding: 3px 10px; border-radius: var(--radius-full);
      background: var(--accent-dim); color: var(--accent);
    }
    .export-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
    .export-card {
      background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
      padding: 20px; box-shadow: var(--card-shadow);
    }
    .export-card-header {
      font-size: 11px; font-weight: 600; text-transform: uppercase;
      letter-spacing: 0.1em; color: var(--muted-light); margin-bottom: 8px;
    }
    .export-rate-big { font-size: 32px; font-weight: 800; color: var(--text); line-height: 1.2; }
    .export-rate-change { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; margin-top: 6px; }
    .export-rate-change.up { color: #16A34A; }
    .export-rate-change.down { color: #DC2626; }
    .export-rate-ts { font-size: 11px; color: var(--muted-light); margin-top: 8px; }
    .export-rate-source { font-size: 10px; color: var(--muted-light); margin-top: 4px; font-style: italic; }
    details summary { list-style: none; }
    details summary::-webkit-details-marker { display: none; }
    details[open] summary { color: var(--accent); }
    .export-sparkline { display: flex; align-items: flex-end; gap: 3px; height: 32px; margin-top: 12px; }
    .export-sparkline-bar {
      flex: 1; background: var(--accent); border-radius: 2px; min-height: 3px;
      opacity: 0.5; transition: opacity 150ms;
    }
    .export-sparkline-bar:last-child { opacity: 1; }
    .export-sparkline-bar:hover { opacity: 1; }
    .export-price-big { font-size: 28px; font-weight: 800; color: var(--accent); line-height: 1.2; }
    .export-price-unit { font-size: 14px; font-weight: 500; color: var(--muted); }
    .export-price-note { font-size: 11px; color: var(--muted); margin-top: 6px; line-height: 1.5; }

    /* Demand heatmap */
    .export-heatmap { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; margin-bottom: 24px; box-shadow: var(--card-shadow); overflow-x: auto; }
    .export-heatmap-table { width: 100%; border-collapse: collapse; min-width: 800px; }
    .export-heatmap-table th {
      font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
      color: var(--muted); padding: 8px 4px; text-align: center; white-space: nowrap;
    }
    .export-heatmap-table th:first-child { text-align: left; padding-left: 12px; width: 140px; }
    .export-heatmap-table td { padding: 3px 4px; text-align: center; }
    .export-heatmap-table td:first-child {
      text-align: left; padding-left: 12px; font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap;
    }
    .export-heatmap-cell {
      display: inline-block; width: calc(100% - 4px); height: 28px; border-radius: 4px;
      cursor: default; position: relative;
    }
    .export-heatmap-holiday {
      position: absolute; top: -2px; right: -2px; width: 8px; height: 8px;
      border-radius: 50%; background: #EF4444; border: 1.5px solid #fff;
    }
    .export-heatmap-legend { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 11px; color: var(--muted); }
    .export-heatmap-legend-swatch { width: 16px; height: 12px; border-radius: 2px; display: inline-block; }

    /* Tooltip */
    .export-tooltip {
      display: none; position: fixed; z-index: 300;
      background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-md);
      padding: 8px 12px; box-shadow: 0 4px 16px rgba(0,0,0,0.12);
      font-size: 12px; color: var(--text); pointer-events: none; max-width: 260px;
    }
    .export-tooltip.visible { display: block; }
    .export-tooltip-title { font-weight: 700; margin-bottom: 2px; }
    .export-tooltip-desc { color: var(--muted); }

    /* Border card */
    .export-border-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
    .export-status-dot { display: inline-block; font-size: 18px; margin-right: 6px; vertical-align: middle; }
    .export-status-label { font-size: 18px; font-weight: 700; color: var(--text); vertical-align: middle; }
    .export-status-note { font-size: 12px; color: var(--muted); margin-top: 8px; }
    .export-news-link:hover {
      border-color: rgba(58, 125, 48, 0.22) !important;
      background: rgba(58, 125, 48, 0.07) !important;
    }
    .export-status-updated { font-size: 11px; color: var(--muted-light); margin-top: 6px; }
    .export-map-wrap { border-radius: var(--radius-md); overflow: hidden; border: 1px solid var(--border); margin-top: 12px; }
    .export-map-wrap iframe { width: 100%; height: 220px; border: none; display: block; }

    /* Phyto table */
    .export-phyto { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; margin-bottom: 24px; box-shadow: var(--card-shadow); }
    .export-phyto-table { width: 100%; border-collapse: collapse; font-size: 13px; }
    .export-phyto-table th {
      text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase;
      letter-spacing: 0.08em; color: var(--muted); padding: 10px 12px;
      border-bottom: 2px solid var(--border); white-space: nowrap;
    }
    .export-phyto-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); color: var(--text); }
    .export-phyto-table tr:last-child td { border-bottom: none; }
    .export-phyto-table tr:hover td { background: rgba(58,125,48,0.03); }
    .export-phyto-highlight { background: rgba(58,125,48,0.06); }

    /* When-to-sell strip */
    .export-sell-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin-bottom: 24px; }
    .export-sell-card {
      background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
      padding: 16px; box-shadow: var(--card-shadow);
    }
    .export-sell-fruit { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
    .export-sell-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); padding: 3px 0; }
    .export-sell-row span:last-child { font-weight: 600; color: var(--text); }
    .export-sell-match { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 700; margin-top: 8px; padding: 4px 10px; border-radius: var(--radius-full); }
    .export-sell-match.great { background: #DEF7D5; color: #16A34A; }
    .export-sell-match.ok { background: #FEF3E7; color: #D4883A; }
    .export-sell-match.bad { background: #FEE2E2; color: #DC2626; }

    /* Export skeleton */
    @keyframes export-pulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 0.7; } }
    .export-skeleton {
      background: var(--border); border-radius: var(--radius-md);
      animation: export-pulse 1.5s ease-in-out infinite;
    }
    .export-skeleton-line { height: 14px; margin-bottom: 8px; }
    .export-skeleton-big { height: 32px; width: 60%; margin-bottom: 8px; }
    .export-skeleton-spark { height: 32px; margin-top: 12px; }

    @media (max-width: 768px) {
      .export-grid-2, .export-border-grid { grid-template-columns: 1fr; }
      .export-sell-strip { grid-template-columns: 1fr; }
    }

    .d2-charts-row { display: flex; gap: 16px; margin-bottom: 20px; }
    .d2-chart-card {
      background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
      padding: 20px; box-shadow: var(--card-shadow);
    }
    .d2-chart-wide { flex: 6; min-width: 0; }
    .d2-chart-narrow { flex: 4; min-width: 0; }
    .d2-chart-wrap { position: relative; height: 280px; }

    .d2-bottom-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
    .d2-bottom-card {
      background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
      padding: 20px; box-shadow: var(--card-shadow);
    }
    .d2-bottom-item {
      display: flex; align-items: center; justify-content: space-between;
      padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px;
    }
    .d2-bottom-item:last-child { border-bottom: none; }
    .d2-bottom-item-name { font-weight: 600; color: var(--text); }
    .d2-bottom-item-sub { color: var(--muted); font-size: 12px; }
    .d2-bottom-item-right { text-align: right; color: var(--muted); font-size: 12px; }
    .d2-ok { display: flex; align-items: center; gap: 8px; padding: 16px 0; color: var(--accent); font-weight: 600; font-size: 14px; }
    .d2-ok svg { color: var(--accent); }
    .d2-issue-count { display: inline-block; background: var(--amber-dim); color: var(--amber); font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: var(--radius-full); }

    @media (max-width: 900px) {
      .d2-harvest-summary,
      .d2-harvest-summary.without-fridge { grid-template-columns: 1fr; }
      .d2-drying-summary { grid-template-columns: 1fr; gap: 16px; padding: 18px; }
      .d2-drying-aside { min-width: 0; padding: 14px 0 0; border-left: 0; border-top: 1px solid var(--border); align-items: flex-start; text-align: left; }
      .d2-drying-aside-value { font-size: 23px; }
      .d2-drying-link { align-self: stretch; }
      .d2-kpi-row { grid-template-columns: repeat(2, 1fr); }
      .d2-charts-row { flex-direction: column; }
      .d2-bottom-row { grid-template-columns: 1fr; }
      .d2-months {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 4px;
      }
      .d2-months::-webkit-scrollbar { display: none; }
      .d2-month-cell { flex-shrink: 0; min-width: 52px; }
    }

    @media (min-width: 901px) and (max-width: 1300px) {
      .d2-harvest-today-content { grid-template-columns: 1fr; gap: 4px; }
    }

    @media (max-width: 600px) {
      .d2-harvest-summary { gap: 9px; }
      .d2-harvest-summary-card { padding: 11px 13px; }
      .d2-harvest-today-content { grid-template-columns: 1fr; gap: 4px; }
      .d2-harvest-big-value,
      .d2-harvest-fridge-value { font-size: 25px; }
      .d2-harvest-orchard-row { grid-template-columns: minmax(82px, 0.8fr) minmax(70px, 1fr) 36px; gap: 7px; }
    }

    @media (max-width: 700px) {
      .sidebar-brand-sub,
      .sidebar-section-label,
      .kpi-card-label,
      .stat-card-label,
      .section-header,
      .filter-group > span,
      .filter-group > label,
      .ms-trigger .ms-badge,
      .ms-panel-btn,
      .stats-mini-label,
      .stats-mini-badge,
      .variety-badge,
      .variety-cell-label,
      .modal-badge,
      .modal-kpi-label,
      .modal-photo-slot .sub,
      .modal-issues-label,
      .modal-section-title,
      .add-form-badge,
      .fruit-group-count,
      .analytics-table th,
      .planning-group-table-title,
      .age-card-label,
      .calendar-table th,
      .calendar-group-row td,
      .calendar-nodata,
      .density-legend-item,
      .density-card-badge,
      .density-card-orchard,
      .d2-harvest-label,
      .d2-harvest-quality > span,
      .d2-harvest-quality strong,
      .d2-harvest-destination-item,
      .d2-harvest-destination-item strong,
      .d2-month-cell,
      .d2-drying-label,
      .d2-drying-status,
      .d2-drying-metric span,
      .d2-drying-aside-label,
      .d2-drying-aside-copy,
      .d2-drying-link,
      .d2-kpi-card-label,
      .d2-weather-feels,
      .d2-weather-meta,
      .d2-weather-day-name,
      .d2-weather-day-temps,
      .d2-weather-alert,
      .d2-weather-refresh,
      .export-card-header,
      .export-rate-ts,
      .export-rate-source,
      .export-price-note,
      .export-heatmap-table th,
      .export-heatmap-legend,
      .export-status-updated,
      .export-phyto-table th,
      .d2-issue-count {
        font-size: 12px;
      }
    }

    @media (max-width: 960px) {
      #sidebarBrandLogo {
        width: 96px;
        height: 32px;
      }
    }

    /* ── Phone navigation drawer ── */
    @media (max-width: 768px) {
      .sidebar {
        bottom: auto;
        height: 100dvh;
        width: min(304px, calc(100vw - 44px));
        padding:
          max(14px, env(safe-area-inset-top))
          0
          max(10px, env(safe-area-inset-bottom));
        border-right-color: rgba(58, 125, 48, 0.18);
        box-shadow: 18px 0 42px rgba(26, 45, 24, 0.13);
        transition: transform 240ms cubic-bezier(0.22, 1, 0.36, 1);
        will-change: transform;
      }

      .sidebar-toggle {
        top: max(12px, env(safe-area-inset-top));
        left: 12px;
        width: 44px;
        height: 44px;
        border-radius: 13px;
        box-shadow: 0 5px 18px rgba(26, 45, 24, 0.08);
        transition: opacity 130ms ease, transform 180ms ease;
      }

      body.sidebar-drawer-open .sidebar-toggle {
        opacity: 0;
        pointer-events: none;
      }

      .sidebar-close {
        position: absolute;
        top: max(12px, env(safe-area-inset-top));
        right: 12px;
        z-index: 2;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        padding: 0;
        border: 1px solid var(--sidebar-border);
        border-radius: 11px;
        background: rgba(255, 255, 255, 0.58);
        color: var(--muted);
        cursor: pointer;
      }

      .sidebar-close:active {
        background: var(--accent-dim);
        color: var(--accent);
        transform: scale(0.96);
      }

      .sidebar-overlay {
        display: block;
        visibility: hidden;
        opacity: 0;
        background: rgba(26, 45, 24, 0.34);
        backdrop-filter: blur(2px);
        -webkit-backdrop-filter: blur(2px);
        pointer-events: none;
        transition: opacity 210ms ease, visibility 210ms ease;
      }

      .sidebar-overlay.visible {
        visibility: visible;
        opacity: 1;
        pointer-events: auto;
      }

      .sidebar-brand {
        min-height: 51px;
        margin-bottom: 8px;
        padding: 2px 62px 0 18px;
      }

      #sidebarBrandLogo {
        width: 96px;
        height: 32px;
      }

      .sidebar-brand-sub {
        max-width: 180px;
        margin-top: 1px;
        overflow: hidden;
        font-size: 12px;
        line-height: 1.3;
        text-overflow: ellipsis;
        white-space: nowrap;
      }

      .sidebar-section-label {
        padding: 8px 18px 7px;
        font-size: 11px;
        line-height: 1.2;
      }

      .sidebar-nav {
        flex: 1 1 auto;
        min-height: 0;
        padding: 0 10px 10px;
        overflow-y: auto;
        overscroll-behavior: contain;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
      }

      .sidebar-nav::-webkit-scrollbar { display: none; }
      .sidebar-nav li + li { margin-top: 2px; }

      .sidebar-nav li a {
        min-height: 44px;
        gap: 11px;
        padding: 7px 10px;
        border: 0;
        border-radius: 10px;
        font-size: 15px;
        line-height: 1.25;
      }

      .sidebar-nav li a.active {
        box-shadow: inset 0 0 0 1px rgba(58, 125, 48, 0.11);
      }

      .sidebar-nav li a .nav-icon {
        width: 28px;
        height: 28px;
        border-radius: 8px;
        background: rgba(255, 255, 255, 0.46);
      }

      .sidebar-nav li a.active .nav-icon {
        background: rgba(58, 125, 48, 0.12);
      }

      .sidebar-nav li a .nav-icon svg {
        width: 17px;
        height: 17px;
      }

      #sidebarInkBar { display: none; }
    }

/* Varieties: compact crop summaries with expandable planting tables. */
#view-varieties .varieties-heading { align-items: center; margin-bottom: 20px; gap: 16px; }
.varieties-heading p { color: var(--muted); margin-top: 3px; }
.varieties-heading .stats-mini-label { color: var(--muted); font-size: 11px; }
.varieties-heading .stats-mini-val { font-size: 17px; }
.varieties-heading .stats-mini-filter { display: none; }
.varieties-controls { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; }
.varieties-toolbar { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(150px, 190px) minmax(170px, 215px) auto; gap: 12px; align-items: end; }
.varieties-toolbar .filter-group, .varieties-advanced .filter-group { min-width: 0; gap: 5px; }
.varieties-controls .filter-group > label, .varieties-controls .filter-group > span { font-size: 12px; letter-spacing: 0; text-transform: none; }
.varieties-controls .field-input, .varieties-controls .ms-trigger, #varietyFiltersToggle { height: 38px; font-size: 13px; border-radius: 8px; }
#varietyFiltersToggle { border-color: var(--input-border); white-space: nowrap; }
#varietyFiltersToggle[aria-expanded="true"] { background: var(--accent-dim); }
.varieties-controls .ms-chevron { color: var(--muted); font-size: 17px; line-height: 1; }
.varieties-advanced { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding-top: 14px; margin-top: 14px; border-top: 1px solid var(--border); }
#view-varieties [hidden] { display: none !important; }
.varieties-controls .multi-select-panel { min-width: 250px; right: auto; width: 100%; max-width: calc(100vw - 64px); }
.varieties-advanced .filter-group:last-child .multi-select-panel { left: auto; right: 0; }
.varieties-results-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 42px; padding: 8px 0; }
.varieties-results-bar p { color: var(--muted); font-size: 12px; }
.varieties-reset { background: transparent; border: 0; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; padding: 4px 0; }
.varieties-reset:hover { text-decoration: underline; }
.varieties-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.varieties-table th { position: sticky; top: 0; z-index: 2; padding: 10px 12px; background: #EEF3E8; color: var(--muted); font-weight: 600; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; font-size: 12px; }
.varieties-table th:first-child { border-top-left-radius: var(--radius-lg); }
.varieties-table th:last-child { border-top-right-radius: var(--radius-lg); }
.varieties-table th button { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; color: inherit; font: inherit; cursor: pointer; min-height: 24px; }
.varieties-table th[aria-sort="ascending"], .varieties-table th[aria-sort="descending"] { color: var(--accent); }
.varieties-table th button span { font-size: 12px; opacity: .7; }
.varieties-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.varieties-table tr:last-child td { border-bottom: 0; }
.varieties-table tbody tr:hover { background: #F7FAF4; }
.varieties-table tbody tr:focus-within { background: #F0F6EC; }
.varieties-table .varieties-name-cell { width: 25%; }
.varieties-name { display: block; width: 100%; color: var(--text); font: inherit; font-weight: 600; background: none; border: 0; text-align: left; cursor: pointer; overflow-wrap: anywhere; padding: 0; line-height: 1.45; }
.varieties-name:hover .varieties-name-label { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.varieties-row-meta { display: block; font-weight: 400; color: var(--muted); font-size: 11px; margin-top: 2px; }
.varieties-issue { display: inline-flex; justify-content: center; align-items: center; width: 16px; height: 16px; border-radius: 50%; background: var(--amber-dim); color: #875319; font-weight: 700; font-size: 11px; margin-left: 5px; }
.varieties-table .varieties-number { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.varieties-table .varieties-year { white-space: nowrap; }
.varieties-table .varieties-ripening { width: 22%; color: var(--muted); font-size: 12px; }
.varieties-mobile-orchard { display: none; }
.varieties-help { font-size: 12px; color: var(--muted); margin-top: 14px; }
#view-varieties .empty-state { margin-top: 0; }
#view-varieties .empty-state button { margin-top: 16px; }
#view-varieties button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
#cardsGrid { scroll-margin-top: 12px; }
@media (max-width: 1250px) {
  .varieties-table .varieties-density { display: none; }
  .varieties-toolbar { grid-template-columns: minmax(170px, 1fr) minmax(130px, 170px) minmax(160px, 190px) auto; gap: 10px; }
}
@media (max-width: 1050px) {
  .varieties-toolbar { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
  .varieties-toolbar .varieties-search { grid-column: 1 / -1; }
  .varieties-table .varieties-ripening { display: none; }
  .varieties-table .varieties-name-cell { width: 36%; }
}
@media (max-width: 768px) {
  #view-varieties .varieties-heading { flex-direction: row; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
  .varieties-heading .stats-mini-val { font-size: 15px; }
  .varieties-heading .stats-mini-sep { margin: 0 10px; }
  .varieties-advanced { grid-template-columns: minmax(0, 1fr); }
  .varieties-controls .multi-select-panel { min-width: 0; max-width: none; left: 0; right: 0; }
  .main-content:has(#view-varieties.active) { overflow-x: clip; }
  #cardsGrid { scroll-margin-top: 68px; }
  .varieties-table th { top: 56px; }
  .varieties-table .varieties-orchard, .varieties-table .varieties-year { display: none; }
  .varieties-mobile-orchard { display: inline; }
  .varieties-table .varieties-name-cell { width: auto; }
  .varieties-table td, .varieties-table th { padding-left: 10px; padding-right: 10px; }
  .varieties-name { min-height: 30px; }
}
@media (max-width: 520px) {
  .varieties-heading p { font-size: 12px; }
  .varieties-heading .stats-mini-row { width: 100%; }
  .varieties-heading .stats-mini-item { flex: 1; }
  .varieties-controls { padding: 12px; }
  .varieties-toolbar { grid-template-columns: minmax(0, 1fr) auto; }
  .varieties-toolbar > [data-filter-key="orchard"] { grid-column: 1; grid-row: 2; }
  #varietyFiltersToggle { grid-column: 2; grid-row: 2; }
  .varieties-toolbar .filter-group:has(#sortBy) { display: none; }
  .varieties-controls:has(.varieties-advanced:not([hidden])) .filter-group:has(#sortBy) { display: flex; grid-column: 1 / -1; grid-row: 3; }
  .varieties-controls .field-input, .varieties-controls .ms-trigger { font-size: 16px; height: 40px; }
  #varietyFiltersToggle { height: 40px; }
  .varieties-table { font-size: 12px; }
  .varieties-table .varieties-name-cell { width: 51%; }
  .varieties-table td, .varieties-table th { padding-left: 8px; padding-right: 8px; }
  .varieties-row-meta { font-size: 11px; }
  .varieties-table th button { gap: 3px; }
}

.varieties-results-actions { display: flex; align-items: center; gap: 20px; }
.varieties-group-list { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card); }
.varieties-group-columns, .varieties-group-summary { display: grid; grid-template-columns: minmax(0, 1fr) 72px 140px 140px 12px; gap: 16px; align-items: center; padding: 8px 14px; }
.varieties-group-columns { border-bottom: 1px solid var(--border); color: var(--muted); background: #EEF3E8; border-radius: var(--radius-lg) var(--radius-lg) 0 0; font-size: 12px; }
.varieties-group-columns > :not(:first-child) { text-align: right; }
.varieties-group + .varieties-group { border-top: 1px solid var(--border); }
.varieties-group-summary { width: 100%; min-height: 44px; border: 0; background: var(--card); color: var(--text); font: inherit; text-align: left; cursor: pointer; font-size: 13px; line-height: 1.35; }
.varieties-group-summary:hover { background: #F5F9F1; }
.varieties-group:last-child { border-radius: 0 0 var(--radius-lg) var(--radius-lg); overflow: clip; }
.varieties-group-summary:focus-visible { position: relative; outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 6px; }
.varieties-group-name { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.varieties-group-dot { width: 8px; height: 8px; flex-shrink: 0; border-radius: 50%; background: var(--variety-group-color, var(--accent)); }
.varieties-group-count { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.varieties-group-metric { position: relative; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.varieties-partial { position: absolute; right: -6px; top: 0; font-size: 11px; color: var(--muted); }
.varieties-group-chevron { transition: transform 280ms cubic-bezier(.4, 0, .2, 1); font-size: 20px; color: var(--muted); line-height: 1; text-align: center; }
.varieties-group[data-expanded="true"] > .varieties-group-summary .varieties-group-chevron { transform: rotate(90deg); }
/* One intrinsic-size transition avoids measuring heights or hiding native details mid-animation. */
.varieties-group-panel { display: grid; grid-template-rows: 0fr; visibility: hidden; transition: grid-template-rows 280ms cubic-bezier(.4, 0, .2, 1), visibility 0s 280ms; }
.varieties-group[data-expanded="true"] > .varieties-group-panel { grid-template-rows: 1fr; visibility: visible; transition-delay: 0s; }
.varieties-group-clip { min-height: 0; overflow: hidden; }
.varieties-group-body { margin: 0 12px 12px; border: 1px solid var(--border); border-inline-start: 3px solid var(--variety-group-color, var(--accent)); border-radius: 6px; overflow: hidden; background: var(--card); }
.varieties-group-body .varieties-table th:first-child, .varieties-group-body .varieties-table th:last-child { border-radius: 0; }
.varieties-group-body .varieties-table th { position: static; background: var(--accent-dim); color: var(--muted); border-color: var(--border); }
.varieties-group-body .varieties-table td { border-color: var(--border); }
.varieties-group-body .varieties-table tbody tr { background: var(--card); }
.varieties-group-body .varieties-table tbody tr:hover,
.varieties-group-body .varieties-table tbody tr:focus-within { background: var(--accent-dim); }
.varieties-group-note { padding: 8px 14px; border-top: 1px solid var(--border); color: var(--muted); background: var(--card); font-size: 12px; }
.varieties-group:last-child .varieties-group-note { border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
@media (max-width: 1050px) {
  .varieties-group-columns, .varieties-group-summary { grid-template-columns: minmax(0, 1fr) 58px 105px 110px 12px; gap: 12px; }
}
@media (max-width: 600px) {
  .varieties-group-body { margin: 0 8px 8px; }
  .varieties-group-columns, .varieties-group-summary { grid-template-columns: minmax(0, 1fr) 82px 78px 10px; gap: 8px; padding-left: 10px; padding-right: 10px; }
  .varieties-group-count { display: none; }
  .varieties-group-summary { min-height: 48px; font-size: 12px; }
  .varieties-group-name { gap: 7px; }
  .varieties-group-dot { width: 6px; height: 6px; }
  .varieties-results-bar { flex-wrap: wrap; gap: 2px 12px; padding: 10px 0; }
  .varieties-results-actions { gap: 16px; }
  .varieties-results-actions button { min-height: 36px; font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .varieties-group-chevron, .varieties-group-panel { transition: none; }
}
