:root {
  --bg: #f5f2eb;
  --surface: #fffdf8;
  --ink: #1a1a18;
  --ink-muted: #6b6860;
  --accent: #7FB157;
  --accent-light: #e8f0ea;
  --accent2: #c17f3a;
  --border: #d4cfc4;
  --red: #c0392b;
  --red-light: #fff0f0;
  --sel: rgba(45, 90, 61, 0.15);
  --sel-b: #7FB157;
  --multi: rgba(45, 90, 61, 0.08);
  --fill: #c6dfc6;
  --fill-b: #7FB157;
}

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'DM Mono', monospace;
  font-weight: 300;
  min-height: 100vh;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: 
    linear-gradient(rgba(45, 90, 61, .04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(45, 90, 61, .04) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

.page-wrap {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 60px 24px 80px;
}

header {
  margin-bottom: 52px;
}

.lab-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 4px 10px;
  border-radius: 10px;
  margin-bottom: 20px;
}

h1 {
  font-family: 'DM Serif Display', serif;
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  line-height: 1.08;
  letter-spacing: -.02em;
  margin-bottom: 14px;
}

h1 em {
  font-style: italic;
  color: var(--accent);
}

.subtitle {
  font-size: 13px;
  color: var(--ink-muted);
  line-height: 1.7;
  max-width: 520px;
}

.divider {
  width: 48px;
  height: 2px;
  background: var(--accent);
  margin: 24px 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 36px 40px;
  box-shadow: 0 2px 20px rgba(0, 0, 0, .04);
  margin-bottom: 20px;
}

.section-label {
  font-size: 9px;
  font-weight: 500;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--accent2);
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

label .req {
  color: var(--accent2);
  margin-left: 2px;
}

input[type="text"],
input[type="email"] {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  font-weight: 300;
  color: var(--ink);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  width: 100%;
}

input[type="text"]:focus,
input[type="email"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(45, 90, 61, .1);
}

/* FASTA uploader */
.fasta-uploader {
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  background: var(--bg);
  transition: all .2s;
  position: relative;
}

.fasta-uploader.drag-over {
  border-color: var(--accent);
  background: var(--accent-light);
}

.fasta-uploader input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
}

.fasta-drop-row {
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: none;
}

.fasta-drop-icon {
  font-size: 20px;
}

.fasta-drop-text {
  font-size: 12px;
  color: var(--ink-muted);
  line-height: 1.5;
}

.fasta-drop-text strong {
  color: var(--accent);
  font-weight: 500;
}

.fasta-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

.fchip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #1a1a18;
  border-radius: 10px;
  padding: 4px 9px;
  font-size: 11px;
  cursor: pointer;
  transition: background .15s;
  position: relative;
}

.fchip:hover {
  background: #2e2e2a;
}

.fchip-hint {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  font-size: 9px;
  padding: 3px 8px;
  border-radius: 10px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity .15s;
  pointer-events: none;
  letter-spacing: .04em;
}

.fchip-hint::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: var(--ink);
}

.fchip:hover .fchip-hint {
  opacity: 1;
}

