:root {
  color-scheme: light;
  --bg: #f3f5f4;
  --surface: #ffffff;
  --surface-muted: #eef2f0;
  --text: #17201f;
  --text-muted: #5f6b68;
  --border: #d9e0dd;
  --sidebar: #17201f;
  --sidebar-text: #e7efec;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --warning: #a15c05;
  --danger: #b42318;
  --success: #18794e;
  --radius: 8px;
  --shadow: 0 12px 32px rgb(23 32 31 / 8%);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
}

.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-text);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  padding: 0 8px;
}

.brand strong {
  display: block;
  font-size: 18px;
}

.brand span,
.sidebar small {
  color: #9fb2ac;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav button {
  width: 100%;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #c8d5d1;
  padding: 10px 12px;
  text-align: left;
}

.nav button.active,
.nav button:hover {
  background: rgb(255 255 255 / 10%);
  color: #ffffff;
}

.main {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.topbar h1 {
  margin: 0 0 4px;
  font-size: 24px;
  letter-spacing: 0;
}

.topbar p {
  margin: 0;
  color: var(--text-muted);
}

.token-bar {
  display: flex;
  gap: 8px;
  align-items: center;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 9px 10px;
}

textarea {
  min-height: 84px;
  resize: vertical;
}

button.primary,
button.secondary,
button.ghost,
button.danger {
  min-height: 38px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 8px 13px;
  font-weight: 600;
}

button.primary {
  background: var(--accent);
  color: white;
}

button.primary:hover {
  background: var(--accent-strong);
}

button.secondary {
  background: var(--text);
  color: white;
}

button.ghost {
  background: white;
  border-color: var(--border);
  color: var(--text);
}

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

.section {
  display: none;
}

.section.active {
  display: block;
}

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

.section-head h2 {
  margin: 0;
  font-size: 18px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.stat span {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 8px;
}

.stat strong {
  font-size: 26px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.panel-body {
  padding: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
  font-size: 14px;
}

th {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  background: #fafcfb;
}

tr:last-child td {
  border-bottom: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-muted);
  color: var(--text-muted);
}

.pill.active,
.pill.success {
  background: #e7f5ee;
  color: var(--success);
}

.pill.deploying,
.pill.dispatched {
  background: #fff3d6;
  color: var(--warning);
}

.pill.failed,
.pill.deploy_failed {
  background: #fdecea;
  color: var(--danger);
}

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

.empty {
  padding: 32px 16px;
  color: var(--text-muted);
  text-align: center;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgb(14 20 19 / 48%);
}

.modal.open {
  display: flex;
}

.modal-card {
  width: min(760px, 100%);
  max-height: 92vh;
  overflow: auto;
  background: white;
  border-radius: var(--radius);
  box-shadow: 0 24px 80px rgb(0 0 0 / 22%);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-head h2 {
  margin: 0;
  font-size: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 20px;
}

.field {
  display: grid;
  gap: 6px;
}

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

.field label {
  font-size: 13px;
  font-weight: 600;
}

.field small {
  color: var(--text-muted);
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 8px;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}

.detail-header h2 {
  margin: 0 0 6px;
}

.detail-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--text-muted);
  font-size: 13px;
}

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.tabs button {
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  padding: 10px 12px;
  color: var(--text-muted);
}

.tabs button.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.notice {
  display: none;
  margin-bottom: 16px;
  border-radius: 6px;
  padding: 10px 12px;
  background: #fff3d6;
  color: #804a02;
}

.notice.show {
  display: block;
}

.error {
  color: var(--danger);
}

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

  .sidebar {
    position: static;
  }

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

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

  .topbar,
  .detail-header {
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .main {
    padding: 16px;
  }

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

  .panel {
    overflow-x: auto;
  }

  table {
    min-width: 720px;
  }
}

/* MorphStage-inspired console theme */
:root {
  color-scheme: dark;
  --bg: #05070d;
  --surface: rgb(13 18 34 / 78%);
  --surface-muted: rgb(28 36 66 / 56%);
  --text: #e4e9f7;
  --text-muted: #8a97c8;
  --border: rgb(121 148 255 / 22%);
  --sidebar: rgb(7 10 20 / 82%);
  --sidebar-text: #dfe6ff;
  --accent: #5b7cff;
  --accent-strong: #7c9cff;
  --warning: #f5c26b;
  --danger: #ff7b8a;
  --success: #5ee0a0;
  --shadow: 0 18px 50px rgb(0 0 0 / 38%);
}

body.bg-neon-field {
  background-color: #05070d;
  background-image:
    linear-gradient(135deg, rgb(91 124 255 / 22%), transparent 48%),
    linear-gradient(200deg, rgb(167 139 250 / 18%), transparent 55%),
    linear-gradient(160deg, rgb(34 211 238 / 14%), transparent 52%),
    linear-gradient(220deg, rgb(124 58 237 / 14%), transparent 60%);
  background-size: 150% 150%, 170% 170%, 140% 140%, 160% 160%;
  animation: neonDrift 18s ease-in-out infinite alternate;
}

body.bg-grid-subtle::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgb(121 148 255 / 6%) 1px, transparent 1px),
    linear-gradient(90deg, rgb(121 148 255 / 6%) 1px, transparent 1px);
  background-size: 48px 48px;
}

