:root {
  --background: #fbfcff;
  --foreground: #1a2230;
  --card: #ffffff;
  --card-subtle: #f6f8fc;
  --muted: #697386;
  --muted-strong: #475569;
  --line: #d9e0ec;
  --line-strong: #b8c3d6;
  --primary: #0047bb;
  --primary-hover: #003b9f;
  --primary-soft: #e8f0ff;
  --green: #21a65b;
  --green-soft: #e8f8ef;
  --red: #d9414f;
  --red-soft: #fff0f2;
  --amber: #c78505;
  --amber-soft: #fff7e6;
  --shadow: 0 18px 44px rgb(36 49 76 / 10%);
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--background);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--foreground);
  background:
    linear-gradient(180deg, rgb(246 248 252 / 96%) 0, rgb(251 252 255 / 100%) 320px),
    var(--background);
  font-family: "Open Sans", "Roboto", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 15px;
}

button,
a {
  font: inherit;
}

button {
  appearance: none;
}

[hidden] {
  display: none !important;
}

a {
  color: inherit;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.auth-gate {
  min-height: 100vh;
  background: var(--background);
}

.auth-layout {
  display: grid;
  min-height: 100vh;
  grid-template-columns: minmax(420px, 0.9fr) minmax(0, 1.1fr);
}

.auth-content {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  gap: 48px;
  padding: 42px clamp(28px, 6vw, 76px);
}

.auth-brand {
  display: inline-flex;
  width: max-content;
  align-items: center;
  text-decoration: none;
}

.auth-brand img {
  width: 44px;
  height: 44px;
  display: block;
}

.auth-card {
  display: grid;
  width: min(360px, 100%);
  margin: auto 0;
  gap: 18px;
}

.auth-card h1 {
  margin: 0;
  color: var(--foreground);
  font-size: clamp(2rem, 5vw, 3.15rem);
  line-height: 0.98;
  font-weight: 800;
}

.auth-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.55;
}

.signin-wrap {
  position: relative;
  width: min(292px, 100%);
  min-height: 44px;
  margin-top: 8px;
}

.signin {
  position: absolute;
  inset: 0;
  z-index: 2;
  opacity: 0.001;
}

.signin,
.signin iframe {
  max-width: 100%;
}

.signin-visual {
  position: relative;
  z-index: 1;
  display: inline-flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--primary);
  border-radius: 7px;
  background: var(--primary);
  color: #ffffff;
  font-size: 0.88rem;
  font-weight: 800;
  text-align: center;
  pointer-events: none;
  box-shadow: 0 10px 24px rgb(0 71 187 / 16%);
}

.signin-wrap:hover .signin-visual {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.auth-art {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  background: #e8edf7;
}

.auth-art img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--line);
  background: rgb(255 255 255 / 92%);
  backdrop-filter: blur(14px);
}

.topbar-inner {
  display: flex;
  max-width: 1180px;
  min-height: 64px;
  margin: 0 auto;
  padding: 12px 24px;
  align-items: center;
  gap: 18px;
}

.product-mark {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
  color: var(--foreground);
  font-weight: 700;
}

.product-mark img {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
}

.product-mark .slash {
  color: var(--line-strong);
  font-weight: 600;
}

