/* Theme tokens */
:root {
  --bg: #f4f4f4;
  --surface: #fff;
  --border: #e5e5e5;
  --border-strong: #0f172a;
  --muted: #666;
  --text: #111;
  --shadow-soft: 0 6px 18px rgba(15, 23, 42, 0.2);
  --shadow-strong: 0 10px 24px rgba(15, 23, 42, 0.25);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* Base elements */
body {
  margin: 0;
  padding: 0;
}
h1 {
  margin-bottom: 0.25rem;
  font-size: clamp(2rem, 5vw, 3rem);
}
ul {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
button {
  border: none;
  background: var(--text);
  color: var(--surface);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
}
button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
a {
  color: inherit;
}
:where(.auth-panel, .summary-panel, .summary-card, .tag-filter-bar, .tag-input-wrapper, li) {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

/* Layout helpers */
.row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.pill {
  border-radius: 999px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
}
.muted {
  color: var(--muted);
}
[x-cloak] {
  display: none !important;
}

/* Header / session */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  position: relative;
  z-index: 60;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.header-left h1 {
  margin: 0;
}

/* Hamburger icon (shared between sidebar toggle & mobile header) */
.hamburger-icon {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 22px;
}
.hamburger-icon span {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--text);
  border-radius: 2px;
}

/* Mobile-only hamburger in header — hidden on desktop */
.hamburger-btn.mobile-only {
  background: transparent;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
}

/* Sidebar toggle button (lives inside the sidebar) */
.sidebar-toggle {
  background: transparent;
  border: none;
  padding: 0.65rem 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: flex-start;
  border-radius: var(--radius-sm);
  margin-bottom: 0.25rem;
  flex-shrink: 0;
}
.sidebar-toggle:hover {
  background: #f3f4f6;
}

/* ===========================================
   App Body (sidebar + content flex container)
   =========================================== */
.app-body {
  display: flex;
  align-items: stretch;
  min-height: calc(100vh - 3.75rem);
}

/* ===========================================
   Sidebar Navigation
   =========================================== */
.sidebar {
  width: 48px;
  min-width: 48px;
  overflow: hidden;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.35rem;
  flex-shrink: 0;
  transition: width 0.25s ease, min-width 0.25s ease;
}
.sidebar.open {
  width: 200px;
  min-width: 200px;
}
/* Hide item labels when collapsed, show only toggle */
.sidebar:not(.open) .sidebar-item {
  display: none;
}
.sidebar-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.65rem 1rem;
  font-size: 0.95rem;
  font-weight: 500;
  background: transparent;
  color: var(--text);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s;
  white-space: nowrap;
}
.sidebar-item:hover {
  background: #f3f4f6;
}
.sidebar-item.active {
  background: #2d6a4f;
  color: #fff;
}

/* Main content fills remaining space */
.main-content {
  flex: 1;
  min-width: 0;
  padding: 0 1.5rem 1rem;
}

.machines-page {
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.machines-sidebar-panel,
.machines-detail-panel {
  padding: 1rem;
}

.machines-panel-header,
.machines-detail-header,
.machines-profile-toolbar,
.machine-profile-group-header,
.machine-profile-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.machines-panel-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.machines-panel-copy {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
}

.machines-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
}

.data-management-page {
  align-items: stretch;
}

.data-management-sidebar,
.data-management-detail,
.data-management-detail-shell {
  min-height: 0;
}

.data-management-sidebar,
.data-management-detail,
.data-management-detail-shell {
  display: flex;
  flex-direction: column;
}

.data-management-sidebar-list,
.data-management-detail-body {
  min-height: 0;
}

.data-management-detail-body {
  margin-top: 1rem;
}

.machines-list-item {
  width: 100%;
  text-align: left;
  background: #f8faf8;
  color: var(--text);
  border: 1px solid #d9e6da;
  padding: 0.85rem;
}

.machines-list-item.active {
  background: #2d6a4f;
  border-color: #2d6a4f;
  color: #fff;
}

.machines-list-name {
  display: block;
  font-weight: 700;
}

.machines-list-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.35rem;
  font-size: 0.82rem;
  opacity: 0.85;
}

.machines-title-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.machines-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0 1.25rem;
}

.machines-summary-card,
.machine-profile-group,
.machine-profile-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fbfcfb;
}

.machines-summary-card {
  padding: 0.8rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.machine-profile-groups {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.machine-profile-group {
  padding: 0.9rem;
}

.machine-profile-card {
  padding: 0.85rem;
  margin-top: 0.75rem;
}

.machine-profile-kind {
  display: block;
  color: #5f6b63;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.25rem;
}

.machine-profile-meta-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.6rem;
  margin-top: 0.75rem;
}

.machine-profile-metric {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.machine-profile-empty {
  margin-top: 0.75rem;
  padding: 0.85rem;
  border: 1px dashed #cbd5c0;
  border-radius: var(--radius-sm);
  color: #667162;
  background: #f7faf6;
}

.machine-profile-override-list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  margin-top: 0.85rem;
}

/* Sidebar overlay (hidden on desktop) */
.sidebar-overlay {
  display: none;
}

/* Mobile overrides */
@media (max-width: 768px) {
  /* Show hamburger in header on mobile */
  .hamburger-btn.mobile-only {
    display: flex;
  }
  /* Sidebar fully hidden when collapsed on mobile */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
    width: 240px !important;
    min-width: 240px !important;
    padding: 4.5rem 0.5rem 1rem !important;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
    overflow-y: auto;
  }
  .sidebar .sidebar-toggle {
    display: none;
  }
  .sidebar:not(.open) .sidebar-item {
    display: block;
  }
  .sidebar.open {
    transform: translateX(0);
    width: 240px !important;
    min-width: 240px !important;
  }
  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 40;
  }
  .main-content {
    padding: 0 1rem 1rem;
  }
  .machines-page {
    grid-template-columns: 1fr;
  }

  .data-management-sidebar,
  .data-management-detail {
    max-height: none;
  }

  .data-management-sidebar-list,
  .data-management-detail-body {
    overflow: visible;
    padding-right: 0;
  }
}

@media (min-width: 769px) {
  .data-management-page {
    min-height: calc(100vh - 5.75rem);
    min-height: calc(100dvh - 5.75rem);
  }

  .data-management-sidebar,
  .data-management-detail {
    height: calc(100vh - 5.75rem);
    height: calc(100dvh - 5.75rem);
  }

  .data-management-sidebar-list,
  .data-management-detail-body {
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 0.25rem;
  }
}
.session-controls {
  position: relative;
  min-height: 48px;
  min-width: 48px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding-top: 0.65rem;
}
.avatar-chip {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--text);
  color: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease;
}
.avatar-chip:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-strong);
}

/* Sync status ring indicators */
.avatar-chip.sync-status-synced {
  box-shadow: 0 0 0 3px #22c55e, var(--shadow-soft); /* green */
}
.avatar-chip.sync-status-unsynced {
  box-shadow: 0 0 0 3px #f97316, var(--shadow-soft); /* orange */
}
.avatar-chip.sync-status-syncing {
  box-shadow: 0 0 0 3px #3b82f6, var(--shadow-soft); /* blue */
  animation: sync-pulse 1.5s ease-in-out infinite;
}
@keyframes sync-pulse {
  0%, 100% { box-shadow: 0 0 0 3px #3b82f6, var(--shadow-soft); }
  50% { box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.4), var(--shadow-soft); }
}
.avatar-chip.sync-status-synced:hover,
.avatar-chip.sync-status-unsynced:hover,
.avatar-chip.sync-status-syncing:hover {
  transform: translateY(-1px);
}

.avatar-chip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.avatar-fallback {
  font-weight: 600;
  letter-spacing: 0.02em;
}
.avatar-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.25rem;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.2);
  min-width: 140px;
  z-index: 20;
}
.avatar-menu-header {
  padding: 0.5rem 0.75rem 0.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.25rem;
}
.avatar-menu-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 140px;
}
.avatar-menu button {
  width: 100%;
  background: transparent;
  border: none;
  padding: 0.5rem 0.75rem;
  text-align: left;
  cursor: pointer;
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--text);
}
.avatar-menu button:hover {
  background: #f3f4f6;
}
.avatar-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 0.25rem 0;
}
.subtitle {
  margin-top: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

/* Forms / hero */
.hero-entry {
  width: 100%;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  margin-top: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: none;
}
.todo-form {
  margin: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 820px;
}
.hero-input-wrapper {
  width: 100%;
}
.hero-input {
  display: block;
  padding: 0.85rem 1rem;
  width: 100%;
  font-size: 1rem;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-sizing: border-box;
  line-height: 1.3;
  background: var(--surface);
  box-shadow: none;
}
.hero-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.25);
}
.remaining-summary {
  margin: 0 0 1rem;
  color: #333;
  font-weight: 500;
}
.hero-hint {
  margin: 0.5rem 0 0;
  color: #555;
  font-size: 0.9rem;
}
.hero-input:disabled {
  background: #f5f5f5;
  border-color: #ddd;
  cursor: not-allowed;
}

/* Lists */
li {
  background: var(--surface);
  border-radius: 10px;
  border: 1px solid var(--border);
}
details {
  padding: 0.6rem 0.9rem;
}
details[open] {
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
}
summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  cursor: pointer;
  list-style: none;
}
summary::-webkit-details-marker {
  display: none;
}
.todo-title {
  font-weight: 600;
  flex: 1;
}
.badges {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  font-size: 0.8rem;
}
.badge {
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
  text-transform: capitalize;
  border: 1px solid #ddd;
}
.badge.priority-rock {
  background: #ffe3e3;
  border-color: #f5b5b5;
}
.badge.priority-pebble {
  background: #fff1d6;
  border-color: #f5c97c;
}
.badge.priority-sand {
  background: #e9f4ff;
  border-color: #b5d8ff;
}
.badge.state-done {
  background: #e7f8e9;
  border-color: #b0e2b8;
}
.badge.state-in_progress {
  background: #f0e8ff;
  border-color: #cdbdff;
}
.badge.state-ready {
  background: #fff2f0;
  border-color: #ffcfc3;
}
.badge.state-new {
  background: #f5f5f5;
  border-color: #ddd;
}
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: #f3f0ff;
  border: 1px solid #d4c9ff;
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  font-size: 0.75rem;
  color: #5b4b8a;
}
.tag-chip .remove-tag {
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  opacity: 0.6;
}
.tag-chip .remove-tag:hover {
  opacity: 1;
}
.tags-display {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}
.tag-input-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  padding: 0.4rem;
  min-height: 2.2rem;
  align-items: center;
  cursor: text;
}
.tag-input-wrapper:focus-within {
  border-color: #666;
  outline: none;
}
.tag-input-wrapper input {
  border: none;
  outline: none;
  flex: 1;
  min-width: 60px;
  font-size: 0.9rem;
  padding: 0.2rem;
}
.tag-filter-bar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
}
.tag-filter-bar .label {
  font-size: 0.85rem;
  color: var(--muted);
}
.tag-filter-bar .tag-chip {
  cursor: pointer;
}
.tag-filter-bar .tag-chip.active {
  background: #5b4b8a;
  color: #fff;
  border-color: #5b4b8a;
}
.tag-filter-bar .clear-filters {
  font-size: 0.8rem;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}
