:root {
  --ink: #10252e;
  --ink-soft: #536a73;
  --paper: #eaf2f4;
  --paper-deep: #d7e5e9;
  --card: #fbfeff;
  --line: #b9cdd3;
  --blue: #0d5b78;
  --blue-deep: #062b3a;
  --aqua: #7bdce4;
  --orange: #ff7546;
  --gold: #d7b55d;
  --green: #1f765f;
  --green-deep: #124a3a;
  --red: #9c3b34;
  --red-soft: #fae8e5;
  --shadow: 0 18px 44px rgba(7, 44, 57, .13);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% -20%, rgba(123, 220, 228, .22), transparent 36%),
    linear-gradient(rgba(13, 91, 120, .05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(13, 91, 120, .05) 1px, transparent 1px),
    var(--paper);
  background-size: auto, 32px 32px, 32px 32px, auto;
  font-family: "Avenir Next", Avenir, "Segoe UI", sans-serif;
}

button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }

button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 3px solid rgba(255, 117, 70, .35);
  outline-offset: 2px;
}

.mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 90px;
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.brand { display: flex; align-items: baseline; gap: 10px; }

.brand h1 {
  margin: 0;
  color: var(--blue-deep);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -.02em;
}

.brand span {
  color: var(--ink-soft);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.auth-box { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.who { color: var(--ink-soft); }
.who strong { color: var(--ink); }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 10px 16px;
  color: var(--blue-deep);
  background: var(--aqua);
  font-size: 13px;
  font-weight: 800;
  transition: transform .14s ease, box-shadow .14s ease, opacity .14s ease;
}

.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(7,44,57,.18); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.secondary { color: var(--blue-deep); background: white; border-color: var(--line); }
.btn.secondary:hover { box-shadow: 0 6px 14px rgba(7,44,57,.10); }
.btn.danger { color: white; background: var(--red); border-color: #6d241c; }
.btn.small { padding: 7px 11px; font-size: 12px; }

/* ---------- panels / cards ---------- */

.panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.notice {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
  margin-bottom: 18px;
  border: 1px solid #94c8d2;
  border-radius: 16px;
  padding: 14px 16px;
  background: #e8f7fa;
  font-size: 13px;
  line-height: 1.55;
}

.notice strong { display: block; color: var(--blue-deep); margin-bottom: 2px; }
.notice p { margin: 0; color: #385a64; }

/* ---------- auth forms ---------- */

.auth-panel { max-width: 420px; margin: 40px auto; }
.auth-panel h2 { margin: 0 0 6px; color: var(--blue-deep); font-family: Georgia, serif; font-size: 26px; }
.auth-panel p.sub { margin: 0 0 18px; color: var(--ink-soft); font-size: 13px; }

.field-group { display: grid; gap: 6px; margin-bottom: 14px; }
.field-group label {
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.field-group input, .field-group select, .field-group textarea {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 12px;
  color: var(--ink);
  background: white;
  font-size: 14px;
}
.field-group textarea { resize: vertical; min-height: 60px; }

.form-error {
  display: none;
  margin: 0 0 14px;
  border: 1px solid #d79a92;
  border-radius: 9px;
  padding: 10px 12px;
  color: #6d241c;
  background: var(--red-soft);
  font-size: 13px;
}
.form-error[data-visible="true"] { display: block; }

.switcher { margin-top: 14px; color: var(--ink-soft); font-size: 13px; }
.switcher a { color: var(--blue); font-weight: 700; text-decoration: none; cursor: pointer; }

/* ---------- quick reference bar (your group purchases) ---------- */

.my-groups-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: var(--paper-deep);
}

.my-groups-label {
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .07em;
  text-transform: uppercase;
  white-space: nowrap;
}

.my-group-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  color: var(--ink);
  background: var(--card);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  transition: transform .12s ease, box-shadow .12s ease;
}
.my-group-chip:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(7,44,57,.10); }
.my-group-chip .chip-date { color: var(--orange); font-family: "SFMono-Regular", Consolas, monospace; font-size: 11px; font-weight: 800; }

/* ---------- list page ---------- */

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 8px 0 18px;
}

.section-head h2 { margin: 0; color: var(--blue-deep); font-family: Georgia, serif; font-size: 30px; }
.section-head p { margin: 6px 0 0; max-width: 480px; color: var(--ink-soft); font-size: 13px; line-height: 1.5; }

.gp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.gp-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px 18px 16px;
  background: var(--card);
  box-shadow: 0 10px 24px rgba(7,44,57,.07);
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}
.gp-card:hover { transform: translateY(-3px); box-shadow: 0 16px 30px rgba(7,44,57,.13); }

.stamp {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border: 2px dashed var(--orange);
  border-radius: 50%;
  color: var(--blue-deep);
  transform: rotate(9deg);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 9px;
  font-weight: 800;
  line-height: 1.15;
  text-align: center;
  text-transform: uppercase;
}

