/*
 * 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 {
  display: none;
  position: absolute;
  top: calc(100% + 0.25rem);
  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.25rem;
  z-index: 100;
}

.topbar__dropdown:hover .topbar__submenu {
  display: block;
}

.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);
}

.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-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; }

.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.9rem 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"],
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;
}

.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;
}

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

.search-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.search-bar__input-wrap {
  position: relative;
  flex: 1;
}

.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; }

.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;
}

.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--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 {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.5);
  color: #fff;
  font-size: 0.65rem;
  padding: 3px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 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: 400px;
  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;
}

.invoice-sidebar {
  grid-column: 2;
  grid-row: 2;
  width: 260px;
  position: sticky;
  top: 1.5rem;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  padding: 1rem;
  box-shadow: 0 2px 8px rgba(15,23,42,0.05);
  font-size: 0.82rem;
}

.inv-sidebar-section {
  padding: 0.6rem 0;
  border-bottom: 1px solid #f1f5f9;
}
.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-attach-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0;
  font-size: 0.78rem;
}
.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-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-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;
}

.inv-list-cell--editable {
  cursor: text;
  min-width: 110px;
}

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

.inv-list-input {
  width: 100%;
  font-size: inherit;
  font-family: inherit;
  border: 1px solid #94a3b8;
  border-radius: 4px;
  padding: 0.15rem 0.35rem;
  outline: none;
}

.inv-list-input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59,130,246,0.2);
}


.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-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-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; }

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

.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-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;
}

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

@media (max-width: 800px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }
  .topbar__nav {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  .topbar__user-name {
    display: none;
  }
}

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

  body {
    background: #fff !important;
  }

  /* Hide all screen-only chrome */
  .topbar,
  .invoice-close-bar,
  .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-filters { 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: 2fr 3fr;
  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;
}
.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;
}
.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;
}
.filter-bar__search-clear:hover { color: #475569; }
.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 {
  cursor: text;
  position: relative;
}
tr:hover .btx-editable-cell {
  background: #f8fafc;
}
tr: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__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; }

/* ── 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 ───────────────────────────── */
.ilines-table td { padding: 0.2rem 0.3rem; vertical-align: middle; }
.ilines-cell--inv  { white-space: nowrap; font-size: 0.85rem; }
.ilines-cell--desc { color: #475569; font-size: 0.85rem; min-width: 160px; }
.ilines-input {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 0.25rem;
  padding: 0.2rem 0.35rem;
  font-size: 0.85rem;
  background: transparent;
  color: inherit;
  transition: border-color 0.15s, background 0.15s;
}
.ilines-input:focus {
  outline: none;
  border-color: #93c5fd;
  background: #fff;
}
.ilines-input--wide  { min-width: 160px; }
.ilines-input--code  { min-width: 100px; }
.ilines-input--crop  { min-width: 90px;  }
.ilines-input--seg   { min-width: 90px;  }
.ilines-input--saved  { border-color: #22c55e !important; background: #f0fdf4 !important; }
.ilines-input--error  { border-color: #ef4444 !important; background: #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;
}
