:root {
  --bg: #070b16;
  --panel: #0f172a;
  --panel-soft: #111a2c;
  --text: #ecf0ff;
  --muted: #a3afcc;
  --accent: #2dd4bf;
  --danger: #f97373;
  --ok: #34d399;
  --line: #22324f;
  --skyline: #11274a;
  --fifa-blue: #0b2a5c;
  --fifa-cyan: #2dd4bf;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Nunito Sans", "Noto Sans TC", "PingFang TC", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 10%, #172554 0%, transparent 40%),
    radial-gradient(circle at 85% 25%, #0f2a4a 0%, transparent 35%),
    linear-gradient(180deg, #05070f 0%, #081126 45%, #05070f 100%);
}

.page {
  max-width: 1140px;
  margin: 0 auto;
  padding: 24px;
}

header {
  margin-bottom: 10px;
}

.top-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 12px 24px;
  margin-bottom: 14px;
  justify-content: flex-start;
  background: linear-gradient(180deg, rgba(8, 14, 30, 0.96), rgba(8, 22, 44, 0.9));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
  letter-spacing: 0.02em;
}

.top-nav a {
  color: #dce7ff;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  text-transform: uppercase;
  transition: 0.2s ease;
}

.top-nav a:hover,
.top-nav a.active {
  border-color: rgba(45, 212, 191, 0.45);
  color: #2dd4bf;
}

.top-nav .nav-brand {
  margin-right: auto;
  border-color: transparent;
  color: #ffffff;
  font-weight: 700;
  background: linear-gradient(90deg, rgba(45, 212, 191, 0.22), rgba(59, 130, 246, 0.28));
  border: 1px solid rgba(45, 212, 191, 0.45);
  letter-spacing: 0.12em;
  font-size: 0.96rem;
}

.top-nav a[href="index.html"]:hover,
.top-nav a[href="index.html"]:focus-visible {
  border-color: rgba(45, 212, 191, 0.65);
}

.hero {
  position: relative;
  margin-bottom: 16px;
  padding: 18px 18px 20px;
  border: 1px solid rgba(45, 212, 191, 0.18);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(13, 31, 64, 0.65), rgba(4, 17, 37, 0.86));
  box-shadow: inset 0 0 60px rgba(45, 212, 191, 0.08);
}

.hero::after {
  content: "";
  position: absolute;
  top: 1px;
  right: 1px;
  bottom: 1px;
  left: 1px;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 15px;
}

h1,
h2,
h3,
h4 {
  margin: 4px 0 10px;
}

.section-kicker {
  margin: 16px 0 0;
  color: var(--fifa-cyan);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.82rem;
}

h2 {
  font-size: 1.42rem;
  line-height: 1.25;
}

h3 {
  font-size: 1.08rem;
  line-height: 1.35;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

button,
select {
  border: 0;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--text);
  font-family: inherit;
}

button {
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

button:hover {
  transform: translateY(-1px);
  opacity: 0.9;
}

.status {
  min-height: 24px;
  padding: 8px 10px;
  border-left: 4px solid #3b82f6;
  background: rgba(59, 130, 246, 0.1);
}

.status.error {
  border-left-color: var(--danger);
  background: rgba(248, 113, 113, 0.12);
}

.status.loading {
  border-left-color: #60a5fa;
  background: rgba(96, 165, 250, 0.12);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.card,
.match-card {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
  backdrop-filter: blur(2px);
}

.today-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.match-mini-card {
  position: relative;
  background: linear-gradient(165deg, rgba(17, 34, 64, 0.9), rgba(8, 16, 33, 0.96));
  border-color: rgba(45, 212, 191, 0.2);
  box-shadow: 0 10px 30px rgba(5, 8, 20, 0.35);
}

.match-mini-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), transparent, #3b82f6);
}

.match-time {
  color: var(--fifa-cyan);
  font-weight: 700;
  margin-bottom: 8px;
}

.today-list {
  margin-top: 0;
}

.today-grid h4 {
  margin-top: 10px;
  margin-bottom: 6px;
  color: #e2ecff;
  border-left: 2px solid rgba(45, 212, 191, 0.6);
  padding-left: 8px;
  font-size: 0.88rem;
}

.today-grid ul {
  margin: 0 0 8px 14px;
  padding-left: 16px;
}

.source-card .source-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.source-card .source-meta {
  margin: 4px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.source-card .source-meta p {
  margin: 0;
}

.source-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(96, 165, 250, 0.16);
  color: #bfdbfe;
  border: 1px solid rgba(96, 165, 250, 0.45);
}

