:root {
  --bg: #0a0e1a;
  --bg-2: #0e1424;
  --panel: rgba(255, 255, 255, 0.035);
  --panel-hover: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #e7eaf3;
  --muted: #8a92a8;
  --accent-1: #22d3ee;
  --accent-2: #818cf8;
  --accent-3: #c084fc;
  --danger: #f87171;
  --ok: #34d399;
  --radius: 14px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.35);
  --grad: linear-gradient(135deg, var(--accent-1), var(--accent-2), var(--accent-3));
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- Light theme ---------- */
[data-theme="light"] {
  --bg: #f4f6fb;
  --bg-2: #e9edf6;
  --panel: rgba(255, 255, 255, 0.7);
  --panel-hover: rgba(255, 255, 255, 0.95);
  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.14);
  --text: #0f172a;
  --muted: #5b6478;
  --shadow-soft: 0 10px 30px rgba(15, 23, 42, 0.12);
}

[data-theme="light"] body {
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(129, 140, 248, 0.18), transparent 60%),
    radial-gradient(900px 500px at 10% 110%, rgba(34, 211, 238, 0.14), transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
}

[data-theme="light"] .topbar { background: rgba(244, 246, 251, 0.8); }
[data-theme="light"] .auth-card,
[data-theme="light"] .captcha-img { background: rgba(255, 255, 255, 0.82); }
[data-theme="light"] .data-table th { background: #eef1f8; }
[data-theme="light"] .data-table tbody tr:hover td { background: rgba(15, 23, 42, 0.03); }
[data-theme="light"] .toast { background: rgba(255, 255, 255, 0.96); color: var(--text); }
[data-theme="light"] .null { color: #94a3b8; }

/* ---------- Aurora animated background ---------- */
.aurora {
  position: fixed;
  inset: -20% -20% -20% -20%;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(40% 50% at 20% 20%, rgba(34, 211, 238, 0.16), transparent 60%),
    radial-gradient(45% 55% at 80% 30%, rgba(129, 140, 248, 0.18), transparent 60%),
    radial-gradient(40% 50% at 50% 90%, rgba(192, 132, 252, 0.14), transparent 60%);
  filter: blur(20px);
  animation: auroraMove 18s var(--ease) infinite alternate;
}

[data-theme="light"] .aurora { opacity: 0.7; }

@keyframes auroraMove {
  0%   { transform: translate3d(0, 0, 0) scale(1); }
  50%  { transform: translate3d(-3%, 2%, 0) scale(1.08); }
  100% { transform: translate3d(3%, -2%, 0) scale(1.04); }
}

@media (prefers-reduced-motion: reduce) {
  .aurora { animation: none; }
}

/* ---------- Entrance animations ---------- */
@keyframes riseIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.anim {
  animation: riseIn 0.6s var(--ease) both;
}
.anim-1 { animation-delay: 0.05s; }
.anim-2 { animation-delay: 0.12s; }
.anim-3 { animation-delay: 0.2s; }
.anim-4 { animation-delay: 0.28s; }

@media (prefers-reduced-motion: reduce) {
  .anim, .anim-1, .anim-2, .anim-3, .anim-4 { animation: none; }
}

/* ---------- Hover-lift for cards ---------- */
.meta-card, .panel, .acc-row, .ref-row {
  transition: transform 0.18s var(--ease), border-color 0.18s var(--ease), box-shadow 0.18s var(--ease), background 0.15s ease;
}
.meta-card:hover, .panel:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-soft);
}
.btn, .table-item, .db-name { transition: transform 0.08s ease, background 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease, border-color 0.15s ease; }

/* ---------- Theme toggle icon ---------- */
.theme-icon { font-size: 16px; line-height: 1; }

/* ---------- Split auth layout ---------- */
.auth-split {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  min-height: 100vh;
}

.auth-aside {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 54px 48px;
  background: linear-gradient(150deg, rgba(34, 211, 238, 0.16), rgba(129, 140, 248, 0.24) 45%, rgba(192, 132, 252, 0.2));
  border-right: 1px solid var(--border);
}

.auth-aside::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(600px 400px at 30% 20%, rgba(255, 255, 255, 0.12), transparent 60%);
  pointer-events: none;
}

.aside-brand { display: flex; align-items: center; gap: 12px; position: relative; z-index: 1; }
.aside-brand .brand-text { font-size: 18px; }
.aside-hero { position: relative; z-index: 1; max-width: 460px; }
.aside-hero h2 {
  font-family: var(--display);
  font-size: 34px;
  line-height: 1.15;
  font-weight: 700;
  margin-bottom: 14px;
}
.aside-hero p { color: var(--text); opacity: 0.82; font-size: 15px; line-height: 1.6; }

.aside-feats { list-style: none; margin-top: 26px; display: flex; flex-direction: column; gap: 14px; }
.aside-feats li { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.aside-feats .fi {
  width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
  background: rgba(255, 255, 255, 0.16); border: 1px solid rgba(255, 255, 255, 0.22);
}
.aside-foot { position: relative; z-index: 1; font-size: 12.5px; color: var(--text); opacity: 0.7; }

.auth-main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  position: relative;
}

@media (max-width: 860px) {
  .auth-split { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
}

/* ---------- Skeleton loader ---------- */
.skeleton-block {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
}
.sk {
  background: linear-gradient(90deg, rgba(255,255,255,0.05) 25%, rgba(255,255,255,0.12) 37%, rgba(255,255,255,0.05) 63%);
  background-size: 400% 100%;
  border-radius: 8px;
  animation: shimmer 1.4s ease infinite;
}
[data-theme="light"] .sk {
  background: linear-gradient(90deg, rgba(15,23,42,0.05) 25%, rgba(15,23,42,0.1) 37%, rgba(15,23,42,0.05) 63%);
  background-size: 400% 100%;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .sk { animation: none; } }

.sk-line { height: 13px; margin: 9px 0; }
.sk-title { height: 22px; width: 45%; margin-bottom: 16px; }
.sk-card { height: 70px; border-radius: 12px; }
.sk-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 18px 0; }

