:root {
  --bg: #0e1116;
  --panel: #161b22;
  --panel-2: #1f2630;
  --border: #2a313c;
  --text: #d6dde6;
  --muted: #8a96a6;
  --accent: #4ea1ff;
  --green: #3fb950;
  --yellow: #d29922;
  --red: #f85149;
  --err-bg: rgba(248, 81, 73, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  font-size: 14px;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
}

button:hover {
  background: #283040;
}

input[type="text"],
input[type="password"] {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 4px;
  outline: none;
}

input[type="text"]:focus,
input[type="password"]:focus {
  border-color: var(--accent);
}

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

.error {
  color: var(--red);
  margin: 8px 0 0;
}

/* ----- Login ----- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 28px 32px;
  width: 320px;
}

.login-card h1 {
  margin: 0 0 18px;
  font-size: 18px;
  font-weight: 600;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-card label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.login-card input {
  font-size: 14px;
}

.login-card button {
  margin-top: 6px;
  background: var(--accent);
  border-color: var(--accent);
  color: #06121f;
  font-weight: 600;
}

.login-card button:hover {
  filter: brightness(1.05);
}

/* ----- Viewer ----- */
.viewer-body {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.topbar .title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.env-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
}

.env-badge.env-staging {
  background: #1d3a5f;
  color: #cfe6ff;
  border-color: #2a557a;
}

.env-badge.env-testing {
  background: #4a3a14;
  color: #ffe6b3;
  border-color: #6b5520;
}

.env-badge.env-gpm {
  background: #3d1d4a;
  color: #ecd1ff;
  border-color: #5a2c6b;
}

.env-badge.env-dev {
  background: #1f3a25;
  color: #c8f0d2;
  border-color: #2c5634;
}

.topbar .status {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  flex: 0 0 auto;
}

@keyframes pulse-running {
  0%   { box-shadow: 0 0 0 0   rgba(78, 161, 255, 0.55); }
  70%  { box-shadow: 0 0 0 10px rgba(78, 161, 255, 0);    }
  100% { box-shadow: 0 0 0 0   rgba(78, 161, 255, 0);    }
}

@keyframes pulse-active {
  0%   { box-shadow: 0 0 0 0   rgba(63, 185, 80, 0.55); }
  70%  { box-shadow: 0 0 0 8px  rgba(63, 185, 80, 0);    }
  100% { box-shadow: 0 0 0 0   rgba(63, 185, 80, 0);    }
}

.dot-running {
  background: var(--accent);
  animation: pulse-running 1.4s ease-out infinite;
}

.dot-active {
  background: var(--green);
  animation: pulse-active 2s ease-out infinite;
}

.dot-ok {
  background: var(--green);
}

.dot-idle {
  background: var(--yellow);
}

.dot-failed {
  background: var(--red);
  box-shadow: 0 0 0 3px rgba(248, 81, 73, 0.18);
}

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

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

.timer {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--muted);
}

.timer-running {
  color: #cfe6ff;
  background: rgba(78, 161, 255, 0.12);
  border-color: rgba(78, 161, 255, 0.45);
}

.timer-ok {
  color: #c8f0d2;
  background: rgba(63, 185, 80, 0.12);
  border-color: rgba(63, 185, 80, 0.45);
}

.timer-failed {
  color: #ffd0cd;
  background: rgba(248, 81, 73, 0.12);
  border-color: rgba(248, 81, 73, 0.45);
}

.layout {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

.sidebar {
  width: 280px;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--border);
  min-height: 0;
}

.sidebar-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex: 0 0 auto;
}

.deploy-list {
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
  flex: 1 1 auto;
}

.sidebar-empty {
  padding: 18px 14px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
}

.deploy-item {
  padding: 10px 14px 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  border-left: 3px solid transparent;
  transition: background 0.08s ease;
}

.deploy-item:hover {
  background: var(--panel-2);
}

.deploy-item.selected {
  background: rgba(78, 161, 255, 0.10);
  border-left-color: var(--accent);
}

.deploy-row1 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.deploy-row1 strong {
  font-weight: 600;
}

.deploy-row2 {
  font-size: 11px;
  margin-top: 3px;
  padding-left: 16px;
  font-variant-numeric: tabular-nums;
}

.item-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: var(--muted);
}

.item-dot.dot-ok       { background: var(--green); }
.item-dot.dot-failed   { background: var(--red); }
.item-dot.dot-aborted  { background: var(--muted); }
.item-dot.dot-running  {
  background: var(--accent);
  animation: pulse-running 1.4s ease-out infinite;
}
.item-dot.dot-active {
  background: var(--green);
  animation: pulse-active 2s ease-out infinite;
}
.item-dot.dot-idle    { background: var(--yellow); }
.item-dot.dot-missing { background: var(--red); }
.item-dot.dot-unknown { background: var(--muted); }

.main-pane {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.toolbar #filter-input {
  flex: 1 1 auto;
  max-width: 400px;
}

.toolbar .cb {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.log {
  flex: 1 1 auto;
  overflow: auto;
  padding: 8px 16px;
  background: var(--bg);
}

.log .empty {
  color: var(--muted);
  font-style: italic;
  padding: 24px 0;
  text-align: center;
}

#log-pre {
  margin: 0;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12.5px;
  line-height: 1.45;
  white-space: pre;
}

.line {
  display: block;
  padding: 0 4px;
  border-radius: 2px;
}

.line.err {
  background: var(--err-bg);
}

.line .err {
  color: var(--red);
  font-weight: 600;
}

.line.hidden {
  display: none;
}
