*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

:root {
  --bg:           #1b2333;   /* page background — dark blue-grey */
  --surface:      #232f42;   /* card surface — slightly lighter navy */
  --surface2:     #1e2a3a;   /* inset surfaces (log, inputs) */
  --border:       #2e4060;   /* subtle steel-blue border */
  --accent:       #c8a84b;   /* gold/amber — MM header colour */
  --accent-hover: #b8963a;
  --red:          #cc2a2a;   /* MM crime/danger red */
  --red-hover:    #a82020;
  --text:         #c8d4e0;   /* light blue-grey body text */
  --muted:        #6a7f96;   /* muted label text */
  --success:      #3a9e5f;   /* green for running state */
  --radius:       4px;
}

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

.container { max-width: 1290px; margin: 0 auto; padding: 20px; }

header { margin-bottom: 20px; position: relative; }
header h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}

.status-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: 13px;
}
.spacer { flex: 1; }
.dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.dot.running { background: var(--success); box-shadow: 0 0 6px var(--success); }
.dot.stopped { background: var(--muted); }
.dot.paused  { background: #c8a020; box-shadow: 0 0 6px #c8a020; }
.status-task { color: var(--muted); font-size: 12px; font-style: italic; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.card h2 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
#s-character > h2 {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: normal;
}

.card h3 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text);
  margin: 14px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.card h3:first-of-type { margin-top: 0; }

.row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.row:last-child { margin-bottom: 0; }

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  flex: 1;
  min-width: 160px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 7px 10px;
  font-size: 13px;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}
select option { background: var(--surface2); }

/* Push toggles to the right edge when inside headings */
.card h2 .toggle-label,
.card h3 .toggle-label { margin-left: auto; flex: none; }

