:root {
  --bg: #f6f4ee;
  --panel: #fffdf8;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #126b5f;
  --accent-soft: #d7efe6;
  --danger: #b42318;
  --line: #e3ddcf;
  --warning: #f59e0b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Trebuchet MS", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 20% 10%, #f8efe0 0%, var(--bg) 42%),
              radial-gradient(circle at 90% 15%, #d8f0eb 0%, transparent 35%),
              var(--bg);
}

.bg-shape {
  position: fixed;
  z-index: -1;
  border-radius: 999px;
  filter: blur(22px);
  opacity: 0.45;
}

.bg-a {
  width: 280px;
  height: 280px;
  background: #ffd9a8;
  top: -70px;
  left: -50px;
}

.bg-b {
  width: 320px;
  height: 320px;
  background: #8ed5c2;
  right: -80px;
  top: 80px;
}

.site-header {
  padding: 14px clamp(16px, 5vw, 56px);
  display: grid;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(4px);
}

.site-header-top {
  display: flex;
  align-items: center;
}

.site-header h1 {
  margin: 0;
  font-size: clamp(1.3rem, 2.5vw, 2rem);
  letter-spacing: 0.02em;
}

.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.nav-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.nav-link {
  text-decoration: none;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 0.88rem;
  white-space: nowrap;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease;
}

.nav-link:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.nav-link.is-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.nav-cta {
  background: var(--accent-soft);
  border-color: #9fd8c8;
  color: var(--accent);
  font-weight: 600;
}

.nav-cta:hover,
.nav-cta.is-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.active-profile-badge {
  display: inline-flex;
  align-items: center;
  gap: 0;
  overflow: hidden;
  background: var(--accent-soft);
  border-color: #9fd8c8;
  color: var(--accent);
}

.active-profile-badge:hover,
.active-profile-badge:focus-visible {
  gap: 5px;
  background: var(--accent-soft);
  border-color: #9fd8c8;
  color: var(--accent);
}

.profile-badge-icon {
  font-size: 1rem;
  line-height: 1;
}

.profile-badge-name {
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  font-size: 0.82rem;
  font-weight: 600;
  transition: max-width 220ms ease;
}

.active-profile-badge:hover .profile-badge-name,
.active-profile-badge:focus-visible .profile-badge-name {
  max-width: 180px;
}

/* legacy fallback — not used if all links go through .nav-link */
.site-header a:not(.nav-link) {
  text-decoration: none;
  color: var(--text);
}

.page-wrap {
  padding: 20px clamp(16px, 5vw, 56px) 42px;
  display: grid;
  gap: 16px;
}

.flash-list {
  display: grid;
  gap: 8px;
}

.flash {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
}

.flash.success {
  border-color: #93d4c1;
  background: #edf9f5;
}

.flash.error {
  border-color: #f3a9a3;
  background: #fff3f2;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.stat-card {
  background: linear-gradient(135deg, #fefbf2 0%, #fff 100%);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  animation: rise 320ms ease both;
}

.stat-card h2 {
  margin: 0 0 8px;
  font-size: 0.9rem;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-card p {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
}

.stat-card.warning {
  border-color: #f1d197;
  background: #fff8e8;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  background: var(--panel);
}

.panel h2 {
  margin-top: 0;
}

.import-form,
.filters-grid,
.item-form-grid {
  display: grid;
  gap: 10px;
}

.filters-grid,
.item-form-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.item-form-grid {
  align-items: start;
}

.item-form-grid > * {
  align-self: start;
}

.filters-grid-compact {
  grid-template-columns: minmax(240px, 2fr) minmax(150px, 1.2fr) minmax(150px, 1.2fr) minmax(120px, 0.8fr);
  align-items: end;
  gap: 8px;
}

.filter-field {
  display: grid;
  gap: 4px;
}

.filter-field-wide {
  grid-column: auto;
}

.filter-label {
  font-size: 0.72rem;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 700;
}

.filter-field input,
.filter-field select {
  min-height: 40px;
}

.custom-dropdown {
  position: relative;
}

.dropdown-toggle {
  min-height: 40px;
  text-align: left;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  position: relative;
  padding-right: 34px;
}

.dropdown-toggle::after {
  content: "▾";
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 0.85rem;
}

.custom-dropdown.is-open .dropdown-toggle {
  border-color: #9fd8c8;
  box-shadow: 0 0 0 2px rgba(18, 107, 95, 0.16);
}

.dropdown-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 20;
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
}

.dropdown-panel[hidden] {
  display: none;
}

.dropdown-search {
  min-height: 36px;
  padding: 8px 10px;
}

.dropdown-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  max-height: 260px;
  overflow-y: auto;
}

.dropdown-option {
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
  cursor: pointer;
  font-weight: 500;
}

.dropdown-option:hover,
.dropdown-option:focus-visible {
  background: #eef8f4;
  outline: none;
}

.dropdown-option.is-selected {
  background: #dff3ec;
  color: #0f5a4f;
}

.dropdown-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.switch-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
}

