/* EnP Toolpak web dashboard — palette scraped from the app's DesignTokens.swift
   (dark-mode E&P navy/blue theme + alliance gold accent). */

:root {
  --enp-navy:      #141C33;  /* page background  (0.08, 0.11, 0.20) */
  --enp-card:      #213361;  /* card surface     (0.13, 0.20, 0.38) */
  --enp-card-soft: rgba(33, 51, 97, 0.6);
  --enp-primary:   #FFFFFF;  /* primary text */
  --enp-subtle:    #99A6BF;  /* muted text       (0.60, 0.65, 0.75) */
  --enp-gold:      #F2C738;  /* alliance gold    (0.95, 0.78, 0.22) */
  --enp-ally:      #61B8FF;  /* ally blue        (0.38, 0.72, 1.00) */
  --enp-enemy:     #FF5940;  /* enemy red        (1.00, 0.35, 0.25) */
  --enp-green:     #34C759;  /* iOS system green (win) */
  --enp-on-accent: #0F1424;  /* dark text on gold buttons */
  --radius: 12px;
  --shadow: 0 3px 6px rgba(0, 0, 0, 0.35);
}

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

body {
  background: var(--enp-navy);
  color: var(--enp-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Top bar ── */
.topbar {
  background: linear-gradient(180deg, #0D1428 0%, var(--enp-navy) 100%);
  border-bottom: 1px solid rgba(242, 199, 56, 0.25);
  position: sticky; top: 0; z-index: 50;
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; gap: 14px;
}
.app-icon {
  width: 46px; height: 46px; border-radius: 11px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(242, 199, 56, 0.4);
}
.title-block h1 { font-size: 19px; font-weight: 800; letter-spacing: 0.3px; }
.title-block .subtitle { font-size: 11.5px; color: var(--enp-gold); font-weight: 600; letter-spacing: 1.2px; text-transform: uppercase; }
.topbar-right { margin-left: auto; display: flex; gap: 10px; align-items: center; }

.alliance-select {
  background: var(--enp-card); color: var(--enp-primary);
  border: 1px solid rgba(153, 166, 191, 0.35); border-radius: 8px;
  padding: 7px 10px; font-size: 13px; font-weight: 600; max-width: 220px;
}

.btn-gold {
  background: var(--enp-gold); color: var(--enp-on-accent);
  border: none; border-radius: 9px; padding: 9px 16px;
  font-size: 13px; font-weight: 800; cursor: pointer;
  box-shadow: var(--shadow); white-space: nowrap;
}
.btn-gold:hover { filter: brightness(1.08); }

/* ── Layout ── */
.dashboard, .upload-panel { max-width: 1080px; width: 100%; margin: 0 auto; padding: 18px 20px; }
.section { margin-bottom: 26px; }
.section-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.section-head .section-label { margin-bottom: 0; }

.section-label {
  font-size: 12.5px; font-weight: 600; color: var(--enp-subtle);
  text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 10px;
}

.card {
  background: var(--enp-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card.pad { padding: 16px; }

.hidden { display: none !important; }
.footnote { font-size: 10.5px; color: var(--enp-subtle); margin-top: 8px; }

/* ── Upload panel ── */
.upload-card { padding: 20px; }
.upload-card h2 { font-size: 16px; margin-bottom: 6px; }
.upload-card .hint { font-size: 12.5px; color: var(--enp-subtle); margin-bottom: 14px; line-height: 1.5; }
.upload-card code { color: var(--enp-gold); }
.upload-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.upload-row label { font-size: 12.5px; font-weight: 600; color: var(--enp-subtle); }
.upload-row input {
  background: var(--enp-navy); color: var(--enp-primary);
  border: 1px solid rgba(153, 166, 191, 0.35); border-radius: 8px;
  padding: 8px 12px; font-size: 13.5px; flex: 1; max-width: 280px;
}
.drop-zone {
  border: 2px dashed rgba(242, 199, 56, 0.45); border-radius: var(--radius);
  padding: 30px 16px; text-align: center; cursor: pointer;
  color: var(--enp-subtle); font-size: 13.5px; transition: all .15s;
}
.drop-zone:hover, .drop-zone.dragover { background: rgba(242, 199, 56, 0.08); color: var(--enp-gold); }
.upload-status { margin-top: 10px; font-size: 13px; font-weight: 600; min-height: 18px; }
.upload-status.ok { color: var(--enp-green); }
.upload-status.err { color: var(--enp-enemy); }

.contributor-list { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.contributor-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--enp-navy); border-radius: 8px; padding: 8px 12px; font-size: 12.5px;
}
.contributor-row .c-name { font-weight: 700; }
.contributor-row .c-meta { color: var(--enp-subtle); font-size: 11px; }
.contributor-row .c-del {
  margin-left: auto; background: none; border: none; color: var(--enp-enemy);
  cursor: pointer; font-size: 12px; font-weight: 700;
}

/* ── Filter bar ── */
.filter-bar { padding: 12px 14px; margin-bottom: 16px; }
.filter-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.filter-head .section-label { margin-bottom: 0; }
.filter-actions { display: flex; gap: 6px; }
.chip-btn {
  background: var(--enp-card-soft); border: 1px solid rgba(153, 166, 191, 0.3);
  color: var(--enp-gold); font-size: 11px; font-weight: 700;
  border-radius: 999px; padding: 4px 12px; cursor: pointer;
}
.chip-row { display: flex; flex-wrap: wrap; gap: 7px; }
.boost-chip {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 999px; padding: 5px 12px; font-size: 12px; font-weight: 600;
  cursor: pointer; border: 1px solid rgba(153, 166, 191, 0.3);
  background: var(--enp-navy); color: var(--enp-subtle);
  user-select: none; transition: all .12s;
}
.boost-chip.on {
  color: var(--enp-primary);
  border-color: var(--boost-color, var(--enp-gold));
  background: color-mix(in srgb, var(--boost-color, var(--enp-gold)) 18%, var(--enp-navy));
}
.boost-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--boost-color, var(--enp-gold)); }

/* ── Tabs ── */
.tabs {
  display: flex; gap: 4px; background: var(--enp-card-soft);
  border-radius: 10px; padding: 4px; margin-bottom: 20px;
}
.tab {
  flex: 1; background: none; border: none; color: var(--enp-subtle);
  font-size: 13.5px; font-weight: 700; padding: 9px 0; border-radius: 8px; cursor: pointer;
}
.tab.active { background: var(--enp-gold); color: var(--enp-on-accent); }

/* ── Tiles ── */
.tile-row { display: flex; gap: 12px; }
.tile {
  flex: 1; background: var(--enp-card); border-radius: var(--radius);
  box-shadow: var(--shadow); text-align: center; padding: 16px 8px;
}
.tile .big { font-size: 27px; font-weight: 900; font-variant-numeric: tabular-nums; }
.tile .lbl { font-size: 11px; font-weight: 600; color: var(--enp-subtle); margin-top: 4px; }
.tile .sub { font-size: 10px; color: var(--enp-subtle); margin-top: 2px; }
.c-green { color: var(--enp-green); }
.c-gold  { color: var(--enp-gold); }
.c-red   { color: var(--enp-enemy); }
.c-sub   { color: var(--enp-subtle); }

/* ── Bar charts (offense trend / flags left) ── */
.bar-chart-card { padding: 14px; }
.bar-chart { display: flex; align-items: flex-end; gap: 5px; height: 110px; }
.bar-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 3px; min-width: 0; }
.bar-col .bar { width: 100%; border-radius: 4px 4px 2px 2px; min-height: 5px; }
.bar-col .bar-val { font-size: 9.5px; font-weight: 700; color: var(--enp-subtle); }
.bar-col .bar-date { font-size: 8.5px; color: var(--enp-subtle); white-space: nowrap; overflow: hidden; max-width: 100%; }
.chart-legend { display: flex; align-items: center; gap: 14px; margin-top: 10px; font-size: 10.5px; color: var(--enp-subtle); }
.chart-legend .avg { margin-left: auto; color: var(--enp-gold); font-weight: 700; }
.legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }

