/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0d0e14;
  --surface:  #161821;
  --surface2: #1e2030;
  --border:   #2e3050;
  --accent:   #7c6af7;
  --accent2:  #56d1c0;
  --danger:   #e06c75;
  --warn:     #e5c07b;
  --text:     #cdd6f4;
  --muted:    #6c7086;
  --dim:      #9399b2;
  --record:   #f9e2af;
  --radius:   6px;
  --shadow:   0 2px 12px rgba(0,0,0,.45);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  min-height: 100vh;
}

/* ── Header ── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  position: sticky;
  top: 0;
  z-index: 10;
}
header h1 { font-size: 17px; font-weight: 700; color: var(--accent); white-space: nowrap; }
header h1 span { color: var(--dim); font-weight: 400; font-size: 14px; }

.header-config {
  margin-left: auto;
  display: flex;
  gap: 16px;
  align-items: center;
}
.header-config label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--dim);
}
.header-config input[type="number"] { width: 44px; }
.header-config select { width: auto; }

/* ── Main ── */
main { padding: 20px; max-width: 1100px; margin: 0 auto; }

/* ── Roster top ── */
.roster-top {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

/* ── Species tabs ── */
.species-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  border-bottom: 2px solid var(--border);
  flex: 1;
}
.species-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  color: var(--dim);
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  border-radius: 0;
  transition: color .15s, border-color .15s;
}
.species-tab:hover { color: var(--text); }
.species-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ── Buttons ── */
button { border: none; cursor: pointer; border-radius: var(--radius); padding: 7px 14px; font-size: 13px; transition: filter .15s; }
.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.15); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { filter: brightness(1.2); }
.btn-ghost     { background: none; color: var(--dim); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.1); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ── Inputs ── */
input[type="text"], input[type="number"], select, textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 13px;
  width: 100%;
  outline: none;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input[type="number"] { width: 64px; text-align: center; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--dim); }

/* ── Breed Plan ── */
.breed-plan {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 20px;
}
.breed-plan-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
}
.breed-plan-header h2 { font-size: 15px; font-weight: 700; }
.eggs-hint { font-size: 12px; color: var(--muted); }
.pair-train-note {
  font-size: 11px;
  color: var(--dim);
  padding: 6px 12px;
  border-top: 1px solid rgba(255,255,255,.05);
  background: rgba(255,255,255,.02);
}

.pair-cards { display: flex; gap: 14px; flex-wrap: wrap; }

.pair-card {
  flex: 1;
  min-width: 260px;
  border: 1px solid;
  border-radius: var(--radius);
  overflow: hidden;
}
.pair-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.pair-label { font-weight: 700; font-size: 13px; }
.pair-score { font-size: 11px; color: var(--dim); }

.pair-parents {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.pair-parent { flex: 1; }
.pp-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 3px; }
.pp-stats { font-size: 12px; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1.6; }
.stat-sep { color: var(--border); margin: 0 4px; }
.pair-x { color: var(--muted); font-size: 16px; font-weight: 300; flex-shrink: 0; }

.pair-ceiling-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.pair-ceiling-table th {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 5px 12px;
  text-align: right;
  border-bottom: 1px solid var(--border);
}
.pair-ceiling-table th:first-child { text-align: left; }
.pair-ceiling-table td { padding: 4px 12px; border-bottom: 1px solid rgba(255,255,255,.03); }
.pc-stat { text-align: left; color: var(--dim); }
.pc-val  { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.pc-ceil { text-align: right; font-weight: 700; color: var(--accent2); font-variant-numeric: tabular-nums; }
.pc-val.boosted { color: var(--warn); }
.pts-note { font-size: 10px; color: var(--warn); font-weight: 400; }

/* ── Roster Table ── */
.roster-table-wrap { overflow-x: auto; }
.roster-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 520px;
}
.roster-table thead th {
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
  padding: 8px 10px;
  text-align: left;
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
}
.roster-table thead th.col-stat { text-align: right; }
.roster-table tbody tr.rt-row { border-bottom: 1px solid var(--border); transition: opacity .15s; }
.roster-table tbody tr.rt-row:hover { background: var(--surface2) !important; }
.roster-table td { padding: 8px 10px; vertical-align: middle; }

