/* ============================================
   SILVIO CONTROL — Design System v22
   Themes: dark (default) + light
   ============================================ */

:root {
  --bg: #0a0b0e;
  --bg-elev: #111318;
  --bg-card: #13161c;
  --bg-hover: #1a1e26;
  --line: #252a33;
  --line-soft: #1c2028;
  --text: #f0ede8;
  --text-muted: #9a9da4;
  --text-dim: #6b6f77;
  --accent: #b83d50;
  --accent-hover: #d04a5f;
  --accent-soft: rgba(184, 61, 80, 0.12);
  --success: #4ecb8a;
  --success-soft: rgba(78, 203, 138, 0.12);
  --danger: #e36471;
  --danger-soft: rgba(227, 100, 113, 0.12);
  --warning: #e0b462;
  --warning-soft: rgba(224, 180, 98, 0.12);
  --info: #6ea8d8;
  --info-soft: rgba(110, 168, 216, 0.12);
  --radius: 12px;
  --radius-lg: 16px;
  --radius-sm: 8px;
  --sidebar-w: 264px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --shadow: 0 8px 24px rgba(0,0,0,.35);
  --shadow-lg: 0 20px 50px rgba(0,0,0,.45);
  --transition: .18s cubic-bezier(.4,0,.2,1);
}

[data-theme="light"] {
  --bg: #f5f3ee;
  --bg-elev: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #eceae4;
  --line: #e0ddd6;
  --line-soft: #ebe8e2;
  --text: #1a1b1e;
  --text-muted: #6b6e75;
  --text-dim: #9a9da4;
  --accent: #a83548;
  --accent-hover: #8f2a3b;
  --accent-soft: rgba(168, 53, 72, 0.08);
  --success: #2fa86a;
  --success-soft: rgba(47, 168, 106, 0.10);
  --danger: #c94a57;
  --danger-soft: rgba(201, 74, 87, 0.10);
  --warning: #b8903f;
  --warning-soft: rgba(184, 144, 63, 0.10);
  --info: #4a88b8;
  --info-soft: rgba(74, 136, 184, 0.10);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.06);
  --shadow: 0 4px 16px rgba(0,0,0,.08);
  --shadow-lg: 0 12px 32px rgba(0,0,0,.12);
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition), color var(--transition);
}

a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
button { appearance: none; border: none; background: none; cursor: pointer; }

/* ---------- LAYOUT ---------- */

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

/* ---------- SIDEBAR ---------- */

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border-right: 1px solid var(--line);
  z-index: 100;
  transition: transform var(--transition), background var(--transition);
}

.brand-side {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 900;
  font-size: 18px;
  flex-shrink: 0;
}

.brand strong {
  display: block;
  font-size: 13px;
  letter-spacing: .22em;
  font-weight: 800;
}

.brand small {
  display: block;
  margin-top: 2px;
  color: var(--text-dim);
  font-size: 9px;
  letter-spacing: .28em;
  font-weight: 600;
}

.side-status {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 14px 14px 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--line-soft);
  color: var(--text-muted);
  font-size: 11px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-soft);
}

