/* ══════════════════════════════════════════════════════════════════
   ACRE CRM — Agricultural Industrial Design System
   Extracted from design prototype, adapted for Blazor Server + MudBlazor
   ══════════════════════════════════════════════════════════════════ */


/* ═══════════════════════════════════════════════
   CSS CUSTOM PROPERTIES — THE DESIGN SYSTEM
   ═══════════════════════════════════════════════ */

:root {
  /* — Agricultural Industrial palette — */
  --bg-primary: #f5f3ef;
  --bg-secondary: #eae7e0;
  --bg-card: #ffffff;
  /* Edge shadow used by the mobile tab-strip "more tabs →" scroll affordance. */
  --tab-scroll-shadow: rgba(0, 0, 0, 0.16);
  --bg-sidebar: #1a2332;
  --bg-sidebar-hover: #243044;
  --bg-sidebar-active: #2a3a52;
  --bg-header: #ffffff;
  --bg-input: #f8f7f4;
  --bg-tab-active: #ffffff;
  --bg-tab-inactive: transparent;
  --bg-row-hover: #f0eeea;
  --bg-row-alt: #faf9f7;
  --bg-modal-overlay: rgba(26, 35, 50, 0.5);
  --bg-tooltip: #1a2332;
  --bg-badge: #c7552b;

  --text-primary: #1a2332;
  --text-secondary: #5a6474;
  --text-tertiary: #8a919c;
  --text-inverse: #f5f3ef;
  --text-sidebar: #a8b4c4;
  --text-sidebar-active: #ffffff;
  --text-link: #2a6b4a;

  --accent-green: #2a6b4a;
  --accent-green-light: #e8f2ec;
  --accent-green-subtle: #d4e8dc;
  --accent-amber: #c7862b;
  --accent-amber-light: #fef3e2;
  --accent-amber-subtle: #f5ddb8;
  --accent-red: #c7552b;
  --accent-red-light: #fde8e0;
  --accent-blue: #2b6bc7;
  --accent-blue-light: #e0ecfd;

  --border-light: #e2dfd8;
  --border-medium: #d0ccc4;
  --border-heavy: #b8b4ac;

  --shadow-sm: 0 1px 2px rgba(26, 35, 50, 0.06);
  --shadow-md: 0 2px 8px rgba(26, 35, 50, 0.08);
  --shadow-lg: 0 4px 16px rgba(26, 35, 50, 0.1);
  --shadow-card: 0 1px 3px rgba(26, 35, 50, 0.06), 0 0 0 1px rgba(26, 35, 50, 0.04);

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --radius-xl: 14px;

  --sidebar-width: 240px;
  --header-height: 56px;
  --bottom-nav-height: 68px;  /* visible bar height (excludes the safe-area inset, which is added on top) */
  --drawer-width: 280px;
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;

  /* Rank colors */
  --rank-1: #c7552b;
  --rank-2: #c7862b;
  --rank-3: #2b6bc7;
  --rank-4: #5a6474;
  --rank-5: #8a919c;

  /* Font stacks */
  --font-body: 'DM Sans', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', 'Cascadia Code', 'Fira Mono', monospace;
}

/* — DARK MODE — */
/* Support both data-theme attribute (custom layout) and .mud-theme-dark (MudBlazor) */
[data-theme="dark"],
.mud-theme-dark {
  --bg-primary: #0f1419;
  --bg-secondary: #161c24;
  --bg-card: #1a2332;
  --tab-scroll-shadow: rgba(255, 255, 255, 0.14);
  --bg-sidebar: #0d1117;
  --bg-sidebar-hover: #161c24;
  --bg-sidebar-active: #1a2332;
  --bg-header: #1a2332;
  --bg-input: #161c24;
  --bg-tab-active: #1a2332;
  --bg-tab-inactive: transparent;
  --bg-row-hover: #1e2a3a;
  --bg-row-alt: #151d28;
  --bg-modal-overlay: rgba(0, 0, 0, 0.6);
  --bg-tooltip: #243044;

  --text-primary: #e4e8ec;
  --text-secondary: #8a919c;
  --text-tertiary: #5a6474;
  --text-inverse: #1a2332;
  --text-sidebar: #6a7888;
  --text-sidebar-active: #e4e8ec;
  --text-link: #5aab7a;

  --accent-green: #3a8b5a;
  --accent-green-light: #1a2e22;
  --accent-green-subtle: #1e3428;
  --accent-amber-light: #2a2418;
  --accent-red-light: #2a1a18;
  --accent-blue-light: #18202a;

  --border-light: #243044;
  --border-medium: #2a3a52;
  --border-heavy: #3a4a62;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(255, 255, 255, 0.04);
}


/* ═══════════════════════════════════════════════
   RESET & BASE
   ═══════════════════════════════════════════════ */

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

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  overflow: hidden;
  height: 100vh;
}

::selection {
  background: var(--accent-green);
  color: #fff;
}


/* ═══════════════════════════════════════════════
   BLAZOR ERROR UI
   ═══════════════════════════════════════════════ */

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuOTQ5IDUxLjQ4MzcgMjY2Ljc5MiA1Mi4zMjk1TDI5MC42OSA3Ni4zMjk1QzI5Mi4wNTQgNzcuNjk5MiAyOTIuMDU0IDc5LjMwMDggMjkwLjY5IDgwLjY3MDVMMjY2Ljc5MiA5NC42NzA1QzI2NC4zOCA5Ny4wOTg5IDI2MC42MDYgOTUuOTg2NCAyNjAuNjA2IDkyLjUwMTVMODkuOTk3OSA1OC41MDQ3QzI2MC42MDYgNTUuMDMgMjYzLjUwNiA1MSAyNjMuNTA2IDUxWiIgZmlsbD0iI0ZGRTg2MyIgZmlsbC1ydWxlPSJldmVub2RkIi8+PC9nPjwvc3ZnPg==) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}


/* ═══════════════════════════════════════════════
   FORM VALIDATION
   ═══════════════════════════════════════════════ */

.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--accent-green);
}

.invalid {
    outline: 1px solid var(--accent-red);
}

.validation-message {
    color: var(--accent-red);
}


/* ═══════════════════════════════════════════════
   LAYOUT SHELL
   ═══════════════════════════════════════════════ */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--header-height) 1fr;
  height: 100vh;
  transition: grid-template-columns var(--transition-normal);

  /* Re-resolve background and color at .app-shell scope so the data-theme="dark"
     variables defined here propagate correctly. Without this, descendants inherit
     the literal color set on <body> (which is outside .app-shell and always reads
     the light-mode variables), and any element that doesn't set its own color
     stays in light-mode text on a dark-mode background. */
  background: var(--bg-primary);
  color: var(--text-primary);
}

/* — SIDEBAR — */
.sidebar {
  grid-row: 1 / -1;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 100;
}

.sidebar-brand {
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

.sidebar-brand-icon {
  width: 36px;
  height: 36px;
  background: #fff;            /* white chip behind the Apache logo (logo art is on white) */
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.sidebar-brand-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
}

.sidebar-brand-name {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 15px;
  color: var(--text-sidebar-active);
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.sidebar-brand-sub {
  font-size: 10px;
  color: var(--text-sidebar);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-weight: 500;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 8px;
}

.nav-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-sidebar);
  padding: 16px 12px 6px;
  font-weight: 600;
  opacity: 0.6;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  color: var(--text-sidebar);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 450;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  margin-bottom: 1px;
}

.nav-item:hover {
  background: var(--bg-sidebar-hover);
  color: var(--text-sidebar-active);
}

.nav-item.active {
  background: var(--bg-sidebar-active);
  color: var(--text-sidebar-active);
  font-weight: 550;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--accent-green);
  border-radius: 0 2px 2px 0;
}

.nav-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.75;
  font-size: 15px;
}

