:root {
  --sidebar-w: 220px;
  --sidebar-bg: #1a1d23;
  --sidebar-text: #c4c9d4;
  --sidebar-active: #4f8cff;
  --bg: #f0f2f5;
  --card-bg: #fff;
  --text: #1a1d23;
  --text-muted: #6b7280;
  --border: #e2e5ea;
  --accent: #4f8cff;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --radius: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
#sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 10;
}
#sidebar.hidden { display: none; }

.sidebar-header {
  padding: 20px 16px;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid #2a2d35;
}

#nav-links { flex: 1; padding: 12px 0; }

#nav-links a {
  display: block;
  padding: 10px 16px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 14px;
  transition: background .15s, color .15s;
}
#nav-links a:hover { background: #2a2d35; color: #fff; }
#nav-links a.active { background: var(--sidebar-active); color: #fff; }

#nav-user {
  padding: 12px 16px;
  border-top: 1px solid #2a2d35;
  font-size: 13px;
}
#nav-user .nickname { color: #fff; font-weight: 600; }
#nav-user button {
  margin-top: 8px;
  background: none;
  border: 1px solid #555;
  color: var(--sidebar-text);
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}
#nav-user button:hover { border-color: var(--danger); color: var(--danger); }

/* Main content */
#app {
  flex: 1;
  padding: 24px 32px;
}
body:not(:has(#sidebar.hidden)) #app {
  margin-left: var(--sidebar-w);
}

/* Cards */
.cards { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  flex: 1;
  min-width: 180px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.card-label { font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
.card-value { font-size: 28px; font-weight: 700; }

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.data-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  background: #fafbfc;
}
.data-table td {
  padding: 10px 14px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f7f8fa; }
.data-table tr.clickable { cursor: pointer; }

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}
.badge-green { background: #dcfce7; color: #166534; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-gray { background: #f3f4f6; color: #374151; }
.badge-yellow { background: #fef3c7; color: #92400e; }

/* Buttons */
.btn {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: opacity .15s;
}
.btn:hover { opacity: .85; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: #b45309; color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* Admin integrity tool: undealt-board projection strip (live-table page) */
.upcoming-board {
  margin: 8px 0 12px;
  padding: 8px 12px;
  background: #2a2214;
  border: 1px solid #b45309;
  border-radius: 6px;
  font-size: 13px;
}
.upcoming-board .upcoming-label { font-weight: 600; margin-right: 6px; }
.upcoming-board .upcoming-note { color: var(--text-secondary, #9ca3af); font-style: italic; }

/* Tabs */
.tabs { display: flex; gap: 0; margin-bottom: 20px; border-bottom: 2px solid var(--border); }
.tab {
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  border: none;
  background: none;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* Section headers */
.section-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 20px;
}

/* Login */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  width: 100%;
}
.login-box {
  background: var(--card-bg);
  padding: 40px;
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0,0,0,.1);
  width: 340px;
}
.login-box h1 { font-size: 22px; margin-bottom: 24px; text-align: center; }
.login-box input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  margin-bottom: 12px;
}
.login-box input:focus { outline: none; border-color: var(--accent); }
.login-box .btn { width: 100%; padding: 10px; font-size: 15px; }
.login-error { color: var(--danger); font-size: 13px; margin-bottom: 12px; text-align: center; }

/* Utility */
.loading { color: var(--text-muted); padding: 40px; text-align: center; }
.error-msg { color: var(--danger); padding: 20px; background: #fee2e2; border-radius: var(--radius); margin-bottom: 16px; }
.empty-msg { color: var(--text-muted); padding: 20px; text-align: center; }
.pager { display: flex; align-items: center; gap: 12px; padding: 12px 4px; justify-content: flex-end; }
.pager-info { color: var(--text-muted); font-size: 13px; }
.pager .btn[disabled] { opacity: 0.45; cursor: default; pointer-events: none; }
.mon-h { font-size: 16px; font-weight: 600; margin: 20px 0 12px; }
.mon-ok { color: var(--success, #16a34a); }
.mon-warn { color: #d97706; }
.mon-bad { color: var(--danger, #dc2626); }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

/* Live monitoring */
.live-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.live-table-name { font-size: 18px; font-weight: 700; flex: 1; }

.live-info-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card-bg);
  padding: 12px 16px;
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  margin-bottom: 16px;
  font-size: 14px;
  gap: 16px;
  flex-wrap: wrap;
}
.pot-display { font-weight: 700; font-size: 16px; }

/* Board */
.board {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  background: #2d5a3c;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  min-height: 80px;
}

/* Cards */
.poker-card {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 60px;
  background: #fff;
  border: 2px solid #d1d5db;
  border-radius: 6px;
  font-family: "Segoe UI", monospace;
  font-size: 16px;
  font-weight: 700;
}
.poker-card.red { color: #dc2626; }
.poker-card.black { color: #1a1d23; }
.card-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 60px;
  border-radius: 6px;
  font-size: 16px;
  font-weight: 700;
}
.card-slot.empty { background: rgba(255,255,255,.15); border: 2px dashed rgba(255,255,255,.3); }
.card-slot.facedown { background: #4b5563; color: #9ca3af; border: 2px solid #6b7280; }

/* Seat grid */
.seat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
}
.seat {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  border: 2px solid transparent;
  transition: border-color .2s, opacity .2s;
}
.seat.current-turn {
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(79,140,255,.3);
}
.seat.folded { opacity: .45; }
.seat.disconnected { border-style: dashed; border-color: var(--warning); opacity: .7; }

.seat-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.seat-no { font-size: 12px; color: var(--text-muted); }
.seat-user { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
/* The id trails the nickname it belongs to: still there for a report, but no longer
   competing with the name an operator is actually reading. */
.seat-uid { font-weight: 400; font-size: 12px; color: var(--text-muted); }
/* Projected winner of the hand, under the projected board it is derived from. */
.proj-winners { margin-top: 6px; font-size: 13px; }
.proj-label { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.proj-winner { font-weight: 600; }
.seat-stack { font-size: 15px; font-weight: 700; color: var(--accent); margin-bottom: 6px; }
.seat-cards { display: flex; gap: 4px; margin-bottom: 6px; }
.seat-cards .poker-card { width: 36px; height: 50px; font-size: 13px; }
.seat-cards .card-slot { width: 36px; height: 50px; font-size: 13px; }
.seat-bet { font-size: 12px; color: var(--warning); font-weight: 600; }
.seat-disc { font-size: 11px; color: var(--danger); font-weight: 600; margin-top: 4px; }

.pos-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
}
.btn-badge { background: #6366f1; }
.sb-badge { background: #64748b; }
.bb-badge { background: #0ea5e9; }

/* Investigation */
.investigate-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.investigate-header .section-title { margin-bottom: 0; flex: 1; }

.flag-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  border-left: 4px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.flag-card strong { display: block; margin-bottom: 4px; }
.flag-card p { font-size: 13px; color: var(--text-muted); margin: 0; }
.flag-red { border-left-color: var(--danger); }
.flag-yellow { border-left-color: var(--warning); }
.flag-green { border-left-color: var(--success); }

.amount-positive { color: var(--success); font-weight: 600; }
.amount-negative { color: var(--danger); font-weight: 600; }

.reconcile-box {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.reconcile-card {
  flex: 1;
  min-width: 200px;
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.reconcile-card .value { font-size: 28px; font-weight: 700; margin: 8px 0; }
.reconcile-card .label { font-size: 13px; color: var(--text-muted); }

.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filter-bar select, .filter-bar input {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
}
.filter-bar select:focus, .filter-bar input:focus { outline: none; border-color: var(--accent); }

/* Integrity columns */
.int-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 24px; }
@media (max-width: 900px) { .int-columns { grid-template-columns: 1fr; } }

/* Generic utility */
.hidden { display: none; }
.muted { color: var(--text-muted); font-size: 12px; }

/* Support page */
.support-msg { max-width: 420px; white-space: pre-wrap; word-break: break-word; }