.fchip-name {
  color: #69b8f7;
  white-space: nowrap;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fchip-x {
  background: none;
  border: none;
  color: #666;
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  padding: 0 1px;
  transition: color .15s;
}

.fchip-x:hover {
  color: #ff6b6b;
}

.fasta-count {
  font-size: 10px;
  color: var(--ink-muted);
  margin-top: 8px;
}

.fasta-count strong {
  color: var(--accent);
}
/* ═══ GRID ═══ */

.sheet-hints {
  font-size: 10px;
  color: var(--ink-muted);
  margin-bottom: 9px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.sheet-hints span {
  opacity: .75;
}
.sheet-hints span::before {
  content: '↳ ';
}

.grid-wrap {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  user-select: none;
}
.grid-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  table-layout: fixed;
}
.grid-table col.c-n  { width: 32px; }
.grid-table col.c-pr { width: 15%; }
.grid-table col.c-pl { width: 17%; }
.grid-table col.c-fa { width: 14%; }
.grid-table col.c-pt { width: 98px; }
.grid-table col.c-lo { width: 72px; }
.grid-table col.c-dl { width: 28px; }

.grid-table thead th {
  background: var(--accent);
  color: #fff;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: .13em;
  text-transform: uppercase;
  padding: 9px 8px;
  text-align: left;
  border-right: 1px solid rgba(255, 255, 255, .12);
  white-space: nowrap;
  overflow: hidden;
}
.grid-table thead th:last-child {
  border-right: none;
}
.grid-table thead th .opt {
  font-weight: 300;
  opacity: .55;
  font-size: 8px;
  letter-spacing: .05em;
  margin-left: 3px;
}

.grid-table td.rn {
  background: #f0ece4;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  text-align: center;
  font-size: 10px;
  color: var(--ink-muted);
  padding: 0;
  vertical-align: middle;
}
.grid-table td.dc {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 0;
  vertical-align: middle;
  position: relative;
  cursor: cell;
  background: var(--surface);
}
.grid-table td.dc:last-of-type {
  border-right: none;
}
.grid-table tbody tr:last-child td {
  border-bottom: none;
}
.grid-table tbody tr:nth-child(even) td.dc {
  background: #faf8f3;
}
.grid-table tbody tr:nth-child(even) td.rn {
  background: #ebe8e0;
}


/* selection states */

.dc.active  {
  background: #fff !important;
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  z-index: 4;
}
.dc.sel {
  background: var(--sel) !important;
  outline: 2px solid var(--sel-b);
  outline-offset: -2px;
  z-index: 2;
}
.dc.in-sel {
  background: var(--multi) !important;
  z-index: 1;
}
.dc.err {
  background: var(--red-light) !important;
  outline: 2px solid var(--red);
  outline-offset: -2px;
}
.dc.fill-pre {
  background: var(--fill) !important;
  outline: 1px dashed var(--fill-b);
  outline-offset: -1px;
}


/* error tooltip */

.etip {
  display: none;
  position: absolute;
  bottom: calc(100% + 5px);
  left: 0;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  padding: 3px 9px;
  border-radius: 10px;
  white-space: nowrap;
  z-index: 30;
  pointer-events: none;
  letter-spacing: .03em;
}
.etip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 10px;
  border: 5px solid transparent;
  border-top-color: var(--red);
}
.dc.err .etip {
  display: block;
}


/* drag handle */

.dh {
  position: absolute;
  bottom: -4px;
  right: -4px;
  width: 8px;
  height: 8px;
  background: var(--sel-b);
  border: 1.5px solid #fff;
  border-radius: 1px;
  cursor: crosshair;
  z-index: 10;
  display: none;
}
.dc.sel .dh,
.dc.active .dh {
  display: block;
}


/* cell inner */

.ci {
  min-height: 30px;
  padding: 5px 8px;
  outline: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  font-weight: 300;
  color: var(--ink);
  cursor: cell;
  line-height: 20px;
}
.ci:empty::before {
  content: attr(data-ph);
  color: #c0bab2;
  pointer-events: none;
}
.dc.active .ci {
  cursor: text;
  white-space: pre;
  overflow: auto;
}


/* plate select */

.psel {
  width: 100%;
  height: 30px;
  border: none;
  outline: none;
  background: transparent;
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  font-weight: 300;
  color: var(--ink);
  cursor: pointer;
  padding: 0 22px 0 8px;
  appearance: none;
  -webkit-appearance: none;
}
td.dc[data-col="plate"]::after {
  content: '▾';
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 9px;
  color: var(--ink-muted);
  pointer-events: none;
}


/* del cell */