.nav-item.active .nav-icon { opacity: 1; }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.sidebar-user:hover { background: var(--bg-sidebar-hover); }

.sidebar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-green);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-sidebar-active);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 11px;
  color: var(--text-sidebar);
}

.sidebar-logout-form {
  display: inline-flex;
  margin: 0;
}

.sidebar-logout-btn {
  background: transparent;
  border: none;
  padding: 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-sidebar);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.sidebar-logout-btn:hover {
  background: var(--bg-sidebar-hover);
  color: var(--text-sidebar-active);
}


/* — TOP HEADER — */
.top-header {
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 50;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.breadcrumb-item {
  color: var(--text-tertiary);
  text-decoration: none;
  cursor: pointer;
  transition: color var(--transition-fast);
}

.breadcrumb-item:hover { color: var(--text-primary); }

.breadcrumb-sep {
  color: var(--text-tertiary);
  font-size: 10px;
  opacity: 0.6;
}

.breadcrumb-current {
  color: var(--text-primary);
  font-weight: 600;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  position: relative;
  font-size: 17px;
}

.header-btn:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.header-btn .badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  background: var(--bg-badge);
  border-radius: 50%;
  border: 2px solid var(--bg-header);
}

.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  background: var(--bg-input);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  transition: all var(--transition-fast);
  color: var(--text-secondary);
}

.theme-toggle:hover {
  border-color: var(--border-medium);
  color: var(--text-primary);
}

.header-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  height: 36px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  min-width: 280px;
  transition: all var(--transition-fast);
  cursor: text;
}

.header-search:focus-within {
  border-color: var(--accent-green);
  box-shadow: 0 0 0 3px var(--accent-green-light);
}

.header-search-icon {
  color: var(--text-tertiary);
  font-size: 14px;
  flex-shrink: 0;
}

.header-search input {
  border: none;
  background: none;
  outline: none;
  font-family: inherit;
  font-size: 13px;
  color: var(--text-primary);
  width: 100%;
}

.header-search input::placeholder { color: var(--text-tertiary); }

.header-search-shortcut {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-tertiary);
  background: var(--bg-primary);
  padding: 2px 5px;
  border-radius: 3px;
  border: 1px solid var(--border-light);
  white-space: nowrap;
}


/* ═══════════════════════════════════════════════
   MAIN CONTENT AREA
   ═══════════════════════════════════════════════ */

.main-content {
  overflow-y: auto;
  padding: 24px;
  background: var(--bg-primary);
}


/* ═══════════════════════════════════════════════
   PAGE HEADER
   ═══════════════════════════════════════════════ */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-title {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.4px;
  line-height: 1.2;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.page-actions {
  display: flex;
  gap: 8px;
}


/* ═══════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent-green);
  color: #fff;
  border-color: var(--accent-green);
}

.btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

.btn-secondary:hover {
  background: var(--bg-secondary);
  border-color: var(--border-heavy);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}


/* ═══════════════════════════════════════════════
   TABS
   ═══════════════════════════════════════════════ */

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border-light);
  margin-bottom: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: all var(--transition-fast);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: inherit;
}

.tab:hover {
  color: var(--text-primary);
}

.tab.active {
  color: var(--accent-green);
  border-bottom-color: var(--accent-green);
  font-weight: 600;
}

.tab .tab-count {
  font-size: 11px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  padding: 1px 7px;
  border-radius: 10px;
  margin-left: 6px;
  font-weight: 600;
  font-family: var(--font-mono);
}

.tab.active .tab-count {
  background: var(--accent-green-light);
  color: var(--accent-green);
}


/* ═══════════════════════════════════════════════
   DATA TABLE
   ═══════════════════════════════════════════════ */

.data-table-wrapper {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.data-table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  gap: 12px;
}

.data-table-toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.data-table-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border-light);
  background: var(--bg-input);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.filter-chip:hover {
  border-color: var(--border-medium);
  color: var(--text-primary);
}

.filter-chip.active {
  border-color: var(--accent-green);
  background: var(--accent-green-light);
  color: var(--accent-green);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: auto;
}

.data-table thead th {
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-tertiary);
  background: var(--bg-input);
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
  position: sticky;
  top: 0;
  cursor: pointer;
  user-select: none;
}

.data-table thead th:hover {
  color: var(--text-secondary);
}

.data-table tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition-fast);
  cursor: pointer;
}

.data-table tbody tr:hover {
  background: var(--bg-row-hover);
}

.data-table tbody tr:nth-child(even) {
  background: var(--bg-row-alt);
}

.data-table tbody tr:nth-child(even):hover {
  background: var(--bg-row-hover);
}

.data-table tbody td {
  padding: 9px 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.data-table tbody td:first-child {
  max-width: 40px;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 11px;
  font-family: var(--font-mono);
}

.rank-1 { background: rgba(199, 85, 43, 0.12); color: var(--rank-1); }
.rank-2 { background: rgba(199, 134, 43, 0.12); color: var(--rank-2); }
.rank-3 { background: rgba(43, 107, 199, 0.12); color: var(--rank-3); }
.rank-4 { background: rgba(90, 100, 116, 0.1); color: var(--rank-4); }
.rank-5 { background: rgba(138, 145, 156, 0.1); color: var(--rank-5); }

.status-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.status-prospect { background: var(--accent-blue-light); color: var(--accent-blue); }
.status-owner { background: var(--accent-green-light); color: var(--accent-green); }
.status-used-owner { background: rgba(42, 107, 74, 0.07); color: var(--accent-green); }
.status-used-prospect { background: rgba(43, 107, 199, 0.07); color: var(--accent-blue); }
.status-previous { background: var(--accent-amber-light); color: var(--accent-amber); }

.overdue {
  color: var(--accent-red);
  font-weight: 600;
}

.rd-initials {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Matched contact-log excerpt under a farmer name in the search results. */
.fc-snippet {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
  line-height: 1.3;
}

/* Mobile-only dashboard card (and the older name-only title) — hidden on desktop,
   rendered as the card under 768px (see the .dash-cards block) so the dashboard shows
   a fixed field set regardless of the desktop column picker. */
.fc-mobile-name, .fc-mobile-card { display: none; }

/* Mobile-only section dropdown that replaces the action-screen tab bar on phones
   (see the 768px block). Hidden on desktop, where the horizontal tabs are shown. */
.tab-select { display: none; }

.data-table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-top: 1px solid var(--border-light);
  font-size: 12px;
  color: var(--text-secondary);
}

.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pagination button {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.pagination button:hover {
  border-color: var(--border-medium);
  color: var(--text-primary);
}

.pagination button.active {
  background: var(--accent-green);
  color: #fff;
  border-color: var(--accent-green);
}


/* ═══════════════════════════════════════════════
   ACTION SCREEN
   ═══════════════════════════════════════════════ */

.action-screen {
  display: none;
}

.action-screen.visible {
  display: block;
}

.dashboard-view.hidden {
  display: none;
}

.action-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.action-back {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  font-size: 16px;
  flex-shrink: 0;
}

.action-back:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.action-farmer-info {
  flex: 1;
}

.action-farmer-name {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.action-farmer-meta {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 2px;
}

.action-farmer-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.action-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  align-items: start;
}

/* Left column — farmer details card */
.farmer-details-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  position: sticky;
  top: 0;
}

.farmer-details-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.farmer-details-title {
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-tertiary);
}

.farmer-details-body {
  padding: 4px 0;
}

.detail-row {
  display: flex;
  align-items: flex-start;
  padding: 8px 16px;
  gap: 8px;
  transition: background var(--transition-fast);
  cursor: default;
}

.detail-row:hover {
  background: var(--bg-row-hover);
}

.detail-label {
  font-size: 12px;
  color: var(--text-tertiary);
  width: 90px;
  flex-shrink: 0;
  padding-top: 1px;
}

