:root {
  --bg-main: #0d1117;
  --bg-card: rgba(22, 27, 34, 0.85);
  --bg-card-hover: rgba(30, 38, 48, 0.95);
  --border: rgba(255, 255, 255, 0.1);
  --border-focus: #58a6ff;
  --text-main: #f0f6fc;
  --text-muted: #8b949e;
  --text-dim: #6e7681;
  --primary: #238636;
  --primary-hover: #2ea043;
  --primary-text: #ffffff;
  --danger: #da3633;
  --danger-hover: #f85149;
  --warning: #d29922;
  --info: #388bfd;
  --input-bg: rgba(13, 17, 23, 0.8);
  --header-bg: rgba(22, 27, 34, 0.85);
  --badge-bg: rgba(110, 118, 129, 0.2);
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

html.light {
  --bg-main: #f6f8fa;
  --bg-card: rgba(255, 255, 255, 0.9);
  --bg-card-hover: #ffffff;
  --border: rgba(0, 0, 0, 0.12);
  --border-focus: #0969da;
  --text-main: #1f2328;
  --text-muted: #57606a;
  --text-dim: #8c959f;
  --primary: #1f883d;
  --primary-hover: #1a7f37;
  --primary-text: #ffffff;
  --danger: #cf222e;
  --danger-hover: #a40e26;
  --warning: #9a6700;
  --info: #0969da;
  --input-bg: #ffffff;
  --header-bg: rgba(255, 255, 255, 0.9);
  --badge-bg: rgba(0, 0, 0, 0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  background-image: radial-gradient(circle at 50% 0%, rgba(35, 134, 54, 0.12) 0%, transparent 60%);
}

.mono { font-family: var(--font-mono); }

/* ── Container & Header ── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-main);
}
.brand-logo {
  min-width: 38px;
  height: 36px;
  padding: 0 4px;
  background: linear-gradient(135deg, #2ea043, #238636);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  box-shadow: 0 2px 10px rgba(35, 134, 54, 0.3);
}
.brand-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
}
.btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-focus);
}
.btn-primary {
  background: var(--primary);
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--primary-text);
}
.btn-primary:hover {
  background: var(--primary-hover);
  border-color: rgba(255, 255, 255, 0.2);
}
.btn-danger {
  background: var(--danger);
  border-color: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}
.btn-danger:hover {
  background: var(--danger-hover);
}
.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 6px;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Status Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
}
.badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.badge.started, .badge.running, .badge.ready, .badge.badge-success {
  background: rgba(46, 160, 67, 0.15);
  color: #3fb950;
  border: 1px solid rgba(46, 160, 67, 0.3);
}
.badge.started .badge-dot, .badge.running .badge-dot, .badge.ready .badge-dot, .badge.badge-success .badge-dot {
  background: #3fb950;
  box-shadow: 0 0 8px #3fb950;
}

.badge.stopped, .badge.exited, .badge.badge-danger, .badge.badge-neutral {
  background: rgba(110, 118, 129, 0.15);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.badge.stopped .badge-dot, .badge.exited .badge-dot, .badge.badge-danger .badge-dot, .badge.badge-neutral .badge-dot {
  background: var(--text-muted);
}

.badge.starting, .badge.creating, .badge.setting_up, .badge.badge-warning {
  background: rgba(210, 153, 34, 0.15);
  color: #d29922;
  border: 1px solid rgba(210, 153, 34, 0.3);
}
.badge.starting .badge-dot, .badge.creating .badge-dot, .badge.setting_up .badge-dot, .badge.badge-warning .badge-dot {
  background: #d29922;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.9); opacity: 0.7; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.7; }
}

/* ── Cards & Grid ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.card-title {
  font-size: 18px;
  font-weight: 600;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

/* ── Banner Info ── */
.banner {
  background: rgba(56, 139, 253, 0.1);
  border: 1px solid rgba(56, 139, 253, 0.3);
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
}

/* ── Form Controls ── */
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text-main);
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s;
}
.form-control:focus {
  border-color: var(--border-focus);
}