/* ---------- Donut charts ---------- */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}
.donut-wrap { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.donut { flex-shrink: 0; }
.donut-legend { display: flex; flex-direction: column; gap: 7px; font-size: 12.5px; min-width: 0; }
.donut-legend .lg { display: flex; align-items: center; gap: 8px; }
.donut-legend .dot { width: 9px; height: 9px; border-radius: 3px; flex-shrink: 0; }
.donut-legend .lg-name { color: var(--text); }
.donut-legend .lg-val { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.donut-empty { color: var(--muted); font-size: 12.5px; padding: 14px 0; }

@media (max-width: 560px) {
  .charts-grid { grid-template-columns: 1fr; }
  .sk-grid { grid-template-columns: 1fr; }
}

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

html, body { height: 100%; }

body {
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(129, 140, 248, 0.12), transparent 60%),
    radial-gradient(900px 500px at 10% 110%, rgba(34, 211, 238, 0.08), transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--muted); }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 60px;
  background: rgba(10, 14, 26, 0.72);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2), var(--accent-3));
  box-shadow: 0 4px 16px rgba(129, 140, 248, 0.45);
  flex-shrink: 0;
}

.brand-mark.large {
  width: 52px;
  height: 52px;
  border-radius: 15px;
  margin: 0 auto;
}

.brand-text { font-weight: 700; letter-spacing: 0.4px; font-size: 16px; }
.brand-text em { color: var(--accent-2); font-style: normal; }

.topbar-right { display: flex; align-items: center; gap: 14px; }

.inline-form { display: inline; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  font-size: 13px;
}

.chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
}

.chip-tag {
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(248, 113, 113, 0.15);
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.3);
}

/* ---------- Buttons ---------- */
.btn {
  font: inherit;
  font-size: 14px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  padding: 9px 18px;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  color: var(--text);
  background: var(--panel);
}

.btn:hover { background: var(--panel-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  border: none;
  color: #fff;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
}
.btn-primary:hover { filter: brightness(1.08); }

.btn-ghost { background: transparent; }
.btn-block { width: 100%; }

.icon-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
}
.icon-btn:hover { color: var(--text); background: var(--panel-hover); }

/* ---------- Auth pages ---------- */
.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.auth-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(600px 400px at 50% 0%, rgba(129, 140, 248, 0.16), transparent 70%);
}

.auth-wrap {
  width: 100%;
  max-width: 420px;
  position: relative;
}

.auth-card {
  background: rgba(17, 23, 40, 0.72);
  backdrop-filter: blur(18px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 34px 30px 26px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.auth-logo { text-align: center; margin-bottom: 24px; }
.auth-logo h1 { font-size: 22px; margin-top: 14px; }
.auth-logo p { color: var(--muted); font-size: 13px; margin-top: 6px; }

.auth-form { display: flex; flex-direction: column; gap: 16px; }

.field { display: flex; flex-direction: column; gap: 7px; font-size: 13px; color: var(--muted); }

.field input {
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 13px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.18);
}

.field input::placeholder { color: rgba(138, 146, 168, 0.5); }

.auth-switch { text-align: center; margin-top: 20px; font-size: 13px; color: var(--muted); }

/* ---------- Captcha ---------- */
.captcha-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.captcha-img {
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: #0e1424;
  display: block;
  flex-shrink: 0;
  user-select: none;
  pointer-events: none;
}

.captcha-btn {
  flex-shrink: 0;
  font-size: 18px;
  line-height: 1;
  padding: 12px 14px;
}

.alert {
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}
.alert-error {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: var(--danger);
}

.alert-info {
  background: rgba(129, 140, 248, 0.1);
  border: 1px solid rgba(129, 140, 248, 0.3);
  color: var(--accent-2);
}

.optional { font-style: normal; font-size: 11px; color: var(--muted); font-weight: 400; }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  padding: 20px 24px;
  height: calc(100vh - 60px);
}

/* ---------- Sidebar ---------- */
.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 0;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.db-list { overflow-y: auto; padding: 10px; flex: 1; min-height: 0; }

.db-section { margin-bottom: 10px; }

.db-name {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 10px;
  border-radius: 10px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  transition: background 0.12s ease;
}
.db-name:hover { background: var(--panel-hover); }

.db-badge {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 7px;
  background: rgba(129, 140, 248, 0.14);
  color: var(--accent-2);
  border: 1px solid rgba(129, 140, 248, 0.25);
}

.db-count { font-size: 11px; color: var(--muted); background: var(--panel-hover); border-radius: 999px; padding: 1px 8px; }

.table-list { display: flex; flex-direction: column; gap: 2px; padding-left: 8px; }

.table-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 13px;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 8px;
  padding: 7px 10px;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.table-item:hover { background: var(--panel-hover); color: var(--text); }

.table-item.active {
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.12), rgba(129, 140, 248, 0.14));
  color: var(--text);
  border: 1px solid rgba(129, 140, 248, 0.25);
}

.table-name {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-rows { font-size: 11px; color: var(--muted); flex-shrink: 0; }

/* ---------- Content ---------- */
.content {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

#table-view { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--muted);
  text-align: center;
  padding: 40px;
}

.empty-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.15), rgba(192, 132, 252, 0.15));
  border: 1px solid var(--border);
  margin-bottom: 6px;
}

.empty-state h2 { color: var(--text); font-size: 18px; }