.detail-value {
  font-size: 13px;
  color: var(--text-primary);
  flex: 1;
  word-break: break-word;
}

.detail-value.editable {
  cursor: pointer;
  border-bottom: 1px dashed var(--border-medium);
  padding-bottom: 1px;
}

.detail-value.editable:hover {
  border-bottom-color: var(--accent-green);
  color: var(--accent-green);
}

.detail-section-divider {
  height: 1px;
  background: var(--border-light);
  margin: 4px 16px;
}

/* Sub-data summary strip */
.subdata-strip {
  padding: 12px 16px;
  border-top: 1px solid var(--border-light);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.subdata-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}

.subdata-chip:hover {
  border-color: var(--accent-green);
  color: var(--accent-green);
  background: var(--accent-green-light);
}

.subdata-chip .chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-green);
}

.subdata-chip.empty .chip-dot {
  background: var(--border-medium);
}

.subdata-chip.empty {
  opacity: 0.5;
}


/* Right column — tabbed content */
.action-content {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  min-height: 500px;
}

.action-content .tabs {
  padding: 0 16px;
  margin-bottom: 0;
}

.action-tab-body {
  padding: 16px;
}


/* Activity timeline */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.timeline-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
  position: relative;
}

.timeline-item:last-child { border-bottom: none; }

.timeline-dot-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 20px;
  flex-shrink: 0;
  padding-top: 3px;
}

.timeline-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border-medium);
  flex-shrink: 0;
}

.timeline-dot.sale { background: var(--accent-green); }
.timeline-dot.call { background: var(--accent-blue); }
.timeline-dot.email { background: var(--accent-amber); }
.timeline-dot.rank { background: var(--accent-red); }

.timeline-line {
  width: 2px;
  flex: 1;
  background: var(--border-light);
  margin-top: 4px;
}

.timeline-content {
  flex: 1;
  min-width: 0;
}

.timeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.timeline-action {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
}

.timeline-code {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
  background: var(--bg-input);
  padding: 1px 6px;
  border-radius: 3px;
}

.timeline-date {
  font-size: 12px;
  color: var(--text-tertiary);
  white-space: nowrap;
}

.timeline-by {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.timeline-notes {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.timeline-next-contact {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--accent-amber);
  background: var(--accent-amber-light);
  padding: 2px 8px;
  border-radius: 4px;
}


/* ═══════════════════════════════════════════════
   LOG CONTACT FORM (inline)
   ═══════════════════════════════════════════════ */

.log-contact-form {
  background: var(--accent-green-light);
  border: 1px solid var(--accent-green-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
}

.log-contact-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 12px;
  color: var(--accent-green);
  display: flex;
  align-items: center;
  gap: 6px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-group.full { grid-column: 1 / -1; }

.form-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-tertiary);
}

.form-input, .form-select, .form-textarea {
  padding: 8px 10px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  font-family: inherit;
  font-size: 13px;
  color: var(--text-primary);
  transition: all var(--transition-fast);
  outline: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent-green);
  box-shadow: 0 0 0 3px var(--accent-green-light);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 4px;
}


/* ═══════════════════════════════════════════════
   STAT CARDS (analytics strip)
   ═══════════════════════════════════════════════ */

.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-tertiary);
  font-weight: 600;
}

.stat-value {
  font-family: var(--font-heading);
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.stat-change {
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 3px;
}

.stat-change.up { color: var(--accent-green); }
.stat-change.down { color: var(--accent-red); }

/* Clickable pipeline banners (RD/ACE). Inherit .stat-card look; add button reset + affordance. */
.stat-card-clickable {
  cursor: pointer;
  text-align: left;
  border: 1px solid transparent;
  font-family: inherit;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}
.stat-card-clickable:hover { border-color: var(--accent-green); box-shadow: var(--shadow-md); }
.stat-card-clickable:focus-visible { outline: 2px solid var(--accent-green); outline-offset: 2px; }
.stat-card-clickable.active {
  border-color: var(--accent-green);
  box-shadow: 0 0 0 2px var(--accent-green-light) inset;
}

/* Active pipeline filter chip above the grid */
.pipeline-active-chip {
  display: inline-flex; align-items: center; gap: 8px;
  margin: 4px 0 12px; padding: 6px 12px;
  background: var(--accent-green-light); color: var(--text-primary);
  border-radius: var(--radius-md); font-size: 13px;
}
.pipeline-chip-clear {
  background: none; border: none; cursor: pointer; font-size: 18px; line-height: 1;
  color: var(--text-secondary); padding: 0 2px;
}
.pipeline-chip-clear:hover { color: var(--accent-red); }


/* ═══════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════ */

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.main-content > * {
  animation: fadeIn 0.3s ease forwards;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Loading pulse — used by the dashboard tab-config loading bar (which referenced an
   undefined `shimmer` keyframe before, so it sat static). Now it gently pulses. */
@keyframes shimmer {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* Skeleton sweep for the dashboard stat-card placeholders while stats load.
   The bar height is intentionally shorter than the 26px stat number — the line box
   (line-height 1.2) keeps the card height identical loaded vs. loading, so there's
   no layout shift when the real number arrives. */
@keyframes skeleton-sweep {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

.stat-skeleton {
  display: inline-block;
  width: 72px;
  height: 20px;
  vertical-align: middle;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--border-light) 50%, var(--bg-secondary) 75%);
  background-size: 200% 100%;
  animation: skeleton-sweep 1.3s ease-in-out infinite;
}


/* ═══════════════════════════════════════════════
   IMPERSONATION BANNER
   ═══════════════════════════════════════════════ */

.impersonation-banner {
  display: none;
  grid-column: 1 / -1;
  background: linear-gradient(90deg, #c7552b, #d4693e);
  color: #fff;
  padding: 0 24px;
  height: 40px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 13px;
  font-weight: 550;
  z-index: 200;
  position: relative;
}

.impersonation-banner.visible {
  display: flex;
}

.impersonation-banner .imp-icon {
  font-size: 16px;
}

.impersonation-banner .imp-text {
  display: flex;
  align-items: center;
  gap: 6px;
}

.impersonation-banner .imp-user {
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.impersonation-banner .imp-since {
  opacity: 0.8;
  font-size: 12px;
  margin-left: 8px;
}

.impersonation-banner .imp-return-btn {
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.35);
  color: #fff;
  padding: 4px 14px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-left: 8px;
}

.impersonation-banner .imp-return-btn:hover {
  background: rgba(255,255,255,0.35);
  border-color: rgba(255,255,255,0.5);
}

.app-shell.impersonating {
  grid-template-rows: 40px var(--header-height) 1fr;
}

.app-shell.impersonating .sidebar {
  grid-row: 1 / -1;
}

/* Impersonation sidebar tint */
.app-shell.impersonating .sidebar-brand {
  border-bottom-color: rgba(199, 85, 43, 0.4);
}

.app-shell.impersonating .sidebar-brand-icon {
  background: var(--accent-red);
}


/* ═══════════════════════════════════════════════
   SEARCH PAGE
   ═══════════════════════════════════════════════ */

.search-view {
  display: none;
}

.search-view.visible {
  display: block;
}

.search-form-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  margin-bottom: 16px;
}

.search-form-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.search-form-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-form-toggle {
  font-size: 12px;
  color: var(--text-link);
  cursor: pointer;
  font-weight: 500;
}

.search-form-toggle:hover {
  text-decoration: underline;
}

.search-form-body {
  padding: 16px;
}

.search-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.search-row-wide {
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}

.search-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.search-group.span-2 {
  grid-column: span 2;
}

/* Desktop: make the Farmer Search form use the FULL width. auto-fit (vs auto-fill)
   collapses the surplus tracks so the real fields stretch edge-to-edge instead of
   clustering on the left, and empty placeholder cells are removed from the grid.
   Scoped to .farmer-search so the Dealers list (shares .search-row) is untouched,
   and gated to ≥769px so the mobile 2-column layout (≤768px) still wins. */
@media (min-width: 769px) {
  .farmer-search .search-row {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }
  .farmer-search .search-group:empty {
    display: none;
  }
}

.search-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-tertiary);
}