.grid-table td.dlc {
  border-bottom: 1px solid var(--border);
  text-align: center;
  vertical-align: middle;
  padding: 0;
}
.bdel {
  background: none;
  border: none;
  color: #ccc;
  font-size: 13px;
  cursor: pointer;
  padding: 3px 5px;
  transition: color .15s;
}
.bdel:hover {
  color: var(--red);
}


/* toolbar */

.grid-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 11px;
  flex-wrap: wrap;
}
.badd {
  background: none;
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 7px 16px;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .1em;
  border-radius: 10px;
  cursor: pointer;
  transition: all .2s;
}
.badd:hover {
  background: var(--accent);
  color: #fff;
}
.ginfo {
  font-size: 10px;
  color: var(--ink-muted);
  margin-left: auto;
}


/* context menu */

#ctx {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, .13);
  font-size: 12px;
  min-width: 210px;
  z-index: 999;
  display: none;
  overflow: hidden;
}
#ctx.on {
  display: block;
}
.ci-item {
  padding: 8px 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  transition: background .1s;
}
.ci-item:hover {
  background: var(--accent-light);
  color: var(--accent);
}
.ci-item.off {
  opacity: .35;
  pointer-events: none;
}
.ci-icon {
  font-size: 12px;
  width: 15px;
  text-align: center;
}
.ci-sep {
  height: 1px;
  background: var(--border);
  margin: 3px 0;
}
.ci-lbl {
  font-size: 9px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-muted);
  padding: 7px 15px 3px;
}


/* submission bar */

.sub-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.bsub {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 13px 32px;
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .12em;
  text-transform: uppercase;
  border-radius: 10px;
  cursor: pointer;
  transition: background .2s, transform .1s;
}
.bsub:hover {
  background: #234830;
}
.bsub:active {
  transform: scale(.98);
}
.bsub.busy {
  pointer-events: none;
  opacity: .7;
}
.fnote {
  font-size: 11px;
  color: var(--ink-muted);
}


/* report panel */

#reportPanel {
  margin-top: 20px;
}
#reportPanel.on {
  display: block;
}
.report-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}
.report-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.5rem;
}
.report-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.rbtn {
  background: none;
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 7px 16px;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .08em;
  border-radius: 10px;
  cursor: pointer;
  transition: all .2s;
}
.rbtn:hover {
  background: var(--accent);
  color: #fff;
}
.rbtn.danger {
  border-color: var(--red);
  color: var(--red);
}
.rbtn.danger:hover {
  background: var(--red);
  color: #fff;
}

.report-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.rtable {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
  table-layout: auto;
}
.rtable thead th {
  background: var(--accent);
  color: #fff;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: .13em;
  text-transform: uppercase;
  padding: 9px 10px;
  text-align: left;
  border-right: 1px solid rgba(255, 255, 255, .12);
  white-space: nowrap;
}
.rtable thead th:last-child {
  border-right: none;
}
.rtable tbody tr {
  border-bottom: 1px solid var(--border);
}
.rtable tbody tr:last-child {
  border-bottom: none;
}
.rtable tbody tr:nth-child(even) {
  background: #faf8f3;
}
.rtable td {
  padding: 7px 10px;
  vertical-align: middle;
  white-space: nowrap;
}
.rtable td.plate-group-start {
  border-top: 2px solid var(--accent);
}
.plate-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid #c0d8c4;
}
.empty-report {
  text-align: center;
  padding: 40px 20px;
  color: var(--ink-muted);
  font-size: 13px;
}

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--ink);
  color: #fff;
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  padding: 12px 22px;
  border-radius: 10px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, .2);
  opacity: 0;
  transition: all .25s;
  pointer-events: none;
  z-index: 1000;
  white-space: nowrap;
}
.toast.on {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.ok::before  { content: '✓  '; color: #6be87d; }
.toast.bad::before { content: '✗  '; color: #ff6b6b; }
.toast.inf::before { content: 'ℹ  '; color: #69b8f7; }


@media (max-width: 640px) {
  .card { padding: 24px 16px; }
  .field-row { grid-template-columns: 1fr; }
}