:root {
  --brand: #2e7d32;
  --brand-light: #43a047;
  --brand-dark: #1b5e20;
  --brand-bg: #f1f8e9;
  --brand-bg2: #e8f5e9;
  --blue: #1565c0;
  --text: #212121;
  --text-secondary: #616161;
  --text-muted: #9e9e9e;
  --border: #e0e0e0;
  --border-light: #eeeeee;
  --bg: #ffffff;
  --bg-gray: #fafafa;
  --radius: 6px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---- Top Bar ---- */
.topbar {
  background: var(--brand-dark);
  color: #fff;
  font-size: .75rem;
}

.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: .4rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.topbar a {
  color: rgba(255,255,255,.85);
  text-decoration: none;
  transition: color .15s;
}

.topbar a:hover { color: #fff; }

/* ---- Header ---- */
.header {
  background: var(--bg);
  border-bottom: 2px solid var(--brand);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: .8rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  text-decoration: none;
  color: var(--text);
  flex-shrink: 0;
}

.header-brand .logo-text {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--brand-dark);
  letter-spacing: -.02em;
}

.header-brand .logo-sub {
  font-size: .7rem;
  color: var(--text-secondary);
  font-weight: 400;
  display: block;
  margin-top: -.15rem;
}

.header-nav {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.header-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: .85rem;
  font-weight: 500;
  transition: color .15s;
}

.header-nav a:hover { color: var(--brand); }

/* ---- Hero Banner ---- */
.hero-banner {
  background: linear-gradient(135deg, var(--brand-dark) 0%, var(--brand) 60%, var(--brand-light) 100%);
  color: #fff;
  padding: 2.5rem 2rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero-banner::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle 400px at 15% 50%, rgba(255,255,255,.08), transparent),
    radial-gradient(circle 300px at 85% 30%, rgba(255,255,255,.05), transparent);
  pointer-events: none;
}

.hero-banner h1 {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: .4rem;
  position: relative;
}

.hero-banner p {
  font-size: .95rem;
  opacity: .9;
  position: relative;
  max-width: 600px;
  margin: 0 auto;
}

/* ---- Search Section ---- */
.search-section {
  background: var(--bg-gray);
  border-bottom: 1px solid var(--border-light);
  padding: 1.5rem 0;
}

.search-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 2rem;
}

.search-row {
  display: flex;
  gap: .75rem;
  align-items: stretch;
}

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

.search-input-wrap .search-icon {
  position: absolute;
  left: 1.1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input-wrap input {
  width: 100%;
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.2rem 1rem 3.2rem;
  font-size: 1.05rem;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.search-input-wrap input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(46,125,50,.1);
}

.search-input-wrap input::placeholder { color: var(--text-muted); }

.search-row select {
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 1rem 2.2rem 1rem 1rem;
  font-size: 1.05rem;
  color: var(--text);
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23616161' viewBox='0 0 16 16'%3E%3Cpath d='M1.5 5.5l6.5 6 6.5-6'/%3E%3C/svg%3E") no-repeat right 1rem center;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  cursor: pointer;
  min-width: 220px;
  transition: border-color .15s;
}

.search-row select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(46,125,50,.1);
}

.search-btn {
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 1rem 2rem;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
  letter-spacing: .05em;
}

.search-btn:hover { background: var(--brand-dark); }

/* ---- Quick Tags ---- */
.quick-tags {
  margin-top: .75rem;
  display: flex;
  align-items: center;
  gap: .45rem;
  flex-wrap: wrap;
}

.quick-tags .label {
  font-size: .78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.quick-tag {
  display: inline-block;
  padding: .2rem .55rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--bg);
  color: var(--text-secondary);
  font-size: .76rem;
  cursor: pointer;
  transition: all .12s;
  white-space: nowrap;
}

.quick-tag:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-bg);
}

.quick-tag code {
  font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
  font-size: .74rem;
  color: var(--blue);
  font-weight: 500;
}

.quick-tag:hover code { color: var(--brand-dark); }

/* ---- Results Info ---- */
.results-bar {
  max-width: 1400px;
  margin: 0 auto;
  padding: .7rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .82rem;
  color: var(--text-secondary);
}

.results-bar strong {
  color: var(--brand);
  font-weight: 700;
}

.results-bar .hint {
  color: var(--text-muted);
  font-weight: 400;
}

/* ---- Table ---- */
.table-section {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 2rem 2rem;
}

.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}

thead {
  background: var(--brand-dark);
  color: #fff;
}

thead th {
  padding: .75rem .9rem;
  text-align: left;
  font-weight: 600;
  font-size: .88rem;
  letter-spacing: .02em;
  white-space: nowrap;
}

tbody tr {
  transition: background .1s;
}

tbody tr:nth-child(even) {
  background: #f5f5f5;
}

tbody tr:hover {
  background: var(--brand-bg2);
}

