:root {
  --bg: #0f1318;
  --panel: #171d25;
  --panel-2: #1e2630;
  --text: #e0e6ee;
  --muted: #99a6b5;
  --accent: #44c2ff;
  --ok: #5fd98a;
  --warn: #ffd166;
  --danger: #ff6f6f;
  --line: #2a3442;
}

@media (min-width: 1200px) {
  .container {
    max-width: 1850px;
  }
}

body {
  background: radial-gradient(circle at 20% 0%, #1d2633 0%, var(--bg) 42%);
  color: var(--text);
  min-height: 100vh;
}

h1, h2, h3, h4 {
  color: #f4f7fb;
}

.alert-secondary {
  border-color: var(--line);
  background-color: var(--panel);
  color: var(--text);
}

.sheet-tabbar {
  display: flex;
  align-items: flex-end;
  gap: 0.35rem;
  border-bottom: 1px solid var(--line);
  padding: 0 0.45rem;
}

.mode-switch {
  display: inline-flex;
  gap: 0.35rem;
  padding: 0.2rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(23, 29, 37, 0.9);
}

.mode-switch-btn {
  border: 0;
  border-radius: 999px;
  padding: 0.42rem 0.95rem;
  background: transparent;
  color: var(--muted);
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.2;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.mode-switch-btn:hover {
  background: #273240;
  color: #dce4ee;
}

.mode-switch-btn.active {
  background: #2f78c4;
  color: #ffffff;
}

.mode-switch-btn:focus {
  outline: none;
  box-shadow: 0 0 0 0.2rem rgba(68, 194, 255, 0.2);
}

.sheet-tab {
  appearance: none;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 0.5rem 0.5rem 0 0;
  background-color: var(--panel-2);
  color: var(--muted);
  padding: 0.45rem 1rem;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.2;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.sheet-tab:hover {
  background-color: #273240;
  color: #dce4ee;
}

.sheet-tab:focus {
  outline: none;
  box-shadow: 0 0 0 0.2rem rgba(68, 194, 255, 0.2);
}

.sheet-tab.active {
  background-color: var(--panel);
  color: #ffffff;
  position: relative;
  top: 1px;
}

.sheet-pane {
  display: none;
}

.sheet-pane.is-active {
  display: block;
  animation: sheetPaneIn 0.12s ease-out;
}

@keyframes sheetPaneIn {
  from {
    opacity: 0.45;
    transform: translateY(2px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.table-shell {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background-color: var(--panel);
}

.table-dark {
  background-color: var(--panel);
}

.table-dark thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background-color: var(--panel-2);
  border-color: #3a4658;
  color: #f4f7fb;
  white-space: nowrap;
}

.sheet-sort-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  border: 0;
  background: transparent;
  color: #f4f7fb;
  padding: 0;
  font-size: 0.8rem;
  text-align: left;
}

.sheet-sort-btn:focus {
  outline: none;
  box-shadow: 0 0 0 0.12rem rgba(68, 194, 255, 0.3);
  border-radius: 3px;
}

.sheet-sort-arrow {
  color: #93a5bc;
  min-width: 1.1rem;
  text-align: right;
  font-size: 1.1rem;
  line-height: 1;
  font-weight: 700;
}

.sheet-action-header {
  width: 46px;
  min-width: 46px;
}

.sheet-action-cell {
  width: 46px;
  min-width: 76px;
  text-align: center;
  vertical-align: middle;
}

.row-action-group {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.row-edit-btn {
  border: 1px solid #3c4a5f;
  background-color: #1b2430;
  color: #cbd6e5;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}

.row-edit-btn:hover {
  background-color: #243246;
  color: #e7f0fc;
  border-color: #5a6f8f;
}

.row-edit-btn:focus {
  outline: none;
  box-shadow: 0 0 0 0.12rem rgba(68, 194, 255, 0.3);
}

.row-edit-btn.is-editing {
  background-color: #2c5a91;
  border-color: #5b9ce8;
  color: #ffffff;
}

.row-delete-btn {
  border: 1px solid #5e3942;
  background-color: #2b1b21;
  color: #f2c9cf;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}

.row-delete-btn:hover {
  background-color: #43232d;
  color: #ffe3e7;
  border-color: #8a4b5a;
}

.row-delete-btn:focus {
  outline: none;
  box-shadow: 0 0 0 0.12rem rgba(255, 111, 111, 0.28);
}

.row-edit-icon {
  font-size: 18px;
  line-height: 1;
}

.table-dark td,
.table-dark th {
  border-color: #2d394a;
}

#tab-nes .table-shell {
  border: 0;
}

#tab-nes #nesTable th,
#tab-nes #nesTable td {
  border: 0 !important;
}

.table td {
  font-size: 0.85rem;
  vertical-align: middle;
}

.table td.sheet-value {
  padding: 0.34rem 0.5rem;
  color: #dbe4ef;
}

.table td.sheet-value-owned {
  background-color: rgba(61, 142, 102, 0.28);
  color: #e7fff1;
  font-weight: 600;
}

.table td.sheet-cell {
  padding: 0.15rem;
}

.sheet-cell-input {
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #2f3a49;
  background-color: #11161d;
  color: var(--text);
  font-size: 0.8rem;
  padding: 0.18rem 0.35rem;
  border-radius: 4px;
}

.sheet-cell-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 0.15rem rgba(68, 194, 255, 0.18);
}

.sheet-cell-input[readonly] {
  background-color: #1a2230;
  color: #d4dce7;
}

.stat-card {
  background-color: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
}

.stat-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.stat-value {
  font-size: 1.25rem;
  margin-top: 0.25rem;
  color: #ffffff;
}

.price-delta-up {
  color: var(--ok);
}

.price-delta-down {
  color: var(--danger);
}

.price-delta-flat {
  color: var(--muted);
}

input.form-control {
  background-color: #11161d;
  border: 1px solid #334053;
  color: var(--text);
}

input.form-control:focus {
  background-color: #10151c;
  border-color: var(--accent);
  box-shadow: 0 0 0 0.2rem rgba(68, 194, 255, 0.2);
  color: var(--text);
}

.table td.sheet-cell .sheet-cell-input {
  background-color: #0f141b !important;
  border: 1px solid #2b3646 !important;
  color: #dde6f2 !important;
}

.table td.sheet-cell .sheet-cell-input:focus {
  background-color: #0d1219 !important;
  border-color: #44c2ff !important;
  box-shadow: 0 0 0 0.15rem rgba(68, 194, 255, 0.18);
}

.table td.sheet-cell .sheet-cell-input[readonly] {
  background-color: #182130 !important;
  border-color: #324155 !important;
  color: #cfd8e4 !important;
}

.table td.sheet-cell .sheet-cell-input.sheet-flag-owned {
  background-color: #1f4f36 !important;
  border-color: #3c8f67 !important;
  color: #e7fff1 !important;
  font-weight: 600;
}

.table td.sheet-cell .sheet-cell-input.sheet-flag-owned:focus {
  background-color: #24593e !important;
  border-color: #58bf8b !important;
}

input.form-control,
.sheet-cell-input {
  color-scheme: dark;
}

.text-muted {
  color: var(--muted) !important;
}

/* TOTALS tab: one table per brand. */
.totals-overview-wrap {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
}

#tab-totals .totals-brand-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

#tab-totals .totals-brand-section {
  width: 100%;
  max-width: 800px;
}

#tab-totals .table-shell {
  border: 0;
  background: transparent;
}

.totals-brand-title {
  color: #ffffff;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.35rem 0.6rem;
  border-radius: 6px 6px 0 0;
}

.totals-brand-shell {
  border-radius: 0 0 6px 6px;
  overflow: hidden;
}

.totals-brand-table {
  margin: 0;
  width: 100%;
  table-layout: fixed;
}

.totals-brand-table thead th {
  border: 0 !important;
  background: #2b3442;
  color: #e7edf6;
  text-align: right;
}

.totals-brand-table thead th:first-child {
  text-align: left;
}

.totals-brand-table td {
  border: 0 !important;
  color: #dce2ea;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.totals-brand-table td:first-child {
  text-align: left;
  color: #cfd8e4;
}

.totals-brand-table td[colspan] {
  text-align: left !important;
}

.totals-brand-table tbody tr:nth-of-type(odd) td {
  background: rgba(22, 29, 37, 0.92);
}

.totals-brand-table tbody tr:nth-of-type(even) td {
  background: rgba(28, 36, 46, 0.92);
}

.totals-brand-table tbody tr.totals-brand-total td {
  background: #222c3a;
  color: #e7edf6;
  font-weight: 700;
}

.mf-nintendo { background: #cb1c25; }
.mf-sega { background: #285b9a; }
.mf-atari { background: #6d430f; }
.mf-sony { background: #050608; }
.mf-microsoft { background: #11822d; }
.mf-commodore { background: #123f79; }
.mf-other { background: #c37800; }
.mf-generic { background: #3a4452; }
