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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0d1117;
  color: #c9d1d9;
  min-height: 100vh;
}

/* Login Page */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-container {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
}

.login-container h1 {
  text-align: center;
  margin-bottom: 24px;
  color: #58a6ff;
  font-size: 1.5rem;
}

.form-group {
  margin-bottom: 16px;
}

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

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.875rem;
  color: #8b949e;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #c9d1d9;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: #58a6ff;
}

.form-group textarea {
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: 0.85rem;
  min-height: 120px;
  resize: vertical;
}

#loginForm button {
  width: 100%;
  padding: 10px;
  background: #238636;
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  margin-top: 8px;
  transition: background 0.2s;
}

#loginForm button:hover {
  background: #2ea043;
}

#loginForm button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.error-msg {
  margin-top: 12px;
  padding: 10px;
  background: #490202;
  border: 1px solid #f85149;
  border-radius: 6px;
  color: #f85149;
  font-size: 0.875rem;
  text-align: center;
}

/* ===== App Layout with Sidebar ===== */
.app-layout {
  display: flex;
  height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 220px;
  min-width: 220px;
  background: #161b22;
  border-right: 1px solid #30363d;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar .logo {
  padding: 16px;
  font-size: 1.1rem;
  font-weight: 700;
  color: #58a6ff;
  border-bottom: 1px solid #30363d;
  text-align: center;
}

.sidebar nav {
  flex: 1;
  padding: 8px 0;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: #8b949e;
  text-decoration: none;
  font-size: 0.9rem;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.sidebar nav a:hover {
  color: #c9d1d9;
  background: #21262d;
}

.sidebar nav a.active {
  color: #58a6ff;
  background: #0d1117;
  border-left-color: #58a6ff;
}

.sidebar nav a .icon {
  width: 18px;
  text-align: center;
  font-size: 1rem;
}

.sidebar .sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid #30363d;
}

.sidebar .sidebar-footer .btn-logout {
  width: 100%;
  padding: 8px;
  background: transparent;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #8b949e;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.sidebar .sidebar-footer .btn-logout:hover {
  border-color: #f85149;
  color: #f85149;
}

/* Main content area */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.logs-main-content {
  display: flex;
  flex-direction: column;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid #30363d;
  background: #161b22;
}

.page-header h2 {
  font-size: 1.2rem;
  color: #c9d1d9;
}

.page-body {
  flex: 1;
  padding: 20px 24px;
  overflow-y: auto;
}

.logs-page-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== Cards ===== */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.card {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 20px;
}

.card .card-label {
  font-size: 0.8rem;
  color: #8b949e;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.card .card-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: #c9d1d9;
}