.todo-body {
  margin-top: 0.75rem;
  border-top: 1px solid #f0f0f0;
  padding-top: 0.75rem;
  display: grid;
  gap: 0.75rem;
}
.todo-description {
  margin: 0;
  color: #444;
  white-space: pre-wrap;
}
.todo-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.edit-form {
  display: grid;
  gap: 0.5rem;
}
.edit-form label {
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  color: #333;
  gap: 0.25rem;
}
.edit-form input,
.edit-form textarea,
.edit-form select {
  padding: 0.35rem 0.45rem;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid #ccc;
  font-family: inherit;
}
.work-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2rem;
  border-top: 1px solid #ddd;
  padding-top: 1rem;
}
.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.archive-section {
  margin-top: 2rem;
}
.archive-toggle {
  text-decoration: none;
  font-size: 0.9rem;
  color: #111;
  border: 1px solid #ddd;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
}

/* Auth panel */
.auth-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  background: var(--surface);
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.08);
}
.auth-panel h2 {
  margin: 0 0 0.5rem;
  font-size: 1.2rem;
}
.auth-description {
  margin: 0 0 1rem;
  color: #555;
}
.auth-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.auth-option {
  padding: 0.75rem 1rem;
  border: 1px solid var(--text);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}
.auth-option:hover:not(:disabled) {
  background: var(--text);
  color: var(--surface);
}
.auth-option:disabled {
  opacity: 0.6;
  cursor: progress;
}
.auth-extension,
.auth-keyteleport {
  background: #f5f5f5;
  color: #666;
  border-color: #999;
}
.auth-extension:hover:not(:disabled),
.auth-extension:active:not(:disabled),
.auth-keyteleport:hover:not(:disabled),
.auth-keyteleport:active:not(:disabled) {
  background: #8b5cf6;
  border-color: #8b5cf6;
  color: #fff;
}
.auth-advanced {
  margin-top: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px dashed #ddd;
}
.auth-advanced summary {
  cursor: pointer;
  color: #333;
  font-weight: 600;
}
.auth-advanced .auth-form {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.auth-advanced input {
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  border: 1px solid #ccc;
  font-size: 0.95rem;
}
.auth-advanced .auth-option {
  width: 100%;
}
.auth-divider {
  width: 80%;
  border: none;
  border-top: 1px solid #ddd;
  margin: 1rem auto;
}
.bunker-submit {
  align-self: flex-start;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  background: var(--text);
  color: var(--surface);
  border: none;
  cursor: pointer;
}
.auth-error {
  margin-top: 0.75rem;
  color: #b91c1c;
  font-size: 0.9rem;
  padding: 0.5rem;
  background: #fee2e2;
  border-radius: 8px;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}
.modal-overlay-stacked {
  z-index: 130;
}
.modal {
  background: #fff;
  border-radius: 16px;
  padding: 2rem;
  max-width: 60%;
  width: 90%;
  text-align: center;
  position: relative;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  max-height: 90vh;
  overflow-y: auto;
  box-sizing: border-box;
}
@media (max-width: 768px) {
  .modal {
    max-width: 90%;
  }
}
.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #666;
  padding: 0.25rem;
  line-height: 1;
}
.modal-close:hover {
  color: #111;
}
.modal h2 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
}
.modal p {
  margin: 0 0 1.25rem;
  color: #555;
  font-size: 0.9rem;
}
/* New Batch button */
.new-batch-btn {
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  background: #2d6a4f;
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  margin-bottom: 0.75rem;
}
.new-batch-btn:hover { background: #1b4332; }

/* Batch modal */
.batch-modal {
  text-align: left;
}
.batch-modal h2 { text-align: center; }
.plan-item-modal {
  padding-top: 0;
}
.plan-item-modal.is-fullscreen {
  width: 90vw;
  max-width: none;
  height: 90vh;
  max-height: 90vh;
}
.batch-detail-modal.is-fullscreen {
  width: 90vw;
  max-width: none;
  height: 90vh;
  max-height: 90vh;
}
.wo-detail-modal.is-fullscreen {
  width: 90vw;
  max-width: none;
  height: 90vh;
  max-height: 90vh;
}
.modal-sticky-title {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 -2rem 1rem;
  padding: 1rem 2rem;
  background: #fff;
  border-bottom: 1px solid var(--border);
}
.modal-sticky-title h2,
.modal-sticky-title h3 {
  flex: 1;
  min-width: 0;
  margin: 0;
  text-align: left;
}
.modal-title-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}
.modal-icon-btn,
.plan-item-modal .modal-close,
.batch-detail-modal .modal-close,
.wo-detail-modal .modal-close {
  position: static;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #666;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
}
.modal-icon-btn:hover,
.plan-item-modal .modal-close:hover,
.batch-detail-modal .modal-close:hover,
.wo-detail-modal .modal-close:hover {
  border-color: var(--border);
  background: #f8fafc;
  color: #111;
}
.plan-item-modal .modal-close,
.batch-detail-modal .modal-close,
.wo-detail-modal .modal-close {
  font-size: 1.5rem;
}
@media (max-width: 768px) {
  .modal-sticky-title {
    margin: 0 -2rem 1rem;
    padding: 0.9rem 2rem;
  }
}

/* Recent chips */
.recent-batches { margin-bottom: 1rem; }
.recent-label {
  font-size: 0.75rem;
  color: #888;
  margin: 0 0 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.recent-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.recent-chip {
  display: flex;
  gap: 0.3rem;
  align-items: center;
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  border: 1px solid #ccc;
  border-radius: 20px;
  background: #f5f5f5;
  cursor: pointer;
  transition: background 0.15s;
}
.recent-chip:hover { background: #e0e0e0; }
.chip-species { font-weight: 600; }
.chip-type { color: #666; font-size: 0.7rem; }

/* Modal form fields */
.modal-field {
  display: flex;
  flex-direction: column;
  margin-bottom: 0.75rem;
}
.field-label-with-help {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.field-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1px solid #9ca3af;
  color: #4b5563;
  font-size: 0.68rem;
  font-style: normal;
  cursor: help;
  font-weight: 700;
  user-select: none;
  background: #fff;
}
.modal-field span {
  font-size: 0.75rem;
  font-weight: 600;
  color: #555;
  margin-bottom: 0.2rem;
}
.advanced-section {
  margin: 0.75rem 0;
}
.stage-actions-menu {
  position: relative;
}
.stage-actions-menu summary {
  list-style: none;
  cursor: pointer;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  color: #333;
  font-size: 1rem;
  line-height: 1;
  padding: 0.2rem 0.45rem;
}
.stage-actions-menu summary::-webkit-details-marker {
  display: none;
}
.stage-actions-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 0.25rem);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 10rem;
  padding: 0.35rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
  z-index: 20;
}
.stage-actions-popover button {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
}
.stage-actions-popover button:hover {
  background: #f3f4f6;
}
.stage-actions-popover button:disabled {
  background: #f3f4f6;
  color: #6b7280;
}
.template-picker-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.template-picker-card {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fafafa;
}
.modal-field select,
.modal-field input,
.modal-field textarea {
  padding: 0.5rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 0.95rem;
  background: #fff;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
}
.modal-field textarea {
  resize: vertical;
}
.modal-field.checkbox-field {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}
.modal-field.checkbox-field input {
  width: auto;
}
.modal-field-row {
  display: flex;
  gap: 0.75rem;
}
.modal-field-row .modal-field { flex: 1; min-width: 0; }
.plant-method-summary {
  font-size: 0.8rem;
}
.plant-method-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}
.plant-method-option {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
}
.plant-method-option input {
  width: auto;
  min-width: 18px;
}
.plant-method-option span {
  margin: 0;
  color: #374151;
}
.plant-seed-facts {
  padding: 0.7rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  margin-bottom: 0.75rem;
}
.modal-submit {
  width: 100%;
  padding: 0.7rem;
  font-size: 1rem;
  font-weight: 600;
  background: #2d6a4f;
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  margin-top: 0.25rem;
}
.modal-submit:hover { background: #1b4332; }

.qr-canvas-container {
  display: flex;
  justify-content: center;
}
.qr-canvas-container canvas {
  border-radius: 8px;
}

/* Utilities */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--muted);
}

/* Key Teleport */
.teleport-modal {
  text-align: left;
}
.teleport-modal h2 {
  text-align: center;
}
.teleport-modal p {
  text-align: center;
}
.teleport-modal .hint {
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 1rem;
}
.teleport-npub {
  background: #f5f5f5;
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 1rem;
}
.teleport-npub label {
  display: block;
  font-size: 0.8rem;
  color: #666;
  margin-bottom: 0.25rem;
}
.teleport-npub code {
  font-size: 0.75rem;
  word-break: break-all;
  display: block;
}
.teleport-identity {
  display: block;
  background: #f5f5f5;
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.8rem;
  word-break: break-all;
  text-align: center;
}
.teleport-modal .auth-form {
  margin-top: 0;
}
.teleport-modal .auth-form label {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: #333;
}
.teleport-modal .auth-form input {
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  border: 1px solid #ccc;
  font-size: 0.95rem;
}
.teleport-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}
.teleport-actions .auth-option {
  flex: 1;
}
.teleport-actions .auth-option.secondary {
  background: transparent;
  border: 1px solid #ccc;
  color: #666;
}
.teleport-actions .auth-option.secondary:hover {
  background: #f5f5f5;
  color: #333;
}

/* SuperBased Modal */
.superbased-modal {
  text-align: left;
}
.superbased-modal h2 {
  text-align: center;
}
.superbased-modal > p {
  text-align: center;
}
.superbased-modal .auth-form {
  margin-top: 1rem;
}
.superbased-modal .auth-form label {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: #333;
}
.token-input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  border: 1px solid #ccc;
  font-size: 0.85rem;
  font-family: monospace;
  resize: vertical;
  box-sizing: border-box;
}
.superbased-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}
.superbased-status.connected {
  background: #e7f8e9;
  color: #166534;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
}
.superbased-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}
.superbased-actions .auth-option {
  flex: 1;
}
.superbased-actions .auth-option.secondary {
  background: transparent;
  border: 1px solid #ccc;
  color: #666;
}
.superbased-actions .auth-option.secondary:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #b91c1c;
}
/* Connection Details */
.superbased-connection-details {
  background: #f8fffe;
  border: 1px solid #d1fae5;
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
}
.connection-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}
.connection-status.connected {
  color: #166534;
}
.connection-info {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}
.info-row {
  display: flex;
  gap: 0.5rem;
}
.info-label {
  color: #666;
  min-width: 70px;
}
.info-value {
  color: #333;
  word-break: break-all;
}
.info-npub {
  font-family: monospace;
  font-size: 0.8rem;
}
.connection-actions {
  display: flex;
  gap: 0.5rem;
}
.connection-actions .auth-option {
  flex: 1;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
}
.auth-option.danger {
  background: transparent;
  border: 1px solid #fca5a5;
  color: #b91c1c;
}
.auth-option.danger:hover {
  background: #fee2e2;
}

