:root {
  color-scheme: light;
  --page: #f4f6f8;
  --ink: #101827;
  --muted: #657287;
  --soft: #eef2f6;
  --line: #d9e0e8;
  --dark: #1f2936;
  --dark-2: #273343;
  --dark-3: #111927;
  --light: #ffffff;
  --accent: #f59a23;
  --accent-2: #ffb14a;
  --good: #24c878;
  --danger: #e52b2b;
  --warning: #bd7a12;
  --shadow: 0 16px 44px rgba(17, 25, 39, .18);
}

* { box-sizing: border-box; }

[hidden],
.app-shell[hidden],
.auth-shell[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, var(--dark) 0 340px, var(--page) 340px 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid #cdd6e0;
  border-radius: 6px;
  padding: 0 14px;
  color: var(--ink);
  background: var(--light);
  cursor: pointer;
  font-weight: 700;
}

button:hover { border-color: var(--accent); }
button:disabled { opacity: .55; cursor: wait; }

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

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid #cdd6e0;
  border-radius: 6px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--light);
}

code {
  border-radius: 4px;
  padding: 2px 5px;
  background: #f3eadc;
  color: #6b3d00;
}

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

.auth-panel {
  width: min(410px, 100%);
  display: grid;
  gap: 16px;
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 8px;
  background: #222d3b;
  box-shadow: var(--shadow);
  color: #f5f7fb;
}

.auth-panel h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.1;
}

.auth-panel label {
  display: grid;
  gap: 8px;
  color: #c8d2df;
  font-weight: 600;
}

.auth-panel input {
  border-color: #3f4c5d;
  color: #f5f7fb;
  background: #121a25;
}

.auth-panel button {
  border-color: var(--accent);
  color: #1f2936;
  background: var(--accent);
}

.status-line {
  min-height: 20px;
  margin: 0;
  color: #ff9e9e;
}

.auth-note {
  margin: 0;
  color: #9facbb;
  line-height: 1.45;
}

.app-shell {
  min-height: 100vh;
}

.site-header {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 0 clamp(18px, 3vw, 34px);
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  background: var(--dark);
  color: #eff5fb;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-row.compact {
  align-items: flex-start;
}

.brand-row strong {
  display: block;
  line-height: 1.1;
}

.brand-row span,
.brand-row p {
  display: block;
  margin: 2px 0 0;
  color: #aeb9c8;
  font-size: 13px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: var(--dark-3);
  font-weight: 900;
}

nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

nav button,
.ghost {
  border-color: transparent;
  color: #d7e1ec;
  background: transparent;
}

nav button {
  min-height: 64px;
  border-radius: 0;
  padding: 0 18px;
  font-weight: 600;
}

nav button.active {
  border-bottom: 2px solid var(--accent);
  color: #fff;
}

.ghost {
  margin-left: auto;
  border-color: rgba(255, 255, 255, .18);
  border-radius: 999px;
  min-height: 36px;
}

.workspace {
  width: min(1220px, calc(100% - 32px));
  margin: 38px auto 56px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto auto;
  align-items: center;
  gap: 18px;
  min-height: 122px;
  padding: 24px 28px;
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 8px;
  background: var(--dark-2);
  color: #fff;
  box-shadow: var(--shadow);
}

.topbar h1 {
  margin: 0 0 8px;
  font-size: clamp(28px, 3vw, 34px);
  line-height: 1.1;
}

.topbar h1::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 14px;
  border-radius: 4px;
  background: var(--good);
  box-shadow: 0 0 0 6px rgba(36, 200, 120, .12);
  vertical-align: 3px;
}

.topbar.offline h1::before {
  background: #8995a5;
  box-shadow: 0 0 0 6px rgba(137, 149, 165, .12);
}

.topbar p {
  margin: 0;
  color: #b8c4d1;
}

.topbar > button {
  border-color: #0f1723;
  color: #fff;
  background: #101827;
}

.topbar-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, auto));
  gap: 8px;
}

