:root {
  --bg-dark: #0f172a;
  --bg-card: #1e293b;
  --bg-card-alt: #162032;
  --border: #334155;
  --text: #f8fafc;
  --muted: #94a3b8;
  --emerald: #10b981;
  --emerald-lt: #34d399;
  --amber: #f59e0b;
  --sky: #38bdf8;
  --crimson: #ef4444;
}

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

body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.45;
}

.hidden { display: none !important; }

/* LOGIN VIEW */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at 20% 20%, #0d2137 0%, #0f172a 55%, #060913 100%);
}

.login-card {
  width: 100%;
  max-width: 430px;
  background: linear-gradient(145deg, #111c33, #0b1324);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  position: relative;
  overflow: hidden;
}

.login-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, transparent, var(--emerald), var(--sky), transparent);
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 24px;
}

.login-logo { width: 54px; height: 54px; margin-bottom: 12px; }

.brand-pill {
  display: inline-block;
  background: #0a1628;
  border: 1px solid var(--sky);
  color: var(--sky);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2.5px;
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 8px;
}

.login-title {
  font-size: 22px;
  font-weight: 800;
  background: linear-gradient(90deg, #e0f7ff, #38bdf8, #10b981);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-sub { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; font-weight: 600; }

input, select {
  width: 100%;
  background: var(--bg-dark);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13.5px;
  outline: none;
}

input:focus, select:focus { border-color: var(--sky); }

.btn-primary {
  background: var(--emerald);
  color: #052e22;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-weight: 700;
  font-size: 13.5px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--emerald-lt); }
.btn-primary:disabled { background: #475569; color: var(--muted); cursor: not-allowed; }
.btn-full { width: 100%; margin-top: 6px; padding: 11px; }

.btn-secondary {
  background: var(--bg-dark);
  color: #cbd5e1;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.btn-secondary:hover { border-color: var(--sky); color: var(--text); }

.btn-danger {
  background: #3b1219;
  color: #fca5a5;
  border: 1px solid #7f1d1d;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}
.btn-danger:hover { background: #7f1d1d; color: #fff; }

.error-banner {
  background: #2a1317;
  border: 1px solid var(--crimson);
  color: #fca5a5;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 12.5px;
  margin-bottom: 12px;
}

.login-foot {
  margin-top: 18px;
  text-align: center;
  font-size: 11px;
  color: #64748b;
}

/* MAIN APP LAYOUT */
.app-shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 14px 16px;
}

.header-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.header-left { display: flex; align-items: center; gap: 12px; }
.header-logo { width: 38px; height: 38px; flex-shrink: 0; }
.header-title-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.app-title { font-size: 18px; font-weight: 800; letter-spacing: 0.3px; }
.season-badge {
  background: #064e3b;
  border: 1px solid var(--emerald);
  color: var(--emerald-lt);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
}
.header-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }

.header-right { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.stat-box {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 10px;
  min-width: 92px;
}
.stat-label { font-size: 10px; color: var(--muted); }
.stat-val { font-size: 14px; font-weight: 800; }
.val-amber { color: var(--amber); }
.val-sky { color: var(--sky); }
.val-red { color: var(--crimson); }
.val-emerald { color: var(--emerald-lt); }

.user-pill {
  background: #0a1628;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  color: #e2e8f0;
}

/* LEAGUE TABS */
.league-bar {
  background: var(--bg-card-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.league-btn {
  background: var(--bg-card);
  color: #cbd5e1;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 9px 10px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.league-btn:hover { border-color: var(--sky); color: var(--text); }
.league-btn.active { background: var(--sky); color: #0f172a; font-weight: 800; }

/* TOP PICKS */
.top-picks-bar {
  background: var(--bg-card-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
}
.top-picks-hdr { font-size: 11.5px; font-weight: 700; color: var(--sky); margin-bottom: 8px; }
.top-picks-hdr span { color: var(--muted); font-weight: 400; }
.top-picks-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.top-pick-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.top-pick-card:hover { border-color: var(--sky); }
.tp-match { font-size: 12.5px; font-weight: 700; }
.tp-market { font-size: 12px; font-weight: 600; color: var(--emerald-lt); margin-top: 2px; }
.tp-time { font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.tp-right { text-align: right; flex-shrink: 0; }
.conf-pill {
  display: inline-block;
  background: #064e3b;
  color: var(--emerald-lt);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
}
.tp-prob { font-size: 13px; font-weight: 800; margin-top: 3px; }

/* SUB TABS */
.sub-tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.sub-tab {
  background: var(--bg-card);
  color: var(--muted);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 7px 7px 0 0;
  padding: 9px 16px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.sub-tab.active { background: var(--sky); color: #0f172a; font-weight: 800; border-color: var(--sky); }

.tab-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0 10px 10px 10px;
  padding: 12px;
}

/* FIXTURES SPLIT */
.split-layout {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 12px;
  align-items: start;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
  align-items: center;
}
.filter-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.filter-item select, .filter-item input { width: auto; padding: 6px 10px; font-size: 12px; }

.fixtures-scroll { max-height: 620px; overflow-y: auto; padding-right: 4px; }
.fixture-card {
  background: var(--bg-card-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 12px;
  margin-bottom: 8px;
  cursor: pointer;
}
.fixture-card:hover { border-color: #64748b; }
.fixture-card.selected { border: 2px solid var(--sky); background: #1b2a42; }

.fc-top { display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.gw-pill { background: var(--bg-dark); color: var(--sky); font-weight: 700; padding: 2px 7px; border-radius: 4px; font-size: 10px; margin-right: 6px; }

.fc-teams { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin-bottom: 6px; }
.fc-team-name { font-size: 14.5px; font-weight: 700; }
.fc-team-sub { font-size: 10.5px; color: var(--muted); }
.fc-away { text-align: right; }
.xg-pill { background: var(--bg-dark); padding: 4px 10px; border-radius: 6px; font-size: 12px; font-weight: 700; color: #e2e8f0; }

.prob-bar { display: flex; height: 9px; border-radius: 4px; overflow: hidden; background: var(--border); }
.prob-h { background: var(--emerald); }
.prob-d { background: var(--amber); }
.prob-a { background: var(--sky); }
.prob-labels { display: flex; justify-content: space-between; font-size: 11px; font-weight: 600; margin-top: 4px; margin-bottom: 6px; }

.fc-bet {
  background: var(--bg-dark);
  border: 1px solid #263449;
  border-radius: 6px;
  padding: 6px 9px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
}

/* DETAIL PANEL */
.detail-box {
  background: var(--bg-card-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  max-height: 660px;
  overflow-y: auto;
}
.detail-meta { font-size: 11px; color: var(--sky); font-weight: 700; }
.detail-title { font-size: 20px; font-weight: 800; margin: 3px 0 10px; }

.detail-teams-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.detail-team-card { background: var(--bg-dark); border: 1px solid var(--border); border-radius: 8px; padding: 10px; }
.dt-hdr { font-size: 11.5px; font-weight: 800; }
.dt-wdl { font-size: 12.5px; font-weight: 700; margin: 4px 0 2px; }
.dt-sub { font-size: 11px; color: var(--muted); }

.rec-card {
  background: #0b2922;
  border: 1px solid var(--emerald);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}
.rec-top { display: flex; justify-content: space-between; font-size: 11px; font-weight: 700; }
.rec-pick { font-size: 17px; font-weight: 800; margin: 4px 0; }
.rec-reason { font-size: 12px; color: #cbd5e1; margin-bottom: 8px; }
.rec-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.rec-pill { background: var(--bg-dark); padding: 4px 8px; border-radius: 4px; font-size: 11px; color: var(--sky); }

.info-section {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 10px;
}
.info-hdr { font-size: 11px; font-weight: 800; color: var(--sky); margin-bottom: 6px; text-transform: uppercase; }
.info-hdr.red { color: var(--crimson); }
.factor-list { list-style: disc; padding-left: 18px; font-size: 11.5px; color: #cbd5e1; }
.factor-list li { margin-bottom: 3px; }
.inj-item { font-size: 11.5px; color: #fca5a5; margin-bottom: 3px; }

/* TABLES */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th {
  background: var(--bg-dark);
  color: var(--sky);
  text-align: left;
  padding: 9px 8px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { padding: 8px; border-bottom: 1px solid #243044; }
tr:nth-child(even) td { background: #182336; }

/* BACKTEST */
.bt-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 12px 0 18px; }
.bt-card { background: var(--bg-dark); border: 1px solid var(--border); border-radius: 8px; padding: 12px; }
.bt-val { font-size: 22px; font-weight: 800; margin-top: 4px; }
.guide-text { font-size: 12.5px; color: #cbd5e1; line-height: 1.7; }
.disclaimer {
  margin-top: 14px;
  background: #2a1b1e;
  border: 1px solid var(--crimson);
  color: #fca5a5;
  border-radius: 8px;
  padding: 11px;
  font-size: 12px;
}

/* ADMIN */
.admin-grid { display: grid; grid-template-columns: 340px 1fr; gap: 14px; align-items: start; }
.admin-card { background: var(--bg-dark); border: 1px solid var(--border); border-radius: 8px; padding: 14px; }
.status-pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.status-active { background: #064e3b; color: var(--emerald-lt); }
.status-disabled { background: #3b1219; color: #fca5a5; }
.action-btns { display: flex; flex-wrap: wrap; gap: 5px; }

.footer-bar {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
  margin-top: 10px;
}

/* MODAL */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal-card {
  width: 100%;
  max-width: 390px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.team-link {
  cursor: pointer;
  transition: color 0.12s;
}
.team-link:hover {
  color: var(--sky) !important;
  text-decoration: underline;
}

.team-hub-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 14px;
  align-items: start;
}

.news-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 8px;
}

.news-card {
  display: block;
  text-decoration: none;
  background: var(--bg-card-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
}
.news-card:hover { border-color: var(--sky); }
.news-title { font-size: 12.5px; font-weight: 600; line-height: 1.35; margin-bottom: 5px; }
.news-meta { font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; }

.res-badge {
  display: inline-block;
  width: 22px;
  text-align: center;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 0;
}
.res-W { background: #064e3b; color: #34d399; }
.res-D { background: #451a03; color: #fbbf24; }
.res-L { background: #3b1219; color: #fca5a5; }

@media (max-width: 1050px) {
  .split-layout, .admin-grid, .team-hub-grid { grid-template-columns: 1fr; }
  .league-bar { grid-template-columns: repeat(2, 1fr); }
  .top-picks-grid { grid-template-columns: 1fr; }
  .bt-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .league-bar { grid-template-columns: 1fr; }
  .detail-teams-grid { grid-template-columns: 1fr; }
}