.table-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.table-title {
  font-size: 17px;
  font-weight: 700;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  word-break: break-all;
}
.table-title .db-path { color: var(--accent-2); }

.table-meta { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.table-meta b { color: var(--text); font-weight: 600; }

.pager { display: flex; align-items: center; gap: 10px; }
.page-info {
  min-width: 26px;
  text-align: center;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.table-scroll { overflow: auto; flex: 1; min-height: 0; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95em;
  font-variant-numeric: tabular-nums;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 5;
  text-align: left;
  font-weight: 600;
  font-size: 0.85em;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--accent-1);
  background: var(--bg);
  border-bottom: 2px solid var(--border-strong);
  padding: 0.5rem 0.6rem;
  white-space: nowrap;
}

.data-table td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  max-width: 380px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-table td:last-child {
  white-space: normal;
  word-break: break-word;
  overflow-wrap: break-word;
}

.data-table tbody tr:hover td {
  background: rgba(201, 170, 113, 0.04);
}

.data-table td.num { font-variant-numeric: tabular-nums; }

.data-table td a {
  color: var(--accent-2);
  text-decoration: none;
  font-weight: 600;
}

.data-table td a:hover {
  color: var(--accent-1);
  text-decoration: underline;
}

.null { color: #6b7280; font-style: italic; }

.blob {
  font-size: 12px;
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.2);
  border-radius: 6px;
  padding: 1px 8px;
  white-space: nowrap;
}

.loading { padding: 12px; text-align: center; }

/* ---------- Dashboard ---------- */
.dash {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

.dash-loading { padding: 48px 0; }
.dash-error {
  padding: 32px;
  text-align: center;
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-radius: var(--radius);
  background: rgba(248, 113, 113, 0.06);
}

.hero {
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.1), rgba(129, 140, 248, 0.12), rgba(192, 132, 252, 0.08));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 26px;
  margin-bottom: 20px;
}

.hero-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

.hero-hello { display: flex; align-items: center; gap: 14px; }

.hero-avatar {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
  flex-shrink: 0;
}

.hero h1 { font-size: 22px; font-weight: 700; }

.hero-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

.hero-chip {
  font-size: 12.5px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
}

.hero-chip.aura {
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.1);
  border-color: rgba(251, 191, 36, 0.25);
}

.hero-actions { display: flex; gap: 10px; }

.meta-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 20px;
}

.meta-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
}

.meta-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--accent-2);
  background: rgba(129, 140, 248, 0.12);
  border: 1px solid rgba(129, 140, 248, 0.25);
  flex-shrink: 0;
}

.meta-value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.meta-title { font-size: 12px; color: var(--muted); margin-top: 2px; }
.meta-sub { font-size: 11px; color: var(--muted); opacity: 0.8; }

.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 20px 22px;
}

.panel-head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }

.section-head h2 { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.section-head p { font-size: 12.5px; }

.acc-row {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-top: 14px;
  background: rgba(255, 255, 255, 0.02);
}

.acc-name { font-weight: 600; font-size: 14.5px; font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }

.acc-empty {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 10px;
  padding: 10px;
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
}

.players { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }

.player { display: flex; align-items: center; gap: 10px; }

.player-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0.6;
  flex-shrink: 0;
}

.player-dot.online { background: var(--ok); box-shadow: 0 0 8px var(--ok); opacity: 1; }

.player-name { font-size: 13.5px; font-weight: 600; }
.player-body { line-height: 1.35; }

.aura-box { display: flex; align-items: center; gap: 16px; margin-top: 16px; }

.aura-icon {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  color: #fbbf24;
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.18), rgba(192, 132, 252, 0.18));
  border: 1px solid rgba(251, 191, 36, 0.3);
  flex-shrink: 0;
}

.aura-text { flex: 1; line-height: 1.4; }
.aura-name { font-weight: 600; font-size: 14.5px; }

.settings-form { display: flex; flex-direction: column; gap: 16px; margin-top: 16px; }

.toggle-row { display: flex; align-items: center; gap: 12px; cursor: pointer; }

.toggle-row input { display: none; }

.toggle-track {
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border-strong);
  position: relative;
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.15s ease, background 0.15s ease;
}

.toggle-row input:checked + .toggle-track { background: rgba(34, 211, 238, 0.35); border-color: rgba(34, 211, 238, 0.5); }
.toggle-row input:checked + .toggle-track::after { transform: translateX(18px); background: var(--accent-1); }

.toggle-text { font-size: 13.5px; line-height: 1.35; }

.ref-box { display: flex; gap: 10px; margin-top: 16px; }

.ref-link {
  flex: 1;
  font: inherit;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 12.5px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
}

.ref-hint { margin-top: 12px; font-size: 12.5px; color: var(--muted); }

.ref-list { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }

.ref-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.02);
}

.ref-name { font-weight: 600; font-size: 14px; }

.ref-status { display: flex; align-items: center; }

.ref-status.ok { color: var(--ok); font-size: 13px; }
.ref-status:not(.ok) { color: var(--muted); font-size: 13px; }

.btn-sm { padding: 6px 12px; font-size: 12.5px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: rgba(17, 23, 40, 0.95);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 12px 20px;
  font-size: 13.5px;
  z-index: 100;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
}

.toast.error { border-color: rgba(248, 113, 113, 0.5); color: var(--danger); }

@media (max-width: 900px) {
  .dash-grid { grid-template-columns: 1fr; }
  .meta-grid { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; height: auto; }
  .sidebar { max-height: 260px; }
}

/* ===== Compact redesigned dashboard ===== */
.dash { max-width: 1180px; margin: 0 auto; padding: 22px 22px 56px; }