/* Toggle switch */
.toggle-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  flex-direction: row;
  gap: 6px;
  min-width: unset;
  flex: none;
}
.toggle-label input[type="checkbox"] { display: none; }
.toggle {
  width: 36px; height: 20px;
  background: var(--border);
  border-radius: 10px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.toggle::after {
  content: '';
  width: 14px; height: 14px;
  background: #fff;
  border-radius: 50%;
  position: absolute;
  top: 3px; left: 3px;
  transition: left 0.2s;
}
.toggle-label input:checked + .toggle { background: var(--accent); }
.toggle-label input:checked + .toggle::after { left: 19px; }

.label-inline {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
}
.inline-toggle {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 13px;
  min-width: unset;
}
/* Toggle rows: grid so the text node aligns with the label column */
label.setting-row.inline-toggle {
  display: grid;
  grid-template-columns: 200px auto;
  align-items: center;
  gap: 10px;
}

/* Tabs — styled to match the top-level main tabs */
.tab-bar { display: flex; gap: 0; flex-wrap: wrap; margin-bottom: 14px; }
.tab-btn {
  flex: 0 0 auto;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  padding: 8px 14px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.tab-btn:hover { color: var(--text); background: rgba(200,168,75,0.06); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); background: rgba(200,168,75,0.08); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }
.placeholder { color: var(--muted); font-style: italic; padding: 10px 0; }
.muted { color: var(--muted); font-weight: normal; }

/* Controls */
.controls { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.controls button { flex: 1; }
button {
  padding: 9px 22px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-secondary {
  background: #2e4060;
  border: 1px solid #3a4d70;
  color: var(--text);
}
.btn-secondary:hover { background: #364a6e; border-color: var(--accent); color: var(--accent); }

#save-btn { background: var(--surface); border-color: var(--border); color: var(--text); }
#save-btn:hover { border-color: var(--accent); color: var(--accent); }

#toggle-btn { background: var(--red); border-color: var(--red); color: #fff; }
#toggle-btn:hover { background: var(--red-hover); border-color: var(--red-hover); }
#toggle-btn.running { background: #2e4060; border-color: #2e4060; color: var(--text); }
#toggle-btn.running:hover { background: #263850; }

#pause-btn { background: #7a6000; border-color: #7a6000; color: #fff; }
#pause-btn:hover { background: #5a4500; border-color: #5a4500; }
#pause-btn.paused { background: #2a5a2a; border-color: #2a5a2a; }
#pause-btn.paused:hover { background: #235023; }
#pause-btn:disabled { background: var(--surface2); border-color: var(--border); color: var(--muted); cursor: default; }

#screenshot-btn { background: var(--surface); border-color: var(--border); color: var(--muted); }
#screenshot-btn:hover { border-color: var(--accent); color: var(--accent); }
#screenshot-btn:disabled { opacity: 0.5; cursor: default; }

/* Character stats card */
.stat-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 4px 0 10px;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 6px;
  margin-bottom: 12px;
}
.stat-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 10px;
}
/* Status groups grid — 2 columns on desktop */
.stat-groups-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 10px;
}
@media (min-width: 560px) {
  .stat-groups-grid { grid-template-columns: 1fr 1fr; }
  .stat-groups-grid .stat-group-full { grid-column: 1 / -1; }
}
/* Individual group table */
.stat-group-table {
  border-collapse: separate;
  border-spacing: 0;
  font-variant-numeric: tabular-nums;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  width: 100%;
}
.stat-group-table td {
  position: relative;
  padding: 6px 10px;
  padding-right: 50px;
  border: 1px solid var(--border);
  background: var(--surface2);
  vertical-align: top;
}
.stat-group-table td .stat-label { display: block; }
.stat-group-table td .stat-value { display: block; white-space: nowrap; }
.stat-group-table .stat-sect-hdr td {
  background: #3a4d6a;
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #d8e2ee;
  padding: 4px 10px;
}
.stat-row-2 td { width: 50%; }
.stat-row-3 td { width: 33.33%; }
.stat-row-full td { width: 100%; }
/* Vitals — thicker vertical borders between cells */
.stat-vitals-table .stat-row-3 td + td {
  border-left: 3px solid var(--surface);
}
/* Progress cell with % shading */
.stat-progress-cell {
  position: relative;
  overflow: hidden;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}
.stat-progress-bg {
  position: absolute;
  inset: 0;
  width: 0%;
  transition: width 0.4s ease;
  pointer-events: none;
}
/* Color steps: red < 25%, orange 25-49%, yellow 50-74%, green 75%+ */
.stat-progress-bg.pct-low  { background: rgba(220,60,60,0.22); }
.stat-progress-bg.pct-mid  { background: rgba(220,150,40,0.22); }
.stat-progress-bg.pct-high { background: rgba(200,168,75,0.20); }
.stat-progress-bg.pct-full { background: rgba(60,180,80,0.22); }
.stat-pct {
  display: none;
  font-size: 12px;
  font-weight: 600;
}
.stat-pct.pct-low  { color: #dc3c3c; }
.stat-pct.pct-mid  { color: #dc9628; }
.stat-pct.pct-high { color: var(--accent); }
.stat-pct.pct-full { color: #3cb450; }
@media (min-width: 560px) {
  .stat-pct {
    display: block;
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
  }
}
@media (max-width: 559px) {
  .stat-progress-cell.show-pct .stat-pct { display: block; margin-top: 2px; }
  .stat-group-table td { padding: 5px 8px; padding-right: 40px; }
}
.in-jail .stat-progress-bg { background: rgba(255,255,255,0.08); }
.in-jail .stat-sect-hdr td { background: #666; color: #e0e0e0; }
.in-hospital .stat-progress-bg { background: rgba(255,200,200,0.15); }
.in-hospital .stat-sect-hdr td { background: #b01212; color: #f8e8e8; }
.stat-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.stat-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.stat-timers { }
.stat-timer-value { color: var(--accent); font-variant-numeric: tabular-nums; }

/* Profile tab */
.profile-section-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  margin: 8px 0 4px;
}
.profile-item {
  padding: 4px 0;
  font-size: 13px;
  line-height: 1.4;
}
.profile-item-name { font-weight: 600; color: var(--text); }
.profile-slot {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--accent);
  letter-spacing: .05em;
}
.profile-nav-bar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.profile-weapon-group { font-size: 11px; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: .06em; margin: 8px 0 2px; }
.profile-item-clickable:hover { background: var(--surface2); border-radius: 4px; cursor: pointer; }
.profile-weapon-pill { display:inline-flex; align-items:center; gap:4px; background:var(--card-bg); border:1px solid var(--border); border-radius:4px; padding:3px 10px; font-size:12px; color:var(--text); }
.profile-weapon-pill.profile-item-clickable:hover { border-color:var(--accent); cursor:pointer; background:var(--surface2); }
.profile-refreshing { opacity: 0.5; pointer-events: none; transition: opacity 0.15s; }
.profile-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.profile-tag {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 12px;
  color: var(--text);
}

.consumables-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 6px;
  margin-bottom: 12px;
}
.consumable-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 10px;
  min-height: 52px;
  text-align: center;
}
.consumable-name {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.consumable-qty {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}
.consumable-link { cursor: pointer; text-decoration: underline; color: var(--accent); }

/* Inline action buttons inside cards */
.action-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 7px 16px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: var(--radius);
  cursor: pointer;
  flex: 0 0 auto;
}
.action-btn:hover { border-color: var(--accent); color: var(--accent); }
.action-btn:disabled { opacity: 0.5; cursor: default; }

/* Character name in header — matches h2 style */
.stat-name-header {
  font-weight: 700;
  font-size: 13px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

/* Settings groups — 2 col desktop, 1 col mobile */
.settings-groups {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 600px) {
  .settings-groups { grid-template-columns: 1fr; }
}
.settings-group h3 { margin-top: 0; }
.setting-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  padding: 5px 0;
  border-bottom: 1px solid rgba(46, 64, 96, 0.3);
  gap: 10px;
  font-size: 13px;
  color: var(--text);
  min-width: unset;
  flex-direction: row;
}
.setting-row > span,
.setting-row > label:first-child {
  color: var(--text);
  font-size: 13px;
}
.setting-row:last-child { border-bottom: none; }
.setting-row .toggle-label { flex-shrink: 0; }
.setting-note {
  font-size: 0.8rem;
  color: var(--text-muted, #6b7e99);
  margin: -4px 0 6px;
}

/* Case work priority table */
.priority-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12px;
  font-size: 13px;
}
.priority-table th {
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 4px 8px 6px;
  border-bottom: 1px solid var(--border);
}
.priority-table td {
  padding: 5px 8px;
  border-bottom: 1px solid rgba(46,64,96,0.3);
  vertical-align: middle;
}
.priority-table tr:last-child td { border-bottom: none; }
.priority-move {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 28px;
}
.priority-move button {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--muted);
  font-size: 10px;
  padding: 1px 4px;
  cursor: pointer;
  line-height: 1.4;
  font-weight: bold;
  text-transform: none;
  letter-spacing: 0;
}
.priority-move button:hover { border-color: var(--accent); color: var(--accent); }
.priority-num {
  color: var(--muted);
  font-size: 11px;
  width: 18px;
  text-align: center;
}
/* Drag-and-drop for priority tables (desktop only) */
.priority-table tr[draggable="true"] { cursor: grab; }
.priority-table tr[draggable="true"].dragging { opacity: 0.35; }
.priority-table tr[draggable="true"].drop-before td { border-top: 2px solid var(--accent); }
.priority-table tr[draggable="true"].drop-after td { border-bottom: 2px solid var(--accent); }
/* Mobile: arrows are primary — larger tap targets, no grab cursor */
@media (max-width: 600px) {
  .priority-table tr[draggable="true"] { cursor: default; }
  .priority-move button { font-size: 13px; padding: 3px 7px; }
}
.cw-select { width: 140px !important; padding: 5px 8px; font-size: 12px; }
.cw-poll-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--muted);
}
.cw-poll-row input { width: 70px !important; }

.eye-btn { width: 36px; padding: 0; display: flex; align-items: center; justify-content: center; }
.eye-icon { width: 18px; height: 13px; display: block; }