/* ── Tables ── */
.table-responsive {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  text-align: left;
}
th {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
}
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* ── Table Pagination ── */
.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 14px;
  margin-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}
.table-pagination-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.table-pagination-select {
  padding: 5px 10px;
  font-size: 13px;
  border-radius: 6px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  color: var(--text-main);
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}
.table-pagination-select:focus {
  border-color: var(--border-focus);
}
.table-pagination-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.table-pagination-pages {
  font-weight: 500;
  color: var(--text-main);
  padding: 0 4px;
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.active {
  display: flex;
}
.modal-box {
  width: 100%;
  max-width: 480px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
  animation: modalIn 0.2s ease-out;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

/* ── Tabs Navigation ── */
.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  overflow-x: auto;
}
.tab-btn {
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.tab-btn.active {
  color: var(--text-main);
  border-bottom-color: var(--primary);
}

/* ── Toast Notifications ── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(8px);
  animation: toastIn 0.3s ease-out;
}
.toast.success { background: #238636; color: #fff; }
.toast.error { background: #da3633; color: #fff; }
.toast.info { background: #1f6feb; color: #fff; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Active Sandboxes Chart Styles ── */
.graph-toggle-group {
  display: flex;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
}
.btn-graph-toggle {
  border: none !important;
  padding: 4px 12px !important;
  font-size: 12px !important;
  border-radius: 6px !important;
  font-weight: 500 !important;
  background: transparent !important;
  color: var(--text-muted) !important;
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-graph-toggle.active {
  background: var(--primary) !important;
  color: #ffffff !important;
  font-weight: 600 !important;
}

.graph-metrics-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.graph-metric-pill {
  background: var(--badge-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
}
.graph-metric-pill .metric-label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 600;
  letter-spacing: 0.3px;
}
.graph-metric-pill .metric-val {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
  margin: 3px 0 1px 0;
}
.graph-metric-pill .metric-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.chart-wrapper {
  position: relative;
  width: 100%;
  background: rgba(13, 17, 23, 0.45);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 14px 12px 14px;
  overflow: visible;
}
html.light .chart-wrapper {
  background: rgba(246, 248, 250, 0.75);
}

.chart-container {
  width: 100%;
  position: relative;
}

.chart-svg {
  width: 100%;
  height: 230px;
  overflow: visible;
  display: block;
}

.chart-tooltip {
  position: absolute;
  z-index: 50;
  background: var(--bg-card);
  border: 1px solid var(--border-focus);
  border-radius: 8px;
  padding: 8px 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap;
  backdrop-filter: blur(10px);
  transform: translate(-50%, -100%);
  margin-top: -12px;
  transition: opacity 0.15s ease-out;
}
.chart-tooltip-header {
  font-weight: 700;
  color: var(--text-main);
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.chart-tooltip-body {
  color: var(--text-muted);
}
.chart-tooltip-highlight {
  font-weight: 700;
  color: #3fb950;
}
html.light .chart-tooltip-highlight {
  color: #1a7f37;
}

/* Hover effects for SVG columns / points */
.chart-col-hover {
  cursor: pointer;
  fill: transparent;
  transition: fill 0.15s ease, stroke 0.15s ease;
}
.chart-col-hover:hover, .chart-col-hover.active {
  fill: rgba(56, 139, 253, 0.12);
}
.chart-col-hover.selected-column {
  fill: rgba(88, 166, 255, 0.22) !important;
  stroke: #58a6ff !important;
  stroke-width: 1.5 !important;
  stroke-dasharray: 2 2 !important;
}
.chart-dot {
  transition: r 0.2s cubic-bezier(0.16, 1, 0.3, 1), fill 0.2s;
  cursor: pointer;
}
.chart-dot:hover, .chart-dot.active {
  r: 6.5 !important;
  fill: #58a6ff !important;
  stroke: #ffffff !important;
  stroke-width: 2px !important;
}

/* ── Floating Theme Button for Login/Public Pages ── */
.theme-btn-floating {
  position: fixed;
  top: 18px;
  right: 20px;
  z-index: 100;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}