.welcome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.10), rgba(129, 140, 248, 0.14), rgba(192, 132, 252, 0.08));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
}
.welcome-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.welcome-avatar {
  width: 46px; height: 46px; border-radius: 13px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; color: #fff; background: var(--grad);
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.4);
}
.welcome h1 { font-size: 19px; font-weight: 700; }
.welcome-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.chip-mini {
  font-size: 12px; color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 999px; padding: 3px 10px;
}
.chip-mini.aura { color: #fbbf24; background: rgba(251, 191, 36, 0.1); border-color: rgba(251, 191, 36, 0.25); }
.welcome-actions { display: flex; gap: 10px; }

.stat-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat {
  display: flex; align-items: center; gap: 13px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px;
  transition: transform 0.18s var(--ease), border-color 0.18s var(--ease), box-shadow 0.18s var(--ease), background 0.15s ease;
}
.stat:hover { transform: translateY(-3px); border-color: var(--border-strong); box-shadow: var(--shadow-soft); }
.stat-ico {
  width: 40px; height: 40px; border-radius: 11px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 700;
  color: #fff; background: var(--grad); box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}
.stat-body { min-width: 0; }
.stat-val { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-suf { font-size: 13px; color: var(--muted); font-weight: 500; margin-left: 2px; }
.stat-lbl { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat-prog { height: 5px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); margin-top: 7px; overflow: hidden; }
.stat-prog-fill { height: 100%; border-radius: 999px; background: var(--grad); transition: width 0.9s var(--ease); }
[data-theme="light"] .stat-prog { background: rgba(15, 23, 42, 0.08); }

.dash-grid { display: grid; grid-template-columns: 1.7fr 1fr; gap: 16px; align-items: start; }
.side { display: flex; flex-direction: column; gap: 16px; }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 4px; padding: 16px 18px; }
.panel-head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 4px; }

.panel .lb-table-wrap {
  margin: 0 -18px;
  padding: 0;
  border-radius: 0;
}
.panel .lb-table-wrap + .lb-pager {
  margin-top: 12px;
}

.acct { padding: 12px 0; border-top: 1px solid var(--border); }
.acct:first-of-type { border-top: none; padding-top: 2px; }
.acct-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.acc-name { font-weight: 600; font-size: 14px; font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }
.acc-sub { font-size: 11.5px; color: var(--muted); }
.player-list { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.player-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.02);
  transition: background 0.12s ease;
}
.player-row:hover { background: var(--panel-hover); }
.player-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); opacity: 0.55; flex-shrink: 0; }
.player-dot.online { background: var(--ok); box-shadow: 0 0 8px var(--ok); opacity: 1; animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.5); }
  50% { box-shadow: 0 0 0 5px rgba(52, 211, 153, 0); }
}
.player-main { min-width: 0; flex: 1; line-height: 1.3; }
.player-name { font-size: 13.5px; font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lvl-badge {
  font-size: 11px; font-weight: 600; color: var(--accent-2);
  background: rgba(129, 140, 248, 0.14); border: 1px solid rgba(129, 140, 248, 0.25);
  border-radius: 6px; padding: 1px 7px;
}
.acc-empty {
  color: var(--muted); font-size: 12.5px; margin-top: 6px; padding: 10px;
  border: 1px dashed var(--border-strong); border-radius: 10px; text-align: center;
}

.acct-pending { border-left: 3px solid var(--danger); background: rgba(248, 113, 113, 0.05); }
.acct-actions { display: flex; gap: 8px; flex-shrink: 0; }
.acct-banner {
  display: flex; align-items: center; gap: 8px; margin-top: 10px;
  padding: 8px 12px; border-radius: 10px;
  background: rgba(248, 113, 113, 0.1); border: 1px solid rgba(248, 113, 113, 0.25);
  font-size: 12.5px; color: var(--danger);
}
.acct-banner-ico { font-size: 14px; }
.delete-timer { font-variant-numeric: tabular-nums; font-weight: 600; }

@media (max-width: 900px) {
  .dash-grid { grid-template-columns: 1fr; }
  .stat-strip { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .player-dot.online { animation: none; }
}

/* ===== Modals (delete confirm / character view) ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(4, 7, 15, 0.62);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.modal-overlay.show { opacity: 1; }

.modal-box {
  width: 100%;
  max-width: 430px;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  transform: translateY(8px) scale(0.98);
  transition: transform 0.2s var(--ease);
}
.modal-overlay.show .modal-box { transform: translateY(0) scale(1); }
[data-theme="light"] .modal-box { background: #fff; }

.modal-icon { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; margin-bottom: 12px; }
.modal-icon.danger { background: rgba(248, 113, 113, 0.15); border: 1px solid rgba(248, 113, 113, 0.3); color: var(--danger); }
.modal-title { font-size: 18px; font-weight: 700; }
.modal-text { font-size: 13px; color: var(--muted); margin-top: 8px; line-height: 1.55; }

.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

.btn-danger { border: none; color: #fff; background: linear-gradient(135deg, #f87171, #ef4444); box-shadow: 0 6px 20px rgba(239, 68, 68, 0.35); }
.btn-danger:hover { filter: brightness(1.08); }

.icon-btn.del-btn { color: var(--muted); }
.icon-btn.del-btn:hover { background: rgba(248, 113, 113, 0.12); color: var(--danger); border-color: transparent; }

.player-clickable { cursor: pointer; }

/* Character detail */
.char-head { display: flex; align-items: center; gap: 12px; }
.char-badge {
  width: 46px; height: 46px; border-radius: 13px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; color: #fff; background: var(--grad);
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.4);
}
.char-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.char-stat { background: rgba(255, 255, 255, 0.03); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.char-stat-l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }
.char-stat-v { font-size: 14px; font-weight: 600; margin-top: 3px; }

/* ===== Arena rankings ===== */
.nav-links { display: flex; gap: 4px; margin-left: 18px; }
.nav-link {
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 10px;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.nav-link:hover { background: var(--panel-hover); color: var(--text); }
.nav-link.active { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; box-shadow: 0 4px 14px rgba(124, 92, 255, 0.35); }

.lb-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 18px; }
.lb-tab {
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--muted);
  font-weight: 700;
  font-size: 13.5px;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s var(--ease), color 0.15s var(--ease), border-color 0.15s var(--ease);
}
.lb-tab:hover { background: rgba(201, 170, 113, 0.1); color: var(--text); border-color: rgba(201, 170, 113, 0.35); }
.lb-tab.active {
  color: var(--text);
  background: rgba(201, 170, 113, 0.15);
  border-color: rgba(201, 170, 113, 0.5);
  box-shadow: none;
}