.search-input-row {
  display: flex;
  gap: 0;
}

.search-input-row .form-input {
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  border-left: none;
  flex: 1;
  min-width: 0;
}

.search-input-row .search-criteria {
  padding: 6px 6px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  background: var(--bg-secondary);
  font-family: inherit;
  font-size: 11px;
  color: var(--text-secondary);
  min-width: 78px;
  outline: none;
  cursor: pointer;
}

.search-input-row .search-criteria:focus {
  border-color: var(--accent-green);
}

.search-form-section {
  border-top: 1px solid var(--border-light);
  padding-top: 12px;
  margin-top: 6px;
}

.search-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-tertiary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.search-checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
}

.search-checkbox-group label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 2px 0;
}

.search-checkbox-group label:hover {
  color: var(--text-primary);
}

.search-checkbox-group input[type="checkbox"] {
  accent-color: var(--accent-green);
  width: 14px;
  height: 14px;
}

.search-form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 16px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-input);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.search-results-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.search-results-count {
  font-weight: 600;
  color: var(--text-primary);
}

.saved-filters {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
}

.saved-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border-light);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.saved-filter-chip:hover {
  border-color: var(--accent-green);
  color: var(--accent-green);
}

.saved-filter-chip.active {
  border-color: var(--accent-green);
  background: var(--accent-green-light);
  color: var(--accent-green);
  font-weight: 600;
}

.saved-filter-label {
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 500;
  margin-right: 4px;
}


/* ═══════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════ */

@media (max-width: 1100px) {
  .action-layout {
    grid-template-columns: 1fr;
  }

  .farmer-details-card {
    position: static;
  }

  .stats-strip {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  /* iOS Safari counts the area behind the address bar + bottom toolbar in 100vh,
     so the shell is TALLER than the visible screen and the bottom-nav row lands
     off-screen behind the toolbar (and body{overflow:hidden} means you can't even
     scroll to it). Dynamic viewport height (dvh) = the VISIBLE viewport, which pins
     the bottom nav on-screen. 100vh stays as the fallback for browsers without dvh. */
  body { height: 100dvh; }

  .app-shell {
    grid-template-columns: 1fr;
    /* Bottom row grows by the safe-area inset so the nav clears the iOS home
       indicator without overflowing a fixed track (the nav also pads itself). */
    grid-template-rows: var(--header-height) 1fr calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
    grid-template-areas:
      "header"
      "content"
      "bottomnav";
    height: 100dvh;
  }

  .sidebar { display: none; }              /* replaced by drawer + bottom bar in later batches */
  .top-header { grid-area: header; }
  .main-content {
    grid-area: content;
    overflow-y: auto;
    /* small breathing room above the bottom bar (which itself clears the inset) */
    padding-bottom: 8px;
  }

  .stats-strip { grid-template-columns: 1fr 1fr; }
  .data-table-wrapper { overflow-x: auto; }

  /* Action (farmer profile) screen — keep everything within the viewport.
     The desktop 2-col grid already collapses to 1 col (≤1100px), but the column
     kept min-width:auto, so the non-wrapping 5-tab bar (min-content ~649px) forced
     the column — and the page — wider than the screen (main-content then scrolled
     sideways). minmax(0,1fr) + min-width:0 let the column shrink to the viewport;
     the tab bar wraps instead of forcing horizontal scroll. */
  .action-layout { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .action-layout > * { min-width: 0; }
  /* Replace the 5-tab bar with a compact dropdown on phones. */
  .action-content .tabs { display: none; }
  .tab-select {
    display: block;
    width: auto;
    margin: 6px 16px 0;
    padding: 9px 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
  }

  /* Farmer Search filter form → fit + densify on phones. The desktop auto-fill
     grid (minmax(180px,1fr)) plus .span-2 forced fields past the screen edge.
     Collapse to 2 columns with minmax(0,1fr) (no horizontal scroll); wide,
     name-criteria, and checkbox fields take the full width; empty filler cells
     are hidden so they don't leave gaps. */
  .search-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .search-group:empty { display: none; }
  .search-group.span-2,
  .search-group:has(.search-input-row),
  .search-group:has(.search-checkbox-group) { grid-column: 1 / -1; }

  /* Batch 1D — header cleanup: search lives on the Search page on phone. */
  .header-search { display: none; }
  .top-header { padding: 0 8px; }

  /* Batch 1D — Issue A (impersonation grid rows on phone).
     The impersonation banner is a SIBLING rendered ABOVE .app-shell in normal
     flow (see MainLayout.razor), so .app-shell itself does NOT need a banner
     grid row on phone. The desktop .app-shell.impersonating rule (0,2,0 spec)
     would otherwise win over the phone .app-shell rule (0,1,0) regardless of
     source order and break the stacked named areas. Re-establish the same
     stacked header/content/bottomnav layout when the impersonating class is
     present at phone width. */
  .app-shell.impersonating {
    grid-template-rows: var(--header-height) 1fr calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
    grid-template-areas:
      "header"
      "content"
      "bottomnav";
  }

  /* Batch 1D — Part 4: lock content scroll behind the open drawer. */
  .app-shell.drawer-open .main-content { overflow: hidden; }
}


/* ═══════════════════════════════════════════════
   SCROLLBAR STYLING
   ═══════════════════════════════════════════════ */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background-color: rgba(26, 35, 50, 0.15);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background-color: rgba(26, 35, 50, 0.3);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb,
.mud-theme-dark ::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.15);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover,
.mud-theme-dark ::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.25);
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(26, 35, 50, 0.15) transparent;
}


/* ═══════════════════════════════════════════════
   HTML CONTENT EDITOR (app-specific)
   ═══════════════════════════════════════════════ */

.html-code-editor .mud-input-slot textarea,
.html-code-editor .mud-input textarea {
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
    tab-size: 2;
}

.template-list-active {
    background-color: var(--accent-green-light);
    font-weight: 600;
}


/* ═══════════════════════════════════════════════
   MUDBLAZOR COMPONENT OVERRIDES
   ═══════════════════════════════════════════════ */

/* Force MudBlazor components to use the design system font */
.mud-dialog .mud-dialog-content { font-family: var(--font-body); }
.mud-snackbar { font-family: var(--font-body); }
.mud-input { font-family: var(--font-body); }
.mud-select { font-family: var(--font-body); }
.mud-table { font-family: var(--font-body); }

/* MudBlazor card overrides */
.mud-card {
    box-shadow: var(--shadow-card) !important;
    border-radius: var(--radius-lg) !important;
    border: none !important;
}

/* MudBlazor table overrides */
.mud-table .mud-table-head .mud-table-cell {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-tertiary);
    background-color: var(--bg-secondary);
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-light);
}

.mud-table .mud-table-body .mud-table-row {
    transition: background-color 100ms ease;
}

.mud-table .mud-table-body .mud-table-row:nth-child(even) {
    background-color: var(--bg-row-alt);
}

.mud-table .mud-table-body .mud-table-row:hover {
    background-color: var(--bg-row-hover) !important;
}

.mud-table .mud-table-body .mud-table-cell {
    padding: 8px 14px;
    font-size: 13.5px;
    border-bottom: 1px solid var(--border-light);
}

/* MudBlazor DataGrid overrides */
.mud-data-grid .mud-table-head .mud-table-cell {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-tertiary);
    background-color: var(--bg-secondary);
    padding: 10px 14px;
}

.mud-data-grid .mud-table-body .mud-table-row:nth-child(even) {
    background-color: var(--bg-row-alt);
}

.mud-data-grid .mud-table-body .mud-table-row:hover {
    background-color: var(--bg-row-hover) !important;
}