.topbar-stats span {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 6px;
  background: rgba(17, 24, 39, .35);
  color: #b8c4d1;
  font-size: 13px;
}

.topbar-stats strong {
  color: #fff;
  font-size: 18px;
}

.panel-section {
  display: none;
  margin-top: 38px;
}

.panel-section.active { display: block; }

.overview-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 292px;
  gap: 16px;
  align-items: start;
}

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

.service-card,
.info-card,
.setup-card,
.backup-row,
.console-layout {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--light);
}

.service-card {
  display: grid;
  gap: 18px;
  padding: 20px;
  min-height: 214px;
  box-shadow: 0 8px 22px rgba(17, 25, 39, .06);
}

.service-card.online {
  border-top: 3px solid var(--good);
}

.service-card.offline {
  border-top: 3px solid #b6c0cc;
}

.service-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.service-head h2 {
  margin: 0 0 6px;
  font-size: 20px;
  line-height: 1.15;
}

.service-head p {
  margin: 0;
  color: var(--muted);
}

.state,
.badge,
.setup-badge {
  align-self: start;
  border: 1px solid #f2c27e;
  border-radius: 6px;
  padding: 4px 8px;
  color: var(--warning);
  background: #fff3df;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  white-space: nowrap;
}

.online .state {
  border-color: #9be7bf;
  color: #0a8847;
  background: #e9fbf1;
}

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

.metrics span {
  min-width: 0;
  display: grid;
  gap: 5px;
  padding: 10px;
  border-radius: 6px;
  background: var(--soft);
  color: var(--muted);
  font-size: 13px;
}

.metrics strong {
  color: var(--ink);
  overflow-wrap: anywhere;
}

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

.wide {
  width: 100%;
}

.ghost-action {
  border-color: var(--accent);
  color: #8a5000;
  background: #fffaf2;
}

.dashboard-side {
  display: grid;
  gap: 16px;
}

.info-card {
  padding: 18px;
}

.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-title h2 {
  margin: 0;
  font-size: 18px;
}

.badge.muted {
  border-color: #d6dde6;
  color: var(--muted);
  background: #f6f8fb;
}

.detail-list,
.port-list {
  display: grid;
  gap: 10px;
}

.detail-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.detail-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.detail-row strong {
  color: var(--muted);
}

.detail-row.online strong {
  color: #0a8847;
}

.detail-row small {
  grid-column: 1 / -1;
  color: var(--muted);
}

.port-list span {
  display: grid;
  gap: 2px;
  color: var(--muted);
}

.port-list strong {
  color: var(--ink);
}