/* Credential field with inline show/hide button */
.input-with-btn {
  display: flex;
  gap: 6px;
}
.input-with-btn input { flex: 1; }
.input-btn {
  padding: 0 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  height: 33px;
  align-self: flex-end;
}
.input-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Narrow inputs for energy thresholds */
.label-narrow { flex: 0 0 auto; min-width: unset; }
.input-narrow { width: 70px !important; padding: 7px 8px; }
.input-narrow-wide { width: 150px !important; padding: 7px 8px; }

/* Log */
.log-card h2 { margin-bottom: 8px; }
.log-open-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.log-file-select {
  font-size: 11px;
  padding: 3px 6px;
  flex: 1;
  min-width: 0;
  max-width: 300px;
}
.log-open-link {
  font-size: 11px;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
  font-weight: 600;
  letter-spacing: 0.03em;
}
.log-open-link:hover { color: var(--accent-hover); text-decoration: underline; }
.log-open-btn {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: none;
  padding: 4px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--accent);
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.log-open-btn:hover { border-color: var(--accent); background: var(--surface); }
#log-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  height: 420px;
  overflow-y: auto;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 11px;
  color: var(--text);
  display: flex;
  flex-direction: column-reverse;
}
@media (max-width: 600px) {
  #log-box { height: 50vh; max-height: 420px; }
}
#log-box .log-line {
  padding: 2px 0;
  border-bottom: 1px solid rgba(46, 64, 96, 0.3);
}

/* ── Collapsible cards ───────────────────────────────────────────────────── */
.collapse-btn {
  background: none; border: none;
  color: var(--text-muted, #6b7e99);
  cursor: pointer; font-size: 12px;
  padding: 0; line-height: 1;
  transition: transform 0.18s;
  flex-shrink: 0; margin-right: 2px;
}
@media (max-width: 600px) {
  .collapse-btn { font-size: 18px; }
}
.collapse-btn.collapsed { transform: rotate(-90deg); }
.card-body.collapsed { display: none; }
/* Remove bottom border on h2 when card is collapsed */
.card-body.collapsed ~ h2,
.card h2:has(+ .card-body.collapsed) { border-bottom-color: transparent; margin-bottom: 0; padding-bottom: 6px; }

/* ── Unsaved input indicator ─────────────────────────────────────────────── */
.input-unsaved { color: var(--red) !important; }
input.input-unsaved { color: var(--red) !important; }

/* ── Inline number-field save button ────────────────────────────────────── */
.num-save-btn {
  padding: 0;
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--muted); border-radius: var(--radius);
  cursor: pointer; flex-shrink: 0;
}
.num-save-btn:hover { border-color: var(--accent); color: var(--accent); }
.num-save-btn.needed { border-color: var(--red); color: var(--red); }
.save-icon { width: 14px; height: 14px; fill: currentColor; display: block; flex-shrink: 0; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; padding: 3px 7px; }

/* ── Credentials save button ─────────────────────────────────────────────── */
#creds-save-btn { margin-top: 10px; width: auto; padding: 6px 14px; }