.lb-table-wrap { overflow-x: auto; border-radius: 0; }
.lb-table { width: 100%; border-collapse: collapse; }
.lb-table th, .lb-table td { padding: 0.5rem 0.6rem; text-align: left; white-space: nowrap; }
.lb-table th.num, .lb-table td.num { text-align: right; }
.lb-rank { width: 46px; font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 700; }
.lb-name { font-weight: 600; color: var(--text); }
.lb-rating { color: var(--accent-1); font-weight: 700; }
.lb-online { color: var(--accent-2); font-weight: 600; }
.lb-gold td.lb-rank { color: #f5c542; }
.lb-silver td.lb-rank { color: #c7d0dd; }
.lb-bronze td.lb-rank { color: #d68b4a; }
.lb-empty { text-align: center; color: var(--muted); padding: 28px 0; }

.lb-pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 18px; }
.lb-page-info { color: var(--muted); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.btn.disabled, .btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ===== Arena rank tiers ===== */
.lb-rank-cell { font-weight: 700; white-space: nowrap; }
.rank-tier-0 { color: #b06a3a; }   /* Bronze */
.rank-tier-1 { color: #9aa7b5; }   /* Silver */
.rank-tier-2 { color: #e3b53b; }   /* Gold */
.rank-tier-3 { color: #4fd1c5; }   /* Platinum */
.rank-tier-4 { color: #6aa9ff; }   /* Diamond */
.rank-tier-5 { color: #c084fc; }   /* Crown */
.rank-tier-6 { color: #ff7a59; }   /* Ace */
.rank-tier-7 { color: #f5c542; text-shadow: 0 0 10px rgba(245,197,66,0.5); }  /* Conqueror */

/* ---------- Shop (cabinet) ---------- */
.shop-balance {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
}
.shop-balance strong { color: var(--text); }
.shop-bal-ico { color: var(--accent-1); font-weight: 700; }
.shop-tree { display: flex; flex-direction: column; gap: 18px; margin-top: 14px; }
.shop-cat { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; background: var(--panel); }
.shop-cat-title { margin: 0 0 10px; font-family: var(--display); font-size: 1.05rem; }
.shop-subcats { margin-top: 12px; padding-left: 14px; border-left: 2px solid var(--border); display: flex; flex-direction: column; gap: 12px; }
.shop-item-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.shop-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-2); }
.shop-item-main { min-width: 0; }
.shop-item-name { font-weight: 600; }
.shop-item-right { display: flex; align-items: center; gap: 10px; flex: none; }
.shop-item-price { color: var(--accent-2); font-weight: 700; white-space: nowrap; }
.shop-hint { margin-top: 12px; font-size: 0.82rem; }

/* ---------- Admin panel ---------- */
.admin-panel { border-color: var(--border-strong); }
.admin-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-top: 14px; background: var(--panel); }
.admin-card-title { margin: 0 0 12px; font-family: var(--display); font-size: 1.02rem; }
.admin-actions { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.admin-cat-list { display: flex; flex-direction: column; gap: 10px; }
.admin-cat { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--bg-2); }
.admin-subcats { margin-top: 10px; padding-left: 12px; border-left: 2px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.admin-cat-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.admin-cat-name { font-weight: 600; }
.admin-cat-btns { display: flex; gap: 6px; flex: none; }
.admin-item-list { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.admin-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; }
.admin-item-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.admin-item-name { font-weight: 600; }
.admin-send { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; align-items: end; }
.admin-send .btn { grid-column: 1 / -1; justify-self: start; }

/* ---------- Admin multi-item send ---------- */
.admin-items { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.admin-item-row { display: grid; grid-template-columns: 1.2fr 0.8fr 1.6fr auto; gap: 8px; align-items: center; }
.admin-item-row input { width: 100%; }
.admin-recipient { margin-bottom: 4px; }

/* ---------- Admin localization (translation) tab ---------- */
.admin-tabs { margin-top: 18px; }
.admin-tab[hidden] { display: none !important; }
.admin-loc-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.admin-loc-row { display: grid; grid-template-columns: 7.5rem minmax(10rem, 1fr) minmax(10rem, 1fr) auto auto; gap: 8px; align-items: center; }
.admin-loc-code { font-weight: 600; color: var(--muted); font-size: 0.85rem; overflow-wrap: anywhere; line-height: 1.3; }
.admin-loc-row input[type="text"] { width: 100%; }
.admin-loc-hide { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; cursor: pointer; }

/* ---------- Admin level-ratios tab ---------- */
.lr-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.lr-toolbar input[type="text"] { width: 100px; }
.lr-toolbar .lr-hint { font-size: 0.8rem; color: var(--muted); }
.lr-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); margin-top: 8px; background: var(--bg-2); }
.lr-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.lr-table th,
.lr-table td { padding: 5px 6px; text-align: center; border-bottom: 1px solid var(--border); white-space: nowrap; }
.lr-table th { background: var(--bg); position: sticky; top: 0; z-index: 1; font-weight: 600; font-size: 0.78rem; color: var(--muted); }
.lr-table td.lvl { font-weight: 700; color: var(--accent-2); position: sticky; left: 0; background: var(--bg-2); z-index: 0; min-width: 32px; }
.lr-table th.lvl { position: sticky; left: 0; z-index: 2; }
.lr-table td.exp { text-align: right; color: var(--text); font-family: monospace; }
.lr-table td input[type="number"] { width: 62px; text-align: center; font-size: 0.8rem; padding: 2px 3px; background: var(--bg); border: 1px solid var(--border); border-radius: 4px; color: var(--text); }
.lr-table td input[type="number"]:focus { border-color: var(--accent); outline: none; }
.lr-table tr:nth-child(even) { background: rgba(255,255,255,0.015); }
.lr-table tr:hover td { background: rgba(201,170,113,0.06); }
.lr-table tr:hover td.lvl { background: rgba(201,170,113,0.10); }
.lr-actions { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; align-items: center; }
.lr-status { font-size: 0.8rem; color: var(--muted); margin-left: auto; }

/* ---------- Stub pages ---------- */
.stub-box { text-align: center; padding: 48px 20px; margin-top: 16px; border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--panel); }
.stub-ico { font-size: 2.6rem; margin-bottom: 10px; }
.stub-title { font-family: var(--display); font-size: 1.25rem; margin-bottom: 8px; }

/* ===== SIDEBAR LAYOUT (Demo Empire style) ===== */

.main-wrapper {
  position: relative;
  display: flex;
  min-height: 100vh;
}

.page-wrapper {
  background: transparent;
  flex: 1;
  min-height: 100vh;
  margin-left: 260px;
  transition: margin-left 0.3s ease;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.page-content {
  background: transparent;
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 28px 40px;
  flex: 1;
}

/* === Left Sidebar === */
.cp-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 260px;
  height: 100vh;
  background: var(--bg);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 200;
  display: flex;
  flex-direction: column;
  scrollbar-width: thin;
  scrollbar-color: rgba(129, 140, 248, 0.15) transparent;
}

.cp-sidebar::-webkit-scrollbar { width: 4px; }
.cp-sidebar::-webkit-scrollbar-track { background: transparent; }
.cp-sidebar::-webkit-scrollbar-thumb { background: rgba(129, 140, 248, 0.15); border-radius: 4px; }

/* Sidebar header */
.cp-sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.cp-sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  margin-bottom: 16px;
}
.cp-sidebar-logo:hover { text-decoration: none; }
.cp-sidebar-logo .brand-mark {
  width: 26px;
  height: 26px;
}
.cp-sidebar-logo .brand-text {
  font-size: 15px;
  color: var(--text);
}

.cp-sidebar-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.cp-sidebar-controls .sidebar-ctrl {
  color: var(--muted);
  font-size: 0.93em;
  text-decoration: none;
  transition: color 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}
.cp-sidebar-controls .sidebar-ctrl:hover {
  color: var(--accent-1);
}

.chip-sm {
  padding: 4px 10px;
  font-size: 12px;
}

/* Sidebar navigation sections */
.cp-sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.cp-sidebar-section {
  margin-bottom: 6px;
}

.cp-sidebar-section-title {
  padding: 8px 24px 4px;
  font-size: 0.71em;
  font-weight: 700;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 1.5px;
  opacity: 0.7;
}

.cp-sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 24px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.96em;
  font-weight: 500;
  transition: all 0.15s ease;
  border-left: 3px solid transparent;
  position: relative;
}

.cp-sidebar-link:hover {
  color: var(--text);
  background: rgba(129, 140, 248, 0.04);
  border-left-color: rgba(129, 140, 248, 0.2);
  text-decoration: none;
}

.cp-sidebar-link.active {
  color: var(--accent-1);
  background: rgba(34, 211, 238, 0.06);
  border-left-color: var(--accent-1);
}

.cp-sidebar-link svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.5;
  transition: opacity 0.15s;
}

.cp-sidebar-link:hover svg,
.cp-sidebar-link.active svg {
  opacity: 0.85;
}

.cp-sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 20px;
}

/* Sidebar footer */
.cp-sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.cp-sidebar-footer-links {
  display: flex;
  gap: 14px;
  justify-content: center;
  align-items: center;
}

.cp-sidebar-footer-links a {
  color: var(--muted);
  font-size: 0.88em;
  font-weight: 600;
  text-decoration: none;
  transition: color 0.2s;
}
.cp-sidebar-footer-links a:hover {
  color: var(--accent-2);
  text-decoration: none;
}

/* Mobile sidebar toggle */
.cp-sidebar-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 250;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  color: var(--accent-1);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.cp-sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.6);
  z-index: 190;
}

/* Responsive: mobile */
@media (max-width: 992px) {
  .cp-sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }
  .cp-sidebar.open {
    transform: translateX(0);
  }
  .cp-sidebar-toggle {
    display: block;
  }
  .cp-sidebar-overlay.open {
    display: block;
  }
  .page-wrapper {
    margin-left: 0;
  }
  .page-content {
    padding: 60px 16px 40px;
  }
}