.hint {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.console-layout {
  display: grid;
  gap: 12px;
  padding: 20px;
}

.console-toolbar,
.backup-actions {
  display: grid;
  grid-template-columns: minmax(180px, 280px) auto auto;
  gap: 10px;
  justify-content: start;
}

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

.preset-row button {
  min-height: 34px;
  border-color: #f1c17e;
  color: #805000;
  background: #fff7ea;
}

.console-output {
  height: min(58vh, 620px);
  margin: 0;
  padding: 16px;
  border: 1px solid #0b111b;
  border-radius: 8px;
  background: #080d14;
  color: #d7f1df;
  overflow: auto;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.55;
}

.console-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

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

.setup-card {
  display: grid;
  gap: 14px;
  align-content: start;
  padding: 20px;
}

.setup-card h2 {
  margin: 0;
  font-size: 22px;
}

.setup-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.setup-card label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

.setup-badge {
  justify-self: start;
}

.backup-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.backup-row {
  display: grid;
  grid-template-columns: 1.3fr auto auto auto;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
}

.backup-row span {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.backup-row strong {
  display: block;
}

.empty {
  margin: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--light);
  color: var(--muted);
}

@media (max-width: 1060px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .topbar-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .dashboard-side {
    grid-template-columns: repeat(2, minmax(260px, 1fr));
  }
}

@media (max-width: 820px) {
  body {
    background: linear-gradient(180deg, var(--dark) 0 280px, var(--page) 280px 100%);
  }

  .site-header {
    height: auto;
    flex-wrap: wrap;
    padding: 12px 16px;
    gap: 12px;
  }

  nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
  }

  nav button {
    min-height: 46px;
    padding: 0 12px;
    white-space: nowrap;
  }

  .ghost {
    margin-left: auto;
  }

  .workspace {
    width: min(100% - 20px, 1220px);
    margin-top: 22px;
  }

  .service-grid,
  .setup-grid,
  .dashboard-side {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 560px) {
  .auth-panel {
    padding: 22px;
  }

  .topbar {
    padding: 20px;
  }

  .topbar-stats,
  .metrics,
  .actions,
  .console-form,
  .console-toolbar,
  .backup-actions {
    grid-template-columns: 1fr;
  }
}

/* Game manager v2 */
.eyebrow {
  display: block;
  margin-bottom: 8px;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.operation-notice {
  position: sticky;
  z-index: 20;
  top: 10px;
  margin-top: 16px;
  padding: 13px 16px;
  border: 1px solid #9dbce7;
  border-radius: 7px;
  background: #eaf3ff;
  color: #174f90;
  box-shadow: 0 8px 22px rgba(17, 25, 39, .12);
  font-weight: 700;
}

.operation-notice.success { border-color: #9be7bf; color: #08713c; background: #e9fbf1; }
.operation-notice.warning { border-color: #f2c27e; color: #895400; background: #fff5e5; }
.operation-notice.error { border-color: #f1a4a4; color: #a31818; background: #fff0f0; }

.security-list,
.resource-list {
  display: grid;
  gap: 10px;
}

.security-list span {
  position: relative;
  padding-left: 24px;
  color: var(--muted);
}

.security-list span::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: #0a8847;
  font-weight: 900;
}

.server-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 24px;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 8px;
  background: var(--dark-2);
  color: #fff;
  box-shadow: var(--shadow);
}

.server-identity {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  min-width: 0;
}

.server-identity label {
  display: block;
  margin-bottom: 7px;
  color: #aeb9c8;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.server-identity select {
  width: min(360px, 100%);
  min-height: 46px;
  border-color: rgba(255, 255, 255, .18);
  color: #fff;
  background: #17212f;
  font-size: 22px;
  font-weight: 800;
}

.server-state-dot {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  margin-top: 34px;
  border-radius: 4px;
  background: #8995a5;
  box-shadow: 0 0 0 6px rgba(137, 149, 165, .12);
}

.server-state-dot.online {
  background: var(--good);
  box-shadow: 0 0 0 6px rgba(36, 200, 120, .12);
}

.server-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 10px;
  color: #b8c4d1;
  font-size: 13px;
}

.server-facts span::before { content: "•"; margin-right: 7px; color: var(--accent); }

.server-actions {
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 8px;
}

.server-actions button:not(.danger) { border-color: #101827; color: #fff; background: #101827; }

.server-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 292px;
  gap: 16px;
  align-items: start;
  margin-top: 38px;
  min-width: 0;
}

.server-manager,
.section-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--light);
  box-shadow: 0 8px 22px rgba(17, 25, 39, .06);
}

.section-card { padding: 20px; }

