:root {
  color-scheme: light dark;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.4;
  background-color: #0f1115;
  color: #f8f8f2;
}

body {
  margin: 0;
  background-color: #0f1115;
}

.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

.site-header,
.site-footer {
  background: linear-gradient(120deg, #1c1f2b, #232943);
  color: #f1f5ff;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.main-nav {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.main-nav a {
  color: #d5dcff;
  text-decoration: none;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.main-nav a.active {
  background: linear-gradient(120deg, #5294ff, #7c4dff);
  color: #fff;
}

.ghost-button {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.main-nav form button {
  padding: 0.35rem 0.9rem;
  font-size: 0.85rem;
}

.login-body {
  background: radial-gradient(circle at top, #202540, #0f1115);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: #1a1e2b;
  padding: 2rem;
  border-radius: 16px;
  width: min(360px, 90%);
  box-shadow: 0 15px 45px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-form button {
  width: 100%;
}

.site-header h1 {
  margin: 0;
}

.card {
  background: #1a1e2b;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.grid {
  display: grid;
  gap: 1.5rem;
}

.layout-two {
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
}

.form-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

label {
  display: flex;
  flex-direction: column;
  font-size: 0.9rem;
  gap: 0.25rem;
}

input,
select,
button,
pre {
  font: inherit;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  color: inherit;
}

input:focus,
select:focus,
button:focus {
  outline: 2px solid #5294ff;
  outline-offset: 2px;
}

button {
  cursor: pointer;
  border: none;
  background: linear-gradient(120deg, #5294ff, #7c4dff);
  color: #fff;
  transition: opacity 0.2s ease;
}

button:hover {
  opacity: 0.9;
}

button.danger {
  background: linear-gradient(120deg, #ff6b6b, #ff3b3b);
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
}

.terminal {
  max-height: 480px;
  overflow: auto;
  background: #050607;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.table-scroll {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  text-align: left;
  padding: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

thead {
  background: rgba(255, 255, 255, 0.05);
}

td.actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

td.actions form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.flash-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem 0;
}

.flash {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 0.5rem;
}

.flash-success {
  background: rgba(82, 214, 151, 0.15);
  border: 1px solid rgba(82, 214, 151, 0.3);
}

.flash-error {
  background: rgba(255, 99, 71, 0.15);
  border: 1px solid rgba(255, 99, 71, 0.3);
}

.state-running td {
  background: rgba(82, 214, 151, 0.05);
}

.state-stopped td {
  background: rgba(255, 99, 71, 0.05);
}

/* Light theme overrides */
body.theme-light {
  background: #f5f6fb;
  color: #0a0c16;
}

body.theme-light .site-header,
body.theme-light .site-footer {
  background: linear-gradient(120deg, #e2e7ff, #f5f9ff);
  color: #0a0c16;
}

body.theme-light .card,
body.theme-light .login-card,
body.theme-light .terminal-controls {
  background: #ffffff;
  color: #0a0c16;
  border-color: rgba(15, 17, 21, 0.08);
  box-shadow: 0 10px 30px rgba(15, 17, 21, 0.08);
}

body.theme-light .terminal-panel,
body.theme-light .terminal-panel header {
  background: #f1f3fb;
  border-color: rgba(15, 17, 21, 0.08);
}

body.theme-light .terminal-output {
  color: #0a0c16;
}

body.theme-light input,
body.theme-light select,
body.theme-light button,
body.theme-light pre {
  background: rgba(10, 12, 22, 0.03);
  color: inherit;
  border-color: rgba(10, 12, 22, 0.15);
}

body.theme-light button {
  color: #fff;
}

body.theme-light .ghost-button {
  color: #0a0c16;
  border-color: rgba(10, 12, 22, 0.4);
  background: rgba(10, 12, 22, 0.05);
}

body.theme-light .terminal-panel header button,
body.theme-light .terminal-run {
  color: #fff;
}

body.theme-light .terminal-panel header button {
  color: #0a0c16;
  background: rgba(10, 12, 22, 0.05);
}

body.theme-light .flash-success {
  background: rgba(82, 214, 151, 0.25);
}

body.theme-light .flash-error {
  background: rgba(255, 99, 71, 0.25);
}

body.theme-light .terminal-panel header,
body.theme-light .container-detail details {
  border-color: rgba(10, 12, 22, 0.08);
}

.container-detail h2 {
  margin-bottom: 0.25rem;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.back-link {
  color: #97b1ff;
  text-decoration: none;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}

.detail-grid ul {
  padding-left: 1rem;
}

.container-detail details {
  margin-top: 1rem;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.container-detail pre {
  max-height: 320px;
  overflow: auto;
}

.terminal-wrapper {
  display: flex;
  gap: 1.5rem;
  flex-direction: column;
  min-height: calc(100vh - 220px);
}

.terminal-controls {
  background: #1a1e2b;
  border-radius: 12px;
  padding: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

#terminal-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.terminal-panel {
  flex: 1;
  background: #050607;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
}

.terminal-panel header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.terminal-output {
  flex: 1;
  margin: 0;
  padding: 1rem;
  overflow: auto;
  font-family: "Fira Code", "SFMono-Regular", Menlo, monospace;
  font-size: 0.9rem;
  background: transparent;
}

.terminal-run {
  align-self: end;
}

.terminal-target select:disabled {
  opacity: 0.5;
}

@media (max-width: 768px) {
  .wrap {
    padding: 1rem;
  }

  .header-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .main-nav {
    width: 100%;
    flex-wrap: wrap;
  }

  .card {
    padding: 1rem;
  }

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

  td.actions {
    flex-direction: row;
    flex-wrap: wrap;
  }

  td.actions form {
    flex-direction: column;
    align-items: stretch;
    width: 48%;
  }

  td.actions label {
    align-self: flex-start;
  }

  #terminal-form {
    grid-template-columns: 1fr;
  }

  .terminal-panel {
    min-height: 60vh;
  }
}
