:root {
  --neon: #00ff41;
  --neon-dim: #00cc33;
  --bg: #050505;
  --card: #111;
  --card-alt: #0d1a0d;
  --border: #333;
  --text: #eee;
  --text-dim: #888;
  --alert: #ff0040;
  --cyan: #00d2ff;
  --amber: #ffaa00;
}

* { box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Courier New', Courier, monospace;
  margin: 0;
  padding: 0;
  line-height: 1.4;
}

/* ─── TABS ─── */
.tab-bar {
  display: flex;
  gap: 2px;
  background: #000;
  border-bottom: 2px solid var(--neon);
  padding: 0 20px;
}

.tab-btn {
  background: #111;
  color: var(--text-dim);
  border: none;
  border-top: 2px solid transparent;
  padding: 12px 24px;
  cursor: pointer;
  font-family: inherit;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: all 0.2s;
}

.tab-btn:hover { color: var(--neon); }
.tab-btn.active {
  background: var(--bg);
  color: var(--neon);
  border-top: 2px solid var(--neon);
}

.tab-panel { display: none; padding: 20px; }
.tab-panel.active { display: block; }

/* ─── CONTROLS ─── */
.controls {
  background: #151515;
  padding: 20px;
  border: 1px solid var(--neon);
  margin-bottom: 20px;
  box-shadow: 0 0 15px rgba(0,255,65,0.15);
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  align-items: end;
}

.control-group { display: flex; flex-direction: column; gap: 5px; }
.control-group label { color: var(--neon); font-size: 0.75em; letter-spacing: 1px; font-weight: bold; }

select, button, input[type="checkbox"] {
  background: #000;
  color: #fff;
  border: 1px solid var(--neon);
  padding: 8px 12px;
  font-family: inherit;
  font-size: 0.9em;
}

button {
  cursor: pointer;
  font-weight: bold;
  text-transform: uppercase;
  transition: all 0.2s;
}

button:hover {
  background: var(--neon);
  color: #000;
}

button.secondary {
  border-color: var(--cyan);
  color: var(--cyan);
}
button.secondary:hover {
  background: var(--cyan);
  color: #000;
}

button.danger {
  border-color: var(--alert);
  color: var(--alert);
}
button.danger:hover {
  background: var(--alert);
  color: #fff;
}

.budget-bar {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 15px;
  padding: 10px 15px;
  background: #0a0a0a;
  border: 1px solid var(--border);
}

.budget-bar span {
  font-size: 0.9em;
}

.budget-bar .cred-val {
  color: var(--neon);
  font-weight: bold;
  font-size: 1.1em;
}

.phase-toggle {
  margin-bottom: 15px;
}

