:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-2: #eef4fb;
  --ink: #132033;
  --muted: #647287;
  --line: #d9e3ef;
  --navy: #071b36;
  --blue: #0a62b7;
  --blue-2: #0f8bd6;
  --cyan: #22b8cf;
  --green: #17865d;
  --red: #c73b37;
  --amber: #b56c00;
  --shadow: 0 18px 44px rgba(12, 34, 60, .1);
  font-family: "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(140deg, rgba(10, 98, 183, .11), transparent 34%),
    linear-gradient(320deg, rgba(34, 184, 207, .11), transparent 38%),
    var(--bg);
  color: var(--ink);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled, input:disabled, select:disabled { opacity: .55; cursor: not-allowed; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 288px 1fr; }
.side {
  min-width: 0;
  background: var(--navy);
  color: white;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.brand { display: grid; gap: 5px; }
.brand strong { font-size: 1.12rem; }
.brand span { color: rgba(255,255,255,.72); font-size: .9rem; }
.mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--blue), var(--cyan));
  border-radius: 8px;
  font-weight: 900;
  margin-bottom: 8px;
}
.preview-mark { margin: 0; }
.avatar {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  overflow: hidden;
  background: linear-gradient(135deg, var(--blue), var(--cyan));
  color: white;
  font-weight: 900;
  flex: 0 0 auto;
}
.avatar.big { width: 86px; height: 86px; font-size: 1.65rem; }
.avatar.mini { width: 28px; height: 28px; font-size: .78rem; }
.avatar-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.user-chip { display: inline-flex; align-items: center; gap: 8px; }
.profile-panel { display: grid; gap: 18px; }
.profile-hero { display: flex; align-items: center; gap: 16px; }
.profile-hero h2, .profile-hero p { margin: 0; }
.avatar-builder {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 12px;
  background: #fbfdff;
}
.avatar-builder h3 { margin: 0; }
.avatar-swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 2px solid var(--line);
  background: var(--swatch);
  padding: 0;
}
.swatch.active { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(19,32,51,.12); }
.nav { display: grid; gap: 7px; }
.nav button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: white;
  text-align: start;
  padding: 10px 12px;
  font-weight: 700;
}
.nav button.active, .nav button:hover { background: rgba(255,255,255,.13); }
.side-foot {
  margin-top: auto;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 8px;
}

.main { min-width: 0; padding: 24px; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.title h1, .title p { margin: 0; }
.title p { color: var(--blue); font-weight: 800; font-size: .78rem; text-transform: uppercase; }
.title h1 { font-size: clamp(1.55rem, 3vw, 2.3rem); letter-spacing: 0; }
.actions { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.btn {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 13px;
  background: var(--panel);
  color: var(--ink);
  font-weight: 800;
}
.btn.primary { background: var(--blue); color: white; }
.btn.good { background: var(--green); color: white; }
.btn.danger { background: #fff0ef; color: #9d2c29; border-color: #f2c3c0; }
.btn.ghost { border-color: var(--line); background: var(--panel); }
.btn.small { min-height: 32px; font-size: .86rem; padding-inline: 10px; }
.lang button[aria-pressed="true"] { background: var(--navy); color: white; }

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.login-card {
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  overflow: hidden;
  border-radius: 12px;
  box-shadow: var(--shadow);
  background: var(--panel);
  border: 1px solid var(--line);
}
.login-hero {
  background: var(--navy);
  color: white;
  padding: clamp(24px, 6vw, 54px);
  display: grid;
  align-content: center;
  gap: 16px;
}
.login-hero h1 { margin: 0; font-size: clamp(2rem, 5vw, 3.4rem); }
.login-hero p { color: rgba(255,255,255,.74); line-height: 1.6; margin: 0; }
.login-form { padding: clamp(22px, 5vw, 42px); display: grid; gap: 14px; align-content: center; }

.grid { display: grid; gap: 14px; }
.grid.metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.panel, .metric, .card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.panel { padding: 18px; }
.metric { min-height: 104px; padding: 16px; display: grid; align-content: space-between; }
.metric span { color: var(--muted); }
.metric strong { font-size: 2rem; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.panel-head h2, .panel h2, .panel h3 { margin: 0; }
.muted { color: var(--muted); font-size: .92rem; }
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--blue);
  font-weight: 850;
  font-size: .78rem;
  width: max-content;
}
.badge.good { background: #e7f6ef; color: var(--green); }
.badge.warn { background: #fff4dc; color: var(--amber); }
.badge.danger { background: #fff0ef; color: var(--red); }

label { display: grid; gap: 7px; color: var(--muted); font-size: .88rem; font-weight: 750; }
input, select, textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  color: var(--ink);
  padding: 9px 11px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 3px solid rgba(15,139,214,.25);
  outline-offset: 2px;
}
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 14px; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; color: var(--ink); }
.switch input { width: 22px; min-height: 22px; accent-color: var(--blue); }

.stage { display: grid; gap: 12px; margin-bottom: 18px; }
.stage h2 { margin: 8px 0 0; font-size: 1.15rem; }
.match-card { padding: 14px; display: grid; gap: 12px; }
.match-top { display: flex; justify-content: space-between; align-items: start; gap: 10px; }
.teams { display: grid; gap: 4px; font-weight: 900; }
.prediction-grid { display: grid; grid-template-columns: 100px 100px minmax(160px, 1fr) auto; gap: 9px; align-items: end; }
.score-input { text-align: center; font-size: 1.1rem; font-weight: 900; }
.status-msg { min-height: 22px; font-weight: 800; color: var(--green); }
.status-msg.err { color: var(--red); }

.leader-table { width: 100%; border-collapse: collapse; }
.leader-table th, .leader-table td { padding: 11px 9px; border-bottom: 1px solid var(--line); text-align: start; }
.leader-cards { display: none; gap: 10px; }
.rank-card { padding: 13px; display: grid; gap: 6px; }

.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs button.active { background: var(--blue); color: white; }
.admin-layout { display: grid; grid-template-columns: 280px 1fr; gap: 14px; align-items: start; }
.admin-menu { display: grid; gap: 8px; }
.admin-menu button { text-align: start; }
.table-wrap { overflow-x: auto; }
table.admin-table { width: 100%; min-width: 820px; border-collapse: collapse; }
table.admin-table th, table.admin-table td { padding: 10px; border-bottom: 1px solid var(--line); text-align: start; vertical-align: top; }
.empty { border: 1px dashed var(--line); border-radius: 8px; color: var(--muted); padding: 18px; text-align: center; }
.toast { position: fixed; inset-inline: 20px; bottom: 20px; z-index: 20; display: grid; justify-items: center; pointer-events: none; }
.toast span { background: var(--navy); color: white; border-radius: 8px; padding: 10px 14px; box-shadow: var(--shadow); }

[dir="rtl"] .nav button, [dir="rtl"] .admin-menu button { text-align: right; }

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .side { padding: 16px; }
  .nav { display: flex; flex-wrap: wrap; padding-bottom: 3px; }
  .nav button { flex: 1 1 140px; white-space: normal; text-align: center; }
  .side-foot { display: none; }
  .grid.metrics, .grid.three, .grid.two, .admin-layout { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .main { padding: 16px; }
  .topbar { flex-direction: column; align-items: stretch; }
  .login-card { grid-template-columns: 1fr; }
  .login-hero { padding: 26px; }
  .form-row, .prediction-grid { grid-template-columns: 1fr; }
  .leader-table { display: none; }
  .leader-cards { display: grid; }
  .panel-head, .match-top { flex-direction: column; align-items: stretch; }
  .actions .btn, .btn.primary, .btn.good { flex: 1; }
}
