:root {
  color-scheme: light;
  --page: #474c66;
  --frame: #f9fafc;
  --sidebar: #ffffff;
  --ink: #1f203b;
  --muted: #7c8194;
  --line: #edf0f5;
  --soft: #f4f6fa;
  --navy: #3d405f;
  --navy-dark: #30334f;
  --cyan: #16a6c7;
  --blue: #2585d9;
  --green: #68d59a;
  --yellow: #ffd989;
  --red: #ff8f88;
  --danger: #d96363;
  --shadow: 0 28px 80px rgba(24, 29, 49, 0.32);
  --card-shadow: 0 12px 28px rgba(38, 43, 70, 0.07);
  --ring: 0 0 0 3px rgba(61, 64, 95, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1180px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 24% 14%, rgba(255, 255, 255, 0.16), transparent 26%),
    linear-gradient(135deg, #555a73, #373c58);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

body.isLocked .appFrame {
  filter: blur(5px);
  pointer-events: none;
  user-select: none;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, color 160ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 0;
  box-shadow: var(--ring);
}

.authGate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 20%, rgba(255, 255, 255, 0.22), transparent 30%),
    rgba(35, 39, 62, 0.72);
  backdrop-filter: blur(10px);
}

.authGate[hidden] {
  display: none;
}

.authPanel {
  width: min(440px, 100%);
  display: grid;
  gap: 14px;
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  animation: cardIn 220ms ease both;
}

.authBrand {
  margin-bottom: 6px;
}

.authPanel h1 {
  font-size: 24px;
}

.authPanel p {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.authPanel .primaryButton {
  margin-top: 4px;
}

.authGateError {
  min-height: 18px;
  color: #b73535;
  font-size: 12px;
  line-height: 1.35;
}

.appFrame {
  width: 100vw;
  height: 100vh;
  min-height: 720px;
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: var(--frame);
  box-shadow: none;
  animation: frameIn 320ms ease both;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 28px 18px 22px;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brandMark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: #ffffff;
  background: var(--navy);
  font-weight: 700;
}

.brand strong {
  display: block;
  color: var(--navy);
  font-size: 20px;
  line-height: 1;
  font-weight: 700;
}

.brand span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.navStack,
.deploymentTabs {
  display: grid;
  gap: 10px;
}

.navItem,
.tabButton {
  display: flex;
  align-items: center;
  min-height: 42px;
  border-radius: 10px;
  padding: 0 13px;
  color: var(--ink);
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
}

.navItem.active {
  color: #ffffff;
  background: var(--navy);
  box-shadow: 0 12px 24px rgba(61, 64, 95, 0.22);
}

.navItem:not(.active):hover,
.tabButton:hover {
  background: var(--soft);
}

.deploymentBlock {
  margin-top: 30px;
}

.sidebarTitle {
  margin-bottom: 12px;
  padding-left: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.tabButton {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tabButton.active {
  color: #ffffff;
  background: var(--navy);
}

.tabCount {
  min-width: 24px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 7px;
  background: rgba(61, 64, 95, 0.1);
  color: currentColor;
  font-size: 12px;
}

.sidebarStatus {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: auto;
  padding: 12px;
  border-radius: 12px;
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.35;
}

.sidebarStatus #statusText {
  white-space: pre-line;
}

.sidebarStatus #statusText strong {
  color: var(--ink);
  font-weight: 700;
}

.statusDot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  margin-top: 4px;
  border-radius: 999px;
  background: var(--muted);
}

.statusDot.ok {
  background: #2aa978;
}

.statusDot.error {
  background: var(--danger);
}

.mainPane {
  min-width: 0;
  overflow: hidden;
}

.topbar {
  height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.topbar > .iconButton {
  margin-left: auto;
}

.searchBox {
  width: 330px;
  height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-radius: 14px;
  background: #f0f1f4;
  color: var(--muted);
  font-size: 12px;
}

.searchBox span {
  font-weight: 600;
}

.searchBox input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
  font-weight: 400;
}

.iconButton,
.primaryButton,
.ghostButton {
  min-height: 38px;
  border-radius: 10px;
  padding: 0 16px;
  font-weight: 650;
}