/* ── Stat rows / tables ── */
.stat-table { display: flex; flex-direction: column; gap: 7px; }
.stat-header {
  display: flex; align-items: center; padding: 0 14px;
  font-size: 10px; font-weight: 700; color: var(--enp-subtle); text-transform: uppercase; letter-spacing: 0.4px;
}
.stat-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--enp-card); border-radius: 10px; box-shadow: var(--shadow);
  padding: 10px 14px; font-size: 12.5px;
}
.stat-row .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.stat-row .num { font-weight: 800; font-variant-numeric: tabular-nums; text-align: right; }
.w-36 { width: 36px; } .w-44 { width: 44px; } .w-56 { width: 56px; } .w-64 { width: 64px; }
.mini-bar-track { height: 6px; border-radius: 3px; background: rgba(153, 166, 191, 0.2); overflow: hidden; margin-top: 4px; }
.mini-bar-fill { height: 100%; border-radius: 3px; }

.badge {
  font-size: 9.5px; font-weight: 800; border-radius: 4px; padding: 2px 6px;
  text-transform: uppercase; letter-spacing: 0.3px;
}
.badge.green { color: var(--enp-green); background: rgba(52, 199, 89, 0.15); }
.badge.red   { color: var(--enp-enemy); background: rgba(255, 89, 64, 0.15); }