.gp-vendor {
  color: var(--blue);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.gp-title { max-width: 78%; margin: 6px 0 0; color: var(--blue-deep); font-family: Georgia, serif; font-size: 21px; line-height: 1.15; }

.gp-meta { display: flex; gap: 10px; margin-top: 14px; color: var(--ink-soft); font-size: 12px; }

.status-chip { display: inline-flex; border-radius: 999px; padding: 3px 9px; font-size: 11px; font-weight: 700; }
.status-chip[data-status="open"] { color: #1f5c3d; background: #e2f2e7; }
.status-chip[data-status="closed"] { color: #6d5411; background: #f8ecc9; }
.status-chip[data-status="ordered"] { color: #29506e; background: #dfeaf3; }

.empty-state { border: 1px dashed var(--line); border-radius: 16px; padding: 40px; text-align: center; color: var(--ink-soft); }

/* ---------- detail page: masthead + KPIs ---------- */

.back-link { display: inline-block; margin-bottom: 14px; color: var(--ink-soft); font-size: 13px; text-decoration: none; }
.back-link:hover { color: var(--blue); }

.detail-masthead {
  position: relative;
  overflow: hidden;
  margin-bottom: 20px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 20px;
  padding: 24px 26px;
  color: white;
  background: linear-gradient(115deg, var(--blue), var(--blue-deep));
  box-shadow: var(--shadow);
}

.detail-masthead .gp-vendor { color: var(--aqua); }
.detail-masthead h2 { margin: 6px 0 0; font-family: Georgia, serif; font-size: 32px; line-height: 1.1; }

.detail-masthead-row {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 18px;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.kpi {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  background: var(--card);
}

.kpi .value { display: block; color: var(--blue-deep); font-family: Georgia, serif; font-size: 26px; font-weight: 700; }
.kpi .label { display: block; margin-top: 4px; color: var(--ink-soft); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }

.testing-box {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  background: var(--card);
}
.testing-box strong { display: block; color: var(--blue-deep); font-size: 14px; }
.testing-box p { margin: 3px 0 0; color: var(--ink-soft); font-size: 12px; line-height: 1.5; }

.toggle-group { display: flex; gap: 6px; margin-left: auto; }
.toggle-group button {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--ink-soft);
  background: white;
  font-size: 12px;
  font-weight: 700;
}
.toggle-group button[data-active="true"] { border-color: var(--green-deep); color: white; background: var(--green); }

/* ---------- participants panel ---------- */

.participants-panel { margin-bottom: 20px; }
.participants-panel h3 { margin: 0 0 10px; color: var(--blue-deep); font-family: Georgia, serif; font-size: 18px; }
.participant-list { display: flex; flex-wrap: wrap; gap: 8px; }
.participant-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  background: var(--card);
  font-size: 13px;
  font-weight: 700;
}
.participant-chip .testing-dot { width: 8px; height: 8px; border-radius: 50%; background: #bcd0d6; }
.participant-chip[data-testing="true"] .testing-dot { background: var(--green); }

/* ---------- controls bar (search / jump / filter) ---------- */

.controls {
  position: sticky;
  z-index: 10;
  top: 12px;
  display: grid;
  grid-template-columns: minmax(200px, 1fr) minmax(220px, 1.4fr) minmax(180px, 1fr);
  gap: 10px;
  margin: 20px 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  background: rgba(251, 254, 255, .94);
  box-shadow: 0 12px 30px rgba(7,44,57,.10);
  backdrop-filter: blur(10px);
}

.controls label { display: block; }

.control-label {
  display: block;
  margin: 0 0 5px 2px;
  color: var(--ink-soft);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.controls select, .controls input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  color: var(--ink);
  background: white;
  font-weight: 700;
  font-size: 13px;
}

/* ---------- compound cards (one per peptide) ---------- */

.section-label {
  margin: 0 0 8px;
  color: var(--orange);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.compound-grid { display: grid; gap: 20px; margin-top: 6px; }

.compound-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  box-shadow: 0 13px 30px rgba(7,44,57,.08);
}

.compound-top {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 16px 20px;
  background: linear-gradient(115deg, var(--blue), var(--blue-deep));
}

.compound-code {
  display: inline-block;
  margin-bottom: 5px;
  color: var(--aqua);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.compound-top h3 { margin: 0; color: white; font-family: Georgia, serif; font-size: 24px; letter-spacing: -.01em; }

.compound-badges { display: flex; gap: 8px; align-items: center; }

.count-badge {
  display: grid;
  place-items: center;
  min-width: 36px;
  height: 36px;
  border-radius: 11px;
  color: white;
  background: var(--orange);
  font-family: Georgia, serif;
  font-size: 16px;
  font-weight: 700;
  padding: 0 8px;
}

.kits-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 999px;
  padding: 5px 10px;
  color: #dff7f4;
  background: rgba(0,0,0,.16);
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.size-table-wrap { overflow-x: auto; }

.size-table { width: 100%; min-width: 640px; border-collapse: collapse; }
.size-table th, .size-table td { border-bottom: 1px solid var(--line); padding: 13px 18px; text-align: left; vertical-align: top; }
.size-table th {
  color: var(--ink-soft);
  background: var(--paper-deep);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.size-table tr:last-child td { border-bottom: 0; }

.size-name { display: block; color: var(--blue-deep); font-family: Georgia, serif; font-size: 18px; font-weight: 700; white-space: nowrap; }
.size-spec { display: block; margin-top: 3px; color: var(--ink-soft); font-family: "SFMono-Regular", Consolas, monospace; font-size: 10px; }

.buyer-list { display: flex; flex-wrap: wrap; gap: 6px; }
.buyer-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 5px 10px;
  color: #10404d;
  background: #d9f1f3;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.buyer-chip .testing-dot { width: 7px; height: 7px; border-radius: 50%; background: #9bbdc4; }
.buyer-chip[data-testing="true"] .testing-dot { background: var(--green); }
.buyer-chip .kit-count { color: var(--orange); }

.no-buyers { color: var(--ink-soft); font-size: 12px; }

.price-display {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid #c8dce0;
  border-radius: 10px;
  padding: 7px 10px;
  color: #10404d;
  background: #f6fbfb;
  font-size: 13px;
  font-weight: 800;
}

.price-input {
  width: 100px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  font-size: 13px;
}

.kit-cap { display: block; margin-top: 4px; color: var(--ink-soft); font-size: 10px; }

.kit-input { width: 62px; border: 1px solid var(--line); border-radius: 7px; padding: 6px 8px; font-size: 13px; text-align: center; }

.locked-cell {
  display: inline-block;
  border-radius: 4px;
  padding: 3px 8px;
  color: transparent;
  background: repeating-linear-gradient(135deg, #3a3a3a, #3a3a3a 4px, #2a2a2a 4px, #2a2a2a 8px);
  user-select: none;
}

.save-row { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  z-index: 50;
  transform: translate(-50%, 12px);
  border-radius: 10px;
  padding: 11px 18px;
  color: white;
  background: var(--green-deep);
  font-size: 13px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  box-shadow: 0 12px 28px rgba(0,0,0,.25);
}
.toast[data-kind="error"] { background: var(--red); }
.toast[data-visible="true"] { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }

/* ---------- create form ---------- */

.item-picker {
  display: grid;
  gap: 8px;
  max-height: 340px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: white;
}

.item-row { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; }
.item-row:hover { background: var(--paper-deep); }
.item-row .name { font-size: 13px; }
.item-row .name small { display: block; color: var(--ink-soft); font-family: "SFMono-Regular", Consolas, monospace; font-size: 11px; }
.item-row .price { font-family: "SFMono-Regular", Consolas, monospace; font-size: 13px; font-weight: 700; color: var(--green-deep); }

.hidden { display: none !important; }

footer.footnote { margin-top: 40px; border-top: 1px solid var(--line); padding-top: 16px; color: var(--ink-soft); font-size: 11px; line-height: 1.6; }

/* ---------- floating chat widget ---------- */

#chatWidget { position: fixed; right: 20px; bottom: 20px; z-index: 60; }

.chat-bubble {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--green-deep);
  border-radius: 999px;
  padding: 12px 18px;
  color: white;
  background: var(--green);
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 12px 28px rgba(7,44,57,.28);
  transition: transform .12s ease;
}
.chat-bubble:hover { transform: translateY(-2px); }
.chat-bubble span { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chat-badge { position: absolute; top: -3px; right: -3px; width: 12px; height: 12px; border: 2px solid white; border-radius: 50%; background: var(--orange); }

.chat-panel {
  display: flex;
  flex-direction: column;
  width: min(340px, calc(100vw - 40px));
  max-height: 460px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  box-shadow: 0 18px 44px rgba(7,44,57,.28);
  overflow: hidden;
}

.chat-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 0;
  padding: 14px 16px;
  color: white;
  background: var(--blue-deep);
  font-size: 13px;
  font-weight: 800;
  text-align: left;
}
.chat-panel-header span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px; }
.chat-minimize { font-size: 20px; line-height: 1; opacity: .85; }

.messages-list { display: flex; flex-direction: column; gap: 10px; max-height: 300px; overflow-y: auto; padding: 14px 16px; }

.message-bubble { max-width: 85%; border-radius: 12px; padding: 9px 12px; background: var(--paper); font-size: 13px; line-height: 1.45; }
.message-bubble.own { align-self: flex-end; color: white; background: var(--green); }
.message-meta { display: block; margin-bottom: 3px; font-size: 10px; font-weight: 800; opacity: .75; }

.messages-empty { padding: 20px 16px; color: var(--ink-soft); font-size: 13px; text-align: center; }

.message-form { display: flex; gap: 8px; border-top: 1px solid var(--line); padding: 12px 14px; }
.message-form input { flex: 1; border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; font-size: 13px; }

@media (max-width: 820px) {
  .controls { grid-template-columns: 1fr; position: static; }
  .kpi-row .kpi { min-height: auto; }
}

@media (max-width: 620px) {
  .shell { width: min(100% - 20px, 1180px); padding-top: 10px; }
  .gp-grid { grid-template-columns: 1fr; }
  .detail-masthead-row { flex-direction: column; }
  .size-controls, .item-row { grid-template-columns: 1fr; }
  #chatWidget { right: 12px; bottom: 12px; }
}