/* MudBlazor tab overrides */
.mud-tabs .mud-tab {
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 13.5px;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text-secondary);
    min-width: auto;
    padding: 10px 16px;
}

.mud-tabs .mud-tab.mud-tab-active {
    color: var(--accent-green) !important;
    font-weight: 600;
}

.mud-tabs .mud-tab-slider {
    background-color: var(--accent-green) !important;
}

/* MudBlazor button overrides */
.mud-button-root {
    text-transform: none !important;
    letter-spacing: 0 !important;
    font-weight: 600 !important;
    border-radius: var(--radius-md) !important;
}

.mud-button-filled.mud-button-primary {
    background-color: var(--accent-green) !important;
}

.mud-button-filled.mud-button-primary:hover {
    background-color: #235d40 !important;
}

/* MudBlazor dialog overrides */
.mud-dialog {
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-lg) !important;
}

.mud-dialog .mud-dialog-title {
    font-family: var(--font-heading) !important;
    font-weight: 600 !important;
    font-size: 16px !important;
    padding: 16px 20px !important;
    border-bottom: 1px solid var(--border-light) !important;
}

.mud-dialog .mud-dialog-content {
    padding: 20px !important;
    font-family: var(--font-body) !important;
}

.mud-dialog .mud-dialog-actions {
    padding: 12px 20px !important;
    border-top: 1px solid var(--border-light) !important;
    gap: 8px !important;
}

/* Form input focus rings — green glow matching prototype */
.mud-input-outlined.mud-input-focused .mud-input-outlined-border {
    border-color: var(--accent-green) !important;
    box-shadow: 0 0 0 3px var(--accent-green-light) !important;
}

/* MudSelect / MudAutocomplete dropdown list */
.mud-popover-open .mud-list {
    font-family: var(--font-body) !important;
    font-size: 13px !important;
}

/* MudDatePicker toolbar */
.mud-picker .mud-picker-toolbar {
    background: var(--accent-green) !important;
}

/* Snackbar border-radius */
.mud-snackbar {
    border-radius: var(--radius-md) !important;
}

/* Contact Log dialog — green-tinted content area (matches prototype .log-contact-form feel) */
.contact-log-dialog .mud-dialog-content {
    background: var(--accent-green-light) !important;
    border: 1px solid var(--accent-green-subtle);
}

/* MudBlazor chip overrides */
.mud-chip {
    font-size: 12px;
    font-weight: 500;
    border-radius: var(--radius-sm) !important;
}

/* MudBlazor input overrides */
.mud-input-outlined .mud-input-outlined-border {
    border-color: var(--border-light);
    border-radius: var(--radius-md);
}

.mud-input-outlined:hover .mud-input-outlined-border {
    border-color: var(--border-medium);
}

.mud-input-outlined.mud-input-focused .mud-input-outlined-border {
    border-color: var(--accent-green);
}

/* MudBlazor popover overrides */
.mud-popover {
    box-shadow: var(--shadow-lg) !important;
    border-radius: var(--radius-lg) !important;
    border: 1px solid var(--border-light);
}

/* MudBlazor breadcrumb overrides */
.breadcrumb-bar {
    min-height: 24px;
}

.mud-breadcrumbs li {
    font-size: 13px;
}

.mud-breadcrumbs li a {
    color: var(--text-tertiary);
}

.mud-breadcrumbs li:last-child {
    color: var(--text-primary);
    font-weight: 500;
}

/* MudBlazor main content background */
.mud-main-content {
    background-color: var(--bg-primary) !important;
}

/* Notification panel */
.notification-unread {
    background-color: var(--accent-green-light);
}

.notification-list .mud-list-item {
    border-bottom: 1px solid var(--border-light);
}

.notification-list .mud-list-item:last-child {
    border-bottom: none;
}

/* Login page (AuthLayout) */
.login-page {
    background-color: var(--bg-primary);
    min-height: 100vh;
}

.login-card {
    box-shadow: var(--shadow-card) !important;
    border-radius: var(--radius-xl) !important;
    border: 1px solid var(--border-light) !important;
}

.login-brand-icon {
    width: 48px;
    height: 48px;
    background: var(--accent-green);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-brand-icon .mud-icon-root {
    color: #ffffff !important;
    font-size: 28px;
}

.login-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 26px;
    color: var(--text-primary);
}


/* ═══════════════════════════════════════════════
   DARK MODE — ADDITIONAL ELEMENT OVERRIDES
   ═══════════════════════════════════════════════ */

/* Contact log dialog: darken the green tint in dark mode */
[data-theme="dark"] .contact-log-dialog .mud-dialog-content,
.mud-theme-dark .contact-log-dialog .mud-dialog-content {
    background: var(--accent-green-light) !important;
    border-color: var(--accent-green-subtle) !important;
}

/* Search form card background in dark mode */
[data-theme="dark"] .search-form-card,
.mud-theme-dark .search-form-card {
    background: var(--bg-card);
    box-shadow: var(--shadow-card);
}

[data-theme="dark"] .search-form-actions,
.mud-theme-dark .search-form-actions {
    background: var(--bg-secondary);
}

/* Saved filter chips in dark mode */
[data-theme="dark"] .saved-filter-chip,
.mud-theme-dark .saved-filter-chip {
    background: var(--bg-card);
    border-color: var(--border-light);
    color: var(--text-secondary);
}

[data-theme="dark"] .saved-filter-chip:hover,
.mud-theme-dark .saved-filter-chip:hover {
    border-color: var(--accent-green);
    color: var(--accent-green);
}

[data-theme="dark"] .saved-filter-chip.active,
.mud-theme-dark .saved-filter-chip.active {
    background: var(--accent-green-light);
    border-color: var(--accent-green);
    color: var(--accent-green);
}

/* Pagination buttons in dark mode */
[data-theme="dark"] .pagination button,
.mud-theme-dark .pagination button {
    background: var(--bg-card);
    border-color: var(--border-light);
    color: var(--text-secondary);
}

[data-theme="dark"] .pagination button:hover,
.mud-theme-dark .pagination button:hover {
    border-color: var(--border-medium);
    color: var(--text-primary);
}

[data-theme="dark"] .pagination button.active,
.mud-theme-dark .pagination button.active {
    background: var(--accent-green);
    color: #fff;
    border-color: var(--accent-green);
}

/* MudDialog borders in dark mode */
[data-theme="dark"] .mud-dialog .mud-dialog-title,
.mud-theme-dark .mud-dialog .mud-dialog-title {
    border-bottom-color: var(--border-light) !important;
}

[data-theme="dark"] .mud-dialog .mud-dialog-actions,
.mud-theme-dark .mud-dialog .mud-dialog-actions {
    border-top-color: var(--border-light) !important;
}