.product-mark strong {
  min-width: 0;
  overflow: hidden;
  color: var(--muted-strong);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-strip {
  display: flex;
  margin-left: auto;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.session-pill,
.ghost-button,
.primary-button,
.row-button,
.label-pill,
.tournament-selector select {
  border-radius: 7px;
}

.session-pill {
  display: inline-flex;
  min-height: 30px;
  padding: 7px 10px;
  align-items: center;
  border: 1px solid var(--line);
  background: var(--card-subtle);
  color: var(--muted-strong);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.session-pill.muted {
  color: var(--muted);
}

.tournament-selector {
  position: relative;
  display: inline-flex;
  min-height: 30px;
  align-items: center;
}

.tournament-selector::after {
  position: absolute;
  right: 11px;
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--muted-strong);
  border-bottom: 2px solid var(--muted-strong);
  content: "";
  pointer-events: none;
  transform: translateY(-2px) rotate(45deg);
}

.tournament-selector select {
  min-height: 30px;
  padding: 7px 32px 7px 11px;
  border: 1px solid var(--line);
  background: var(--card-subtle);
  color: var(--muted-strong);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 800;
  appearance: none;
}

.tournament-selector select:hover,
.tournament-selector select:focus-visible {
  border-color: var(--primary);
  outline: none;
}

.ghost-button,
.primary-button,
.row-button {
  min-height: 34px;
  border: 1px solid var(--line-strong);
  cursor: pointer;
  font-weight: 700;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease, opacity 140ms ease, transform 140ms ease;
}

.ghost-button {
  padding: 7px 10px;
  background: var(--card);
  color: var(--muted-strong);
  font-size: 0.78rem;
}

.ghost-button:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.summary-band {
  border-bottom: 1px solid var(--line);
  background: #f6f8fc;
}

.summary-inner,
.ops-log,
.workspace {
  max-width: 1180px;
  margin: 0 auto;
}

.summary-inner {
  display: flex;
  padding: 14px 24px 10px;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.metric {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.metric strong {
  color: var(--foreground);
  font-size: 1.25rem;
}

.metric.running strong {
  color: var(--green);
}

.metric.pending strong {
  color: var(--amber);
}

.metric.stopped strong {
  color: var(--muted);
}

.metric.unknown strong {
  color: var(--red);
}

.primary-button {
  margin-left: auto;
  padding: 9px 14px;
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
  font-size: 0.78rem;
}

.primary-button:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  transform: translateY(-1px);
}

.ops-log {
  display: flex;
  min-height: 34px;
  padding: 0 24px 12px;
  align-items: center;
  gap: 10px;
  overflow-x: auto;
  color: var(--muted);
  font-size: 0.76rem;
  white-space: nowrap;
}

.ops-label {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
}

.ops-entry {
  display: inline-flex;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted-strong);
  background: var(--card);
}

.ops-empty {
  color: var(--muted);
}

.workspace {
  padding: 30px 24px 64px;
}

.workspace-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.eyebrow,
.workspace-heading p {
  margin: 0;
}

.eyebrow {
  color: var(--primary);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.workspace-heading h2 {
  margin: 5px 0 0;
  color: var(--foreground);
  font-size: clamp(1.7rem, 4vw, 2.65rem);
  line-height: 1;
  font-weight: 800;
}

#workspace-status {
  color: var(--muted);
  font-size: 0.82rem;
  text-align: right;
}

.global-error {
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid rgb(217 65 79 / 34%);
  border-radius: var(--radius);
  background: var(--red-soft);
  color: #9d2430;
  font-size: 0.92rem;
}

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

.empty-state {
  padding: 18px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--card-subtle);
  color: var(--muted-strong);
  font-size: 0.9rem;
  font-weight: 700;
}

.instance-row {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 8px 24px rgb(36 49 76 / 6%);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--red);
}

.status-dot.running {
  background: var(--green);
  box-shadow: 0 0 0 4px rgb(33 166 91 / 12%);
}

.status-dot.pending {
  background: var(--amber);
  animation: pulse 1.2s infinite;
}

.status-dot.stopped {
  background: #8a95a8;
}

.status-dot.unknown {
  background: var(--red);
}

.instance-main {
  min-width: 0;
}

.instance-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.instance-name {
  color: var(--foreground);
  font-size: 0.98rem;
  font-weight: 800;
}

.label-pill {
  display: inline-flex;
  max-width: 220px;
  padding: 3px 7px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--card-subtle);
  font-size: 0.68rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.instance-meta {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.5;
}

.instance-meta.running {
  color: var(--green);
}

.instance-meta.pending {
  color: var(--amber);
}

.instance-meta.unknown {
  color: var(--red);
}

.instance-note {
  margin-top: 8px;
  color: var(--muted-strong);
  font-size: 0.84rem;
}