/* Hide topbar when sidebar is active */
.topbar {
  display: none;
}

/* === Dash stats (cards style like Demo) === */
.dash-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.dash-stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.3s, box-shadow 0.3s, transform 0.18s var(--ease);
}
.dash-stat:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-soft);
  transform: translateY(-3px);
}

.dash-stat-label {
  font-size: 0.82em;
  font-weight: 600;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0.8px;
}

.dash-stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dash-stat-value .stat-action {
  color: var(--muted);
  transition: color 0.2s;
  display: inline-flex;
}
.dash-stat-value .stat-action:hover {
  color: var(--accent-1);
}

.dash-stat-sub {
  font-size: 0.9em;
  color: var(--muted);
  margin-top: 2px;
}
.dash-stat-sub a {
  color: var(--accent-2);
  text-decoration: none;
}
.dash-stat-sub a:hover { color: var(--accent-1); text-decoration: underline; }

/* === Section headers (Demo style) === */
.dash-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  margin-top: 8px;
}
.dash-section-header h6 {
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0;
}
.dash-section-header .dash-section-line {
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* === Tables (Demo Empire style) === */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  color: var(--text);
  transition: border-color 0.3s, box-shadow 0.3s;
  overflow: hidden;
}

.card:hover {
  border-color: var(--border-strong);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.card-body {
  background: transparent;
  color: var(--text);
  padding: 1.25rem;
}

.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  color: var(--text);
  width: 100%;
  font-size: 0.95em;
  white-space: nowrap;
  border-collapse: collapse;
}

