:root {
  color-scheme: light;
  font-family:
    "Segoe UI",
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
  --bg: #f4f7fb;
  --bg-accent: #eef4ff;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-secondary: #475569;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #dbeafe;
  --success: #059669;
  --success-soft: #d1fae5;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warning-soft: #fef3c7;
  --warning-text: #92400e;
  --shadow-sm: 0 1px 2px rgb(15 23 42 / 6%);
  --shadow-md: 0 10px 30px rgb(15 23 42 / 8%);
  --shadow-lg: 0 18px 50px rgb(15 23 42 / 10%);
  --radius: 16px;
  --radius-lg: 20px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  background:
    radial-gradient(circle at top left, rgb(219 234 254 / 70%), transparent 28rem),
    linear-gradient(180deg, var(--bg-accent) 0%, var(--bg) 240px, #f8fafc 100%);
  color: var(--text);
  margin: 0;
  min-height: 100vh;
}

button,
input,
textarea {
  border: 0;
  border-radius: 12px;
  font: inherit;
}

button {
  align-items: center;
  background: var(--primary);
  box-shadow: var(--shadow-sm);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font-weight: 600;
  justify-content: center;
  min-height: 40px;
  padding: 9px 14px;
  transition:
    background 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease;
}

button:hover {
  background: var(--primary-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
}

button.secondary {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: none;
  color: var(--text);
}

button.secondary:hover {
  background: var(--surface-muted);
  border-color: #94a3b8;
}

button.danger {
  background: var(--danger);
}

button.danger:hover {
  background: #b91c1c;
}

button.danger.secondary {
  background: var(--danger-soft);
  border: 1px solid #fca5a5;
  box-shadow: none;
  color: #b91c1c;
}

button.danger.secondary:hover {
  background: #fecaca;
  border-color: #f87171;
  color: #991b1b;
}

.page-shell {
  margin: 0 auto;
  max-width: 1200px;
  padding: 20px 24px 40px;
}

.topbar {
  align-items: center;
  background: rgb(255 255 255 / 94%);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  display: grid;
  gap: 14px 18px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 14px 18px;
  position: sticky;
  top: max(12px, env(safe-area-inset-top, 0px));
  z-index: 20;
}

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

.brand-copy {
  min-width: 0;
}

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

.brand-tagline {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  margin: 3px 0 0;
}

.status-chip {
  align-items: center;
  background: var(--success-soft);
  border: 1px solid #a7f3d0;
  border-radius: 999px;
  color: var(--success);
  display: inline-flex;
  font-size: 11px;
  font-weight: 800;
  gap: 6px;
  letter-spacing: 0.04em;
  padding: 4px 10px 4px 8px;
  text-transform: uppercase;
}

.status-dot {
  animation: status-pulse 2.4s ease-in-out infinite;
  background: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgb(5 150 105 / 18%);
  height: 7px;
  width: 7px;
}

@keyframes status-pulse {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.55;
  }
}

.brand-mark {
  align-items: center;
  background: linear-gradient(135deg, #3b82f6, #2563eb 60%, #10b981);
  border-radius: 14px;
  box-shadow: 0 8px 20px rgb(37 99 235 / 25%);
  color: #fff;
  display: grid;
  flex: 0 0 auto;
  font-size: 15px;
  font-weight: 800;
  height: 44px;
  place-items: center;
  width: 44px;
}

.topbar h1,
.panel-header h2,
.server-row h3 {
  color: var(--text);
  letter-spacing: -0.03em;
  margin: 0;
}

.topbar h1 {
  font-size: 21px;
}

.topbar p,
.panel-header p,
.hint,
.muted {
  color: var(--muted);
  margin: 4px 0 0;
}

.topbar-toolbar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.topbar-btn {
  align-items: center;
  border-radius: 11px;
  cursor: pointer;
  display: inline-flex;
  font-size: 13px;
  font-weight: 700;
  gap: 7px;
  justify-content: center;
  line-height: 1;
  min-height: 40px;
  padding: 0 14px;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease,
    color 160ms ease;
}

.topbar-btn-icon {
  flex: 0 0 auto;
}

.topbar-btn--primary {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  border: 0;
  box-shadow: 0 8px 18px rgb(37 99 235 / 24%);
  color: #fff;
}

.topbar-btn--primary:hover {
  box-shadow: 0 12px 22px rgb(37 99 235 / 30%);
  filter: brightness(1.04);
  transform: translateY(-1px);
}

.topbar-btn--ghost {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: none;
  color: var(--text-secondary);
}

.topbar-btn--ghost:hover {
  background: var(--surface-muted);
  border-color: #94a3b8;
  color: var(--text);
  transform: translateY(-1px);
}

.topbar-btn--logout:hover {
  background: var(--danger-soft);
  border-color: #fecaca;
  color: #b91c1c;
}

main {
  display: grid;
  gap: 20px;
  padding-top: 20px;
}

.summary-card,
.server-row,
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

.eyebrow,
.section-kicker {
  color: var(--primary);
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
  text-transform: uppercase;
}

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

.summary-card {
  border-radius: var(--radius);
  padding: 18px 20px;
}

.summary-card span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  font-weight: 600;
}

.summary-card strong {
  color: var(--text);
  display: block;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.04em;
  margin-top: 6px;
}

.panel {
  border-radius: var(--radius-lg);
  padding: 22px;
}

.panel-header {
  align-items: flex-start;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
}

.servers-panel .panel-header {
  align-items: center;
}

.logs-monitor-btn {
  align-items: center;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 52%, #0891b2 100%);
  border-radius: 12px;
  box-shadow:
    0 10px 24px rgb(37 99 235 / 28%),
    inset 0 1px 0 rgb(255 255 255 / 18%);
  color: #fff;
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 14px;
  font-weight: 700;
  gap: 9px;
  letter-spacing: -0.01em;
  min-height: 42px;
  padding: 10px 18px;
  text-decoration: none;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    filter 160ms ease;
  white-space: nowrap;
}

.logs-monitor-btn:hover {
  box-shadow:
    0 14px 28px rgb(37 99 235 / 34%),
    inset 0 1px 0 rgb(255 255 255 / 22%);
  color: #fff;
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.logs-monitor-btn:active {
  transform: translateY(0);
}

.logs-monitor-btn__icon {
  align-items: center;
  background: rgb(255 255 255 / 16%);
  border-radius: 8px;
  display: grid;
  flex: 0 0 auto;
  height: 30px;
  place-items: center;
  width: 30px;
}

.logs-monitor-btn__icon svg {
  display: block;
}

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

.bootstrap-form label {
  color: var(--text-secondary);
  display: grid;
  font-size: 13px;
  font-weight: 600;
  gap: 6px;
}

.bootstrap-form input,
.bootstrap-form textarea,
.login-form input {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  outline: none;
  padding: 11px 13px;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease;
  width: 100%;
}

.bootstrap-form input:focus,
.bootstrap-form textarea:focus,
.login-form input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgb(37 99 235 / 12%);
}

.bootstrap-form textarea {
  font: 12px/1.5 ui-monospace, Consolas, monospace;
  min-height: 100px;
  resize: vertical;
}

.bootstrap-form .wide,
.form-actions.wide {
  grid-column: 1 / -1;
}

.form-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.primary-big,
.primary-wide {
  min-width: 180px;
}

.warning-box {
  background: var(--warning-soft);
  border: 1px solid #fcd34d;
  border-radius: 12px;
  color: var(--warning-text);
  line-height: 1.55;
  margin-top: 14px;
  padding: 12px 14px;
}

.hint {
  background: var(--surface-muted);
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  line-height: 1.55;
  margin-top: 14px;
  padding: 12px 14px;
}

.output-panel {
  width: 100%;
}

.output-panel .panel-header {
  align-items: center;
}

#output {
  background: #0f172a;
  border-radius: 12px;
  color: #e2e8f0;
  font: 13px/1.6 ui-monospace, Consolas, monospace;
  height: clamp(360px, 52vh, 720px);
  margin-top: 14px;
  overflow: auto;
  padding: 16px 18px;
  white-space: pre-wrap;
  width: 100%;
}

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

