:root {
  --bg: #0b0a09;
  --surface: #161311;
  --surface-2: #1e1a17;
  --text: #f2ece1;
  --muted: #a89a86;
  --border: #2e2822;
  --gold: #e6b325;
  --gold-bright: #ffd85e;
  --red: #dc2626;
  --red-bright: #ff4d4d;
  --accent: var(--gold);
  --accent-text: #17130c;
  --success: #4ade80;
  --success-bg: #12281a;
  --warn: #facc15;
  --warn-bg: #2e2405;
  --danger: var(--red-bright);
  --danger-bg: #2d0f0e;
  --neutral-bg: #1e1a17;
}

/* This brand is dark-first by design (matches the logo's black/gold/red),
   so we intentionally keep the same palette regardless of OS light/dark
   preference — only an explicit override changes it. */
:root[data-theme="light"] {
  --bg: #f7f3ec;
  --surface: #ffffff;
  --surface-2: #f0e9db;
  --text: #201a12;
  --muted: #6b5f4d;
  --border: #e4d9c4;
  --accent-text: #17130c;
  --neutral-bg: #f0e9db;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a { color: var(--gold-bright); }

/* ---------- layout ---------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  text-decoration: none;
  border-bottom: 1px solid var(--border);
}
.brand img { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; }
.brand span {
  font-weight: 800;
  color: var(--gold-bright);
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  line-height: 1.15;
}

.nav { display: flex; flex-direction: column; padding: 12px 10px; gap: 2px; flex: 1; }
.nav a {
  padding: 9px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.92rem;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--surface-2); color: var(--gold-bright); }

.sidebar-footer {
  padding: 14px 16px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.guild-switcher label { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.guild-switcher select {
  width: 100%;
  margin-top: 3px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.85rem;
}
.guild-current { font-size: 0.85rem; color: var(--text); font-weight: 600; }
.who { color: var(--muted); font-size: 0.8rem; margin-top: 4px; }
.logout-link { font-size: 0.8rem; color: var(--muted); text-decoration: none; }
.logout-link:hover { color: var(--red-bright); }

main { flex: 1; min-width: 0; }
main.no-sidebar { min-height: 100vh; }
.main-inner { max-width: 1040px; margin: 0 auto; padding: 32px 28px 64px; }

h1 { font-size: 1.5rem; margin: 0 0 20px; color: var(--text); }
h2 { font-size: 1.1rem; color: var(--text); }

/* ---------- shared components ---------- */

.center-card {
  max-width: 420px;
  margin: 80px auto 0;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 44px 36px;
}
.center-card img { width: 88px; margin-bottom: 12px; border-radius: 16px; }
.center-card p { color: var(--muted); }

.button, button, .link-button {
  display: inline-block;
  background: var(--gold);
  color: var(--accent-text);
  border: none;
  padding: 9px 18px;
  border-radius: 8px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  font-size: 0.9rem;
}
.button:hover, button:hover { background: var(--gold-bright); }
.button.danger, button.danger { background: var(--red); color: #fff; }
.button.danger:hover, button.danger:hover { background: var(--red-bright); }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.table-scroll { overflow-x: auto; border-radius: 10px; }

th, td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
  white-space: nowrap;
}
th { color: var(--muted); font-weight: 600; background: var(--neutral-bg); }
tr:last-child td { border-bottom: none; }
.row-link { cursor: pointer; }
.row-link:hover { background: var(--surface-2); }
.row-actions a, .row-actions .link-button {
  background: none; color: var(--gold-bright); padding: 0; margin-right: 12px; font-weight: 600;
}
.inline-form-tiny { display: inline; }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: capitalize;
  background: var(--neutral-bg);
  color: var(--muted);
}
.status-paid, .status-fulfilled, .status-active { background: var(--success-bg); color: var(--success); }
.status-awaiting_payment, .status-pending_approval { background: var(--warn-bg); color: var(--warn); }
.status-refunded, .status-cancelled { background: var(--danger-bg); color: var(--danger); }

.filters { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.chip {
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  text-transform: capitalize;
}
.chip.active { background: var(--gold); color: var(--accent-text); border-color: var(--gold); }

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

dl { display: grid; grid-template-columns: 160px 1fr; row-gap: 10px; margin: 0 0 20px; }
dt { color: var(--muted); font-weight: 500; }
dd { margin: 0; }

.inline-form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.inline-form select { padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); }
.hint { color: var(--muted); font-size: 0.85rem; margin-top: 12px; }

.form-grid { display: flex; flex-direction: column; gap: 16px; max-width: 480px; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 0.9rem; }
.form-grid input, .form-grid textarea, .form-grid select {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
}
.form-grid select[multiple] { min-height: 130px; }
.checkbox-label { flex-direction: row !important; align-items: center; gap: 8px !important; }
.form-grid button { align-self: flex-start; }

.back-link { display: inline-block; margin-bottom: 12px; text-decoration: none; color: var(--muted); font-size: 0.9rem; }
.empty { color: var(--muted); }

/* ---------- overview stat cards ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
}
.stat-card .value { font-size: 1.6rem; font-weight: 800; color: var(--gold-bright); }
.stat-card .label { color: var(--muted); font-size: 0.82rem; margin-top: 2px; }

.section-title { font-size: 1rem; color: var(--text); margin: 28px 0 12px; }

/* ---------- /servers picker page ---------- */

.servers-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.servers-topbar .brand { padding: 0; border: none; }

.server-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}
.server-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.server-icon { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; }
.server-icon-placeholder {
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--gold-bright);
  font-weight: 800; font-size: 1.4rem;
}
.server-name { font-weight: 700; font-size: 0.95rem; }
