/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

:root {
  color-scheme: light;
  font-family: Inter, "Noto Sans Thai", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f6f8fb;
  color: #111827;
}

html {
  box-sizing: border-box;
}
*, *::before, *::after {
  box-sizing: inherit;
}

/* Ensure HTML hidden attribute always wins over author display rules */
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background: #eef2f6;
}

a {
  color: #1d4ed8;
  text-decoration: none;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 0.5rem;
  padding: 0.65rem 1rem;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.button--primary {
  background: #2563eb;
  color: #ffffff;
}

.button--secondary {
  background: #f8fafc;
  color: #0f172a;
  border-color: #cbd5e1;
}

.button--danger {
  background: #fff;
  color: #dc2626;
  border-color: #fca5a5;
}
.button--danger:hover { background: #fef2f2; }

.button:hover {
  opacity: 0.95;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar__brand {
  display: flex;
  align-items: center;
}

.topbar__logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: #111827;
}

.topbar__logo-img {
  height: 28px;
  width: auto;
}

.topbar__nav {
  display: flex;
  gap: 1rem;
}

.topbar__link {
  color: #475569;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
}

.topbar__link--active,
.topbar__link:hover {
  background: #f8fafc;
  color: #0f172a;
}

.topbar__dropdown {
  position: relative;
}

.topbar__dropdown > .topbar__link {
  cursor: default;
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

.topbar__submenu {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: visibility 0s 0.18s, opacity 0.12s 0.06s;
  position: absolute;
  top: 100%;
  left: 0;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  min-width: 11rem;
  padding: 0.4rem 0.25rem 0.25rem;
  z-index: 100;
}

.topbar__dropdown:hover .topbar__submenu {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transition: visibility 0s, opacity 0.1s;
}

.topbar__submenu-link {
  display: block;
  padding: 0.5rem 0.75rem;
  color: #475569;
  border-radius: 0.375rem;
  white-space: nowrap;
}

.topbar__submenu-link:hover,
.topbar__submenu-link--active {
  background: #f8fafc;
  color: #0f172a;
}

.app-shell {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1.5rem;
}

.page-header__title {
  margin: 0;
  font-size: clamp(1.5rem, 2vw, 2rem);
}

/* Header carrying an inline control: it sits beside the title rather than
   being pushed to the far edge by the default space-between. */
.page-header--with-filter {
  justify-content: flex-start;
  align-items: center;
  gap: 1rem;
}
.page-header__filter { display: flex; align-items: center; }

.page-header__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 1rem;
  padding: 1rem 1.25rem;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.04);
}

.panel--sticky {
  position: sticky;
  top: 57px;
  z-index: 9;
}

.panel-title {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6b7280;
  margin-bottom: 0.75rem;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.data-table th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: #6b7280;
  padding: 0.25rem 0.5rem 0.5rem;
  border-bottom: 1px solid #e2e8f0;
}
.data-table th.text-right { text-align: right; }
.data-table td {
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid #f1f5f9;
  color: #1e293b;
}
.data-table tbody tr:last-child td { border-bottom: none; }

a.link {
  color: #3b82f6;
  text-decoration: none;
}
a.link:hover { text-decoration: underline; }

a.link--add {
  font-size: 0.875rem;
  color: #6b7280;
}
a.link--add:hover { color: #3b82f6; text-decoration: none; }

.seed-lots-add-row {
  margin-top: 0.75rem;
}

.prod-attach-list {
  list-style: none;
  padding: 0;
  margin: 0 0 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.prod-attach-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.875rem;
}

.prod-attach-icon { color: #64748b; flex-shrink: 0; }

.prod-attach-link {
  flex: 1;
  color: #3b82f6;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.prod-attach-link:hover { text-decoration: underline; }

.prod-attach-name-input {
  flex: 1;
  font-size: 0.875rem;
  padding: 0.2rem 0.4rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.4rem;
}

.prod-attach-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #94a3b8;
  padding: 0.1rem 0.3rem;
  line-height: 1;
  flex-shrink: 0;
}
.prod-attach-btn:hover { color: #475569; }
.prod-attach-btn--delete:hover { color: #ef4444; }

.prod-attach-add summary { cursor: pointer; font-size: 0.875rem; }
.prod-attach-add[open] summary { margin-bottom: 0.5rem; }

.prod-attach-form {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.prod-attach-input {
  width: 100%;
  padding: 0.4rem 0.6rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.6rem;
  font-size: 0.875rem;
  background: #f8fafc;
}

.empty-state {
  color: #9ca3af;
  font-size: 0.875rem;
  margin: 0;
}

.section {
  margin-bottom: 1.5rem;
}

.cards {
  display: grid;
  gap: 1rem;
}

.grid {
  display: grid;
  gap: 1rem;
}

.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
}

thead {
  background: #f8fafc;
}

thead th,
tbody td {
  text-align: left;
  padding: 0.45rem 1rem;
  border-bottom: 1px solid #e2e8f0;
}

tbody tr:last-child td {
  border-bottom: none;
}

.table-group-header td {
  background: #e8edf3;
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #475569;
  padding: 0.5rem 1rem;
  border-top: 2px solid #e2e8f0;
}

.table__label {
  color: #475569;
  font-size: 0.95rem;
}

.form-field {
  display: grid;
  gap: 0.25rem;
  margin-bottom: 1rem;
}

label {
  font-size: 0.95rem;
  color: #334155;
}

input[type="text"],
input[type="date"],
input[type="number"],
input[type="email"],
input[type="tel"],
input[type="url"],
select,
textarea {
  width: 100%;
  min-width: 0;
  padding: 0.75rem 0.9rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.75rem;
  background: #f8fafc;
  color: #0f172a;
}

textarea {
  min-height: 120px;
}

.field-inline {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.flash {
  padding: 1rem 1.25rem;
  border-radius: 1rem;
  margin-bottom: 1rem;
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #d1fae5;
}

.button--sm {
  padding: 0.3rem 0.7rem;
  font-size: 0.85rem;
}

.row-actions {
  width: 1%;
  white-space: nowrap;
  text-align: right;
  padding-right: 1rem;
}

.table-row--hoverable .row-actions .button {
  opacity: 0;
  transition: opacity 0.15s ease;
}

.table-row--hoverable:hover .row-actions .button {
  opacity: 1;
}

.btx-row--selected td {
  background: #bfdbfe;
}

[data-controller~="bank-transaction-table"] {
  outline: none;
}

.contact-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  max-width: 1100px;
}

.contact-form__left {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.contact-form__right {
  display: flex;
  flex-direction: column;
}

.section--compact {
  margin-bottom: 0;
}

.section--sm {
  margin-bottom: 0.5rem;
}

.form-field--compact {
  margin-bottom: 0.2rem;
}

.form-field--compact label {
  font-size: 0.72rem;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.1rem;
}

.form-field--compact input,
.form-field--compact select,
.form-field--compact textarea {
  font-size: 1rem;
  padding: 0.4rem 0.6rem;
}

.notes-area {
  min-height: 80px;
  resize: vertical;
}

.panel__title {
  font-size: 1rem;
  font-weight: 600;
  color: #475569;
  margin: 0 0 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.form-field--inline-check {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  padding-top: 1.75rem;
}

.form-field--inline-check input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
}

.flash--error {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
}

.text-muted {
  color: #94a3b8;
  font-size: 0.85rem;
}

.badge--active {
  color: #16a34a;
  font-weight: 700;
}

.badge--inactive {
  color: #dc2626;
  font-weight: 700;
}

.text-right {
  text-align: right;
}

/* ── Crop filter buttons ──────────────────── */

.crop-filter-buttons {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.crop-filter-buttons .button {
  min-width: 5rem;
  text-align: center;
  justify-content: center;
}

.search-bar__count {
  font-size: 0.85rem;
  color: #6b7280;
  white-space: nowrap;
}

/* ── Search bar ───────────────────────────── */

.search-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  /* Fill the panel so margin-left:auto has room to push trailing buttons to
     the right edge, even on bars with no flexible search input. */
  width: 100%;
}

.search-bar__input-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
  max-width: 220px;
}

.search-bar__icon {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.9rem;
  pointer-events: none;
  color: #94a3b8;
}

.search-bar__input {
  width: 100%;
  padding: 0.5rem 2rem 0.5rem 2.2rem !important;
}

.search-bar__clear {
  position: absolute;
  right: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.search-bar__clear:hover { color: #475569; }
.invoice-year-select { width: 5.5rem; flex-shrink: 0; }
.search-bar__checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: #475569;
  white-space: nowrap;
  cursor: pointer;
}

/* ── Variety detail ───────────────────────── */

.variety-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 1rem;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 1rem;
  margin-bottom: 0.75rem;
}

.variety-header__left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.variety-header__right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.variety-code-pill {
  font-family: monospace;
  font-size: 1rem;
  font-weight: 700;
  background: #166534;
  color: #fff;
  padding: 4px 14px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}

.variety-header__name {
  font-size: 1rem;
  font-weight: 500;
  color: #1a1a1a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.variety-header__meta {
  font-size: 1rem;
  color: #94a3b8;
  white-space: nowrap;
}

.status-badge {
  font-size: 0.85rem;
  font-weight: 500;
  padding: 3px 11px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}
.badge-sales        { background: #d4edda; color: #155724; }
.badge-testing      { background: #fff3cd; color: #856404; }
.badge-stopped      { background: #e2e3e5; color: #383d41; }
.badge-third-party  { background: #dbeafe; color: #1e40af; }

.btn-nav {
  font-size: 0.85rem;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #1d1d1f;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.4;
}
.btn-nav:hover { background: #f5f5f7; color: #1d1d1f; }
.btn-nav--disabled { opacity: 0.3; cursor: default; }

.nav-counter { font-size: 0.7rem; color: #aaa; }

.variety-notice {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #d1fae5;
  border-radius: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.variety-body {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 0.75rem;
  min-height: 0;
}

.production-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  align-items: start;
}

.production-col {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.production-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0 0.25rem;
}

.prod-parentage-grid {
  display: grid;
  grid-template-columns: 4rem 1fr 1fr 1fr 1fr;
  gap: 0.4rem 0.6rem;
  align-items: center;
}

.prod-parentage-grid .form-field {
  margin-bottom: 0;
}

.prod-parentage-header {
  font-size: 0.78rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding-bottom: 0.2rem;
}

.prod-parentage-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #334155;
}

.prod-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.75rem;
}

.prod-row-variety {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 0.75rem;
}

.prod-variety-name__value {
  padding: 0 0.9rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  background: #f1f5f9;
  min-height: 2.75rem;
  display: flex;
  align-items: center;
  line-height: normal;
}

/* Productions list — quantity cell: target above, actual below */
.prod-qty-target {
  font-size: 0.7rem;
  color: #b6c2d1;
}

.prod-qty-actual {
  font-size: 1rem;
  font-weight: 600;
  color: #2563eb;
}

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

.input-group {
  display: flex;
  align-items: stretch;
}

.input-group__prefix {
  display: flex;
  align-items: center;
  padding: 0 0.6rem;
  background: #e2e8f0;
  border: 1px solid #cbd5e1;
  border-right: none;
  border-radius: 0.75rem 0 0 0.75rem;
  font-size: 0.9rem;
  color: #475569;
  min-width: 2rem;
  justify-content: center;
}

.input-group input {
  border-radius: 0 0.75rem 0.75rem 0;
}

.variety-col-left {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 1rem;
  padding: 1rem 1.25rem;
  overflow-y: auto;
}

.variety-col-right {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 1rem;
  padding: 1rem 1.25rem;
  overflow-y: auto;
}

.variety-field {
  margin-bottom: 0.6rem;
}

.variety-field label {
  display: block;
  font-size: 0.72rem;
  font-weight: 500;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.2rem;
}

.variety-field input[type="text"],
.variety-field select,
.variety-field textarea {
  width: 100%;
  padding: 0.4rem 0.6rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  background: #f8fafc;
  color: #1a1a1a;
  font-size: 0.95rem;
}

.variety-field textarea { resize: vertical; min-height: 64px; }

.variety-field input:focus,
.variety-field select:focus,
.variety-field textarea:focus {
  outline: none;
  border-color: #94a3b8;
  background: #fff;
}

.variety-field--check {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  padding-top: 1.4rem;
}

.variety-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin-bottom: 0.0rem;
}

/* Resistances pill */
.resistances-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.res-pill {
  display: inline-flex;
  align-items: center;
  background: #dbeafe;
  color: #1e40af;
  padding: 4px 13px;
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
  word-break: break-word;
}

.res-pill--empty {
  background: transparent;
  border: 1.5px dashed #cbd5e1;
  color: #94a3b8;
  font-size: 0.8rem;
}
.res-pill--empty:hover { border-color: #94a3b8; color: #64748b; }

.res-input {
  flex: 1;
  border-radius: 999px !important;
  padding: 4px 13px !important;
  font-size: 0.85rem !important;
}

/* Collapsible */
.coll-header {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 6px 0;
  user-select: none;
  margin-top: 4px;
  border-top: 1px solid #f1f5f9;
}
.coll-header:hover .coll-title { color: #475569; }

.coll-chevron { font-size: 0.6rem; color: #94a3b8; flex-shrink: 0; }
.coll-title { font-size: 0.8rem; font-weight: 600; color: #94a3b8; white-space: nowrap; text-transform: uppercase; letter-spacing: 0.05em; }
.coll-rule { flex: 1; height: 1px; background: #e8edf3; }
.coll-summary { font-size: 0.72rem; color: #94a3b8; white-space: nowrap; max-width: 200px; overflow: hidden; text-overflow: ellipsis; }

.coll-content { display: none; padding-top: 0.5rem; }
.coll-content--open { display: block; }

/* Photos */
.variety-photos-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.variety-photos-label { font-size: 0.8rem; font-weight: 600; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.05em; }
.variety-photos-count { font-size: 0.75rem; color: #94a3b8; }
.variety-photos-empty { font-size: 0.85rem; color: #94a3b8; font-style: italic; }

.photo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}

.photo-tile {
  aspect-ratio: 1;
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: #e8e8e8;
}

.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }

.photo-tile__link { display: block; width: 100%; height: 100%; }
.photo-tile__link--text {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: #555;
}

.photo-tile__delete {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
  padding: 0;
}
.photo-tile:hover .photo-tile__delete { opacity: 1; }
.photo-tile__delete:hover { background: rgba(220,38,38,0.85); }

.photo-tile--add {
  border: 1.5px dashed #cbd5e1;
  border-radius: 8px;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #cbd5e1;
  font-size: 1.8rem;
  aspect-ratio: 1;
}
.photo-tile--add:hover { border-color: #94a3b8; color: #94a3b8; }

.photo-tile__caption-area {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
}

.photo-tile__caption-display {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(0,0,0,0.5);
  color: #fff;
  font-size: 0.65rem;
  padding: 3px 6px;
  cursor: pointer;
  min-height: 20px;
}
.photo-tile__caption-display span:first-child {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.photo-tile__caption-pen {
  opacity: 0;
  font-size: 0.7rem;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
.photo-tile:hover .photo-tile__caption-pen { opacity: 1; }
.photo-tile__caption-display:not(:has(span:first-child:empty)) { background: rgba(0,0,0,0.5); }
.photo-tile__caption-display:has(span:first-child:empty) { background: transparent; }
.photo-tile:hover .photo-tile__caption-display:has(span:first-child:empty) { background: rgba(0,0,0,0.4); }

.photo-tile__caption-editor {
  display: none;
  align-items: center;
  background: rgba(0,0,0,0.75);
  padding: 2px 4px;
}
.photo-tile__caption-editor input {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(255,255,255,0.6);
  color: #fff;
  font-size: 0.65rem;
  outline: none;
  padding: 2px 2px;
  width: 100%;
}

/* Add photo form */
.add-photo-form {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
  border-top: 1px solid #e2e8f0;
  margin-top: 0.75rem;
}

.add-photo-form--open {
  max-height: 600px;
  padding-top: 0.75rem;
}

.add-photo-form__title {
  font-size: 0.72rem;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.6rem;
}

.add-photo-form__actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.upload-btn-wrap { position: relative; }

.upload-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}

.upload-btn {
  background: #fff;
  color: #166534;
  border: 1px solid #166534;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.82rem;
}
.upload-btn:hover { background: #f0fdf4; }

.file-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 6px 8px;
  margin-top: 6px;
  font-size: 0.78rem;
  color: #475569;
}

.file-preview img {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
}

.file-preview__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.file-preview__clear {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0;
  flex-shrink: 0;
}
.file-preview__clear:hover { color: #475569; background: none; }

.add-photo-divider {
  text-align: center;
  font-size: 0.72rem;
  color: #94a3b8;
  margin: 0.5rem 0;
}

.photo-tile__img { width: 100%; height: 100%; object-fit: cover; display: block; }

.add-photo-form__cancel {
  background: none;
  border: none;
  font-size: 0.85rem;
  color: #94a3b8;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}
.add-photo-form__cancel:hover { color: #475569; background: none; }

/* Variety footer */
.variety-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0 0.25rem;
}

/* ── Invoice template ─────────────────────────── */

/* Close button row — same max-width as invoice paper, button right-aligned */
.invoice-close-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}
.inv-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #475569;
  text-decoration: none;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.inv-close-btn:hover { background: #cbd5e1; color: #0f172a; }

/* ── Invoice show: paper + sidebar layout ───────────────────── */
.invoice-show-layout {
  display: grid;
  grid-template-columns: 1fr 260px;
  grid-template-rows: auto 1fr;
  gap: 0.4rem 0.75rem;
}

.invoice-close-bar {
  grid-column: 1;
  grid-row: 1;
}

.invoice-show-layout .invoice-preview-wrap {
  grid-column: 1;
  grid-row: 2;
  min-width: 0;
}

/* The sidebar is a column of cards, not a card itself — the box styling now
   lives on .inv-sidebar-card so the groups read as separate panels. */
.invoice-sidebar {
  grid-column: 2;
  grid-row: 2;
  width: 260px;
  position: sticky;
  top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  font-size: 0.82rem;
}

.inv-sidebar-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  padding: 0.4rem 1rem;
  box-shadow: 0 2px 8px rgba(15,23,42,0.05);
}
/* An empty card (e.g. no attachments block rendered) should not show. */
.inv-sidebar-card:empty { display: none; }

.inv-sidebar-section {
  padding: 0.6rem 0;
  border-bottom: 1px solid #f1f5f9;
}
.inv-sidebar-section:last-child { border-bottom: none; }
/* Dividers separate rows within a card; the card edge ends the last one. */
.inv-sidebar-card > .inv-sidebar-section:last-child { border-bottom: none; }

.inv-sidebar-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94a3b8;
  margin-bottom: 0.25rem;
}

.inv-sidebar-row { display: flex; align-items: center; gap: 0.4rem; }

.inv-sidebar-value { color: #1e293b; }
.inv-sidebar-value--total { font-weight: 600; font-size: 0.95rem; color: #0f6b3a; }

.inv-attach-list { list-style: none; margin: 0.25rem 0 0.5rem; padding: 0; }

.inv-input--date { width: 100%; padding: 0.3rem 0.4rem; font-size: 0.85rem; border: 1px solid #cbd5e1; border-radius: 6px; color: #1e293b; background: #fff; }

.inv-paid-pill { display: inline-block; font-size: 0.82rem; font-weight: 600; color: #16a34a; border: 1.5px solid #16a34a; border-radius: 6px; padding: 0.2rem 0.6rem; }

.inv-clear-date-btn { background: none; border: none; color: #94a3b8; font-size: 1rem; line-height: 1; cursor: pointer; padding: 0 0.2rem; }
.inv-clear-date-btn:hover { color: #ef4444; }

.inv-receipt-signature { margin-top: 1.5rem; display: flex; flex-direction: column; align-items: flex-start; gap: 0.4rem; }
.inv-sig-line { width: 200px; border-bottom: 1px solid #334155; }
.inv-sig-label { font-size: 0.78rem; color: #475569; }
.inv-sig-image { width: 160px; height: auto; margin-bottom: -0.4rem; }
.inv-attach-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0;
  font-size: 0.78rem;
}
.btx-attach-item {
  background: #cbd5e1;
  border-radius: 6px;
  padding: 0.4rem 0.5rem;
  margin-bottom: 0.3rem;
}
.inv-attach-icon { flex-shrink: 0; font-size: 0.85rem; color: #64748b; }
.inv-attach-icon.bi-file-pdf-fill    { color: #dc2626; }
.inv-attach-icon.bi-file-spreadsheet-fill { color: #16a34a; }
.inv-attach-icon.bi-folder-fill      { color: #d97706; }
.inv-attach-link {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #2563eb;
  text-decoration: none;
}
.inv-attach-link:hover { text-decoration: underline; }
.inv-attach-item form {
  flex-shrink: 0;
  display: inline-flex;
  margin: 0;
}
.inv-attach-delete {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: #94a3b8;
  padding: 0 2px;
  font-size: 0.85rem;
  line-height: 1;
}
.inv-attach-delete:hover { color: #dc2626; }
.inv-attach-edit {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: #94a3b8;
  padding: 0 2px;
  font-size: 0.75rem;
  line-height: 1;
}
.inv-attach-edit:hover { color: #2563eb; }
.inv-attach-name-input {
  flex: 1;
  min-width: 0;
  font-size: 0.78rem;
  padding: 1px 4px;
  height: 22px;
}
.inv-attach-add { margin-top: 0.4rem; }
.inv-attach-add-toggle {
  font-size: 0.78rem;
  color: #2563eb;
  cursor: pointer;
  list-style: none;
}
.inv-attach-add-toggle::-webkit-details-marker { display: none; }
.inv-attach-form {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.4rem;
}
.inv-attach-url-input { font-size: 0.78rem !important; padding: 0.25rem 0.4rem !important; }

.inv-attach-notes-display {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-left: 0.5rem;
  padding-left: 0.5rem;
  border-left: 1px solid #94a3b8;
  font-size: 0.75rem;
  color: #334155;
}
.inv-attach-notes-display.inv-attach-notes--empty { color: #475569; font-style: italic; }
.inv-attach-notes-input {
  flex: 1;
  min-width: 0;
  max-width: 320px;
  margin-left: 0.5rem;
  font-size: 0.75rem;
  padding: 1px 4px;
  height: 20px;
}

/* ── Bank transaction detail (redesign) ─────────────────────── */
.btx-detail-body { display: flex; flex-direction: column; gap: 16px; }

.btx-card {
  background: #e3e5e1;
  border-radius: 14px;
  padding: 28px 32px;
}

.btx-eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #8a938e;
  margin-bottom: 6px;
}

.btx-field-label {
  font-size: 13px;
  color: #8a938e;
  margin-bottom: 4px;
}

.btx-field-value {
  font-size: 15px;
  font-weight: 600;
  color: #1c2321;
}

.btx-field-value--mono {
  font-weight: 500;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.btx-header-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 28px;
}

.btx-tx-ref { font-size: 26px; font-weight: 700; letter-spacing: -0.01em; color: #1c2321; }
.btx-tx-date { font-size: 14px; color: #8a938e; margin-top: 4px; }

.btx-header-meta { display: flex; flex-direction: column; gap: 14px; }

.btx-header-amount { text-align: right; }
.btx-amount { font-size: 34px; font-weight: 700; letter-spacing: -0.01em; }
.btx-amount--withdrawal { color: #b3261e; }
.btx-amount--deposit    { color: #0f6b4c; }

.btx-header-pills {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}
.btx-header-pills .pill { white-space: nowrap; }

.btx-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.btx-detail-grid > .btx-card { display: flex; flex-direction: column; gap: 18px; }

@media (max-width: 720px) {
  .btx-detail-grid { grid-template-columns: 1fr; }
}

.btx-editable-cell { cursor: text; }

.btx-attach-list { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 10px; }

.btx-attach-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: #fbfbfa;
  border: 1px solid #eef0ed;
  border-radius: 10px;
}

.btx-attach-icon-wrap {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #e7f3ee;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #0f6b4c;
  text-decoration: none;
}

.btx-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  border: 1px solid #e5e7e2;
  background: #ffffff;
  color: #4b524d;
  font-size: 20px;
  text-decoration: none;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.btx-close-btn:hover { background: #f4f5f3; color: #1c2321; }

.btx-attach-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.btx-attach-link {
  font-size: 14px;
  font-weight: 500;
  color: #1c2321;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.btx-attach-link:hover { text-decoration: underline; }

.btx-attach-name-input { font-size: 14px; padding: 2px 6px; height: 26px; min-width: 140px; }

.btx-attach-notes-display { font-size: 13px; color: #8a938e; }
.btx-attach-notes-display.btx-attach-notes--empty { font-style: italic; }
.btx-attach-notes-input { font-size: 13px; padding: 2px 6px; height: 24px; min-width: 120px; }

.btx-attach-actions {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  color: #8a938e;
  font-size: 14px;
}

.btx-attach-icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #8a938e;
  padding: 0;
  line-height: 1;
}
.btx-attach-icon-btn:hover { color: #1c2321; }

.btx-attach-actions form { display: inline-flex; margin: 0; }

.inv-currency-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}
.inv-currency-badge--thb { background: #dcfce7; color: #15803d; }
.inv-currency-badge--usd { background: #dbeafe; color: #1d4ed8; }
.inv-currency-badge--eur { background: #ede9fe; color: #6d28d9; }

.inv-currency-select {
  border: 1px solid #cbd5e1;
  border-radius: 0.4rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: #1e293b;
  background: #f8fafc;
  cursor: pointer;
}

@media print {
  .invoice-sidebar { display: none; }
  .invoice-show-layout { display: block; }
}

.invoice-preview-wrap {
  overflow-x: auto;
  padding-bottom: 280px;
}

.invoice-preview {
  display: inline-block;
  width: 100%;
  transform: scale(1.25);
  transform-origin: top center;
}

.invoice-paper {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 1rem;
  padding: 2rem 3.5rem;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.04);
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 1120px;
  font-family: "Roboto", "Noto Sans Thai", sans-serif;
}

.invoice-body { flex: 1; }

.invoice-footer {
  border-top: 1px solid #e2e8f0;
  padding-top: 0.75rem;
  margin-top: 1rem;
}

.invoice-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
  margin-bottom: 1.25rem;
}

.invoice-info-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 2rem;
  margin-bottom: 1.25rem;
}

.invoice-info-row .invoice-brand {
  flex-shrink: 0;
}

.invoice-info-row .invoice-customer-block {
  flex: 0 0 auto;
  width: 52%;
}

.invoice-seller {
  font-family: "Roboto", sans-serif;
  font-size: 12px;
  line-height: 1.75;
  color: #334155;
}

.invoice-seller__name {
  font-family: "Roboto", sans-serif;
  font-weight: 700;
  font-size: 13px;
  color: #111;
}

.invoice-brand {
  text-align: left;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
  flex-shrink: 0;
}

.invoice-logo {
  height: 110px;
  width: auto;
}

.invoice-paid-badge {
  font-size: 1.1rem;
  font-weight: 700;
  color: #16a34a;
  border: 2.5px solid #16a34a;
  border-radius: 6px;
  padding: 0.25rem 0.75rem;
  white-space: nowrap;
  align-self: center;
}

.inv-list-thb-est {
  display: block;
  font-weight: 500;
}

.inv-list-foreign-amount {
  display: block;
  font-size: 0.75rem;
  color: #64748b;
}

/* Fixed layout: column widths come from the header alone, so the browser never
   re-measures cell content. Without this, revealing the payment-ref input
   re-flowed the whole table — contact names wrapped and every row grew. */
.inv-list-table { table-layout: fixed; }

/* Nicknames run to 40+ characters. Truncate rather than widen the column, so
   the space stays with Contact; the full value is on the cell's title. */
.inv-list-nick {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 0;
}

/* Fixed width, so opening the editor cannot widen the column and force the
   rest of the table to re-flow (contact names wrapping, rows growing).
   Tighter side padding than the default cell, so the editor fills the column
   instead of sitting in a narrow well inside 1rem of padding on each side. */
.inv-list-cell--editable {
  cursor: text;
  width: 130px;
  min-width: 130px;
  max-width: 130px;
  padding-left: 0.4rem;
  padding-right: 0.4rem;
}

.inv-list-cell--editable:hover {
  background: #f8fafc;
}

/* The display span reserves the same box as the input it swaps with, so the
   swap changes nothing about the row's geometry. */
.inv-list-cell--editable > span {
  display: block;
  height: 1.6rem;
  line-height: 1.6rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Sized to sit exactly where the display text was: box-sizing keeps the border
   and padding inside the cell's width, and the fixed line-height/height stops
   the row growing taller when the editor opens. The radius is declared with
   !important because the global input[type=text] rule (0.75rem, pill-like at
   this height) is defined later in the file and would otherwise win. */
.inv-list-input {
  width: 100%;
  box-sizing: border-box;
  height: 1.6rem;
  line-height: 1.3;
  font: inherit;
  border: 1px solid #94a3b8;
  border-radius: 4px !important;
  padding: 0.15rem 0.4rem;
  outline: none;
}

/* An inset ring instead of box-shadow spread — a spread ring is painted
   outside the element and nudges the layout on some browsers. */
.inv-list-input:focus {
  border-color: #3b82f6;
  box-shadow: inset 0 0 0 1px rgba(59,130,246,0.35);
}

/* Category picker in the invoice list — quiet until hovered or focused, so a
   column of selects does not shout over the rest of the row. font/color are
   inherited from the cell so it matches the Contact column exactly; a select
   would otherwise fall back to the browser's own form-control font. */
/* Fixed width that fits the longest value ("SEED SALES") plus the arrow, and a
   fixed height matching the payment-ref editor so rows keep one geometry. */
.inv-list-category-select {
  font: inherit;
  color: inherit;
  width: 145px;
  height: 1.6rem;
  box-sizing: border-box;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 0.15rem 0.35rem;
  background: transparent;
  cursor: pointer;
}
.inv-list-category-select:hover { border-color: #cbd5e1; }
.inv-list-category-select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: inset 0 0 0 1px rgba(59,130,246,0.35);
}
.inv-list-saved { border-color: #22c55e !important; background: rgba(34,197,94,.12) !important; }


.invoice-heading {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: #166534;
}

.invoice-meta-table {
  border-collapse: separate;
  border-spacing: 0 0.3rem;
  font-size: 0.88rem;
  color: #334155;
}

.invoice-meta-table td {
  padding: 0.18rem 0.25rem 0.18rem 0;
  vertical-align: middle;
  border: none;
}

.invoice-meta-table td:last-child {
  background: #e2e8f0;
  border-radius: 999px;
  padding: 0;
  width: 8.5rem;
  text-align: center;
  font-size: 0.88rem;
  color: #334155;
  overflow: hidden;
}

/* Display text inside the pill cell */
.inv-pill-display {
  display: block;
  padding: 0 0.85rem;
  height: 1.6rem;
  line-height: 1.6rem;
}

.inv-meta-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94a3b8;
  white-space: nowrap;
  padding-right: 0.6rem !important;
}

/* Pill-shaped input that fills the grey pill cell */
.inv-pill-input {
  display: block;
  width: 100%;
  min-width: 0;
  background: transparent;
  border: none;
  border-radius: 999px;
  padding: 0 0.85rem;
  height: 1.6rem;
  line-height: 1.6rem;
  text-align: center;
  font-size: 0.88rem;
  color: #334155;
  outline: none;
  box-shadow: inset 0 0 0 2px #3b82f6;
  font-family: inherit;
  box-sizing: border-box;
  appearance: none;
  -webkit-appearance: none;
}
.inv-pill-input--bold { font-weight: 700; }

.invoice-due-date {
  font-size: 0.88rem;
  color: #334155;
}

.invoice-divider {
  border: none;
  border-top: 1.5px solid #e2e8f0;
  margin: 0.9rem 0;
}

.invoice-customer-block {
  margin-bottom: 0.25rem;
}

.invoice-customer-block__label {
  font-size: 0.85rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #0f172a;
  margin-bottom: 0.35rem;
}

.invoice-customer-block__body {
  font-size: 0.9rem;
  color: #334155;
  line-height: 1.6;
  background: #e2e8f0;
  border-radius: 1rem;
  padding: 0.6rem 0.75rem;
  min-height: 3rem;
}

/* Inline inputs — invisible until hovered/focused */
.inv-input {
  width: 100%;
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 0.375rem;
  background: transparent;
  padding: 0.3rem 0.4rem;
  font-size: 0.9rem;
  color: #0f172a;
  transition: border-color 0.1s, background 0.1s;
}

.inv-input:hover  { border-color: #e2e8f0; background: #f8fafc; }
.inv-input:focus  { border-color: #94a3b8; background: #fff; outline: none; }
.inv-input--num   { text-align: right; -moz-appearance: textfield; }
.inv-input--num::-webkit-inner-spin-button,
.inv-input--num::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.inv-input--bold  { font-weight: 700; }
.inv-input--error,
.inv-input--error:hover,
.inv-input--error:focus { border-color: #dc2626; background: #fef2f2; }
.inv-line-error { margin-top: 0.3rem; font-size: 0.78rem; color: #b91c1c; }

.inv-sync-warning {
  margin: 0 auto 0.75rem; max-width: 210mm;
  padding: 0.6rem 0.9rem; border: 1px solid #fcd34d; border-radius: 8px;
  background: #fffbeb; color: #92400e; font-size: 0.85rem;
}
.inv-sync-warning ul { margin: 0.3rem 0 0 1.1rem; padding: 0; }

.inv-select {
  width: 100%;
  padding: 0.1rem 0.5rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  background: #f8fafc;
  color: #0f172a;
  font-size: 0.9rem;
}

.inv-select:focus { outline: none; border-color: #94a3b8; background: #fff; }

/* Line items table */
.invoice-lines-table {
  width: 100%;
  border-collapse: collapse;
  font-family: "Roboto", "Noto Sans Thai", sans-serif;
  font-size: 12px;
  margin: 0.25rem 0;
}

.invoice-lines-table thead th {
  font-size: 1.1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #166534;
  padding: 0.4rem 0.5rem;
  border-bottom: 2px solid #e2e8f0;
  text-align: left;
}

.invoice-lines-table thead th.th-num { text-align: right; }

.invoice-lines-table tbody tr:nth-child(even) { background: #e8edf3; }
.invoice-lines-table tbody tr:nth-child(odd)  { background: #ffffff; }

/* Per-line editing */
.inv-line-row { cursor: pointer; }
.inv-line-row:not(.inv-line-editing):hover td { background: #f0f9ff; }
.inv-line-editing td { background: #eff6ff !important; cursor: default; }

.invoice-lines-table tbody td {
  padding: 0.2rem 0.5rem;
  vertical-align: middle;
  border: none;
}

/* Display spans match input height so the row never shifts on edit */
/* Inputs in the lines table: compact vertical padding, inherit table font size */
.invoice-lines-table .inv-input {
  font-size: inherit;
  padding-top: 0.05rem;
  padding-bottom: 0.05rem;
}

/* Display spans mirror the input size exactly so rows never shift */
.invoice-lines-table span[data-invoice-line-target$="Display"] {
  display: block;
  padding: 0.05rem 0.4rem;
  border: 1px solid transparent;
  font-size: inherit;
  line-height: inherit;
}

.inv-cell-total {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.inv-total-spacer td {
  height: 0.6rem;
  padding: 0;
  border: none;
  background: transparent;
}

.inv-total-row td {
  background: #e2e8f0;
  border-top: 1px solid #cbd5e1;
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f172a;
  padding-top: 0.30rem;
  padding-bottom: 0.30rem;
}

.inv-remove-btn {
  background: none;
  border: none;
  color: #cbd5e1;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  line-height: 1;
}

.inv-remove-btn:hover { color: #dc2626; background: #fef2f2; }

/* Mode-toggle button (switches picker ↔ free text) */
.inv-save-btn {
  background: none;
  border: 1px solid #86efac;
  border-radius: 4px;
  color: #16a34a;
  cursor: pointer;
  padding: 0.15rem 0.3rem;
  line-height: 1;
  margin-right: 0.2rem;
}
.inv-save-btn:hover { background: #f0fdf4; color: #15803d; }
.inv-mode-toggle {
  background: none;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  color: #64748b;
  cursor: pointer;
  padding: 0.15rem 0.3rem;
  line-height: 1;
  margin-right: 0.2rem;
}
.inv-mode-toggle:hover { background: #e2e8f0; color: #334155; }

/* Last-column cell holding toggle + delete */
.inv-new-badge {
  display: inline-block;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: #f97316;
  color: #fff;
  border-radius: 3px;
  padding: 1px 4px;
  margin-left: 3px;
  vertical-align: middle;
  line-height: 1.4;
}

.inv-line-btns {
  white-space: nowrap;
  vertical-align: middle;
}

/* Description cell needs relative positioning for the dropdown */
.inv-desc-cell { position: relative; }

/* Picker panel: variety input + lot select side by side */
.inv-picker-panel {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  width: 100%;
}

.inv-variety-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

.inv-variety-input { width: 100%; }

.inv-variety-dropdown {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  z-index: 200;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 0.5rem;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.1);
  list-style: none;
  margin: 0;
  padding: 0.25rem 0;
  max-height: 220px;
  overflow-y: auto;
}

.inv-variety-dropdown li {
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  font-size: 0.82rem;
  color: #334155;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inv-variety-dropdown li:hover { background: #e2e8f0; }

.inv-lot-select {
  flex: 0 0 auto;
  width: 150px;
  font-size: 0.9rem;
  padding: 0.3rem 1.6rem 0.3rem 0.4rem;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.4rem center;
  background-size: 14px;
  cursor: pointer;
}

.invoice-add-line { padding: 0.4rem 0.5rem; }

/* Totals */
.invoice-totals {
  display: flex;
  justify-content: flex-end;
  margin: 0.25rem 0 1.25rem;
}

.invoice-totals__table {
  min-width: 260px;
  font-size: 0.9rem;
  border-collapse: collapse;
}

.invoice-totals__table td { padding: 0.3rem 0.5rem; }
.invoice-totals__table td:last-child { text-align: right; font-variant-numeric: tabular-nums; }

.invoice-totals__table tr.total-row td {
  font-weight: 700;
  font-size: 1rem;
  border-top: 2px solid #111;
  padding-top: 0.5rem;
}

/* Bank details — inside invoice-footer, no extra border of its own */
.invoice-bank {
  font-size: 0.82rem;
  color: #64748b;
}

.invoice-bank__title {
  display: inline;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94a3b8;
}

/* Notes — sits tight below the lines total */
.invoice-notes {
  margin-top: 0.4rem;
  padding-top: 0;
}

.invoice-notes__label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #94a3b8;
  display: block;
  margin-bottom: 0.3rem;
}

.invoice-notes__body {
  font-size: 0.9rem;
  color: #334155;
  line-height: 1.6;
  min-height: 1.5rem;
  padding: 0.25rem 0;
}

.inv-textarea {
  width: 100%;
  padding: 0.2rem 0.5rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  background: #f8fafc;
  color: #0f172a;
  font-size: 0.88rem;
  resize: vertical;
  min-height: 2rem;
}

.inv-textarea:focus { outline: none; border-color: #94a3b8; background: #fff; }

/* Footer */
.invoice-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.75rem;
  border-top: 1px solid #e2e8f0;
  padding-top: 0.75rem;
}

.invoice-footer__paid {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: #334155;
  cursor: pointer;
}

/* ── Lines table sub-headers ────────────────────────────────────── */
.th-sub {
  display: block;
  font-size: 0.75em;
  font-weight: 400;
  color: #64748b;
  letter-spacing: 0;
}

/* ── Add-line button: reveal on hover of the lines zone ─────────── */
.inv-add-line-hover {
  opacity: 0;
  transition: opacity 0.15s;
}
.inv-lines-display-zone:hover .inv-add-line-hover {
  opacity: 1;
}

/* ── Inline-editable field indicators ──────────────────────────── */
.inv-editable {
  cursor: pointer;
  border-radius: 3px;
  transition: background 0.15s, outline 0.15s;
}
.inv-editable:hover {
  background: #f0f9ff;
  outline: 1px dashed #93c5fd;
}

.inv-inline-cancel {
  margin-top: 0.3rem;
}
.inv-inline-cancel button {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.8rem;
  color: #94a3b8;
  cursor: pointer;
}
.inv-inline-cancel button:hover { color: #ef4444; }

.inv-lines-actions {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 0 0.25rem;
}

/* ── Inventory show page ──────────────────────────────────────── */

.lot-number-pill {
  font-family: monospace;
  font-size: 0.95rem;
  font-weight: 700;
  background: #1d4ed8;
  color: #fff;
  padding: 0 14px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}

.inv-show-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.inv-show-nav__pos {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Stats strip — connected tiles with dividers */
.inv-stats-strip {
  padding: 10px 18px;
  display: flex;
  overflow: hidden;
}
.inv-stat {
  flex: 1;
  min-width: 90px;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.inv-stat:first-child { padding-left: 0; }
.inv-stat:last-child  { padding-right: 0; }
.inv-stat + .inv-stat { border-left: 1px solid #e2e8f0; }
.inv-stat__label { font-size: 11px; font-weight: 500; color: #6e6e73; }
.inv-stat__value { font-size: 16px; font-weight: 700; color: #1d1d1f; line-height: 1.2; }
.inv-stat__value--text { font-size: 13px; }
.inv-stat__unit  { font-size: 11px; color: #94a3b8; }

/* Status pills */
.status-pill { font-size: 11px; font-weight: 500; padding: 0 14px; height: 26px; display: inline-flex; align-items: center; border-radius: 999px; white-space: nowrap; flex-shrink: 0; }
.pill-green  { background: #d1fae5; color: #065f46; }
.pill-amber  { background: #fef3c7; color: #92400e; }
.pill-red    { background: #fee2e2; color: #991b1b; }
.pill-gray   { background: #f3f4f6; color: #6b7280; }
.pill-blue   { background: #dbeafe; color: #1e40af; }

/* Inventory lines zone */
.invl-zone { position: relative; }

.invl-add-zone {
  opacity: 0;
  transition: opacity 0.15s;
  padding: 0.4rem 0.5rem;
}
.invl-zone:hover .invl-add-zone { opacity: 1; }

/* Line rows */
.invl-row td { padding: 0.55rem 0.75rem; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.invl-row:last-child td { border-bottom: none; }
.invl-row.invl-editing td { background: #eff6ff !important; }
.invl-row--new td { background: #f8fafc; }

/* Hover: reveal plain-text edit/del links */
.invl-row-btns { display: flex; gap: 0.4rem; justify-content: flex-end; }
.invl-edit-link {
  opacity: 0;
  transition: opacity 0.12s;
  background: none;
  border: none;
  cursor: pointer;
  color: #8e8e93;
  font-size: 11px;
  padding: 0;
  line-height: 1;
}
.invl-row:hover .invl-edit-link { opacity: 1; }
.invl-edit-link:hover            { color: #1d1d1f; background: none; }
.invl-edit-link--danger:hover    { color: #dc2626; }

.invl-edit-btns { display: flex; gap: 0.25rem; justify-content: flex-end; }

.invl-actions-cell {
  text-align: right;
  white-space: nowrap;
  padding-right: 0.5rem !important;
}

/* Compact inputs inside rows */
.invl-input {
  width: 100%;
  min-width: 0;
  padding: 0.25rem 0.4rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.375rem;
  background: #fff;
  font-size: 0.9rem;
  text-align: right;
  -moz-appearance: textfield;
}
.invl-input::-webkit-inner-spin-button,
.invl-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.invl-input:focus { outline: none; border-color: #94a3b8; }
.invl-input--left { text-align: left; }
/* Native date picker: left-aligned, and keep the calendar button reachable
   in the narrow date column. */
.invl-input--date {
  text-align: left;
  padding-right: 0.2rem;
  font-size: 0.85rem;
}
.invl-input--date::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.55;
  padding: 0;
  margin-left: 0.1rem;
}
.invl-input--date::-webkit-calendar-picker-indicator:hover { opacity: 1; }

.invl-select {
  width: 100%;
  padding: 0.25rem 0.4rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.375rem;
  background: #fff;
  font-size: 0.85rem;
}
.invl-select:focus { outline: none; border-color: #94a3b8; }

/* Line type badges */
.invl-type-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}
.invl-stock-check {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  margin: 0.5rem 0 0.75rem;
}
.invl-stock-check__label { font-size: 0.85rem; color: #64748b; }
.invl-stock-check .invl-input { border-color: #cbd5e1; }

.invl-src-badge {
  font-size: 0.72rem; padding: 0.1rem 0.45rem; border-radius: 9999px;
  background: #f1f5f9; color: #475569; text-decoration: none; white-space: nowrap;
}
.invl-src-badge:hover { background: #e2e8f0; color: #1e293b; }
.invl-type-badge--receipt        { background: #d1fae5; color: #065f46; }
.invl-type-badge--retail_packing { background: #dbeafe; color: #1e40af; }
.invl-type-badge--shipment       { background: #ffedd5; color: #9a3412; }
.invl-type-badge--adjustment     { background: #f1f5f9; color: #475569; }

/* Seed lot test type badges */
.slt-type-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}
.slt-type-badge--germination { background: #d1fae5; color: #065f46; }
.slt-type-badge--purity      { background: #dbeafe; color: #1e40af; }
.slt-type-badge--tsw         { background: #ede9fe; color: #5b21b6; }
.slt-type-badge--vigor       { background: #fef3c7; color: #92400e; }
.slt-type-badge--laboratory  { background: #e0f2fe; color: #0369a1; }
.slt-type-badge--other       { background: #f1f5f9; color: #475569; }

/* Current balance row */
.invl-balance-row td {
  background: #f8fafc;
  border-top: 2px solid #e2e8f0;
  padding: 0.6rem 0.75rem;
  font-size: 0.9rem;
  color: #475569;
}

/* Production info row */
.inv-prod-row { display: flex; flex-wrap: wrap; gap: 0; align-items: flex-start; }
.inv-prod-field { display: flex; flex-direction: column; gap: 2px; padding: 0 14px; }
.inv-prod-field:first-child { padding-left: 0; }
.inv-prod-field + .inv-prod-field { border-left: 1px solid #e2e8f0; }
.inv-prod-label { font-size: 11px; color: #6e6e73; }
.inv-prod-value { font-size: 13px; font-weight: 500; color: #1d1d1f; }

/* Lot status select inside Production collapsible */
.inv-status-select { font-size: 13px; font-weight: 500; color: #1d1d1f; padding: 1px 4px; border: 1px solid #d1d5db; border-radius: 4px; background: #fff; width: auto; }

/* Show footer */
.inv-show-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.25rem 0 0.5rem;
}

.topbar__user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.topbar__user-name {
  font-size: 0.85rem;
  color: #6b7280;
  white-space: nowrap;
}

/* ── Mobile top bar ────────────────────────────────────────── */
.mobile-topbar {
  display: none;
  align-items: center;
  height: 48px;
  padding: 0 1rem;
  background: #2563eb;
  position: sticky;
  top: 0;
  z-index: 200;
}

.mobile-topbar__brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #ffffff;
  font-weight: 700;
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-topbar__logo-img {
  height: 24px;
  width: auto;
  flex-shrink: 0;
}

/* ── Mobile bottom tab bar ─────────────────────────────────── */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: #2563eb;
  border-top: 1px solid rgba(0, 0, 0, 0.15);
  z-index: 100;
  justify-content: space-around;
  align-items: stretch;
}

.mobile-bottom-nav__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 2px;
  padding: 6px 4px;
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.65rem;
  text-decoration: none;
  transition: color 0.15s;
}

.mobile-bottom-nav__item i { font-size: 1.25rem; line-height: 1; }

.mobile-bottom-nav__item:hover,
.mobile-bottom-nav__item--active {
  color: #ffffff;
}

.mobile-bottom-nav__item--disabled {
  opacity: 0.35;
  pointer-events: none;
}

.btx-mobile-detail {
  display: none;
  flex-direction: column;
  gap: 0.75rem;
}

@media (max-width: 767.98px) {
  .topbar--desktop {
    display: none;
  }
  .mobile-topbar,
  .mobile-bottom-nav {
    display: flex;
  }
  .app-shell {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
    padding-bottom: 76px;
  }
  .btx-desktop-filters,
  .btx-desktop-summary,
  .btx-desktop-detail,
  .btx-desktop-close-bar {
    display: none;
  }
  .btx-mobile-detail {
    display: flex;
  }
}

.btx-mobile-detail-card {
  display: block;
}

.btx-mobile-card__pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

.btx-mobile-detail-field {
  margin-bottom: 0.9rem;
}
.btx-mobile-detail-field:last-child {
  margin-bottom: 0;
}
.btx-mobile-detail-field .btx-editable-cell {
  font-size: 0.95rem;
  font-weight: 600;
  color: #1e293b;
  margin-top: 0.2rem;
}

/* ── Bottom sheet (generic mobile drawer) ─────────────────────── */
.bottom-sheet {
  position: fixed;
  inset: 0;
  z-index: 300;
}

.bottom-sheet__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.bottom-sheet__backdrop--visible { opacity: 1; }

.bottom-sheet__panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 85vh;
  overflow-y: auto;
  background: #ffffff;
  border-radius: 1.25rem 1.25rem 0 0;
  padding: 1rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom, 0px));
  transform: translateY(100%);
  transition: transform 0.22s ease;
  box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.12);
}
.bottom-sheet__panel--visible { transform: translateY(0); }

.bottom-sheet__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.bottom-sheet__title {
  font-weight: 700;
  font-size: 1rem;
  color: #0f172a;
}

.bottom-sheet__close {
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  color: #64748b;
  cursor: pointer;
  padding: 0.2rem;
}

/* ── Bank transactions mobile filter bar + sheet trigger ──────── */
.btx-mobile-filter-bar {
  display: none;
}

.btx-mobile-filter-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 0.6rem;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #2563eb;
  font-size: 1.05rem;
  position: relative;
}

.btx-mobile-filter-btn--active {
  border-color: #2563eb;
  background: #eff6ff;
}

.btx-mobile-filter-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2563eb;
}

.btx-mobile-search {
  flex: 1;
  min-width: 0;
  padding: 0.55rem 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.6rem;
  font-size: 0.9rem;
}

.btx-sheet-field { margin-bottom: 0.9rem; }
.btx-sheet-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  margin-bottom: 0.35rem;
}
.btx-sheet-select {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.6rem;
  font-size: 0.9rem;
  background: #fff;
}
.btx-sheet-checks {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}
.btx-sheet-checks label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: #1e293b;
}

@media (max-width: 767.98px) {
  .btx-mobile-filter-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }
}

/* ── Bank transactions mobile card list (floating islands) ──── */
.btx-mobile-list { display: none; }

@media (max-width: 767.98px) {
  .btx-desktop-table {
    display: none;
  }
  .btx-mobile-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }
}

.btx-mobile-card {
  display: block;
  background: #bfdbfe;
  border: 1px solid #93c5fd;
  border-radius: 1rem;
  padding: 0.9rem 1.1rem;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.1), 0 1px 3px rgba(15, 23, 42, 0.06);
  text-decoration: none;
  color: inherit;
}

.btx-mobile-card__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}

.btx-mobile-card__row--sub {
  margin-top: 0.15rem;
}

.btx-mobile-card__row--account {
  margin-top: 0.5rem;
}

.btx-mobile-card__ref {
  font-weight: 700;
  color: #2563eb;
  font-size: 0.95rem;
}

.btx-mobile-card__flow {
  font-weight: 700;
  font-size: 1rem;
  white-space: nowrap;
}

.btx-mobile-card__flow--debit  { color: #dc2626; }
.btx-mobile-card__flow--credit { color: #16a34a; }

.btx-mobile-card__date {
  font-size: 0.78rem;
  color: #64748b;
}

.btx-mobile-card__balance {
  font-size: 0.78rem;
  color: #64748b;
  white-space: nowrap;
}

.btx-mobile-card__account {
  font-size: 0.9rem;
  font-weight: 600;
  color: #1e293b;
  flex-shrink: 0;
  max-width: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btx-mobile-card__note {
  flex: 1;
  min-width: 0;
  text-align: right;
  font-size: 0.8rem;
  color: #64748b;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media print {
  /* Page setup */
  @page { margin: 1cm; }

  body {
    background: #fff !important;
  }

  /* Hide all screen-only chrome */
  .topbar,
  .mobile-topbar,
  .mobile-bottom-nav,
  .invoice-close-bar,
  .inv-sync-warning,
  .inv-add-line-hover,
  [data-invoice-show-target="linesEdit"],
  .inv-lines-actions {
    display: none !important;
  }

  /* Remove page shell padding */
  .app-shell {
    padding: 0 !important;
    max-width: 100% !important;
  }

  /* Flatten the card — no shadow, border, or rounded corners on paper */
  .invoice-paper {
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    margin: 0 !important;
    padding: 0 !important;
    max-width: 100% !important;
    min-height: unset !important;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  /* Remove edit-hover highlights */
  .inv-editable,
  .inv-editable:hover,
  .inv-line-row,
  .inv-line-row:hover td {
    background: transparent !important;
    outline: none !important;
    cursor: default !important;
  }

  /* Keep zebra striping in print */
  .invoice-lines-table tbody tr:nth-child(even) td {
    background: #f1f5f9 !important;
  }

  /* Keep total row background */
  .inv-total-row td {
    background: #e2e8f0 !important;
  }

  /* Pin footer to bottom of page without adding document height */
  .invoice-footer {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    padding: 0.5rem 3.5rem !important;
    background: #fff !important;
    border-top: 1px solid #e2e8f0 !important;
  }

  /* Picker UI never prints */
  .inv-picker-panel, .inv-variety-dropdown, .inv-mode-toggle { display: none !important; }

  /* Hide empty-state placeholders */
  .invoice-notes__body em { display: none !important; }

  /* Smaller font for invoice lines in print */
  .invoice-lines-table {
    font-size: 12px !important;
  }
  .invoice-lines-table thead th {
    font-size: 14px !important;
  }

  /* Reset zoom wrapper so the invoice prints at actual size */
  .invoice-preview {
    transform: none !important;
    transform-origin: unset !important;
    width: 100% !important;
  }
  .invoice-preview-wrap {
    padding-bottom: 0 !important;
    overflow: visible !important;
  }
}

/* ── Invoice list total ─────────────────── */
.inv-list-total {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.3;
}
.inv-list-total__label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94a3b8;
}
.inv-list-total__amount {
  font-size: 1.5rem;
  font-weight: 700;
  color: #111827;
}

/* ── Bank transaction list print ────────── */
@media print {
  .btx-filter-panel,
  .pagination { display: none !important; }
  .pill { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .btx-editable-cell { background: transparent !important; cursor: default !important; }
  .summary-bar { flex-wrap: wrap; }
}

/* ── Invoice list print ─────────────────── */
@media print {
  .inv-list-filter-form { display: none !important; }
  .inv-list-cell--editable { background: transparent !important; cursor: default !important; }
  .pill { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}

/* ── Invoice print run ───────────────────── */
.invoice-print-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1.25rem;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  margin-bottom: 1.5rem;
}
.invoice-print-bar__info {
  flex: 1;
  font-size: 0.9rem;
  color: #475569;
}
.invoice-print-run .invoice-preview-wrap + .invoice-preview-wrap {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 2px dashed #e2e8f0;
}

@media print {
  .invoice-print-bar { display: none !important; }
  .invoice-print-run .invoice-preview-wrap + .invoice-preview-wrap {
    margin-top: 0 !important;
    padding-top: 0 !important;
    border-top: none !important;
  }
  .invoice-print-run .invoice-paper {
    min-height: 0 !important;
    break-after: page;
  }
  .invoice-print-run .invoice-paper:last-child {
    break-after: auto;
  }
}

/* ── Inventory detail two-column layout ──── */

.inv-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1.5rem;
  align-items: start;
}

.inv-two-col__left,
.inv-two-col__right {
  min-width: 0;
}

.inv-two-col thead th,
.inv-two-col tbody td {
  font-size: 0.83rem;
  padding: 0.55rem 0.75rem;
}

.inv-two-col .button--sm {
  font-size: 0.78rem;
  padding: 0.2rem 0.5rem;
}

.inv-two-col .invl-select,
.inv-two-col .invl-input {
  font-size: 0.83rem;
  padding: 0.3rem 0.5rem;
}

@media (max-width: 900px) {
  .inv-two-col {
    grid-template-columns: 1fr;
  }
}

/* ── Basket ───────────────────────────────── */

.button--icon {
  padding: 0.3rem 0.5rem;
  line-height: 1;
}

.button--active.button--icon svg {
  stroke: #1d4ed8;
}

.topbar__link--basket {
  font-weight: 600;
  color: #1d4ed8;
}

.button--active {
  background: #dbeafe;
  color: #1d4ed8;
  border-color: #93c5fd;
}

.flash--alert {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
  padding: 1rem 1.25rem;
  border-radius: 1rem;
  margin-bottom: 1rem;
}

.flash--notice {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #d1fae5;
  padding: 1rem 1.25rem;
  border-radius: 1rem;
  margin-bottom: 1rem;
}

.input--compact {
  width: 100px;
  padding: 0.35rem 0.5rem;
  font-size: 0.95rem;
  text-align: right;
  border: 1px solid #cbd5e1;
  border-radius: 0.5rem;
  background: #f8fafc;
  -moz-appearance: textfield;
}
.input--compact::-webkit-outer-spin-button,
.input--compact::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* ── Filter bar ──────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
}
.filter-bar__group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
/* Paging parked at the right end of the filter bar. */
.filter-bar__pager {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
}
.filter-bar__group--check {
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
  padding-bottom: 0.2rem;
}
.filter-bar__label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.filter-bar__select,
.filter-bar__input {
  border: 1px solid #cbd5e1;
  border-radius: 0.5rem;
  padding: 0.45rem 0.65rem;
  font-size: 0.9rem;
  line-height: 1.5;
  height: 2.35rem;
  box-sizing: border-box;
  background: #fff;
  color: #111827;
}
/* Selects share the input's box, plus their own arrow. */
select.filter-bar__select {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  padding-right: 1.9rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath fill='%2394a3b8' d='M0 0h10L5 6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  background-size: 9px 6px;
}
.filter-bar__group--search { flex: 1; min-width: 180px; max-width: 320px; }
.filter-bar__input { width: 100%; }
.filter-bar__search-wrap { position: relative; display: flex; align-items: center; }
.filter-bar__search-input { padding-right: 1.8rem; width: 100%; }
.filter-bar__search-clear {
  position: absolute;
  right: 0.5rem;
  background: none;
  border: none;
  cursor: pointer;
  color: #94a3b8;
  font-size: 0.85rem;
  padding: 0;
  line-height: 1;
}
/* Used as a link as well as a button — centre the icon either way. */
.filter-bar__search-clear {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.filter-bar__search-clear:hover { color: #475569; }
.theme-dark .filter-bar__search-clear { color: var(--dk-text-mut); }
.theme-dark .filter-bar__search-clear:hover { color: var(--dk-text); }
.filter-bar__check {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
}

/* ── Summary bar ─────────────────────────────────────────────── */
.summary-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}
.summary-bar__item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 130px;
}
.summary-bar__label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.summary-bar__value {
  font-size: 1.15rem;
  font-weight: 700;
  color: #111827;
}
.summary-bar__item--positive .summary-bar__value { color: #065f46; }
.summary-bar__item--negative .summary-bar__value { color: #991b1b; }

/* ── Detail table (show page) ────────────────────────────────── */
.detail-table { width: 100%; border-collapse: collapse; }
.detail-table th,
.detail-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
  font-size: 0.9rem;
  vertical-align: top;
}
.detail-table th {
  width: 160px;
  color: #6b7280;
  font-weight: 600;
}

/* ── Pill (docs complete indicator) ──────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
}
.pill--green { background: #d1fae5; color: #065f46; }
.pill--red   { background: #fee2e2; color: #991b1b; }
.pill--toggle { cursor: pointer; }
.pill--toggle:hover { filter: brightness(0.93); }

/* ── Bank transaction inline editing ────────────────────────── */
.btx-editable-cell {
  position: relative;
}
tr.btx-row--selected .btx-editable-cell {
  cursor: text;
  background: #bfdbfe;
}
tr.btx-row--selected:hover .btx-editable-cell::after {
  content: "✎";
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.7rem;
  color: #94a3b8;
  pointer-events: none;
}
.btx-editable-cell select,
.btx-notes-input {
  width: 100%;
  border: 1px solid #93c5fd;
  border-radius: 0.375rem;
  padding: 0.3rem 0.5rem;
  font-size: 0.875rem;
  background: #fff;
  outline: none;
  box-shadow: 0 0 0 2px #dbeafe;
}
.btx-notes-input { min-width: 200px; }

/* ── Accounts list ───────────────────────────────────────────── */
.acct-group {
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 0.25rem;
  margin-bottom: 0.25rem;
}
.acct-group:last-of-type { border-bottom: none; margin-bottom: 0; }

.acct-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.25rem;
  border-radius: 0.375rem;
}
.acct-row:hover { background: #f8fafc; }
.acct-row:hover .acct-row-actions { opacity: 1; }

.acct-row--parent { font-weight: 600; }
.acct-row--child  {
  padding-left: 1.5rem;
  font-weight: 400;
  color: #374151;
  display: grid;
  grid-template-columns: 140px 1fr auto;
  align-items: center;
  gap: 0.75rem;
}

.acct-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: text;
  padding: 0.2rem 0.3rem;
  border-radius: 0.25rem;
}
.acct-name--parent { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: #6b7280; }

.acct-name-input {
  padding: 0.2rem 0.4rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.375rem;
  font-size: inherit;
  font-weight: inherit;
  outline: none;
  background: #fff;
}
.acct-name-input:focus { border-color: #93c5fd; box-shadow: 0 0 0 2px #dbeafe; }
.acct-name-input--add  { min-width: 180px; }

.acct-type-select {
  font-size: 0.8rem;
  padding: 0.25rem 0.4rem;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: #fff;
  color: #374151;
  cursor: pointer;
  width: 100%;
}

.acct-row-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  opacity: 0;
  transition: opacity 0.1s;
}

.acct-delete-btn { color: #9ca3af; }
.acct-delete-btn:hover { color: #dc2626; background: #fef2f2; }

.acct-add-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.25rem 0.35rem 1.5rem;
}
.acct-add-row--group { padding-left: 0.25rem; }

.acct-add-group {
  padding-top: 0.75rem;
  margin-top: 0.5rem;
}

.acct-empty { color: #9ca3af; font-size: 0.875rem; padding: 0.5rem 0; }

/* ── Pagination ──────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1rem 0 1.5rem;
}
.pagination__info {
  font-size: 0.875rem;
  color: #6b7280;
}

/* ── Ghost button ────────────────────────────────────────────── */
.button--ghost {
  background: transparent;
  border-color: transparent;
  color: #6b7280;
}
.button--ghost:hover { background: #f3f4f6; color: #111827; }

/* ── Filter panel ─────────────────────────────────────────── */
.filter-panel {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ── Seed Samples ────────────────────────────────────────── */
.ss-summary {
  margin-top: 0.75rem;
  font-size: 0.875rem;
  color: #6b7280;
}

.ss-variety-link    { font-weight: 600; color: #1d4ed8; }
.ss-variety-code    { font-weight: 600; color: #374151; }
.ss-variety-name    { color: #6b7280; font-size: 0.92em; margin-left: 0.3rem; }
.ss-variety-segment { display: inline-block; margin-left: 0.4rem; font-size: 0.82em; background: #f3f4f6; color: #4b5563; border-radius: 999px; padding: 0.1em 0.6em; vertical-align: middle; }
.ss-variety-raw     { color: #374151; }
.ss-remarks         { color: #6b7280; font-size: 0.85em; max-width: 260px; }

.ss-row td                    { padding-top: 0.05rem; padding-bottom: 0.05rem; }
.ss-row__actions              { width: 1%; white-space: nowrap; padding-right: 0.5rem; }
.ss-row__actions .button      { opacity: 0; transition: opacity 0.15s; }
.ss-row:hover .ss-row__actions .button { opacity: 1; }
.ss-row                       { cursor: pointer; }

.detail-nav                   { display: flex; gap: 0.25rem; }
.detail-nav__disabled         { opacity: 0.3; pointer-events: none; }

.ss-edit-header               { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; }
.ss-edit-header__title        { font-size: 1.25rem; font-weight: 600; color: #111827; margin: 0; }

.ss-sample-form .panel        { padding: 0.75rem 1rem; }
.ss-sample-form .section      { margin-bottom: 0.6rem; }
.ss-sample-form .panel__title { margin-bottom: 0.5rem; }
.ss-sample-form .field-inline { gap: 0.5rem; }
.ss-sample-form textarea      { min-height: 60px; }

.ss-readonly-display {
  background: #f1f5f9 !important;
  color: #64748b !important;
  border-color: #e2e8f0 !important;
  cursor: default;
}

.ss-form-resolved {
  display: block;
  font-size: 0.82rem;
  color: #16a34a;
  font-weight: 500;
  margin-top: 0.15rem;
  min-height: 1em;
}

.ss-form-hint {
  font-size: 0.8rem;
  color: #94a3b8;
  margin: 0 0 0.6rem;
}

.ss-variety-row { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.ss-qty-field   { max-width: 140px; }

.ss-exp-pill {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #15803d;
  background: #dcfce7;
  border: 1px solid #86efac;
  border-radius: 999px;
  padding: 0.05em 0.55em;
  vertical-align: middle;
  margin-left: 0.35rem;
}

.ss-contact-raw, .ss-unlinked-variety { display: inline-flex; align-items: center; gap: 0.25rem; color: #6b7280; font-style: italic; }
.ss-contact-raw__icon         { width: 0.875rem; height: 0.875rem; color: #f59e0b; flex-shrink: 0; }

/* ── Tom Select overrides ───────────────────────────────────────────── */

.ts-wrapper.single .ts-control,
.ts-wrapper.single.input-active .ts-control {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 0.75rem;
  padding: 0.4rem 2rem 0.4rem 0.6rem;
  font-size: 1rem;
  color: #0f172a;
  box-shadow: none;
  cursor: pointer;
}

.ts-wrapper.single.focus .ts-control {
  border-color: #94a3b8;
  box-shadow: none;
  outline: none;
}

.ts-dropdown {
  border: 1px solid #cbd5e1;
  border-radius: 0.5rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  font-size: 0.95rem;
}

.ts-dropdown .option { padding: 0.4rem 0.7rem; color: #0f172a; }
.ts-dropdown .option:hover,
.ts-dropdown .option.active { background: #f1f5f9; color: #0f172a; }

.ts-wrapper .ts-control input { font-size: 1rem; }

/* Tom Select's JS is pinned to esm.sh, which bundles its stylesheet and
   injects it as a <style> tag at runtime — landing after our stylesheet in
   <head>, so plain .theme-dark rules lose. body.theme-dark raises specificity
   above the injected CSS without needing !important. */
body.theme-dark .ts-wrapper.single .ts-control,
body.theme-dark .ts-wrapper.single.input-active .ts-control {
  background: var(--dk-chip);
  border-color: var(--dk-border-ctl);
  color: var(--dk-text);
}
body.theme-dark .ts-wrapper.single.focus .ts-control {
  border-color: rgba(127, 196, 245, .45);
}
body.theme-dark .ts-control input { color: var(--dk-text); }
body.theme-dark .ts-control input::placeholder { color: rgba(231, 236, 242, .35); }
body.theme-dark .ts-wrapper.single .ts-control .item { color: var(--dk-text); }

body.theme-dark .ts-dropdown,
body.theme-dark .ts-dropdown.single {
  background: var(--dk-menu);
  border-color: var(--dk-border-ctl);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
  color: var(--dk-text);
}
body.theme-dark .ts-dropdown .option,
body.theme-dark .ts-dropdown .ts-dropdown-content .option {
  background: var(--dk-menu);
  color: var(--dk-text);
}
body.theme-dark .ts-dropdown .option:hover,
body.theme-dark .ts-dropdown .option.active {
  background: rgba(127, 196, 245, .16);
  color: var(--dk-text);
}
body.theme-dark .ts-dropdown .no-results,
body.theme-dark .ts-dropdown .optgroup-header {
  background: var(--dk-menu);
  color: var(--dk-text-sec);
}
body.theme-dark .ts-wrapper.single .ts-control:after { border-top-color: var(--dk-text-sec); }

.ts-variety-item { display: flex; align-items: baseline; gap: 0.5rem; white-space: nowrap; overflow: hidden; }
.ts-variety-item__code { font-weight: 600; flex-shrink: 0; }
.ts-variety-item__name { color: #6b7280; font-size: 0.85em; overflow: hidden; text-overflow: ellipsis; }

/* ── Profit & Loss ──────────────────────────────────────────────────── */
.pl-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.pl-label-col { width: 220px; }
.pl-year-col  { min-width: 110px; }

.pl-section-header td {
  padding: 1rem 0.5rem 0.25rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6b7280;
  border-top: 1px solid #e5e7eb;
}
.pl-section-header:first-child td { border-top: none; }

.pl-row td {
  padding: 0.3rem 0.5rem;
  color: #374151;
}
.pl-account { padding-left: 1.25rem !important; }

.pl-subtotal td {
  padding: 0.35rem 0.5rem;
  font-weight: 600;
  color: #111827;
  border-top: 1px solid #d1d5db;
}

.pl-total td {
  padding: 0.5rem 0.5rem;
  font-weight: 700;
  font-size: 0.9rem;
  border-top: 2px solid #374151;
  border-bottom: 2px solid #374151;
  color: #111827;
}

.pl-total--net td {
  font-size: 1rem;
  background: #f8fafc;
  border-top: 2px solid #374151;
  border-bottom: 3px double #374151;
}

.pl-negative { color: #dc2626; }
.pl-section-header--capital td { border-top: 3px double #374151; padding-top: 1.25rem; color: #9ca3af; }

/* ── Invoice Lines normalisation table ───────────────────────────── */
/* width:auto, not the global 100%: at 100% the browser squeezes columns below
   their min-width to make the table fit, which clipped the seed lot text.
   Sizing to content lets .table-wrapper scroll instead on a narrow screen. */
.ilines-table { width: auto; min-width: 100%; }
.ilines-table td { padding: 0.2rem 0.3rem; vertical-align: middle; }
.ilines-table th, .ilines-table td { white-space: nowrap; }
.ilines-cell--inv  { white-space: nowrap; font-size: 0.85rem; }
/* The description repeats the code/name/lot that now have their own columns,
   so it gives up its width first. Full text stays available on hover. */
.ilines-cell--desc {
  color: #475569;
  font-size: 0.85rem;
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ilines-cell--contact { color: #475569; font-size: 0.85rem; white-space: nowrap; }
.ilines-cell--type { color: #9ca3af; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
/* Matches the app's standard field (1px #cbd5e1, 0.75rem radius, #f8fafc)
   with the padding tightened for table row density. */
/* Matches the app's standard field (1px #cbd5e1, 0.75rem radius, #f8fafc)
   with padding tightened for table row density. Explicit height and
   box-sizing so inputs and selects are identical — a select is otherwise
   sized by the browser and ends up a couple of pixels taller. */
.ilines-input {
  width: 100%;
  height: 2rem;
  box-sizing: border-box;
  border: 1px solid #cbd5e1;
  border-radius: 0.75rem;
  padding: 0 0.6rem;
  font-size: 0.85rem;
  line-height: 1.4;
  font-family: inherit;
  background-color: #f8fafc;
  color: #0f172a;
  transition: border-color 0.15s, background-color 0.15s;
}
.ilines-input:focus {
  outline: none;
  border-color: #93c5fd;
  background-color: #fff;
}
/* Widths are sized from the data: seed lot and segment fit their longest
   value (12 and 14 chars), code is exactly 6 everywhere. Crop fits "cucumber"
   (847 of 949 rows) rather than the 29 "Blocky Pepper" outliers, which scroll
   within the field on focus. */
/* Text width plus the field's own padding. Seed lot carries the longest
   values (12 chars, "KKCP-5288-01") so it gets the most room; code is a
   fixed 6 chars and crop fits "cucumber". */
.ilines-input--wide  { min-width: 104px; }
.ilines-input--code  { min-width: 50px;  }
.ilines-input--crop  { min-width: 74px;  }
.ilines-input--seg   { min-width: 112px; }
.ilines-input--lot   { min-width: 132px; }
.ilines-input--type  { min-width: 104px; }
.ilines-input--cat   { min-width: 114px; }
/* Selects inherit .ilines-input; drop the native chrome so they match the text
   inputs exactly, then draw our own arrow. */
select.ilines-input {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  /* Same left padding as the inputs; only the right side grows for the arrow. */
  padding-left: 0.6rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath fill='%239ca3af' d='M0 0h10L5 6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.55rem center;
  background-size: 8px 5px;
  padding-right: 1.5rem;
}
/* Placeholder spans on non-variety rows: they hold the column open so those
   rows line up with variety rows, but stay invisible and inert. */
/* Invisible, but the same box as a real field so the column keeps its width
   and the row keeps its height. */
.ilines-cell--blank .ilines-input {
  display: block;
  border-color: transparent;
  background-color: transparent;
}
/* Variety inputs switched off because the line is a plain charge line — no
   box, matching the blank placeholder cells on server-rendered charge rows. */
.ilines-input--off {
  cursor: not-allowed;
  background-color: transparent !important;
  border-color: transparent !important;
}
.theme-dark select.ilines-input option { background: var(--dk-menu); color: var(--dk-text); }
.ilines-input--saved  { border-color: #22c55e !important; background-color: #f0fdf4 !important; }
.ilines-input--error  { border-color: #ef4444 !important; background-color: #fef2f2 !important; }

/* Remove number input spinners globally */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }

/* ── Contact address label ───────────────── */
.contact-label-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1.25rem;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.contact-label-wrap {
  display: flex;
  justify-content: center;
  padding: 2.5rem 1rem;
}

.contact-label {
  width: 66%;
  border: 1.5px solid #374151;
  border-radius: 6px;
  overflow: hidden;
  font-family: "Noto Sans Thai", "Roboto", sans-serif;
  font-size: 13px;
  background: #fff;
}

.contact-label__from {
  padding: 1.5rem 1.25rem 1.25rem;
  border-bottom: 1.5px solid #374151;
  background: #f8fafc;
  line-height: 1.7;
  font-size: 15px;
  font-weight: 400;
  color: #111827;
}

.contact-label__from-tag {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280;
  margin-bottom: 0.5rem;
}

.contact-label__from-company {
  font-size: 18px;
  font-weight: 400;
  color: #111827;
  line-height: 1.3;
  margin-bottom: 0.1rem;
}

.contact-label__to {
  padding: 1.5rem 1.25rem 2rem;
  line-height: 1.7;
  font-size: 15px;
  font-weight: 400;
  color: #111827;
}

.contact-label__to-tag {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280;
  margin-bottom: 0.5rem;
}

.contact-label__to-company {
  font-size: 18px;
  font-weight: 400;
  color: #111827;
  line-height: 1.3;
  margin-bottom: 0.1rem;
}

.contact-label__to-person {
  font-size: 15px;
  font-weight: 400;
  color: #111827;
  margin-bottom: 0.1rem;
}

.contact-label__to-phone {
  margin-top: 0.5rem;
  font-size: 14px;
  font-weight: 400;
  color: #111827;
}

@media print {
  .contact-label-bar { display: none !important; }
  .contact-label-wrap { padding: 0; }
  .contact-label {
    width: 66%;
    border-radius: 0;
    border-color: #000;
    box-shadow: none;
  }
  .contact-label__from { border-bottom-color: #000; background: #fff !important; }
}

/* ── Seed samples list print ─────────────── */
@media print {
  .ss-print-btn,
  .filter-panel,
  .pagination,
  .page-header .button { display: none !important; }
  .ss-summary { margin-top: 0.5rem; }
}

/* ── Shipment print bar ───────────────────── */
.ss-print-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  max-width: 860px;
  margin: 0 auto 1.5rem;
  padding: 0.75rem 1rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
}
.ss-print-bar__info {
  font-size: 0.85rem;
  color: #6b7280;
  margin-left: 0.5rem;
}

/* ── Shipment paper ───────────────────────── */
.ss-shipment-wrap {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 1rem 3rem;
}

.ss-paper {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  padding: 2.5rem 3rem;
  font-size: 0.88rem;
  color: #111827;
  line-height: 1.5;
}

.ss-paper__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 2px solid #111827;
}
.ss-paper__seller-name {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 0.2rem;
}
.ss-paper__seller { color: #374151; line-height: 1.6; }
.ss-paper__logo   { height: 96px; object-fit: contain; }

.ss-paper__info-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2rem;
  gap: 2rem;
}

.ss-paper__title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  margin-bottom: 0.75rem;
}
.ss-paper__meta { border-collapse: collapse; }
.ss-paper__meta td { padding: 0.1rem 0.75rem 0.1rem 0; }
.ss-paper__meta-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9ca3af;
  white-space: nowrap;
}

.ss-paper__recipient-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9ca3af;
  margin-bottom: 0.3rem;
}
.ss-paper__recipient { line-height: 1.6; }

.ss-paper__lines {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 2.5rem;
  font-size: 0.85rem;
}
.ss-paper__lines th {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280;
  border-bottom: 1px solid #d1d5db;
  padding: 0.4rem 0.5rem;
  text-align: left;
}
.ss-paper__lines td {
  padding: 0.5rem 0.5rem;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: top;
}
.ss-paper__lines tbody tr:last-child td { border-bottom: none; }
.ss-paper__line-num { color: #9ca3af; width: 1.5rem; }

.ss-paper__footer {
  display: flex;
  justify-content: flex-end;
  padding-top: 1.5rem;
  border-top: 1px solid #e5e7eb;
}
.ss-paper__sig { text-align: center; font-size: 0.8rem; color: #6b7280; }
.ss-paper__sig-line {
  width: 180px;
  border-bottom: 1px solid #374151;
  margin-bottom: 0.4rem;
  height: 2rem;
}

/* ── Shipment print media ─────────────────── */
@media print {
  .ss-print-bar    { display: none !important; }
  .ss-shipment-wrap { max-width: none; padding: 0; }
  .ss-paper {
    border: none;
    border-radius: 0;
    padding: 0;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
  .ss-paper__header { border-bottom-color: #000; }
  .ss-variety-segment {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
}

/* ── CSV import tooltip ──────────────────── */
.csv-import-wrap {
  position: relative;
  display: inline-block;
}

.csv-import-tooltip {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: #1e293b;
  color: #e2e8f0;
  border-radius: 6px;
  padding: 0.65rem 0.85rem;
  font-size: 12px;
  line-height: 1.7;
  white-space: nowrap;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

.csv-import-tooltip code {
  font-family: monospace;
  color: #7dd3fc;
}

.csv-import-wrap:hover .csv-import-tooltip {
  display: block;
}

/* All dark-theme styling is screen-only: printing always uses the light styles. */
@media screen {
/* ── Dark theme tokens (design handoff: dark dashboard) ──────────────
   Scoped to body.theme-dark. Set the class on more pages (or the layout)
   to roll dark mode out app-wide on desktop. */
body.theme-dark {
  --dk-canvas: #0b0e12;
  --dk-card-hi: #141821;
  --dk-card-lo: #0f131a;
  --dk-card-flat: #12161d;
  --dk-menu: #161b25;
  --dk-chip: #1a2028;
  --dk-border-card: rgba(255, 255, 255, .07);
  --dk-border-div: rgba(255, 255, 255, .06);
  --dk-border-row: rgba(255, 255, 255, .05);
  --dk-border-ctl: rgba(255, 255, 255, .1);
  --dk-text: #e7ecf2;
  --dk-text-num: #f2f6fa;
  --dk-text-title: #f2f6fa;
  --dk-text-sec: rgba(231, 236, 242, .55);
  --dk-text-mut: rgba(231, 236, 242, .45);
  --dk-text-faint: rgba(231, 236, 242, .35);
  --dk-accent: #7fc4f5;
  --dk-accent-hover: #a9d9fa;
  --dk-neg: #ff8b7a;
  --dk-font-ui: "Instrument Sans", system-ui, sans-serif;
  --dk-font-mono: "IBM Plex Mono", ui-monospace, monospace;
  background: var(--dk-canvas);
  color: var(--dk-text);
  font-family: var(--dk-font-ui);
  color-scheme: dark;
}

.theme-dark ::selection { background: rgba(127, 196, 245, .28); }

/* Topbar restyle (only when the dark theme is active) */
.theme-dark .topbar {
  background: rgba(11, 14, 18, .86);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--dk-border-card);
}
.theme-dark .topbar__logo { color: var(--dk-text); }
.theme-dark .topbar__link {
  color: rgba(231, 236, 242, .62);
  font-size: 14.5px;
  font-weight: 500;
  transition: background .13s ease, color .13s ease;
}
.theme-dark .topbar__link:hover { background: rgba(255, 255, 255, .06); color: var(--dk-text); }
.theme-dark .topbar__link--active,
.theme-dark .topbar__link--active:hover { background: var(--dk-accent); color: var(--dk-canvas); font-weight: 600; }
.theme-dark .topbar__link--basket { font-weight: 500; color: rgba(231, 236, 242, .62); }
.theme-dark .topbar__link--basket:hover { background: rgba(255, 255, 255, .06); color: var(--dk-text); }
.theme-dark .topbar__link--basket.topbar__link--active,
.theme-dark .topbar__link--basket.topbar__link--active:hover { background: var(--dk-accent); color: var(--dk-canvas); font-weight: 600; }
.theme-dark .topbar__submenu {
  background: var(--dk-menu);
  border-color: rgba(255, 255, 255, .12);
  box-shadow: 0 18px 40px rgba(0, 0, 0, .55);
}
.theme-dark .topbar__submenu-link { color: rgba(231, 236, 242, .78); }
.theme-dark .topbar__submenu-link:hover,
.theme-dark .topbar__submenu-link--active { background: rgba(255, 255, 255, .06); color: var(--dk-text); }
.theme-dark .topbar__user-name { color: rgba(231, 236, 242, .75); }
.theme-dark .button--ghost { background: transparent; color: rgba(231, 236, 242, .8); border-color: var(--dk-border-ctl); }
.theme-dark .flash { background: var(--dk-menu); color: var(--dk-text); border: 1px solid var(--dk-border-ctl); }

/* ── Left sidebar nav (dark pages, desktop) ──────────────────────────
   The shared topbar markup is re-laid-out as a fixed left column, so
   pages adopt the sidebar simply by setting the theme-dark body class. */
@media (min-width: 768px) {
  body.theme-dark { display: flex; align-items: stretch; }

  .theme-dark .topbar--desktop {
    position: sticky;
    top: 0;
    flex: none;
    width: 224px;
    height: 100vh;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 18px;
    padding: 18px 14px 14px;
    overflow: visible; /* submenu flyouts must escape the sidebar */
    border-bottom: none;
    border-right: 1px solid var(--dk-border-card);
    background: var(--dk-card-lo);
    backdrop-filter: none;
  }

  .theme-dark .topbar__logo { gap: 0.6rem; }
  .theme-dark .topbar__logo-img { height: 42px; }
  .theme-dark .topbar__logo > span {
    font-size: 15.5px;
    line-height: 1.35;
    white-space: normal;
    color: var(--dk-text);
  }

  .theme-dark .topbar__nav {
    flex: 1;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    min-height: 0;
  }
  .theme-dark .topbar__nav > .topbar__link { display: block; padding: 8px 12px; }
  /* Manage sits at the bottom of the nav, just above the user block;
     its flyout opens upward so it never clips the viewport bottom */
  .theme-dark .topbar__dropdown--bottom { margin-top: auto; }
  .theme-dark .topbar__dropdown--bottom .topbar__submenu { top: auto; bottom: 0; }

  /* Dropdown groups: label is a normal sidebar item with a caret; the
     submenu stays hidden and flies out to the right on hover (the base
     .topbar__dropdown:hover rules handle the show/hide + grace period). */
  .theme-dark .topbar__dropdown > .topbar__link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
  }
  .theme-dark .topbar__dropdown > .topbar__link::after {
    content: "▸";
    font-size: 10px;
    color: rgba(231, 236, 242, .4);
  }
  .theme-dark .topbar__dropdown > .topbar__link--active::after { color: inherit; }
  .theme-dark .topbar__submenu {
    top: 0;
    left: 100%;
    margin-left: -110px; /* overlap the sidebar so the flyout opens over the labels */
    min-width: 190px;
    padding: 6px;
    border-radius: 11px;
    background: var(--dk-menu);
    border: 1px solid rgba(255, 255, 255, .12);
    box-shadow: 0 18px 40px rgba(0, 0, 0, .55);
    z-index: 30;
  }
  .theme-dark .topbar__submenu-link { padding: 8px 10px; font-size: 14px; border-radius: 8px; }
  .theme-dark .topbar__submenu-link--active,
  .theme-dark .topbar__submenu-link--active:hover { background: var(--dk-accent); color: var(--dk-canvas); font-weight: 600; }


  .theme-dark .topbar__user {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--dk-border-div);
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .theme-dark .app-shell { flex: 1; min-width: 0; }
}

/* Dark pages: full-width content (pages keep their own inner max-width) */
.theme-dark .app-shell { max-width: none; }
/* Dashboard only: edge-to-edge, the dash grid brings its own padding */
.theme-dark--full .app-shell { padding: 0; }

/* ── Dark theme: shared components ───────────────────────────────────
   Generic sweep so content pages (invoices, invoice lines, reports…)
   only need the theme-dark body class to render correctly. */
.theme-dark a { color: var(--dk-accent); }
.theme-dark a:hover { color: var(--dk-accent-hover); }

.theme-dark .panel {
  background: var(--dk-card-flat);
  border-color: var(--dk-border-card);
  box-shadow: none;
}
.theme-dark .panel--sticky { top: 12px; }
.theme-dark .page-header p { color: var(--dk-text-sec); }

.theme-dark table { background: transparent; }
/* Panel headings are a dark slate for light pages; on the dark canvas they
   were nearly invisible. */
.theme-dark .panel__title { color: var(--dk-text); }

.theme-dark thead { background: rgba(255, 255, 255, .03); }
.theme-dark thead th {
  font: 500 10.5px var(--dk-font-mono);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(231, 236, 242, .75);
  border-bottom-color: var(--dk-border-div);
}
.theme-dark tbody td { border-bottom-color: var(--dk-border-row); }
.theme-dark tbody tr:hover td { background: rgba(255, 255, 255, .025); }
.theme-dark .table__label { color: var(--dk-text-sec); }
.theme-dark .table-group-header td {
  background: rgba(255, 255, 255, .04);
  color: var(--dk-text-sec);
  border-top-color: var(--dk-border-div);
}

.theme-dark input[type="text"],
.theme-dark input[type="number"],
.theme-dark input[type="date"],
.theme-dark input[type="email"],
.theme-dark input[type="tel"],
.theme-dark input[type="url"],
.theme-dark textarea,
.theme-dark select {
  background-color: var(--dk-chip);
  border: 1px solid var(--dk-border-ctl);
  color: var(--dk-text);
}
.theme-dark input:focus,
.theme-dark textarea:focus,
.theme-dark select:focus {
  border-color: rgba(127, 196, 245, .45);
  outline: none;
}
.theme-dark option { background-color: var(--dk-menu); color: var(--dk-text); }
.theme-dark input::placeholder { color: rgba(231, 236, 242, .35); }
.theme-dark label { color: var(--dk-text-sec); }
.theme-dark .search-bar__checkbox-label { color: var(--dk-text-sec); }
.theme-dark .search-bar__clear:hover { color: var(--dk-text); }
.theme-dark .filter-bar__label { color: var(--dk-text-mut); }

.theme-dark .button--secondary {
  background: var(--dk-chip);
  color: var(--dk-text);
  border-color: var(--dk-border-ctl);
}
.theme-dark .button--primary {
  background: var(--dk-accent);
  color: var(--dk-canvas);
  border-color: transparent;
  font-weight: 600;
}
.theme-dark .button--danger { background: transparent; color: var(--dk-neg); border-color: rgba(255, 139, 122, .4); }

.theme-dark .pill--green { background: rgba(34, 197, 94, .18); color: #7ee2a8; }
.theme-dark .pill--red   { background: rgba(255, 139, 122, .16); color: var(--dk-neg); }
.theme-dark .pagination__info { color: var(--dk-text-mut); }

/* Invoices list */
.inv-list-title-row { display: flex; align-items: center; gap: 14px; }
.inv-list-header { align-items: flex-end; }
.inv-list-hero { text-align: right; }
.inv-list-hero__label {
  font: 500 11px var(--dk-font-mono, ui-monospace);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #6b7280;
}
.inv-list-hero__amount { font: 600 24px var(--dk-font-mono, ui-monospace); letter-spacing: -.02em; }
.theme-dark .inv-list-hero__label { color: var(--dk-text-mut); }
.theme-dark .inv-list-hero__amount { color: var(--dk-text-num); }

.theme-dark .page-header__title { font: 700 30px/1.1 var(--dk-font-ui); letter-spacing: -.025em; }

/* Filter row sits directly on the canvas (no panel box) */
.theme-dark .inv-list-filters {
  background: var(--dk-canvas);
  border: none;
  box-shadow: none;
  border-radius: 0;
  padding: 0.25rem 0 0.75rem;
  top: 0;
}
.theme-dark .search-bar__input-wrap { max-width: 420px; }
.theme-dark .search-bar__input {
  height: 40px;
  border-radius: 10px;
  background-color: var(--dk-card-hi);
  border-color: var(--dk-border-ctl);
}
.theme-dark .search-bar__input:focus { border-color: rgba(127, 196, 245, .45); }
.theme-dark .search-bar__icon { color: rgba(231, 236, 242, .35); }
.theme-dark .search-bar__checkbox-label {
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--dk-border-ctl);
  border-radius: 10px;
  background: var(--dk-card-hi);
  font-size: 13px;
  font-weight: 600;
  color: var(--dk-text);
  transition: border-color .13s ease;
}
.theme-dark .search-bar__checkbox-label:hover { border-color: rgba(127, 196, 245, .45); }
.theme-dark .search-bar__checkbox-label input { accent-color: var(--dk-accent); }
.theme-dark .inv-list-filters .button { height: 40px; border-radius: 10px; }

.theme-dark .inv-list-thb-est { color: var(--dk-text-num); }
.theme-dark .inv-list-foreign-amount { color: var(--dk-text-mut); }
.theme-dark .inv-list-total__label { color: var(--dk-text-mut); }
.theme-dark .inv-list-total__amount { color: var(--dk-text-num); font-family: var(--dk-font-mono); }
.theme-dark .inv-list-cell--editable:hover { background: rgba(255, 255, 255, .05); }
.theme-dark .inv-list-category-select { color: var(--dk-text); }
.theme-dark .inv-list-category-select:hover { border-color: var(--dk-border-ctl); }
.theme-dark .inv-list-category-select option { background: var(--dk-menu); color: var(--dk-text); }

/* Invoice Lines normalisation table */
.theme-dark .ilines-cell--desc,
.theme-dark .ilines-cell--contact { color: var(--dk-text-sec); }
.theme-dark .ilines-cell--type { color: var(--dk-text-faint); }
/* Every editable cell — text input and select alike — carries the same box, so
   the selects read as editable rather than as plain text. */
/* Same tokens as the app-wide dark field style, so these match every other
   input on the page. background-color, not the shorthand — the selects' arrow
   lives in background-image and the shorthand would erase it. */
.theme-dark .ilines-input {
  background-color: var(--dk-chip);
  border-color: var(--dk-border-ctl);
  color: var(--dk-text);
}
.theme-dark .ilines-input:focus { background-color: var(--dk-menu); border-color: rgba(127, 196, 245, .45); }
/* Placeholder cells on charge lines stay empty — no box to imply editability. */
.theme-dark .ilines-cell--blank .ilines-input { background-color: transparent; border-color: transparent; }
.theme-dark .ilines-input--saved { background-color: rgba(34, 197, 94, .15) !important; border-color: rgba(34, 197, 94, .5) !important; }
.theme-dark .ilines-input--error { background-color: rgba(239, 68, 68, .18) !important; border-color: rgba(239, 68, 68, .55) !important; }

/* Top Customers: slightly larger type than the default report table */
.tc-table { font-size: 0.95rem; }
.tc-table .pl-row td { padding: 0.42rem 0.5rem; }

/* Report tables (pl-table based pages, e.g. Top Customers) */
.theme-dark .pl-row td { color: var(--dk-text); }
.theme-dark .pl-section-header td { color: var(--dk-text-mut); border-top-color: var(--dk-border-div); }
.report-total-row { font-weight: 600; background: #f1f5f9; }
.report-total-row td { border-top: 2px solid #cbd5e1; }
.theme-dark .report-total-row { background: rgba(127, 196, 245, .09); }
.theme-dark .report-total-row td { border-top-color: rgba(127, 196, 245, .2); color: var(--dk-accent); }

.dash { display: flex; flex-direction: column; }

.dash-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 20px 24px 0;
}
.dash-eyebrow {
  font: 500 11px var(--dk-font-mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: rgba(127, 196, 245, .7);
}
.dash-title-row { display: flex; align-items: center; gap: 14px; margin-top: 10px; }
.dash-title { margin: 0; font: 700 30px/1.1 var(--dk-font-ui); letter-spacing: -.025em; }
.dash-subtitle {
  margin: 10px 0 0;
  font-size: 13.5px;
  line-height: 1.4;
  color: var(--dk-text-sec);
  max-width: 560px;
}
.dash-inline-form { display: inline-flex; }

.dash-year-select {
  appearance: none;
  -webkit-appearance: none;
  padding: 8px 32px 8px 13px;
  border-radius: 10px;
  background-color: var(--dk-card-hi);
  border: 1px solid var(--dk-border-ctl);
  color: var(--dk-text);
  font: 600 13.5px var(--dk-font-mono);
  cursor: pointer;
  transition: border-color .13s ease;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23e7ecf2' fill-opacity='.45'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.dash-year-select:hover { border-color: rgba(127, 196, 245, .45); }

/* Panel grid: 4 columns on a big desktop, degrading below */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 372px));
  gap: 14px;
  padding: 14px 24px 22px;
}
@media (max-width: 1599px) { .dash-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 1199px) { .dash-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px)  { .dash-grid { grid-template-columns: 1fr; } }

/* Two rows of four whenever the window is wide enough, regardless of height.
   On a short screen (e.g. 1600x900) the second row simply scrolls into view,
   which beats collapsing the grid and pushing those panels off the page. */
@media (min-width: 1600px) {
  /* Each row is as tall as its tallest panel, and every panel in that row
     stretches to match — so the four tops and bottoms line up. A cap keeps a
     long list from making one row dominate; it scrolls inside instead. */
  .dash-grid { grid-template-rows: auto auto; align-items: stretch; }
  .dash-panel { height: 100%; max-height: 440px; }
}

/* Single-screen mode: on a display tall enough to hold both rows, lock the
   page to the viewport so long tables scroll inside their own panel instead
   of scrolling the whole dashboard. */
@media (min-width: 1600px) and (min-height: 800px) {
  /* body is already a flex row (sidebar + content) from the sidebar block */
  body.theme-dark--full { height: 100vh; overflow: hidden; }
  .theme-dark--full .app-shell { min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
  .theme-dark .dash { flex: 1; min-height: 0; }
  .dash-grid { flex: 1; min-height: 0; grid-template-rows: 1fr 1fr; }
  /* Cancels the height cap set for short screens above, so the panels stretch
     to fill the viewport again. */
  .dash-panel { min-height: 0; height: auto; max-height: none; }
}

/* Panel anatomy */
.dash-panel {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--dk-border-card);
  border-radius: 16px;
  overflow: hidden;
  min-height: 260px;
}
.dash-panel--gradient { background: linear-gradient(180deg, var(--dk-card-hi), var(--dk-card-lo)); }
.dash-panel--flat { background: var(--dk-card-flat); }

.dash-panel__head { padding: 13px 18px 11px; border-bottom: 1px solid var(--dk-border-div); }
.dash-panel__head--split { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.dash-panel__title {
  font: 600 11.5px var(--dk-font-mono);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--dk-text-title);
}
.dash-hero-row { display: flex; align-items: flex-end; gap: 10px; margin-top: 6px; }
.dash-hero { font: 600 24px var(--dk-font-mono); letter-spacing: -.02em; color: var(--dk-text-num); }
.dash-hero--alert { color: var(--dk-neg); }
.dash-panel__caption { margin-top: 3px; font-size: 12.5px; color: var(--dk-text-mut); }

.dash-delta {
  font: 600 11.5px var(--dk-font-mono);
  border-radius: 6px;
  padding: 3px 7px;
  margin-bottom: 4px;
  white-space: nowrap;
}
.dash-delta--bad  { color: var(--dk-neg); background: rgba(255, 139, 122, .13); }
.dash-delta--good { color: var(--dk-accent); background: rgba(127, 196, 245, .13); }

.dash-bars { display: inline-flex; align-items: flex-end; gap: 4px; height: 44px; margin-left: auto; }
.dash-bars i { width: 16px; border-radius: 4px; display: block; }
.dash-bars__prev { background: rgba(255, 255, 255, .12); }
.dash-bars__cur  { background: var(--dk-accent); }

.dash-panel__body { flex: 1; min-height: 0; overflow: auto; padding: 2px 9px 4px; }

.dash-row {
  display: grid;
  gap: 8px;
  align-items: baseline;
  padding: 6px 10px;
  border-radius: 8px;
  border-top: 1px solid var(--dk-border-row);
  grid-template-columns: 1fr 110px;
  transition: background .13s ease;
}
.dash-row:hover { background: rgba(255, 255, 255, .035); }
.dash-row--3col { grid-template-columns: 1fr 92px 92px; }
.dash-row--2col { grid-template-columns: 1fr 96px; }
.dash-row--rank { grid-template-columns: 26px 1fr 36px 92px; }
.dash-row--ar   { grid-template-columns: 1fr 36px 100px; }
.dash-row--prod { grid-template-columns: 1fr 44px 70px; }
.dash-row--inv  { grid-template-columns: 1fr 70px 90px; }
.dash-row--head {
  border-top: none;
  font: 500 10px var(--dk-font-mono);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(231, 236, 242, .4);
}
.dash-row--head:hover { background: transparent; }
.dash-row:first-of-type + .dash-row { border-top: none; }

.dash-num-col { text-align: right; }
.dash-label { font: 500 13px var(--dk-font-ui); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-qualifier { font: 400 11.5px var(--dk-font-mono); color: rgba(231, 236, 242, .4); margin-left: 4px; }
.dash-num {
  font: 500 13px var(--dk-font-mono);
  text-align: right;
  color: var(--dk-text-num);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.dash-num--prev   { font-weight: 400; color: var(--dk-text-mut); }
.dash-num--accent { color: var(--dk-accent); }
.dash-num--faint  { font-weight: 400; color: rgba(231, 236, 242, .32); }
.dash-rank { font: 600 12px var(--dk-font-mono); color: var(--dk-text-mut); }
.dash-rank--top { color: var(--dk-accent); }

.dash-row--total {
  background: rgba(127, 196, 245, .09);
  border-top: 1px solid rgba(127, 196, 245, .2);
  margin-top: 4px;
  padding: 7px 10px;
}
.dash-row--total:hover { background: rgba(127, 196, 245, .09); }
.dash-row--total .dash-label { font-weight: 600; font-size: 13.5px; }
.dash-row--total .dash-num { font-weight: 600; color: var(--dk-accent); }
.dash-empty { color: var(--dk-text-faint); font-size: 13px; }

.dash-panel__foot { margin-top: auto; padding: 9px 18px 11px; border-top: 1px solid var(--dk-border-div); }
.dash-panel__foot a { font: 600 13px var(--dk-font-ui); color: var(--dk-accent); transition: color .13s ease; }
.dash-panel__foot a:hover { color: var(--dk-accent-hover); }
.dash-link { color: var(--dk-text); }
.dash-link:hover { color: var(--dk-accent-hover); }

.dash-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  height: 32px;
  border-radius: 9px;
  background: var(--dk-chip);
  border: 1px solid rgba(255, 255, 255, .09);
  transition: border-color .13s ease;
}
.dash-chip:hover,
.dash-chip:focus-within { border-color: rgba(127, 196, 245, .45); }
.dash-chip__dot { width: 8px; height: 8px; border-radius: 50%; display: block; flex: none; }
.dash-chip__label { font: 600 12.5px var(--dk-font-ui); color: var(--dk-text); white-space: nowrap; }
.dash-chip__caret { font-size: 10px; color: rgba(231, 236, 242, .4); }
/* The real select sits invisibly on top of the chip, so the whole chip is
   clickable and the native popup anchors to it. */
.dash-chip__select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  border: none;
  cursor: pointer;
  color-scheme: dark;
}

/* Native popup lists follow the page's light theme by default — force the
   dark palette on the options of every dashboard select. */
.dash-year-select { color-scheme: dark; }
.dash-year-select option,
.dash-chip__select option {
  background-color: var(--dk-menu);
  color: var(--dk-text);
  font-family: var(--dk-font-ui);
}

/* ── Invoice detail: dark chrome around a light printable paper ────── */
.theme-dark .inv-close-btn { background: var(--dk-chip); color: var(--dk-text-sec); }
.theme-dark .inv-close-btn:hover { background: rgba(255, 255, 255, .12); color: var(--dk-text); }
.theme-dark .inv-sync-warning {
  background: rgba(252, 211, 77, .1);
  border-color: rgba(252, 211, 77, .35);
  color: #fcd34d;
}
/* The column itself is transparent in dark mode; each card carries the panel. */
.theme-dark .invoice-sidebar {
  background: transparent;
  border: none;
  box-shadow: none;
}
/* Lighter than the flat card token and with a stronger edge — against the
   #0b0e12 canvas the flat tone was nearly invisible as a separate panel. */
.theme-dark .inv-sidebar-card {
  background: #1a1f29;
  border-color: rgba(255, 255, 255, .12);
  box-shadow: none;
}
.theme-dark .inv-sidebar-section { border-bottom-color: rgba(255, 255, 255, .08); }
.theme-dark .inv-sidebar-label { color: var(--dk-text-mut); }
.theme-dark .inv-sidebar-value { color: var(--dk-text); }
.theme-dark .inv-sidebar-value--total { color: #7ee2a8; }
.theme-dark .inv-paid-pill { color: #7ee2a8; border-color: rgba(34, 197, 94, .5); }
.theme-dark .inv-editable:hover { background: rgba(255, 255, 255, .06); }

/* The paper itself stays a light document — reverse the generic dark
   sweep inside it so on-screen matches what prints. */
.theme-dark .invoice-paper {
  color-scheme: light;
  /* softer than pure white against the dark canvas; print stays #fff */
  background: #e9edf2;
  border-color: rgba(255, 255, 255, .12);
  /* the paper is a light island — don't inherit the dark theme's light text */
  color: #0f172a;
}
.theme-dark .invoice-paper a { color: #1d4ed8; }
.theme-dark .invoice-paper input[type="text"],
.theme-dark .invoice-paper input[type="number"],
.theme-dark .invoice-paper input[type="date"],
.theme-dark .invoice-paper textarea {
  background-color: transparent;
  border-color: transparent;
  color: #0f172a;
}
.theme-dark .invoice-paper select {
  background-color: #f8fafc;
  border-color: #e2e8f0;
  color: #0f172a;
}
.theme-dark .invoice-paper input:hover,
.theme-dark .invoice-paper textarea:hover { border-color: #e2e8f0; background-color: #f8fafc; }
.theme-dark .invoice-paper input:focus,
.theme-dark .invoice-paper textarea:focus,
.theme-dark .invoice-paper select:focus { border-color: #94a3b8; background-color: #fff; }
.theme-dark .invoice-paper input::placeholder { color: #94a3b8; }
.theme-dark .invoice-paper option { background-color: #fff; color: #0f172a; }
.theme-dark .invoice-paper th {
  font: inherit;
  text-transform: none;
  letter-spacing: normal;
  color: inherit;
  border-bottom-color: #e2e8f0;
}
.theme-dark .invoice-paper .invoice-lines-table thead th {
  font-family: "Roboto", "Noto Sans Thai", sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #166534;
}
.theme-dark .invoice-paper thead { background: transparent; }
.theme-dark .invoice-paper .invoice-lines-table tbody tr:nth-child(odd)  { background: transparent; }
.theme-dark .invoice-paper .invoice-lines-table tbody tr:nth-child(even) { background: #dde3ea; }
.theme-dark .invoice-paper tbody td { border-bottom-color: #d8dee6; }
.theme-dark .invoice-paper tbody tr:hover td { background: transparent; }

/* ── Dark theme: Finance + list pages rollout ──────────────────────── */
.theme-dark .pl-subtotal td { color: var(--dk-text-num); border-top-color: rgba(255, 255, 255, .25); }
.theme-dark .pl-total td {
  color: var(--dk-text-num);
  border-top-color: rgba(255, 255, 255, .5);
  border-bottom-color: rgba(255, 255, 255, .5);
}
.theme-dark .pl-total--net td { background: rgba(127, 196, 245, .08); }
.theme-dark .pl-section-header--capital td { border-top-color: rgba(255, 255, 255, .5); color: var(--dk-text-mut); }
.theme-dark .pl-negative { color: var(--dk-neg); }

.theme-dark .acct-group { border-bottom-color: var(--dk-border-div); }
.theme-dark .acct-row:hover { background: rgba(255, 255, 255, .04); }
.theme-dark .acct-name--parent { color: var(--dk-text-mut); }
.theme-dark .acct-name-input:focus { border-color: rgba(127, 196, 245, .45); box-shadow: 0 0 0 2px rgba(127, 196, 245, .2); }
.theme-dark .acct-empty { color: var(--dk-text-faint); }

.theme-dark .badge--active { color: #7ee2a8; }
.theme-dark .badge--inactive { color: var(--dk-neg); }
.theme-dark .badge-sales       { background: rgba(34, 197, 94, .18); color: #7ee2a8; }
.theme-dark .badge-testing     { background: rgba(252, 211, 77, .15); color: #fcd34d; }
.theme-dark .badge-stopped     { background: rgba(255, 255, 255, .08); color: var(--dk-text-sec); }
.theme-dark .badge-third-party { background: rgba(127, 196, 245, .15); color: var(--dk-accent); }

.theme-dark .ss-variety-code,
.theme-dark .ss-variety-raw { color: var(--dk-text); }
.theme-dark .ss-variety-name,
.theme-dark .ss-remarks { color: var(--dk-text-mut); }
.theme-dark .ss-variety-segment { background: rgba(255, 255, 255, .08); color: var(--dk-text-sec); }
.theme-dark .ss-contact-raw,
.theme-dark .ss-unlinked-variety { color: var(--dk-text-mut); }
.theme-dark .ss-exp-pill { background: rgba(252, 211, 77, .15); color: #fcd34d; }

.theme-dark .prod-attach-icon { color: var(--dk-text-mut); }
.theme-dark .search-bar__count { color: var(--dk-text-mut); }

/* ── Dark theme: Bank Transactions ──────────────────────────────────── */
.btx-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.btx-stat {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 1rem;
  padding: 0.85rem 1.15rem;
}
.btx-stat__label {
  font: 600 0.7rem var(--dk-font-mono, ui-monospace);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #6b7280;
  margin-bottom: 0.35rem;
}
.btx-stat__value {
  font-size: 1.3rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.btx-stat__value--pos { color: #16a34a; }
.btx-stat__value--neg { color: #dc2626; }
.btx-stale { color: #dc2626; font-weight: 600; font-size: 0.9rem; }

.theme-dark .btx-stat { background: var(--dk-card-flat); border-color: var(--dk-border-card); }
.theme-dark .btx-stat__label { color: var(--dk-text-mut); }
.theme-dark .btx-stat__value { font-family: var(--dk-font-mono); color: var(--dk-text-num); font-size: 1.2rem; }
.theme-dark .btx-stat__value--pos { color: var(--dk-accent); }
.theme-dark .btx-stat__value--neg { color: var(--dk-neg); }
.theme-dark .btx-stale { color: var(--dk-neg); }
@media (max-width: 767.98px) {
  /* mobile main page: no stale warning, no year chip (Year lives in the
     filter sheet), no stat tiles. The tile rule must live here, after
     .btx-stat-grid's display:grid, or the earlier hide loses the cascade. */
  .btx-stale,
  .btx-year-form,
  .btx-stat-grid { display: none; }
}

.theme-dark .btx-filter-panel {
  background: var(--dk-canvas);
  border: none;
  box-shadow: none;
  border-radius: 0;
  padding: 0.25rem 0 0.5rem;
  top: 0;
}
/* let the (visible) filter form span the whole panel so the CSV buttons
   reach the page's right edge; the hidden import form takes no space */
.theme-dark .btx-filter-panel .filter-panel > form:first-of-type { flex: 1; min-width: 0; }
.theme-dark .btx-filter-panel .filter-panel > form:last-of-type { flex: 0 0 auto; }
.theme-dark .btx-filter-row {
  row-gap: 0.5rem;
  align-items: center;
  flex-wrap: nowrap; /* keep everything on one line; the search field absorbs the slack */
  gap: 0.5rem;
}
.theme-dark .btx-filter-row .button,
.theme-dark .btx-filter-row .search-bar__checkbox-label { flex: 0 0 auto; white-space: nowrap; }
/* chip selects size to their content (the global select rule is width:100%) */
.theme-dark .btx-filter-row .dash-year-select { width: auto; flex: 0 0 auto; }
.theme-dark .btx-row--selected td { background: rgba(127, 196, 245, .14); }
.theme-dark tr.btx-row--selected .btx-editable-cell { background: rgba(127, 196, 245, .14); }
.theme-dark .btx-filter-row .search-bar__input-wrap { flex: 1 1 auto; min-width: 110px; max-width: 340px; }
.theme-dark .btx-filter-row .button { height: 40px; border-radius: 10px; }
.theme-dark .btx-filter-submit {
  background: transparent;
  border-color: rgba(127, 196, 245, .5);
  color: var(--dk-accent);
}
.theme-dark .btx-filter-submit:hover { background: rgba(127, 196, 245, .1); }

.theme-dark .btx-ref a { font: 600 13px var(--dk-font-mono); }
.theme-dark .btx-date { font-family: var(--dk-font-mono); font-size: 13px; color: var(--dk-text-sec); }
.theme-dark .btx-num { font-family: var(--dk-font-mono); font-size: 13px; }
.theme-dark .btx-num--withdrawal { color: var(--dk-neg); }
.theme-dark .btx-num--deposit { color: var(--dk-accent); font-weight: 600; }
.theme-dark .btx-num--balance { color: var(--dk-text-mut); }
.theme-dark .btx-editable-cell:hover { background: rgba(255, 255, 255, .05); }
.theme-dark .btx-notes-input { background: var(--dk-menu); border-color: rgba(127, 196, 245, .45); }


/* ── Dark theme: detail pages rollout ──────────────────────────────── */

/* Bank transaction detail */
.theme-dark .btx-card { background: var(--dk-card-flat); border: 1px solid var(--dk-border-card); }
.theme-dark .btx-eyebrow,
.theme-dark .btx-field-label,
.theme-dark .btx-tx-date { color: var(--dk-text-mut); }
.theme-dark .btx-field-value,
.theme-dark .btx-tx-ref { color: var(--dk-text-num); }
.theme-dark .btx-amount--withdrawal { color: var(--dk-neg); }
.theme-dark .btx-amount--deposit { color: #7ee2a8; }
.theme-dark .btx-attach-row { background: rgba(255, 255, 255, .03); border-color: var(--dk-border-div); }
.theme-dark .btx-attach-icon-wrap { background: rgba(34, 197, 94, .14); color: #7ee2a8; }
.theme-dark .btx-attach-link { color: var(--dk-text); }
.theme-dark .btx-close-btn { background: var(--dk-chip); border-color: var(--dk-border-ctl); color: var(--dk-text-sec); }
.theme-dark .btx-close-btn:hover { background: rgba(255, 255, 255, .1); color: var(--dk-text); }

/* Status pills (inventory, bank detail) */
.theme-dark .pill-green { background: rgba(34, 197, 94, .18); color: #7ee2a8; }
.theme-dark .pill-amber { background: rgba(252, 211, 77, .15); color: #fcd34d; }
.theme-dark .pill-red   { background: rgba(255, 139, 122, .16); color: var(--dk-neg); }
.theme-dark .pill-gray  { background: rgba(255, 255, 255, .08); color: var(--dk-text-sec); }

/* Inventory detail */
.theme-dark .inv-stat + .inv-stat { border-left-color: var(--dk-border-div); }
.theme-dark .inv-stat__label { color: var(--dk-text-mut); }
.theme-dark .inv-stat__value { color: var(--dk-text-num); }
.theme-dark .inv-stat__unit { color: var(--dk-text-faint); }
.theme-dark .invl-row td { border-bottom-color: var(--dk-border-row); }
.theme-dark .invl-row--new td { background: rgba(255, 255, 255, .04); }
/* editing row: the base rule uses !important, so this must too */
.theme-dark .invl-row.invl-editing td { background: rgba(127, 196, 245, .1) !important; }
.theme-dark .invl-input,
.theme-dark .invl-select {
  background: var(--dk-chip);
  border-color: var(--dk-border-ctl);
  color: var(--dk-text);
}
/* the browser's calendar glyph is black; invert it on the dark chip */
.theme-dark .invl-input--date::-webkit-calendar-picker-indicator { filter: invert(1); }
.theme-dark .invl-input:focus,
.theme-dark .invl-select:focus { border-color: rgba(127, 196, 245, .45); }
.theme-dark .slt-type-badge--germination { background: rgba(34, 197, 94, .18); color: #7ee2a8; }
.theme-dark .slt-type-badge--purity      { background: rgba(127, 196, 245, .15); color: var(--dk-accent); }
.theme-dark .slt-type-badge--tsw         { background: rgba(167, 139, 250, .18); color: #c4b5fd; }
.theme-dark .slt-type-badge--vigor       { background: rgba(252, 211, 77, .15); color: #fcd34d; }
.theme-dark .slt-type-badge--laboratory  { background: rgba(127, 196, 245, .12); color: #93cff5; }
.theme-dark .coll-header { border-top: none; }
.theme-dark .coll-rule { display: none; }
.theme-dark .coll-header:hover .coll-title { color: var(--dk-text); }

/* Variety detail */
.theme-dark .variety-header { background: var(--dk-card-flat); border-color: var(--dk-border-card); }
.theme-dark .variety-header__name { color: var(--dk-text); }
.theme-dark .variety-field label { color: var(--dk-text-mut); }
.theme-dark .btn-nav { background: var(--dk-chip); border-color: var(--dk-border-ctl); color: var(--dk-text-sec); }
.theme-dark .btn-nav:hover { background: rgba(255, 255, 255, .1); color: var(--dk-text); }
.theme-dark .nav-counter { color: var(--dk-text-mut); }
.theme-dark .res-pill { background: rgba(127, 196, 245, .15); color: var(--dk-accent); }
.theme-dark .res-pill--empty { background: transparent; border-color: rgba(255, 255, 255, .22); color: var(--dk-text-mut); }
.theme-dark .res-pill--empty:hover { border-color: rgba(255, 255, 255, .45); color: var(--dk-text-sec); }
.theme-dark .photo-tile { background: rgba(255, 255, 255, .08); }
.theme-dark .photo-tile--add { border-color: rgba(255, 255, 255, .22); color: rgba(255, 255, 255, .3); }
.theme-dark .photo-tile--add:hover { border-color: rgba(255, 255, 255, .45); color: rgba(255, 255, 255, .55); }
.theme-dark .empty-state { color: var(--dk-text-faint); }
.theme-dark .variety-notice { background: rgba(34, 197, 94, .12); color: #7ee2a8; border-color: rgba(34, 197, 94, .3); }

/* Forms (contacts, users, productions, seed samples) */
.theme-dark .prod-parentage-header,
.theme-dark .prod-parentage-label { color: var(--dk-text-mut); }
.theme-dark .ss-readonly-display {
  background: rgba(255, 255, 255, .05) !important;
  color: var(--dk-text-sec) !important;
  border-color: var(--dk-border-div) !important;
}
.theme-dark .ss-form-resolved { color: #7ee2a8; }
.theme-dark .ss-form-hint { color: var(--dk-text-mut); }
.theme-dark .ss-edit-header__title { color: var(--dk-text); }
.theme-dark .ss-variety-link { color: var(--dk-accent); }


.theme-dark .invl-balance-row td {
  background: rgba(127, 196, 245, .09);
  border-top-color: rgba(127, 196, 245, .2);
  color: var(--dk-accent);
}
.theme-dark .prod-variety-name__value {
  background: rgba(255, 255, 255, .05);
  border-color: var(--dk-border-div);
}
/* Uniform control height on form pages (textareas keep their own height) */
.theme-dark .form-field input[type="text"],
.theme-dark .form-field input[type="number"],
.theme-dark .form-field input[type="date"],
.theme-dark .form-field input[type="email"],
.theme-dark .form-field input[type="tel"],
.theme-dark .form-field input[type="url"],
.theme-dark .form-field select,
.theme-dark .form-field .prod-variety-name__value {
  height: 2.75rem;
  min-height: 0;
  padding-top: 0;
  padding-bottom: 0;
}
.theme-dark .form-field .input-group__prefix {
  height: 2.75rem;
  display: inline-flex;
  align-items: center;
}
.theme-dark .input-group__prefix {
  background: var(--dk-accent);
  border-color: var(--dk-accent);
  color: var(--dk-canvas);
  font-weight: 600;
}

/* Email/autofill: match normal text inputs; kill Chrome's autofill tint */
.theme-dark input:-webkit-autofill,
.theme-dark input:-webkit-autofill:hover,
.theme-dark input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--dk-chip) inset;
  -webkit-text-fill-color: var(--dk-text);
  caret-color: var(--dk-text);
}

/* No focus box around the sidebar brand link */
.theme-dark .topbar__logo:focus,
.theme-dark .topbar__logo:focus-visible { outline: none; }

.theme-dark .panel__title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.theme-dark .contact-active-check {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--dk-text-sec);
  cursor: pointer;
}
.theme-dark .contact-active-check input { accent-color: var(--dk-accent); }

/* ── Dark theme: mobile (Bank Transactions + shared mobile chrome) ─── */
.btx-mobile-balance { display: none; }
@media (max-width: 767.98px) {
  .theme-dark .mobile-topbar {
    background: rgba(11, 14, 18, .92);
    border-bottom: 1px solid var(--dk-border-card);
  }
  .theme-dark .mobile-topbar__brand { color: var(--dk-text); }
  .theme-dark .mobile-bottom-nav { background: #10141b; border-top: 1px solid var(--dk-border-card); }
  .theme-dark .mobile-bottom-nav__item { color: rgba(231, 236, 242, .55); }
  .theme-dark .mobile-bottom-nav__item:hover,
  .theme-dark .mobile-bottom-nav__item--active { background: transparent; color: var(--dk-accent); }

  .theme-dark .btx-mobile-search {
    height: 46px;
    border-radius: 12px;
    background-color: var(--dk-card-hi);
    border-color: var(--dk-border-ctl);
  }
  .theme-dark .btx-mobile-filter-btn {
    background: var(--dk-card-hi);
    border: 1px solid var(--dk-border-ctl);
    border-radius: 12px;
    color: var(--dk-text-sec);
  }
  .theme-dark .btx-mobile-filter-btn--active { border-color: rgba(127, 196, 245, .5); color: var(--dk-accent); }

  .theme-dark .btx-mobile-balance {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.85rem;
    padding: 0.75rem 1rem;
    border: 1px solid rgba(127, 196, 245, .35);
    border-radius: 12px;
    background: rgba(127, 196, 245, .08);
  }
  .theme-dark .btx-mobile-balance__label {
    font: 600 11px var(--dk-font-mono);
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--dk-accent);
  }
  .theme-dark .btx-mobile-balance__amount { font: 600 20px var(--dk-font-mono); color: var(--dk-text-num); }

  .theme-dark .btx-mobile-card {
    background: var(--dk-card-flat);
    border: 1px solid var(--dk-border-card);
    border-radius: 12px;
    box-shadow: none;
    color: var(--dk-text);
  }
  .theme-dark .btx-mobile-card__ref { font: 600 15px var(--dk-font-mono); color: var(--dk-accent); }
  .theme-dark .btx-mobile-card__flow { font: 600 15px var(--dk-font-mono); }
  .theme-dark .btx-mobile-card__flow--credit { color: var(--dk-accent); }
  .theme-dark .btx-mobile-card__flow--debit { color: var(--dk-neg); }
  .theme-dark .btx-mobile-card__date,
  .theme-dark .btx-mobile-card__balance { font: 400 13px var(--dk-font-mono); color: var(--dk-text-mut); }
  .theme-dark .btx-mobile-card__account {
    font: 500 10.5px var(--dk-font-mono);
    letter-spacing: .08em;
    text-transform: uppercase;
    background: rgba(255, 255, 255, .08);
    color: var(--dk-text-sec);
    border-radius: 6px;
    padding: 3px 9px;
    max-width: 50%;
  }
  .theme-dark .btx-mobile-card__note {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    color: var(--dk-text-mut);
  }
  .theme-dark .btx-mobile-card__row--account { display: flex; align-items: center; gap: 0.6rem; }
  .theme-dark .btx-mobile-card__docs {
    margin-left: auto;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex: none;
  }
  .theme-dark .btx-mobile-card__docs--todo { background: rgba(255, 139, 122, .22); color: var(--dk-neg); }
  .theme-dark .btx-mobile-card__docs--ok   { background: rgba(34, 197, 94, .22); color: #7ee2a8; }

  .theme-dark .bottom-sheet__panel { background: var(--dk-menu); color: var(--dk-text); }
  .theme-dark .bottom-sheet__title { color: var(--dk-text); }
  .theme-dark .bottom-sheet__close { color: var(--dk-text-sec); }
  .theme-dark .btx-sheet-label { color: var(--dk-text-mut); }
  .theme-dark .btx-sheet-checks label { color: var(--dk-text-sec); }
}

/* ── Mobile app bar (Seedpit-style): actions cluster + dropdown menu ── */
.m-appbar__actions { display: none; }
@media (max-width: 767.98px) {
  .theme-dark .mobile-topbar { display: flex; align-items: center; gap: 0.5rem; }
  .theme-dark .mobile-topbar__brand { flex-shrink: 1; min-width: 0; }
  .m-appbar__actions { display: flex; align-items: center; gap: 0.15rem; margin-left: auto; }
  .m-appbar-btn {
    position: relative;
    background: transparent;
    border: none;
    color: var(--dk-text, #e7ecf2);
    font-size: 1.25rem;
    line-height: 1;
    padding: 0.35rem 0.5rem;
    border-radius: 8px;
    cursor: pointer;
  }
  .m-appbar-btn:hover,
  .m-appbar-btn:active { background: rgba(255, 255, 255, .1); }
  .m-appbar-btn__dot {
    position: absolute;
    top: 3px;
    right: 4px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #fcd34d;
    border: 1px solid var(--dk-canvas, #0b0e12);
  }
  .m-menu { position: relative; }
  .m-menu__panel {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 220px;
    max-height: 72vh;
    overflow-y: auto;
    background: var(--dk-menu, #161b25);
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 11px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, .55);
    padding: 6px;
    z-index: 300;
  }
  .m-menu__link,
  .theme-dark .m-menu__link {
    display: block;
    width: 100%;
    text-align: left;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: rgba(231, 236, 242, .85);
    text-decoration: none;
    background: transparent;
    border: none;
    cursor: pointer;
  }
  .theme-dark .m-menu__link:hover { background: rgba(255, 255, 255, .06); color: var(--dk-text, #e7ecf2); }
  .theme-dark .m-menu__link--active,
  .theme-dark .m-menu__link--active:hover { background: var(--dk-accent, #7fc4f5); color: var(--dk-canvas, #0b0e12); font-weight: 600; }
  .m-menu__divider { height: 1px; background: rgba(255, 255, 255, .1); margin: 6px 4px; }
}

/* ── Mobile: Variety Catalog cards ──────────────────────────────────── */
.vc-mobile-list { display: none; }
@media (max-width: 767.98px) {
  .vc-desktop { display: none; }
  .vc-mobile-list { display: flex; flex-direction: column; gap: 0.6rem; }
  .theme-dark .vc-mobile-group {
    font: 600 11px var(--dk-font-mono);
    letter-spacing: .14em;
    text-transform: uppercase;
    color: rgba(127, 196, 245, .7);
    margin: 0.5rem 0.2rem 0;
  }
  .theme-dark .vc-card {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    background: var(--dk-card-flat);
    border: 1px solid var(--dk-border-card);
    border-radius: 12px;
    padding: 0.7rem 0.9rem;
    text-decoration: none;
  }
  .theme-dark .vc-card__pic {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    overflow: hidden;
    flex: none;
    background: rgba(255, 255, 255, .08);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(231, 236, 242, .35);
    font-size: 1.4rem;
  }
  .vc-card__pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
  .theme-dark .vc-card__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
  .theme-dark .vc-card__code { font: 600 15px var(--dk-font-mono); color: var(--dk-accent); }
  .theme-dark .vc-card__name {
    font-size: 14px;
    color: var(--dk-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .theme-dark .vc-card__meta { font-size: 12.5px; color: var(--dk-text-mut); }
  .theme-dark .vc-card__side { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
  .theme-dark .vc-card__disc {
    font-size: 10px;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--dk-neg);
  }

  /* Crop pills in the filter sheet — tap to toggle, multi-select */
  .vc-crop-pills { display: flex; flex-wrap: wrap; gap: 0.5rem; }
  .vc-crop-pill { position: relative; }
  .vc-crop-pill input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
  }
  .theme-dark .vc-crop-pill span {
    display: inline-block;
    padding: 9px 18px;
    border-radius: 999px;
    border: 1px solid var(--dk-border-ctl);
    background: var(--dk-chip);
    color: var(--dk-text-sec);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background .13s ease, color .13s ease, border-color .13s ease;
  }
  .theme-dark .vc-crop-pill input:checked + span {
    background: var(--dk-accent);
    border-color: var(--dk-accent);
    color: var(--dk-canvas);
  }
  .theme-dark .vc-crop-pill--sm span { padding: 6px 13px; font-size: 13px; font-weight: 500; }
  /* crop pills: one row, equal widths */
  .vc-crop-pills--row { flex-wrap: nowrap; }
  .vc-crop-pills--row .vc-crop-pill { flex: 1 1 0; min-width: 0; }
  .theme-dark .vc-crop-pills--row .vc-crop-pill span {
    display: block;
    width: 100%;
    text-align: center;
    padding: 9px 4px;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

.theme-dark .variety-col-left,
.theme-dark .variety-col-right {
  background: var(--dk-card-flat);
  border-color: var(--dk-border-card);
}

/* Variety detail form controls: the .variety-field-scoped base rules
   outrank the generic dark input sweep, so restate them here. */
.theme-dark .variety-field input[type="text"],
.theme-dark .variety-field input[type="number"],
.theme-dark .variety-field input[type="date"],
.theme-dark .variety-field select,
.theme-dark .variety-field textarea {
  background: var(--dk-chip);
  border-color: var(--dk-border-ctl);
  color: var(--dk-text);
}
.theme-dark .variety-field input:focus,
.theme-dark .variety-field select:focus,
.theme-dark .variety-field textarea:focus {
  border-color: rgba(127, 196, 245, .45);
  background: var(--dk-menu);
}
/* consistent single-line control height inside the variety form */
.theme-dark .variety-field input[type="text"],
.theme-dark .variety-field input[type="number"],
.theme-dark .variety-field input[type="date"],
.theme-dark .variety-field select {
  height: 2.4rem;
  padding-top: 0;
  padding-bottom: 0;
}

/* ── Mobile: Variety Detail — same areas, photos on top ────────────── */
@media (max-width: 767.98px) {
  .variety-body { grid-template-columns: 1fr; min-width: 0; }
  .variety-col-left,
  .variety-col-right {
    overflow-y: visible;
    max-height: none;
    /* contain the photo strip: without min-width:0 the grid item grows to
       the strip's intrinsic width and the whole page scrolls sideways */
    min-width: 0;
    max-width: 100%;
  }
  .variety-col-right { order: -1; }
  /* photos as a horizontal swipe strip */
  .variety-col-right .photo-grid {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }
  /* belt and braces: the page itself never pans sideways on mobile */
  body.theme-dark { overflow-x: hidden; }
  .variety-col-right .photo-tile,
  .variety-col-right .photo-tile--add { width: 108px; flex: none; }
  /* bottom nav handles prev/next on mobile; hide the header arrows */
  .variety-header__right { display: none; }
  /* header wraps gracefully on narrow screens */
  .variety-header { flex-wrap: wrap; row-gap: 0.5rem; }
  .variety-header__left { flex-wrap: wrap; row-gap: 0.35rem; }
  .variety-header__name { white-space: normal; }
}

/* Fullscreen photo lightbox (variety detail) */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(5, 8, 12, .93);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2vh 2vw;
}
.lightbox-overlay img {
  max-width: 96vw;
  max-height: 92vh;
  object-fit: contain;
  border-radius: 8px;
}
.lightbox-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .14);
  border: none;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

/* Mobile close button in the page header of detail screens */
.detail-close-mobile { display: none; }
@media (max-width: 767.98px) {
  .theme-dark .detail-close-mobile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--dk-chip);
    border: 1px solid var(--dk-border-ctl);
    color: var(--dk-text-sec);
    font-size: 16px;
    text-decoration: none;
  }
}

/* Touch devices: no hover state exists — show the tile controls outright
   so the first tap acts as a real click instead of hover-reveal. */
@media (hover: none) {
  .photo-tile__delete,
  .photo-tile__caption-pen { opacity: 1 !important; }
}


/* Variety codes in lists: plain text in green mono */
.theme-dark a.vc-code-text,
.theme-dark a.vc-code-text:hover,
.theme-dark .vc-code-text { color: #7ee2a8; font-family: var(--dk-font-mono); font-weight: 600; }

/* Lot status select in the Quality Control card header: red unless approved */
.coll-status { margin-left: auto; display: inline-flex; align-items: center; gap: 12px; cursor: default; }
.coll-status__check {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: #6e6e73;
  cursor: pointer;
}
.theme-dark .coll-status__check { color: var(--dk-text-sec); }
.theme-dark .coll-status__check input { accent-color: var(--dk-accent); }
.inv-status-select--warn { color: #dc2626; font-weight: 600; }
.inv-status-select--ok   { color: #16a34a; font-weight: 600; }
.theme-dark .inv-status-select--warn { color: var(--dk-neg); }
.theme-dark .inv-status-select--ok   { color: #7ee2a8; }
.inv-status-select--info { color: #2563eb; font-weight: 600; }
.theme-dark .inv-status-select--info { color: var(--dk-accent); }
.theme-dark .pill-blue { background: rgba(127, 196, 245, .15); color: var(--dk-accent); }

/* Production card: no vertical separators in dark; readable values;
   disabled origin/year read as plain display text */
.theme-dark .inv-prod-field + .inv-prod-field { border-left: none; }
/* Production / Origin / Year controls share one height */
.theme-dark .inv-prod-field input[type="text"],
.theme-dark .inv-prod-field input[type="number"],
.theme-dark .inv-prod-field select {
  height: 2.25rem;
  padding-top: 0;
  padding-bottom: 0;
  font-size: 13px;
}
.theme-dark .inv-prod-value { color: var(--dk-text); }
.theme-dark .inv-prod-field input:disabled {
  background: transparent;
  border-color: transparent;
  color: var(--dk-text);
  opacity: 1;
  padding-left: 0;
}

/* Inventory list: status colors — approved green, rejected/finished red, testing blue */
.inv-list-status--ok   { color: #16a34a; font-weight: 600; }
.inv-list-status--bad  { color: #dc2626; font-weight: 600; }
.inv-list-status--info { color: #2563eb; font-weight: 600; }
.theme-dark td.inv-list-status--ok   { color: #7ee2a8; }
.theme-dark td.inv-list-status--bad  { color: var(--dk-neg); }
.theme-dark td.inv-list-status--info { color: var(--dk-accent); }
.inv-list-status--amber { color: #b45309; font-weight: 600; }
.theme-dark td.inv-list-status--amber { color: #fcd34d; }

/* Inventory list: default-lot star */
.theme-dark .inv-list-default { color: var(--dk-accent); text-align: center; }

/* ── Seed price list ────────────────────── */
.seed-price-note { margin: 0 0 0.75rem; font-size: 0.85rem; color: #64748b; }
/* Half the previous 8rem: these hold a price, not a long number. */
.seed-price-col { width: 1%; white-space: nowrap; }
.seed-price-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  justify-content: flex-end;
}
.seed-price-input {
  width: 5.5rem;
  text-align: right;
  padding: 0.3rem 0.5rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.35rem;
  background: #fff;
  color: #0f172a;
}
.theme-dark .seed-price-input {
  background: var(--dk-input-bg, #1e293b);
  border-color: var(--dk-border-card);
  color: var(--dk-text, #e2e8f0);
}
.seed-price-input:focus {
  outline: none;
  border-color: #3b82f6;
}

/* ── Seed stock summary by variety ──────── */
.ss-print-title { display: none; }
.ss-no-tsw { color: #b45309; font-weight: 700; cursor: help; }
.ss-footnote { margin: 0.6rem 0 0; font-size: 0.8rem; color: #64748b; }
.ss-total-row { font-weight: 700; border-top: 2px solid #e2e8f0; }
.theme-dark .ss-total-row { border-top-color: #475569; }

@media print {
  /* Paper is white: drop the dark theme rather than printing a black page. */
  body.theme-dark, body.theme-dark .panel, body.theme-dark table,
  body.theme-dark td, body.theme-dark th {
    background: #fff !important;
    color: #000 !important;
  }
  .stock-summary-bar, .page-header, .app-sidebar, .app-nav, .flash { display: none !important; }
  .ss-print-title {
    display: block;
    font-size: 15pt;
    font-weight: 700;
    margin: 0 0 0.6rem;
    color: #000 !important;
  }
  .ss-print-date { float: right; font-size: 10pt; font-weight: 400; }
  .panel, .table-wrapper, .section {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
  }
  table { width: 100%; border-collapse: collapse; font-size: 9pt; }
  th, td { border-bottom: 1px solid #ccc; padding: 3px 6px !important; }
  thead { display: table-header-group; }
  tr { page-break-inside: avoid; }
  .table-group-header td {
    font-weight: 700;
    background: #eee !important;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
  .ss-total-row td { border-top: 2px solid #000; font-weight: 700; }
  /* The blue reads as grey on a mono printer; keep it black for legibility. */
  .inv-list-code, .inv-list-seeds,
  .theme-dark .inv-list-code, .theme-dark td.inv-list-seeds { color: #000 !important; }
}

/* Inventory list: variety code and estimated seeds picked out in blue */
.inv-list-code { color: #2563eb; font-weight: 600; }
.theme-dark .inv-list-code { color: var(--dk-accent); }
.inv-list-seeds { color: #2563eb; }
.theme-dark td.inv-list-seeds { color: var(--dk-accent); }

/* Production card: aligned grid instead of scattered flex row */
.theme-dark .inv-prod-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px 22px;
  align-items: start;
}
.theme-dark .inv-prod-field { padding: 0; gap: 4px; }
.theme-dark .inv-prod-field--wide { grid-column: span 2; }
/* second line inside the production grid: spans full width, own grid */
.theme-dark .inv-prod-row--sub {
  grid-column: 1 / -1;
  margin-top: 4px;
}
.theme-dark .inv-prod-field input[type="text"],
.theme-dark .inv-prod-field input[type="number"],
.theme-dark .inv-prod-field select { width: 100% !important; }
.theme-dark .inv-prod-field .inv-prod-value {
  min-height: 2.25rem;
  display: inline-flex;
  align-items: center;
}
.theme-dark .inv-prod-field input[type="checkbox"] { margin: 0.55rem 0 0; }

/* ── Standard filter-row control height (app-wide, dark theme) ───────
   Everything that sits in a filter/search row — buttons, inputs,
   selects, checkbox chips, year chips — is 40px tall, radius 10px. */
.theme-dark .search-bar .button,
.theme-dark .filter-bar .button,
.theme-dark .crop-filter-buttons .button,
.theme-dark .search-bar__input,
.theme-dark .filter-bar__input,
.theme-dark .filter-bar__select,
.theme-dark .search-bar__checkbox-label,
.theme-dark .dash-year-select {
  height: 40px;
  border-radius: 10px;
  padding-top: 0;
  padding-bottom: 0;
}
.theme-dark .search-bar { align-items: center; }
/* Lighter arrow so it reads against the dark control background. */
.theme-dark select.filter-bar__select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath fill='%23e7ecf2' fill-opacity='.45' d='M0 0h10L5 6z'/%3E%3C/svg%3E");
}

/* data-table: bind to the standard token scale (its base rules carry
   hardcoded light-mode colors that defeat inheritance) */
.theme-dark .data-table td { color: var(--dk-text); border-bottom-color: var(--dk-border-row); }
.theme-dark .data-table th { color: var(--dk-text-mut); border-bottom-color: var(--dk-border-div); }

/* Productions list quantity cell */
.theme-dark .prod-qty-target { color: var(--dk-text-faint); }
.theme-dark .prod-qty-actual {
  color: var(--dk-accent);
  font-family: var(--dk-font-mono);
}

/* Compact close button in detail nav rows */
.theme-dark .inv-close-btn--sm {
  width: 32px;
  height: 32px;
  font-size: 14px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 8px;
  text-decoration: none;
}
} /* end @media screen (dark theme) */