.status-dot.danger {
  background: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.sidebar nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar nav::-webkit-scrollbar { width: 6px; }
.sidebar nav::-webkit-scrollbar-track { background: transparent; }
.sidebar nav::-webkit-scrollbar-thumb { background: var(--line); border-radius: 99px; }

.nav-label {
  padding: 16px 10px 6px;
  color: var(--text-dim);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .22em;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 40px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
  border: 1px solid transparent;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
  font-weight: 600;
}

.nav-icon {
  width: 20px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-size: 14px;
}

.sidebar-bottom {
  flex-shrink: 0;
  padding: 12px 10px 14px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.profile-mini {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 9px;
  border-radius: var(--radius-sm);
}

.profile-mini strong {
  display: block;
  font-size: 12px;
  font-weight: 600;
}

.profile-mini small {
  display: block;
  margin-top: 1px;
  color: var(--text-dim);
  font-size: 10px;
}

.avatar {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 12px;
}

.avatar-sm { width: 26px; height: 26px; font-size: 10px; }

/* ---------- MAIN ---------- */

.main-content {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  transition: margin var(--transition);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  min-height: 72px;
  padding: 14px 28px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  backdrop-filter: blur(12px);
  transition: background var(--transition);
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.eyebrow {
  color: var(--text-dim);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .22em;
  text-transform: uppercase;
}

.topbar h1 {
  margin: 3px 0 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -.02em;
}

.mobile-menu {
  display: none;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  font-size: 16px;
}

.live-chip, .account-chip, .theme-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  border: 1px solid var(--line);
  background: var(--bg-card);
  border-radius: 99px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 7px 12px;
  transition: all var(--transition);
  cursor: default;
}

.theme-toggle {
  cursor: pointer;
  padding: 7px 10px;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.theme-toggle svg {
  width: 14px;
  height: 14px;
}

.account-chip {
  padding: 4px 11px 4px 5px;
  color: var(--text);
  cursor: default;
}

.account-chip .avatar-sm {
  width: 24px;
  height: 24px;
}

/* ---------- CONTENT ---------- */

.content {
  width: min(100%, 1440px);
  margin: 0 auto;
  padding: 28px 28px 56px;
  flex: 1;
}

.page-intro {
  margin-bottom: 24px;
}

.page-intro h2 {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -.025em;
}

.page-intro p {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
  max-width: 720px;
}

/* ---------- CARDS ---------- */

.card, .stat-card, .hero-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color var(--transition), background var(--transition);
}

.card { padding: 22px; }
.stat-card { padding: 18px; }

.hero-card {
  padding: 24px 26px;
  margin-bottom: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-left: 3px solid var(--accent);
}

.hero-card h2 {
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.02em;
}

.hero-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
}

.hero-orb {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 26px;
  font-weight: 900;
  flex-shrink: 0;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-title {
  font-size: 14px;
  font-weight: 700;
}

.section-label {
  color: var(--text-dim);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .2em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

/* ---------- STATS ---------- */

.stat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
}

.stat-kicker {
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 8px;
  letter-spacing: .12em;
  font-weight: 800;
  text-transform: uppercase;
  background: var(--bg);
}

.stat-card strong {
  display: block;
  margin-top: 12px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -.03em;
}

.stat-card small {
  display: block;
  margin-top: 3px;
  color: var(--text-dim);
  font-size: 11px;
}

/* ---------- GRIDS ---------- */

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }

/* ---------- TABLES ---------- */

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-card);
}

.table-wrap::-webkit-scrollbar { height: 6px; }
.table-wrap::-webkit-scrollbar-track { background: var(--bg); }
.table-wrap::-webkit-scrollbar-thumb { background: var(--line); border-radius: 99px; }

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 680px;
}

th, td {
  text-align: left;
  padding: 12px 11px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12px;
  vertical-align: middle;
}

th {
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  background: var(--bg);
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--bg-hover); }

.table-person {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 180px;
}

.table-person strong {
  display: block;
  font-size: 12px;
  font-weight: 600;
}

.table-person small {
  display: block;
  margin-top: 1px;
  color: var(--text-dim);
  font-size: 10px;
}

/* ---------- BADGES ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 99px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

.badge.success { background: var(--success-soft); border-color: transparent; color: var(--success); }
.badge.danger  { background: var(--danger-soft);  border-color: transparent; color: var(--danger); }
.badge.warn    { background: var(--warning-soft); border-color: transparent; color: var(--warning); }
.badge.info    { background: var(--info-soft);    border-color: transparent; color: var(--info); }
.badge.accent  { background: var(--accent-soft);  border-color: transparent; color: var(--accent); }

/* ---------- BUTTONS ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg); border-color: var(--line); color: var(--text); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.1); }
.btn-ghost     { background: transparent; border-color: var(--line); color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-small     { min-height: 30px; padding: 6px 10px; font-size: 11px; }
.btn-block     { width: 100%; }

/* ---------- FORMS ---------- */

label {
  display: grid;
  gap: 7px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  margin: 14px 0 0;
}

input, textarea, select {
  width: 100%;
  min-height: 40px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  outline: none;
  transition: all var(--transition);
}

textarea { min-height: 110px; resize: vertical; }
select { cursor: pointer; }

input::placeholder, textarea::placeholder { color: var(--text-dim); }

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------- ALERTS ---------- */

.alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid;
  margin-bottom: 16px;
  font-size: 12px;
}

.alert-success { background: var(--success-soft); border-color: transparent; color: var(--success); }
.alert-danger  { background: var(--danger-soft);  border-color: transparent; color: var(--danger); }
.alert-warning { background: var(--warning-soft); border-color: transparent; color: var(--warning); }

/* ---------- ACTION GRID ---------- */

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.action-grid a {
  display: flex;
  gap: 11px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  transition: all var(--transition);
}

.action-grid a:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.action-grid a > span {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  flex-shrink: 0;
}

.action-grid strong { display: block; font-size: 12px; font-weight: 600; }
.action-grid small { display: block; color: var(--text-dim); margin-top: 2px; font-size: 10px; }

/* ---------- RANK BARS ---------- */

.rank-bars { display: grid; gap: 8px; }

.rank-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.rank-row > div { display: flex; align-items: center; gap: 10px; }
.rank-row strong { color: var(--text); font-weight: 600; }

.rank-pill {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  padding: 0 7px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
  font-size: 11px;
}

/* ---------- ACTIVITY / TIMELINE ---------- */

.activity-list { display: grid; }

.activity {
  display: grid;
  grid-template-columns: 7px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line-soft);
}

.activity:last-child { border-bottom: 0; }
.activity-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.activity strong { display: block; font-size: 12px; font-weight: 600; }
.activity span { display: block; color: var(--text-muted); font-size: 11px; margin-top: 2px; }
.activity time { color: var(--text-dim); font-size: 10px; white-space: nowrap; }

/* ---------- AUTH PAGE ---------- */

.auth-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background: var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 28px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.auth-card .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.auth-card .brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 20px;
  flex-shrink: 0;
}

.auth-card .brand strong {
  display: block;
  font-size: 14px;
  letter-spacing: .18em;
  font-weight: 800;
}

.auth-card .brand small {
  display: block;
  margin-top: 2px;
  color: var(--text-dim);
  font-size: 9px;
  letter-spacing: .24em;
  font-weight: 600;
}

.auth-card h1 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.02em;
}

.auth-card .muted {
  margin: 0 0 18px;
  color: var(--text-muted);
  font-size: 13px;
}

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

/* ---------- INLINE ACTIONS ---------- */

.inline-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.cell-sub {
  display: block;
  margin-top: 2px;
  color: var(--text-dim);
  font-size: 10px;
}

/* ---------- TIMELINE ---------- */

.timeline { display: grid; }

.timeline-item {
  display: grid;
  grid-template-columns: 7px minmax(0, 1fr);
  gap: 11px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
}

.timeline-item:last-child { border-bottom: 0; }

.timeline-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 5px;
}

.timeline-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.timeline-item strong { font-size: 12px; font-weight: 600; }
.timeline-item p { margin: 6px 0 0; color: var(--text-muted); font-size: 12px; }
.timeline-item time { display: block; margin-top: 5px; color: var(--text-dim); font-size: 10px; }
.timeline-item small { color: var(--text-dim); font-size: 10px; }

/* ---------- CALLOUT ---------- */

.callout {
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-muted);
  font-size: 12px;
}

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

/* ---------- MISC ---------- */

.link { color: var(--accent); font-size: 11px; font-weight: 600; }
.link:hover { text-decoration: underline; }

.empty {
  padding: 32px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}

.footnote { font-size: 10px; color: var(--text-dim); margin-top: 10px; }

.mt-10 { margin-top: 10px !important; }
.mt-20 { margin-top: 20px !important; }

/* ---------- RESPONSIVE ---------- */

@media (max-width: 1200px) {
  :root { --sidebar-w: 232px; }
  .grid-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-5 { grid-template-columns: 1fr 1fr; }
  .hero-card { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 760px) {
  :root { --sidebar-w: 0px; }
  .sidebar {
    width: min(300px, 88vw);
    transform: translateX(-105%);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .mobile-menu { display: grid; place-items: center; }
  .topbar { padding: 12px 16px; }
  .content { padding: 18px 16px 40px; }
  .grid-2, .grid-3, .grid-4, .grid-5, .action-grid { grid-template-columns: 1fr; }
  .page-intro h2 { font-size: 22px; }
  .account-chip { display: none; }
}