tbody td {
  padding: .55rem .9rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

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

.col-id {
  width: 46px;
  color: var(--text-muted);
  text-align: center;
  font-size: .78rem;
}

thead th[class] { color: #fff; }
thead .col-id { text-align: center; }

.col-gene {
  max-width: 200px;
  font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
  font-size: .8rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.col-species {
  color: var(--text);
  font-style: italic;
}

.col-cat {
  font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
  font-weight: 600;
  color: var(--brand);
  white-space: nowrap;
}

.col-product { color: var(--text); }

.col-size {
  white-space: nowrap;
  color: var(--text-secondary);
  width: 72px;
}

.col-price {
  white-space: nowrap;
  font-weight: 600;
  color: #c62828;
  text-align: right;
  width: 90px;
}

mark {
  background: #fff9c4;
  color: var(--text);
  border-radius: 2px;
  padding: 0 1px;
}

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

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: .75rem;
  opacity: .3;
}

.empty-state h3 {
  margin: 0 0 .25rem;
  color: var(--text-secondary);
  font-size: .95rem;
  font-weight: 600;
}

.empty-state p {
  margin: 0;
  font-size: .85rem;
}

/* ---- Loading ---- */
.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(255,255,255,.5);
  justify-content: center;
  align-items: center;
}

.loading-overlay.active { display: flex; }

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

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

/* ---- Table row cursor for dblclick ---- */
tbody tr { cursor: pointer; }

/* ---- Modal ---- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,.45);
  justify-content: center;
  align-items: center;
  padding: 1rem;
}

.modal-overlay.active { display: flex; }

.modal-box {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  position: relative;
  animation: modalIn .2s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(20px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-close {
  position: absolute;
  top: .75rem;
  right: .75rem;
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg-gray);
  border-radius: 50%;
  font-size: 1.2rem;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
  line-height: 1;
}

.modal-close:hover {
  background: var(--border);
  color: var(--text);
}

.modal-header {
  padding: 1.5rem 1.5rem .75rem;
  border-bottom: 1px solid var(--border-light);
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--brand-dark);
  margin-bottom: .35rem;
}

.modal-product {
  font-size: .82rem;
  color: var(--text-secondary);
  background: var(--bg-gray);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: .45rem .7rem;
  display: inline-block;
  line-height: 1.4;
}

.modal-product strong {
  color: var(--brand);
  font-weight: 600;
}

#quoteForm {
  padding: 1rem 1.5rem 1.5rem;
}

.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: .3rem;
}

.form-group label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text);
}

.form-group .req {
  color: #c62828;
}

.form-group input,
.form-group textarea,
.form-group select {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .6rem .75rem;
  font-size: .88rem;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
  resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(46,125,50,.1);
}

.form-group select {
  width: 100%;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .75rem center;
  padding-right: 2rem;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-muted);
}

.form-full {
  margin-top: .75rem;
}

.modal-tip {
  margin-top: .75rem;
  font-size: .76rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.modal-tip a {
  color: var(--brand);
  text-decoration: none;
}

.modal-tip strong {
  color: var(--text-secondary);
}

.modal-actions {
  margin-top: 1.25rem;
  display: flex;
  justify-content: flex-end;
  gap: .6rem;
}

.btn-cancel {
  padding: .6rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text-secondary);
  font-size: .88rem;
  cursor: pointer;
  transition: all .15s;
}

.btn-cancel:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.btn-submit {
  padding: .6rem 1.5rem;
  border: none;
  border-radius: var(--radius);
  background: var(--brand);
  color: #fff;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}

.btn-submit:hover { background: var(--brand-dark); }

.btn-submit:disabled {
  opacity: .5;
  cursor: not-allowed;
}

@media (max-width: 580px) {
  .modal-box { max-width: 100%; }
  .modal-grid { grid-template-columns: 1fr; }
  .modal-header { padding: 1.25rem 1rem .75rem; }
  #quoteForm { padding: 1rem; }
}

/* ---- Footer ---- */
.footer {
  background: #333;
  color: rgba(255,255,255,.7);
  padding: 1.5rem 2rem;
  font-size: .78rem;
  text-align: center;
}

.footer a {
  color: #a5d6a7;
  text-decoration: none;
}

.footer a:hover { text-decoration: underline; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .topbar { display: none; }
  .header-inner { padding: .6rem 1rem; }
  .header-nav { display: none; }
  .hero-banner { padding: 1.5rem 1rem; }
  .hero-banner h1 { font-size: 1.3rem; }
  .search-section { padding: 1rem; }
  .search-row { flex-direction: column; }
  .search-row select { min-width: 0; width: 100%; }
  .search-input-wrap input,
  .search-row select,
  .search-btn { font-size: .95rem; padding-top: .85rem; padding-bottom: .85rem; }
  .results-bar { padding: .6rem 1rem; }
  .table-section { padding: 0 1rem 1rem; }
  thead th, tbody td { padding: .45rem .5rem; font-size: .78rem; }
  .col-id { display: none; }
}