.col-badges { width: 1%; white-space: nowrap; }
.col-lvl    { width: 48px; color: var(--dim); }
.col-stat   { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.col-actions { white-space: nowrap; text-align: right; }
.col-actions .btn-sm + .btn-sm { margin-left: 4px; }

.record-cell { color: var(--record); }

/* badges */
.pair-badge, .unspent-badge, .sup-badge, .affix-badge {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 99px;
  margin-right: 3px;
}
.pair-badge    { border: 1px solid; font-weight: 700; }
.unspent-badge { background: rgba(229,192,123,.15); color: var(--warn); border: 1px solid rgba(229,192,123,.3); }
.sup-badge     { background: rgba(108,112,134,.12); color: var(--muted); }
.affix-badge                        { border: 1px solid; }
.affix-badge.tier-common        { color: var(--muted);  border-color: rgba(108,112,134,.35); background: rgba(108,112,134,.1);  }
.affix-badge.tier-base          { color: var(--text);   border-color: rgba(205,214,244,.3);  background: rgba(205,214,244,.08); }
.affix-badge.tier-notably       { color: #98c379;       border-color: rgba(152,195,121,.4);  background: rgba(152,195,121,.1);  }
.affix-badge.tier-exceptionally { color: #61afef;       border-color: rgba(97,175,239,.4);   background: rgba(97,175,239,.1);   }

/* superseded rows */
.roster-table tbody tr.releasable { opacity: 0.35; }
.roster-table tbody tr.releasable:hover { opacity: 0.7 !important; }

.section-divider td {
  padding: 10px 10px 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  border-top: 2px dashed var(--border);
}

/* ── Forms ── */
.form-row { display: flex; gap: 12px; margin-bottom: 14px; }
.form-row > label { flex: 1; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin-bottom: 14px; }
legend { font-size: 12px; color: var(--dim); padding: 0 6px; }
.hint { font-size: 11px; color: var(--muted); font-style: italic; }

.stat-inputs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.stat-inputs label { flex-direction: column; width: 60px; gap: 4px; }

.affix-row { display: flex; gap: 12px; align-items: flex-end; margin-top: 10px; }
.affix-row label { flex: none; }
.affix-row select { width: auto; }

.train-tier-hint {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 14px;
}
.train-tier-hint strong { color: var(--dim); }

/* ── Suggested name ── */
.name-suggestion {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  margin-bottom: 14px;
}
.ns-label { font-size: 11px; color: var(--muted); white-space: nowrap; }
.ns-name {
  flex: 1;
  background: none;
  border: none;
  color: var(--accent2);
  font-size: 15px;
  font-weight: 700;
  font-family: 'Consolas', 'Courier New', monospace;
  cursor: pointer;
  text-align: left;
  padding: 0;
  border-radius: 0;
  letter-spacing: .02em;
}
.ns-name:hover { color: var(--text); }
.ns-name::after { content: ' ⎘'; font-size: 12px; opacity: .5; }
.ns-feedback { font-size: 11px; color: var(--accent2); white-space: nowrap; }

.notes-label { margin-bottom: 14px; display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--dim); }
.notes-label textarea { resize: vertical; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* ── Modals ── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 100; }
.modal {
  position: fixed; inset: 0; z-index: 101;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.modal:not(.hidden) { pointer-events: auto; }
.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  width: min(520px, 96vw);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal-box h2 { margin-bottom: 16px; font-size: 16px; }

/* ── Misc ── */
.hidden { display: none !important; }
.empty-state { text-align: center; color: var(--muted); padding: 60px 20px; font-style: italic; }

/* ── Responsive ── */
@media (max-width: 640px) {
  .pair-cards { flex-direction: column; }
  .header-config { display: none; }
}
