
:root {
  --bg: #0c1117;
  --panel: #121923;
  --panel-2: #17212d;
  --line: #263446;
  --text: #eef5fb;
  --muted: #93a4b8;
  --accent: #a970ff;
  --r3: #57d38c;
  --r2: #65a9ff;
  --r1: #ff7474;
  --warn: #ffca64;
  --shadow: 0 14px 40px rgba(0,0,0,.22);
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 85% 0%, rgba(169,112,255,.10), transparent 28rem),
    var(--bg);
  color: var(--text);
}
button, input, select { font: inherit; }
.topbar {
  min-height: 82px;
  padding: 16px clamp(18px, 4vw, 54px);
  border-bottom: 1px solid var(--line);
  background: rgba(12,17,23,.88);
  backdrop-filter: blur(16px);
  display: flex;
  gap: 24px;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark {
  width: 46px; height: 46px; border-radius: 13px;
  display: grid; place-items: center;
  font-weight: 900; letter-spacing: -.04em;
  color: #071017;
  background: #000000;
  box-shadow: 0 8px 30px rgba(139,92,246,.28);
}
.brand h1 { font-size: 18px; margin: 0; }
.brand p { color: var(--muted); margin: 3px 0 0; font-size: 13px; }
.selectors { display: flex; gap: 12px; }
.selectors label { display: grid; gap: 5px; }
.selectors span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
select, input {
  color: var(--text);
  background: #101721;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}
select { min-width: 170px; padding: 9px 34px 9px 11px; }
.shell { max-width: 1500px; margin: 0 auto; padding: 30px clamp(16px, 3vw, 42px) 70px; }
.hero {
  display: flex; gap: 30px; justify-content: space-between; align-items: end;
  margin-bottom: 22px;
}
.eyebrow {
  color: var(--accent);
  font-size: 12px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .12em;
}
.hero h2 { font-size: clamp(27px, 3vw, 39px); margin: 5px 0 5px; letter-spacing: -.04em; }
.hero p { color: var(--muted); margin: 0; max-width: 860px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.legend span { display: flex; gap: 7px; align-items: center; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.r3 { background: var(--r3); }
.dot.r2 { background: var(--r2); }
.dot.r1 { background: var(--r1); }
.dot.power-low-dot { background: #67d9ff; }
.dot.power-mid-dot { background: #f0c45a; }
.dot.power-high-dot { background: #c69cff; }
.kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.kpi {
  background: linear-gradient(180deg, rgba(255,255,255,.025), transparent), var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 15px 16px;
  box-shadow: var(--shadow);
}
.kpi .label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.kpi .value { font-size: 24px; font-weight: 800; margin-top: 5px; letter-spacing: -.03em; }
.kpi .sub { margin-top: 3px; color: var(--muted); font-size: 12px; }
.controls {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; margin: 19px 0 12px;
}
.search-wrap { width: min(390px, 100%); }
.search-wrap input { width: 100%; padding: 11px 13px; }
.filters { display: flex; flex-wrap: wrap; gap: 7px; justify-content: flex-end; }
.filter, .icon-button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  border-radius: 9px;
  cursor: pointer;
}
.filter { padding: 8px 11px; }
.filter:hover, .filter.active { color: var(--text); border-color: #6f4aa8; background: var(--panel-2); }
.table-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.table-scroll { overflow: auto; max-height: calc(100vh - 315px); min-height: 420px; }
table { width: 100%; border-collapse: collapse; min-width: 1180px; }
th {
  position: sticky; top: 0; z-index: 3;
  background: #151e29;
  color: #b8c7d7;
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  text-align: right;
  padding: 12px 13px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  user-select: none;
}
th:nth-child(2), td:nth-child(2) { text-align: left; }
th:nth-child(3), td:nth-child(3) { text-align: center; }
td {
  padding: 11px 13px;
  border-bottom: 1px solid rgba(38,52,70,.72);
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}
tbody tr { cursor: pointer; }
tbody tr:hover { background: rgba(169,112,255,.055); }
tbody tr:last-child td { border-bottom: 0; }
.player { font-weight: 700; color: #f7fbff; }
.muted { color: var(--muted); }
.rank {
  display: inline-flex; min-width: 42px; justify-content: center;
  padding: 4px 8px; border-radius: 999px; font-weight: 800; font-size: 11px;
}
.rank.R3 { color: #baf3d0; background: rgba(87,211,140,.13); border: 1px solid rgba(87,211,140,.30); }
.rank.R2 { color: #c7e0ff; background: rgba(101,169,255,.13); border: 1px solid rgba(101,169,255,.30); }
.rank.R1 { color: #ffc5c5; background: rgba(255,116,116,.13); border: 1px solid rgba(255,116,116,.30); }
.growth.met { color: var(--r3); }
.growth.missed { color: var(--r1); }
.growth.grace { color: var(--warn); }
.empty-state {
  padding: 46px; border: 1px dashed #39506a; border-radius: 16px;
  text-align: center; background: rgba(18,25,35,.55);
}
.empty-state p { color: var(--muted); }
.hidden { display: none !important; }
dialog {
  width: min(760px, calc(100vw - 30px));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0;
  color: var(--text);
  background: #111923;
  box-shadow: 0 30px 100px rgba(0,0,0,.65);
}
dialog::backdrop { background: rgba(4,8,12,.72); backdrop-filter: blur(5px); }
.dialog-head { display: flex; justify-content: space-between; gap: 20px; padding: 22px 24px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 4px 0 0; font-size: 26px; }
.icon-button { width: 38px; height: 38px; font-size: 23px; }
#dialogContent { padding: 22px 24px 26px; }
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.detail {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0e151e;
  padding: 13px;
}
.detail .label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; }
.detail .value { margin-top: 5px; font-weight: 750; font-size: 17px; }
.detail-section { margin-top: 22px; }
.detail-section h3 { margin: 0 0 10px; font-size: 14px; }
.history { display: grid; gap: 7px; }
.history-row {
  display: grid; grid-template-columns: 105px 70px 90px 1fr;
  gap: 10px; align-items: center;
  background: #0e151e; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  font-size: 13px;
}
@media (max-width: 1050px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .hero { align-items: flex-start; flex-direction: column; }
  .controls { align-items: stretch; flex-direction: column; }
  .search-wrap { width: 100%; }
  .filters { justify-content: flex-start; }
}
@media (max-width: 720px) {
  .topbar { position: static; align-items: stretch; flex-direction: column; }
  .selectors { display: grid; grid-template-columns: 1fr 1fr; }
  select { min-width: 0; width: 100%; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .detail-grid { grid-template-columns: repeat(2, 1fr); }
  .history-row { grid-template-columns: 1fr 1fr; }
}


.player.power-low { color: #67d9ff; }
.player.power-mid { color: #f0c45a; }
.player.power-high { color: #c69cff; }
.power-group-tag {
  display: inline-flex;
  margin-left: 7px;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
  vertical-align: middle;
  border: 1px solid currentColor;
  opacity: .9;
}
.power-group-tag.low { color: #67d9ff; background: rgba(103,217,255,.08); }
.power-group-tag.mid { color: #f0c45a; background: rgba(240,196,90,.08); }
.power-group-tag.high { color: #c69cff; background: rgba(198,156,255,.08); }


.admin-tools { display:flex; gap:8px; margin-left:auto; }
.toolbar-button {
  border:1px solid var(--line);
  background:var(--panel-2);
  color:var(--text);
  border-radius:9px;
  padding:9px 12px;
  cursor:pointer;
}
.toolbar-button.secondary { color:var(--muted); background:var(--panel); }
.toolbar-button.active { border-color:var(--accent); color:var(--accent); }
.officer-badge {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  margin-left:7px;
  padding:2px 6px;
  border-radius:999px;
  font-size:9px;
  font-weight:900;
  letter-spacing:.05em;
  vertical-align:middle;
  border:1px solid currentColor;
}
.officer-badge.R5 { color:#ffd166; background:rgba(255,209,102,.10); }
.officer-badge.R4 { color:#ff9f68; background:rgba(255,159,104,.10); }
.edit-hint { color:var(--accent); font-size:11px; margin-left:8px; }
.edit-form {
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:12px;
}
.edit-form label { display:grid; gap:6px; }
.edit-form label span {
  color:var(--muted);
  font-size:11px;
  text-transform:uppercase;
  letter-spacing:.07em;
}
.edit-form input, .edit-form select, .edit-form textarea {
  width:100%;
  color:var(--text);
  background:#0e151e;
  border:1px solid var(--line);
  border-radius:9px;
  padding:9px 10px;
}
.edit-form textarea { min-height:70px; resize:vertical; }
.edit-actions { display:flex; gap:8px; justify-content:flex-end; margin-top:16px; }
.edit-actions button {
  border:1px solid var(--line);
  border-radius:9px;
  padding:9px 13px;
  cursor:pointer;
  background:var(--panel-2);
  color:var(--text);
}
.local-save-note {
  margin:14px 0 0;
  color:var(--muted);
  font-size:12px;
  line-height:1.45;
}
@media (max-width:900px) {
  .topbar { flex-wrap:wrap; }
  .admin-tools { order:3; margin-left:0; }
}
@media (max-width:620px) {
  .edit-form { grid-template-columns:1fr; }
}


/* Header alignment refinement */
.header-actions {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-left: auto;
}
.header-actions .admin-tools {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-left: 0;
  order: initial;
}
.header-actions .toolbar-button,
.header-actions select {
  height: 38px;
}
.header-actions .toolbar-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding-top: 0;
  padding-bottom: 0;
}
.header-actions .selectors {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

@media (max-width: 900px) {
  .header-actions {
    width: 100%;
    margin-left: 0;
    align-items: flex-end;
    flex-wrap: wrap;
  }
  .header-actions .admin-tools {
    order: initial;
  }
}
@media (max-width: 720px) {
  .header-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
  .header-actions .admin-tools {
    width: 100%;
  }
  .header-actions .toolbar-button {
    flex: 1;
  }
  .header-actions .selectors {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

.growth-gap {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  font-weight: 700;
  color: var(--r1);
  white-space: nowrap;
}


.player-tag {
  display: inline-block;
  margin-right: 3px;
  position: relative;
  top: -0.34em;
  font-size: 0.68em;
  line-height: 1;
  font-weight: 900;
  letter-spacing: 0.02em;
  color: var(--muted);
  vertical-align: baseline;
  text-transform: none;
}

.toolbar-button:disabled {
  opacity: .45;
  cursor: not-allowed;
}
.login-dialog { width: min(460px, calc(100vw - 30px)); }
.login-body { padding: 22px 24px 26px; display: grid; gap: 14px; }
.login-body label { display: grid; gap: 6px; }
.login-body label span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; }
.login-body input { width: 100%; padding: 10px 11px; }
.login-error { min-height: 18px; color: var(--r1); font-size: 12px; }


.requirement-missed {
  box-shadow: inset 0 -2px 0 var(--r1);
}
.requirement-met { color: var(--r3); }
.requirement-missed-text { color: var(--r1); }
.rules-dialog { width: min(760px, calc(100vw - 30px)); }
.rules-body { padding: 22px 24px 26px; }
.rules-section + .rules-section { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.rules-section h3 { margin: 0 0 12px; font-size: 14px; }
.rules-note { color: var(--muted); font-size: 12px; line-height: 1.5; margin: 10px 0 14px; }


/* v3 administration, targets and officer overview */
.brand-mark img, .preview-mark img { width: 100%; height: 100%; object-fit: contain; border-radius: inherit; }
.user-badge { display:inline-flex; align-items:center; padding:9px 11px; color:var(--muted); font-size:12px; }
.officer-section { margin: 4px 0 18px; }
.section-head { display:flex; justify-content:space-between; align-items:end; margin-bottom:10px; }
.section-head h3 { margin:3px 0 0; font-size:17px; }
.officer-cards { display:grid; grid-template-columns:repeat(auto-fit,minmax(215px,1fr)); gap:10px; }
.officer-card { text-align:left; border:1px solid var(--line); background:var(--panel); color:var(--text); border-radius:13px; padding:12px; cursor:pointer; box-shadow:var(--shadow); }
.officer-card:hover { border-color:#6f4aa8; background:var(--panel-2); }
.officer-card-head { display:flex; justify-content:space-between; align-items:center; gap:8px; }
.officer-stats { display:grid; grid-template-columns:repeat(4,1fr); gap:8px; margin-top:11px; }
.officer-stats span { display:grid; gap:2px; }
.officer-stats small { color:var(--muted); font-size:9px; text-transform:uppercase; letter-spacing:.06em; }
.officer-stats strong { font-size:13px; }
.officer-warnings { display:flex; flex-wrap:wrap; gap:5px; margin-top:10px; min-height:20px; }
.warning-chip, .ok-chip { display:inline-flex; border-radius:999px; padding:3px 7px; font-size:10px; font-weight:800; }
.warning-chip { color:#ffd0d0; background:rgba(255,116,116,.10); border:1px solid rgba(255,116,116,.42); }
.ok-chip { color:#baf3ce; background:rgba(87,211,140,.08); border:1px solid rgba(87,211,140,.35); }
.metric-target { color:var(--muted); font-size:10px; }
.target-gap { display:block; color:var(--r1); font-size:9px; font-weight:800; margin-top:2px; }
.requirement-missed { background:rgba(255,116,116,.06); box-shadow:inset 0 -2px 0 var(--r1); }
.admin-dialog { width:min(850px,calc(100vw - 30px)); }
.alliance-admin-list { display:grid; gap:9px; }
.alliance-admin-row { display:grid; grid-template-columns:minmax(180px,1fr) minmax(100px,.4fr) auto auto; gap:8px; align-items:center; }
.alliance-admin-row input { padding:9px 10px; width:100%; }
.alliance-admin-row button, .danger-button { border:1px solid var(--line); background:var(--panel-2); color:var(--text); border-radius:9px; padding:9px 11px; cursor:pointer; }
.danger-button { color:#ffaaaa !important; border-color:rgba(255,116,116,.35) !important; }
.branding-preview { margin:18px 0; display:flex; align-items:center; gap:12px; }
.preview-mark { position:static; width:64px; height:64px; }
@media(max-width:760px){ .alliance-admin-row{grid-template-columns:1fr 1fr}.alliance-admin-row button{width:100%}.officer-cards{grid-template-columns:1fr 1fr} }
@media(max-width:520px){ .officer-cards{grid-template-columns:1fr} }

/* Auth gate */
body.auth-locked main {
  display: none;
}

body.auth-locked .header-actions {
  display: none;
}

body.auth-locked .topbar {
  position: static;
  justify-content: center;
  min-height: 120px;
  border-bottom: 0;
  background: transparent;
}

body.auth-locked #loginClose,
body.auth-locked #loginCancel {
  display: none;
}

body.auth-locked #loginDialog::backdrop {
  background: rgba(5, 7, 12, .88);
  backdrop-filter: blur(10px);
}

/* Account administration */
.accounts-dialog {
  width: min(980px, calc(100vw - 32px));
}

.account-admin-list {
  display: grid;
  gap: 16px;
}

.account-admin-card {
  padding: 18px;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 14px;
  background: rgba(255,255,255,.025);
}

.account-admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.account-admin-head > div {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.account-scope-box {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px;
  background: rgba(0,0,0,.14);
}

.account-scope-box > .label {
  margin-bottom: 10px;
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
}

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

.account-alliance-option,
.account-toggle > span:last-child {
  display: flex;
  align-items: center;
  gap: 8px;
}

.account-alliance-option {
  padding: 8px 10px;
  border-radius: 9px;
  background: rgba(255,255,255,.035);
}

.account-alliance-option:has(input:disabled) {
  opacity: .48;
}

.account-password-reset {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-top: 14px;
}

.account-password-reset label {
  display: grid;
  gap: 6px;
}

.account-password-reset label > span {
  font-size: .78rem;
  color: var(--muted);
}

@media (max-width: 680px) {
  .account-password-reset {
    grid-template-columns: 1fr;
  }

  .account-admin-head {
    align-items: flex-start;
    flex-direction: column;
  }
}