/* ── Segmented controls / steppers / selects ── */
.controls-inline { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--enp-navy); border-radius: 8px; padding: 3px; gap: 2px; }
.seg-btn {
  background: none; border: none; color: var(--enp-subtle);
  font-size: 12px; font-weight: 700; padding: 5px 14px; border-radius: 6px; cursor: pointer;
}
.seg-btn.active { background: var(--enp-gold); color: var(--enp-on-accent); }
.mini-select {
  background: var(--enp-card-soft); color: var(--enp-gold);
  border: 1px solid rgba(153, 166, 191, 0.3); border-radius: 999px;
  font-size: 12px; font-weight: 700; padding: 5px 10px;
}
.stepper { display: inline-flex; align-items: center; gap: 8px; }
.stepper-label { font-size: 10.5px; color: var(--enp-subtle); }
.step-btn {
  width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--enp-gold);
  background: none; color: var(--enp-gold); font-size: 14px; font-weight: 800; cursor: pointer;
  line-height: 1;
}
.step-btn:disabled { border-color: var(--enp-subtle); color: var(--enp-subtle); }
.step-value { font-size: 14px; font-weight: 800; min-width: 20px; text-align: center; }
.check-label { font-size: 12px; color: var(--enp-subtle); display: flex; align-items: center; gap: 6px; }

/* ── Defender position groups ── */
.pos-groups { display: flex; gap: 10px; align-items: flex-start; }
.pos-group { flex: 1; background: var(--enp-card); border-radius: 10px; box-shadow: var(--shadow); padding: 12px; }
.pos-group h4 { font-size: 11.5px; font-weight: 800; color: var(--enp-gold); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.pos-hero { display: flex; gap: 6px; margin-bottom: 6px; align-items: baseline; }
.pos-hero .rank { font-size: 10.5px; font-weight: 800; width: 16px; flex-shrink: 0; }
.pos-hero .info { min-width: 0; }
.pos-hero .name { font-size: 11.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pos-hero .meta { font-size: 9.5px; color: var(--enp-subtle); }
.thin { color: var(--enp-subtle) !important; }

/* facet rows */
.facet-group { margin-top: 12px; }
.facet-group h4 { font-size: 12px; font-weight: 800; margin-bottom: 6px; }
.facet-row { display: flex; align-items: center; gap: 8px; font-size: 12px; padding: 3px 0; }
.facet-row .chip {
  width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.25);
}
.facet-row .f-label { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.facet-row .f-score { font-weight: 900; color: var(--enp-gold); font-variant-numeric: tabular-nums; }
.facet-row .f-unit { font-size: 9px; color: var(--enp-subtle); }
.facet-row .f-flags { font-size: 10px; color: var(--enp-subtle); min-width: 32px; text-align: right; }
.scope-line { font-size: 11px; color: var(--enp-subtle); margin: 6px 0 2px; }

/* ── Player table ── */
.ptable-wrap { overflow-x: auto; background: var(--enp-card); border-radius: var(--radius); box-shadow: var(--shadow); }
table.ptable { width: 100%; border-collapse: collapse; font-size: 12.5px; min-width: 720px; }
.ptable th {
  text-align: right; padding: 10px 10px; font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.4px; color: var(--enp-subtle); cursor: pointer; user-select: none; white-space: nowrap;
}
.ptable th:first-child, .ptable td:first-child { text-align: left; padding-left: 14px; }
.ptable th.sorted { color: var(--enp-gold); }
.ptable td { padding: 8px 10px; text-align: right; font-variant-numeric: tabular-nums; border-top: 1px solid rgba(153, 166, 191, 0.12); }
.ptable td.name { font-weight: 700; text-align: left; }
.ptable .ex-member { color: var(--enp-subtle); font-style: italic; }

/* ── Recent wars ── */
.war-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--enp-card); border-radius: 10px; box-shadow: var(--shadow);
  padding: 10px 14px; margin-bottom: 8px;
}
.war-row .result-bar { width: 4px; height: 34px; border-radius: 3px; flex-shrink: 0; }
.war-row .w-title { font-size: 13px; font-weight: 700; }
.war-row .w-meta { font-size: 10.5px; color: var(--enp-subtle); margin-top: 2px; display: flex; gap: 8px; align-items: center; }
.war-row .w-score { margin-left: auto; font-size: 14.5px; font-weight: 900; font-variant-numeric: tabular-nums; }
.war-row .w-status { font-size: 10px; font-weight: 800; }