/* Quick Connect */
.superbased-quick-connect {
  margin-bottom: 1rem;
}
.otherstuff-connect {
  width: 100%;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: white;
  font-weight: 600;
  padding: 0.85rem 1rem;
  border: none;
}
.otherstuff-connect:hover {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
}
.quick-connect-divider {
  text-align: center;
  color: #999;
  font-size: 0.8rem;
  margin: 1rem 0 0.5rem;
  position: relative;
}
.quick-connect-divider::before,
.quick-connect-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 30%;
  height: 1px;
  background: #ddd;
}
.quick-connect-divider::before {
  left: 0;
}
.quick-connect-divider::after {
  right: 0;
}

.superbased-sync-status {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px dashed #ddd;
  text-align: center;
}
.superbased-sync-status p {
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 0.75rem;
}

/* ===========================================
   Agent Connect Modal
   =========================================== */

.agent-connect-modal {
  text-align: left;
}
.agent-connect-modal h2 {
  text-align: center;
}
.agent-connect-modal > p {
  text-align: center;
  margin-bottom: 1rem;
}
.agent-connect-content {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 12px;
  padding: 1rem;
}
.agent-config-json {
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  overflow-x: auto;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
}
.agent-config-json code {
  font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
}
.copy-button {
  display: block;
  width: 100%;
  padding: 0.6rem 1rem;
  margin-bottom: 0.75rem;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.copy-button:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
}
.copy-button.copied {
  background: #22c55e;
}

/* ===========================================
   Delegation UI Styles
   =========================================== */

.delegations-modal {
  text-align: left;
}
.delegations-modal h2 {
  text-align: center;
}
.delegations-modal > p {
  text-align: center;
}

.delegation-section {
  margin-bottom: 1.5rem;
}

.delegation-section h3 {
  font-size: 0.85rem;
  color: #666;
  margin: 0 0 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.delegation-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.delegation-form input[type="text"] {
  padding: 0.6rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-family: monospace;
  font-size: 0.85rem;
}

.permission-checkboxes {
  display: flex;
  gap: 1rem;
}

.permission-checkboxes label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: #444;
}

.permission-checkboxes input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
}

.delegation-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.delegation-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background: #f9f9f9;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
}

.delegation-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.delegation-npub {
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--text);
}

.delegation-perms {
  display: flex;
  gap: 0.25rem;
}

.perm-badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  background: #8b5cf6;
  color: white;
  border-radius: 999px;
  font-size: 0.7rem;
  text-transform: uppercase;
  font-weight: 500;
}

.perm-badge.read {
  background: #3b82f6;
}

.perm-badge.write {
  background: #22c55e;
}

.revoke-btn {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  background: #fff;
  color: #dc2626;
  border: 1px solid #fca5a5;
  border-radius: 6px;
  cursor: pointer;
}

.revoke-btn:hover {
  background: #fee2e2;
  border-color: #dc2626;
}

.empty-delegations {
  color: #666;
  font-style: italic;
  text-align: center;
  padding: 1rem;
  background: transparent;
  border: none;
}

/* Assigned-to field in todo edit form */
.assigned-to-field input {
  font-family: monospace;
  font-size: 0.85rem;
}

.assigned-to-hint {
  font-size: 0.75rem;
  color: #666;
  margin-top: 0.25rem;
}

/* Delegated todos indicator */
.delegated-badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  background: #0ea5e9;
  color: white;
  border-radius: 999px;
  font-size: 0.7rem;
  text-transform: uppercase;
  font-weight: 500;
}

.loading {
  text-align: center;
  color: #666;
  padding: 1rem;
}

/* Tab Navigation */
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-top: 1.5rem;
  margin-bottom: 1rem;
}
.tab-bar button {
  flex: 1;
  background: transparent;
  color: var(--muted);
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.6rem 0.25rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: -2px;
  transition: color 150ms, border-color 150ms;
}
.tab-bar button.active {
  color: var(--text);
  border-bottom-color: var(--text);
}
.tab-bar button:hover:not(.active) {
  color: #333;
}

/* Create forms */
.create-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}
.form-row {
  display: flex;
  gap: 0.5rem;
}
.form-row > * {
  flex: 1;
  min-width: 0;
}
.create-form input,
.create-form select {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
}
.create-form button[type="submit"] {
  align-self: flex-start;
}