/* ─── CREW ROSTER ─── */
.crew-roster {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.member-cards.masonry {
  display: flex;
  gap: 15px;
  align-items: flex-start;
}

.masonry-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.masonry-col .member-card {
  width: 100%;
}

.roster-header {
  border: 2px solid var(--neon);
  padding: 15px;
  background: #0a0a0a;
}

.crew-name {
  font-size: 1.5em;
  font-weight: bold;
  color: var(--neon);
  text-transform: uppercase;
  letter-spacing: 2px;
}

.crew-meta {
  display: flex;
  gap: 20px;
  margin-top: 8px;
  font-size: 0.85em;
}

.crew-meta span {
  border: 1px solid #444;
  padding: 4px 10px;
  background: #000;
}

.inline-blank {
  width: 30px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: #fff;
  font-family: inherit;
  font-size: 0.9em;
  text-align: center;
}
.inline-blank::placeholder { color: #555; }

/* ─── MEMBER CARD ─── */
.member-card {
  border: 1px solid var(--border);
  padding: 15px;
  background: var(--card);
  position: relative;
}

.member-card.specialist {
  border-left: 4px solid var(--neon);
  background: var(--card-alt);
}

.member-card.standard {
  border-left: 4px solid #444;
}

.member-card.crew-card {
  border-left: 4px solid var(--cyan);
  background: #0a1a1a;
  margin-bottom: 15px;
  width: 100%;
  box-sizing: border-box;
}

.member-card.crew-card .crew-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 8px;
}

.member-card.crew-card .crew-meta .stat-box {
  border: 1px solid var(--cyan);
  background: #000;
  padding: 6px;
  text-align: center;
}

.member-card.crew-card .crew-meta .stat-name {
  display: block;
  font-size: 0.6em;
  color: var(--cyan);
  text-transform: uppercase;
}

.member-card.crew-card .crew-meta .stat-val {
  font-size: 1.2em;
  font-weight: bold;
  color: #fff;
}

.member-card.unmet {
  opacity: 0.5;
  border-left-color: var(--alert);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 12px;
  border-bottom: 1px solid #222;
  padding-bottom: 8px;
}

.ident .name {
  font-size: 1.1em;
  font-weight: bold;
  display: block;
}

.ident .handle {
  font-size: 0.85em;
  color: var(--text-dim);
  font-style: italic;
}

.type-tag {
  font-size: 0.7em;
  color: var(--neon);
  border: 1px solid var(--neon);
  padding: 2px 8px;
  text-transform: uppercase;
}

.vitals {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.vitals span { font-size: 0.85em; }
.hp { color: var(--alert); }
.arm { color: var(--cyan); }

.hp-print { display: none; }
.bugs-print { display: none; }
.hp-screen { color: var(--alert); }
.bugs-screen { color: var(--amber); }

.stats-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  margin-bottom: 12px;
}

.stat-box {
  border: 1px solid #222;
  padding: 6px;
  text-align: center;
  background: #000;
}

.stat-box.positive { border-color: var(--neon); }
.stat-box.negative { border-color: var(--alert); }

.stat-name {
  display: block;
  font-size: 0.6em;
  color: #666;
  text-transform: uppercase;
}

.stat-val {
  font-size: 1.2em;
  font-weight: bold;
}

/* ─── TRAITS ─── */
.traits-block { margin-bottom: 12px; }

.trait {
  margin-bottom: 8px;
  padding: 6px;
  background: #0a0a0a;
  border-left: 2px solid #444;
}

.trait.bonus { border-left-color: var(--neon); }
.trait.flaw-active { border-left-color: var(--alert); }

.trait label {
  display: block;
  font-size: 0.65em;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.trait-name { font-weight: bold; font-size: 0.9em; color: #fff; }
.trait-desc { display: block; font-size: 0.75em; color: var(--text-dim); margin-top: 2px; }

/* ─── MODS ─── */
.mods-block { margin-bottom: 12px; }
.mod-section { margin-bottom: 6px; }
.mod-section label {
  font-size: 0.65em;
  color: var(--neon);
  text-transform: uppercase;
}

.mod-entry, .mut-entry {
  padding: 4px 8px;
  background: #0a0a0a;
  margin: 2px 0;
  font-size: 0.85em;
}

  .mod-name, .mut-name { font-weight: bold; color: var(--neon); }
  .mod-condition { color: var(--text-dim); margin-left: 8px; }
  .mod-condition.flawed { color: var(--alert); }
  .mod-condition.unmet { color: var(--alert); font-weight: bold; }

/* Programme entries */
.programme-entry {
  border-left: 2px solid var(--cyan);
  padding-left: 8px;
  margin-bottom: 6px;
}

.prog-detail {
  display: block;
  font-size: 0.8em;
  color: #aaa;
  margin-top: 2px;
}

.prog-detail b { color: var(--neon); }

/* Programme shop chooser */
.prog-shop-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.prog-shop-item {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 8px;
  padding: 6px 8px;
  background: #0a0a0a;
  border: 1px solid #222;
}

.prog-shop-item:hover { border-color: var(--neon); }

.prog-shop-info {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.prog-shop-name {
  font-weight: bold;
  color: #fff;
  font-size: 0.9em;
  margin-bottom: 3px;
}

.prog-shop-detail {
  font-size: 0.78em;
  color: #888;
  margin-top: 1px;
}

/* ─── INVENTORY ─── */
.inventory-block { margin-bottom: 12px; }
.inventory-block label {
  font-size: 0.7em;
  color: var(--cyan);
  text-transform: uppercase;
  display: block;
  margin-bottom: 4px;
}

.item-list { display: flex; flex-direction: column; gap: 3px; }

.item-entry {
  display: flex;
  justify-content: space-between;
  padding: 4px 8px;
  background: #0a0a0a;
  font-size: 0.8em;
  border-left: 2px solid #333;
}

  .item-entry.slotless { border-left-color: #000; }

.item-name { color: #fff; }
.item-meta { color: #666; font-size: 0.85em; }

/* ─── DRONE ─── */
.drone-block {
  border: 1px dashed #555;
  padding: 8px;
  margin-bottom: 12px;
  background: #0a0a0a;
}

.drone-block label {
  display: block;
  color: var(--cyan);
  font-size: 0.8em;
  font-weight: bold;
}

.drone-stats { font-size: 0.8em; color: var(--text-dim); margin-right: 10px; }
.drone-special { font-size: 0.75em; color: #666; display: block; margin-top: 4px; }

/* ─── CONDITIONS / BUGS ─── */
.condition-tag {
  display: inline-block;
  font-size: 0.65em;
  padding: 2px 6px;
  background: var(--alert);
  color: #fff;
  margin-right: 4px;
  margin-bottom: 4px;
}

.injury-track {
  border-top: 1px solid #222;
  padding-top: 8px;
}

.injury-track label {
  font-size: 0.65em;
  color: #666;
  text-transform: uppercase;
}

.track-boxes { display: flex; gap: 8px; margin-top: 4px; }

.bug-box {
  width: 20px;
  height: 20px;
  border: 1px solid #444;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8em;
  margin: 1px;
}

/* ─── SHOP PANEL ─── */
.shop-panel {
  background: #0a0a0a;
  border: 1px solid var(--border);
  padding: 15px;
  margin-top: 10px;
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  max-height: 300px;
  overflow-y: auto;
}

.shop-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  background: #000;
  border: 1px solid #222;
  font-size: 0.8em;
}

.shop-item:hover { border-color: var(--neon); }

.shop-item .item-info { display: flex; flex-direction: column; }
.shop-item .item-cost { color: var(--neon); font-weight: bold; }

/* ─── TABLE REFERENCE ─── */
.table-ref {
  margin-bottom: 30px;
}

.table-ref h3 {
  color: var(--neon);
  border-bottom: 1px solid var(--neon);
  padding-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85em;
  margin-top: 10px;
}

.data-table th {
  background: #0a0a0a;
  color: var(--neon);
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--neon);
  position: sticky;
  top: 0;
}

.data-table td {
  padding: 6px 10px;
  border-bottom: 1px solid #222;
  vertical-align: top;
}

.data-table tr:hover td { background: #111; }

.search-box {
  width: 100%;
  max-width: 400px;
  padding: 8px 12px;
  background: #000;
  border: 1px solid var(--neon);
  color: #fff;
  font-family: inherit;
  margin-bottom: 15px;
}

/* ─── SHOP CATEGORIES ─── */
.shop-categories { display: flex; flex-direction: column; gap: 8px; }
.shop-category { border: 1px solid #333; }
.cat-toggle {
  background: #1a1a1a;
  color: var(--neon);
  border: none;
  padding: 8px 12px;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  font-weight: bold;
  text-transform: uppercase;
  font-size: 0.8em;
}
.cat-toggle:hover { background: #252525; }
.cat-grid {
  display: grid;
  gap: 4px;
  padding: 8px;
  background: #0a0a0a;
}

.sell-btn {
  font-size: 0.65em;
  padding: 1px 4px;
  margin-left: 6px;
  border-color: var(--alert);
  color: var(--alert);
}
.sell-btn:hover {
  background: var(--alert);
  color: #fff;
}

.fillable-line {
  display: block;
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid #444;
  color: #fff;
  font-family: inherit;
  font-size: 0.8em;
  margin-bottom: 4px;
  padding: 2px 0;
}
.fillable-line::placeholder { color: #555; }

.bug-field {
  width: 24px;
  height: 24px;
  text-align: center;
  background: #000;
  border: 1px solid #444;
  color: #fff;
  font-family: inherit;
  font-size: 0.8em;
}

/* ─── ATTRIBUTES ROW ─── */
.attributes-row {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.attr-box {
  flex: 1;
  min-width: 52px;
  background: #000;
  border: 1px solid #333;
  padding: 4px 6px;
  text-align: center;
}

.attr-label {
  display: block;
  font-size: 0.55em;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 2px;
}

.attr-val {
  font-size: 0.95em;
  font-weight: bold;
  color: #fff;
}

.attr-orig {
  font-size: 0.75em;
  color: #555;
  text-decoration: line-through;
}

.attr-arrow { font-size: 0.7em; color: #555; margin: 0 2px; }
.attr-sub   { font-size: 0.7em; color: #888; font-weight: normal; }

/* ─── STAT MODIFIERS ─── */
.stat-val-group {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
}

.stat-orig { font-size: 0.7em; color: #555; text-decoration: line-through; }
.stat-sep  { font-size: 0.65em; color: #555; }

.stat-val.stat-buff { color: var(--neon); }
.stat-val.stat-nerf { color: var(--alert); }

.test-mod {
  display: block;
  font-size: 0.52em;
  color: var(--amber);
  text-align: center;
  margin-top: 1px;
}

/* ─── LEGAL FOOTER ─── */
.legal-footer {
  margin-top: 40px;
  padding: 20px;
  border-top: 1px solid var(--neon);
  background: var(--card);
  color: var(--text-dim);
  font-size: 0.7em;
  line-height: 1.6;
}

.legal-footer p { margin: 0 0 6px 0; }
.legal-footer p:last-child { margin-bottom: 0; }
.footer-title {
  color: var(--neon);
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px !important;
}

/* ─── PRINT ─── */
@page {
  size: 297mm 210mm;
  margin: 14mm;
}

@media print {
  @page {
    size: 297mm 210mm;
    margin: 14mm;
  }

  body {
    background: #fff;
    color: #000;
    font-size: 7pt;
    line-height: 1.2;
    padding: 0;
    margin: 0;
  }

  /* Attributes row print */
  .attributes-row { display: flex; gap: 4px; margin-bottom: 6px; }
  .attr-box { flex: 1; border: 1px solid #000; background: #fff; padding: 2px 4px; text-align: center; }
  .attr-label { font-size: 0.5em; color: #000; }
  .attr-val { font-size: 0.85em; color: #000; }
  .attr-orig { color: #666; }
  .attr-arrow { color: #666; }
  .stat-orig {
    color: #333;
    text-decoration: none;
    font-size: 0.8em;
  }
  .stat-sep { color: #333; }
  .stat-val.stat-buff, .stat-val.stat-nerf { color: #000; font-weight: bold; }
  .test-mod { color: #333; font-size: 0.55em; }

  /* Hide all interactive / non-essential UI elements */
  .no-print,
  .legal-footer,
  .controls,
  .tab-bar,
  .shop-panel,
  .phase-toggle,
  .budget-bar,
  [data-shop],
  [data-reroll],
  .sell-btn,
  .cat-toggle,
  #tables-panel,
  #tables-panel * {
    display: none !important;
  }

  /* Show print-only elements */
  .hp-print { display: inline !important; }
  .hp-screen { display: none !important; }
  .bugs-print { display: inline !important; }
  .bugs-screen { display: none !important; }

  /* Inline blank styling for print */
  .inline-blank {
    width: 24px;
    border-bottom: 1px solid #000;
    color: #000;
  }
  .inline-blank::placeholder { color: #000; }

  .fillable-line {
    display: block;
    width: 100%;
    height: 14px;
    background: transparent;
    border: none;
    border-bottom: 1px solid #000;
    margin-bottom: 8px;
    padding: 0;
  }
  .fillable-line::placeholder { color: transparent; }

  /* Layout: roster takes full width */
  #generator-panel,
  #crew-area {
    display: block !important;
    width: 100%;
    padding: 0;
    margin: 0;
  }

  .crew-roster {
    display: block !important;
    width: 100%;
    padding-top: 4px;
  }

  /* Print layout: 2 float columns */
  .member-cards.masonry {
    display: block !important;
    width: 100%;
    overflow: hidden;
    padding-top: 2px;
  }

  .masonry-col {
    float: left;
    width: 45%;
    margin-right: 2%;
    display: block;
    padding-top: 3px;
  }
  .masonry-col:last-child { margin-right: 0; }
  .masonry-col:first-child { margin-left: 1%; }

  .masonry-col .member-card {
    display: block;
    width: 100%;
    margin-bottom: 6px;
    margin-top: 2px;
    border: 1px solid #000;
    background: #fff;
    break-inside: avoid;
    page-break-inside: avoid;
    -webkit-column-break-inside: avoid;
    box-sizing: border-box;
  }

  .member-card.specialist { border-left: 4px solid #00ff41; }
  .member-card.standard { border-left: 3px solid #000; }
  .member-card.crew-card {
    border-left: 3px solid #000;
    background: #fff;
    width: 92%;
    margin-left: 1%;
    display: block;
    margin-bottom: 6px;
    margin-top: 4px;
    padding: 4px 6px;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .member-card.crew-card .crew-meta {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-top: 4px;
  }
  .member-card.crew-card .crew-meta .stat-box {
    border: 1px solid #000;
    background: #fff;
    padding: 2px;
    text-align: center;
  }
  .member-card.crew-card .crew-meta .stat-name {
    display: block;
    font-size: 0.55em;
    color: #000;
    text-transform: uppercase;
  }
  .member-card.crew-card .crew-meta .stat-val {
    font-size: 0.9em;
    font-weight: bold;
    color: #000;
  }
  .member-card.unmet { opacity: 0.8; }

  .card-header {
    margin-bottom: 3px;
    padding-bottom: 2px;
    border-bottom: 1px solid #000;
  }

  .ident .name {
    font-size: 1em;
    font-weight: bold;
    color: #000;
  }

  .ident .handle {
    font-size: 0.8em;
    color: #000;
  }

  .type-tag {
    font-size: 0.65em;
    color: #000;
    border: 1px solid #000;
    padding: 1px 4px;
  }

  .vitals {
    display: flex;
    gap: 8px;
    margin-bottom: 4px;
    flex-wrap: wrap;
    font-size: 0.85em;
  }
  .vitals span { color: #000 !important; }

  .stats-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 2px;
    margin-bottom: 4px;
  }

  .stat-box {
    border: 1px solid #000;
    background: #fff;
    padding: 2px;
    text-align: center;
  }

  .stat-name { font-size: 0.55em; color: #000; }
  .stat-val { font-size: 0.9em; font-weight: bold; color: #000; }

  .traits-block,
  .mods-block,
  .inventory-block,
  .drone-block,
  .injury-track {
    margin-bottom: 3px;
  }

  .trait {
    margin-bottom: 2px;
    padding: 2px 4px;
    border-left: 2px solid #000;
    background: #fff;
  }

  .trait.bonus { border-left-color: #00ff41; }
  .trait.flaw-active { border-left-color: #ff0040; }

  .trait-name { font-weight: bold; font-size: 0.85em; color: #000; }
  .trait-desc { display: block; font-size: 0.75em; color: #000; margin-top: 1px; }

  .mod-section label,
  .inventory-block label,
  .drone-block label,
  .injury-track label {
    font-size: 0.6em;
    color: #000;
    text-transform: uppercase;
    display: block;
    margin-bottom: 1px;
  }

  .mod-entry {
    padding: 1px 3px;
    margin: 1px 0;
    background: #fff;
    font-size: 0.8em;
    color: #000;
  }
  .mod-entry span { color: #000 !important; }
  .mod-name, .mut-name { color: #000 !important; }
  .mod-condition { color: #000 !important; }

  .programme-entry {
    border-left: 2px solid #00d2ff;
    padding-left: 4px;
    margin-bottom: 2px;
  }

  .prog-detail {
    display: block;
    font-size: 0.75em;
    color: #000;
    margin-top: 1px;
  }

  .item-entry {
    display: flex;
    justify-content: space-between;
    padding: 1px 3px;
    background: #fff;
    border-left: 1px solid #000;
    font-size: 0.8em;
  }
  .item-entry span { color: #000 !important; }

  .item-name { color: #000; }
  .item-meta { color: #000; font-size: 0.85em; }

  .drone-block {
    border: 1px dashed #000;
    padding: 3px;
    background: #fff;
  }

  .drone-stats { font-size: 0.8em; color: #000; margin-right: 6px; }
  .drone-special { font-size: 0.75em; color: #000; display: block; margin-top: 2px; }

  .condition-tag {
    display: inline-block;
    font-size: 0.6em;
    padding: 1px 3px;
    background: #000;
    color: #fff;
    margin-right: 2px;
    margin-bottom: 2px;
  }

  .hp { color: #000; }
  .arm { color: #000; }

  .tab-panel { display: block !important; padding: 0; margin: 0; }
}