/* ── Empty state / footer ── */
.empty-state { text-align: center; padding: 70px 20px; }
.empty-icon { width: 84px; height: 84px; border-radius: 20px; margin-bottom: 18px; box-shadow: var(--shadow); }
.empty-state h2 { font-size: 18px; margin-bottom: 8px; }
.empty-state p { font-size: 13px; color: var(--enp-subtle); margin-bottom: 18px; }

.footer {
  margin-top: auto; text-align: center; padding: 22px 18px;
  font-size: 10.5px; color: var(--enp-subtle);
  border-top: 1px solid rgba(153, 166, 191, 0.15);
}
.footer .footer-line { margin: 5px 0; }
.footer .privacy-line { font-size: 11px; }
.footer a { color: var(--enp-gold); text-decoration: none; }
.footer a:hover { text-decoration: underline; }

.kofi-btn {
  display: inline-block; margin-bottom: 14px;
  background: var(--enp-gold); color: var(--enp-on-accent) !important;
  border-radius: 999px; padding: 8px 18px;
  font-size: 12.5px; font-weight: 800; text-decoration: none !important;
  box-shadow: var(--shadow);
}
.kofi-btn:hover { filter: brightness(1.08); }

.muted-note { font-size: 12px; color: var(--enp-subtle); padding: 8px 2px; }

/* ── Legal / privacy page ── */
.legal-page { max-width: 760px; width: 100%; margin: 0 auto; padding: 26px 22px 60px; line-height: 1.6; }
.legal-page .back { display: inline-block; margin-bottom: 18px; font-size: 13px; color: var(--enp-gold); text-decoration: none; font-weight: 700; }
.legal-page .back:hover { text-decoration: underline; }
.legal-page h1 { font-size: 23px; margin-bottom: 6px; }
.legal-page .updated { font-size: 12px; color: var(--enp-subtle); margin-bottom: 20px; }
.legal-page h2 { font-size: 15px; color: var(--enp-gold); margin: 26px 0 8px; }
.legal-page p, .legal-page li { font-size: 13.5px; color: var(--enp-primary); }
.legal-page ul { margin: 8px 0 8px 20px; }
.legal-page li { margin-bottom: 6px; }
.legal-page a { color: var(--enp-gold); }
.legal-page .callout {
  background: var(--enp-card); border-radius: var(--radius);
  padding: 14px 16px; margin: 18px 0; box-shadow: var(--shadow);
  border-left: 3px solid var(--enp-gold);
}
.legal-page .callout p { margin: 0; }

@media (max-width: 760px) {
  .tile-row { flex-wrap: wrap; }
  .tile { min-width: 44%; }
  .pos-groups { flex-direction: column; }
  .topbar-inner { flex-wrap: wrap; }
  .topbar-right { width: 100%; justify-content: flex-end; }
}