.card .card-value.green { color: #3fb950; }
.card .card-value.yellow { color: #e3b341; }
.card .card-value.red { color: #f85149; }
.card .card-value.blue { color: #58a6ff; }

/* ===== Tables ===== */
.table-container {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 20px;
}

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

.table-container th {
  text-align: left;
  padding: 12px 16px;
  background: #0d1117;
  font-size: 0.8rem;
  color: #8b949e;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #30363d;
}

.table-container td {
  padding: 10px 16px;
  font-size: 0.9rem;
  border-bottom: 1px solid #21262d;
}

.table-container tr:last-child td {
  border-bottom: none;
}

.table-container tr:hover td {
  background: #21262d;
}

/* ===== Status badges ===== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-healthy { background: #0e3a1e; color: #3fb950; }
.badge-degraded { background: #3d2e00; color: #e3b341; }
.badge-down { background: #490202; color: #f85149; }
.badge-unknown { background: #21262d; color: #8b949e; }
.badge-online { background: #0e3a1e; color: #3fb950; }
.badge-stopped { background: #490202; color: #f85149; }
.badge-success { background: #0e3a1e; color: #3fb950; }
.badge-failed { background: #490202; color: #f85149; }
.badge-running { background: #0c2d6b; color: #58a6ff; }
.badge-pending { background: #21262d; color: #8b949e; }
.badge-timeout { background: #3d2e00; color: #e3b341; }
.badge-open { background: #490202; color: #f85149; }
.badge-closed { background: #0e3a1e; color: #3fb950; }
.badge-half_open { background: #3d2e00; color: #e3b341; }

/* ===== Buttons ===== */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: opacity 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary { background: #238636; color: #fff; }
.btn-primary:hover { background: #2ea043; }
.btn-danger { background: #da3633; color: #fff; }
.btn-danger:hover { background: #f85149; }
.btn-secondary { background: #30363d; color: #c9d1d9; }
.btn-secondary:hover { background: #484f58; }
.btn-small { padding: 4px 10px; font-size: 0.8rem; }

.btn-start { background: #238636; color: #fff; }
.btn-stop { background: #da3633; color: #fff; }
.btn-clear { background: #30363d; color: #c9d1d9; }

/* ===== Modals ===== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  width: 100%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 24px;
}

.modal h3 {
  margin-bottom: 16px;
  color: #c9d1d9;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ===== Controls (logs page) ===== */
.controls {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.controls input,
.controls select {
  flex: 1;
  min-width: 200px;
  padding: 8px 12px;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #c9d1d9;
  font-size: 0.95rem;
  outline: none;
}

.controls input:focus,
.controls select:focus {
  border-color: #58a6ff;
}

.controls button {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: opacity 0.2s;
}

.controls button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.status-bar {
  margin-bottom: 8px;
  font-size: 0.8rem;
  color: #8b949e;
}

.status-default { color: #8b949e; }
.status-warning { color: #e3b341; }
.status-success { color: #3fb950; }
.status-error { color: #f85149; }

/* ===== Console ===== */
.console {
  flex: 1;
  background: #010409;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 12px;
  overflow-y: auto;
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: 0.82rem;
  line-height: 1.5;
}

.log-line {
  white-space: pre-wrap;
  word-break: break-all;
}

.log-line .ts { color: #484f58; }
.log-line .pid { color: #8b949e; }
.log-line .stream-stdout { color: #c9d1d9; }
.log-line .stream-stderr { color: #f85149; }
.log-line .stream-system { color: #58a6ff; }

/* ===== Execution output ===== */
.exec-output {
  background: #010409;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 12px;
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: 0.82rem;
  line-height: 1.5;
  max-height: 400px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.exec-output .stdout { color: #c9d1d9; }
.exec-output .stderr { color: #f85149; }

/* ===== Empty state ===== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #8b949e;
}

.empty-state p {
  margin-bottom: 12px;
}

/* ===== Toast / alert ===== */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 12px 20px;
  border-radius: 6px;
  font-size: 0.9rem;
  z-index: 2000;
  transition: opacity 0.3s;
}

.toast-success { background: #0e3a1e; color: #3fb950; border: 1px solid #238636; }
.toast-error { background: #490202; color: #f85149; border: 1px solid #da3633; }

/* ===== Scrollbar ===== */
.console::-webkit-scrollbar,
.page-body::-webkit-scrollbar,
.exec-output::-webkit-scrollbar {
  width: 8px;
}

.console::-webkit-scrollbar-track,
.page-body::-webkit-scrollbar-track,
.exec-output::-webkit-scrollbar-track {
  background: #010409;
}

.console::-webkit-scrollbar-thumb,
.page-body::-webkit-scrollbar-thumb,
.exec-output::-webkit-scrollbar-thumb {
  background: #30363d;
  border-radius: 4px;
}

/* ===== Toolbar ===== */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.toolbar-spaced {
  margin-bottom: 20px;
}

.toolbar-tight {
  margin-bottom: 8px;
}

.card-spaced {
  margin-bottom: 20px;
}

.exec-output-container-spaced {
  margin-bottom: 20px;
}

.muted-text {
  color: #8b949e;
}

.no-margin {
  margin: 0;
}

.toolbar select {
  padding: 8px 12px;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #c9d1d9;
  font-size: 0.9rem;
  outline: none;
}

/* ===== Section ===== */
.section-title {
  font-size: 1rem;
  color: #c9d1d9;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #21262d;
}

/* ===== Confirm dialog ===== */
.confirm-text {
  color: #c9d1d9;
  margin-bottom: 16px;
  line-height: 1.5;
}

/* ===== Settings page ===== */
.settings-card { max-width: 600px; }
.settings-card-spaced { max-width: 600px; margin-top: 16px; }
.settings-table { width: 100%; }
.settings-label { color: #8b949e; padding: 8px 0; }
.no-border { border: none; }
