:root {
  --bg: #0d1117;
  --bg-sidebar: #161b22;
  --bg-header: #161b22;
  --bg-input: #21262d;
  --bg-hover: #1f2937;
  --bg-active: #1a3a5c;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --text-link: #58a6ff;
  --border: #30363d;
  --accent: #58a6ff;
  --green: #3fb950;
  --red: #f85149;
  --yellow: #d29922;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

.hidden { display: none !important; }

/* Login */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
}

.login-box {
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 40px;
  width: 340px;
}

.login-box h1 {
  font-size: 20px;
  margin-bottom: 24px;
  text-align: center;
}

.login-box input {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.login-box input:focus { border-color: var(--accent); }

.login-box button {
  width: 100%;
  padding: 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 600;
}

.login-box button:hover { opacity: 0.9; }

.error {
  color: var(--red);
  font-size: 13px;
  margin-top: 10px;
  text-align: center;
}

/* Header */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 48px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
}

header h1 { font-size: 16px; font-weight: 600; }

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}

.header-right span { color: var(--text-muted); }

.header-right a {
  color: var(--text-link);
  text-decoration: none;
  font-size: 13px;
}

/* Container */
.container {
  display: flex;
  height: calc(100vh - 48px);
}

/* Sidebar */
#sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 8px 0;
}

.app-group { margin-bottom: 4px; }

.app-name {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.app-name:hover { color: var(--text); }
.app-name .arrow { font-size: 10px; transition: transform 0.15s; }
.app-name.open .arrow { transform: rotate(90deg); }

.log-list { display: none; }
.app-group.open .log-list { display: block; }

.log-item {
  display: block;
  padding: 6px 16px 6px 36px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  border-left: 2px solid transparent;
}

.log-item:hover { background: var(--bg-hover); }
.log-item.active {
  background: var(--bg-active);
  border-left-color: var(--accent);
}

/* Main */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Toolbar */
#toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-sidebar);
  flex-wrap: wrap;
  gap: 8px;
}

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

#log-title {
  font-size: 14px;
  font-weight: 600;
}

#live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--green);
  font-weight: 600;
}

.dot {
  width: 8px;
  height: 8px;
  background: var(--green);
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

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

#search-input {
  padding: 5px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 13px;
  width: 180px;
  outline: none;
}

#search-input:focus { border-color: var(--accent); }

#line-count {
  padding: 5px 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}

#toolbar button {
  padding: 5px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

#toolbar button:hover { background: var(--bg-hover); }

#tail-btn.active {
  background: var(--green);
  color: #000;
  border-color: var(--green);
  font-weight: 600;
}

/* Log content */
#log-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  font-family: 'JetBrains Mono', 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.6;
}

#log-lines {
  white-space: pre-wrap;
  word-wrap: break-word;
  color: var(--text);
}

.line-num {
  color: var(--text-muted);
  user-select: none;
  display: inline-block;
  width: 50px;
  text-align: right;
  margin-right: 12px;
}

/* HTTP status code colors */
.http-2xx { color: #3fb950; font-weight: 600; }
.http-3xx { color: #58a6ff; font-weight: 600; }
.http-4xx { color: #d29922; font-weight: 600; }
.http-5xx { color: #f85149; font-weight: 600; }
.http-1xx { color: #8b949e; }

/* Log level colors */
.log-error { color: #f85149; font-weight: 600; }
.log-warn { color: #d29922; font-weight: 600; }
.log-info { color: #58a6ff; }
.log-ok { color: #3fb950; font-weight: 600; }
.log-debug { color: #8b949e; }
.log-cron { color: #bc8cff; font-weight: 600; }
.log-http { color: #58a6ff; font-weight: 600; }
.log-source { color: #79c0ff; }
.log-method { color: #79c0ff; font-weight: 600; }
.log-key { color: #8b949e; }
.log-value { color: #e6edf3; font-weight: 500; }
.log-ai { color: #f0883e; }
.log-regime { color: #56d4dd; }
.log-time { color: #8b949e; }

.decision-flow-row {
  display: block;
  margin: 8px 0;
}

.decision-flow-row .line-num {
  color: #58a6ff;
}

.decision-card {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  max-width: calc(100% - 70px);
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: 6px;
  background: #111820;
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.025);
  vertical-align: top;
}

.decision-title {
  font-weight: 700;
  margin-right: 4px;
  color: #e6edf3;
}

.decision-cycle { border-left-color: #58a6ff; background: rgba(88, 166, 255, 0.08); }
.decision-good { border-left-color: #3fb950; background: rgba(63, 185, 80, 0.08); }
.decision-warn { border-left-color: #d29922; background: rgba(210, 153, 34, 0.10); }
.decision-bad { border-left-color: #f85149; background: rgba(248, 81, 73, 0.10); }
.decision-info { border-left-color: #bc8cff; background: rgba(188, 140, 255, 0.08); }
.decision-neutral { border-left-color: #8b949e; }

.decision-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border: 1px solid #30363d;
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  white-space: nowrap;
}

.decision-chip b {
  color: #8b949e;
  font-weight: 600;
}

.decision-chip em {
  color: #e6edf3;
  font-style: normal;
  font-weight: 650;
}

.chip-good {
  border-color: rgba(63, 185, 80, 0.55);
  background: rgba(63, 185, 80, 0.12);
}

.chip-bad {
  border-color: rgba(248, 81, 73, 0.65);
  background: rgba(248, 81, 73, 0.12);
}

.chip-warn {
  border-color: rgba(210, 153, 34, 0.65);
  background: rgba(210, 153, 34, 0.12);
}

.chip-muted {
  border-color: rgba(139, 148, 158, 0.35);
  background: rgba(139, 148, 158, 0.08);
}

.chip-code em {
  color: #8b949e;
  font-weight: 500;
}

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

.highlight {
  background: rgba(210, 153, 34, 0.3);
  border-radius: 2px;
  padding: 0 2px;
}

/* Jump to bottom */
#jump-bottom {
  position: absolute;
  bottom: 20px;
  right: 20px;
  padding: 8px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

#jump-bottom:hover { opacity: 0.9; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Modal overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 999;
}

/* Responsive */
@media (max-width: 768px) {
  #sidebar { width: 180px; min-width: 180px; }
  #search-input { width: 120px; }
}