@keyframes neonDrift {
  0% {
    background-position: 0% 0%, 100% 0%, 0% 100%, 100% 100%;
  }
  100% {
    background-position: 30% 20%, 70% 40%, 20% 80%, 80% 30%;
  }
}

.is-hidden {
  display: none !important;
}

.brand-gradient,
.text-gradient {
  background: linear-gradient(90deg, #8bb4ff 0%, #c3a7ff 45%, #75e7f0 100%);
  background-clip: text;
  color: transparent;
}

.glass-card {
  background: linear-gradient(180deg, rgb(20 26 48 / 82%), rgb(13 18 34 / 82%));
  border: 1px solid rgb(121 148 255 / 22%);
  box-shadow: var(--shadow), inset 0 1px 0 rgb(255 255 255 / 6%);
  backdrop-filter: blur(14px);
}

.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  z-index: 1;
}

.login-panel {
  width: min(440px, 100%);
  border-radius: 18px;
  padding: 34px;
  text-align: center;
  position: relative;
  z-index: 1;
}

.login-brand {
  color: white;
  font-size: 27px;
  font-weight: 800;
  letter-spacing: 0;
}

.login-panel h1 {
  margin: 26px 0 6px;
  color: #fff;
  font-size: 22px;
}

.login-panel > p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

.login-form {
  display: grid;
  gap: 18px;
  margin-top: 26px;
  text-align: left;
}

.input-with-icon {
  position: relative;
}

.input-with-icon i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  z-index: 1;
}

.input-with-icon input {
  padding-left: 40px;
}

.login-button {
  width: 100%;
  min-height: 46px;
  font-weight: 700;
}

.login-note {
  margin-top: 18px !important;
  font-size: 12px !important;
}

.login-error {
  display: none;
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgb(180 35 24 / 16%);
  color: #ffb4bd;
  font-size: 13px;
}

.login-error.show {
  display: block;
}

.app-shell {
  position: relative;
  z-index: 1;
  background: transparent;
}

.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(18px);
}

.brand strong {
  color: white;
}

.nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
  color: var(--text-muted);
}

.nav button i {
  width: 16px;
  text-align: center;
}

.nav button.active,
.nav button:hover {
  background: linear-gradient(135deg, rgb(91 124 255 / 20%), rgb(167 139 250 / 12%));
  border-color: rgb(121 148 255 / 24%);
  color: white;
}

.topbar h1,
.section-head h2,
.panel-header strong,
.detail-header h2,
.modal-head h2 {
  color: white;
}

.operator-bar,
.actions,
.token-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.operator-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: #cdd7ff;
  background: rgb(255 255 255 / 4%);
  font-size: 13px;
}

input,
select,
textarea {
  border-color: var(--border);
  background: rgb(255 255 255 / 4%);
  color: var(--text);
  backdrop-filter: blur(8px);
}

input::placeholder,
textarea::placeholder {
  color: #69769f;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 16px rgb(91 124 255 / 28%);
}

button.primary,
button.secondary,
button.ghost,
button.danger,
.btn-glass {
  border-radius: 8px;
  transition: all 0.25s ease;
}