.login-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Section heading utility */
.section-heading {
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Monospace data values */
.monospace {
    font-family: var(--font-mono);
    font-size: 13px;
}

/* ═══════════════════════════════════════════════
   IMPERSONATION BANNER
   Displayed at the very top of the page when an
   admin is logged in as a different user.
   ═══════════════════════════════════════════════ */

.impersonation-banner {
    background: linear-gradient(90deg, #f59e0b, #d97706);
    color: #fff;
    padding: 8px 16px;
    text-align: center;
    font-weight: 600;
    font-size: 14px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    position: relative;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.impersonation-icon {
    font-size: 16px;
    line-height: 1;
}

.impersonation-stop-btn {
    margin-left: 12px;
    background: #fff;
    color: #d97706;
    border: none;
    padding: 4px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 700;
    font-size: 13px;
    line-height: 1.5;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.impersonation-stop-btn:hover {
    background: #fef3c7;
    color: #b45309;
}

/* Dark mode: keep the amber brand visible */
[data-theme="dark"] .impersonation-banner {
    background: linear-gradient(90deg, #b45309, #92400e);
}

[data-theme="dark"] .impersonation-stop-btn {
    background: #1a2332;
    color: #fbbf24;
}

[data-theme="dark"] .impersonation-stop-btn:hover {
    background: #243044;
    color: #fde68a;
}

/* ═══════════════════════════════════════════════
   DASHBOARD COLUMN PICKER POPOVER
   ═══════════════════════════════════════════════ */

.column-picker-backdrop {
    position: fixed;
    inset: 0;
    background: transparent;
    z-index: 999;
}

.column-picker {
    position: absolute;
    top: 44px;
    right: 16px;
    width: 280px;
    max-height: 480px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.column-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
}

.column-picker-body {
    overflow-y: auto;
    padding: 6px 10px;
    flex: 1;
}

.column-picker-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 4px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
}

.column-picker-row:last-child {
    border-bottom: none;
}

.column-picker-row button[disabled] {
    opacity: 0.35;
    cursor: not-allowed;
}

.column-picker-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-top: 1px solid var(--border-light);
    background: var(--bg-input);
}

/* Give the wrapper a positioning context so the picker anchors correctly */
.data-table-wrapper {
    position: relative;
}

/* ═══════════════════════════════════════════════
   SHARED MODAL (used where MudDialog + @bind-IsVisible
   was removed in MudBlazor v7 migration; we conditionally
   render this modal shell instead)
   ═══════════════════════════════════════════════ */

.acre-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1400;
    animation: acre-modal-fade 120ms ease-out;
}

.acre-modal-shell {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 1401;
    min-width: 420px;
    max-width: 640px;
    max-height: 85vh;
    width: 90vw;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: acre-modal-rise 140ms ease-out;
}

.acre-modal-title {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.acre-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    color: var(--text-primary);
}

.acre-modal-actions {
    padding: 12px 20px;
    border-top: 1px solid var(--border-light);
    background: var(--bg-input);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

@keyframes acre-modal-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes acre-modal-rise {
    from { opacity: 0; transform: translate(-50%, -46%); }
    to   { opacity: 1; transform: translate(-50%, -50%); }
}

/* Dark mode — same palette variables work, but nudge backdrop darker */
[data-theme="dark"] .acre-modal-backdrop,
.mud-theme-dark .acre-modal-backdrop {
    background: rgba(0, 0, 0, 0.65);
}

/* MudBlazor popovers (MudSelect dropdown options, autocomplete menus, etc.)
   default to z-index 1200. Our custom acre-modal shell is at 1401, which
   means dropdowns opened inside the modal would render BEHIND it. Boost
   open popovers above the modal so they appear correctly. */
.mud-popover-open {
    z-index: 1500 !important;
}

/* Mobile bottom navigation — hidden on desktop, shown < 768px */
.bottom-nav { display: none; }

@media (max-width: 768px) {
  .bottom-nav {
    grid-area: bottomnav;
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    background: var(--bg-sidebar);
    border-top: 1px solid var(--bg-sidebar-hover);
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 200;
  }
  .bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 48px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-sidebar);
    text-decoration: none;
    font-size: 10px;
    font-weight: 600;
  }
  .bottom-nav-item.active { color: var(--text-sidebar-active); }
  .bottom-nav-icon { font-size: 20px; line-height: 1; }
  .bottom-nav-label {
    font-size: 10px;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* ══════════════════════════════════════════════════════════════════
   MOBILE NAV DRAWER (Batch 1C) — hamburger + left slide-out drawer
   Hidden on desktop; shown < 768px. Reuses the full NavMenu component.
   ══════════════════════════════════════════════════════════════════ */
.mobile-hamburger { display: none; }
.mobile-drawer, .mobile-drawer-backdrop { display: none; }

@media (max-width: 768px) {
  .mobile-hamburger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px; height: 44px;
    background: none; border: none;
    font-size: 22px; cursor: pointer;
    color: var(--text-primary);
  }

  .mobile-drawer-backdrop {
    display: block;
    position: fixed; inset: 0;
    background: var(--bg-modal-overlay);
    opacity: 0; pointer-events: none;
    transition: opacity var(--transition-normal);
    z-index: 300;
  }
  .mobile-drawer-backdrop.open { opacity: 1; pointer-events: auto; }

  .mobile-drawer {
    display: flex; flex-direction: column;
    position: fixed; top: 0; left: 0; bottom: 0;
    width: var(--drawer-width); max-width: 85vw;
    background: var(--bg-sidebar);
    transform: translateX(-100%);
    transition: transform var(--transition-normal);
    z-index: 301;
    overflow-y: auto;
  }
  .mobile-drawer.open { transform: translateX(0); }

  .mobile-drawer-header {
    display: flex; align-items: center; justify-content: space-between;
    height: var(--header-height); padding: 0 16px; flex-shrink: 0;
    border-bottom: 1px solid var(--bg-sidebar-hover);
  }
  .mobile-drawer-header .sidebar-brand-name { color: var(--text-sidebar-active); font-weight: 700; }
  .mobile-drawer-close {
    background: none; border: none; color: var(--text-sidebar);
    font-size: 28px; cursor: pointer; width: 44px; height: 44px;
  }
  .mobile-drawer-nav { padding: 8px 0; flex: 1; }
  .mobile-drawer-logout { border-top: 1px solid var(--bg-sidebar-hover); padding: 8px 0; }

  /* Batch 1D — Issue B: during impersonation the banner (z-index: 9999) would
     paint over the open drawer's header and hide the × close button. Raise the
     drawer + backdrop above the banner on phone so the drawer fully covers it
     while open and the close button stays tappable. Phone-only override of the
     300/301 values set above. */
  .mobile-drawer-backdrop { z-index: 10000; }
  .mobile-drawer { z-index: 10001; }
}

/* ── Batch 2A — Dashboard data table → card list on phone width ─────────── */
@media (max-width: 768px) {
  /* Dashboard data table → card list: each row becomes a card, cells stack with labels. */
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table tr {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    margin-bottom: 12px;
    padding: 8px 12px;
  }
  .data-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 6px 0;
    border: none;
    text-align: right;
    max-width: none !important;       /* override desktop ellipsis caps */
    white-space: normal !important;
    overflow: visible !important;
  }
  .data-table td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 11px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: left;
    flex-shrink: 0;
  }
  /* Quick-note cell (empty label): no label, left-aligned, full-width */
  .data-table td[data-label=""]::before { content: none; }
  .data-table td[data-label=""] { justify-content: flex-start; }

  /* Long, wrapping values (address/notes) read better with the label top-aligned
     against the multi-line value rather than vertically centered. */
  .data-table td[data-label="Address"],
  .data-table td[data-label="Notes"] { align-items: flex-start; }

  /* Card mode doesn't need the horizontal-scroll wrapper.
     Uses a stable class hook (not an inline-style substring match). */
  .data-table-wrapper .data-table-scroll { overflow-x: visible !important; }
}

/* ── Farmer grids (search results + dashboard) → richer mobile card ──────────
   Scoped to .farmer-cards so the other .data-table card lists (dealers,
   registrations, action screen) keep the plain stacked layout. Builds a real
   hierarchy: name as the title, rank badge + quick-note pinned top-right,
   status pill, condensed location, phone + next-contact paired, and the
   notes-search snippet as a full-width quote. Reuses the existing value
   classes (.rank-badge/.rank-N, .status-tag, .overdue) for colour.
   Desktop untouched — lives only inside the 768px breakpoint. */