/* ── Collapsed section summary pills ────────────────────────────────────── */
.section-pills {
  display: none;
  gap: 4px;
  margin-left: 4px;
  align-items: center;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.is-collapsed .section-pills { display: inline-flex; }
.pill {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 2px 8px;
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  white-space: nowrap;
}
.pill-clickable {
  cursor: pointer;
}
.pill-clickable:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Jail */
.jail-badge {
  display: inline-block;
  background: #5a5a5a;
  color: #ddd;
  border-radius: 3px;
  padding: 1px 7px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  vertical-align: middle;
  margin-left: 4px;
}
.in-jail {
  border-color: #5a5a5a !important;
  background: #4a4a4a !important;
}
.in-jail > h2 {
  background: #4a4a4a !important;
  border-bottom-color: #5a5a5a !important;
}
.in-jail .card-body {
  background: #4a4a4a;
}
.in-jail .stat-item,
.in-jail .stat-table td {
  background: #525252;
  border-color: #666;
}
.in-jail .stat-label {
  color: #b0b0b0;
}
.in-jail .stat-value {
  color: #f0f0f0;
}
.in-jail .stat-divider {
  border-top-color: #666;
}
.in-jail .placeholder {
  color: #888;
}
.in-jail .stat-timer-value {
  color: #c8c8c8 !important;
}
.in-jail .stat-timer-value.ready,
.in-jail .stat-item-timer .stat-value.ready {
  color: #8ecb8e !important;
}
/* Jail variants for the rest of the status-section elements */
.in-jail .tab-btn { color: #c0c0c0; }
.in-jail .tab-btn:hover { color: #f0f0f0; background: rgba(255,255,255,0.04); }
.in-jail .tab-btn.active { color: #e0e0e0; border-bottom-color: #e0e0e0; background: rgba(255,255,255,0.06); }
/* Character history */
.in-jail .ch-section { background: #525252; border-color: #666; }
.in-jail .ch-section-head { background: #4a4a4a; border-bottom-color: #666; }
.in-jail .ch-section-title { color: #dcdcdc; }
.in-jail .ch-table td { color: #e8e8e8; border-bottom-color: #666; }
.in-jail .ch-key,
.in-jail .ch-earn-label,
.in-jail .ch-earn-cat,
.in-jail .ch-empty-note,
.in-jail .ch-date,
.in-jail .ch-st-type { color: #b0b0b0; }
.in-jail .ch-money,
.in-jail .ch-earn-count { color: #e0c890; }
.in-jail .ch-st-name { color: #f0f0f0; }
.in-jail .ch-promo-table th,
.in-jail .ch-unlocked-item { border-color: #666; }
.in-jail .ch-promo-table th { color: #b0b0b0; }
.in-jail .ch-earn-item { background: #4a4a4a; border-color: #666; }
.in-jail .ch-locked-btn { background: #525252; border-color: #666; color: #d0d0d0; }
.in-jail .ch-locked-btn:hover { border-color: #999; color: #f0f0f0; }
.in-jail .ch-rank-badge { background: #525252; border-color: #666; color: #c8c8c8; }
.in-jail .ch-locked-divider { background: #4a4a4a; border-color: #666; color: #b0b0b0; }
.in-jail .ch-locked-name { color: #c0c0c0; }
.in-jail .ch-locked-desc { color: #a0a0a0; }
.in-jail .pill { background: #525252; border-color: #666; color: #d8d8d8; }
.in-jail select,
.in-jail input,
.in-jail textarea { background: #525252; color: #f0f0f0; border-color: #666; }
.in-jail .btn-secondary,
.in-jail .action-btn { background: #525252; border-color: #666; color: #e8e8e8; }
.in-jail .consumable-item { background: #525252; border-color: #666; }
.in-jail .consumable-name { color: #b0b0b0; }
.in-jail .consumable-qty { color: #f0f0f0; }
.in-jail .muted,
.in-jail .status-task { color: #9a9a9a; }
.in-jail h3, .in-jail h4 { color: #dcdcdc; }
.in-jail a { color: #cbb58e; }
.in-jail table, .in-jail th, .in-jail td { border-color: #666 !important; }
.in-jail th { color: #b0b0b0; }
.in-jail td { color: #e0e0e0; }
.in-hospital {
  border-color: #a01010 !important;
  background: #750606 !important;
}
.in-hospital > h2 {
  background: #750606 !important;
  border-bottom-color: #a01010 !important;
}
.in-hospital .card-body {
  background: #750606;
}
.in-hospital .stat-item,
.in-hospital .stat-table td {
  background: #8a0808;
  border-color: #b01212;
}
.in-hospital .stat-label {
  color: #e0a0a0;
}
.in-hospital .stat-value {
  color: #f8e8e8;
}
.in-hospital .stat-divider {
  border-top-color: #a01010;
}
.in-hospital .placeholder {
  color: #c08080;
}
.in-hospital .stat-timer-value {
  color: #f0c0c0 !important;
}
.in-hospital .stat-timer-value.ready,
.in-hospital .stat-item-timer .stat-value.ready {
  color: #f08080 !important;
}
.cash-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 5px;
  cursor: pointer;
  color: #cdd6f4;
  background: #313244;
}
.cash-opt:hover { background: #45475a; }

/* ── Character History ──────────────────────────── */

/* Two-column grid that stacks on mobile */
.ch-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}
@media (max-width: 540px) {
  .ch-grid { grid-template-columns: 1fr; }
}
.ch-grid-item { display: flex; flex-direction: column; }

/* Section card */
.ch-section {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 8px;
  flex: 1;
}
.ch-section-full { margin-bottom: 8px; }
.ch-section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.ch-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  flex: 1;
}

/* Hide-zeros toggle — reuses the site's toggle-label, scaled down */
.ch-hz-toggle { transform: scale(0.75); transform-origin: right center; }

/* Key/value table */
.ch-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.ch-table td {
  padding: 4px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.ch-table tr:last-child td { border-bottom: none; }
.ch-key { color: var(--muted); width: 55%; }
.ch-val { font-weight: 500; text-align: right; }
.ch-money { color: var(--accent); }
.ch-empty-note { padding: 6px 10px; font-size: 0.75rem; color: var(--muted); }

/* Earn History table */
.ch-earn-table {
  border-collapse: separate; border-spacing: 0;
  border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--border); width: 100%;
}
.ch-earn-table td {
  border-bottom: 1px solid var(--border); vertical-align: top;
}
.ch-earn-table tr:last-child td { border-bottom: none; }
.ch-earn-cat {
  background: #3a4d6a;
  font-size: 0.68rem; font-weight: 700; color: #d8e2ee;
  text-transform: uppercase; letter-spacing: 0.05em;
  white-space: nowrap; padding: 6px 10px; width: 90px;
  vertical-align: middle; border-right: 1px solid var(--border);
}
.ch-earn-entries {
  padding: 0; background: var(--surface2);
}
.ch-earn-entry {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 10px; border-bottom: 1px solid var(--border);
}
.ch-earn-entry:last-child { border-bottom: none; }
.ch-earn-label { font-size: 0.8rem; color: var(--muted); }
.ch-earn-count {
  font-size: 0.8rem; font-weight: 600; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.ch-earn-entry.ch-earn-summary .ch-earn-count { color: var(--accent); }

/* Promotion choices */
.promo-row {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 4px 10px;
  padding: 5px 0;
  border-bottom: 1px solid #2a2a3a;
}
.promo-rank-name {
  font-size: 0.88rem;
  min-width: 140px;
  flex-shrink: 0;
  padding-top: 2px;
}
.promo-options {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
}
.promo-option {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  font-size: 0.78rem;
  color: var(--muted);
}

/* Promotion History */
.ch-table-scroll { overflow-x: auto; }
.ch-promo-table th {
  padding: 4px 10px; text-align: left; color: var(--muted);
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border); font-weight: 600; white-space: nowrap;
}
.ch-date { color: var(--muted); font-size: 0.75rem; white-space: nowrap; }

/* Unlocked skills/traits — single column list */
.ch-unlocked-list { list-style: none; margin: 0; padding: 0; }
.ch-unlocked-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 0.83rem;
}
.ch-unlocked-item:last-child { border-bottom: none; }
.ch-st-type {
  font-size: 0.65rem; font-weight: 700; color: var(--accent);
  text-transform: uppercase; letter-spacing: 0.05em;
  min-width: 36px;
}
.ch-st-name { color: var(--text); flex: 1; }
.ch-rank-badge {
  font-size: 0.72rem; background: var(--surface); color: var(--muted);
  border: 1px solid var(--border); border-radius: 3px;
  padding: 1px 5px; white-space: nowrap;
}

/* Locked traits panel */
.ch-locked-btn {
  background: var(--surface2); border: 1px solid var(--border); color: var(--muted);
  border-radius: var(--radius); padding: 2px 8px; font-size: 0.72rem;
  cursor: pointer; margin-left: auto;
}
.ch-locked-btn:hover { border-color: var(--accent); color: var(--accent); }
.ch-locked-divider {
  padding: 5px 10px; font-size: 0.68rem; font-weight: 700;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em;
  background: var(--surface); border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.ch-locked-item {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
}
.ch-locked-item:last-child { border-bottom: none; }
.ch-locked-row { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.ch-locked-name { color: var(--muted); flex: 1; font-size: 0.83rem; }
.ch-locked-desc { font-size: 0.75rem; color: var(--muted); opacity: 0.6; margin-bottom: 4px; }
.ch-req-unknown { font-style: italic; }
.ch-req { margin-top: 4px; }
.ch-req-label {
  font-size: 0.75rem; color: var(--muted);
  display: flex; justify-content: space-between;
  margin-bottom: 2px;
}
.ch-req-counts { color: var(--text); font-weight: 500; }
.ch-req-bar {
  height: 4px; background: var(--surface); border-radius: 2px; overflow: hidden;
}
.ch-req-fill {
  height: 100%; background: var(--accent); border-radius: 2px;
  transition: width 0.3s ease;
}

/* ── Tasks section ──────────────────────────────── */
.task-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.task-label {
  font-size: 0.83rem;
  color: var(--muted);
  min-width: 110px;
  flex-shrink: 0;
}
.task-select {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 5px 8px;
  font-size: 0.83rem;
  min-width: 180px;
}
.task-select-flex { flex: 1; min-width: 120px; }
.task-hint { font-size: 0.72rem; color: var(--muted); }
.task-hint-block { font-size: 0.82rem; color: var(--muted); margin-bottom: 10px; }
.task-panel { margin-top: 12px; }
.task-subpanel {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-top: 10px;
}
.task-inline-btn { white-space: nowrap; flex-shrink: 0; }
.task-submit-btn { margin-top: 6px; }
.task-feedback {
  padding: 7px 10px;
  border-radius: var(--radius);
  font-size: 0.82rem;
  margin-bottom: 8px;
}
.task-feedback-ok  { background: #1e3a2f; color: #a6e3a1; border: 1px solid #2a5a40; }
.task-feedback-error { background: #3a1e1e; color: #f38ba8; border: 1px solid #5a2a2a; }

/* ── Mobile layout fixes ────────────────────────── */
@media (max-width: 540px) {
  .task-row { flex-direction: column; align-items: flex-start; }
  .task-label { min-width: unset; }
  .card h2 { flex-wrap: wrap; }
  /* Pills wrap to their own row; toggle stays on the title row via order */
  .section-pills { flex-basis: 100%; margin-left: 0; order: 10; }
  .card h2 > .toggle-label { order: 5; margin-left: auto; }
}

/* ── Communications & Journals section ─────────── */
.cj-search-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.cj-entry {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
}
.cj-entry-title {
  font-weight: 600;
  color: var(--accent);
  font-size: 0.88rem;
}
.cj-entry-time {
  font-size: 0.75rem;
  color: var(--muted);
  margin-left: 8px;
}
.cj-entry-text {
  font-size: 0.83rem;
  color: var(--text);
  margin-top: 5px;
  line-height: 1.4;
}
.cj-entry.cj-inactive {
  opacity: 0.45;
}
.cj-pager {
  display: flex;
  gap: 4px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 10px;
}
.cj-pager button {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 4px 10px;
  font-size: 0.8rem;
  cursor: pointer;
}
.cj-pager button.active, .cj-pager button:hover {
  background: var(--accent);
  color: #1b2333;
  border-color: var(--accent);
}
.cj-empty {
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 20px 0;
}

.warrant-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  margin-top: 8px;
}
.warrant-table th {
  text-align: left;
  padding: 4px 8px;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.warrant-table td {
  padding: 5px 8px;
  vertical-align: middle;
  white-space: nowrap;
}
.warrant-table tr:nth-child(even) td {
  background: var(--bg-alt, rgba(255,255,255,0.03));
}

.autobuy-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  margin-top: 4px;
}
.autobuy-table th {
  text-align: left;
  padding: 4px 8px;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.autobuy-table td {
  padding: 5px 8px;
  vertical-align: middle;
}
.autobuy-table tr:nth-child(even) td {
  background: var(--bg-alt, rgba(255,255,255,0.03));
}

/* ── Players section ─────────────────────────────────────────────────────── */
.pl-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

/* Active players tab */
.pl-active-toolbar { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.pl-active-hint { font-size: 0.8rem; color: var(--muted); }
.pl-active-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.pl-legend-item { font-size: 0.72rem; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.pl-legend-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.pl-active-group { margin-bottom: 14px; }
.pl-active-group-head { font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 6px; border-bottom: 1px solid var(--border); padding-bottom: 3px; }
.pl-active-count { color: var(--text); font-weight: 400; }
.pl-active-names { display: flex; flex-wrap: wrap; gap: 4px 10px; }
.pl-active-name { background: none; border: none; padding: 2px 4px; font-size: 0.85rem; font-weight: 600; cursor: pointer; border-radius: 3px; text-transform: none; letter-spacing: 0; }
.pl-active-name:hover { background: var(--surface2); text-decoration: underline; }
.pl-active-empty { color: var(--muted); font-size: 0.82rem; font-style: italic; }

.pl-act-menu { position: fixed; z-index: 2000; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 32px rgba(0,0,0,.5); padding: 8px; min-width: 200px; max-width: 280px; display: flex; flex-direction: column; gap: 4px; }
.pl-act-menu-head { font-weight: 700; font-size: 0.95rem; padding: 2px 4px 4px; }
.pl-act-btn { text-align: left; background: #2e4060; border: 1px solid #3a4d70; color: var(--text); padding: 6px 10px; font-size: 0.8rem; text-transform: none; letter-spacing: 0; border-radius: 5px; }
.pl-act-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.pl-act-btn:disabled { opacity: .5; cursor: default; }
.pl-act-result { font-size: 0.78rem; padding: 6px 4px 2px; color: var(--muted); white-space: normal; }
.pl-act-menu-top { text-align: center; padding: 8px 4px 4px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.pl-act-avatar { width: 120px; height: 120px; object-fit: cover; border-radius: 50%; border: 2px solid var(--border); display: block; margin: 0 auto 6px; }
.pl-act-details { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 4px; }
.pl-act-row { display: flex; gap: 6px; font-size: 0.76rem; }
.pl-act-row > span { color: var(--muted); flex: 0 0 34px; }
.pl-act-row > b { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-act-unknown { color: var(--muted); font-style: italic; }
.pl-act-ok { color: #4ade80; }
.pl-act-fail { color: #f87171; }

/* Table */
.pl-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
}
.pl-th {
  text-align: left;
  padding: 6px 10px;
  background: var(--surface2, rgba(255,255,255,0.06));
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border, #333);
  white-space: nowrap;
  user-select: none;
}
.pl-th[data-col] { cursor: pointer; }
.pl-th[data-col]:hover { color: var(--text); }
.pl-th-sorted { color: var(--accent, #89b4fa) !important; }
.pl-sort-icon { font-size: 0.7rem; margin-left: 3px; opacity: 0.6; }
.pl-th-sorted .pl-sort-icon { opacity: 1; }

/* Columns dropdown sections */
.pl-col-section { margin-bottom: 4px; }
.pl-col-section:last-child { margin-bottom: 0; }
.pl-col-section-body label {
  display: flex; flex-direction: row; justify-content: space-between;
  align-items: center; gap: 8px;
  padding: 3px 0; cursor: pointer; font-size: 13px;
}
.pl-col-section-body label input[type="checkbox"] { flex-shrink: 0; }

/* Filter row under headers */
.pl-filter-cell {
  padding: 3px 4px;
  background: var(--surface, #181825);
  border-bottom: 2px solid var(--border, #333);
}
.pl-filter-input {
  width: 100%;
  background: var(--surface2, rgba(255,255,255,0.06));
  color: var(--text);
  border: 1px solid var(--border, #333);
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 0.75rem;
  box-sizing: border-box;
}

/* Data rows */
.pl-data-row td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border, #2a2a3a);
  vertical-align: middle;
}
.pl-data-row:hover td { background: var(--surface2, rgba(255,255,255,0.04)); }
.pl-row-expanded td { background: var(--surface2, rgba(255,255,255,0.04)); }

.pl-detail-row td { padding: 0; border-bottom: 2px solid var(--accent, #89b4fa); }
.pl-detail {
  padding: 12px 16px;
  background: var(--surface, #181825);
}

.pl-chevron { font-size: 0.7rem; margin-right: 4px; color: var(--muted); }

/* Assignment badges */
.pl-assign-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
  text-transform: capitalize;
}
.pl-assign-whitelist { background: rgba(50,200,100,0.2); color: #4ade80; }
.pl-assign-blacklist  { background: rgba(220,50,50,0.2);  color: #f87171; }

/* Detail panel */
.pl-detail-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  margin-bottom: 10px;
}
.pl-detail-item { font-size: 0.83rem; display: flex; flex-direction: column; gap: 2px; }
.pl-detail-label { color: var(--text-muted); font-size: 0.72rem; }

.pl-history-toggle {
  font-size: 0.8rem;
  color: var(--accent, #89b4fa);
  cursor: pointer;
  margin-top: 4px;
  display: inline-block;
}
.pl-history-toggle:hover { opacity: 0.8; }

.pl-history-table {
  border-collapse: collapse;
  font-size: 0.75rem;
  margin-top: 8px;
}
.pl-history-table th {
  text-align: left;
  padding: 4px 8px;
  background: var(--surface2, rgba(255,255,255,0.06));
  color: var(--text-muted);
  font-size: 0.72rem;
  border-bottom: 1px solid var(--border, #333);
}
.pl-history-table td {
  padding: 4px 8px;
  border-bottom: 1px solid var(--border, #2a2a3a);
}
.pl-history-table tr:nth-child(even) td { background: var(--surface2, rgba(255,255,255,0.03)); }

.pl-detail select { max-width: 200px; }

/* Mobile: player detail panel — one field per line */
@media (max-width: 600px) {
  .pl-detail-grid {
    flex-direction: column;
    gap: 8px 0;
  }
  .pl-detail-item { flex-direction: row; align-items: center; gap: 6px; }
  .pl-detail-label { min-width: 80px; flex-shrink: 0; }
  .pl-detail { padding: 10px 12px; }
  .pl-detail select,
  .pl-detail textarea { max-width: 100% !important; width: 100% !important; }
  .pl-history-table { font-size: 0.68rem; }
  .pl-history-table th,
  .pl-history-table td { padding: 2px 3px; }
}

/* Tags & badges */
.pl-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.pl-tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(137,180,250,0.18);
  color: var(--accent, #89b4fa);
}
.pl-group-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 10px;
  color: #fff;
  white-space: nowrap;
}

/* Colour swatches */
.pl-swatches {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-wrap: wrap;
}
.pl-swatch {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.1s, border-color 0.1s;
}
.pl-swatch:hover { transform: scale(1.2); }
.pl-swatch.selected { border-color: #fff; transform: scale(1.15); }

/* Group type indicators */
.pl-type-friendly { color: #4ade80; }
.pl-type-enemy    { color: #f87171; }
.pl-type-neutral  { color: var(--muted); }

/* Modal overlay */
.pl-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.pl-modal-overlay.active {
  display: flex;
}
.pl-modal-box {
  background: var(--surface, #1e1e2e);
  border: 1px solid var(--border, #333);
  border-radius: 10px;
  padding: 24px;
  min-width: 300px;
  max-width: 480px;
  width: 90%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.pl-modal-box h3 { margin: 0; font-size: 1rem; }
.pl-modal-box > div { display: flex; gap: 8px; justify-content: flex-end; }
#skill-overlay .pl-modal-box { max-width: 360px; }
#skill-overlay-body { flex-direction: column; justify-content: flex-start; gap: 12px; }

/* Icon buttons */
.pl-icon-btn {
  background: none;
  border: 1px solid var(--border, #333);
  border-radius: 6px;
  padding: 4px 6px;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
}
.pl-icon-btn:hover { border-color: var(--accent, #7c3aed); color: var(--accent, #7c3aed); }
.pl-icon-btn-danger {
  background: none;
  border: 1px solid var(--border, #333);
  border-radius: 6px;
  padding: 4px 6px;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
}
.pl-icon-btn-danger:hover { border-color: #ef4444; color: #ef4444; }

/* Danger button */
.btn-danger {
  background: #ef4444;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 0.85rem;
}
.btn-danger:hover { background: #dc2626; }

/* Colour select */
.pl-color-select {
  font-family: monospace;
  border-left: 10px solid var(--pl-sel-color, #3498db) !important;
  padding-left: 6px;
}

/* Import textarea */
.pl-import-textarea {
  width: 100%;
  min-height: 100px;
  background: var(--surface, #181825);
  color: var(--text);
  border: 1px solid var(--border, #333);
  border-radius: 6px;
  padding: 8px;
  font-size: 0.85rem;
  font-family: monospace;
  resize: vertical;
  box-sizing: border-box;
}

/* ── Mobile overflow fixes ───────────────────────── */
.card { overflow: hidden; }

.setting-btn-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

@media (max-width: 600px) {
  .setting-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .setting-row > span,
  .setting-row > label:first-child {
    font-size: 11px;
    color: var(--muted);
  }
  label.setting-row.inline-toggle {
    grid-template-columns: 1fr auto;
  }
  .setting-row select { width: auto !important; }
  .setting-btn-row { width: 100%; }
}

/* Eliminate 300ms tap delay on all interactive elements */
button, [onclick] { touch-action: manipulation; }

/* Responsive tab label — short on mobile, full on desktop */
.tab-label-short { display: none; }
.tab-label-long  { display: inline; }
@media (max-width: 600px) {
  .tab-label-short { display: inline; }
  .tab-label-long  { display: none; }
}

/* ── Income section — 3-row pills in header ─────── */
.income-h2 { align-items: flex-start !important; }
.income-pills-block {
  display: none;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
  margin-left: 4px;
  padding-top: 1px;
}
.is-collapsed .income-pills-block { display: flex; }
.income-pills-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
  min-height: 18px;
}
.income-pills-row:empty { display: none; }

/* ── Disabled tab coloring ───────────────────────── */
.tab-btn.tab-disabled { color: var(--red); border-bottom-color: rgba(204,42,42,0.5); }
.tab-btn.tab-disabled:hover { color: var(--red-hover); border-bottom-color: var(--red); }
.tab-btn.tab-disabled.active { color: var(--red); border-bottom-color: var(--red); }

/* ── Notifications tab ────────────────────────────── */
.notif-tab-head {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-bottom: 10px;
}
.notif-tab-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent;
}
.notif-tab-item:last-child { border-bottom: none; }
.notif-tab-item-unread {
  border-left-color: var(--accent);
  background: rgba(200,168,75,0.05);
}
.notif-tab-item-body { flex: 1; min-width: 0; }
.notif-tab-ts { font-size: 0.72rem; color: var(--muted); display: block; margin-bottom: 2px; }
.notif-tab-msg { font-size: 0.85rem; word-break: break-word; color: var(--text); }
.notif-tab-item-unread .notif-tab-msg { font-weight: 600; }
.notif-tab-item-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* Unread-count badge overlaid on the Notifications main tab's icon */
.notif-count-badge {
  display: none;
  position: absolute;
  top: 2px;
  right: 2px;
  background: var(--red, #cc2a2a);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  border-radius: 8px;
  padding: 0 4px;
  min-width: 14px;
  line-height: 14px;
  text-align: center;
}
.notif-count-badge.has-count { display: flex; align-items: center; justify-content: center; }

/* Cross-tab settings-sync banner */
.settings-sync-banner {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3000;
  background: var(--surface, #1b2a3a);
  border: 1px solid var(--accent, #4d7fe0);
  color: var(--text, #e8eef5);
  padding: 8px 12px;
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0,0,0,.5);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.settings-sync-banner button {
  background: var(--accent, #4d7fe0);
  color: #fff;
  border: none;
  border-radius: 5px;
  padding: 3px 10px;
  font-size: 0.8rem;
  cursor: pointer;
}
.settings-sync-banner button.dismiss {
  background: transparent;
  color: var(--muted, #9aa7b4);
  padding: 3px 6px;
}

#s-players { position: relative; }

/* Career filter tabs */
.pl-career-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.pl-career-tab { background: var(--bg-alt); border: 1px solid var(--border); color: var(--muted); padding: 2px 8px; font-size: 0.72rem; border-radius: 12px; cursor: pointer; }
.pl-career-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pl-career-tab:hover:not(.active) { border-color: var(--accent); color: var(--text); }

/* Mayor italics */
.pl-active-mayor { font-style: italic; }

/* ── Communications ──────────────────────────────────────────────────────── */
.comms-row { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 6px; cursor: pointer; transition: border-color 0.15s; }
.comms-row:hover { border-color: var(--accent); }
.comms-row-header { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.comms-row-player { font-weight: 600; color: var(--accent); font-size: 0.88rem; }
.comms-row-count { font-size: 0.88rem; font-weight: 600; color: var(--text); }
.comms-row-time { font-size: 0.78rem; color: var(--muted); margin-left: auto; }
.comms-row-subject { font-size: 0.85rem; font-weight: 600; color: var(--text); }
.comms-row-excerpt { font-size: 0.83rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.comms-search-row { display: flex; gap: 6px; }

.comms-message { padding: 6px 0; font-size: 0.88rem; line-height: 1.5; border-bottom: 1px solid var(--border); }
.comms-msg-from { font-weight: 600; color: var(--accent); }
.comms-msg-time { font-size: 0.78rem; color: var(--muted); margin-bottom: 2px; }

.comms-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 1000; justify-content: center; align-items: center; }
.comms-overlay-content { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 16px; width: 440px; max-width: 95vw; max-height: 85vh; overflow-y: auto; }

/* ── Main Tab Bar ──────────────────────────────────────────────────────── */
.main-tab-bar {
  display: flex;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  position: sticky;
  top: 0;
  z-index: 50;
  margin-bottom: 14px;
}
.main-tab-bar::-webkit-scrollbar { display: none; }

.main-tab {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.main-tab:hover { color: var(--text); background: rgba(200,168,75,0.06); }
.main-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: rgba(200,168,75,0.08);
}
.main-tab-icon { display: block; flex-shrink: 0; width: 22px; height: 22px; }
.main-tab-label { display: none; }

/* Section visibility — only active section shown */
main > section.main-section { display: none; }
main > section.main-section.main-active { display: block; }

/* Mobile: tighter tab padding */
@media (max-width: 540px) {
  .main-tab { padding: 10px 10px; }
  .main-tab-icon { width: 18px; height: 18px; }
}

/* In-jail theme overrides */
.in-jail .main-tab.active { color: #e0e0e0; border-bottom-color: #e0e0e0; background: rgba(255,255,255,0.06); }
.in-jail .main-tab:hover { color: #ccc; background: rgba(255,255,255,0.04); }

/* ── War Mode ─────────────────────────────────────────────────────────────
   Shared between the standalone /war page and the embedded War Mode main tab. */
.war-add { display:flex; gap:8px; align-items:center; flex-wrap:wrap; margin-bottom:12px; }
.war-add input[type=text] { width:200px; }
.war-table { width:100%; border-collapse:collapse; margin-bottom:8px; font-size:0.82rem; }
.war-table th, .war-table td { border:1px solid var(--border); padding:5px 7px; text-align:left; }
.war-table th { background:var(--surface2); color:var(--muted); text-transform:uppercase; font-size:0.7rem; letter-spacing:.04em; }
.war-status { font-weight:700; }
.war-status.Open { color:#5bbf5b; }
.war-status.In-Window { color:#e0a53a; }
.war-status.Protected { color:#cc5555; }
.war-whack-cell { white-space:nowrap; }
.war-clear { background:transparent; border:none; color:var(--muted); cursor:pointer; font-size:0.85rem; padding:0 4px; }
.war-clear:hover { color:var(--red); }
.war-th { cursor:pointer; user-select:none; white-space:nowrap; }
.war-th:hover { color:var(--accent); }
.war-actions { display:flex; gap:6px; }
.war-btn { padding:3px 10px; font-size:0.72rem; }
.war-del:hover { border-color:var(--red); color:var(--red); }
.war-log { background:var(--surface2); border:1px solid var(--border); border-radius:6px; padding:8px; height:200px; overflow-y:auto; font-family:monospace; font-size:0.78rem; }
.war-log-line { padding:2px 0; border-bottom:1px solid rgba(255,255,255,.05); }
.war-empty { color:var(--muted); font-style:italic; }
.war-time-input { width:150px; font-size:0.78rem; }
.war-table-wrap { overflow-x:auto; -webkit-overflow-scrolling:touch; }

/* Phones: stack each row into a labelled card instead of a wide table. */
@media (max-width: 640px) {
  .war-add input[type=text] { width:100%; }
  .war-table-wrap { overflow-x:visible; }
  .war-table { font-size:0.85rem; }
  .war-table thead { display:none; }
  .war-table, .war-table tbody, .war-table tr, .war-table td { display:block; width:100%; }
  .war-table tr { border:1px solid var(--border); border-radius:8px; margin-bottom:10px; background:var(--surface2); }
  .war-table td { border:none; border-bottom:1px solid rgba(255,255,255,.06); padding:8px 12px;
                  display:flex; justify-content:space-between; align-items:center; gap:12px; }
  .war-table td:last-child { border-bottom:none; }
  .war-table td::before { content:attr(data-label); color:var(--muted); font-size:0.7rem;
                          text-transform:uppercase; letter-spacing:.04em; flex:0 0 auto; }
  .war-table td[data-label=""]::before { content:""; }
  .war-time-input { width:auto; flex:1; min-width:0; }
  .war-table select { width:auto; max-width:60%; }
}

/* ── Earn Category Manager ──────────────────────────────────────────────── */
.earn-cat-modal {
  background: #1e1e2e; border: 1px solid #444; border-radius: 8px;
  padding: 24px; width: 100%; max-width: 680px;
}
.earn-cat-add-row {
  display: flex; gap: 8px; align-items: center; margin-bottom: 16px;
}
.earn-cat-group { margin-bottom: 2px; }
.earn-cat-header {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; background: #252536; border-radius: 6px;
  cursor: pointer; user-select: none;
}
.earn-cat-header:hover { background: #2a2a40; }
.earn-cat-arrow {
  font-size: 0.7rem; color: var(--muted); transition: transform 0.15s;
  width: 12px; text-align: center; flex-shrink: 0;
}
.earn-cat-group.open > .earn-cat-header > .earn-cat-arrow { transform: rotate(90deg); }
.earn-cat-name {
  flex: 1; font-weight: 600; font-size: 0.88rem; color: #cdd6f4;
}
.earn-cat-count {
  font-size: 0.78rem; color: var(--muted); margin-right: 4px;
}
.earn-cat-actions { display: flex; gap: 4px; }
.earn-cat-actions button {
  background: none; border: 1px solid transparent; color: var(--muted);
  border-radius: 4px; padding: 2px 8px; font-size: 0.78rem; cursor: pointer;
}
.earn-cat-actions button:hover { border-color: var(--accent); color: var(--accent); }
.earn-cat-actions .ec-del:hover { border-color: #ef4444; color: #ef4444; }
.earn-cat-items {
  display: none; padding: 4px 0 4px 24px;
}
.earn-cat-group.open > .earn-cat-items { display: block; }
.earn-cat-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 8px; border-bottom: 1px solid #2a2a3a; font-size: 0.84rem;
}
.earn-cat-row-label { flex: 1; color: #cdd6f4; }
.earn-cat-row select {
  background: #2a2a3a; color: #cdd6f4; border: 1px solid #444;
  border-radius: 4px; padding: 3px 6px; font-size: 0.82rem;
}
.earn-cat-rename-input {
  background: #2a2a3a; color: #cdd6f4; border: 1px solid var(--accent);
  border-radius: 4px; padding: 4px 8px; font-size: 0.85rem; width: 100%;
}
.earn-cat-loading {
  text-align: center; color: var(--muted); padding: 32px 0; font-size: 0.9rem;
}