.server-tabs {
  max-width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.server-tabs button {
  min-height: 58px;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  padding: 0 14px;
  color: var(--muted);
  background: transparent;
  white-space: nowrap;
}

.server-tabs button.active { border-bottom-color: var(--accent); color: #9a5900; }
.server-tab { display: none; min-width: 0; padding: 20px; }
.server-tab.active { display: block; }
.server-side { display: grid; gap: 16px; }

.resource-list div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.resource-list div:last-child { border-bottom: 0; padding-bottom: 0; }
.resource-list span { color: var(--muted); }

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

.section-toolbar h2,
.section-toolbar p { margin: 0; }
.section-toolbar h2 { font-size: 20px; }
.section-toolbar p { margin-top: 4px; color: var(--muted); }

.compact-hint { margin: 0 0 14px; }

.console-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.console-output,
.console-form,
.preset-row {
  min-width: 0;
  max-width: 100%;
}

.file-toolbar {
  display: grid;
  grid-template-columns: auto minmax(140px, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.file-toolbar strong {
  min-width: 0;
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--soft);
  color: var(--muted);
  overflow-wrap: anywhere;
}

.file-list {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}

.file-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 100px 170px auto;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}

.file-row:last-child { border-bottom: 0; }
.file-row > span { color: var(--muted); font-size: 13px; }

.file-open {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  border-color: transparent;
  padding: 0 8px;
  text-align: left;
}

.file-open strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.file-icon { color: var(--accent); font-size: 18px; }
.danger-outline { border-color: #efb2b2; color: #b01e1e; background: #fff7f7; }

.file-editor {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafc;
}

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

.editor-head span,
.editor-head strong { display: block; }
.editor-head span { color: var(--muted); font-size: 12px; }

.file-editor textarea {
  width: 100%;
  min-height: 380px;
  resize: vertical;
  border: 1px solid #111927;
  border-radius: 7px;
  padding: 14px;
  color: #d7f1df;
  background: #080d14;
  font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  tab-size: 2;
}

.editor-actions { display: flex; justify-content: flex-end; gap: 10px; }

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

.player-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.player-avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: #6b3d00;
  background: #ffe1b6;
  font-weight: 900;
}

.player-card strong,
.player-card small { display: block; }
.player-card small { margin-top: 3px; color: var(--muted); }

.player-action-form {
  display: grid;
  grid-template-columns: 1fr 1fr 1.4fr auto;
  align-items: end;
  gap: 10px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.player-action-form label,
.settings-grid label,
.mini-settings label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.raw-output {
  max-height: 200px;
  margin: 16px 0 0;
  padding: 12px;
  border-radius: 7px;
  color: #c7d4e3;
  background: #101827;
  overflow: auto;
  white-space: pre-wrap;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

.span-2 { grid-column: 1 / -1; }

.check-label {
  display: flex !important;
  align-items: center;
  gap: 9px !important;
}

.check-label input { width: 18px; min-height: 18px; }

.settings-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.settings-note {
  margin: 0;
  padding: 12px;
  border-radius: 6px;
  color: var(--muted);
  background: var(--soft);
}

.network-list { display: grid; gap: 10px; }

.network-row {
  display: grid;
  grid-template-columns: 90px 140px 1fr;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.network-scope {
  border-radius: 999px;
  padding: 4px 8px;
  text-align: center;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.network-scope.public { color: #08713c; background: #e9fbf1; }
.network-scope.loopback { color: #174f90; background: #eaf3ff; }

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

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

.backup-row {
  grid-template-columns: minmax(220px, 1.3fr) auto auto auto auto;
}

.checksum {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
}

.backup-buttons { display: flex; gap: 8px; }

@media (max-width: 1060px) {
  .server-layout { grid-template-columns: 1fr; }
  .server-side { grid-template-columns: repeat(2, minmax(260px, 1fr)); }
}

@media (max-width: 820px) {
  .server-side,
  .player-grid { grid-template-columns: 1fr; }
  .server-hero { align-items: stretch; flex-direction: column; }
  .server-actions { grid-template-columns: repeat(3, 1fr); }
  .file-toolbar,
  .file-row,
  .player-action-form { grid-template-columns: 1fr; }
  .file-row { gap: 6px; padding: 12px; }
  .file-row > span { padding-left: 8px; }
  .backup-buttons { display: grid; grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
  .settings-grid,
  .mini-settings,
  .server-actions,
  .console-toolbar,
  .console-form,
  .backup-actions { grid-template-columns: 1fr; }
  .span-2,
  .wide-field { grid-column: auto; }
  .settings-footer,
  .section-toolbar,
  .editor-head { align-items: stretch; flex-direction: column; }
  .network-row { grid-template-columns: 1fr; }
}