input,
select,
textarea,
button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  background: #fff;
}

textarea {
  grid-column: 1 / -1;
}

button {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.btn-secondary {
  background: #fff;
  color: var(--text);
}

button.danger {
  background: var(--danger);
}

.delete-x {
  width: 30px;
  min-width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  font-weight: 800;
  line-height: 1;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 8px;
  grid-column: span 2;
  cursor: pointer;
}

.switch-row.switch-row-compact {
  display: grid;
  gap: 4px;
  grid-column: auto;
  align-items: start;
}

.switch-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-ui {
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: #cfd8d3;
  position: relative;
  transition: background 180ms ease;
}

.switch-ui::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 180ms ease;
}

.switch-row input:checked + .switch-ui {
  background: var(--accent);
}

.switch-row input:checked + .switch-ui::after {
  transform: translateX(20px);
}

.drop-zone {
  border: 2px dashed #9ecbc0;
  border-radius: 12px;
  padding: 16px;
  display: grid;
  gap: 8px;
  background: #f3fbf8;
}

.drop-zone input[type="file"] {
  border: none;
  padding: 0;
}

.profile-panel {
  display: grid;
  gap: 12px;
}

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

.profile-card,
.profile-empty {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
}

.profile-card {
  display: grid;
  gap: 8px;
  align-content: start;
  position: relative;
}

.profile-delete-form {
  position: absolute;
  top: 6px;
  right: 6px;
  margin: 0;
}