.table th,
.table td {
  border-color: var(--border);
  color: var(--text);
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table td:last-child {
  white-space: normal;
  word-break: break-word;
  overflow-wrap: break-word;
}

.table thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  font-size: 0.85em;
  color: var(--accent-1);
  text-transform: none;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border-strong);
  font-weight: 600;
  background: var(--bg);
}

.table-striped tbody tr:nth-of-type(odd) {
  background-color: rgba(255, 255, 255, 0.015);
}

.table-hover tbody tr:hover {
  background-color: rgba(201, 170, 113, 0.04);
  color: var(--text);
}

.table-hover tbody tr:hover td {
  background-color: transparent;
}

.table td strong {
  color: var(--text);
}

.table td a {
  color: var(--accent-2);
  text-decoration: none;
  font-weight: 600;
}

.table td a:hover {
  color: var(--accent-1);
  text-decoration: underline;
}

/* Rating table specifics (like Demo) */
.rating-table {
  font-size: 0.95em;
  white-space: nowrap;
  width: 100%;
}

.rating-table th,
.rating-table td {
  padding: 0.5rem 0.45rem !important;
}

.rating-table thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
}

.rating-table td:last-child {
  white-space: normal;
  word-break: break-word;
  overflow-wrap: break-word;
}

/* Hint-th for sortable columns */
.hint-th {
  cursor: help;
  border-bottom: 1px dotted rgba(255,255,255,0.35);
}
.hint-th::after {
  content: "?";
  display: inline-block;
  width: 14px;
  height: 14px;
  line-height: 14px;
  text-align: center;
  font-size: 0.6rem;
  font-weight: 700;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.5);
  margin-left: 4px;
  vertical-align: middle;
}

.sort-icon {
  font-size: 0.75em;
  opacity: 0.5;
}

/* Class icons (Demo style) */
.class-icon {
  display: inline-block;
  width: 22px;
  height: 22px;
  vertical-align: middle;
  margin-right: 4px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  filter: invert(1);
}

/* Position label */
.position-label {
  color: var(--accent-1);
}

/* Division badges */
.div-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.82em;
  font-weight: 600;
}

/* Match history card bars (Demo style) */
.match-card {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  width: 100%;
  border-left: 3px solid transparent;
  border-bottom: 1px solid var(--border);
  transition: background-color 0.15s;
}
.match-card:hover {
  background: rgba(255, 255, 255, 0.03);
}
.match-card.mc-win   { border-left-color: #4CAF50; background: rgba(76, 175, 80, 0.05); }
.match-card.mc-loss  { border-left-color: #F44336; background: rgba(244, 67, 54, 0.05); }
.match-card.mc-draw  { border-left-color: #FFC107; background: rgba(255, 193, 7, 0.04); }
.match-card.mc-leave { border-left-color: #9E9E9E; background: rgba(158, 158, 158, 0.04); }

/* Stats grid (Demo style) */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 16px 12px;
  text-align: center;
}

.stat-item {
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px 8px;
  transition: border-color 0.2s;
}
.stat-item:hover {
  border-color: var(--border-strong);
}

.stat-value {
  font-size: 1.3em;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 0.8em;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0.5px;
}

/* === Badges (Demo style) === */
.badge-success {
  background: rgba(52, 211, 153, 0.15) !important;
  color: var(--ok) !important;
  border: 1px solid rgba(52, 211, 153, 0.25) !important;
}

.badge-danger {
  background: rgba(248, 113, 113, 0.15) !important;
  color: var(--danger) !important;
  border: 1px solid rgba(248, 113, 113, 0.25) !important;
}

/* === Buttons (Demo style) === */
.btn-primary,
.btn-primary:focus {
  background: rgba(129, 140, 248, 0.18) !important;
  border: 1px solid rgba(129, 140, 248, 0.35) !important;
  color: var(--accent-2) !important;
  transition: all 0.2s ease;
}
.btn-primary:hover {
  background: rgba(129, 140, 248, 0.28) !important;
  border-color: rgba(129, 140, 248, 0.5) !important;
  color: var(--accent-1) !important;
}

/* === Form controls (Demo style) === */
.form-control {
  background: rgba(255, 255, 255, 0.04) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
}
.form-control:focus {
  border-color: var(--accent-2) !important;
  background: rgba(255, 255, 255, 0.06) !important;
  box-shadow: 0 0 0 2px rgba(129, 140, 248, 0.1) !important;
  color: var(--text) !important;
}
.form-control::placeholder {
  color: var(--muted) !important;
}

/* === Dropdowns (Demo style) === */
.dropdown-menu {
  background: var(--bg-2) !important;
  border: 1px solid var(--border-strong) !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5) !important;
  border-radius: 10px;
}

.dropdown-item {
  color: var(--text) !important;
  transition: all 0.15s;
}
.dropdown-item:hover,
.dropdown-item:focus {
  background: rgba(129, 140, 248, 0.1) !important;
  color: var(--accent-1) !important;
}

/* === Alerts (Demo style) === */
.alert-info {
  background: rgba(129, 140, 248, 0.07) !important;
  border-color: rgba(129, 140, 248, 0.18) !important;
  color: var(--accent-2) !important;
}

/* === Search dropdown (Demo style) === */
.search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-top: none;
  border-radius: 0 0 4px 4px;
  z-index: 200;
  max-height: 300px;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}
.search-dropdown a {
  display: block;
  padding: 8px 12px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  font-size: 0.93em;
}
.search-dropdown a:hover {
  background: rgba(201, 170, 113, 0.1);
  text-decoration: none;
}

/* === Hint tooltips (Demo style) === */
.hint-tooltip {
  position: fixed;
  background: var(--bg-2);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 400;
  white-space: nowrap;
  pointer-events: none;
  z-index: 9999;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  border: 1px solid var(--border-strong);
}

/* === Responsive tables (Demo style) === */
@media (max-width: 768px) {
  .rating-table th:nth-child(4),
  .rating-table td:nth-child(4),
  .rating-table th:nth-child(8),
  .rating-table td:nth-child(8) {
    display: none;
  }
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px 8px;
  }
  .stat-value { font-size: 1.1em; }
}

