:root {
  --ui-zoom: 0.8;
  --bg-0: #050c17;
  --bg-1: #07111f;
  --bg-2: #0b1729;
  --panel: #0d1828;
  --panel-2: #101f34;
  --border: #23344c;
  --text: #d7e3f4;
  --muted: #8ca1bc;
  --accent: #56b4ff;
  --ok: #3be37c;
  --bad: #ff6c6c;
  --warn: #f4c76a;
  --terminal: #2be06f;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  max-width: 100vw;
  height: 100%;
  min-height: 100%;
}

body {
  margin: 0;
  zoom: var(--ui-zoom);
  overflow-x: hidden;
  overflow-y: hidden;
  color: var(--text);
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  background:
    radial-gradient(1200px 520px at 12% -8%, #102a48 0%, rgba(16, 42, 72, 0) 60%),
    linear-gradient(180deg, var(--bg-1), var(--bg-0));
}

.terminal-app {
  width: calc(100vw / var(--ui-zoom));
  max-width: calc(100vw / var(--ui-zoom));
  height: calc(100vh / var(--ui-zoom));
  max-height: calc(100vh / var(--ui-zoom));
  padding: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 10px;
  overflow: hidden;
}

.top-strip {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}

.brand-block h1 {
  margin: 0;
  letter-spacing: 1.6px;
  font-size: 36px;
  line-height: 1;
  font-family: "IBM Plex Mono", "JetBrains Mono", monospace;
  background: linear-gradient(
    90deg,
    #6bf7ff 0%,
    #57b3ff 22%,
    #64ff9c 47%,
    #ffe67a 71%,
    #ff8d88 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
  background-size: 240% 100%;
  color: transparent;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 18px rgba(87, 179, 255, 0.18);
  text-transform: uppercase;
  animation: polyelon-spectrum-shift 7s linear infinite;
  will-change: background-position;
}

@keyframes polyelon-spectrum-shift {
  0% {
    background-position: 0% 50%;
  }
  100% {
    background-position: 200% 50%;
  }
}

.brand-block p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.top-metrics {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.metric {
  display: flex;
  align-items: baseline;
  gap: 7px;
  font-family: "IBM Plex Mono", "JetBrains Mono", monospace;
  font-size: 13px;
}

.metric span {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  font-size: 11px;
}

.metric strong {
  color: var(--text);
  font-weight: 600;
}

#topNext {
  color: var(--ok);
  text-shadow: 0 0 10px rgba(59, 227, 124, 0.25);
}

.pill {
  border: 1px solid var(--border);
  background: var(--panel-2);
  border-radius: 8px;
  padding: 2px 8px;
  font-size: 12px;
}

.pill.running {
  color: var(--ok);
  border-color: rgba(59, 227, 124, 0.5);
}

.pill.stopped {
  color: #ff8f8f;
  border-color: rgba(255, 108, 108, 0.5);
}

.control-grid-wrap,
.log-shell {
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(14, 25, 41, 0.95), rgba(9, 18, 31, 0.96));
  border-radius: 10px;
}

.strip-label {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 1px;
  font-weight: 700;
  min-width: 44px;
}


.control-grid-wrap {
  padding: 10px;
  display: flex;
  gap: 10px;
  align-items: flex-end;
  justify-content: space-between;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
  flex: 1;
}

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  min-width: 0;
}

input,
select,
.chip {
  border: 1px solid #30455f;
  background: var(--panel-2);
  color: var(--text);
  border-radius: 7px;
  min-height: 35px;
  padding: 7px 9px;
  font-family: "IBM Plex Mono", "JetBrains Mono", monospace;
  font-size: 14px;
  width: 100%;
  min-width: 0;
}

.chip {
  display: flex;
  align-items: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

input::placeholder {
  color: #6c84a2;
}

.control-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 0;
}

.action-combo-label {
  width: 320px;
  max-width: 100%;
  font-size: 10px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.action-combo-label select {
  min-height: 40px;
  font-size: 15px;
}

.action-combo-label select.status-running {
  color: var(--ok);
  border-color: rgba(59, 227, 124, 0.55);
}

.action-combo-label select.status-stopped {
  color: #ff9b9b;
  border-color: rgba(255, 108, 108, 0.55);
}

button {
  border: 1px solid #324a68;
  background: #1a2940;
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-family: "IBM Plex Mono", "JetBrains Mono", monospace;
  font-size: 14px;
  line-height: 1;
}

button:hover {
  border-color: var(--accent);
}

.btn-good {
  border-color: rgba(59, 227, 124, 0.45);
  color: var(--ok);
}

.btn-bad {
  border-color: rgba(255, 108, 108, 0.45);
  color: #ffa4a4;
}

.log-shell {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  min-width: 0;
  overflow: hidden;
}

.log-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.log-toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.view-toggle {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.view-toggle button {
  padding: 6px 10px;
}

.view-toggle button.active {
  border-color: var(--accent);
  color: #d9ebff;
  background: #20344e;
}

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

#logsBox,
#statusBox {
  margin: 0;
  flex: 1;
  min-height: 0;
  border: 0;
  border-radius: 0 0 10px 10px;
  padding: 12px;
  overflow: auto;
  max-width: 100%;
  color: var(--terminal);
  background: #07101e;
  font-family: "IBM Plex Mono", "JetBrains Mono", monospace;
  font-size: 13px;
  line-height: 1.48;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

#statusBox {
  background: #0b1727;
  color: #9ec0e8;
  font-size: 12px;
  line-height: 1.45;
}

.hidden {
  display: none !important;
}

@media (max-width: 1400px) {
  .control-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  body {
    zoom: 1;
    overflow-y: auto;
  }

  .terminal-app {
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: none;
    min-height: 100vh;
    padding: 10px;
    gap: 8px;
    overflow: visible;
  }

  .top-strip {
    flex-direction: column;
    align-items: flex-start;
  }

  .top-metrics {
    justify-content: flex-start;
  }

  .control-grid-wrap {
    flex-direction: column;
    align-items: stretch;
  }

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

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

  #logsBox {
    min-height: 320px;
  }
}