button.primary,
.btn-glass-primary {
  border-color: rgb(121 148 255 / 45%);
  background: linear-gradient(135deg, rgb(91 124 255 / 78%), rgb(167 139 250 / 62%));
  color: white;
  box-shadow: 0 10px 28px rgb(91 124 255 / 28%);
}

button.primary:hover,
.btn-glass-primary:hover {
  background: linear-gradient(135deg, #6d8cff, #a98bff);
  transform: translateY(-1px);
}

button.ghost,
.btn-glass-ghost {
  border-color: var(--border);
  background: rgb(255 255 255 / 4%);
  color: var(--text);
}

button.ghost:hover,
.btn-glass-ghost:hover {
  border-color: rgb(167 139 250 / 58%);
  background: rgb(167 139 250 / 10%);
}

.btn-glass {
  position: relative;
  overflow: hidden;
  padding: 9px 14px;
}

.btn-glass::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 -130%;
  width: 65%;
  background: linear-gradient(120deg, transparent, rgb(255 255 255 / 18%), transparent);
  transform: skewX(-20deg);
  transition: left 0.55s ease;
}

.btn-glass:hover::before {
  left: 130%;
}

.stat,
.panel,
.modal-card {
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgb(20 26 48 / 78%), rgb(13 18 34 / 82%));
  box-shadow: var(--shadow), inset 0 1px 0 rgb(255 255 255 / 5%);
  backdrop-filter: blur(14px);
}

.stat {
  border-radius: 12px;
}

.panel,
.modal-card {
  border-radius: 14px;
}

.panel-header {
  border-bottom-color: var(--border);
}

.panel-body {
  background: transparent;
}

th {
  background: rgb(255 255 255 / 3%);
  color: #8fa0d2;
}

td {
  color: #d8def5;
}

th,
td {
  border-bottom-color: rgb(121 148 255 / 13%);
}

tr:hover td {
  background: rgb(91 124 255 / 5%);
}

td a {
  color: #8bb4ff;
}

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

.modal {
  background: rgb(3 5 10 / 72%);
}

.tabs {
  border-bottom-color: var(--border);
}

.tabs button {
  color: var(--text-muted);
}

.tabs button.active {
  color: #a9bcff;
  border-bottom-color: #7c9cff;
}

.notice {
  border: 1px solid rgb(245 194 107 / 26%);
  background: rgb(161 92 5 / 18%);
  color: #ffd89b;
}

.notice.error,
.error {
  color: #ffb4bd;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #9fb0e3;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.manual-hero {
  padding: 28px;
  border-radius: 16px;
  margin-bottom: 18px;
}

.manual-hero h2 {
  margin: 12px 0 8px;
  color: white;
  font-size: 28px;
}

.manual-hero p {
  margin: 0;
  max-width: 760px;
  color: var(--text-muted);
  line-height: 1.7;
}

.manual-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.manual-step {
  border-radius: 14px;
  padding: 20px;
  min-height: 240px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.step-number {
  color: #8bb4ff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.manual-step h3,
.manual-panel h3 {
  margin: 12px 0 8px;
  color: white;
  font-size: 17px;
}

.manual-step p,
.manual-panel p,
.manual-panel li {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.65;
}

.manual-step p {
  flex: 1;
}

.manual-step code {
  color: #b9c7ff;
  word-break: break-all;
}

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

.manual-panel {
  border-radius: 14px;
  padding: 22px;
}

.check-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.check-list li {
  position: relative;
  padding-left: 24px;
}

.check-list li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: #5ee0a0;
  font-weight: 700;
}

.manual-panel details {
  border-top: 1px solid var(--border);
  padding: 12px 0;
}

.manual-panel details:first-of-type {
  border-top: 0;
}

.manual-panel summary {
  cursor: pointer;
  color: #dfe6ff;
  font-weight: 600;
}

.manual-panel details p {
  margin: 8px 0 0;
}

@media (max-width: 1100px) {
  .manual-steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .manual-steps,
  .manual-grid {
    grid-template-columns: 1fr;
  }

  .manual-step {
    min-height: 0;
  }

  .manual-hero {
    padding: 22px;
  }

  .manual-hero h2 {
    font-size: 23px;
  }
}