.source-badge.ok {
  background: rgba(16, 185, 129, 0.16);
  border-color: rgba(16, 185, 129, 0.55);
  color: #bbf7d0;
}

.source-badge.danger {
  background: rgba(248, 113, 113, 0.16);
  border-color: rgba(248, 113, 113, 0.55);
  color: #fecaca;
}

.source-badge.loading {
  background: rgba(250, 204, 21, 0.16);
  border-color: rgba(250, 204, 21, 0.55);
  color: #fef08a;
}

.source-badge.pending {
  background: rgba(148, 163, 184, 0.16);
  border-color: rgba(148, 163, 184, 0.45);
  color: #cbd5e1;
}

.source-badge.reference {
  background: rgba(125, 211, 252, 0.14);
  border-color: rgba(125, 211, 252, 0.45);
  color: #bae6fd;
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
}

.mini-chart {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding-top: 8px;
}

.mini-bar-row {
  display: grid;
  grid-template-columns: 84px 1fr 46px;
  gap: 8px;
  align-items: center;
}

.mini-bar-label {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
}

.mini-bar-track {
  height: 10px;
  border-radius: 99px;
  background: rgba(148, 163, 184, 0.14);
  overflow: hidden;
}

.mini-bar-fill {
  --bar: var(--accent);
  display: block;
  height: 100%;
  width: 0;
  background: var(--bar);
  border-radius: 99px;
  transition: width 0.25s ease;
}

.mini-bar-value {
  text-align: right;
  font-size: 12px;
  color: #dbeafe;
}

ul {
  padding-left: 18px;
  margin-top: 8px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.methodology {
  max-width: 1140px;
  margin: 10px auto 30px;
  padding: 0 24px 24px;
}

.source-legend {
  margin: 8px 0 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.source-legend .source-badge {
  margin-right: 0;
}

.methodology ul {
  color: #e2e8f0;
}

.note {
  color: #fbbf24;
}

.single-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
}

.market-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
}

.market-matrix-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  border: 1px solid rgba(148, 163, 184, 0.2);
  padding: 8px 10px;
  text-align: left;
}

.data-table th {
  background: rgba(45, 212, 191, 0.14);
  color: #e2ebff;
  font-size: 12px;
}

.analysis-toolbar {
  margin-bottom: 10px;
}

.analysis-toolbar label {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.analysis-toolbar select {
  min-width: 240px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.portfolio-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: #e2ebff;
}

.portfolio-form input,
.portfolio-form select,
.portfolio-form button {
  width: 100%;
}

.portfolio-form .spacer {
  display: block;
  visibility: hidden;
  height: 1px;
}

.tier-badge {
  display: inline-block;
  margin-left: 8px;
  margin-right: 2px;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
}

.tier-badge.high {
  background: rgba(248, 113, 113, 0.16);
  border: 1px solid rgba(248, 113, 113, 0.55);
  color: #fecaca;
}

.tier-badge.medium {
  background: rgba(250, 204, 21, 0.16);
  border: 1px solid rgba(250, 204, 21, 0.55);
  color: #fef08a;
}

.tier-badge.low {
  background: rgba(16, 185, 129, 0.16);
  border: 1px solid rgba(16, 185, 129, 0.55);
  color: #bbf7d0;
}

.playbook-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.playbook-row {
  border-left: 2px solid rgba(45, 212, 191, 0.35);
  padding-left: 8px;
  margin-top: 0;
  margin-bottom: 8px;
  color: #dce7ff;
}

.playbook-meta {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.risk-high {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.45);
  color: #bbf7d0;
}

.risk-medium {
  background: rgba(250, 204, 21, 0.12);
  border: 1px solid rgba(250, 204, 21, 0.45);
  color: #fef08a;
}

.risk-low {
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.45);
  color: #fecaca;
}

.risk-pill {
  display: inline-block;
  border-radius: 999px;
  margin-left: 8px;
  padding: 1px 8px;
  font-size: 11px;
}

.playbook-grid .card ul {
  margin: 0;
  padding-left: 16px;
}

@media (max-width: 640px) {
  .page {
    padding: 14px;
  }

  .top-nav {
    padding: 10px 14px;
  }

  .top-nav a {
    width: fit-content;
  }

  .actions {
    flex-direction: column;
    align-items: stretch;
  }

  button,
  select {
    width: 100%;
  }
}