@media (max-width: 768px) {
  .farmer-cards tr {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    column-gap: 8px;
    row-gap: 3px;
    padding: 12px 14px;
  }
  .farmer-cards td { display: block; width: auto; padding: 0; text-align: left; }
  .farmer-cards td::before { display: none; }
  .farmer-cards td:empty { display: none; }

  /* Low-signal fields: still on the action screen, off the card face. */
  .farmer-cards td[data-label="RD"],
  .farmer-cards td[data-label="Address"],
  .farmer-cards td[data-label="County"],
  .farmer-cards td[data-label="ST"],
  .farmer-cards td[data-label="Last Code"] { display: none; }

  /* Name → card title, own line. */
  .farmer-cards td[data-label="Farmer Name"],
  .farmer-cards td.fc-mobile-name {
    display: block;
    order: -1;
    flex: 1 1 100%;
    padding-right: 68px;        /* clear the pinned rank + quick-note badges */
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
  }
  /* Dashboard's configurable name column is replaced by the always-on title above. */
  .farmer-cards td[data-label="Farmer"] { display: none; }

  /* Rank badge → pinned top-right. */
  .farmer-cards td[data-label="Rank"] {
    position: absolute;
    top: 11px;
    right: 12px;
    left: auto;
    width: auto;
  }

  /* Quick-note (+) button (dashboard only) → top-right, left of the rank. */
  .farmer-cards td[data-label=""] {
    position: absolute;
    top: 8px;
    right: 40px;
    left: auto;
    width: auto;
  }

  /* Status pill + dealer share a line. */
  .farmer-cards td[data-label="Status"] { order: 1; flex: 1 1 100%; }
  .farmer-cards td[data-label="Dealer"] {
    order: 2;
    flex: 1 1 100%;
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Location (city) on its own line. */
  .farmer-cards td[data-label="City"] {
    order: 3;
    flex: 1 1 100%;
    font-size: 12px;
    color: var(--text-secondary);
  }

  /* Dashboard notes line (muted). */
  .farmer-cards td[data-label="Notes"] {
    order: 4;
    flex: 1 1 100%;
    font-size: 12px;
    color: var(--text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Phone + next-contact share a line. */
  .farmer-cards td[data-label="Phone"] { order: 5; flex: 0 0 auto; font-size: 13px; }
  .farmer-cards td[data-label="Phone"] a { color: var(--text-link); }
  .farmer-cards td[data-label="Next Contact"] {
    order: 6;
    flex: 1 1 auto;
    text-align: right;
    font-size: 13px;
  }
  .farmer-cards td[data-label="Next Contact"]::before {
    display: inline;
    content: "Next: ";
    text-transform: none;
    letter-spacing: 0;
    font-weight: 400;
    color: var(--text-tertiary);
  }

  /* Notes-search snippet → full-width quote under the name. */
  .farmer-cards .fc-snippet {
    flex: 1 1 100%;
    margin-top: 7px;
    margin-right: -68px;
    padding: 7px 9px;
    background: var(--bg-input);
    border-radius: var(--radius-md);
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}

/* ── Dashboard grid → dedicated mobile card (fixed field set) ────────────────
   The dashboard's desktop columns are user-configurable, but on a phone the card
   must always show the same essentials regardless of role/column picker. So under
   768px we hide every column cell and render the dedicated .fc-mobile-card cell:
   name + rank, status + dealer, county/state + phone, next contact. ~4 lines.
   Desktop stays the normal configurable table (this is media-scoped). */
@media (max-width: 768px) {
  .dash-cards thead { display: none; }
  .dash-cards, .dash-cards tbody, .dash-cards tr { display: block; width: 100%; }
  .dash-cards tbody tr {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    margin-bottom: 10px;
    padding: 0;
    cursor: pointer;
  }
  .dash-cards td[data-label] { display: none; }       /* hide every desktop column + quick-note cell */
  .dash-cards td.fc-mobile-card { display: block; width: auto; padding: 11px 13px; border: none; }

  .fcm-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .fcm-name { font-size: 15px; font-weight: 600; color: var(--text-primary); }
  .fcm-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 5px; }
  .fcm-dealer { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .fcm-loc { font-size: 12px; color: var(--text-secondary); white-space: nowrap; }
  .fcm-phone { font-size: 13px; color: var(--text-link); white-space: nowrap; }
  .fcm-next { font-size: 13px; margin-top: 5px; }
}

/* ── Batch 2B — MudTable → card list on phone width ─────────────────────────
   Mirrors the .data-table card pattern above for MudBlazor <MudTable> pages
   (e.g. /admin/contact-code-search). MudBlazor v7 emits data-label on each
   .mud-table-cell from the <MudTd DataLabel="..."> attribute, so we reuse it
   here. Class names verified against MudBlazor 7.16.0. Desktop untouched. */
@media (max-width: 768px) {
  .mud-table-root .mud-table-head { display: none; }
  .mud-table-root .mud-table-body .mud-table-row {
    display: block;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    margin-bottom: 12px;
    padding: 8px 12px;
  }
  .mud-table-root .mud-table-body .mud-table-cell {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 6px 0;
    border: none;
    text-align: right;
  }
  .mud-table-root .mud-table-body .mud-table-cell::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 11px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: left;
    flex-shrink: 0;
  }
  /* MudTable pager: let it wrap instead of forcing horizontal scroll */
  .mud-table-root .mud-table-pagination { flex-wrap: wrap; }

  /* MudDataGrid fix: the card reflow above also applies to <MudDataGrid> (same
     .mud-table-root / .mud-table-cell classes + data-label), but MudDataGrid wraps
     its table in an extra .mud-drop-container and leaves the <table> sizing to its
     widest content — so on phones the table grew past the viewport (e.g. /admin/users
     hit ~391px in a ~295px column) and you had to scroll sideways to read rows or reach
     the Actions (Impersonate, etc.). Constrain the table + wrapper to the container
     width and let cell content wrap. Reusable across every MudDataGrid page; desktop
     untouched (media-query scoped). */
  .mud-table-container { overflow-x: hidden; }
  .mud-drop-container,
  .mud-table-root { display: block; width: 100%; max-width: 100%; }
  .mud-table-root .mud-table-body { display: block; }
  .mud-table-root .mud-table-body .mud-table-cell { flex-wrap: wrap; overflow-wrap: anywhere; }
}

/* ═══════════════════════════════════════════════
   BATCH 2C — phone touch ergonomics
   ═══════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Comfortable tap targets on phone */
  .filter-chip { min-height: 40px; display: inline-flex; align-items: center; }
  .btn-icon { min-width: 44px !important; min-height: 44px !important; }

  /* Tab strips (.tabs is the real class shared by the Dashboard role tabs
     and the Action Screen tabs; RD dashboard has up to 6 tabs). The base
     .tabs rule already sets overflow-x:auto + touch scrolling + hidden
     scrollbar, so here we only force non-wrap so tabs scroll instead of
     stacking onto a second line on narrow phones.
     A right-edge shadow (classic scrolling-shadow technique) signals "more
     tabs → swipe" and disappears once scrolled to the end: the soft shadow
     is pinned to the right edge (background-attachment: scroll) while a
     page-colored cover moves with the content (local) and hides it at the end. */
  .tabs {
    flex-wrap: nowrap;
    background:
      linear-gradient(to left, var(--bg-primary), transparent 22px) right center / 22px 100% no-repeat local,
      linear-gradient(to left, var(--tab-scroll-shadow), transparent 18px) right center / 18px 100% no-repeat scroll;
  }
}

/* ═══════════════════════════════════════════════
   BATCH 3A — Action screen mobile layout
   Phone-only (≤768px). Desktop is untouched: the collapse
   chevron/toggle and the `.collapsed` hide rule only exist
   inside the media query, so on desktop the details card is
   always fully shown and the header is not a toggle.
   ═══════════════════════════════════════════════ */

/* Chevron + header-actions group are inert on desktop (chevron hidden).
   The actions wrapper keeps the Quick Note button right-aligned exactly as before.
   The chevron is a real <button> for keyboard/AT access on phone; reset its chrome
   here. It's display:none on desktop, so it adds no desktop focus stop. */
.farmer-details-header-actions { display: flex; align-items: center; gap: 8px; }
.farmer-details-chevron {
  display: none;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  cursor: pointer;
}

@media (max-width: 768px) {
  /* The header becomes a tap toggle for the collapsible details body. */
  .farmer-details-header { cursor: pointer; user-select: none; }
  .farmer-details-chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;          /* comfortable keyboard/touch target */
    font-size: 14px;
    color: var(--text-tertiary);
    transition: transform var(--transition-fast);
  }
  .farmer-details-chevron:focus-visible {
    outline: 2px solid var(--accent-green);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
  }
  .farmer-details-chevron.expanded { transform: rotate(180deg); }

  /* Default-collapsed on phone: hide the body+subdata until expanded. */
  .farmer-details-collapsible.collapsed { display: none; }

  /* Let the action header and its action buttons wrap instead of overflowing. */
  .action-header { flex-wrap: wrap; gap: 10px; }
  .action-farmer-meta { flex-wrap: wrap; gap: 8px; }
  .page-actions { flex-wrap: wrap; width: 100%; }
}

/* ═══════════════════════════════════════════════
   BATCH 3B — Full-screen dialogs on phone
   Phone-only (≤768px). Makes every MudDialog (Contact Log, Email
   Composer, sub-data editors, message boxes) AND the custom
   .acre-modal-shell fill the screen so they're usable one-handed,
   with the action bar pinned above the iOS home indicator. This is
   applied uniformly via CSS — no per-call-site DialogOptions changes.
   Desktop is untouched. The !important values are required to beat the
   existing `.mud-dialog { border-radius: … !important }` base rules.
   ═══════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* MudBlazor dialogs → full-bleed sheet (container padding zeroed so the
     dialog reaches all four edges). */
  .mud-dialog-container { padding: 0 !important; }
  .mud-dialog-container .mud-dialog {
    margin: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    display: flex;
    flex-direction: column;
  }
  /* Content scrolls; title + actions stay pinned. */
  .mud-dialog .mud-dialog-content {
    flex: 1 1 auto;
    overflow-y: auto;
    max-height: none !important;
  }
  .mud-dialog-container .mud-dialog-actions {
    position: sticky;
    bottom: 0;
    background: var(--bg-card);
    padding-bottom: calc(env(safe-area-inset-bottom) + 12px) !important;
  }

  /* EXCEPTION: short confirm dialogs (MudMessageBox — e.g. the status-change "Are you
     sure?") stay a centered compact card, not a full-screen sheet. MudBlazor puts the
     `mud-message-box` class on the dialog element itself, so this `#id.class`-level
     selector (specificity 0,3,0) cleanly overrides the full-screen rule above (0,2,0). */
  .mud-dialog-container .mud-dialog.mud-message-box {
    width: auto !important;
    max-width: 92vw !important;
    height: auto !important;
    max-height: 85dvh !important;
    margin: auto !important;
    border-radius: var(--radius-lg) !important;
  }
  .mud-dialog.mud-message-box .mud-dialog-actions {
    position: static !important;
    padding-bottom: 12px !important;
  }

  /* Custom shared modal shell (used where MudDialog @bind-IsVisible was removed
     in the v7 migration). Override the centered transform + size to full-screen
     and disable the rise animation (its keyframe transform would fight the
     full-screen position for ~140ms). */
  .acre-modal-shell {
    top: 0 !important;
    left: 0 !important;
    transform: none !important;
    width: 100vw !important;
    max-width: 100vw !important;
    min-width: 0 !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    animation: none !important;
  }
  .acre-modal-actions {
    padding-bottom: calc(env(safe-area-inset-bottom) + 12px);
  }
}