/* Batch status badges */
.badge.status-active { background: #dbeafe; border-color: #93c5fd; color: #1e40af; }
.badge.status-ready { background: #dcfce7; border-color: #86efac; color: #166534; }
.badge.status-held { background: #fef3c7; border-color: #fcd34d; color: #92400e; }
.badge.status-delivered { background: #ccfbf1; border-color: #5eead4; color: #115e59; }
.badge.status-ended { background: #f3f4f6; border-color: #d1d5db; color: #6b7280; }

/* Batch type badges */
.badge.type-seed { background: #fef9c3; border-color: #fde047; color: #854d0e; }
.badge.type-cutting { background: #e0f2fe; border-color: #7dd3fc; color: #075985; }
.badge.type-tissue_culture { background: #f3e8ff; border-color: #d8b4fe; color: #6b21a8; }
.badge.type-buy_in { background: #ffe4e6; border-color: #fda4af; color: #9f1239; }
.badge.type-division { background: #d1fae5; border-color: #6ee7b7; color: #065f46; }
.badge.type-pot_up { background: #fce7f3; border-color: #f9a8d4; color: #9d174d; }
.badge.type-split { background: #e0e7ff; border-color: #a5b4fc; color: #3730a3; }

/* Quantity badge */
.badge.qty-badge {
  background: #f8fafc;
  border-color: #cbd5e1;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Status filter chips */
.status-chips {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}
.status-chip {
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
  background: #f5f5f5;
  color: #666;
  border: 1px solid #ddd;
  cursor: pointer;
  transition: all 0.15s;
}
.status-chip.active {
  background: var(--text);
  color: var(--surface);
  border-color: var(--text);
}
.status-chip.status-active.active { background: #1e40af; border-color: #1e40af; }
.status-chip.status-ready.active { background: #166534; border-color: #166534; }
.status-chip.status-held.active { background: #92400e; border-color: #92400e; }
.status-chip.status-delivered.active { background: #115e59; border-color: #115e59; }
.chip-count {
  font-size: 0.7rem;
  opacity: 0.7;
  margin-left: 0.15rem;
}

/* Search bar */
.batch-search {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
  box-sizing: border-box;
  background: var(--surface);
}
.batch-search:focus {
  outline: none;
  border-color: #888;
}
.split-parent-search-result {
  margin: -0.25rem 0 0.75rem;
  padding: 0.65rem;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
}
.split-parent-search-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: #475569;
  margin-bottom: 0.5rem;
}

/* Batch card layout */
.batch-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.batch-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.7rem 0.9rem;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.batch-card:hover {
  border-color: #bbb;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.batch-card.ended {
  opacity: 0.65;
  cursor: default;
}
.batch-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}
.batch-card-left {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  min-width: 0;
}
.batch-card-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}
.batch-qty {
  font-weight: 700;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}
.batch-age {
  font-size: 0.75rem;
  color: #999;
  background: #f5f5f5;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
}
.batch-number {
  font-weight: 600;
  font-size: 0.9rem;
}
.batch-species {
  font-size: 0.8rem;
  color: var(--muted);
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.batch-card-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.4rem;
  gap: 0.5rem;
}
.batch-meta {
  font-size: 0.75rem;
  color: #888;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.batch-card-actions {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.55rem;
  justify-content: flex-end;
}

/* Action modal */
.action-subtitle {
  font-size: 0.85rem;
  color: #666;
  text-align: center;
  margin: 0 0 1rem;
}
.action-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1rem;
}
.action-tabs button {
  flex: 1;
  background: transparent;
  color: var(--muted);
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.5rem 0.25rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: -2px;
}
.action-tabs button.active {
  color: var(--text);
  border-bottom-color: var(--text);
}
.action-error {
  color: #b91c1c;
  font-size: 0.85rem;
  margin: 0.5rem 0;
  padding: 0.4rem 0.6rem;
  background: #fee2e2;
  border-radius: 6px;
}
.action-transitions {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid #eee;
}
.action-transition-row {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.transition-btn {
  font-size: 0.8rem;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
}
.action-danger-row {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid #eee;
  display: flex;
  justify-content: flex-end;
}

/* Simple item (species/containers/locations list) */
.simple-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.9rem;
}
.simple-item em {
  font-style: italic;
}

/* Danger button */
.danger-btn {
  background: #fff;
  color: #dc2626;
  border: 1px solid #fca5a5;
}
.danger-btn:hover {
  background: #fee2e2;
  border-color: #dc2626;
}
.danger-btn.small {
  padding: 0.2rem 0.5rem;
  font-size: 0.8rem;
}

/* Archive toggle row */
.archive-toggle-row {
  display: flex;
  justify-content: center;
  margin: 1rem 0;
}

/* Sample data prompt */
.sample-data-prompt {
  text-align: center;
  padding: 2rem 1rem;
  background: #f8faf5;
  border: 1px dashed #a3c585;
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
}
.sample-data-prompt p {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

/* Hint text */
.create-hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

/* Batch detail modal */
.batch-detail-modal {
  text-align: left;
  max-width: 780px;
}
.batch-detail-titlebar {
  align-items: flex-start;
}
.batch-detail-titlebar > div:first-child {
  flex: 1;
  min-width: 0;
}
.batch-detail-titlebar .action-subtitle {
  margin-bottom: 0;
  overflow-wrap: anywhere;
}
.batch-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.batch-detail-update-btn {
  margin: 0;
  width: auto;
  min-width: 140px;
}
.batch-detail-action-row {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  align-items: center;
  margin: 0.6rem 0 0.9rem;
  flex-wrap: wrap;
}
.batch-detail-action-btn {
  flex: 1 1 160px;
  max-width: 260px;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #0f172a;
  border-radius: 999px;
  padding: 0.55rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}
.batch-detail-action-btn:hover {
  background: #f8fafc;
}
.batch-detail-action-btn-active {
  background: #16a34a;
  border-color: #16a34a;
  color: #fff;
}
.batch-detail-action-btn-active:hover {
  background: #15803d;
}
.batch-detail-footer-link {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}
.batch-detail-text-link {
  border: none;
  background: transparent;
  color: #475569;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
}
.batch-detail-text-link:hover {
  color: #0f172a;
  text-decoration: underline;
}
.batch-detail-grid-link {
  justify-self: start;
  text-align: left;
  padding: 0;
}
.batch-work-order-history-link {
  padding: 0;
  text-align: left;
}
.observation-history-modal {
  max-width: 1120px;
  text-align: left;
}
.observation-history-table-wrap {
  overflow-x: auto;
}
.observation-history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.observation-history-table th,
.observation-history-table td {
  padding: 0.6rem 0.7rem;
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
  vertical-align: top;
}
.observation-history-table th {
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #64748b;
}
.observation-history-table td {
  color: #0f172a;
}
.seed-inventory-page {
  padding: 1rem;
}
.seed-inventory-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.seed-inventory-header h2 {
  margin: 0 0 0.25rem;
}
.seed-inventory-header input {
  min-width: 260px;
  max-width: 420px;
  width: 35%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.seed-inventory-form {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.9rem;
  margin-bottom: 1rem;
  background: var(--surface);
}
.seed-inventory-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.6rem;
}
.seed-inventory-form-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.seed-inventory-form-grid input,
.seed-inventory-form-grid select {
  padding: 0.55rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.seed-inventory-wide {
  grid-column: 1 / -1;
}
.seed-inventory-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.8rem;
  align-items: center;
}
.seed-inventory-actions .new-batch-btn {
  width: auto;
  min-width: 160px;
}
.seed-inventory-table-wrap {
  overflow-x: auto;
}
.seed-inventory-table tr:hover {
  background: #f8fafc;
}
.seed-lot-detail-modal {
  background: #fff;
  border-radius: 16px;
  padding: 2rem;
  max-width: 1040px;
  width: 95%;
  text-align: left;
  position: relative;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  max-height: 90vh;
  overflow-y: auto;
  box-sizing: border-box;
}
.seed-lot-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem 1rem;
  margin: 1rem 0;
  font-size: 0.9rem;
}
.seed-lot-detail-wide {
  grid-column: 1 / -1;
}
.seed-lot-activity-section {
  margin-top: 1.2rem;
}
.seed-lot-activity-section h3,
.batch-lineage h3 {
  margin: 0 0 0.6rem;
  font-size: 1rem;
}
.seed-lot-batch-list,
.batch-lineage-list {
  display: grid;
  gap: 0.5rem;
}
.batch-lineage {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.8rem;
  margin: 0.8rem 0;
  background: #f8fafc;
}
.batch-lineage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.8rem;
}
.batch-lineage-grid > div {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.batch-lineage-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.batch-lineage-link:hover {
  border-color: #94a3b8;
}
.batch-lineage-source-history {
  display: grid;
  gap: 0.4rem;
  margin-top: 0.45rem;
}
.batch-lineage-history-link {
  display: grid;
  gap: 0.15rem;
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.batch-lineage-history-link:hover {
  border-color: #94a3b8;
}
.batch-stage-terminal-note {
  display: grid;
  gap: 0.2rem;
  margin-top: 0.75rem;
  padding: 0.75rem 0.85rem;
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius-sm);
  background: #f8fafc;
  color: #475569;
  font-size: 0.9rem;
}
@media (max-width: 768px) {
  .seed-inventory-header {
    flex-direction: column;
  }
  .seed-inventory-header input {
    max-width: none;
    width: 100%;
    min-width: 0;
  }
  .seed-lot-detail-grid {
    grid-template-columns: 1fr;
  }
}
.observation-delta-positive {
  color: #15803d !important;
  font-weight: 700;
}
.observation-delta-negative {
  color: #dc2626 !important;
  font-weight: 700;
}
.observation-delta-neutral {
  color: #475569 !important;
  font-weight: 700;
}
.observation-delta-muted {
  color: #94a3b8 !important;
}
.batch-detail-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.batch-detail-stat {
  background: #f8fafc;
  border: 1px solid #dbe5ef;
  border-radius: 8px;
  padding: 10px 12px;
}
.batch-detail-stat-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  margin-bottom: 4px;
}
.batch-action-current-row {
  margin: 0 0 0.75rem;
  padding: 0.75rem 0.9rem;
  background: #f8fafc;
  border: 1px solid #dbe5ef;
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
}
.batch-future-stages {
  margin-top: 14px;
}
.batch-future-stage-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.batch-future-stage-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
}
@media (max-width: 768px) {
  .batch-detail-header {
    flex-direction: column;
    align-items: stretch;
  }
  .batch-detail-action-row {
    justify-content: flex-start;
  }
  .batch-detail-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .batch-future-stage-row {
    flex-direction: column;
    align-items: flex-start;
  }
  .batch-action-current-row {
    flex-direction: column;
    align-items: flex-start;
  }
}
.batch-plan-board {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}
.batch-stage-section {
  border: 1px solid #dbe5ef;
  border-radius: 10px;
  background: #fff;
  padding: 12px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}
.batch-stage-current {
  border-color: #93c5fd;
  background: #f8fbff;
}
.batch-stage-completed {
  border-color: #bbf7d0;
  background: #f7fff8;
}
.batch-stage-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.batch-stage-title {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.batch-stage-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
  text-align: right;
  font-size: 0.8rem;
}
.batch-stage-current-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  padding: 8px 12px;
  background: #f0f9ff;
  border-radius: 6px;
  border: 1px solid #bae6fd;
}
.stage-advance-date {
  font-size: 0.85rem;
  color: #334155;
}
.stage-advance-date-label {
  color: #64748b;
  margin-right: 4px;
}
.stage-ready-toggle {
  padding: 5px 12px;
  border-radius: 6px;
  border: 1.5px solid #94a3b8;
  background: #fff;
  color: #475569;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  min-width: 94px;
}
.stage-ready-toggle:hover {
  border-color: #d97706;
  color: #92400e;
}
.stage-ready-toggle.stage-ready-active {
  background: #f59e0b;
  border-color: #d97706;
  color: #111827;
}
.stage-ready-toggle.stage-ready-active:hover {
  background: #d97706;
  border-color: #b45309;
  color: #fff;
}
.batch-stage-actions-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed #cbd5e1;
}
.batch-stage-actions-footer .batch-stage-task-btn-muted {
  opacity: 0.82;
}
.batch-stage-subsection {
  margin-top: 12px;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}
.batch-stage-subtitle {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  margin-bottom: 6px;
}
.batch-stage-history {
  border-top: 1px solid #e2e8f0;
  padding-top: 10px;
}
.batch-stage-history-summary {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  list-style-position: inside;
}
.batch-stage-history-list {
  margin-top: 6px;
}
.batch-stage-history-row {
  background: #f8fafc;
  border-color: #dbe5ef;
}
.batch-stage-history-row .batch-stage-task-status {
  margin-left: auto;
  align-items: flex-end;
  text-align: right;
}
.batch-stage-task-list,
.batch-stage-workorder-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}
.batch-stage-task-row,
.batch-stage-workorder-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 9px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  text-align: left;
  overflow: hidden;
}
.batch-stage-workorder-row {
  cursor: pointer;
  color: #0f172a;
}
.batch-stage-planned-task-row {
  background: #fff;
  border-color: #dbe5ef;
  padding: 8px 10px;
}
.batch-stage-planned-task-row .batch-stage-task-main strong,
.batch-stage-workorder-row .batch-stage-task-main strong {
  font-size: 0.9rem;
  line-height: 1.2;
}
.batch-stage-task-main {
  flex: 1 1 260px;
  min-width: 0;
  overflow-wrap: anywhere;
}
.batch-stage-task-status {
  flex: 0 1 140px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.batch-stage-planned-task-row .batch-stage-task-status {
  margin-left: auto;
  align-items: flex-end;
  text-align: right;
}
.batch-stage-task-status .badge {
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}
.batch-stage-plan-badge {
  background: #eef2f7;
  color: #475569;
  border: 1px solid #d6dee8;
}
.batch-stage-task-btn {
  flex: 0 1 190px;
  max-width: 100%;
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}
.batch-stage-task-btn-outline {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #0f172a;
}
.batch-stage-task-btn-outline:hover {
  background: #f8fafc;
}
.batch-stage-planned-task-row .batch-stage-task-btn {
  flex: 0 0 auto;
  min-width: 150px;
  padding: 0.32rem 0.7rem;
}
.batch-stage-planned-task-row .batch-stage-task-btn:not(.batch-stage-task-btn-outline) {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #0f172a;
  font-weight: 600;
}
.batch-stage-planned-task-row .batch-stage-task-btn:not(.batch-stage-task-btn-outline):hover {
  background: #f8fafc;
}
.batch-stage-add-work-order-row {
  justify-content: center;
  margin-top: 12px;
  border-style: dotted;
  border-color: #cbd5e1;
  background: rgba(248, 250, 252, 0.72);
}
.batch-stage-add-work-order-row .batch-stage-task-btn {
  flex: 0 0 190px;
}
.batch-stage-task-btn-muted {
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #475569;
  font-weight: 600;
}
.batch-stage-task-btn-muted:hover {
  background: #eef2f7;
  color: #334155;
}
.batch-stage-workorder-row:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}
.batch-stage-workorder-action,
.batch-stage-workorder-qty {
  font-size: 0.85rem;
}
.batch-stage-advance-row {
  border-style: dashed;
}
@media (max-width: 768px) {
  .batch-stage-header {
    flex-direction: column;
  }
  .batch-stage-meta {
    align-items: flex-start;
    text-align: left;
  }
  .batch-stage-task-row,
  .batch-stage-workorder-row {
    flex-direction: column;
    align-items: stretch;
  }
  .batch-stage-task-main,
  .batch-stage-task-status,
  .batch-stage-task-btn {
    flex-basis: auto;
    width: 100%;
  }
  .batch-stage-history-row .batch-stage-task-status,
  .batch-stage-planned-task-row .batch-stage-task-status {
    margin-left: 0;
    align-items: flex-start;
    text-align: left;
  }
  .batch-stage-task-btn {
    justify-content: center;
  }
  .batch-stage-add-work-order-row .batch-stage-task-btn {
    flex-basis: 190px;
    width: 190px;
  }
}

/* ===========================================
   Batch Plan Progress Bar (on batch cards)
   =========================================== */
.batch-plan-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.35rem;
}
.plan-track {
  flex: 1;
  height: 4px;
  background: #e5e7eb;
  border-radius: 2px;
  overflow: hidden;
}
.plan-fill {
  height: 100%;
  background: #2d6a4f;
  border-radius: 2px;
  transition: width 0.3s;
  min-width: 2px;
}
.plan-label {
  font-size: 0.7rem;
  color: #666;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ===========================================
   Plans Tab
   =========================================== */
.plans-header {
  margin-bottom: 0.75rem;
}
.plans-filter-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.plans-species-filter {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  background: var(--surface);
}
.plans-count {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}
.plans-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.plan-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.8rem;
}
.plan-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}
.plan-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.plan-weeks-badge {
  font-size: 0.7rem;
  color: var(--muted);
  background: #f5f5f5;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}
.plan-stages-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.15rem;
  margin-top: 0.3rem;
}
.plan-stage-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.7rem;
}
.plan-stage-type {
  font-weight: 600;
  color: #444;
}
.plan-stage-duration {
  color: var(--muted);
}
.plan-stage-loss {
  color: #b91c1c;
  font-size: 0.65rem;
}
.plan-stage-arrow {
  color: #ccc;
  margin: 0 0.1rem;
}
.plans-truncated {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 0.5rem;
}

/* ===========================================
   Plan Preview (New Batch Modal)
   =========================================== */
.plan-preview {
  background: #f8faf5;
  border: 1px solid #d4e5c7;
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  margin-top: 0.3rem;
}
.plan-preview-text {
  font-size: 0.75rem;
  color: #555;
  line-height: 1.4;
}

/* ===========================================
   Plan Detail (Action Modal)
   =========================================== */
.plan-detail {
  margin-bottom: 0.5rem;
}
.plan-template-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  margin: 0 0 0.75rem;
}
.plan-stage-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.plan-stage-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  background: #f9fafb;
  border: 1px solid #f0f0f0;
}
.plan-stage-row.current {
  background: #eff6ff;
  border-color: #bfdbfe;
}
.plan-stage-row.completed {
  background: #f0fdf4;
  border-color: #bbf7d0;
}
.plan-stage-row.pending {
  opacity: 0.6;
}
.stage-indicator {
  width: 1.2rem;
  text-align: center;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.plan-stage-row.completed .stage-indicator { color: #22c55e; }
.plan-stage-row.current .stage-indicator { color: #3b82f6; }
.stage-info {
  flex: 1;
  display: flex;
  gap: 0.35rem;
  align-items: baseline;
  min-width: 0;
}
.stage-type-label {
  font-weight: 600;
  font-size: 0.8rem;
}
.stage-container-name {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stage-meta-info {
  display: flex;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--muted);
  flex-shrink: 0;
}
.stage-loss {
  color: #b91c1c;
}
.plan-total-weeks {
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0.5rem 0 0;
}
.plan-empty-state {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 1rem 0;
}

/* ===========================================
   Orders Tab
   =========================================== */
.order-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.order-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.7rem 0.9rem;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.order-card:hover {
  border-color: #bbb;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.order-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}
.order-card-left {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  min-width: 0;
}
.order-card-right {
  flex-shrink: 0;
}
.order-number {
  font-weight: 600;
  font-size: 0.9rem;
}
.order-customer {
  font-size: 0.8rem;
  color: var(--muted);
}
.order-card-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.4rem;
  gap: 0.5rem;
}
.order-meta {
  font-size: 0.75rem;
  color: #888;
  display: flex;
  gap: 0.5rem;
}
.order-item-count {
  font-size: 0.75rem;
  color: var(--muted);
  background: #f5f5f5;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
}

/* Order status badges */
.badge.order-status-draft { background: #f3f4f6; border-color: #d1d5db; color: #6b7280; }
.badge.order-status-confirmed { background: #dbeafe; border-color: #93c5fd; color: #1e40af; }
.badge.order-status-on_hold { background: #fef3c7; border-color: #f59e0b; color: #92400e; }
.badge.order-status-in_progress { background: #fef3c7; border-color: #fcd34d; color: #92400e; }
.badge.order-status-ready { background: #dcfce7; border-color: #86efac; color: #166534; }
.badge.order-status-dispatched { background: #e0f2fe; border-color: #7dd3fc; color: #075985; }
.badge.order-status-delivered { background: #ccfbf1; border-color: #5eead4; color: #115e59; }
.badge.order-status-cancelled { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }

/* Order detail modal */
.order-detail-modal {
  text-align: left;
}
.order-detail-modal h2 { text-align: center; }
.order-detail-header {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.order-status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 1rem;
  justify-content: center;
}
.order-status-row .status-chip {
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
}
.order-items-section {
  margin-top: 0.5rem;
}
.order-items-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}
.order-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.6rem;
  background: #f9fafb;
  border: 1px solid #f0f0f0;
  border-radius: 6px;
}
.order-item-info {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}
.order-item-species {
  font-weight: 600;
  font-size: 0.8rem;
  font-style: italic;
}
.order-item-meta {
  font-size: 0.75rem;
  color: var(--muted);
}
.order-add-item {
  border-top: 1px solid #eee;
  padding-top: 0.75rem;
}

/* Order item actions row */
.order-item-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

/* Linked batch badge on order item */
.order-item-batch-link {
  font-size: 0.7rem;
  font-weight: 600;
  background: #dcfce7;
  color: #166534;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid #86efac;
}

/* Plan / Generate button */
.generate-btn {
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #93c5fd;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
}
.generate-btn:hover {
  background: #dbeafe;
  border-color: #60a5fa;
}

/* Generate preview (in Plan Batch modal) */
.generate-preview {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  margin: 0.75rem 0;
}
.generate-preview-text {
  font-size: 0.85rem;
  color: #333;
  line-height: 1.5;
  margin: 0 0 0.5rem;
}
.generate-preview-error {
  font-size: 0.85rem;
  color: #b91c1c;
  margin: 0.5rem 0;
}

/* Per-stage timeline in generate preview */
.generate-timeline {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.generate-timeline-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.5rem;
  background: rgba(255,255,255,0.7);
  border-radius: 4px;
  font-size: 0.75rem;
}
.generate-timeline-type {
  font-weight: 600;
  min-width: 3.5rem;
}
.generate-timeline-qty {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 3rem;
}
.generate-timeline-dates {
  color: #555;
  flex: 1;
  white-space: nowrap;
}
.generate-timeline-meta {
  display: flex;
  gap: 0.3rem;
  color: var(--muted);
  flex-shrink: 0;
}

/* Generate actions */
.generate-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

/* ===========================================
   Home Page
   =========================================== */
.home-hero-image {
  margin: 1.25rem auto 0.75rem;
  width: min(980px, calc(100% - 1.5rem));
  height: clamp(180px, 30vw, 300px);
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.18);
}
.home-hero-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}
.home-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 2rem 1rem 0.5rem;
  max-width: 400px;
  margin: 0 auto;
}
.home-welcome-logo {
  height: 40px;
  margin-bottom: 0.75rem;
}
.home-welcome-text {
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
}

.home-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 320px;
  margin: 1.5rem auto 1.5rem;
}
.home-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 1.25rem 1rem;
  font-size: 1.1rem;
  font-weight: 600;
  background: #2d6a4f;
  color: #fff;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.home-action-btn:hover { background: #1b4332; transform: translateY(-1px); }
.home-action-btn:active { transform: translateY(0); }
.home-action-planning { background: #2d6a4f; }
.home-action-planning:hover { background: #1b4332; }
.home-action-walk { background: #1e40af; }
.home-action-walk:hover { background: #1e3a8a; }
.home-action-icon { font-size: 1.3rem; }

.home-stats {
  display: flex;
  gap: 0.75rem;
  max-width: 320px;
  margin: 0 auto 1.5rem;
}
.home-stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color 0.15s;
}
.home-stat:hover { border-color: #bbb; }
.home-stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.home-stat-label {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.home-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  max-width: 320px;
  margin: 0 auto;
  justify-content: center;
}
.home-nav-btn {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  background: #f5f5f5;
  color: #444;
  border: 1px solid #ddd;
  border-radius: 999px;
  cursor: pointer;
}
.home-nav-btn:hover { background: #e0e0e0; }

/* ===========================================
   Nursery Walk
   =========================================== */
.walk-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}
.walk-back-btn {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  cursor: pointer;
}
.walk-back-btn:hover { background: #f5f5f5; }
.walk-title {
  margin: 0;
  font-size: 1.2rem;
}
.walk-progress {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 1rem;
}
.walk-status-message {
  margin: 0 0 1rem;
  color: #166534;
  font-size: 0.85rem;
}
.walk-session-home,
.walk-session-detail {
  display: grid;
  gap: 1rem;
}
.walk-session-hero,
.walk-session-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border: 1px solid #d9e8d3;
  border-radius: 16px;
  background: linear-gradient(135deg, #f6fbf3 0%, #eef6ea 100%);
}
.walk-session-hero h3,
.walk-session-summary h3 {
  margin: 0;
  font-size: 1.1rem;
}
.walk-session-hero p,
.walk-session-summary p {
  margin: 0.2rem 0 0;
  color: #4b5563;
}
.walk-session-kicker {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #2f6b2f;
}
.walk-start-btn,
.walk-secondary-btn {
  white-space: nowrap;
}
.walk-secondary-btn {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #0f172a;
  border-radius: 999px;
  padding: 0.55rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
.walk-secondary-btn:hover {
  background: #f8fafc;
}
.walk-session-list {
  display: grid;
  gap: 0.75rem;
}
.walk-session-card {
  display: grid;
  gap: 0.2rem;
  text-align: left;
  font: inherit;
  padding: 0.95rem 1rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  cursor: pointer;
}
.walk-session-card:hover {
  border-color: #7aa36c;
  box-shadow: 0 6px 18px rgba(47, 107, 47, 0.08);
}
.walk-session-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: #111827;
}
.walk-session-card-meta {
  font-size: 0.85rem;
  color: #6b7280;
}
.walk-empty-state {
  padding: 1rem 1.1rem;
  border: 1px dashed #b6c9ac;
  border-radius: 14px;
  background: #fafcf8;
}
.walk-empty-state strong {
  display: block;
  margin-bottom: 0.25rem;
}
.walk-empty-state p {
  margin: 0;
  color: #4b5563;
}
.walk-location-group {
  margin-bottom: 1rem;
}
.walk-location-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  padding: 0.4rem 0;
  margin: 0 0 0.35rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: #444;
  border-bottom: 1px solid var(--border);
}
.walk-batch-card.walk-reviewed {
  border-left: 3px solid #22c55e;
}
.walk-batch-card {
  width: 100%;
  text-align: left;
  font: inherit;
}
.walk-check {
  color: #22c55e;
  font-size: 1.1rem;
  font-weight: 700;
}

/* Walk Review Modal */
.walk-review-modal {
  text-align: left;
}
.walk-review-modal h2 { text-align: center; }

.health-checks {
  margin-bottom: 0.75rem;
}
.health-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}
.health-label {
  min-width: 5rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: #444;
}
.health-btns {
  display: flex;
  gap: 0.35rem;
}
.health-btn {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: 2px solid #ddd;
  background: transparent;
  color: #888;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.health-btn.good.active {
  background: #22c55e;
  border-color: #22c55e;
  color: #fff;
}
.health-btn.neutral.active {
  background: #f59e0b;
  border-color: #f59e0b;
  color: #fff;
}
.health-btn.bad.active {
  background: #ef4444;
  border-color: #ef4444;
  color: #fff;
}
.health-btn:hover {
  border-color: #999;
}

.walk-photo-preview {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-top: 0.25rem;
}
.walk-photo-preview img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.walk-forecast {
  margin-bottom: 0.75rem;
  border: none;
  padding: 0;
}
.walk-forecast summary {
  font-size: 0.8rem;
  color: var(--muted);
  cursor: pointer;
  margin-bottom: 0.5rem;
}

.walk-review-modal textarea {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  resize: vertical;
  box-sizing: border-box;
}

@media (max-width: 720px) {
  .walk-session-hero,
  .walk-session-summary {
    align-items: flex-start;
    flex-direction: column;
  }
  .walk-start-btn,
  .walk-secondary-btn {
    width: 100%;
  }
}

/* ===========================================
   Scrollable Action Tabs
   =========================================== */
.action-tabs.scrollable {
  overflow-x: auto;
  flex-wrap: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.action-tabs.scrollable::-webkit-scrollbar { display: none; }
.action-tabs.scrollable button {
  flex: 0 0 auto;
  white-space: nowrap;
  padding: 0.5rem 0.6rem;
  font-size: 0.8rem;
}

/* ===========================================
   Planning Gantt Chart
   =========================================== */
.gantt-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-top: 0.35rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.gantt-controls .new-batch-btn {
  width: auto;
  margin-bottom: 0;
  padding: 0.45rem 0.8rem;
  font-size: 0.88rem;
  border-radius: 8px;
}
.new-batch-btn.secondary {
  background: #f8fafc;
  color: #334155;
  border: 1px solid #cbd5e1;
}
.new-batch-btn.secondary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.gantt-resolution {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 0.85rem;
  color: var(--text);
}
.planning-period-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.planning-period-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}
.planning-date-picker {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--muted);
}
.planning-date-input {
  min-width: 150px;
}
.gantt-key-link {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--muted);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
  cursor: pointer;
}
.gantt-key-link:hover {
  color: var(--text);
}
.planning-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.planning-generate-btn {
  margin-left: 0;
}
.planning-new-btn {
  white-space: nowrap;
}
.planning-key-btn {
  padding: 0.2rem 0.45rem;
  font-size: 0.75rem;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}
.planning-key-btn:hover {
  color: var(--text);
  background: #f8fafc;
  border-color: var(--border);
}

/* Stage key modal */
.stage-key-modal {
  max-width: 360px;
}
.stage-key-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.stage-key-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
}
.stage-key-swatch {
  font-weight: 700;
  font-size: 0.75rem;
  min-width: 40px;
  text-align: right;
}
.gantt-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}
.gantt-empty p {
  margin-bottom: 1rem;
}

/* Scroll wrapper */
.gantt-scroll {
  overflow-x: auto;
  overflow-y: auto;
  max-height: calc(100vh - 180px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  -webkit-overflow-scrolling: touch;
}

/* Table base */
.gantt-table {
  border-collapse: collapse;
  width: max-content;
  min-width: 100%;
}

/* Header row */
.gantt-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  padding: 10px 6px;
  text-align: center;
  color: var(--muted);
}
.gantt-label-th {
  position: sticky;
  left: 0;
  z-index: 4 !important;
  text-align: left !important;
  min-width: 220px;
  max-width: 280px;
  padding-left: 12px !important;
  border-right: 2px solid var(--border);
  background: var(--surface);
}
.gantt-col-th {
  min-width: 56px;
  border-right: 1px solid var(--border);
}

/* Data rows */
.gantt-row {
  cursor: pointer;
}
.gantt-table-planning .gantt-row {
  height: 86px;
}
.gantt-row:hover .gantt-label-td {
  background: #f8f8f8;
}
.gantt-row:hover .gantt-cell:not(.gantt-bar) {
  background: #fafafa;
}
.gantt-spacer-row td {
  padding: 0;
  border: 0;
  background: transparent;
}
.gantt-spacer-cell {
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
}

/* Label cell (sticky left) */
.gantt-label-td {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface);
  border-right: 2px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 8px 12px;
  min-width: 220px;
  max-width: 280px;
  vertical-align: middle;
}
.gantt-item-name {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}
.gantt-item-meta {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 2px;
  font-size: 0.75rem;
}
.gantt-item-qty {
  color: var(--muted);
  font-weight: 500;
}
.gantt-item-detail {
  margin-top: 3px;
  font-size: 0.68rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
  opacity: 0.85;
}
.gantt-item-customer {
  font-size: inherit;
}
.gantt-item-project {
  font-size: inherit;
}
.gantt-item-sep {
  margin: 0 4px;
}
.gantt-item-actions {
  margin-top: 6px;
}
.tiny-btn {
  font-size: 0.7rem;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f8fafc;
  color: #334155;
  cursor: pointer;
}
.tiny-btn:hover {
  border-color: #94a3b8;
}
.wo-plan-nav-btn {
  padding: 4px 12px;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 4px);
  background: var(--surface);
  cursor: pointer;
  color: var(--text);
}
.wo-plan-nav-btn:hover {
  background: #f1f5f9;
}
.wo-plan-nav-btn.active {
  background: var(--primary, #2d6a4f);
  color: #fff;
  border-color: var(--primary, #2d6a4f);
}
.wo-plan-table .gantt-cell {
  min-width: 120px;
  text-align: left;
  padding: 0.45rem 0.55rem;
  height: auto;
}

.grow-plan-builder-page {
  padding: 0.75rem 0;
}
.grow-plan-builder-shell {
  max-width: 1100px;
  min-width: 900px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.9rem;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
  box-sizing: border-box;
}
.plan-stage-change-alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 10px;
  padding: 8px 10px;
  border: 1px solid #f2c94c;
  border-radius: 6px;
  background: #fff8db;
  color: #5f4300;
  font-size: 12px;
}
.plan-stage-change-alert button {
  flex: 0 0 auto;
}

/* Plan status badges */
.badge.plan-planned { background: #dbeafe; color: #1d4ed8; }
.badge.plan-in_production { background: #dcfce7; color: #15803d; }
.badge.plan-partial { background: #fef3c7; color: #92400e; }
.badge.plan-complete { background: #e2e8f0; color: #475569; }

/* Time cells */
.gantt-cell {
  position: relative;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  min-width: 56px;
  height: 44px;
  padding: 1px 0;
  vertical-align: middle;
  text-align: center;
}

/* Today column highlight */
.gantt-col-th.gantt-today,
.gantt-cell.gantt-today {
  background: rgba(37, 99, 235, 0.04);
}

/* Gantt bar (pseudo-element) */
.gantt-cell.gantt-bar::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 22px;
  transform: translateY(-50%);
  background: #3b82f6;
  opacity: 0.75;
}
.gantt-cell.gantt-bar-start::after {
  left: 3px;
  border-radius: 4px 0 0 4px;
}
.gantt-cell.gantt-bar-end::after {
  right: 3px;
  border-radius: 0 4px 4px 0;
}
.gantt-cell.gantt-bar-start.gantt-bar-end::after {
  border-radius: 4px;
}

/* Quantity label in bar-end cell */
.gantt-bar-qty {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.65rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
  line-height: 1;
  white-space: nowrap;
}

/* Stage markers in Gantt cells */
.gantt-stage-marker {
  position: relative;
  z-index: 2;
  display: block;
  font-size: 0.6rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  text-align: center;
}

/* Status-based bar colors */
tr[data-status="planned"] .gantt-bar::after { background: #3b82f6; }
tr[data-status="in_production"] .gantt-bar::after { background: #22c55e; }
tr[data-status="partial"] .gantt-bar::after { background: #f59e0b; }
tr[data-status="complete"] .gantt-bar::after { background: #94a3b8; }
.gantt-row.gantt-forecast-gap .gantt-bar::after { background: #ef4444; }

/* Batch indicator in Gantt row */
.gantt-batch-indicator {
  font-size: 0.7rem;
  background: #dbeafe;
  color: #1e40af;
  padding: 1px 5px;
  border-radius: 4px;
  white-space: nowrap;
}

/* Plan preview (backward calc) */
.plan-preview {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-sm);
  padding: 0.6rem;
  margin-top: 0.5rem;
}
.plan-preview-header {
  font-size: 0.8rem;
  margin-bottom: 0.4rem;
}
.plan-preview-summary {
  display: flex;
  gap: 1rem;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}
.plan-preview-stages {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.plan-preview-stage {
  display: flex;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--muted);
  align-items: center;
}
.plan-preview-stage .stage-name {
  text-transform: capitalize;
  font-weight: 600;
  min-width: 70px;
}
.plan-preview-stage .stage-qty {
  margin-left: auto;
  font-weight: 600;
  color: var(--text);
}

.plant-item-plan-actions {
  margin-top: 6px;
  display: flex;
  gap: 6px;
  align-items: center;
}
.plant-item-plan-actions .small {
  width: auto;
}
.plant-item-plan-preview {
  margin-top: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.plant-item-plan-stage {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 0.78rem;
  color: var(--muted);
}
.plant-item-plan-stage strong {
  min-width: 72px;
  color: var(--text);
}

/* Plan item container typeahead */
.plan-item-typeahead {
  position: relative;
}
.plan-item-typeahead-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.15);
  max-height: 220px;
  overflow-y: auto;
  z-index: 40;
}
.plan-item-typeahead-item {
  display: block;
  width: 100%;
  text-align: left;
  background: #fff;
  color: var(--text);
  border: none;
  border-bottom: 1px solid #f1f5f9;
  border-radius: 0;
  padding: 0.5rem 0.65rem;
  font-size: 0.9rem;
}
.plan-item-typeahead-item:hover {
  background: #e0f2fe;
}
.plan-item-typeahead-item.active,
.plan-item-typeahead-item:focus-visible {
  background: #dbeafe;
  outline: none;
}

/* Existing batches section in plan modal */
.plan-batches-section {
  margin-top: 0.75rem;
  border-top: 1px solid var(--border);
  padding-top: 0.5rem;
}
.plan-batches-section h3 {
  font-size: 0.85rem;
  margin: 0 0 0.4rem 0;
}
.plan-batches-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.plan-work-order-cards {
  margin-top: 0.35rem;
}
.plan-work-order-card {
  border-color: #dbe4f0;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.plan-batch-row {
  display: flex;
  gap: 0.5rem;
  font-size: 0.8rem;
  align-items: center;
  padding: 0.2rem 0;
}
.plan-batch-open {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  border-radius: 6px;
  padding: 0.2rem 0.25rem;
}
.plan-batch-open:hover {
  background: #f3f4f6;
  color: var(--text);
}
.plan-batch-row .batch-num {
  font-weight: 600;
}
.plan-batch-row .batch-qty {
  color: var(--muted);
}
.plan-batch-open:hover .batch-qty {
  color: #4b5563;
}

/* Derive batch button */
.derive-batch-btn {
  width: 100%;
  margin-top: 0.5rem;
  background: #1e40af;
  color: #fff;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}
.derive-batch-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.derive-batch-btn-secondary {
  background: #fff;
  color: #0f172a;
  border: 1px solid #cbd5e1;
}
.plan-item-management {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.badge.plan-life-draft {
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #fdba74;
}
.badge.plan-life-ready {
  background: #ecfdf5;
  color: #166534;
  border: 1px solid #86efac;
}
.badge.plan-life-generated {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #93c5fd;
}

/* Today button */
.gantt-today-btn {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
  background: transparent;
  color: #2563eb;
  border: 1px solid #93c5fd;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.gantt-today-btn:hover {
  background: #eff6ff;
  color: #1d4ed8;
}

/* ===========================================
   At-Risk Highlighting
   =========================================== */
.gantt-risk-overdue .gantt-label-td {
  border-left: 3px solid #dc2626;
  background: #fff5f5;
}
.gantt-risk-imminent .gantt-label-td {
  border-left: 3px solid #f59e0b;
  background: #fffbeb;
}
.gantt-risk-overdue:hover .gantt-label-td {
  background: #fee2e2;
}
.gantt-risk-imminent:hover .gantt-label-td {
  background: #fef3c7;
}
.gantt-risk-badge {
  font-size: 0.6rem;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.gantt-risk-badge-overdue {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}
.gantt-risk-badge-imminent {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
}

/* ===========================================
   Workload Summary Row (tfoot)
   =========================================== */
.gantt-summary-row {
  position: sticky;
  bottom: 0;
  z-index: 3;
}
.gantt-summary-row .gantt-label-td {
  position: sticky;
  left: 0;
  z-index: 4;
  background: #f8fafc;
  border-top: 2px solid var(--border);
  border-right: 2px solid var(--border);
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--muted);
  padding: 8px 12px;
}
.gantt-summary-cell {
  background: #f8fafc;
  border-top: 2px solid var(--border);
  min-height: 36px;
}
.gantt-workload-marker {
  display: block;
  font-size: 0.6rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
}

/* ===========================================
   Plan vs Reality Markers
   =========================================== */
.gantt-reality-marker {
  position: absolute;
  bottom: 2px;
  right: 3px;
  z-index: 2;
  font-size: 0.65rem;
  line-height: 1;
}
.gantt-reality-on_track { color: #16a34a; }
.gantt-reality-behind { color: #f59e0b; }
.gantt-reality-complete { color: #94a3b8; }

/* Mobile adjustments */
@media (max-width: 768px) {
  .gantt-label-th,
  .gantt-label-td {
    min-width: 160px;
    max-width: 180px;
  }
  .gantt-col-th {
    min-width: 44px;
  }
  .gantt-cell {
    min-width: 44px;
    height: 38px;
  }
  .gantt-item-name {
    font-size: 0.8rem;
    max-width: 150px;
  }
  .gantt-controls {
    gap: 0.4rem;
  }
}

/* Work order status badges */
.wo-status-draft { background: #f0ad4e; color: #fff; }
.wo-status-ready { background: #5bc0de; color: #fff; }
.wo-status-completed { background: #5cb85c; color: #fff; }
.wo-status-done { background: #5cb85c; color: #fff; }
.wo-status-in_progress { background: #f0ad4e; color: #fff; }
.wo-draft { border-left: 3px solid #f0ad4e; }
.wo-ready { border-left: 3px solid #5bc0de; }
.wo-plan-row-ready td,
.wo-plan-row-ready { background: #eff6ff; }
.wo-plan-row-in-progress td,
.wo-plan-row-in-progress { background: #fff7ed; }
.wo-plan-row-done td,
.wo-plan-row-done { background: #ecfdf5; }

.wo-plan-detail-list {
  display: grid;
  gap: 10px;
}
.wo-plan-detail-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
}
.wo-plan-detail-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.wo-plan-detail-grid {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 12px;
  font-size: 0.85rem;
}
.wo-plan-detail-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
}
.plan-work-order-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.plan-item-work-orders-wrap {
  margin-top: 8px;
}
.plan-item-work-orders-table {
  min-width: 980px;
}
.plan-item-work-orders-table td {
  vertical-align: top;
}
.plan-item-work-orders-actions {
  white-space: nowrap;
}
.plan-item-work-order-click-row {
  cursor: pointer;
}
.plan-item-work-order-click-row:hover td,
.plan-item-work-order-click-row:focus-visible td {
  background: #dbeafe;
}
.plan-item-work-order-click-row:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: -2px;
}
.plan-item-work-orders-actions .wo-plan-edit-btn,
.plan-item-work-orders-actions .wo-plan-ready-btn {
  min-width: 88px;
  padding: 7px 12px;
}
.plan-item-work-orders-actions .wo-plan-ready-btn {
  margin-left: 6px;
}
.wo-plan-ready-btn {
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  background: #0f766e;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  min-width: 120px;
}
.wo-plan-ready-btn:hover {
  background: #0d9488;
}
.wo-plan-edit-btn {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 9px 16px;
  background: #fff;
  color: #0f172a;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  min-width: 140px;
}
.wo-plan-edit-btn:hover {
  background: #f8fafc;
}
@media (max-width: 768px) {
  .plan-work-order-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .wo-plan-detail-grid {
    grid-template-columns: 1fr;
  }
  .wo-plan-detail-actions {
    flex-direction: column;
  }
  .wo-plan-edit-btn,
  .wo-plan-ready-btn {
    width: 100%;
  }
}

/* My Work stats row */
.my-work-stats { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0.75rem 0 1rem; }
.my-work-stat { flex: 1; min-width: 80px; text-align: center; padding: 8px 6px; background: #f8f9fa; border-radius: 6px; border: 1px solid #e5e7eb; }
.my-work-stat-value { font-size: 1.25rem; font-weight: 700; color: var(--text); }
.my-work-stat-label { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.my-work-stat-subvalue { margin-top: 2px; font-size: 0.72rem; color: #475569; }

.my-work-action-tabs {
  display: flex;
  align-items: stretch;
  margin: 18px 0 10px;
  overflow-x: auto;
  border: 1px solid #cfd6dd;
  border-radius: 6px 6px 0 0;
  background: #eef1f4;
  box-shadow: inset 0 -1px 0 #cfd6dd;
  -webkit-overflow-scrolling: touch;
}
.my-work-action-tab {
  flex: 1 1 0;
  min-width: 118px;
  min-height: 46px;
  padding: 11px 14px;
  border: 0;
  border-right: 1px solid #cfd6dd;
  border-bottom: 3px solid transparent;
  background: #f7f9fb;
  color: #475569;
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.15;
  cursor: pointer;
  white-space: nowrap;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.my-work-action-tab:last-child { border-right: 0; }
.my-work-action-tab:hover:not(.active) {
  background: #ffffff;
  color: #111827;
}
.my-work-action-tab.active {
  background: #1f6f50;
  color: #ffffff;
  border-bottom-color: #0f5138;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
}
.my-work-action-tab:focus-visible {
  outline: 3px solid #86b7fe;
  outline-offset: -3px;
  position: relative;
  z-index: 1;
}

@media (max-width: 480px) {
  .my-work-stat { min-width: calc(33% - 0.5rem); flex: none; }
  .my-work-action-tabs {
    margin-top: 14px;
  }
  .my-work-action-tab {
    flex: 0 0 auto;
    min-width: 108px;
    min-height: 42px;
    padding: 10px 12px;
    font-size: 0.82rem;
  }
}

/* My Work filters - always visible on desktop */
@media (min-width: 769px) {
  .my-work-filters-collapse summary { display: none; }
  .my-work-filters-collapse > div { display: flex !important; }
}

/* Walk quick actions */
.walk-quick-actions { margin: 12px 0; }
.walk-quick-actions summary { cursor: pointer; font-weight: 600; font-size: 0.9rem; }
.walk-move-work-order {
  margin: 10px 0 12px;
  padding: 10px;
  border: 1px solid #d7e6d7;
  border-radius: 8px;
  background: #f6fbf5;
}
.walk-move-work-order-title {
  margin-bottom: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  color: #2f5d35;
}
.walk-move-work-order-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
}
.walk-action-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.walk-action-btn { min-width: 0; padding: 8px; font-size: 0.85rem; border: 1px solid #ddd; border-radius: 4px; background: #f8f9fa; cursor: pointer; white-space: normal; overflow-wrap: anywhere; }
.walk-action-btn:hover { background: #e9ecef; }
.walk-action-btn-primary {
  width: 100%;
  margin-top: 8px;
  border-color: #2f6b3b;
  background: #2f6b3b;
  color: #fff;
}
.walk-action-btn-primary:hover {
  background: #24542d;
}
@media (max-width: 640px) {
  .walk-move-work-order-grid {
    grid-template-columns: 1fr;
  }
}

/* Work order history in batch detail */
.wo-history-list { display: flex; flex-direction: column; gap: 4px; }
.wo-history-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 4px; cursor: pointer; font-size: 0.85rem; }
.wo-history-item:hover { background: #f0f0f0; }
.wo-history-action { flex: 1; }
.wo-history-date { font-size: 0.8rem; }
.wo-history-qty { font-size: 0.8rem; color: #666; }

/* Stage advance layout */
.stage-advance-info { display: flex; align-items: center; gap: 12px; margin: 12px 0; padding: 10px; background: #f0f7f0; border-radius: 6px; }
.stage-advance-current, .stage-advance-next { flex: 1; }
.stage-advance-arrow { font-size: 1.5rem; color: #888; }

/* Work order toggle in action modal */
.wo-schedule-row { margin: 12px 0 4px; padding: 10px; background: #f8f9fa; border-radius: 6px; }
.wo-toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 0.9rem; }
.wo-toggle input[type="checkbox"] { width: 18px; height: 18px; }
.wo-submit { background: #f0ad4e !important; }

/* Work order detail modal — wider */
.wo-detail-modal {
  background: #fff;
  border-radius: 16px;
  padding: 2rem;
  max-width: 750px;
  width: 95%;
  position: relative;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  max-height: 90vh;
  overflow-y: auto;
  box-sizing: border-box;
}
.wo-headline-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0 14px;
}
.wo-flow-metrics {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.wo-headline-metric {
  background: #f8fafc;
  border: 1px solid #dbe5ef;
  border-radius: 8px;
  padding: 8px 10px;
  text-align: center;
}
.wo-headline-label {
  font-size: 0.72rem;
  line-height: 1.1;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.wo-headline-value {
  font-size: 1.7rem;
  font-weight: 800;
  line-height: 1.1;
  color: #0f172a;
  margin-top: 2px;
}
.wo-headline-subvalue {
  margin-top: 4px;
  font-size: 0.75rem;
  color: #475569;
}
.wo-worker-card {
  background: #f8fafc;
  border: 1px solid #dbe5ef;
  border-radius: 8px;
  padding: 14px;
  margin: 10px 0 14px;
}
.wo-worker-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.wo-worker-card h4 {
  margin: 2px 0 0;
  font-size: 1.05rem;
  color: #0f172a;
}
.wo-worker-eyebrow {
  font-size: 0.72rem;
  line-height: 1.1;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
}
.wo-worker-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
}
.wo-worker-grid > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.wo-worker-grid strong {
  color: #111827;
  font-size: 0.95rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.wo-linked-batch-btn {
  align-self: flex-start;
  border: 0;
  background: transparent;
  color: #1d4ed8;
  padding: 0;
  font: inherit;
  font-weight: 700;
  line-height: 1.25;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.wo-linked-batch-btn:hover {
  color: #0f3a8a;
}
.wo-worker-instruction {
  grid-column: 1 / -1;
}
.wo-worker-team select {
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.9rem;
  background: #fff;
}
.wo-worker-team-edit {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.wo-worker-team-edit select {
  min-width: 180px;
}
.wo-worker-team-edit button {
  border: 0;
  border-radius: 6px;
  background: #337ab7;
  color: #fff;
  padding: 7px 10px;
  font-size: 0.85rem;
  cursor: pointer;
}
.wo-worker-team-edit .secondary-btn {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #334155;
}
.wo-inline-edit {
  border: 0;
  background: transparent;
  color: #1d4ed8;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0 0 0 6px;
  cursor: pointer;
}
@media (max-width: 768px) {
  .wo-detail-modal { max-width: 95%; padding: 1rem; }
  .wo-headline-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wo-headline-value { font-size: 1.35rem; }
  .wo-worker-grid { grid-template-columns: 1fr; }
}

.wo-plan-section {
  background: #f8fbff;
  border: 1px solid #dbe5ef;
  border-radius: 8px;
  padding: 12px 14px;
  margin: 12px 0;
}
.wo-section-title {
  margin: 0 0 8px;
  font-size: 0.85rem;
  color: #1d4ed8;
}
.wo-plan-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 12px;
  font-size: 0.9rem;
}
.wo-plan-edit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
}
.wo-plan-edit-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
}
.wo-plan-edit-grid input,
.wo-plan-edit-grid select,
.wo-plan-edit-grid textarea {
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.9rem;
  background: #fff;
}
.wo-plan-notes {
  grid-column: 1 / -1;
}

/* Seeding details section in WO modal */
.wo-seeding-details {
  background: #f0f7f0;
  border: 1px solid #d4e6d4;
  border-radius: 8px;
  padding: 12px 14px;
  margin: 12px 0;
}
.wo-seeding-defaults {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.wo-seeding-default-card {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid #d4e6d4;
  border-radius: 8px;
  padding: 8px 10px;
}
.wo-seeding-default-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #5b6b5b;
}
.wo-seeding-default-value {
  margin-top: 3px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #234323;
}
@media (max-width: 768px) {
  .wo-seeding-defaults {
    grid-template-columns: 1fr;
  }
  .wo-plan-grid,
  .wo-plan-edit-grid {
    grid-template-columns: 1fr;
  }
}

.wo-exec-log {
  background: #f8fafc;
  border: 1px solid #dbe5ef;
  border-radius: 8px;
  padding: 12px 14px;
  margin: 12px 0;
}
.wo-exec-summary {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: #334155;
  margin-bottom: 8px;
}
.wo-session-notice {
  margin: 0 0 8px;
  padding: 8px 10px;
  border-radius: 6px;
  background: #dcfce7;
  color: #166534;
  font-size: 0.85rem;
  border: 1px solid #86efac;
}
.wo-session-warning {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 6px;
  background: #fff7ed;
  color: #9a3412;
  font-size: 0.85rem;
  border: 1px solid #fdba74;
}
.wo-session-warning p {
  margin: 0;
}
.wo-execution-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
  padding: 8px;
  background: #f8fafc;
  border: 1px solid #dbe5ef;
  border-radius: 8px;
}
.wo-execution-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: #334155;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
}
.wo-execution-tab.active {
  border-color: #337ab7;
  background: #dff0fd;
  color: #174766;
  box-shadow: inset 0 -3px 0 #337ab7;
}
.wo-execution-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #334155;
  font-size: 0.75rem;
  line-height: 1;
}
.wo-execution-tab.active .wo-execution-step {
  background: #337ab7;
  color: #fff;
}
.wo-record-work-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.wo-primary-action {
  background: #337ab7;
  color: #fff;
}
.wo-exec-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.wo-form-step-heading {
  grid-column: 1 / -1;
  margin-top: 2px;
  padding-top: 2px;
  color: #1f2937;
  font-size: 0.82rem;
  font-weight: 700;
}
.wo-exec-grid label {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.wo-exec-grid input,
.wo-exec-grid select {
  padding: 4px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 0.85rem;
}
.wo-exec-notes {
  grid-column: 1 / -1;
}
.wo-batch-panel {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  background: #eef6ff;
  border: 1px solid #cfe0f5;
  border-radius: 8px;
}
.wo-batch-panel-title {
  grid-column: 1 / -1;
  font-size: 0.82rem;
  font-weight: 700;
  color: #1e3a5f;
}
.wo-batch-panel-copy {
  grid-column: 1 / -1;
  font-size: 0.78rem;
  color: #475569;
  margin-top: -2px;
}
@media (max-width: 768px) {
  .wo-record-work-actions {
    justify-content: stretch;
  }
  .wo-record-work-actions button {
    flex: 1 1 160px;
  }
  .wo-exec-grid {
    grid-template-columns: 1fr;
  }
  .wo-batch-panel {
    grid-template-columns: 1fr;
  }
}
.wo-exec-table {
  margin-top: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  overflow: hidden;
}
.wo-exec-head,
.wo-exec-row {
  display: grid;
  grid-template-columns: 1.4fr 0.9fr 0.7fr 0.9fr 0.8fr 1fr 1.5fr;
  gap: 8px;
  padding: 6px 8px;
  font-size: 0.8rem;
}
.wo-exec-head {
  background: #e2e8f0;
  font-weight: 600;
}
.wo-exec-row:nth-child(even) {
  background: #f8fafc;
}
.wo-exec-empty {
  padding: 10px 8px;
  color: #64748b;
  font-size: 0.82rem;
  text-align: center;
  background: #fff;
}

/* Seeding sub-row in task editor */
.seeding-task-details {
  background: #f8faf8;
  border-left: 3px solid #5cb85c;
  padding: 6px 8px;
  margin: 0 0 6px 20px;
  border-radius: 0 4px 4px 0;
}

/* Work Order creation — action picker buttons */
.wo-action-pick-btn {
  padding: 10px 8px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #f9fafb;
  color: #1f2937;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  text-align: center;
  transition: background 0.15s, border-color 0.15s;
}
.wo-action-pick-btn:hover {
  background: #e0f2fe;
  border-color: #93c5fd;
  color: #1f2937;
}

/* Typeahead dropdown */
.wo-typeahead-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 0 0 6px 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  max-height: 200px;
  overflow-y: auto;
  z-index: 50;
}
.wo-typeahead-item {
  padding: 8px 10px;
  cursor: pointer;
  font-size: 0.85rem;
}
.wo-typeahead-item:hover {
  background: #e0f2fe;
}

/* Strict alignment for plan task editor header/rows */
.plan-task-grid-header,
.plan-task-grid-row {
  display: grid;
  grid-template-columns: minmax(170px, 2fr) minmax(130px, 1.2fr) 58px 54px 64px 64px 56px 64px 68px 52px 30px;
  gap: 4px;
  align-items: center;
}
.plan-task-grid-header {
  padding: 4px 4px 6px;
  border-bottom: 2px solid #ddd;
  margin-bottom: 4px;
  font-size: 10px;
  font-weight: 600;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.plan-task-grid-header span {
  text-align: center;
}
.plan-task-grid-header span:first-child,
.plan-task-grid-header span:nth-child(2) {
  text-align: left;
}
.plan-task-grid-row {
  margin-bottom: 6px;
  padding: 4px;
  border-bottom: 1px solid #f0f0f0;
}
.plan-task-grid-row input,
.plan-task-grid-row select {
  width: 100%;
  min-width: 0;
  padding: 3px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 12px;
  box-sizing: border-box;
}
.plan-task-readonly-type {
  width: 100%;
  min-width: 0;
  min-height: 28px;
  display: flex;
  align-items: center;
  padding: 3px 6px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #f5f5f5;
  color: #333;
  font-size: 12px;
  box-sizing: border-box;
}
.plan-task-auto {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 11px;
  color: #555;
}
.plan-task-remove {
  padding: 1px 5px;
  font-size: 14px;
  line-height: 1;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  color: #c00;
  font-weight: 700;
  cursor: pointer;
}
.plan-task-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
}
.plan-task-move {
  padding: 1px 4px;
  font-size: 12px;
  line-height: 1;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  color: #374151;
  cursor: pointer;
}
.plan-task-move:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.plan-task-chem-row {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 6px;
  margin: -2px 4px 6px;
}
.plan-task-chem-row input {
  width: 100%;
  padding: 3px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 12px;
  box-sizing: border-box;
}
.plan-task-detail-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 1.15fr);
  gap: 8px 12px;
  margin: -2px 4px 8px;
  padding: 8px 10px;
  border: 1px solid #dbead9;
  border-radius: 6px;
  background: #f7fbf5;
}
.plan-task-detail-pair,
.plan-task-detail-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.plan-task-detail-label {
  font-size: 10px;
  font-weight: 700;
  color: #5f6f52;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.plan-task-detail-value {
  font-size: 12px;
  color: #253028;
}
.plan-task-detail-field select,
.plan-task-detail-field input {
  width: 100%;
  min-width: 0;
  padding: 5px 6px;
  border: 1px solid #cddccc;
  border-radius: 4px;
  font-size: 12px;
  box-sizing: border-box;
  background: #fff;
}
.plan-task-summary {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
  font-size: 0.78rem;
  color: #5f6b76;
}

.batch-production-links {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 14px 0;
  padding: 12px;
  border: 1px solid #d8e2d6;
  border-radius: 6px;
  background: #fbfdf9;
}
.batch-production-link-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.batch-production-link-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid #e4ebe2;
  border-radius: 6px;
  background: #fff;
}
.batch-production-link-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}
.batch-production-link-form {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) minmax(90px, 0.45fr) minmax(180px, 1fr) auto auto;
  gap: 8px;
  align-items: end;
}
.batch-production-link-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  font-size: 0.78rem;
  font-weight: 700;
  color: #455346;
}
.batch-production-link-form select,
.batch-production-link-form input {
  width: 100%;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid #cfd8cd;
  border-radius: 4px;
  background: #fff;
  font-size: 0.86rem;
  box-sizing: border-box;
}
.batch-production-link-reason {
  min-width: 0;
}

@media (max-width: 840px) {
  .batch-production-link-row,
  .batch-production-link-form {
    grid-template-columns: 1fr;
  }
  .batch-production-link-actions {
    justify-content: flex-start;
  }
}

.gantt-board-chip {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  padding: 1px 5px;
  border: 1px solid #d7e2d8;
  border-radius: 4px;
  background: #f8fbf6;
  color: #34423a;
  font-size: 0.68rem;
  font-weight: 650;
  line-height: 1.2;
}
.gantt-board-chip-gap,
.gantt-board-risk-gap,
.plan-board-risk-gap {
  border-color: #fecaca;
  background: #fff1f2;
  color: #991b1b;
}
.gantt-board-risk-watch,
.plan-board-risk-watch {
  border-color: #fde68a;
  background: #fffbeb;
  color: #92400e;
}
.gantt-board-risk-covered,
.plan-board-risk-covered {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}
.gantt-board-risk-none {
  color: #667085;
}
.plan-board-detail {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.plan-board-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.plan-board-metric {
  min-width: 0;
  padding: 8px;
  border: 1px solid #dfe7dd;
  border-radius: 6px;
  background: #fbfdf9;
}
.plan-board-metric span {
  display: block;
  color: #667085;
  font-size: 0.72rem;
  font-weight: 650;
}
.plan-board-metric strong {
  display: block;
  margin-top: 2px;
  font-size: 1rem;
}
.plan-board-metric small {
  display: block;
  margin-top: 2px;
  color: #667085;
  font-size: 0.68rem;
  font-weight: 600;
}
.plan-board-metric-risk {
  border-color: #fecaca;
  background: #fff7f7;
}
.plan-board-detail-block h4 {
  margin: 0 0 6px;
  font-size: 0.8rem;
}
.plan-board-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.plan-board-list-row {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) auto auto auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  padding: 7px 8px;
  border: 1px solid #e3ebe0;
  border-radius: 6px;
  background: #fff;
  color: inherit;
  text-align: left;
  font-size: 0.78rem;
}
.plan-board-list-row small {
  color: #667085;
  font-size: 0.72rem;
}
.plan-board-lineage-label {
  display: block;
  margin-top: 2px;
}
.plan-board-coverage-wrap {
  max-height: 260px;
}
.plan-board-coverage-table th,
.plan-board-coverage-table td {
  white-space: nowrap;
}

@media (max-width: 760px) {
  .plan-board-summary-grid,
  .plan-board-list-row {
    grid-template-columns: 1fr 1fr;
  }
}
