:root {
  --primary: #1a56db;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --text: #111827;
  --muted: #64748b;
  --border: #dbe3ef;
  --danger: #dc2626;
  --warning: #f59e0b;
  --success: #16a34a;
  --shadow: 0 18px 45px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }
html { font-family: Inter, system-ui, sans-serif; color: var(--text); background: var(--bg); }
body { margin: 0; min-height: 100vh; }
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font: inherit; }

.app-shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar { background: #0f172a; color: #fff; padding: 20px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: 10px; align-items: center; color: inherit; font-weight: 800; margin-bottom: 28px; }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 8px; background: var(--primary); color: #fff; font-size: 13px; }
.nav { display: grid; gap: 6px; }
.nav a { color: #cbd5e1; padding: 11px 12px; border-radius: 8px; }
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; }

.main { min-width: 0; }
.topbar { height: 68px; display: flex; align-items: center; justify-content: space-between; padding: 0 28px; background: rgba(255,255,255,.86); border-bottom: 1px solid var(--border); backdrop-filter: blur(14px); position: sticky; top: 0; z-index: 5; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.content { padding: 28px; max-width: 1500px; margin: 0 auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head h1 { margin: 0 0 6px; font-size: 30px; letter-spacing: 0; }
.page-head p, .muted { color: var(--muted); margin: 0; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 18px; box-shadow: var(--shadow); margin-bottom: 18px; }
.progress-panel { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; margin-bottom: 18px; box-shadow: var(--shadow); }
.progress-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 10px; }
.progress-head span { color: var(--muted); font-size: 13px; }
.progress-bar { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress-bar span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--primary); transition: width .35s ease; }
.progress-panel p { margin-top: 10px; font-size: 13px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.panel h2 { margin: 0 0 12px; font-size: 18px; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 18px; box-shadow: var(--shadow); }
.kpi span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.kpi strong { font-size: 28px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 900px; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0; }
tr:hover td { background: rgba(26, 86, 219, .04); }
.highlight { background: rgba(26, 86, 219, .12); font-weight: 700; }

.btn, button.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); cursor: pointer; }
.btn:disabled, button:disabled { opacity: .6; cursor: wait; }
.link-button { border: 0; background: transparent; color: var(--primary); padding: 0; cursor: pointer; font: inherit; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-ghost { background: transparent; }
.btn-small { min-height: 32px; padding: 0 10px; font-size: 13px; }
.icon-btn { width: 40px; height: 40px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: pointer; }
.menu-toggle { display: none; }
.actions, .row-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.danger { color: var(--danger); }

.filters, .form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.form-grid label, .filters label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
input, select, textarea { width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; background: var(--surface); color: var(--text); min-height: 42px; }
textarea { min-height: 92px; resize: vertical; }
.check { display: flex !important; align-items: center; gap: 8px; }
.check input { width: auto; min-height: auto; }
.form-actions { grid-column: 1 / -1; display: flex; gap: 10px; }

.badge { display: inline-flex; align-items: center; min-height: 26px; padding: 0 9px; border-radius: 999px; background: color-mix(in srgb, var(--badge-color, var(--primary)) 14%, transparent); color: var(--badge-color, var(--primary)); font-weight: 700; font-size: 12px; }
.badge-muted { --badge-color: #64748b; }
.badge-warning { --badge-color: var(--warning); }
.avatar, .avatar-img { width: 38px; height: 38px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--surface-2); color: var(--primary); font-weight: 800; object-fit: cover; }
.avatar-lg { width: 70px; height: 70px; font-size: 22px; }
.cards-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.player-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 18px; transition: transform .18s ease, box-shadow .18s ease; }
.player-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.player-photo { width: 70px; height: 70px; border-radius: 50%; object-fit: cover; }
.player-card h3 { margin: 12px 0 8px; font-size: 17px; }
.hidden { display: none !important; }

.details { display: grid; grid-template-columns: 180px 1fr; gap: 10px; }
.details dt { color: var(--muted); }
.details dd { margin: 0; font-weight: 600; }
.profile-grid { display: grid; grid-template-columns: 420px 1fr; gap: 18px; }
.elo-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.elo-card { border: 1px solid var(--border); border-radius: 8px; padding: 14px; background: var(--surface-2); }
.elo-card span { display: block; color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; margin-bottom: 6px; }
.elo-card strong { font-size: 26px; line-height: 1; }
.elo-standard { border-left: 4px solid #1a56db; }
.elo-rapid { border-left: 4px solid #10b981; }
.elo-blitz { border-left: 4px solid #e63946; }
.elo-local { border-left: 4px solid #f59e0b; }
.elo-updated { margin-bottom: 12px; font-size: 13px; }
.chart-frame { position: relative; height: 340px; max-height: 340px; overflow: hidden; }
.chart-frame canvas { display: block; width: 100% !important; height: 340px !important; max-height: 340px !important; }
.range-list { display: flex; flex-wrap: wrap; gap: 8px; }
.range-pill, .user-chip { background: var(--surface-2); border-radius: 999px; padding: 7px 10px; font-size: 13px; color: var(--muted); }
.swatch { display: inline-block; width: 18px; height: 18px; border-radius: 4px; vertical-align: middle; margin-right: 8px; }
.pagination { display: flex; gap: 6px; justify-content: center; }
.pagination a { padding: 8px 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.pagination .is-active { background: var(--primary); color: #fff; }

.alert { padding: 12px 14px; border-radius: 8px; background: var(--surface-2); margin-bottom: 14px; }
.alert-danger { background: #fee2e2; color: #991b1b; }
.login-page { display: grid; place-items: center; min-height: 100vh; background: var(--bg); padding: 18px; }
.login-card { width: min(430px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 28px; box-shadow: var(--shadow); display: grid; gap: 14px; }
.login-card h1 { margin: 0; }
.login-brand { margin-bottom: 6px; color: var(--text); }
.modal { border: 1px solid var(--border); border-radius: 8px; padding: 18px; background: var(--surface); color: var(--text); }
.toast-stack { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 10px; z-index: 20; }
.toast { background: var(--text); color: var(--surface); padding: 12px 14px; border-radius: 8px; box-shadow: var(--shadow); }

@media (max-width: 1199px) { .cards-grid { grid-template-columns: repeat(3, 1fr); } .kpi-grid, .elo-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 1023px) { .app-shell { grid-template-columns: 1fr; } .sidebar { position: fixed; inset: 0 auto 0 0; width: 280px; transform: translateX(-100%); transition: transform .2s; z-index: 10; } .sidebar.is-open { transform: none; } .menu-toggle { display: inline-grid; place-items: center; } .profile-grid { grid-template-columns: 1fr; } .filters, .form-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 767px) { .content { padding: 18px; } .page-head { align-items: flex-start; flex-direction: column; } .cards-grid { grid-template-columns: repeat(2, 1fr); } .kpi-grid, .elo-grid, .filters, .form-grid { grid-template-columns: 1fr; } }
@media (max-width: 479px) { .cards-grid { grid-template-columns: 1fr; } .topbar { padding: 0 14px; } .details { grid-template-columns: 1fr; } }
