:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #111418;
  color: #e8edf2;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

[hidden] {
  display: none !important;
}

button {
  border: 1px solid #3a4652;
  border-radius: 6px;
  background: #1c2530;
  color: #eef4fa;
  cursor: pointer;
  font: inherit;
  min-height: 36px;
  padding: 0 12px;
}

button:hover {
  background: #263342;
}

.app {
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px;
}

.login-screen {
  align-items: center;
  display: flex;
  min-height: 100vh;
  justify-content: center;
  padding: 24px;
}

.login-panel {
  border: 1px solid #2b3540;
  border-radius: 8px;
  background: #151a20;
  display: grid;
  gap: 16px;
  max-width: 380px;
  padding: 22px;
  width: 100%;
}

.login-panel label {
  display: grid;
  gap: 6px;
}

.login-panel input {
  border: 1px solid #3a4652;
  border-radius: 6px;
  background: #10151b;
  color: #eef4fa;
  font: inherit;
  min-height: 40px;
  padding: 8px 10px;
}

.login-status {
  color: #ffb4a8;
  min-height: 20px;
}

.auth-user {
  align-self: center;
  color: #a9b6c3;
  font-size: 13px;
  min-height: 24px;
  padding: 4px 0;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  font-size: 16px;
}

p,
.muted {
  color: #9caab8;
  font-size: 14px;
  line-height: 1.4;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.item-actions {
  align-items: flex-start;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-start;
}

.item-actions button {
  min-height: 28px;
  padding: 0 8px;
  white-space: nowrap;
}

.item-qty-input {
  border: 1px solid #33404d;
  border-radius: 6px;
  background: #10151b;
  color: #eef4fa;
  font: inherit;
  height: 28px;
  min-height: 28px;
  width: 68px;
  padding: 0 7px;
}

.actions select {
  max-width: 170px;
  min-width: 120px;
}

.grid {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(420px, 1fr);
  gap: 16px;
}

.panel {
  border: 1px solid #2b3540;
  border-radius: 8px;
  background: #151a20;
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #2b3540;
  padding: 12px 14px;
}

.panel-head-actions {
  align-items: center;
  display: flex;
  gap: 8px;
}

.icon-button {
  align-items: center;
  display: inline-flex;
  justify-content: center;
  min-height: 28px;
  min-width: 32px;
  padding: 0;
}

.profile-list,
.session-list,
.party-list {
  display: grid;
  gap: 8px;
  max-height: 58vh;
  overflow: auto;
  padding: 12px;
}

.row {
  border: 1px solid #2b3540;
  border-radius: 6px;
  background: #10151b;
  padding: 10px;
}

.row.selected {
  border-color: #58a6ff;
}

.party-summary {
  border: 1px solid #2b3540;
  border-radius: 6px;
  background: #10151b;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
}

.party-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.party-summary div {
  display: grid;
  gap: 3px;
}

.party-summary span {
  color: #a9b6c3;
  font-size: 12px;
}

.party-member {
  text-align: left;
}

.party-member.ready {
  border-color: #2e8b57;
}

.row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.name {
  font-weight: 700;
}

.status {
  border-radius: 999px;
  background: #253040;
  color: #b9c7d6;
  font-size: 12px;
  padding: 3px 8px;
  white-space: nowrap;
}

.status.blocked_protocol {
  background: #493a1c;
  color: #ffd991;
}

.status.server_switch_failed {
  background: #4a2525;
  color: #ffb4a8;
}

.status.stopped {
  background: #30343a;
}

.status.online {
  background: #163823;
  color: #96e8b3;
}

.meta {
  color: #a9b6c3;
  display: grid;
  gap: 3px;
  font-size: 13px;
  line-height: 1.35;
}

.session-row {
  display: grid;
  gap: 8px;
}

.session-compact {
  color: #a9b6c3;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
}

.session-compact span {
  border: 1px solid #303c48;
  border-radius: 5px;
  background: #151d26;
  min-height: 24px;
  padding: 4px 6px;
}

.session-compact .warn-chip {
  border-color: #5d342e;
  background: #2b1c1c;
  color: #ffb4a8;
}

.basic-info {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 9px 0 10px;
}

.info-pill {
  align-items: baseline;
  border: 1px solid #33404d;
  border-radius: 6px;
  background: #17202a;
  display: inline-flex;
  gap: 5px;
  min-height: 28px;
  padding: 5px 7px;
}

.info-label {
  color: #91a2b3;
  font-size: 11px;
  text-transform: uppercase;
}

.info-value {
  color: #eef4fa;
  font-size: 13px;
  font-weight: 650;
}

.live-panel {
  margin-top: 16px;
}

.account-config-panel {
  margin-bottom: 16px;
}

.account-config-panel.collapsed .panel-head {
  border-bottom: 0;
}

.account-config {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.account-config-section {
  display: grid;
  gap: 8px;
}

.party-config-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(140px, 1fr) minmax(140px, 1fr) 90px 90px;
}

.party-config-grid label,
.party-member-config-row label {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.party-member-config {
  display: grid;
  gap: 8px;
}

.party-member-config-row {
  align-items: end;
  border: 1px solid #2b3540;
  border-radius: 6px;
  background: #10151b;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(180px, 1fr) auto auto auto;
  padding: 10px;
}

.account-config-row {
  align-items: end;
  border: 1px solid #2b3540;
  border-radius: 6px;
  background: #10151b;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(140px, 1fr) 90px minmax(160px, 1fr) minmax(160px, 1fr) auto;
  padding: 10px;
}

.account-config-row label {
  display: grid;
  gap: 5px;
}

.account-config-row span,
.party-config-grid span,
.party-member-config-row span {
  color: #91a2b3;
  font-size: 12px;
}

.account-config-row input,
.account-config-row select,
.party-config-grid input,
.party-member-config-row input {
  border: 1px solid #3a4652;
  border-radius: 6px;
  background: #151d26;
  color: #eef4fa;
  font: inherit;
  min-height: 36px;
  min-width: 0;
  padding: 6px 8px;
}

.live-state {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.25fr) minmax(240px, 0.85fr);
  gap: 12px;
  padding: 12px;
}

.state-column {
  border: 1px solid #2b3540;
  border-radius: 6px;
  background: #10151b;
  min-width: 0;
  padding: 10px;
}

.split-column {
  display: grid;
  gap: 10px;
}

.subsection {
  border-top: 1px solid #27313c;
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
}

.section-title {
  color: #91a2b3;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.character-hero {
  display: grid;
  gap: 10px;
}

.character-name {
  color: #f3f7fb;
  font-size: 20px;
  font-weight: 750;
  line-height: 1.15;
}

.character-stack {
  display: grid;
  gap: 7px;
}

.character-field {
  display: grid;
  grid-template-columns: minmax(86px, 112px) 1fr;
  gap: 10px;
  align-items: baseline;
}

.character-field-label {
  color: #91a2b3;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.character-field-value {
  color: #eef4fa;
  font-size: 13px;
  font-weight: 650;
  min-width: 0;
  word-break: break-word;
}

.vitals {
  display: grid;
  gap: 9px;
}

.bar-row {
  display: grid;
  gap: 5px;
}

.bar-label {
  color: #a9b6c3;
  display: flex;
  font-size: 12px;
  justify-content: space-between;
}

.bar-track {
  background: #202a35;
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

.bar-track span {
  background: #44b678;
  display: block;
  height: 100%;
  min-width: 0;
}

.hp-bar .bar-track span {
  background: #e05252;
}

.sp-bar .bar-track span {
  background: #4b8df0;
}

.data-table {
  border-collapse: collapse;
  font-size: 13px;
  width: 100%;
}

.data-table-wrap {
  max-height: 460px;
  overflow: auto;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid #27313c;
  padding: 7px 6px;
  text-align: left;
  vertical-align: top;
}

.data-table th {
  background: #101821;
  color: #91a2b3;
  font-size: 11px;
  font-weight: 700;
  position: sticky;
  top: 0;
  text-transform: uppercase;
  z-index: 1;
}

.data-table td {
  color: #e3ebf3;
}

.section-count {
  color: #91a2b3;
  font-size: 12px;
  font-weight: 700;
}

.kv-grid {
  display: grid;
  grid-template-columns: minmax(48px, auto) 1fr;
  gap: 7px 10px;
  font-size: 13px;
}

.kv-grid span {
  color: #91a2b3;
}

.kv-grid strong {
  color: #eef4fa;
}

.pet-panel {
  display: grid;
  gap: 10px;
}

.pet-roster {
  display: grid;
  gap: 7px;
}

.pet-count {
  color: #91a2b3;
  font-size: 12px;
  line-height: 1.3;
}

.pet-row {
  align-items: center;
  border: 1px solid #27313c;
  border-radius: 6px;
  background: #121922;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px 9px;
  min-height: 58px;
  padding: 8px;
}

.pet-row.active {
  border-color: #44b678;
  background: #111d18;
}

.pet-row-main {
  min-width: 0;
}

.pet-row-side {
  align-items: flex-end;
  display: grid;
  gap: 6px;
  justify-items: end;
}

.pet-row-side button {
  min-height: 28px;
  padding: 0 8px;
}

.pet-warning {
  color: #f3ba62;
  font-size: 12px;
  grid-column: 1 / -1;
}

.pet-detail {
  border: 1px solid #27313c;
  border-radius: 6px;
  background: #121922;
  display: grid;
  gap: 8px;
  padding: 9px;
}

.pet-head {
  align-items: flex-start;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.pet-name {
  color: #f3f7fb;
  font-size: 15px;
  font-weight: 750;
  line-height: 1.2;
}

.pet-subtitle,
.pet-meta {
  color: #91a2b3;
  font-size: 12px;
  line-height: 1.35;
}

.pet-status {
  border-radius: 999px;
  background: #30343a;
  color: #b9c7d6;
  flex: 0 0 auto;
  font-size: 11px;
  padding: 3px 7px;
  white-space: nowrap;
}

.pet-status.active {
  background: #163823;
  color: #96e8b3;
}

.pet-actions {
  display: flex;
  gap: 6px;
}

.pet-actions button {
  min-height: 30px;
  padding: 0 9px;
}

.pet-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.pet-stats {
  border-top: 1px solid #27313c;
  padding-top: 8px;
}

.empty-state {
  align-items: center;
  border: 1px dashed #33404d;
  border-radius: 6px;
  color: #91a2b3;
  display: flex;
  min-height: 96px;
  padding: 12px;
}

.empty-state.compact {
  min-height: 56px;
}

.logs-panel {
  margin-top: 16px;
}

.tool-panel {
  margin-top: 16px;
}

.tool-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 12px;
}

.tool-grid label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.tool-grid label span {
  color: #91a2b3;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

textarea,
input {
  border: 1px solid #33404d;
  border-radius: 6px;
  background: #10151b;
  color: #eef4fa;
  font: inherit;
}

textarea {
  min-height: 180px;
  padding: 10px;
  resize: vertical;
}

input {
  min-height: 36px;
  padding: 0 10px;
}

select {
  border: 1px solid #33404d;
  border-radius: 6px;
  background: #10151b;
  color: #eef4fa;
  font: inherit;
  min-height: 36px;
  min-width: 0;
  padding: 0 9px;
}

.battle-plan-panel {
  margin-top: 16px;
}

.training-panel {
  border-top: 1px solid #27313c;
  display: grid;
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
}

.training-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.training-head .section-title {
  margin-bottom: 0;
}

.training-state {
  border-radius: 999px;
  background: #30343a;
  color: #b9c7d6;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  text-transform: uppercase;
}

.training-state.running {
  background: #163823;
  color: #96e8b3;
}

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

.training-status-card {
  border: 1px solid #303c48;
  border-radius: 6px;
  background: #121922;
  display: grid;
  gap: 5px;
  min-height: 58px;
  min-width: 0;
  padding: 8px;
}

.training-status-card span {
  color: #91a2b3;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.training-status-card strong {
  color: #eef4fa;
  font-size: 13px;
  line-height: 1.25;
  min-width: 0;
  overflow-wrap: anywhere;
}

.training-data {
  border: 1px solid #2b3540;
  border-radius: 6px;
  background: #111820;
  display: grid;
  gap: 8px;
  padding: 9px;
}

.training-data-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.training-data-head span {
  color: #91a2b3;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.training-data-head strong {
  border-radius: 999px;
  background: #263342;
  color: #c8d6e4;
  font-size: 11px;
  padding: 3px 8px;
  text-transform: uppercase;
}

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

.training-metrics div {
  border: 1px solid #303c48;
  border-radius: 6px;
  background: #151f29;
  display: grid;
  gap: 4px;
  min-height: 54px;
  padding: 8px;
}

.training-metrics span {
  color: #91a2b3;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.training-metrics strong {
  color: #eef4fa;
  font-size: 14px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.training-control-panel {
  border: 1px solid #27313c;
  border-radius: 6px;
  background: #10161d;
  display: grid;
  gap: 10px;
  padding: 9px;
}

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

.training-move-field {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.training-move-field input {
  box-sizing: border-box;
  min-width: 0;
  width: 100%;
}

.training-actions button {
  min-width: 0;
  white-space: nowrap;
}

.training-test-packet {
  display: contents;
}

.training-test-packet.open {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.training-test-packet.open .training-packet-status {
  grid-column: 1 / -1;
}

.training-debug-toggle {
  opacity: 0.72;
}

.training-test-packet.open .training-debug-toggle {
  grid-column: 1 / -1;
  justify-self: start;
}

.training-map-field {
  min-width: 86px;
}

.training-map-select {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.training-map-picker {
  border: 1px solid #27313c;
  border-radius: 6px;
  background: #0d141b;
  display: grid;
  grid-column: 1 / -1;
  gap: 8px;
  padding: 8px;
}

.training-map-select select {
  width: 100%;
}

.training-map-picker button,
.training-map-select input {
  min-width: 0;
  width: 100%;
}

.training-map-picker button {
  white-space: nowrap;
}

.training-map-status {
  border-radius: 6px;
  color: #d8e1ea;
  font-size: 12px;
  line-height: 1.35;
  padding: 7px 8px;
}

.training-map-status.info {
  background: #122338;
  color: #b9d8ff;
}

.training-map-status.warn {
  background: #332412;
  color: #ffd08a;
}

.training-move-field span,
.training-map-select span {
  color: #91a2b3;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.training-spot {
  display: grid;
  gap: 6px;
}

.training-spot span {
  color: #91a2b3;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

@media (max-width: 720px) {
  .training-status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

.battle-plan-body {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.skill-filter {
  display: grid;
  gap: 6px;
  max-width: 360px;
}

.skill-filter span {
  color: #91a2b3;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.battle-plan {
  display: grid;
  gap: 8px;
}

.battle-plan-mode {
  display: flex;
}

.battle-plan-mode label {
  display: grid;
  gap: 6px;
  min-width: 220px;
}

.battle-plan-mode span {
  color: #91a2b3;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.battle-plan-defaults {
  border-bottom: 1px solid #27313c;
  display: grid;
  gap: 8px;
  padding-bottom: 10px;
}

.battle-plan-row {
  align-items: center;
  display: grid;
  grid-template-columns: 72px minmax(170px, 1fr) minmax(150px, 0.7fr) minmax(170px, 1fr) minmax(150px, 0.7fr);
  gap: 8px;
}

.battle-plan-defaults .battle-plan-row {
  grid-template-columns: 96px minmax(180px, 1fr) minmax(170px, 0.8fr);
}

.battle-plan-head {
  color: #91a2b3;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.tool-actions {
  align-items: center;
  border-top: 1px solid #2b3540;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
}

.tool-actions input {
  flex: 1;
  min-width: 180px;
}

pre {
  font-size: 12px;
  line-height: 1.45;
  margin: 0;
  min-height: 180px;
  max-height: 26vh;
  overflow: auto;
  padding: 12px 14px;
  white-space: pre-wrap;
  word-break: break-word;
  color: #d7e1eb;
}

@media (max-width: 900px) {
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .actions {
    justify-content: flex-start;
  }

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

  .live-state {
    grid-template-columns: 1fr;
  }

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

  .tool-actions input {
    flex-basis: 100%;
    min-width: 0;
  }

  .tool-actions button {
    flex: 1 1 120px;
  }

  .battle-plan-row,
  .battle-plan-defaults .battle-plan-row {
    grid-template-columns: 1fr;
  }

  .account-config-row {
    grid-template-columns: 1fr;
  }

  .party-config-grid,
  .party-member-config-row {
    grid-template-columns: 1fr;
  }

  .training-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .training-map-select {
    grid-column: 1 / -1;
  }
}
