:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --panel: #ffffff;
  --panel-soft: #f7f7f9;
  --line: #e5e5ea;
  --line-soft: #f0f0f3;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --blue: #007aff;
  --blue-strong: #0057d9;
  --blue-soft: #eef6ff;
  --green: #1d7f55;
  --green-soft: #ebf8f1;
  --amber: #946516;
  --amber-soft: #fff7e8;
  --red: #b33a3a;
  --red-soft: #fff0f0;
  --shadow: 0 16px 42px rgba(0, 0, 0, 0.06);
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.04);
  --radius: 8px;
  --sidebar: 248px;
}

/* Alliance Battle */
.detail-shell.alliance-battle-shell {
  width: min(1560px, calc(100% - 48px));
  grid-template-columns: minmax(0, 1fr);
}

.alliance-battle-shell > * {
  min-width: 0;
}

.alliance-battle-page .detail-floating-close {
  right: 16px;
  z-index: 91;
}

.panel.alliance-battle-header-panel {
  padding-bottom: 0;
}

.panel-heading.alliance-battle-heading {
  align-items: flex-end;
}

.alliance-battle-heading h1 {
  margin-bottom: 4px;
}

.alliance-battle-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.alliance-battle-period-controls {
  display: grid;
  grid-template-columns: auto minmax(210px, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.alliance-battle-period-controls label {
  color: var(--muted);
  font-size: 12px;
}

.alliance-battle-primary-tabs,
.alliance-battle-day-tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.alliance-battle-primary-tabs {
  margin: 18px -20px 0;
  padding: 0 20px;
  border-top: 1px solid var(--line);
}

.alliance-battle-primary-tabs button,
.alliance-battle-day-tabs button {
  flex: 0 0 auto;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-weight: 650;
}

.alliance-battle-primary-tabs button {
  min-height: 48px;
  padding: 0 18px;
}

.alliance-battle-primary-tabs button:hover,
.alliance-battle-primary-tabs button.active,
.alliance-battle-day-tabs button:hover,
.alliance-battle-day-tabs button.active {
  border-bottom-color: var(--blue);
  color: var(--blue-strong);
}

.panel.alliance-battle-period-panel {
  padding-bottom: 0;
}

.alliance-battle-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 18px 0 8px;
  border-block: 1px solid var(--line);
}

.alliance-battle-metrics > div {
  min-width: 0;
  padding: 14px 18px;
  border-right: 1px solid var(--line);
}

.alliance-battle-metrics > div:first-child {
  padding-left: 0;
}

.alliance-battle-metrics > div:last-child {
  border-right: 0;
}

.alliance-battle-metrics dt {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
}

.alliance-battle-metrics dd {
  margin: 0;
  font-size: 20px;
  font-weight: 750;
  line-height: 1.15;
}

.alliance-battle-day-tabs {
  margin: 0 -20px;
  padding: 0 20px;
}

.alliance-battle-day-tabs button {
  display: grid;
  place-items: center;
  min-width: 96px;
  min-height: 58px;
  padding: 7px 14px 6px;
}

.alliance-battle-day-tabs button small {
  color: inherit;
  font-size: 10px;
  font-weight: 500;
}

.alliance-battle-data-heading {
  align-items: center;
}

.alliance-battle-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(150px, 0.45fr) minmax(180px, 0.55fr);
  gap: 12px;
  margin: 16px 0;
}

.alliance-battle-toolbar label {
  display: grid;
  gap: 5px;
}

.alliance-battle-toolbar label > span {
  color: var(--muted);
  font-size: 12px;
}

.alliance-battle-table-wrap {
  max-height: min(70vh, 780px);
  border: 1px solid var(--line);
}

.alliance-battle-table-wrap table {
  margin: 0;
  min-width: 1080px;
}

.alliance-battle-table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f7f7f9;
}

.alliance-battle-summary-table th:first-child,
.alliance-battle-summary-table td:first-child {
  width: 58px;
  text-align: center;
}

.alliance-battle-summary-table th:nth-child(2),
.alliance-battle-summary-table td:nth-child(2) {
  min-width: 220px;
}

.alliance-battle-summary-table th:nth-child(n+3):nth-child(-n+10),
.alliance-battle-summary-table td:nth-child(n+3):nth-child(-n+10) {
  white-space: nowrap;
}

.battle-person-button {
  display: grid;
  gap: 2px;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
}

.battle-person-button:not(a) {
  cursor: default;
}

.battle-person-button.matched:hover strong,
.battle-person-button.matched strong {
  color: var(--blue-strong);
}

.battle-person-button small,
.battle-source-tags,
.alliance-battle-history-table td small {
  color: var(--muted);
  font-size: 11px;
}

.battle-source-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
}

.battle-source-tags .tag {
  padding: 2px 5px;
  font-size: 10px;
}

.battle-unmatched-row {
  background: #fffdf7;
}

.battle-total-score {
  color: var(--blue-strong);
}

.numeric-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.battle-data-note {
  display: flex;
  gap: 10px;
  margin: 14px 0;
  padding: 10px 12px;
  border-left: 3px solid var(--amber);
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 13px;
}

.alliance-battle-day-table th:nth-child(2),
.alliance-battle-day-table td:nth-child(2) {
  min-width: 230px;
  text-align: left;
}

.alliance-battle-day-table td:nth-child(2) {
  white-space: normal;
}

.alliance-battle-empty,
.alliance-battle-empty-day {
  display: grid;
  justify-items: start;
  gap: 10px;
  padding-block: 36px;
}

.alliance-battle-empty h2,
.alliance-battle-empty p,
.alliance-battle-empty-day p {
  margin: 0;
}

.alliance-battle-empty p,
.alliance-battle-empty-day p {
  color: var(--muted);
}

.quick-modal-card.battle-day-editor-card {
  width: min(1180px, calc(100vw - 40px));
  max-height: min(92vh, 940px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 8px;
}

#battleDayEditorForm {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.battle-day-editor-rows {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

.battle-day-editor-card > :not(form),
#battleDayEditorForm > :not(.battle-day-editor-rows) {
  flex-shrink: 0;
}

.alliance-battle-page.modal-locked .detail-session-bar,
.alliance-battle-page.modal-locked > .detail-floating-close {
  visibility: hidden;
}