/* ═══════════════════════════════════════════════
   BATCH 4C — Branded PWA reconnect overlay
   Replaces Blazor Server's default reconnect bar. Blazor toggles the classes
   components-reconnect-{show,hide,failed,rejected} on #components-reconnect-modal.
   Shown for show + failed + rejected so the user is never left on a dead circuit
   with no UI. Applies on all viewports — it's connection-state UI, not layout, so
   the normal (connected) desktop appearance is unchanged.
   ═══════════════════════════════════════════════ */
#components-reconnect-modal { display: none; }

#components-reconnect-modal.components-reconnect-show,
#components-reconnect-modal.components-reconnect-retrying,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected {
  display: flex;
  position: fixed;
  inset: 0;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom);
  /* MudBlazor.min.css sets `#components-reconnect-modal { z-index: 9999 !important;
     background-color: var(--mud-palette-background) !important }`. The z-index would
     sit BELOW the mobile drawer (10001) and the opaque bg would kill the scrim. Our
     selector is more specific, so `!important` on both wins and gives us a real dark
     scrim above all chrome. */
  z-index: 100000 !important;
  background-color: var(--bg-modal-overlay, rgba(0, 0, 0, 0.5)) !important;
}

.acre-reconnect-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 28px 32px;
  max-width: 320px;
  width: 100%;
  text-align: center;
}

.acre-reconnect-spinner {
  width: 36px;
  height: 36px;
  margin: 0 auto 16px;
  border: 3px solid var(--border-light);
  border-top-color: var(--accent-green);
  border-radius: 50%;
  animation: acre-spin 0.8s linear infinite;
}

@keyframes acre-spin { to { transform: rotate(360deg); } }

.acre-reconnect-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.acre-reconnect-text {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.acre-reconnect-reload {
  display: inline-block;
  margin-top: 16px;
  padding: 8px 18px;
  background: var(--accent-green);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
}

/* State-specific title swap + spinner hide.
   Default: show the "Reconnecting…" title, hide the "Connection lost" title. */
.acre-reconnect-title-failed { display: none; }

#components-reconnect-modal.components-reconnect-failed .acre-reconnect-title-show,
#components-reconnect-modal.components-reconnect-rejected .acre-reconnect-title-show { display: none; }

#components-reconnect-modal.components-reconnect-failed .acre-reconnect-title-failed,
#components-reconnect-modal.components-reconnect-rejected .acre-reconnect-title-failed { display: block; }

#components-reconnect-modal.components-reconnect-failed .acre-reconnect-spinner,
#components-reconnect-modal.components-reconnect-rejected .acre-reconnect-spinner { display: none; }

/* ═══════════════════════════════════════════════
   ACCESS DENIED / NOT AUTHORIZED panel
   Branded card shown for the authenticated-but-forbidden case (App.razor inline
   NotAuthorized) and the /access-denied page (HTTP 403 redirect target). Replaces
   a bare unstyled sentence / a 404 dead-end.
   ═══════════════════════════════════════════════ */
.access-denied-panel {
  max-width: 460px;
  margin: 64px auto;
  text-align: center;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 40px 32px;
}
.access-denied-icon { font-size: 40px; line-height: 1; margin-bottom: 12px; }
.access-denied-title {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 8px;
}
.access-denied-text {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0 0 24px;
}

/* ═══════════════════════════════════════════════
   NEARBY FARMERS — ROUTE MODE
   Destination input + header row for the "farmers along my route" feature
   (/maps/nearby). Themed to match MudTextField inputs (--bg-input). The
   page-specific stop-list / suggestion-card styles live in the page's own
   <style> block; only the route header row lives here since it's the input
   chrome shared across the route control row.
   ═══════════════════════════════════════════════ */
.route-header-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
  width: 100%;
}

.route-dest-input {
  flex: 1;
  min-width: 200px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
}
.route-dest-input::placeholder { color: var(--text-tertiary); }
.route-dest-input:focus {
  outline: none;
  border-color: var(--accent-green);
}

/* Mobile: route header row + input go full-width and wrap cleanly so the
   destination box never overflows horizontally on small screens. */
@media (max-width: 768px) {
  .route-header-row {
    gap: 6px;
  }
  .route-dest-input {
    flex: 1 1 100%;
    min-width: 0;
    width: 100%;
  }
}