@media (max-width: 480px) {
  .rating-table th:nth-child(4),
  .rating-table td:nth-child(4),
  .rating-table th:nth-child(5),
  .rating-table td:nth-child(5),
  .rating-table th:nth-child(8),
  .rating-table td:nth-child(8),
  .rating-table th:nth-child(10),
  .rating-table td:nth-child(10) {
    display: none;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px 6px;
  }
  .stat-item { padding: 10px 6px; }
  .stat-value { font-size: 1em; }
}

/* === Scrollbar === */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: rgba(129, 140, 248, 0.2);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(129, 140, 248, 0.35);
}

/* ============================================================
   Character page (/character/:id)
   ============================================================ */
.char-page { max-width: 1100px; }

.cp-nav-row { margin-bottom: 16px; }

.cp-hero {
  display: flex;
  align-items: center;
  gap: 18px;
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.10), rgba(129, 140, 248, 0.14), rgba(192, 132, 252, 0.08));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.cp-hero-left { display: flex; align-items: center; gap: 16px; min-width: 0; flex: 1; }
.char-badge.lg { width: 58px; height: 58px; border-radius: 16px; font-size: 26px; }
.cp-hero-name { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.cp-hero-name h1 {
  font-family: var(--display);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.15;
}
.cp-title {
  margin-top: 6px;
  font-size: 12.5px;
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.25);
  border-radius: 999px;
  padding: 2px 10px;
  display: inline-block;
}

.chip-tag.online-tag { background: rgba(52, 211, 153, 0.15); color: var(--ok); border-color: rgba(52, 211, 153, 0.3); }
.chip-tag.offline-tag { background: rgba(138, 146, 168, 0.12); color: var(--muted); border-color: rgba(138, 146, 168, 0.3); }

/* XP progress block (character page + modal) */
.section-title-line {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 14px;
}
.cp-xp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.cp-xp-head h2 { margin-bottom: 0; }
.xp-pct-big {
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent-1);
}
.xp-level-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0 8px;
  font-size: 13.5px;
}
.xp-level-now { font-weight: 700; color: var(--text); }
.xp-level-next { color: var(--muted); }

.xp-bar {
  height: 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
  position: relative;
}
[data-theme="light"] .xp-bar { background: rgba(15, 23, 42, 0.08); }
.xp-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--grad);
  box-shadow: 0 0 12px rgba(129, 140, 248, 0.5);
  transition: width 0.9s var(--ease);
}
.xp-bar.big { height: 18px; }
.xp-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* Character stat grid column layout */
.char-grid.cols4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) {
  .char-grid.cols4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  .char-grid.cols4 { grid-template-columns: 1fr; }
}

.cp-main-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 16px;
  align-items: start;
  margin-top: 16px;
}
.cp-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
@media (max-width: 900px) {
  .cp-main-grid { grid-template-columns: 1fr; }
}

/* PvP rank card */
.cp-rank-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.cp-rank-badge {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}
.cp-rank-elo {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  margin-top: 2px;
}
.cp-rank-format { color: var(--muted); font-size: 13.5px; }
.cp-rank-last { margin-top: 12px; font-size: 12.5px; }

/* Dungeon record card */
.cd-box {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.02);
  margin-bottom: 14px;
}
.cd-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #c084fc;
  background: rgba(192, 132, 252, 0.12);
  border: 1px solid rgba(192, 132, 252, 0.25);
}
.cd-name { font-weight: 600; font-size: 15px; }

/* EXP block inside the character modal */
.char-xp {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.02);
}
.char-xp-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.char-xp-lbl { font-size: 12px; color: var(--muted); font-weight: 600; }
.char-xp-pct { font-size: 14px; font-weight: 700; color: var(--accent-1); font-variant-numeric: tabular-nums; }
.char-xp .xp-bar { height: 10px; }
.char-xp-meta { margin-top: 8px; font-size: 11.5px; font-variant-numeric: tabular-nums; }

/* ---------- Лог чата: колонки ---------- */
.lb-table th.cell-chan, .lb-table td.cell-chan { white-space: nowrap; }
.lb-table td.lb-msg {
  max-width: 660px;
  min-width: 220px;
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.5;
}