.instance-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  flex-wrap: wrap;
}

.row-button {
  min-width: 74px;
  padding: 8px 10px;
  background: var(--card);
  color: var(--muted-strong);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.row-button.start {
  border-color: rgb(33 166 91 / 44%);
  color: #137a3f;
  background: var(--green-soft);
}

.row-button.stop {
  border-color: rgb(217 65 79 / 44%);
  color: #a72a36;
  background: var(--red-soft);
}

.row-button.restart {
  border-color: rgb(199 133 5 / 44%);
  color: #835702;
  background: var(--amber-soft);
}

.row-button.refresh {
  border-color: rgb(0 71 187 / 26%);
  color: var(--primary);
  background: var(--primary-soft);
}

.row-button:hover:not(:disabled) {
  border-color: currentColor;
  transform: translateY(-1px);
}

.instance-details {
  grid-column: 2 / -1;
  border-top: 1px solid var(--line);
  padding-top: 10px;
  color: var(--muted);
  font-size: 0.8rem;
}

.instance-details summary {
  width: max-content;
  cursor: pointer;
  color: var(--primary);
  font-weight: 700;
}

.instance-details pre {
  max-height: 280px;
  margin: 10px 0 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: #263244;
  font: 0.74rem/1.45 "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  white-space: pre-wrap;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgb(10 18 32 / 42%);
  backdrop-filter: blur(12px);
}

.modal-panel {
  display: grid;
  width: min(480px, 100%);
  gap: 14px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  box-shadow: 0 28px 80px rgb(20 30 54 / 22%);
}

.modal-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted-strong);
  font-size: 0.82rem;
  font-weight: 800;
}

.modal-brand img {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
}

.modal-panel h2 {
  margin: 0;
  color: var(--foreground);
  font-size: 1.55rem;
  line-height: 1.1;
}

.modal-panel p {
  margin: 0;
  color: var(--muted-strong);
  line-height: 1.55;
}

.modal-meta {
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--card-subtle);
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.modal-action-button {
  min-height: 38px;
  padding: 9px 15px;
  border: 1px solid var(--primary);
  border-radius: 7px;
  background: var(--primary);
  color: #ffffff;
  cursor: pointer;
  font-weight: 800;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.modal-action-button:hover:not(:disabled) {
  border-color: var(--primary-hover);
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.modal-action-button.start {
  border-color: var(--green);
  background: var(--green);
}

.modal-action-button.stop,
.modal-action-button.restart {
  border-color: var(--red);
  background: var(--red);
}

.modal-action-button.authorize {
  min-width: 160px;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.46;
  }
}

@media (max-width: 960px) {
  .auth-layout {
    grid-template-columns: 1fr;
  }

  .auth-content {
    min-height: 100vh;
  }

  .auth-art {
    display: none;
  }
}

@media (max-width: 840px) {
  .topbar-inner,
  .summary-inner,
  .ops-log,
  .workspace {
    padding-left: 16px;
    padding-right: 16px;
  }

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

  .session-strip,
  .primary-button {
    width: 100%;
    margin-left: 0;
    justify-content: flex-start;
  }

  .instance-row {
    grid-template-columns: 12px minmax(0, 1fr);
  }

  .instance-actions,
  .instance-details {
    grid-column: 2;
    justify-content: flex-start;
  }

  .row-button {
    min-width: 86px;
  }
}

@media (max-width: 540px) {
  .auth-content {
    gap: 38px;
    padding: 30px 22px;
  }

  .auth-brand img {
    width: 38px;
    height: 38px;
  }

  .auth-card {
    margin: auto 0;
  }

  .summary-inner {
    gap: 14px;
  }

  .metric {
    min-width: calc(50% - 14px);
  }

  .session-pill,
  .tournament-selector,
  .tournament-selector select {
    width: 100%;
  }

  .modal-panel {
    padding: 20px;
  }

  .modal-actions,
  .modal-actions .ghost-button,
  .modal-actions .modal-action-button {
    width: 100%;
  }
}