.battle-match-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.battle-star-overview,
.battle-auto-stars,
.battle-editor-topbar,
.battle-reward-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.battle-star-overview {
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.battle-star-overview > div {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-right: 12px;
}

.battle-star-overview strong {
  color: #137c65;
  font-size: 24px;
}

.battle-auto-stars {
  gap: 7px;
  font-size: 13px;
}

.battle-auto-stars input {
  width: 18px;
  height: 18px;
  accent-color: #137c65;
}

#battleStarEditorForm > .battle-auto-stars,
.battle-editor-topbar,
.battle-reward-controls {
  margin-bottom: 16px;
}

.battle-editor-topbar label,
.battle-reward-controls label {
  display: grid;
  gap: 5px;
  font-size: 13px;
}

.battle-editor-topbar input {
  width: 110px;
}

.battle-editor-topbar input,
.battle-reward-controls select,
.battle-day-editor-row input {
  min-height: 36px;
  padding: 6px 9px;
  font-size: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.battle-score-warning {
  color: #9e421c;
  background: #fff3e9;
  border-left: 3px solid #c5612b;
  padding: 10px 12px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.battle-score-anomaly {
  background: #fff0eb;
}

.battle-entry-identity {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px 12px;
  padding-top: 5px;
  font-size: 12px;
}

.battle-entry-identity small {
  color: #18785d;
  overflow-wrap: anywhere;
}

.battle-entry-identity button {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.battle-entry-candidates {
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  margin-top: 7px;
}

.battle-entry-candidates button {
  display: grid;
  gap: 3px;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: #fff;
  padding: 8px 10px;
  text-align: left;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.battle-entry-candidates button:hover {
  background: #eff7f4;
}

.battle-entry-candidates small {
  color: var(--muted);
}

.battle-day-name-field {
  min-width: 0;
}

.battle-day-name-field > label {
  display: grid;
  gap: 4px;
}

.battle-rewards-panel > h3 {
  margin-top: 24px;
  font-size: 16px;
}

.battle-reward-sources {
  margin-top: 24px;
}

.battle-reward-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.battle-reward-gallery a {
  display: grid;
  gap: 6px;
  text-align: center;
}

.battle-reward-gallery img {
  width: 100%;
  aspect-ratio: 898 / 1684;
  object-fit: contain;
}

.battle-match-toolbar label,
.battle-new-person-grid small {
  color: var(--muted);
  font-size: 12px;
}

.battle-new-person-grid input,
.battle-new-person-grid select {
  min-width: 0;
  width: 100%;
}

.battle-new-person-error {
  color: var(--red);
  font-size: 13px;
  overflow-wrap: anywhere;
}

#allianceBattleMatchModal .match-source strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.battle-editor-help {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
}

.battle-bulk-import {
  margin-bottom: 16px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
}

.battle-bulk-import summary {
  cursor: pointer;
  font-weight: 650;
}

.battle-bulk-import textarea {
  width: 100%;
  margin: 10px 0 8px;
  resize: vertical;
}

.battle-day-editor-labels,
.battle-day-editor-row {
  display: grid;
  grid-template-columns: 72px minmax(220px, 1.4fr) minmax(90px, 0.45fr) minmax(150px, 0.7fr) 36px;
  gap: 8px;
  align-items: end;
}

.battle-day-editor-labels {
  padding: 0 5px 6px;
  color: var(--muted);
  font-size: 11px;
}

.battle-day-editor-row {
  padding: 9px 5px;
  border-top: 1px solid var(--line-soft);
  align-items: start;
}

.battle-day-editor-row label {
  display: grid;
  gap: 4px;
  min-width: 0;
  color: var(--muted);
  font-size: 10px;
}

.battle-day-editor-row input,
.battle-day-editor-row select {
  width: 100%;
  min-width: 0;
}

.battle-day-editor-row .icon-button {
  margin-top: 20px;
  margin-bottom: 2px;
}

.battle-editor-add-row {
  padding-top: 12px;
}

.quick-modal-card.battle-period-editor-card,
.quick-modal-card.battle-history-editor-card {
  width: min(760px, calc(100vw - 40px));
  border-radius: 8px;
}

.battle-period-editor-form label small,
.battle-history-editor-card label small {
  color: var(--muted);
  font-size: 11px;
}

.history-metrics {
  margin-bottom: 16px;
}

.alliance-battle-history-table th:first-child,
.alliance-battle-history-table td:first-child {
  min-width: 170px;
}

.alliance-battle-history-table td:nth-child(4),
.alliance-battle-history-table td:nth-child(5),
.alliance-battle-history-table td:nth-child(6) {
  min-width: 180px;
  white-space: normal;
}

.alliance-battle-history-table td small {
  display: block;
  margin-top: 3px;
}

.battle-history-score {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.battle-history-score span {
  margin: 0 5px;
  color: var(--muted);
}

.alliance-activity-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

@media (max-width: 860px) {
  .detail-shell.alliance-battle-shell {
    width: min(100% - 20px, 1560px);
  }

  .panel-heading.alliance-battle-heading {
    align-items: stretch;
  }

  .alliance-battle-period-controls {
    grid-template-columns: 1fr auto;
  }

  .alliance-battle-period-controls label {
    grid-column: 1 / -1;
  }

  .alliance-battle-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .alliance-battle-metrics > div,
  .alliance-battle-metrics > div:first-child {
    padding: 12px;
    border-bottom: 1px solid var(--line);
  }

  .alliance-battle-metrics > div:nth-child(2) {
    border-right: 0;
  }

  .alliance-battle-metrics > div:nth-last-child(-n+2) {
    border-bottom: 0;
  }

  .alliance-battle-toolbar {
    grid-template-columns: 1fr;
  }

  .battle-day-editor-labels {
    display: none;
  }

  .battle-day-editor-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 36px;
  }

  .battle-day-name-field {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .battle-day-score-field {
    grid-column: 1 / -1;
    grid-row: 3;
  }

  .battle-day-editor-row > label:nth-of-type(2) {
    grid-column: 2;
    grid-row: 1;
  }

  .battle-day-editor-row .icon-button {
    grid-column: 3;
    grid-row: 1;
  }
}

@media (max-width: 520px) {
  .alliance-battle-metrics dd {
    font-size: 17px;
  }

  .alliance-battle-primary-tabs {
    margin-inline: -14px;
    padding-inline: 14px;
  }

  .alliance-battle-day-tabs {
    margin-inline: -14px;
    padding-inline: 14px;
  }

  .battle-day-editor-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 36px;
  }
}

.metric-with-date {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
  line-height: 1.25;
}

.metric-with-date > span {
  color: var(--text);
  white-space: nowrap;
}

.metric-with-date > small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
  white-space: nowrap;
}

.migration-record-list {
  display: grid;
  gap: 8px;
}

.migration-record-item {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(150px, 0.8fr) 36px;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.migration-record-item > div {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 4px 8px;
}

.migration-record-item > div small {
  grid-column: 2;
  color: var(--muted);
}

.migration-record-item > span {
  color: var(--muted);
  text-align: right;
}

.migration-record-editor {
  display: grid;
  grid-template-columns: minmax(210px, 1.3fr) minmax(125px, 0.7fr) minmax(140px, 0.8fr) auto;
  align-items: end;
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.migration-record-editor label,
.migration-direction-preview {
  display: grid;
  gap: 6px;
}

.migration-record-editor label > span,
.migration-direction-preview > span,
.migration-direction-preview > small {
  color: var(--muted);
  font-size: 12px;
}

.migration-record-editor select,
.migration-record-editor input {
  width: 100%;
  min-width: 0;
}

.migration-record-editor > label {
  min-width: 0;
}

.migration-record-item > .migration-origin-edit {
  grid-column: 1 / -1;
  display: flex;
  align-items: end;
  gap: 8px;
}

.migration-origin-edit label {
  display: grid;
  gap: 6px;
  max-width: 180px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
}

.migration-origin-edit input {
  width: 100%;
  min-width: 0;
}

@media (min-width: 721px) and (max-width: 1100px) {
  .migration-record-editor { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.transfer-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.transfer-record-group {
  min-width: 0;
}

.transfer-record-group-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.transfer-record-group-heading h4 {
  margin: 0;
}

.transfer-record-group-heading span {
  color: var(--muted);
  font-size: 12px;
}

.transfer-person-list {
  display: grid;
  gap: 6px;
}

.transfer-person-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
}

.transfer-person-row:last-child {
  border-bottom: 0;
}

.transfer-person-row:hover strong {
  color: var(--blue);
}

.transfer-person-row span,
.transfer-person-row small {
  color: var(--muted);
  font-size: 12px;
}

.transfer-person-row small {
  grid-column: 1;
}

@media (max-width: 720px) {
  .migration-record-item,
  .migration-record-editor,
  .transfer-summary-grid {
    grid-template-columns: 1fr;
  }

  .migration-record-item > span {
    text-align: left;
  }

  .migration-record-item > .icon-button {
    justify-self: end;
  }
}

html[data-auth-role="member"] [data-admin-only],
[hidden] {
  display: none !important;
}

.sidebar-account {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding: 12px 8px 2px;
  border-top: 1px solid var(--line);
}

.sidebar-account > div {
  min-width: 0;
  display: grid;
}

.sidebar-account strong,
.sidebar-account span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-account span {
  color: var(--muted);
  font-size: 12px;
}

.login-page {
  min-height: 100vh;
  background: var(--bg);
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(100%, 420px);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-brand {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  margin-bottom: 26px;
}

.login-brand p,
.login-brand h1 {
  margin: 0;
}

.login-brand p {
  color: var(--muted);
  font-size: 12px;
}

.login-brand h1 {
  font-size: 22px;
  letter-spacing: 0;
}

.login-form,
.auth-modal-card form {
  display: grid;
  gap: 16px;
}

.login-form label,
.auth-modal-card label,
.system-user-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.login-form input,
.auth-modal-card input,
.system-user-form input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  padding: 8px 11px;
  font-size: 14px;
  font-weight: 400;
  outline: none;
}

.login-form input:focus,
.auth-modal-card input:focus,
.system-user-form input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.13);
}

.login-form .primary-button,
.auth-modal-card .primary-button {
  width: 100%;
  min-height: 42px;
}

.form-error {
  margin: -4px 0 0;
  color: var(--red);
  font-size: 13px;
}

.system-user-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto;
  align-items: end;
  gap: 12px;
  margin: 14px 0 8px;
}

.system-user-form .primary-button {
  min-height: 42px;
}

.form-note {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 12px;
}

.system-user-table th,
.system-user-table td {
  vertical-align: middle;
}

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: none;
  place-items: center;
  padding: 20px;
}

.auth-modal.open {
  display: grid;
}

.auth-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(19, 31, 45, 0.62);
}

.auth-modal-card {
  position: relative;
  width: min(100%, 430px);
  padding: 26px;
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-modal-card h2,
.auth-modal-card > p {
  margin: 0 0 8px;
  letter-spacing: 0;
}

body.modal-locked {
  overflow: hidden;
}

.detail-session-bar {
  position: fixed;
  top: 16px;
  right: 62px;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 4px 6px 4px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-soft);
  color: var(--muted);
  font-size: 12px;
}

.detail-session-bar button {
  min-height: 25px;
  border: 0;
  border-left: 1px solid var(--line);
  background: transparent;
  color: var(--blue-strong);
  padding: 0 7px 0 10px;
}

.auth-toast[data-type="error"] {
  background: var(--red);
}

@media (max-width: 620px) {
  .login-shell {
    align-items: start;
    padding: 12vh 16px 24px;
  }

  .login-panel {
    padding: 24px 20px;
  }

  .system-user-form {
    grid-template-columns: 1fr;
  }

  .detail-session-bar {
    top: 10px;
    right: 52px;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  background: linear-gradient(180deg, #fbfbfd 0, var(--bg) 360px);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 14px;
  border-right: 1px solid var(--line);
  background: rgba(251, 251, 253, 0.94);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 10px;
  align-items: center;
  padding: 0 4px;
}

.mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font-weight: 800;
  box-shadow: var(--shadow-soft);
}

.brand h1,
.topbar h2,
.panel h3,
.drawer h3 {
  margin: 0;
  line-height: 1.18;
  letter-spacing: 0;
}

.brand h1 {
  font-size: 17px;
  font-weight: 750;
}

.brand p,
.eyebrow,
.panel-heading span,
.sidebar-note span {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.nav-tabs {
  display: grid;
  gap: 7px;
}

.nav-group {
  display: grid;
  gap: 3px;
}

.district-side-nav,
.national-side-nav,
.library-side-nav {
  display: grid;
  gap: 3px;
  margin: 0 0 2px 32px;
  padding-left: 11px;
  border-left: 1px solid var(--line);
}

.district-side-link {
  min-height: 30px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  padding: 3px 8px;
  text-align: left;
}

.district-side-link:hover,
.district-side-link.active {
  background: #fff;
  color: var(--text);
  font-weight: 700;
  box-shadow: inset 0 0 0 1px var(--line);
}

.subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.subnav-tab {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--muted);
  padding: 0 14px;
}

.subnav-tab:hover,
.subnav-tab.active {
  color: var(--blue-strong);
  background: var(--panel-soft);
  border-color: #d1d1d6;
}

.district-subview {
  display: none;
  min-width: 0;
  overflow: hidden;
}

.district-subview.active {
  display: grid;
}

.people-view-tabs {
  display: flex;
  gap: 20px;
  margin: 2px 0 14px;
  border-bottom: 1px solid var(--line);
}

.people-view-tab {
  position: relative;
  min-height: 38px;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0 2px;
}

.people-view-tab.active {
  color: var(--blue-strong);
  font-weight: 700;
}

.people-view-tab.active::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  background: var(--blue);
  content: "";
}

.people-view-panel {
  display: none;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.people-view-panel.active {
  display: block;
}

.alliance-archive-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 7px 0;
}

.nav-tab {
  width: 100%;
  height: 40px;
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  text-align: left;
  padding: 0 12px;
}

.nav-tab span:first-child {
  text-align: center;
  font-weight: 700;
}

.nav-tab:hover,
.nav-tab.active {
  color: var(--text);
  background: #fff;
  border-color: var(--line);
  box-shadow: var(--shadow-soft);
}

.sidebar-note {
  margin-top: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.sidebar-note strong {
  display: block;
  margin-bottom: 4px;
}

.main {
  min-width: 0;
  padding: 28px min(3.2vw, 40px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.topbar h2 {
  font-size: 28px;
  font-weight: 760;
}

.top-actions,
.maintenance-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.icon-button,
.soft-button,
.primary-button,
.file-button {
  min-height: 36px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 0 12px;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.icon-button {
  width: 38px;
  padding: 0;
  font-size: 18px;
}

.primary-button {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

.icon-button:hover,
.soft-button:hover,
.file-button:hover {
  border-color: #d1d1d6;
  background: var(--panel-soft);
}

.primary-button:hover {
  background: var(--blue-strong);
  border-color: var(--blue-strong);
}

.danger {
  color: var(--red);
  border-color: #efc3c3;
}

.file-button {
  display: inline-grid;
  place-items: center;
  position: relative;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.status-strip,
.panel,
.metric-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-soft);
}

.status-strip {
  padding: 12px 14px;
  margin-bottom: 14px;
  color: var(--muted);
  background: var(--panel-soft);
  box-shadow: none;
}

.operations-cockpit {
  display: grid;
  grid-template-columns: minmax(280px, 0.95fr) minmax(420px, 1.05fr);
  gap: 18px;
  align-items: stretch;
  margin-bottom: 16px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.cockpit-lede {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
}

.cockpit-lede h3 {
  max-width: 560px;
  margin: 0;
  font-size: 28px;
  font-weight: 760;
  line-height: 1.2;
}

.cockpit-lede p:last-child {
  max-width: 520px;
  margin: 0;
  color: var(--muted);
}

.cockpit-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.ops-metric {
  display: grid;
  align-content: space-between;
  gap: 8px;
  min-height: 122px;
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.ops-metric span,
.ops-metric small {
  color: var(--muted);
  font-size: 12px;
}

.ops-metric strong {
  overflow: hidden;
  color: var(--text);
  font-size: 21px;
  font-weight: 760;
  line-height: 1.18;
  text-overflow: ellipsis;
}

.ops-metric.primary {
  border-color: #d7d7dd;
  background: #1d1d1f;
}

.ops-metric.primary span,
.ops-metric.primary small,
.ops-metric.primary strong {
  color: #fff;
}

.ops-metric.green {
  border-color: #caead7;
  background: var(--green-soft);
}

.ops-metric.amber {
  border-color: #f0dcc0;
  background: var(--amber-soft);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(136px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metric-card {
  padding: 14px;
  box-shadow: none;
  background: var(--panel-soft);
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric-card strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}

.dashboard-grid,
.activity-layout,
.accounts-layout,
.alliance-layout,
.district-layout,
.settings-grid {
  display: grid;
  gap: 14px;
}

.dashboard-grid {
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
}

.activity-layout {
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
}

.accounts-layout {
  grid-template-columns: minmax(260px, 0.42fr) minmax(0, 1fr);
}

.alliance-layout,
.district-layout,
.settings-grid {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.55fr);
}

.panel {
  padding: 16px;
  margin-bottom: 14px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-heading h3 {
  font-size: 16px;
  font-weight: 740;
}

.distribution-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.mini-chart {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: #fff;
}

.mini-chart h4 {
  margin: 0 0 8px;
  font-size: 13px;
}

.bar-row {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr) 30px;
  align-items: center;
  gap: 8px;
  margin: 7px 0;
}

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

.bar {
  height: 8px;
  border-radius: 6px;
  background: var(--line-soft);
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  background: var(--blue);
}

.issue-list,
.actions-list,
.history-list,
.dictionary-list,
.field-map {
  display: grid;
  gap: 9px;
}

.issue,
.action-item,
.history-item,
.dict-item,
.tree-login,
.alliance-card,
.field-row {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 10px;
  box-shadow: none;
}

a.alliance-card {
  display: block;
  color: inherit;
  text-decoration: none;
}

a.alliance-card:hover {
  border-color: #d1d1d6;
  background: #fbfbfd;
}

.issue.warning {
  border-color: #efd392;
  background: var(--amber-soft);
}

.issue.danger {
  border-color: #e0aaaa;
  background: var(--red-soft);
}

.action-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.action-bridge {
  border-color: var(--line);
  background: var(--blue-soft);
}

.activity-filter-stack {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.activity-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 0;
}

.activity-tab {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--muted);
  padding: 0 10px;
  font-size: 13px;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

.activity-tab.major {
  min-height: 34px;
  border-color: var(--line);
  background: var(--panel-soft);
  color: var(--text);
  padding: 0 13px;
  font-weight: 700;
}

.activity-tab.major.active,
.activity-tab.major:hover {
  border-color: var(--text);
  background: var(--text);
  color: #fff;
}

.panel-heading-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.activity-tab.active,
.activity-tab:hover {
  border-color: #d1d1d6;
  background: var(--panel-soft);
  color: var(--blue-strong);
}

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

.expert-layout {
  display: grid;
  grid-template-columns: minmax(420px, 1.05fr) minmax(360px, 0.95fr);
  gap: 14px;
}

.expert-layout .panel {
  min-width: 0;
}

.expert-table {
  min-width: 520px;
}

.activity-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 14px;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.activity-card:hover,
.activity-card.selected {
  border-color: #d1d1d6;
  background: #fff;
  box-shadow: var(--shadow-soft);
  transform: translateY(-1px);
}

.activity-card.selected {
  border-color: var(--text);
  box-shadow: inset 0 0 0 1px var(--text), var(--shadow-soft);
}

.activity-card h4 {
  margin: 10px 0 6px;
  font-size: 16px;
  font-weight: 740;
  line-height: 1.25;
}

.activity-card p {
  min-height: 42px;
  margin: 0;
  color: var(--muted);
}

.param-strip {
  display: grid;
  gap: 5px;
  margin-top: 9px;
}

.param-strip span {
  display: block;
  overflow: hidden;
  min-height: 24px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: #fbfbfd;
  color: #515154;
  padding: 3px 7px;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-card-top,
.activity-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.activity-meta {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.subpage-link,
.back-link,
.inline-link {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--blue-strong);
  background: var(--blue-soft);
  padding: 0 10px;
  text-decoration: none;
}

.inline-link {
  min-height: 28px;
  margin-top: 8px;
  font-size: 12px;
}

.person-ref {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--blue-strong);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.person-ref:hover {
  text-decoration: underline;
}

.activity-page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px;
}

.activity-page-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.activity-page h1 {
  margin: 0 0 6px;
  font-size: 28px;
  line-height: 1.2;
}

.joe-score-panel {
  overflow: hidden;
}

.joe-score-heading {
  align-items: center;
}

.joe-score-heading-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.joe-score-controls {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(220px, 300px);
  gap: 14px;
  margin: 14px 0 0;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.joe-bonus-control {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.joe-percent-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px;
  align-items: center;
  height: 38px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.joe-percent-input input {
  width: 100%;
  min-width: 0;
  height: 36px;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0 9px;
  outline: none;
}

.joe-percent-input b {
  color: var(--muted);
  font-weight: 600;
  text-align: center;
}

.joe-score-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 14px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.joe-score-summary > div {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 12px 14px;
  border-right: 1px solid var(--line);
}

.joe-score-summary > div:last-child {
  border-right: 0;
}

.joe-score-summary span,
.joe-score-summary small,
.joe-score-notes {
  color: var(--muted);
}

.joe-score-summary strong {
  font-size: 21px;
  line-height: 1.2;
}

.joe-score-notes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  padding: 10px 0;
  font-size: 12px;
}

.table-wrap.joe-score-table-wrap {
  max-height: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.joe-score-table {
  min-width: 780px;
}

.joe-score-table th:nth-child(1) {
  width: 86px;
}

.joe-score-table th:nth-child(2) {
  width: 118px;
}

.joe-score-table th:nth-child(3),
.joe-score-table th:nth-child(4) {
  width: 142px;
}

.joe-score-table td:nth-child(3),
.joe-score-table td:nth-child(4) {
  font-variant-numeric: tabular-nums;
}

.joe-score-table tr.joe-online-wave td {
  background: #fff9eb;
}

.joe-score-table tr.joe-headquarters-wave td {
  background: #eef6ff;
}

.joe-score-table tr.joe-missing-wave td {
  background: #fafbfd;
  color: var(--muted);
}

.joe-wave-kind,
.joe-record-state {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 12px;
  white-space: nowrap;
}

.joe-wave-kind {
  background: #eef2f6;
  color: #47586c;
}

.joe-record-state {
  border: 1px solid #b8d7c7;
  background: var(--green-soft);
  color: #17643f;
}

.joe-record-state.estimated {
  border-color: #efd392;
  background: var(--amber-soft);
  color: #875700;
}

.joe-record-state.missing {
  border-color: var(--line);
  background: #eef2f6;
  color: var(--muted);
}

.joe-source-bonus {
  display: inline-block;
  margin-left: 6px;
  color: var(--muted);
  font-size: 11px;
}

.joe-wave-note {
  display: inline;
  margin-left: 8px;
  color: var(--muted);
  font-size: 12px;
}

.joe-score-empty {
  margin-top: 14px;
}

.joe-rank-metrics {
  margin-bottom: 12px;
}

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

.joe-rank-snapshot {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 12px;
}

.joe-rank-snapshot-header,
.joe-rank-editor-settings {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.joe-rank-snapshot-header h4 {
  margin: 2px 0 0;
}

.joe-rank-note {
  margin: 10px 0;
  border-left: 3px solid var(--blue);
  background: var(--panel-soft);
  color: #515154;
  padding: 7px 9px;
  white-space: pre-wrap;
}

.joe-rank-table {
  min-width: 360px;
}

.quick-modal-card.joe-rank-editor-card {
  width: min(760px, 100%);
}

.joe-rank-editor-settings {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(150px, 0.55fr);
  margin-bottom: 14px;
}

.joe-rank-editor-settings label,
.joe-rank-editor-row label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.joe-rank-editor-settings .wide-field {
  grid-column: 1 / -1;
}

.joe-rank-editor-settings input,
.joe-rank-editor-settings select,
.joe-rank-editor-row input {
  width: 100%;
  min-width: 0;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  padding: 0 9px;
}

.joe-rank-editor-rows {
  display: grid;
  gap: 7px;
}

.joe-rank-editor-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(160px, 0.65fr) 38px;
  gap: 8px;
  align-items: end;
  border-bottom: 1px solid var(--line);
  padding-bottom: 7px;
}

.quick-modal-card.joe-score-editor-card {
  width: min(1080px, 100%);
  max-height: 92vh;
}

.joe-score-editor-settings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 260px));
  gap: 12px;
  margin-bottom: 14px;
}

.joe-score-editor-settings > label,
.joe-score-editor-row > label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.joe-score-editor-settings select,
.joe-score-editor-settings > label > input,
.joe-score-editor-row input,
.joe-score-editor-row select {
  width: 100%;
  min-width: 0;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  padding: 0 9px;
}

.joe-score-editor-rows {
  max-height: min(600px, 62vh);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.joe-editor-table-head,
.joe-score-editor-row {
  display: grid;
  grid-template-columns: 92px 150px 150px 126px minmax(220px, 1fr);
  gap: 8px;
  align-items: end;
  min-width: 850px;
  padding: 8px 10px;
}

.joe-editor-table-head {
  position: sticky;
  top: 0;
  z-index: 2;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: #fbfbfd;
  color: #515154;
  font-size: 12px;
  font-weight: 700;
}

.joe-score-editor-row {
  border-bottom: 1px solid var(--line);
}

.joe-score-editor-row:last-child {
  border-bottom: 0;
}

.joe-score-editor-row:hover {
  background: #f9fbfd;
}

.joe-score-editor-row > label > span {
  display: none;
}

.joe-editor-wave {
  display: grid;
  align-self: center;
}

.joe-editor-wave small,
.joe-expected-placeholder {
  color: var(--muted);
  font-size: 11px;
}

.joe-expected-placeholder {
  align-self: center;
  padding-left: 9px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(96px, 1fr));
  gap: 6px;
}

.calendar-weekday {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.calendar-cell {
  min-height: 116px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 7px;
}

.calendar-cell.empty {
  background: transparent;
  border-color: transparent;
}

.calendar-date {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

.calendar-event {
  display: grid;
  gap: 1px;
  margin: 4px 0;
  border-left: 3px solid var(--blue);
  border-radius: 5px;
  background: #eef6ff;
  padding: 5px 6px;
  color: inherit;
  text-decoration: none;
}

.calendar-event.projected {
  border-left-style: dashed;
  border-left-color: var(--amber);
  background: #fff7e6;
}

.calendar-event strong {
  font-size: 12px;
}

.calendar-event span {
  color: var(--muted);
  font-size: 11px;
}

.calendar-event-day {
  display: inline-block;
  margin-left: 6px;
  color: #236b65;
  font-size: 11px;
  font-weight: 750;
}

.calendar-event:hover {
  background: #e3f1ff;
}

.activity-timeline {
  display: grid;
  gap: 8px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 104px 120px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: var(--radius);
  background: #fff;
  padding: 9px 10px;
}

.timeline-item.projected {
  border-left-style: dashed;
  border-left-color: var(--amber);
  background: #fffaf0;
}

.timeline-item span,
.timeline-item p {
  color: var(--muted);
}

.timeline-item p {
  margin: 0;
}

.hall-item {
  grid-template-columns: 104px 100px minmax(0, 1fr) auto;
  align-items: center;
}

.hall-item.local-castle {
  border-left-color: #7b8da3;
}

.hall-item.invaded {
  border-left-color: var(--red);
  background: #fff7f7;
}

.invader-label {
  display: inline-block;
  margin-right: 5px;
  color: var(--red);
  font-weight: 800;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.template-row {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 10px;
}

.template-row span {
  color: var(--muted);
  font-size: 12px;
}

.template-row strong {
  font-weight: 600;
}

.record-grid,
.prep-grid,
.district-rank-grid,
.district-archive-metrics,
.district-alliance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.record-card,
.prep-card,
.district-rank-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 11px;
  color: inherit;
  text-decoration: none;
  box-shadow: none;
}

.district-rank-card.selected {
  border-color: var(--text);
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--text), var(--shadow-soft);
}

.rank-detail-button {
  display: inline-flex;
  align-items: center;
  margin-top: 10px;
}

.personnel-table {
  min-width: 980px;
}

.people-overview-toolbar {
  grid-template-columns: minmax(300px, 1fr) minmax(150px, 190px) auto;
  align-items: end;
}

.geocore-toolbar {
  grid-template-columns: minmax(300px, 1fr) minmax(150px, 190px);
  align-items: end;
}

.geocore-toolbar {
  align-items: center;
}

.geocore-toolbar > p {
  line-height: 1.55;
}

.filter-control {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.filter-control select {
  width: 100%;
  height: 38px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  padding: 0 9px;
  outline: none;
}

.filter-control select:focus,
.search-box:focus-within,
.toolbar select:focus,
.inline-select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.12);
}

.geocore-table {
  min-width: 1080px;
}

.geocore-table th:nth-child(1) {
  width: 64px;
}

.geocore-table th:nth-child(8) {
  width: 220px;
}

.geocore-nickname-cell {
  text-align: left;
}

.geocore-source-name {
  display: block;
  max-width: 260px;
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.geocore-match-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.geocore-unmatched-row {
  background: #fffaf0;
}

.geocore-resolved-row {
  background: #f7f8fa;
}

.personnel-table tbody tr {
  cursor: pointer;
}

.personnel-table tbody tr:hover {
  background: #fbfbfd;
}

.personnel-table td:first-child,
.personnel-table th:first-child {
  width: 140px;
}

.personnel-table .tag {
  margin: 2px 3px 2px 0;
}

.inline-select {
  min-width: 108px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 8px;
  background: #fff;
  color: var(--text);
}

.switch-line {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  color: var(--text);
}

.candidate-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) minmax(140px, 0.55fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.candidate-form label,
.match-search-label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.candidate-form input,
.match-search-label input {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  padding: 0 10px;
}

.candidate-form input[readonly] {
  background: #f4f7fa;
  color: #31445a;
  font-weight: 700;
}

.candidate-table {
  min-width: 960px;
}

.candidate-table tbody tr {
  cursor: default;
}

.candidate-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 265px;
}

.compact-button {
  min-height: 32px;
  white-space: nowrap;
}

.compact-icon {
  width: 32px;
  height: 32px;
  min-height: 32px;
  font-size: 17px;
}

.toggle-switch {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 112px;
  cursor: pointer;
  white-space: nowrap;
}

.toggle-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-track {
  position: relative;
  flex: 0 0 auto;
  width: 36px;
  height: 20px;
  border: 1px solid #afbdcc;
  border-radius: 999px;
  background: #dfe6ed;
  transition: background 140ms ease, border-color 140ms ease;
}

.toggle-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(24, 36, 51, 0.25);
  transition: transform 140ms ease;
}

.toggle-switch input:checked + .toggle-track {
  border-color: var(--green);
  background: var(--green);
}

.toggle-switch input:checked + .toggle-track::after {
  transform: translateX(16px);
}

.toggle-switch input:focus-visible + .toggle-track {
  outline: 3px solid rgba(47, 119, 199, 0.24);
  outline-offset: 2px;
}

.toggle-label {
  color: var(--muted);
  font-size: 12px;
}

.compact-toggle {
  min-width: 92px;
}

.unmatched-person-ref {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 0;
  border-bottom: 1px dashed var(--amber);
  background: transparent;
  color: #7b5508;
  padding: 0 0 1px;
  text-align: left;
}

.unmatched-person-ref small {
  border-radius: 999px;
  background: var(--amber-soft);
  color: var(--amber);
  padding: 1px 5px;
  font-size: 10px;
}

.resolved-person-ref {
  display: inline-grid;
  gap: 1px;
  border: 0;
  border-bottom: 1px dashed #a8b3bf;
  background: transparent;
  color: #566779;
  padding: 0 0 1px;
  text-align: left;
}

.resolved-person-ref.retired {
  border-bottom-color: #d99898;
  color: var(--red);
}

.resolved-person-ref small {
  max-width: 150px;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#openUnmatchedMatcher {
  white-space: nowrap;
}

#openUnmatchedMatcher.has-unmatched {
  border-color: #e2bf73;
  background: var(--amber-soft);
  color: #765000;
}

#unmatchedCountBadge {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  margin-left: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  font-size: 11px;
  font-weight: 700;
}

.empty-row {
  height: 72px;
  color: var(--muted);
  text-align: center !important;
  vertical-align: middle !important;
}

.district-alliance-card {
  min-height: 154px;
}

.detail-page {
  min-width: 320px;
}

.detail-shell {
  width: min(1180px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 24px 0 40px;
  display: grid;
  gap: 14px;
}

.alliance-profile-panel .panel-heading {
  align-items: start;
}

.district-rank-card dl {
  display: grid;
  gap: 6px;
  margin: 10px 0 0;
}

.district-rank-card dl div {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 8px;
}

.district-rank-card dt {
  color: var(--muted);
}

.district-rank-card dd {
  margin: 0;
}

.rank-summary {
  display: grid;
  gap: 9px;
}

.rank-summary-field {
  min-height: 42px;
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  padding: 3px 0;
  border-bottom: 1px solid #e6edf4;
}

.rank-summary-field > span {
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
}

.result-segmented {
  display: inline-flex;
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: 5px;
  overflow: hidden;
}

.result-segmented button,
.negotiated-button {
  min-width: 78px;
  min-height: 34px;
  border: 0;
  background: #fff;
  color: var(--muted);
  padding: 0 12px;
}

.result-segmented button + button {
  border-left: 1px solid var(--line);
}

.result-segmented button.active {
  background: var(--green-soft);
  color: #17643f;
  font-weight: 700;
}

.negotiated-button {
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: 5px;
}

.negotiated-button.active {
  border-color: #d5b35e;
  background: var(--amber-soft);
  color: #765000;
  font-weight: 700;
}

.rank-record-panel {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 10px;
}

.rank-record-panel h4 {
  margin: 0;
}

.prep-record-table {
  min-width: 1120px;
}

.rank-table-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.svs-rank-table {
  min-width: 1240px;
  table-layout: fixed;
}

.svs-rank-table .rank-col-final,
.svs-rank-table .rank-col-raw {
  width: 64px;
}

.svs-rank-table .rank-col-nickname {
  width: 118px;
}

.svs-rank-table .rank-col-current {
  width: 132px;
}

.svs-rank-table .rank-col-score {
  width: 100px;
}

.svs-rank-table .rank-col-alt-count {
  width: 58px;
}

.svs-rank-table .rank-col-alt {
  width: 144px;
}

.svs-rank-table .rank-col-tier {
  width: 72px;
}

.svs-rank-table .rank-col-lock {
  width: 96px;
}

.svs-rank-table .rank-col-note {
  width: 278px;
}

.svs-rank-table tbody tr {
  cursor: default;
}

.svs-rank-table td {
  overflow-wrap: anywhere;
}

.svs-rank-table .rank-name-cell {
  text-align: left;
}

.rank-alt-list {
  display: grid;
  gap: 5px;
}

.rank-alt-item {
  display: grid;
  gap: 1px;
  min-width: 0;
  border-left: 2px solid #cbd9e7;
  padding-left: 6px;
}

.rank-alt-item .person-ref,
.rank-alt-item .unmatched-person-ref,
.rank-alt-item .resolved-person-ref {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.rank-alt-item small {
  color: var(--muted);
  font-size: 11px;
}

.rank-alt-item.excluded {
  border-left-color: #d99898;
  opacity: 0.72;
}

.rank-alt-item.excluded small {
  color: var(--red);
}

.nickname-records {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.nickname-record {
  display: grid;
  gap: 1px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #f8fbfe;
  padding: 5px 8px;
}

.nickname-record small {
  color: var(--muted);
  font-size: 11px;
}

.alliance-tag-editor-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.alliance-tag-editor-list .tag {
  gap: 5px;
}

.alliance-tag-editor-list button {
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.72);
  color: inherit;
  padding: 0;
  line-height: 1;
}

.alliance-editor-row {
  display: grid;
  grid-template-columns: minmax(160px, 0.5fr) minmax(260px, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.alliance-editor-row label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.alliance-editor-row input {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 10px;
}

.rank-inline-select,
.rank-note-input {
  width: 100%;
  min-width: 0;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  padding: 0 7px;
}

.rank-lock-select.is-locked {
  border-color: #8bc6a6;
  background: var(--green-soft);
  color: #17643f;
  font-weight: 700;
}

.rank-note-input:focus,
.rank-inline-select:focus {
  border-color: #79aee5;
  outline: 3px solid rgba(47, 119, 199, 0.14);
}

#lockAllRankRows:disabled {
  cursor: default;
  border-color: #a9d3bb;
  background: var(--green-soft);
  color: #17643f;
  opacity: 1;
}

.record-card.focus {
  border-color: #95c7ab;
  background: #f1fbf5;
}

.record-card dl {
  display: grid;
  gap: 7px;
  margin: 10px 0 0;
}

.record-card dl div {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 8px;
}

.record-card dt {
  color: var(--muted);
}

.record-card dd {
  font-weight: 600;
}

.svs-layout {
  display: grid;
  gap: 16px;
}

.svs-layout > section > h4,
.raw-section > h4 {
  margin: 0 0 10px;
}

.raw-section {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.mechanism-layout {
  display: grid;
  gap: 14px;
}

.mechanism-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.green-block {
  border-color: #95c7ab;
  background: var(--green-soft);
}

.prep-card ul {
  margin: 0 0 10px;
  padding-left: 18px;
  color: var(--muted);
}

.activity-detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.detail-block {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 12px;
}

.detail-block.warning {
  border-color: #efd392;
  background: var(--amber-soft);
}

.detail-block.source {
  border-color: #cbd9e7;
  background: #fbfbfd;
}

.detail-block h4,
.activity-related h4 {
  margin: 0 0 7px;
}

.detail-block ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.detail-block li {
  margin: 3px 0;
}

.parameter-block dl {
  display: grid;
  gap: 7px;
  margin: 0;
}

.parameter-block div {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 8px;
}

.parameter-block dt {
  color: var(--muted);
}

.parameter-block dd {
  margin: 0;
  font-weight: 600;
}

.activity-related {
  margin-top: 12px;
}

.activity-related > div {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}

.mini-character {
  min-height: 54px;
  display: grid;
  gap: 2px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 8px 10px;
}

.mini-character span,
.field-row span {
  color: var(--muted);
  font-size: 12px;
}

.field-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.cycle-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.cycle-card {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 12px;
  box-shadow: none;
}

.cycle-order {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  background: var(--panel-soft);
  color: var(--text);
  font-weight: 700;
}

.cycle-card h4,
.record-card h4,
.prep-card h4 {
  margin: 0 0 5px;
}

.cycle-card p,
.record-card dd,
.prep-card p {
  margin: 0;
  color: var(--muted);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) repeat(4, minmax(130px, 160px)) 70px;
  gap: 8px;
  margin-bottom: 14px;
}

.search-box {
  height: 38px;
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 0 10px;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.search-box input,
.toolbar select {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 0 10px;
  min-width: 0;
  outline: none;
}

.search-box input {
  height: 34px;
  border: 0;
  outline: 0;
  padding: 0;
}

.tree-login h4 {
  margin: 0 0 8px;
  font-size: 13px;
}

.tree-server {
  margin: 8px 0 0;
  padding-left: 10px;
  border-left: 3px solid #d9e7f6;
}

.tree-character {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 6px 0;
  color: var(--muted);
}

.table-wrap {
  position: relative;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: auto;
  contain: inline-size;
  max-height: calc(100vh - 210px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

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

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line-soft);
  padding: 9px 8px;
  text-align: left;
  vertical-align: top;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fbfbfd;
  color: #515154;
  font-size: 12px;
}

.data-table tbody tr {
  cursor: pointer;
}

.data-table tbody tr:hover {
  background: #fbfbfd;
}

.compact-table {
  min-width: 760px;
}

.compact-table th,
.compact-table td {
  font-size: 12px;
  vertical-align: top;
}

.tag {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 24px;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 12px;
  background: var(--panel-soft);
  color: #515154;
}

.tag.green {
  background: var(--green-soft);
  color: var(--green);
}

.tag.amber {
  background: var(--amber-soft);
  color: var(--amber);
}

.tag.red {
  background: var(--red-soft);
  color: var(--red);
}

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

.alliance-card h4,
.history-item h4,
.dict-item h4,
.action-item h4,
.issue h4 {
  margin: 0 0 5px;
}

.muted,
.history-item p,
.dict-item p,
.action-item p,
.issue p,
.alliance-card p {
  margin: 0;
  color: var(--muted);
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(520px, 100vw);
  height: 100vh;
  transform: translateX(105%);
  transition: transform 160ms ease;
  background: #fff;
  border-left: 1px solid var(--line);
  box-shadow: -20px 0 48px rgba(25, 41, 60, 0.18);
  z-index: 10;
  display: none;
  flex-direction: column;
  visibility: hidden;
  pointer-events: none;
}

.drawer.open {
  display: flex;
  transform: translateX(0);
  visibility: visible;
  pointer-events: auto;
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.drawer-body {
  padding: 18px;
  overflow: auto;
}

.quick-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.quick-modal.open {
  display: flex;
}

.quick-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.32);
}

.quick-modal-card {
  position: relative;
  width: min(460px, 100%);
  max-height: min(720px, 90vh);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24);
  padding: 18px;
}

.quick-modal-card h3 {
  margin: 4px 0 14px;
}

.match-modal-card {
  width: min(620px, 100%);
}

.match-source {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 12px;
  border-left: 3px solid var(--amber);
  background: var(--amber-soft);
  padding: 8px 10px;
}

.match-source span {
  color: var(--muted);
  font-size: 12px;
}

.match-search-label {
  margin-bottom: 10px;
}

.match-results {
  display: grid;
  gap: 6px;
  min-height: 84px;
  max-height: 390px;
  overflow: auto;
}

.match-result {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, auto);
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  padding: 9px 10px;
  text-align: left;
}

.match-result:hover,
.match-result.selected {
  border-color: #8db9e8;
  background: #eff7ff;
}

.match-result > span {
  display: grid;
  min-width: 0;
}

.match-result > span:last-child {
  text-align: right;
}

.match-result small {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.match-empty {
  display: grid;
  place-items: center;
  min-height: 84px;
  color: var(--muted);
}

.match-actions {
  justify-content: flex-end;
}

.match-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.match-resolution-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.match-resolution-actions > span {
  margin-right: auto;
  color: var(--muted);
  font-size: 12px;
}

.match-resolution-actions button.active {
  border-color: var(--blue);
  background: #eff7ff;
  color: var(--blue-strong);
}

.match-resolution-actions button.danger.active {
  border-color: #d99898;
  background: var(--red-soft);
  color: var(--red);
}

.quick-modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.detail-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 14px;
}

.detail-table th,
.detail-table td {
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
  text-align: left;
}

.edit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.edit-grid label {
  display: grid;
  gap: 4px;
  color: var(--muted);
}

.edit-grid input,
.edit-grid select {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 10px;
}

.add-person-modal-card {
  width: min(680px, 100%);
}

.uid-editor-label {
  grid-column: 1 / -1;
}

.uid-editor-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.uid-editor-row input[readonly] {
  background: #f1f4f7;
  color: #566779;
}

.uid-lock-state {
  font-size: 11px;
}

.uid-lock-state.locked {
  color: var(--green);
}

.uid-lock-state.unlocked {
  color: var(--amber);
}

.drawer-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.summary-contract {
  min-height: 178px;
  overflow: auto;
  background: #152233;
  color: #dcecff;
  padding: 12px;
  border-radius: var(--radius);
}

.account-view-panel {
  display: none;
  min-width: 0;
}

.account-view-panel.active {
  display: block;
}

.panel-heading-actions,
.compact-actions,
.login-account-header,
.minor-rank-detail-header,
.minor-rank-entry-heading {
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-heading-actions,
.compact-actions {
  flex-wrap: wrap;
}

.login-account-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.login-account-card {
  min-width: 0;
  padding: 12px;
}

.login-account-header,
.minor-rank-detail-header,
.minor-rank-entry-heading {
  justify-content: space-between;
}

.login-account-header h4,
.login-account-header p,
.minor-rank-detail-header h4,
.minor-rank-comment p,
.minor-rank-entry-heading h4 {
  margin: 0;
}

.login-account-header p {
  color: var(--muted);
  font-size: 12px;
}

.login-character-list {
  display: grid;
  gap: 5px;
  margin-top: 10px;
  border-top: 1px solid var(--line);
  padding-top: 7px;
}

.login-character-list .tree-character {
  width: 100%;
  min-height: 48px;
  align-items: center;
  margin: 0;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  padding: 6px 7px;
  text-align: left;
}

.login-character-list .tree-character:hover {
  border-color: #c9ddf5;
  background: #f2f8ff;
}

.login-character-list .tree-character > span:first-child {
  display: grid;
  min-width: 0;
}

.login-character-list .tree-character small {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.login-unbound-card {
  border-color: #efd392;
  background: #fffaf0;
}

.personal-alt-table {
  min-width: 1120px;
}

.personal-alt-table tbody tr {
  cursor: pointer;
}

.remove-personal-alt {
  min-height: 30px;
  width: 32px;
}

.login-editor-card {
  width: min(600px, 100%);
}

.personal-alt-modal-card {
  width: min(760px, 100%);
}

.modal-section-divider {
  position: relative;
  margin: 18px 0 14px;
  border-top: 1px solid var(--line);
  text-align: center;
}

.modal-section-divider span {
  position: relative;
  top: -11px;
  background: #fff;
  color: var(--muted);
  padding: 0 10px;
  font-size: 12px;
}

.edit-grid textarea,
.alliance-activity-edit-block textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  padding: 8px 10px;
}

.wide-field {
  grid-column: 1 / -1;
}

.alliance-profile-edit-grid {
  max-width: 920px;
}

.alliance-edit-form h4 {
  margin-top: 0;
}

.alliance-activity-block,
.alliance-activity-edit-block {
  min-height: 126px;
}

.alliance-activity-block p {
  min-height: 44px;
}

.alliance-activity-edit-block label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.alliance-activity-edit-block input,
.alliance-activity-edit-block select {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 0 9px;
}

.activity-updated-at {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-size: 11px;
}

.alliance-edit-actions {
  justify-content: flex-end;
  margin: -2px 0 14px;
}

.minor-rank-toolbar {
  grid-template-columns: minmax(170px, 220px) minmax(130px, 160px) minmax(280px, 1fr);
}

.minor-rank-estimate {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f7fafc;
  padding: 0 11px;
}

.minor-rank-estimate span {
  color: var(--muted);
  font-size: 12px;
}

.minor-rank-layout {
  display: grid;
  grid-template-columns: minmax(620px, 1.2fr) minmax(340px, 0.8fr);
  gap: 12px;
  align-items: start;
}

.minor-rank-period-table {
  min-width: 920px;
}

.minor-rank-period-table tbody tr {
  cursor: pointer;
}

.minor-rank-period-table tbody tr:hover,
.minor-rank-period-table tbody tr.selected {
  background: #eff7ff;
}

.minor-rank-comment-cell {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.minor-rank-detail {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 12px;
}

.minor-rank-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.minor-rank-summary > div {
  border-left: 3px solid #c9ddf5;
  background: #f7fafc;
  padding: 7px 9px;
}

.minor-rank-summary dt,
.minor-rank-comment span {
  color: var(--muted);
  font-size: 11px;
}

.minor-rank-summary dd {
  margin: 2px 0 0;
  font-weight: 700;
}

.minor-rank-comment {
  margin-bottom: 12px;
  border-left: 3px solid var(--amber);
  background: var(--amber-soft);
  padding: 8px 10px;
}

.minor-rank-comment p {
  white-space: pre-wrap;
}

.minor-rank-result-table {
  min-width: 520px;
}

.inline-link-button {
  border: 0;
  background: transparent;
  color: var(--blue-strong);
  padding: 0;
  text-align: left;
  text-decoration: underline;
}

.empty-state {
  min-height: 220px;
  display: grid;
  place-content: center;
  color: var(--muted);
  text-align: center;
}

.empty-state h4 {
  margin: 0;
  color: var(--text);
}

.minor-rank-editor-card {
  width: min(940px, 100%);
}

.minor-rank-period-fields {
  margin-bottom: 16px;
}

.minor-rank-entry-heading {
  margin-bottom: 8px;
}

.minor-rank-editor-rows {
  display: grid;
  gap: 7px;
}

.minor-rank-editor-row {
  display: grid;
  grid-template-columns: 86px minmax(160px, 1fr) minmax(150px, 0.75fr) minmax(130px, 0.6fr) 38px;
  gap: 7px;
  align-items: end;
  border-bottom: 1px solid var(--line);
  padding-bottom: 7px;
}

.minor-rank-editor-row label {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 11px;
}

.minor-rank-editor-row input {
  width: 100%;
  min-width: 0;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 8px;
}

.activity-tag-manager-card {
  width: min(1080px, 100%);
}

.activity-tag-manager-heading,
.activity-tag-editor-head,
.activity-tag-editor-row {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(170px, 0.65fr) minmax(280px, 1.2fr) 88px;
  gap: 10px;
  align-items: center;
}

.activity-tag-manager-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.activity-tag-manager-heading h3 {
  margin-bottom: 0;
}

.activity-tag-manager-heading > span,
.activity-tag-editor-row small,
.activity-tag-editor-row label > span {
  color: var(--muted);
  font-size: 11px;
}

.activity-tag-editor-head {
  position: sticky;
  top: -18px;
  z-index: 2;
  border-bottom: 1px solid var(--line);
  background: #f7f9fc;
  color: var(--muted);
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 700;
}

.activity-tag-editor-list {
  display: grid;
  max-height: 54vh;
  overflow: auto;
}

.activity-tag-editor-row {
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
}

.activity-tag-editor-row:last-child {
  border-bottom: 0;
}

.activity-tag-editor-row > div,
.activity-tag-editor-row label {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.activity-tag-editor-row input {
  width: 100%;
  min-width: 0;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 0 8px;
}

.activity-tag-editor-row input:focus {
  border-color: var(--blue);
  outline: 2px solid rgba(47, 119, 199, 0.12);
}

.settings-wide-panel {
  grid-column: 1 / -1;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.reward-catalog-toolbar {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(170px, 220px);
  gap: 10px;
  margin-bottom: 12px;
  min-width: 0;
}

.reward-catalog-toolbar > * {
  min-width: 0;
  max-width: 100%;
}

.reward-catalog-wrap {
  max-height: min(520px, calc(100vh - 290px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.reward-catalog-table {
  min-width: 1120px;
}

.reward-catalog-table tbody tr {
  cursor: default;
}

.reward-catalog-table th:nth-child(1) {
  width: 200px;
}

.reward-catalog-table th:nth-child(2) {
  width: 110px;
}

.reward-catalog-table th:nth-child(3) {
  width: 220px;
}

.reward-catalog-table th:nth-child(4) {
  width: 300px;
}

.catalog-item-name {
  display: grid;
  gap: 3px;
}

.catalog-item-name small,
.catalog-signature {
  color: var(--muted);
  font-size: 12px;
}

.tag.blue {
  background: #e6f1fc;
  color: var(--blue-strong);
}

.compact-action {
  min-height: 32px;
  padding: 5px 10px;
}

.reward-item-editor-card {
  width: min(760px, 100%);
}

.reward-item-edit-grid .wide-field {
  grid-column: 1 / -1;
}

.reward-item-edit-grid textarea {
  width: 100%;
  min-height: 68px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  font: inherit;
}

.reward-item-edit-grid input[readonly] {
  background: #f1f4f7;
  color: #566779;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  pointer-events: none;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: #1b2b3c;
  color: #fff;
  box-shadow: var(--shadow);
  transition: opacity 150ms ease, transform 150ms ease;
  z-index: 20;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 1020px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-tabs {
    grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  }

  .nav-group {
    min-width: 0;
  }

  .district-side-nav,
  .national-side-nav,
  .library-side-nav {
    margin: 3px 0 0;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
  }

  .district-side-link {
    text-align: center;
  }

  .nav-tab {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    height: auto;
    min-height: 48px;
  }

  .nav-tab span:last-child {
    font-size: 12px;
  }

  .metric-grid,
  .operations-cockpit,
  .dashboard-grid,
  .activity-layout,
  .expert-layout,
  .accounts-layout,
  .login-account-grid,
  .minor-rank-layout,
  .alliance-layout,
  .district-layout,
  .settings-grid,
  .cycle-grid,
  .mechanism-grid {
    grid-template-columns: 1fr;
  }

  .settings-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .minor-rank-toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .minor-rank-estimate {
    grid-column: 1 / -1;
  }

  .reward-catalog-toolbar {
    grid-template-columns: minmax(0, 1fr) minmax(170px, 220px);
  }

  .calendar-grid {
    grid-template-columns: repeat(7, minmax(72px, 1fr));
    overflow-x: auto;
  }
}

@media (max-width: 620px) {
  .main {
    padding: 14px;
  }

  .topbar,
  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .metric-grid,
  .distribution-grid,
  .toolbar,
  .cockpit-metrics,
  .activity-detail-grid,
  .template-grid {
    grid-template-columns: 1fr;
  }

  .operations-cockpit {
    padding: 16px;
  }

  .cockpit-lede h3 {
    font-size: 23px;
  }

  .minor-rank-toolbar,
  .minor-rank-summary,
  .minor-rank-editor-row,
  .activity-tag-editor-row {
    grid-template-columns: 1fr;
  }

  .activity-tag-editor-head {
    display: none;
  }

  .activity-tag-editor-row {
    gap: 8px;
    padding: 12px 4px;
  }

  .activity-tag-editor-row .soft-button {
    justify-self: start;
  }

  .activity-tag-manager-heading,
  .panel-heading-actions {
    width: 100%;
    align-items: flex-start;
  }

  .minor-rank-estimate {
    grid-column: auto;
    align-items: flex-start;
    flex-direction: column;
    padding: 8px 10px;
  }

  .login-account-header,
  .minor-rank-detail-header,
  .minor-rank-entry-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .minor-rank-editor-row .icon-button {
    justify-self: end;
  }

  .reward-catalog-toolbar,
  .reward-item-edit-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .reward-item-edit-grid .wide-field {
    grid-column: auto;
  }

  .timeline-item,
  .hall-item {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .calendar-grid {
    grid-template-columns: 1fr;
  }

  .calendar-weekday,
  .calendar-cell.empty {
    display: none;
  }

  .activity-page {
    padding: 14px;
  }

  .activity-page-hero {
    flex-direction: column;
  }

  .joe-score-controls,
  .joe-score-summary {
    grid-template-columns: 1fr;
  }

  .joe-score-heading-actions {
    width: 100%;
    justify-content: space-between;
  }

  .joe-score-editor-settings {
    grid-template-columns: 1fr;
  }

  .joe-rank-snapshots,
  .joe-rank-editor-settings,
  .joe-rank-editor-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .joe-rank-editor-row .icon-button {
    justify-self: end;
  }

  .joe-score-summary > div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .joe-score-summary > div:last-child {
    border-bottom: 0;
  }

  .edit-grid {
    grid-template-columns: 1fr;
  }

  .candidate-form,
  .match-result,
  .alliance-editor-row {
    grid-template-columns: 1fr;
  }

  .rank-summary-field {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .match-result > span:last-child {
    text-align: left;
  }
}

/* National registry and Frostdragon qualification archives */
.national-subview {
  display: none;
  min-width: 0;
  overflow: hidden;
}

.national-subview.active {
  display: grid;
}

.library-subview {
  display: none;
  min-width: 0;
}

.library-subview.active {
  display: grid;
}

.reference-library-panel {
  max-width: 1080px;
}

.login-channel-fieldset {
  min-width: 0;
  margin: 0;
  padding: 10px 12px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.login-channel-fieldset legend {
  padding: 0 5px;
  color: var(--muted);
  font-size: 12px;
}

.login-channel-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.login-channel-options label {
  display: flex;
  min-height: 34px;
  align-items: center;
  gap: 7px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
}

.login-channel-options input {
  width: 16px;
  height: 16px;
  margin: 0;
}

.frostdragon-participant-icon {
  display: inline-grid;
  width: 20px;
  height: 20px;
  margin-right: 5px;
  place-items: center;
  border: 1px solid #cda146;
  border-radius: 50%;
  background: #fff7df;
  color: #7c5611;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  vertical-align: middle;
}

.joe-rank-editor-row [data-joe-rank-uid] {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

@media (max-width: 640px) {
  .login-channel-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.national-heading,
.national-range-filter,
.frostdragon-archive-heading,
.frostdragon-archive-toolbar {
  align-items: flex-end;
}

.national-range-filter,
.frostdragon-archive-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.national-range-separator {
  align-self: center;
  color: var(--muted);
  padding-bottom: 8px;
}

.national-alliance-search,
.national-server-search {
  width: min(320px, 100%);
}

.national-filter-panel .district-archive-metrics,
.frostdragon-archive-panel .district-archive-metrics {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.district-alliance-grid:has(.national-alliance-table-wrap) {
  display: block;
}

.national-alliance-table {
  min-width: 920px;
  table-layout: fixed;
}

.national-alliance-table td {
  vertical-align: middle;
}

.national-alliance-table th:nth-child(1) { width: 9%; }
.national-alliance-table th:nth-child(2) { width: 23%; }
.national-alliance-table th:nth-child(3) { width: 12%; }
.national-alliance-table th:nth-child(4) { width: 13%; }
.national-alliance-table th:nth-child(5) { width: 13%; }
.national-alliance-table th:nth-child(6) { width: 11%; }
.national-alliance-table th:nth-child(7) { width: 19%; }

.district-alliance-table th:nth-child(1) { width: 28%; }
.district-alliance-table th:nth-child(2) { width: 13%; }
.district-alliance-table th:nth-child(3) { width: 14%; }
.district-alliance-table th:nth-child(4) { width: 14%; }
.district-alliance-table th:nth-child(5) { width: 11%; }
.district-alliance-table th:nth-child(6) { width: 20%; }

.national-alliance-table .table-sort-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.national-alliance-table .table-sort-button i {
  color: #9aa2a9;
  font-size: 12px;
  font-style: normal;
}

.national-alliance-table .table-sort-button.active,
.national-alliance-table .table-sort-button.active i {
  color: var(--blue-strong);
}

.national-alliance-table td small,
.glory-road-cell small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  white-space: nowrap;
}

.national-alliance-link {
  display: flex;
  width: 100%;
  min-width: 0;
  color: var(--text);
}

.national-alliance-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.positive-value {
  color: var(--green);
  font-weight: 700;
}

.negative-value {
  color: var(--red);
  font-weight: 700;
}

.glory-road-cell strong {
  display: inline-block;
  margin-right: 8px;
  color: #865d0f;
}

.glory-road-display {
  display: grid;
  gap: 4px;
}

.glory-road-display strong {
  color: #865d0f;
  font-size: 24px;
}

.glory-road-display span {
  color: var(--muted);
}

.glory-road-block {
  border-top: 3px solid #d6a328;
  background: #fffbef;
}

.glory-road-editor {
  gap: 12px;
  border-top: 3px solid #d6a328;
  background: #fffbef;
}

.glory-road-inputs {
  display: grid;
  grid-template-columns: repeat(3, minmax(76px, 1fr));
  gap: 8px;
}

.glory-road-inputs label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.glory-road-level-preview {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 1px solid #ead79e;
}

.glory-road-level-preview strong {
  color: #865d0f;
  font-size: 22px;
}

.alliance-ranking-history {
  min-width: 720px;
}

.frostdragon-archive-panel {
  gap: 16px;
}

.frostdragon-section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.frostdragon-section-heading h4 {
  margin: 0 0 4px;
  font-size: 16px;
}

.frostdragon-section-heading span {
  color: var(--muted);
  font-size: 13px;
}

.frostdragon-snapshot-heading {
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.frostdragon-archive-toolbar .filter-control select {
  min-width: 150px;
}

.frostdragon-rule-note {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(300px, 1.4fr);
  gap: 8px 18px;
  border-left: 3px solid var(--amber);
  background: var(--amber-soft);
}

.frostdragon-rule-note span,
.frostdragon-rule-note small {
  color: var(--muted);
}

.frostdragon-rule-note small {
  grid-column: 1 / -1;
}

.frostdragon-ranking-table,
.frostdragon-server-table,
.frostdragon-comparison-table,
.frostdragon-battle-table {
  min-width: 850px;
}

.frostdragon-battle-table td small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  white-space: nowrap;
}

.national-heading-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: min(460px, 100%);
}

.national-people-search {
  width: min(360px, 100%);
}

.national-people-table {
  min-width: 980px;
}

.national-people-table th:first-child,
.national-people-table td:first-child {
  width: 76px;
  min-width: 76px;
  padding-left: 8px;
  padding-right: 8px;
  white-space: nowrap;
}

.fallback-warning,
.pending-warning {
  display: block;
  margin-top: 3px;
  color: var(--amber) !important;
  font-size: 11px;
  font-weight: 700;
}

.server-strength-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.server-strength-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-left: 5px solid #8796a8;
  border-radius: var(--radius);
  background: #fff;
}

.server-strength-card.strong-server {
  border-color: #5ca57f;
  border-left-width: 7px;
  box-shadow: inset 0 0 0 1px #b8ddca;
}

.server-strength-card > header {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: #f7f9fc;
  padding: 10px 12px;
}

.server-strength-card > header h4,
.server-strength-card > header p {
  margin: 0;
}

.server-strength-card > header h4 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 18px;
}

.server-strength-card > header p {
  color: var(--muted);
  font-size: 12px;
}

.server-rank {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #e8edf3;
  color: #3d4d60;
  font-weight: 800;
}

.strong-server-tag {
  border: 1px solid #8ac4a6;
  background: #e4f5ec;
  color: #176e49;
}

.server-strength-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(118px, 1fr));
  border-bottom: 1px solid var(--line);
}

.server-strength-metrics > div {
  display: grid;
  align-content: start;
  gap: 2px;
  min-height: 80px;
  border-right: 1px solid var(--line);
  padding: 10px 12px;
}

.server-strength-metrics > div:last-child {
  border-right: 0;
}

.server-strength-metrics span,
.server-strength-metrics small {
  color: var(--muted);
  font-size: 11px;
}

.server-strength-metrics strong {
  font-size: 18px;
}

.server-alliance-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1px;
  background: var(--line);
}

.server-alliance-link {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  min-height: 42px;
  background: #fff;
  color: var(--text);
  padding: 7px 10px;
  text-decoration: none;
}

.server-alliance-link:hover {
  background: #f1f7fd;
}

.server-alliance-link span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.server-alliance-link small {
  color: var(--muted);
  white-space: nowrap;
}

.server-profile-editor-card,
.alliance-create-editor-card,
.add-person-modal-card {
  width: min(760px, 100%);
}

.editor-toggle {
  margin-bottom: 14px;
}

.migration-status-control {
  display: grid;
  align-content: start;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.migration-status-control .toggle-switch {
  min-height: 38px;
  color: var(--text);
}

.detail-floating-close {
  position: fixed;
  top: 18px;
  right: max(20px, calc((100vw - 1180px) / 2 - 58px));
  z-index: 30;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid #b8c6d5;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.96);
  color: #304156;
  box-shadow: 0 7px 20px rgba(42, 64, 89, 0.18);
  font-size: 25px;
  line-height: 1;
}

.detail-floating-close:hover {
  border-color: var(--blue);
  color: var(--blue-strong);
}

.activity-tag-catalog {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.activity-tag-catalog > section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafc;
  padding: 10px;
}

.activity-tag-catalog h4 {
  margin: 0 0 8px;
}

.managed-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 35px;
}

.managed-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 2px 4px 2px 8px;
}

.managed-tag small {
  color: var(--green);
  font-weight: 700;
}

.managed-tag .icon-button {
  width: 26px;
  height: 26px;
  min-height: 26px;
  font-size: 13px;
}

.tag-create-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
  margin-top: 9px;
}

.tag-create-row input,
.activity-tag-editor-row select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 0 8px;
}

.tag-create-row input,
.activity-tag-editor-row select:not([multiple]) {
  height: 36px;
}

.activity-tag-editor-row select[multiple] {
  min-height: 76px;
  padding: 5px 7px;
}

.tag-create-row input:focus,
.activity-tag-editor-row select:focus {
  border-color: var(--blue);
  outline: 2px solid rgba(47, 119, 199, 0.12);
}

.activity-relationship-block li {
  display: grid;
  gap: 2px;
}

.activity-relationship-block li + li {
  margin-top: 7px;
}

.activity-relationship-block li span {
  color: var(--muted);
  font-size: 12px;
}

.calendar-cell {
  overflow: hidden;
}

.calendar-event strong {
  overflow-wrap: anywhere;
}

.calendar-event.calendar-lock {
  border-left: 5px solid var(--red);
  background: var(--red-soft);
  color: #7f2424;
  box-shadow: inset 0 0 0 1px #efc1c1;
}

.calendar-event.calendar-lock strong {
  font-weight: 850;
}

.calendar-event.calendar-warning {
  border-left-color: var(--amber);
  background: var(--amber-soft);
  color: #704900;
}

.calendar-event.calendar-no_score {
  border-left-color: #7b8796;
  background: #edf0f3;
  color: #4b5868;
}

.calendar-event.calendar-reward_claim {
  border-left-color: var(--green);
  background: var(--green-soft);
}

.calendar-event.calendar-minor_rank {
  border-left-color: #7653a6;
  background: #f1ebf8;
}

.calendar-event.calendar-regular:not(.calendar-lock):not(.calendar-reward_claim) {
  border-left-color: #7b8796;
  background: #f3f5f7;
}

.calendar-regular-toggle {
  min-width: 0;
}

@media (max-width: 1180px) {
  .detail-floating-close {
    top: 10px;
    right: 10px;
  }

  .server-strength-metrics {
    grid-template-columns: repeat(3, minmax(130px, 1fr));
  }

  .server-strength-metrics > div:nth-child(3) {
    border-right: 0;
  }

  .server-strength-metrics > div:nth-child(n + 4) {
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 760px) {
  .national-heading,
  .frostdragon-archive-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .national-range-filter,
  .frostdragon-archive-toolbar {
    align-items: stretch;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .national-range-separator {
    display: none;
  }

  .national-range-filter .soft-button {
    align-self: end;
  }

  .frostdragon-rule-note {
    grid-template-columns: 1fr;
  }

  .frostdragon-rule-note small {
    grid-column: auto;
  }

  .frostdragon-archive-toolbar .filter-control {
    display: grid;
    gap: 5px;
  }

  .frostdragon-archive-toolbar .filter-control select {
    width: 100%;
    min-width: 0;
  }

  .national-filter-panel .district-archive-metrics,
  .frostdragon-archive-panel .district-archive-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .national-heading-actions,
  .national-people-search {
    width: 100%;
    min-width: 0;
  }

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

  .server-strength-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .server-strength-metrics > div,
  .server-strength-metrics > div:nth-child(3) {
    border-right: 1px solid var(--line);
    border-top: 1px solid var(--line);
  }

  .server-strength-metrics > div:nth-child(odd) {
    border-right: 1px solid var(--line);
  }

  .server-strength-metrics > div:nth-child(even) {
    border-right: 0;
  }

  .server-strength-metrics > div:nth-child(-n + 2) {
    border-top: 0;
  }

  .server-strength-card > header {
    grid-template-columns: 36px minmax(0, 1fr);
  }

  .server-strength-card > header .soft-button {
    grid-column: 2;
    justify-self: start;
  }

  .activity-tag-catalog {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .server-strength-metrics,
  .server-alliance-list {
    grid-template-columns: 1fr;
  }

  .server-strength-metrics > div,
  .server-strength-metrics > div:nth-child(odd),
  .server-strength-metrics > div:nth-child(even) {
    border-right: 0;
    border-top: 1px solid var(--line);
  }

  .server-strength-metrics > div:first-child {
    border-top: 0;
  }

  .server-alliance-link {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .server-alliance-link small {
    grid-column: 2;
  }
}

/* District map and fortress management */

.district-side-link[href] {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.fortress-active .activity-page {
  max-width: 1540px;
}

.fortress-management {
  display: grid;
  gap: 14px;
}

.fortress-management[hidden] {
  display: none;
}

.fortress-section-tabs {
  position: sticky;
  top: 8px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.96);
  padding: 5px;
  box-shadow: 0 8px 22px rgba(39, 59, 77, 0.08);
}

.fortress-section-tabs button {
  flex: 0 0 auto;
  min-height: 36px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  padding: 0 13px;
  font-weight: 700;
  cursor: pointer;
}

.fortress-section-tabs button:hover {
  background: #f0f5f7;
  color: var(--text);
}

.fortress-section-tabs button.active,
.fortress-section-tabs button[aria-selected="true"] {
  background: #255f80;
  color: #fff;
}

.fortress-period-toolbar,
.reward-list-toolbar,
.reward-list-create-form,
.reward-member-form,
.map-controls {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.fortress-period-toolbar {
  margin-top: 14px;
}

.fortress-period-toolbar .filter-control,
.reward-list-toolbar .filter-control,
.map-controls .filter-control {
  grid-template-columns: 1fr;
  gap: 3px;
}

.fortress-period-select-control,
.reward-list-select-control {
  min-width: min(360px, 100%);
}

.fortress-status-flow {
  display: grid;
  grid-template-columns: repeat(7, minmax(70px, 1fr));
  gap: 2px;
  margin-top: 16px;
}

.status-step {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-bottom: 2px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.status-step i {
  display: grid;
  place-items: center;
  width: 21px;
  height: 21px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  font-style: normal;
}

.status-step.done {
  border-color: #2b7770;
  color: #1e625d;
  font-weight: 700;
}

.status-step.done i {
  border-color: #2b7770;
  background: #e4f4f1;
}

.inline-notice {
  display: grid;
  grid-template-columns: minmax(170px, auto) minmax(260px, 1fr) auto;
  align-items: center;
  gap: 16px;
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.inline-notice > div {
  display: grid;
  gap: 2px;
}

.inline-notice span {
  color: var(--muted);
  font-size: 12px;
}

.recommendation-warnings {
  margin-top: 12px;
  border-left: 3px solid #c47b32;
  background: #fff8ed;
  padding: 10px 12px;
  color: #72491f;
}

.recommendation-warnings.clear {
  border-left-color: #2b7770;
  background: #eef8f6;
  color: #1f625d;
}

.recommendation-warnings strong,
.recommendation-warnings span {
  display: block;
}

.recommendation-warnings ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

.recommendation-warnings li + li {
  margin-top: 4px;
}

.fortress-allocation-table {
  --fortress-col-building: 94px;
  --fortress-col-reward: 118px;
  --fortress-col-previous: 84px;
  --fortress-col-recommendation: 104px;
  --fortress-col-planned: 116px;
  min-width: 1330px;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.fortress-allocation-table th:nth-child(1),
.fortress-allocation-table td:nth-child(1) {
  width: var(--fortress-col-building);
  min-width: var(--fortress-col-building);
  max-width: var(--fortress-col-building);
  left: 0;
}

.fortress-allocation-table th:nth-child(2),
.fortress-allocation-table td:nth-child(2) {
  width: var(--fortress-col-reward);
  min-width: var(--fortress-col-reward);
  max-width: var(--fortress-col-reward);
  left: var(--fortress-col-building);
}

.fortress-allocation-table th:nth-child(3),
.fortress-allocation-table td:nth-child(3) {
  width: var(--fortress-col-previous);
  min-width: var(--fortress-col-previous);
  max-width: var(--fortress-col-previous);
  left: calc(var(--fortress-col-building) + var(--fortress-col-reward));
}

.fortress-allocation-table th:nth-child(4),
.fortress-allocation-table td:nth-child(4) {
  width: var(--fortress-col-recommendation);
  min-width: var(--fortress-col-recommendation);
  max-width: var(--fortress-col-recommendation);
  left: calc(var(--fortress-col-building) + var(--fortress-col-reward) + var(--fortress-col-previous));
}

.fortress-allocation-table th:nth-child(5),
.fortress-allocation-table td:nth-child(5) {
  width: var(--fortress-col-planned);
  min-width: var(--fortress-col-planned);
  max-width: var(--fortress-col-planned);
  left: calc(var(--fortress-col-building) + var(--fortress-col-reward) + var(--fortress-col-previous) + var(--fortress-col-recommendation));
  border-right: 2px solid #c9d5de;
}

.fortress-allocation-table th:nth-child(-n+5),
.fortress-allocation-table td:nth-child(-n+5) {
  position: sticky;
}

.fortress-allocation-table thead th:nth-child(-n+5) {
  z-index: 7;
  background: #f1f7fa;
}

.fortress-allocation-table tbody td:nth-child(-n+5) {
  z-index: 3;
  background: #fff;
}

.fortress-allocation-table tbody tr:hover td:nth-child(-n+5) {
  background: #f7fbff;
}

.fortress-allocation-table th:nth-child(6),
.fortress-allocation-table td:nth-child(6) {
  width: 150px;
  max-width: 150px;
}

.fortress-allocation-table th:nth-child(7),
.fortress-allocation-table td:nth-child(7) {
  width: 90px;
}

.fortress-allocation-table th:nth-child(8),
.fortress-allocation-table td:nth-child(8) {
  width: 192px;
}

.fortress-allocation-table th:nth-child(9),
.fortress-allocation-table td:nth-child(9) {
  width: 98px;
}

.fortress-allocation-table th:nth-child(10),
.fortress-allocation-table td:nth-child(10) {
  width: 116px;
}

.fortress-allocation-table th:nth-child(11),
.fortress-allocation-table td:nth-child(11) {
  width: 168px;
}

.fortress-allocation-table td:first-child small,
.allocation-reason small,
.reward-balance-item small,
.setting-tile small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.fortress-allocation-table select,
.fortress-allocation-table input,
.reward-member-table select,
.reward-member-table input,
.reward-list-create-form input,
.reward-list-create-form select,
.reward-member-form input,
.reward-member-form select,
.setting-tile select {
  width: 100%;
  min-width: 112px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--text);
  padding: 0 7px;
}

.fortress-allocation-table select,
.fortress-allocation-table input {
  min-width: 0;
}

.fortress-allocation-table input[data-allocation-people] {
  min-width: 0;
}

.allocation-reward {
  color: #365365;
  font-weight: 700;
  line-height: 1.25;
}

.allocation-reward .reward-name,
.allocation-reward .reward-quantity {
  display: block;
}

.allocation-reward .reward-name {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
}

.allocation-reward .reward-quantity {
  margin-top: 4px;
  color: #617786;
  font-size: 11px;
}

.allocation-alliance-cell {
  overflow: hidden;
}

.allocation-alliance-cell .tag {
  font-weight: 700;
}

.allocation-alliance-cell small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.allocation-alliance-cell.changed {
  background: #fff8ed;
  box-shadow: inset 3px 0 #c47b32;
}

.fortress-allocation-table tbody td.allocation-alliance-cell.changed {
  background: #fff8ed;
}

.allocation-alliance-cell.changed small {
  color: #8a571d;
}

.allocation-alliance-cell.planned.changed select {
  border-color: #d59b56;
  background: #fff8ed;
  color: #70471b;
  font-weight: 700;
}

.responsibility-editor {
  display: grid;
  grid-template-columns: minmax(105px, 1fr) 72px;
  gap: 6px;
  min-width: 0;
}

.responsibility-editor select {
  min-width: 0;
}

.responsibility-exempt {
  display: grid;
  gap: 2px;
  min-width: 0;
  color: #315e55;
}

.responsibility-exempt small {
  color: var(--muted);
  font-size: 11px;
}

.fortress-allocation-table input[data-allocation-field="note"] {
  min-width: 0;
}

.allocation-reason strong,
.allocation-reason small {
  display: block;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.allocation-reason {
  cursor: help;
}

.fortress-allocation-table select:disabled,
.fortress-allocation-table input:disabled {
  border-color: transparent;
  background: transparent;
  color: var(--text);
  opacity: 1;
}

.fortress-season-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  margin: 4px 0 14px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.fortress-season-metrics > div {
  display: grid;
  gap: 3px;
  padding: 11px 14px;
  border-right: 1px solid var(--line);
}

.fortress-season-metrics > div:last-child {
  border-right: 0;
}

.fortress-season-metrics span,
.season-period-head small,
.season-period-head span,
.fortress-season-table tbody th small,
.season-allocation-cell span,
.season-allocation-cell small {
  color: var(--muted);
  font-size: 11px;
}

.fortress-season-table {
  min-width: 1440px;
}

.fortress-season-table th:first-child {
  position: sticky;
  left: 0;
  z-index: 3;
  min-width: 116px;
  background: #f7fafb;
}

.fortress-season-table tbody th {
  text-align: left;
}

.fortress-season-table tbody th small {
  display: block;
  margin-top: 3px;
}

.season-period-head,
.season-allocation-cell {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
  text-align: left;
  cursor: pointer;
}

.season-period-head {
  display: grid;
  gap: 2px;
  min-width: 130px;
}

.season-allocation-cell {
  display: grid;
  gap: 3px;
  min-width: 130px;
  min-height: 60px;
  border-left: 3px solid transparent;
  padding: 7px 8px;
}

.season-allocation-cell:hover,
.season-allocation-cell.active {
  background: #eef5f8;
}

.season-allocation-cell.active {
  border-left-color: #255f80;
}

.season-allocation-cell strong {
  color: var(--alliance-color, var(--text));
}

.season-allocation-cell small {
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.allocation-reason {
  max-width: 230px;
}

.allocation-reason small {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fortress-settings-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.setting-tile {
  min-height: 78px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-right: 1px solid var(--line);
}

.setting-tile:last-child {
  border-right: 0;
}

.recommendation-setting {
  display: grid;
  grid-template-columns: 1fr;
  align-content: center;
  gap: 5px;
}

.recommendation-setting small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-derived-setting {
  background: #f7f9fb;
}

.calendar-derived-setting.active {
  background: #eef8f3;
}

.calendar-signal-dot {
  flex: 0 0 auto;
  width: 11px;
  height: 11px;
  border: 2px solid #8b97a5;
  border-radius: 50%;
  background: #fff;
}

.calendar-derived-setting.active .calendar-signal-dot {
  border-color: #287267;
  background: #287267;
  box-shadow: 0 0 0 4px rgba(40, 114, 103, 0.12);
}

.calendar-derived-setting > span {
  display: grid;
  gap: 3px;
}

.calendar-derived-setting strong {
  color: var(--text);
}

.setting-tile > span:not(:only-child),
.setting-tile > span:first-child {
  color: var(--muted);
  font-size: 12px;
}

.toggle-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toggle-control input {
  width: 18px;
  height: 18px;
  accent-color: #2b7770;
}

.reward-list-toolbar {
  margin: 8px 0 14px;
}

.reward-list-create-form,
.reward-member-form {
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.reward-member-form[hidden] {
  display: none !important;
}

.reward-list-create-form label,
.reward-member-form label {
  display: grid;
  gap: 4px;
  min-width: 220px;
  color: var(--muted);
  font-size: 12px;
}

.reward-tier-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.reward-list-source-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.reward-tier-metrics > div,
.reward-list-source-summary > div {
  display: grid;
  gap: 3px;
  padding: 11px 14px;
  border-right: 1px solid var(--line);
}

.reward-tier-metrics > div:last-child,
.reward-list-source-summary > div:last-child {
  border-right: 0;
}

.reward-tier-metrics span,
.reward-list-source-summary span {
  color: var(--muted);
  font-size: 11px;
}

.reward-member-wrap {
  max-height: none;
  overflow: visible;
  contain: none;
}

.reward-link-summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 14px 0 8px;
  color: #365365;
}

.reward-link-summary span {
  color: var(--muted);
  font-size: 12px;
}

.reward-tier-columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.reward-tier-column {
  min-width: 0;
  border-right: 1px solid var(--line);
  background: #fff;
}

.reward-tier-column:last-child {
  border-right: 0;
}

.reward-tier-column > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  border-bottom: 1px solid var(--line);
  background: #eef3f6;
  padding: 9px 13px;
}

.reward-tier-column h4 {
  margin: 0;
  font-size: 15px;
}

.reward-tier-column header span {
  color: var(--muted);
  font-size: 12px;
}

.reward-tier-names {
  display: grid;
  align-content: start;
  min-height: 160px;
}

.reward-tier-person {
  position: relative;
  min-width: 0;
  border-bottom: 1px solid #edf0f2;
  padding: 9px 12px;
}

.reward-tier-person:last-child {
  border-bottom: 0;
}

.reward-tier-person.high-power {
  background: #fff8e8;
  box-shadow: inset 4px 0 #c78a2e;
}

.reward-tier-person.unlinked {
  background: #fff5f3;
  box-shadow: inset 4px 0 #c35b4f;
}

.reward-person-name {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.reward-person-link {
  min-width: 0;
  overflow: hidden;
  color: #254f68;
  font-weight: 700;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: normal;
}

span.person-name,
.person-name > .person-name-label {
  display: inline;
  margin: 0;
  color: inherit;
  font: inherit;
  white-space: normal;
  overflow-wrap: anywhere;
}

span.person-furnace {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin: 0 0 0 4px;
  vertical-align: baseline;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0;
  color: #5c6971;
}

span.person-furnace-fire {
  color: #b34b16;
}

.person-furnace > span {
  margin: 0;
  color: inherit;
  font: inherit;
}

.person-furnace .lucide-flame {
  flex: 0 0 12px;
  width: 12px;
  height: 12px;
  align-self: center;
}

.reward-person-link:hover {
  text-decoration: underline;
}

.reward-person-link.unresolved {
  color: #944a40;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}

.high-power-mark {
  flex: 0 0 auto;
  color: #8a5b18;
  font-size: 11px;
  font-weight: 700;
}

.reward-person-controls {
  display: grid;
  grid-template-columns: 30px minmax(76px, 92px) minmax(70px, 1fr) 30px;
  gap: 6px;
  margin-top: 7px;
}

.reward-drag-handle {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #f7f9fa;
  color: #657985;
  cursor: grab;
  font: 700 13px/1 system-ui, sans-serif;
  letter-spacing: 0;
}

.reward-drag-handle:hover {
  border-color: #7d9ca9;
  background: #eef3f5;
  color: #2f6673;
}

.reward-drag-handle:active {
  cursor: grabbing;
}

.reward-tier-person.dragging {
  opacity: 0.42;
}

.reward-tier-person.drop-before::before,
.reward-tier-person.drop-after::after {
  position: absolute;
  right: 8px;
  left: 8px;
  z-index: 2;
  height: 3px;
  border-radius: 2px;
  background: #238078;
  content: "";
  pointer-events: none;
}

.reward-tier-person.drop-before::before {
  top: -2px;
}

.reward-tier-person.drop-after::after {
  bottom: -2px;
}

.reward-person-controls select,
.reward-person-controls input {
  width: 100%;
  min-width: 0;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  padding: 0 6px;
  font-size: 12px;
}

.reward-tier-empty {
  padding: 18px 12px;
}

.compact-icon {
  width: 30px;
  min-height: 30px;
  height: 30px;
}

.reward-balance-heading {
  margin-top: 18px;
}

.reward-balance-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  border-top: 1px solid var(--line);
}

.reward-balance-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 10px;
  padding: 12px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.reward-balance-item strong {
  color: #1e625d;
  font-size: 18px;
}

.reward-balance-item small {
  grid-column: 1 / -1;
}

.reward-balance-item.over strong {
  color: var(--red);
}

.announcement-editor {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfdff;
  color: var(--text);
  padding: 14px;
  font: 13px/1.75 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.announcement-history-heading {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.announcement-structure {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 12px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #f7fafb;
}

.announcement-structure > div {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 10px 12px;
  border-right: 1px solid var(--line);
}

.announcement-structure > div:last-child {
  border-right: 0;
}

.announcement-structure span {
  color: var(--muted);
  font-size: 11px;
}

.announcement-structure strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.announcement-version-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
}

.announcement-version-card.selected {
  border-color: #568397;
  box-shadow: inset 3px 0 #568397;
}

.announcement-version {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 52px;
  width: 100%;
  border: 0;
  border-radius: 0;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
  text-align: left;
  cursor: pointer;
}

.announcement-version:hover {
  background: #f5fafc;
}

.announcement-version > span:first-child {
  display: grid;
  gap: 2px;
}

.announcement-version small {
  color: var(--muted);
}

.announcement-version-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--line);
}

.announcement-version-actions button {
  min-height: 32px;
  border: 0;
  border-right: 1px solid var(--line);
  background: #fff;
  color: #456275;
  cursor: pointer;
}

.announcement-version-actions button:last-child {
  border-right: 0;
  color: #9a4b43;
}

.announcement-version-actions button:hover {
  background: #f5fafc;
}

.announcement-deleted-note {
  grid-column: 1 / -1;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.fortress-rules-heading {
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}

.fortress-rules-heading h3 {
  margin-top: 2px;
}

.fortress-rules-content {
  display: grid;
}

.fortress-rule-band {
  display: grid;
  grid-template-columns: minmax(190px, 250px) minmax(0, 1fr);
  gap: 28px;
  border-bottom: 1px solid var(--line);
  padding: 22px 0;
}

.fortress-rule-band:last-child {
  border-bottom: 0;
  padding-bottom: 2px;
}

.fortress-rule-band > header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.fortress-rule-band > header > span {
  color: #2d6f68;
  font-size: 12px;
  font-weight: 800;
}

.fortress-rule-band h4,
.fortress-rule-band p {
  margin: 0;
}

.fortress-rule-band h4 {
  font-size: 17px;
}

.fortress-rule-band p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.fortress-rule-band > ul {
  margin: 0;
  padding-left: 19px;
  color: #334957;
  line-height: 1.65;
}

.fortress-rule-band > ul li + li {
  margin-top: 6px;
}

.fortress-workflow-list {
  display: grid;
  grid-template-columns: repeat(7, minmax(112px, 1fr));
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.fortress-workflow-list li {
  position: relative;
  display: grid;
  align-content: start;
  gap: 5px;
  min-height: 92px;
  border-top: 3px solid #6b8d9f;
  padding: 12px 10px 8px 0;
}

.fortress-workflow-list li:not(:last-child)::after {
  content: "";
  position: absolute;
  top: -5px;
  right: 7px;
  width: 7px;
  height: 7px;
  border-top: 2px solid #6b8d9f;
  border-right: 2px solid #6b8d9f;
  transform: rotate(45deg);
}

.fortress-workflow-list strong {
  font-size: 13px;
}

.fortress-workflow-list span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.fortress-live-rules {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0;
  border-top: 1px solid var(--line);
}

.fortress-live-rules > div {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr);
  gap: 10px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 11px 12px;
}

.fortress-live-rules > div:nth-child(2n) {
  border-right: 0;
}

.fortress-live-rules dt {
  color: var(--muted);
}

.fortress-live-rules dd {
  margin: 0;
  color: #294957;
  font-weight: 650;
}

.fortress-image-dialog {
  width: min(1180px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  border: 1px solid #aeb8c2;
  border-radius: 7px;
  background: #fff;
  padding: 0;
  box-shadow: 0 24px 70px rgba(29, 42, 55, 0.28);
}

.fortress-image-dialog::backdrop {
  background: rgba(20, 31, 43, 0.62);
}

.image-dialog-header,
.image-dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
}

.image-dialog-header {
  border-bottom: 1px solid var(--line);
}

.image-dialog-header h3,
.image-dialog-header p {
  margin: 0;
}

.fortress-image-preview-wrap {
  max-height: calc(100vh - 190px);
  overflow: auto;
  background: #edf1f4;
  padding: 16px;
}

.fortress-image-preview-wrap img {
  display: block;
  width: min(100%, 900px);
  height: auto;
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 4px 16px rgba(29, 42, 55, 0.18);
}

.image-dialog-actions {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
}

.image-dialog-actions .muted {
  margin-right: auto;
}

.map-shell {
  width: min(1400px, calc(100vw - 28px));
}

.map-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.map-hero h1 {
  margin: 0 0 6px;
  letter-spacing: 0;
}

.map-toolbar-heading {
  align-items: end;
}

.map-search-control {
  min-width: min(270px, 100%);
}

.map-search-control input {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--text);
  padding: 0 9px;
}

.map-search-status {
  min-height: 22px;
  color: var(--muted);
  font-size: 12px;
}

.district-map-layout {
  display: grid;
  grid-template-columns: minmax(480px, 1fr) minmax(230px, 300px);
  gap: 22px;
  align-items: start;
}

.map-stage-scroll {
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-gutter: stable;
}

.district-map-stage {
  position: relative;
  width: min(100%, 860px);
  aspect-ratio: 1;
  margin: 0 auto;
  overflow: hidden;
}

.district-map-stage canvas,
.district-map-points {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.map-point {
  position: absolute;
  z-index: 2;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #c8533f;
  color: #fff;
  box-shadow: 0 3px 10px rgba(36, 56, 72, 0.28);
  padding: 0;
  font-size: 11px;
  line-height: 1;
}

.map-point.stronghold {
  width: 42px;
  height: 42px;
  border-radius: 6px;
  background: #2b7770;
}

.map-point.anchor {
  width: 46px;
  height: 28px;
  border-radius: 5px;
  background: #775a29;
}

.map-point small {
  position: absolute;
  top: calc(100% + 3px);
  left: 50%;
  transform: translateX(-50%);
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--alliance-color, rgba(24, 36, 51, 0.86));
  color: #fff;
  font-size: 9px;
  white-space: nowrap;
}

.map-point:hover,
.map-point.selected {
  z-index: 4;
  outline: 3px solid rgba(217, 150, 42, 0.48);
  outline-offset: 2px;
}

.map-point.layer-final,
.map-point.layer-manual,
.map-point.layer-recommended {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--alliance-color) 72%, transparent), 0 3px 10px rgba(36, 56, 72, 0.28);
}

.map-inspector {
  min-height: 260px;
  margin-top: 28px;
  border-left: 2px solid var(--line);
  padding: 4px 0 4px 18px;
}

.map-inspector h3 {
  margin: 4px 0 14px;
}

.map-detail-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.map-detail-list > div {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 8px;
}

.map-detail-list dt {
  color: var(--muted);
}

.map-detail-list dd {
  margin: 0;
  font-weight: 700;
}

.map-point-note {
  margin-top: 14px;
  color: var(--muted);
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.map-legend > span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.legend-shape {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #c8533f;
}

.legend-shape.stronghold {
  border-radius: 2px;
  background: #2b7770;
}

.legend-shape.anchor {
  width: 16px;
  border-radius: 2px;
  background: #775a29;
}

.legend-shape.station {
  border-radius: 1px;
  background: repeating-linear-gradient(135deg, #8b99a3 0 3px, #d9e0e4 3px 6px);
}

.alliance-map-tag {
  border-color: color-mix(in srgb, var(--alliance-color) 55%, #ffffff);
  background: color-mix(in srgb, var(--alliance-color) 13%, #ffffff);
  color: var(--alliance-color);
}

.coordinate-vertices {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--line);
}

.coordinate-vertices > div {
  display: grid;
  gap: 3px;
  padding: 12px 16px;
  border-right: 1px solid var(--line);
}

.coordinate-vertices > div:last-child {
  border-right: 0;
}

.coordinate-vertices span {
  color: var(--muted);
  font-size: 11px;
}

@media (max-width: 960px) {
  .district-map-layout {
    grid-template-columns: 1fr;
  }

  .map-inspector {
    min-height: 0;
    margin-top: 0;
    border-top: 1px solid var(--line);
    border-left: 0;
    padding: 14px 0 0;
  }

  .fortress-settings-grid,
  .reward-balance-grid,
  .announcement-structure {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }

  .announcement-structure > div:nth-child(2) {
    border-right: 0;
  }

  .fortress-season-metrics {
    grid-template-columns: repeat(2, minmax(130px, 1fr));
  }

  .fortress-season-metrics > div:nth-child(2) {
    border-right: 0;
  }

  .fortress-settings-grid .setting-tile:nth-child(2),
  .fortress-settings-grid .setting-tile:nth-child(4) {
    border-right: 0;
  }

  .fortress-rule-band {
    grid-template-columns: 170px minmax(0, 1fr);
    gap: 20px;
  }

  .fortress-workflow-list {
    grid-template-columns: repeat(4, minmax(110px, 1fr));
  }
}

@media (max-width: 620px) {
  .map-shell {
    width: calc(100vw - 28px);
    min-width: 0;
    max-width: calc(100vw - 28px);
  }

  .map-shell > *,
  .map-workspace-panel,
  .map-toolbar-heading,
  .map-controls,
  .district-map-layout,
  .map-stage-scroll {
    min-width: 0;
    max-width: 100%;
  }

  .map-workspace-panel {
    overflow: hidden;
  }

  .map-toolbar-heading,
  .map-controls {
    align-items: stretch;
  }

  .map-controls .filter-control,
  .map-controls select {
    width: 100%;
    min-width: 0;
  }

  .fortress-status-flow {
    grid-template-columns: repeat(4, 1fr);
  }

  .inline-notice,
  .fortress-season-metrics,
  .reward-tier-metrics,
  .reward-list-source-summary,
    .coordinate-vertices,
    .fortress-settings-grid,
    .reward-balance-grid,
    .announcement-structure {
    grid-template-columns: 1fr;
  }

  .setting-tile,
  .fortress-season-metrics > div,
  .reward-tier-metrics > div,
  .reward-list-source-summary > div,
    .coordinate-vertices > div,
    .reward-balance-item,
    .announcement-structure > div {
    border-right: 0;
  }

  .fortress-allocation-table tbody td:nth-child(n+2):nth-child(-n+5) {
    position: static;
  }

  .fortress-allocation-table thead th:nth-child(n+2):nth-child(-n+5) {
    left: auto;
  }

  .reward-link-summary,
  .image-dialog-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .fortress-announcement-panel > .panel-heading .rank-table-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .fortress-announcement-panel > .panel-heading .rank-table-actions button {
    width: 100%;
  }

  .reward-tier-columns,
  .fortress-live-rules {
    grid-template-columns: 1fr;
  }

  .reward-tier-column {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .reward-tier-column:last-child {
    border-bottom: 0;
  }

  .reward-tier-names {
    min-height: 0;
  }

  .fortress-rule-band {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .fortress-workflow-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .fortress-live-rules > div {
    border-right: 0;
  }

  .image-dialog-actions .muted {
    margin-right: 0;
  }

  .fortress-image-preview-wrap {
    padding: 8px;
  }

  .map-hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .fortress-section-tabs {
    top: 4px;
  }

  .fortress-section-tabs button {
    padding: 0 10px;
  }

  .map-controls,
  .map-search-control {
    width: 100%;
  }

  .district-map-layout {
    display: block;
  }

  .district-map-stage {
    width: 500px;
    min-width: 500px;
    margin: 0;
  }

  .map-point {
    width: 27px;
    height: 27px;
    font-size: 10px;
  }

  .map-point.stronghold {
    width: 34px;
    height: 34px;
  }
}