.iconButton,
.primaryButton {
  color: #ffffff;
  background: var(--navy);
  box-shadow: 0 12px 24px rgba(61, 64, 95, 0.18);
}

.ghostButton {
  color: var(--navy);
  background: #eef0f7;
}

.connection {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 12px;
  padding: 18px 24px 4px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

input,
textarea {
  width: 100%;
  border: 1px solid #dfe4ec;
  border-radius: 10px;
  background: #ffffff;
  color: var(--ink);
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 400;
}

textarea {
  min-height: 78px;
  resize: vertical;
}

.contentGrid {
  height: calc(100% - 144px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 296px;
  gap: 18px;
  padding: 18px 24px 24px;
  overflow: hidden;
}

.centerPane {
  min-width: 0;
  overflow: hidden;
}

.sectionTop {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  color: var(--ink);
  font-size: 22px;
  line-height: 1.2;
  font-weight: 700;
}

.sectionTop p,
.cardHeader span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.countBadge {
  min-width: 34px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border-radius: 9px;
  background: #e9ecf3;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.metricCards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metricCard {
  min-height: 88px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
  box-shadow: var(--card-shadow);
}

.metricCard.active {
  color: #ffffff;
  background: var(--navy);
}

.metricCard span {
  display: block;
  color: inherit;
  opacity: 0.72;
  font-size: 12px;
  font-weight: 500;
}

.metricCard strong {
  display: block;
  margin-top: 12px;
  font-size: 22px;
  line-height: 1.25;
  font-weight: 700;
  overflow: visible;
  text-overflow: ellipsis;
}

#selectedDeploymentLabel {
  font-size: clamp(14px, 1.1vw, 18px);
  line-height: 1.28;
  white-space: normal;
  overflow-wrap: anywhere;
}

.sessionCards {
  height: calc(100% - 150px);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: 14px;
  overflow: auto;
  padding-right: 2px;
}

.sessionCard,
.overviewCard,
.inspector {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #ffffff;
  box-shadow: var(--card-shadow);
}

.sessionCard {
  overflow: hidden;
  animation: cardIn 220ms ease both;
}

.sessionCardHeader {
  width: 100%;
  min-height: 58px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 0 10px 0 14px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
  color: inherit;
}

.sessionHeaderMain {
  min-width: 0;
  min-height: 58px;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.sessionCardHeader:hover,
.sessionHeaderMain:hover {
  background: #f8f9fc;
}

.terminateSessionButton {
  min-height: 32px;
  padding: 0 10px;
  border-radius: 9px;
  color: var(--danger);
  background: #fff3f3;
  border: 1px solid rgba(217, 99, 99, 0.24);
  font-size: 12px;
  font-weight: 650;
}

.sessionToggle {
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  border-radius: 6px;
  background: #eef0f7;
}

.sessionToggle::before {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 2px solid var(--navy);
  border-bottom: 2px solid var(--navy);
  transform: rotate(45deg) translate(-1px, -1px);
  transition: transform 160ms ease;
}

.sessionCard.collapsed .sessionToggle::before {
  transform: rotate(-45deg);
}

.sessionCard.collapsed .sessionCardHeader {
  border-bottom: 0;
}

.sessionCard.collapsed .playerList {
  display: none;
}

.sessionName {
  min-width: 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sessionMeta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.playerList {
  display: grid;
}

.playerItem {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px 140px auto;
  gap: 12px;
  align-items: center;
  min-height: 62px;
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
  animation: rowIn 180ms ease both;
}

.sessionEmpty {
  min-height: 52px;
  display: grid;
  align-items: center;
  padding: 0 14px;
  color: var(--muted);
  font-size: 12px;
  background: #fafbfe;
}

.playerItem:last-child {
  border-bottom: 0;
}

.playerItem:hover,
.playerItem.selected {
  background: #f6f8fc;
}

.playerItem.selected {
  box-shadow: inset 4px 0 0 var(--cyan);
}

.playerName,
.miniValue {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.playerName {
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
}

.playerSub,
.miniLabel {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

.miniLabel {
  display: block;
  margin-top: 0;
  font-weight: 600;
  text-transform: uppercase;
}

.miniValue {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 500;
}

.linkButton {
  min-height: 32px;
  padding: 0 10px;
  border-radius: 9px;
  color: var(--navy);
  background: #eef0f7;
  font-size: 12px;
  font-weight: 650;
}

.rightPane {
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100%;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.overviewCard,
.inspector {
  padding: 16px;
}

.inspector {
  flex: 0 0 auto;
  min-height: 0;
}

.cardHeader {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

h2 {
  font-size: 14px;
  font-weight: 700;
}

.donutWrap {
  position: relative;
  width: 108px;
  height: 108px;
  margin: 6px auto 12px;
}

.fleetDonut {
  width: 108px;
  height: 108px;
  border-radius: 50%;
  background: conic-gradient(var(--green) 0 33%, var(--red) 33% 66%, var(--yellow) 66% 100%);
}

.fleetDonut::after {
  content: "";
  position: absolute;
  inset: 25px;
  border-radius: 50%;
  background: #ffffff;
}

.donutCenter {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
}

.donutCenter strong {
  font-size: 17px;
  line-height: 1;
}

.donutCenter span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.deploymentLegend {
  display: grid;
  gap: 8px;
}

.capacityControls {
  display: grid;
  gap: 12px;
}

.capacityForm {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8f9fc;
}

.capacitySummary {
  display: grid;
  gap: 8px;
}

.capacitySummary strong {
  display: block;
  color: var(--ink);
  font-size: 13px;
}

.capacitySummary > div > span,
.capacityRange,
.capacityHint,
.capacityEmpty {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

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

.capacityCounts span {
  padding: 4px 7px;
  border-radius: 999px;
  color: var(--muted);
  background: #ffffff;
  font-size: 10px;
}

.capacityCounts b {
  color: var(--ink);
}

.capacityAction {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px;
}

.capacityAction label {
  gap: 5px;
  font-size: 10px;
}

.capacityAction input {
  min-height: 36px;
}

.capacityAction button {
  min-height: 36px;
  padding: 0 12px;
  white-space: nowrap;
}

.capacityHint {
  margin-top: 10px;
}

.capacityEmpty {
  padding: 8px 0;
}

.legendRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.legendName {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legendSwatch {
  width: 9px;
  height: 9px;
  border-radius: 3px;
}

#inspectorFields {
  margin: 0;
}

#inspectorFields div {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  animation: inspectorIn 180ms ease both;
}

dt {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}

dd {
  margin: 5px 0 0;
  color: var(--ink);
  overflow-wrap: anywhere;
  font-size: 12px;
  line-height: 1.35;
}

.kickForm {
  display: grid;
  gap: 11px;
  margin-top: 12px;
}

.announcementForm {
  display: grid;
  gap: 11px;
}

.announcementForm textarea {
  min-height: 64px;
}

.secondaryButton,
.dangerOutlineButton {
  min-height: 38px;
  border-radius: 11px;
  font-weight: 650;
}

.secondaryButton {
  color: #ffffff;
  background: var(--navy);
}

.dangerOutlineButton {
  color: var(--danger);
  background: #fff3f3;
  border: 1px solid rgba(217, 99, 99, 0.24);
}

#kickButton {
  min-height: 40px;
  border-radius: 11px;
  color: #ffffff;
  background: linear-gradient(180deg, #df7272, var(--danger));
  box-shadow: 0 12px 24px rgba(217, 99, 99, 0.18);
  font-weight: 700;
}

.emptyState {
  grid-column: 1 / -1;
  min-height: 280px;
  display: grid;
  place-items: center;
  border: 1px dashed #d8deea;
  border-radius: 16px;
  color: var(--muted);
  text-align: center;
  background: rgba(255, 255, 255, 0.6);
}

.emptyState strong {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
  font-size: 15px;
}

.isLoading::after {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-left: 8px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #ffffff;
  border-radius: 999px;
  animation: spin 700ms linear infinite;
}

@keyframes frameIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes rowIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes inspectorIn {
  from {
    opacity: 0;
    transform: translateX(5px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