.btn-profile-delete {
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.btn-profile-delete:hover {
  background: var(--danger);
  color: #fff;
}

.profile-card h3 {
  margin: 0;
}

.profile-icon {
  font-size: 1.8rem;
  line-height: 1;
  margin: 0;
}

.profile-create-wrap {
  display: grid;
  gap: 10px;
}

.profile-create-wrap .btn-secondary {
  max-width: 240px;
}

.profile-create-form {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.profile-create-form button {
  grid-column: 1 / -1;
}

.is-hidden {
  display: none;
}

.table-wrap {
  overflow: auto;
}

.table-meta {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.92rem;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.sort-link {
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}

.sort-link:hover {
  color: var(--accent);
}

td small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

.low-row {
  background: #fff7ed;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 360px;
  opacity: 0;
  transform: translateX(4px);
  pointer-events: none;
  transition: opacity 140ms ease, transform 140ms ease;
}

.table-panel tbody tr:hover .actions,
.table-panel tbody tr:focus-within .actions {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.actions-main {
  display: grid;
  gap: 6px;
  flex: 1;
}

.actions-side {
  display: grid;
  gap: 6px;
  justify-items: end;
  align-content: center;
}

.actions-delete {
  margin: 0;
}

.actions-cell {
  vertical-align: middle;
}

.icon-btn {
  width: 30px;
  min-width: 30px;
  height: 30px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  text-decoration: none;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--accent);
  font-weight: 700;
  line-height: 1;
}

.icon-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.movement-inline {
  display: grid;
  grid-template-columns: 88px 68px 1fr 56px;
  gap: 4px;
}

.qty-cell {
  vertical-align: middle;
  min-width: 126px;
}

.qty-adjuster {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
}

.qty-btn {
  width: 28px;
  min-width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--accent);
  font-weight: 700;
  line-height: 1;
  padding: 0;
}

.qty-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.qty-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.qty-value {
  min-width: 34px;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 700;
}

.qty-status {
  display: block;
  margin-top: 4px;
  min-height: 1.1em;
  color: var(--muted);
  font-size: 0.76rem;
}

.qty-status.is-active {
  color: var(--accent);
}

.actions-loan {
  align-items: flex-start;
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.loan-inline-form {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(120px, 1fr) 136px 82px;
  gap: 4px;
}

.loan-inline-form input,
.loan-inline-form button {
  min-height: 34px;
  padding: 7px 9px;
}

.loan-combobox {
  position: relative;
}

.loan-combobox-panel {
  position: fixed;
  z-index: 60;
  margin: 0;
  padding: 4px;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
  max-height: 240px;
  overflow-y: auto;
  min-width: 140px;
}

.loan-combobox-panel[hidden] {
  display: none;
}

.loan-combobox-panel .dropdown-option {
  padding: 6px 8px;
}

.loan-combobox-empty {
  padding: 6px 8px;
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.loan-hover-only {
  transition: opacity 140ms ease, transform 140ms ease, max-height 140ms ease;
}

@media (hover: hover) {
  .loan-hover-only {
    opacity: 0;
    pointer-events: none;
    max-height: 0;
    overflow: hidden;
    transform: translateY(-2px);
  }

  .table-panel tbody tr:hover .loan-hover-only,
  .table-panel tbody tr:focus-within .loan-hover-only {
    opacity: 1;
    pointer-events: auto;
    max-height: 160px;
    overflow: visible;
    transform: translateY(0);
  }
}

@media (hover: none) {
  .loan-hover-only {
    opacity: 1;
    pointer-events: auto;
    max-height: none;
    overflow: visible;
    transform: none;
  }
}

.loan-inline-form button[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.loan-active-list {
  margin-top: 6px;
  display: grid;
  gap: 4px;
}

.loan-pill-form {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 3px 4px 3px 10px;
}

.loan-pill-meta {
  font-size: 0.82rem;
  color: var(--danger);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.loan-return-btn {
  width: auto;
  min-width: 72px;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 700;
}

.btn-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.form-intro {
  margin-top: -4px;
  color: var(--muted);
}

.form-subnote {
  margin: 0 0 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.form-meta-pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.82rem;
  color: var(--muted);
}

.item-form-layout {
  display: grid;
  gap: 14px;
}

.form-panel {
  max-width: 1120px;
  margin-inline: auto;
}

.form-section {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffcf5;
  padding: 12px;
  margin: 0;
}

.form-section legend {
  color: var(--accent);
  font-weight: 700;
  padding: 0 6px;
}

.form-field {
  display: grid;
  gap: 6px;
}

.form-field span {
  font-size: 0.9rem;
  color: var(--muted);
}

.item-form-layout .form-field input:not([type="hidden"]),
.item-form-layout .form-field select,
.item-form-layout .dropdown-toggle,
.item-form-layout .dropdown-search {
  min-height: 44px;
}

.field-hint {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.3;
}

.size-suggest-wrap {
  border: 1px dashed #b8c4bf;
  border-radius: 10px;
  padding: 8px;
  background: #f8fbfa;
}

.size-suggest-title {
  margin: 0 0 6px;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}

.size-suggest-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.size-suggest-chip {
  width: auto;
  min-height: 30px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid #9fd8c8;
  background: #eaf8f3;
  color: #0f5a4f;
  font-size: 0.84rem;
  font-weight: 600;
}

.size-suggest-chip:hover,
.size-suggest-chip:focus-visible {
  border-color: #6abda8;
  background: #dcf3eb;
}

.readonly-field input[readonly] {
  background: #f7f7f5;
  color: #4b5563;
}

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

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  align-items: center;
}

.form-actions-sticky {
  position: sticky;
  bottom: 8px;
  z-index: 5;
  background: rgba(255, 253, 248, 0.92);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  justify-content: space-between;
  backdrop-filter: blur(4px);
}

.form-actions-sticky .page-btn,
.form-actions-sticky button {
  width: auto;
  min-width: 140px;
  text-align: center;
}

.pagination-bar {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.page-btn {
  text-decoration: none;
  border: 1px solid var(--line);
  color: var(--text);
  background: #fff;
  border-radius: 10px;
  padding: 8px 10px;
}

.page-btn.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.page-info {
  color: var(--muted);
  padding: 0 4px;
}

.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 120;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 24px));
  pointer-events: none;
}

.toast {
  display: grid;
  grid-template-columns: 10px 1fr;
  align-items: center;
  gap: 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(5px);
  box-shadow: 0 10px 26px rgba(31, 41, 55, 0.18);
  color: var(--text);
  padding: 11px 12px;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  transition: opacity 180ms ease, transform 220ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.toast-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.toast p {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.35;
  font-weight: 600;
}

.toast-success {
  border-color: #8ad4c0;
}

.toast-success .toast-dot {
  background: #0f7c67;
}

.toast-error {
  border-color: #efb2ad;
}

.toast-error .toast-dot {
  background: #b42318;
}

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

@media (max-width: 960px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filters-grid,
  .item-form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filters-grid-compact {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .filters-grid-compact .filter-field-wide {
    grid-column: 1 / -1;
  }

  .dropdown-panel {
    position: static;
    margin-top: 6px;
    box-shadow: none;
  }

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

  .form-actions-sticky {
    bottom: 6px;
  }
}

@media (max-width: 640px) {
  .site-header {
    gap: 8px;
  }

  .site-nav {
    justify-content: flex-start;
  }

  .nav-secondary {
    width: 100%;
  }

  .profile-badge-name {
    max-width: 180px;
  }

  .active-profile-badge {
    gap: 5px;
  }

  .stats-grid,
  .filters-grid,
  .item-form-grid {
    grid-template-columns: 1fr;
  }

  .profile-create-form {
    grid-template-columns: 1fr;
  }

  .filters-grid-compact {
    gap: 10px;
  }

  .filters-grid-compact .filter-field-wide,
  .filters-grid-compact .switch-row-compact {
    grid-column: 1;
  }

  .dropdown-list {
    max-height: 220px;
  }

  .form-section {
    padding: 10px;
  }

  .form-subnote {
    gap: 6px;
  }

  .switch-row {
    grid-column: 1;
  }

  .movement-inline {
    grid-template-columns: 1fr;
  }

  .qty-cell {
    min-width: 0;
  }

  .qty-adjuster {
    gap: 8px;
    padding: 4px 6px;
  }

  .qty-btn {
    width: 30px;
    min-width: 30px;
    height: 30px;
  }

  .qty-value {
    min-width: 30px;
  }

  .qty-status {
    margin-top: 3px;
  }

  .loan-inline-form {
    grid-template-columns: 1fr;
  }

  .loan-pill-form {
    border-radius: 12px;
    align-items: stretch;
    flex-direction: column;
    padding: 8px;
  }

  .loan-pill-meta {
    white-space: normal;
  }

  .loan-return-btn {
    width: 100%;
  }

  .actions {
    display: grid;
    min-width: 0;
    gap: 8px;
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }

  .actions-delete {
    margin-left: 0;
    justify-self: start;
  }

  .actions-side {
    justify-items: start;
  }

  .pagination-bar {
    gap: 6px;
  }

  .page-btn {
    font-size: 0.9rem;
    padding: 7px 9px;
  }

  .form-actions-sticky {
    position: static;
    padding: 0;
    border: none;
    background: transparent;
    backdrop-filter: none;
    display: grid;
    gap: 8px;
  }

  .form-actions-sticky .page-btn,
  .form-actions-sticky button {
    width: 100%;
    min-width: 0;
  }

  .toast-stack {
    right: 10px;
    bottom: 10px;
    width: min(340px, calc(100vw - 20px));
  }
}

@media (hover: none) {
  .actions {
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }
}

@media (max-width: 480px) {
  .panel {
    padding: 12px;
  }

  .form-section {
    border-radius: 10px;
  }

  th,
  td {
    padding: 8px;
    font-size: 0.9rem;
  }

  .dropdown-toggle,
  .dropdown-search,
  .dropdown-option {
    font-size: 0.95rem;
  }

  .form-meta-pill {
    font-size: 0.76rem;
    padding: 3px 8px;
  }

  .toast {
    grid-template-columns: 8px 1fr;
    gap: 8px;
    border-radius: 10px;
    padding: 10px;
  }

  .toast p {
    font-size: 0.88rem;
  }

  .qty-adjuster {
    gap: 6px;
    padding: 3px 5px;
  }

  .qty-btn {
    width: 28px;
    min-width: 28px;
    height: 28px;
  }

  .qty-status {
    font-size: 0.72rem;
  }
}

@media (max-width: 360px) {
  .nav-link {
    width: 100%;
    text-align: center;
    justify-content: center;
  }

  .pagination-bar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .page-btn {
    text-align: center;
  }

  .form-section legend {
    font-size: 0.92rem;
  }

  .dropdown-panel {
    padding: 8px;
  }

  .field-hint {
    font-size: 0.74rem;
  }

  .toast-stack {
    right: 8px;
    bottom: 8px;
    width: calc(100vw - 16px);
  }

  .qty-adjuster {
    gap: 5px;
  }

  .qty-value {
    min-width: 26px;
    font-size: 0.88rem;
  }
}

/* ===== Management pages: Suppliers / Locations ===== */

.btn-sm {
  width: auto;
  padding: 6px 14px;
  font-size: 0.88rem;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.muted-text {
  color: var(--muted);
  font-size: 0.92rem;
  margin: 0 0 8px;
}

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

.lookup-page-header h2 {
  margin: 0;
}

.lookup-count-badge {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.85rem;
  font-weight: 700;
  vertical-align: middle;
}

.lookup-section {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  margin-top: 16px;
}

.lookup-section h3 {
  margin: 0 0 10px;
  font-size: 1rem;
  color: var(--text);
}

.merge-form {
  display: block;
}

.merge-fields {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.merge-field-group {
  display: grid;
  gap: 4px;
  flex: 1;
  min-width: 160px;
}

.merge-arrow {
  font-size: 1.5rem;
  color: var(--muted);
  padding-bottom: 6px;
  flex-shrink: 0;
  align-self: flex-end;
}

.merge-submit-wrap {
  display: grid;
  gap: 4px;
  flex-shrink: 0;
}

.merge-submit-spacer {
  visibility: hidden;
  display: block;
  line-height: 1;
}

.merge-submit-wrap button {
  width: auto;
  white-space: nowrap;
}

.add-inline-form {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.add-inline-form input[type="text"] {
  flex: 1;
}

.add-inline-form button {
  width: auto;
  white-space: nowrap;
}

.lookup-table {

  .lookup-check-th,
  .lookup-check-td {
    width: 36px;
    text-align: center;
    vertical-align: middle;
    padding-left: 6px;
    padding-right: 2px;
  }

  .merge-check-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }

  .merge-check-label input[type="checkbox"] {
    width: 16px;
    min-height: 16px;
    padding: 0;
    border-radius: 4px;
    cursor: pointer;
    accent-color: var(--accent);
  }

  width: 100%;
}

.lookup-count-th,
.lookup-actions-th {
  white-space: nowrap;
}

.lookup-count-th {
  width: 90px;
  text-align: right;
}

.lookup-actions-th {
  width: 120px;
  text-align: right;
}

.lookup-count-td {
  text-align: right;
  color: var(--muted);
  vertical-align: middle;
}

.lookup-actions-td {
  text-align: right;
  vertical-align: middle;
}

.merge-reason {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.merge-reason.reason-alias {
  background: #eef8f4;
  border-color: #9fd8c8;
  color: #0f5a4f;
}

.merge-reason.reason-ocr {
  background: #f0f7ff;
  border-color: #a8c9f0;
  color: #1f4f80;
}

.merge-reason.reason-accent {
  background: #f5f0ff;
  border-color: #ccb8f2;
  color: #4d2d80;
}

.merge-reason.reason-typo {
  background: #fff7ed;
  border-color: #f2d3a2;
  color: #8a4a16;
}

.lookup-actions-td form {
  display: inline;
}

.inline-rename-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.rename-input {
  flex: 1;
  padding: 6px 10px;
  font-size: 0.92rem;
}

.inline-rename-form button {
  width: auto;
  white-space: nowrap;
  flex-shrink: 0;
}

.dropdown-count {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 400;
  margin-left: 8px;
}

@media (max-width: 640px) {
  .merge-fields {
    flex-direction: column;
    gap: 10px;
  }

  .merge-arrow {
    align-self: auto;
    padding-bottom: 0;
    font-size: 1.2rem;
  }

  .merge-field-group {
    width: 100%;
  }

  .merge-submit-wrap {
    width: 100%;
  }

  .merge-submit-wrap button,
  .add-inline-form button {
    width: 100%;
  }

  .lookup-page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .inline-rename-form {
    flex-wrap: wrap;
  }

  .rename-input {
    min-width: 0;
  }
}