.server-row {
  border-radius: var(--radius-lg);
  overflow: hidden;
  padding: 0;
}

.server-row.is-online {
  border-color: #86efac;
  box-shadow: 0 12px 32px rgb(16 185 129 / 10%);
}

.server-row-header {
  align-items: center;
  border-bottom: 1px solid var(--border);
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(180px, 1.2fr) minmax(220px, 1.5fr) auto;
  padding: 18px 20px;
}

.server-row h3 {
  font-size: 18px;
}

.server-subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.server-header-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

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

.metric-tile {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
}

.metric-tile span {
  color: var(--muted);
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric-tile strong {
  color: var(--text);
  display: block;
  font-size: 15px;
  font-weight: 700;
  margin-top: 4px;
}

.service-panel {
  padding: 0 20px 18px;
}

.service-panel-title {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin: 14px 0 10px;
  text-transform: uppercase;
}

.service-scroll {
  max-height: 280px;
  overflow: auto;
  padding-right: 4px;
}

.service-table {
  display: grid;
  gap: 8px;
}

.service-row {
  align-items: center;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(200px, 1.4fr) minmax(120px, 0.8fr) auto;
  padding: 12px 14px;
}

.service-info strong {
  color: var(--text);
  display: block;
  font-size: 14px;
}

.service-path {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
  word-break: break-all;
}

.service-meta {
  align-items: center;
  color: var(--text-secondary);
  display: flex;
  flex-wrap: wrap;
  font-size: 12px;
  gap: 8px;
}

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

.service-actions button {
  font-size: 12px;
  min-height: 34px;
  padding: 6px 10px;
}

.service-actions button.is-following {
  background: var(--primary-soft);
  border-color: #93c5fd;
  color: var(--primary);
}

.badge {
  border-radius: 999px;
  display: inline-flex;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.03em;
  padding: 4px 10px;
  text-transform: uppercase;
}

.badge.online,
.badge.running {
  background: var(--success-soft);
  color: var(--success);
}

.badge.offline,
.badge.errored {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge.unknown,
.badge.stopped {
  background: #e2e8f0;
  color: #475569;
}

.empty-state {
  align-items: center;
  background: var(--surface-muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--muted);
  display: grid;
  gap: 8px;
  justify-items: center;
  min-height: 140px;
  padding: 28px;
  text-align: center;
}

.empty-state strong {
  color: var(--text);
  font-size: 17px;
}

.login-screen {
  align-items: center;
  background:
    linear-gradient(180deg, #e8eef6 0%, #f4f7fb 42%, #f8fafc 100%);
  display: grid;
  min-height: 100vh;
  padding: 24px;
  place-items: center;
}

.login-shell {
  border: 1px solid #cbd5e1;
  box-shadow: 0 18px 48px rgb(15 23 42 / 12%);
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  max-width: 920px;
  width: min(100%, 920px);
}

.login-brand-panel {
  background: linear-gradient(160deg, #0f172a 0%, #1e293b 55%, #0f2744 100%);
  border-right: 1px solid #334155;
  color: #e2e8f0;
  display: grid;
  gap: 14px;
  padding: 40px 36px;
}

.login-brand-mark {
  align-items: center;
  background: #2563eb;
  border: 1px solid #3b82f6;
  color: #fff;
  display: inline-grid;
  font-size: 14px;
  font-weight: 800;
  height: 44px;
  letter-spacing: 0.06em;
  place-items: center;
  width: 44px;
}

.login-brand-panel h1 {
  color: #fff;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin: 0;
}

.login-brand-panel p {
  color: #94a3b8;
  font-size: 14px;
  line-height: 1.65;
  margin: 0;
  max-width: 34ch;
}

.login-form-panel {
  background: #fff;
  display: grid;
  gap: 20px;
  padding: 40px 36px;
}

.login-form-header {
  display: grid;
  gap: 6px;
}

.login-kicker {
  color: #2563eb;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.login-form-header h2 {
  color: var(--text);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0;
}

.login-form-header p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
  margin: 0;
}

.login-form {
  display: grid;
  gap: 16px;
}

.login-field {
  display: grid;
  gap: 8px;
}

.login-field span {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.login-screen .login-field input {
  background: #fff;
  border: 1px solid #94a3b8;
  border-radius: 0;
  color: var(--text);
  min-height: 46px;
  padding: 12px 14px;
}

.login-screen .login-field input:focus {
  border-color: #2563eb;
  box-shadow: inset 0 0 0 1px #2563eb;
  outline: none;
}

.login-screen .login-submit {
  background: #1d4ed8;
  border: 1px solid #1e40af;
  border-radius: 0;
  box-shadow: none;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.03em;
  min-height: 46px;
  text-transform: uppercase;
}

.login-screen .login-submit:hover {
  background: #1e40af;
  box-shadow: none;
  transform: none;
}

.login-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-left: 3px solid #dc2626;
  border-radius: 0;
  color: #b91c1c !important;
  font-size: 13px;
  line-height: 1.5;
  margin: 0;
  padding: 12px 14px;
}

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

  .login-brand-panel {
    border-bottom: 1px solid #334155;
    border-right: 0;
    padding: 28px 24px;
  }

  .login-form-panel {
    padding: 28px 24px;
  }
}

.install-modal-root {
  align-items: start;
  display: grid;
  inset: 0;
  justify-items: center;
  overflow-y: auto;
  padding: 24px 20px;
  position: fixed;
  z-index: 900;
}

.install-modal-root:not([hidden]) {
  display: grid;
}

.install-modal-backdrop {
  animation: dialog-fade-in 180ms ease;
  backdrop-filter: blur(4px);
  background: rgb(15 23 42 / 42%);
  inset: 0;
  position: fixed;
}

.install-modal-card {
  animation: dialog-slide-in 220ms ease;
  border-radius: var(--radius-lg);
  margin: auto 0;
  max-height: none;
  position: relative;
  width: min(100%, 760px);
  z-index: 1;
}

.install-modal-header {
  margin-bottom: 4px;
}

.install-modal-root[data-busy="true"] [data-install-dismiss] {
  pointer-events: none;
}

.dialog-root {
  align-items: center;
  display: grid;
  inset: 0;
  justify-items: center;
  padding: 20px;
  position: fixed;
  z-index: 1000;
}

.dialog-root:not([hidden]) {
  display: grid;
}

.dialog-backdrop {
  animation: dialog-fade-in 180ms ease;
  backdrop-filter: blur(4px);
  background: rgb(15 23 42 / 42%);
  inset: 0;
  position: absolute;
}

.dialog-card {
  animation: dialog-slide-in 220ms ease;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 420px;
  padding: 24px;
  position: relative;
  text-align: center;
  width: min(100%, 420px);
  z-index: 1;
}

.dialog-icon {
  align-items: center;
  border-radius: 999px;
  display: grid;
  font-size: 22px;
  font-weight: 700;
  height: 52px;
  justify-items: center;
  margin: 0 auto 14px;
  width: 52px;
}

.dialog-root.is-danger .dialog-icon {
  background: var(--danger-soft);
  color: var(--danger);
}

.dialog-root.is-info .dialog-icon {
  background: var(--primary-soft);
  color: var(--primary);
}

.dialog-title {
  font-size: 1.15rem;
  margin: 0 0 8px;
}

.dialog-message {
  color: var(--text-secondary);
  line-height: 1.55;
  margin: 0 0 22px;
}

.dialog-message strong {
  color: var(--text);
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.dialog-actions button {
  min-width: 112px;
}

.dialog-root.is-alert-only .dialog-actions button.secondary {
  display: none;
}

.dialog-root.is-danger #dialogConfirm {
  background: var(--danger);
}

.dialog-root.is-danger #dialogConfirm:hover {
  background: #b91c1c;
}

@keyframes dialog-fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes dialog-slide-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 1100px) {
  #output {
    height: clamp(280px, 42vh, 520px);
  }

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

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

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

@media (min-width: 900px) {
  .topbar-btn--ghost:not(.topbar-btn--logout) {
    padding: 0;
    width: 40px;
  }

  .topbar-btn--ghost:not(.topbar-btn--logout) .topbar-btn-text {
    display: none;
  }
}

@media (max-width: 820px) {
  .page-shell {
    padding: 12px;
  }

  .topbar {
    grid-template-columns: 1fr;
    padding: 12px 14px;
  }

  .brand-tagline {
    display: none;
  }

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

  .topbar-btn--primary {
    grid-column: 1 / -1;
    min-height: 44px;
  }

  .topbar-btn {
    min-height: 42px;
    width: 100%;
  }

  .topbar-btn-text {
    display: inline;
  }

  .summary-grid,
  .bootstrap-form {
    grid-template-columns: 1fr;
  }

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

  .servers-panel .panel-header {
    align-items: stretch;
  }

  .logs-monitor-btn {
    justify-content: center;
    width: 100%;
  }

  .form-actions,
  .form-actions button {
    width: 100%;
  }
}
