:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-2: #f6f7f8;
  --panel-hover: #eef0f2;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #0a0a0a;
  --muted: #6b7280;
  --accent: #0a0a0a;
  --btn-bg: #0a0a0a;
  --btn-fg: #ffffff;
  --shadow: 0 1px 3px rgba(0,0,0,0.04), 0 6px 24px rgba(0,0,0,0.04);
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --term: #7c3aed;
  --info: #2563eb;
}

html[data-theme="dark"] {
  --bg: #0b0d10;
  --panel: #111418;
  --panel-2: #171a1f;
  --panel-hover: #1d2127;
  --border: #262a31;
  --border-strong: #383c44;
  --text: #e7e9ec;
  --muted: #8b9099;
  --accent: #ffffff;
  --btn-bg: #ffffff;
  --btn-fg: #0a0a0a;
  --shadow: 0 1px 3px rgba(0,0,0,0.4), 0 6px 24px rgba(0,0,0,0.3);
  --ok: #4ade80;
  --warn: #fbbf24;
  --err: #f87171;
  --term: #a78bfa;
  --info: #60a5fa;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.mono, code, pre {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
a { color: var(--text); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }

/* Inline icons */
.icon {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 1.8;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.icon-sm { width: 13px; height: 13px; stroke-width: 2; }
.icon-lg { width: 22px; height: 22px; }
.icon-xl { width: 48px; height: 48px; stroke-width: 1.4; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.2px;
}
.brand .icon { color: var(--text); }
.controls { display: flex; align-items: center; gap: 18px; }
.controls label { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.controls select {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border-strong);
  padding: 5px 10px;
  border-radius: 5px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}
.controls select:hover { border-color: var(--text); }
.link {
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
}
.link:hover { color: var(--text); }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.theme-toggle:hover {
  color: var(--text);
  border-color: var(--text);
  background: var(--panel-2);
}
.theme-toggle .icon { width: 15px; height: 15px; stroke-width: 1.8; }
html[data-theme="dark"] .theme-toggle .icon-sun { display: inline; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
html:not([data-theme="dark"]) .theme-toggle .icon-sun { display: none; }
html:not([data-theme="dark"]) .theme-toggle .icon-moon { display: inline; }
#user { font-size: 13px; }
#status { font-size: 13px; }

#app {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 1600px;
  margin: 0 auto;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
}
.panel h2 {
  margin: 0 0 12px 0;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel h2 .icon { color: var(--text); }
.panel h2 .muted {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  margin-left: auto;
  font-size: 12px;
}

.grid {
  width: 100%;
  border-collapse: collapse;
}
.grid th, .grid td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-weight: 400;
}
.grid th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 600;
}
.grid tr:last-child td { border-bottom: none; }
.grid tr:hover td { background: var(--panel-2); }

.ns {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 14px;
  overflow: hidden;
}
.ns-head {
  padding: 12px 18px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}
.ns-head:hover { background: var(--panel-hover); }
.ns-head .name {
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ns-head .counts { display: flex; gap: 14px; font-size: 13px; }
.ns-body { padding: 14px 18px; }
.ns.collapsed .ns-body { display: none; }
.ns.collapsed .ns-head { border-bottom: none; }

.wl-group { margin-top: 12px; }
.wl-group:first-child { margin-top: 0; }
.wl-group h3 {
  font-size: 11px;
  font-weight: 600;
  margin: 0 0 8px 0;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.wl-group h3 .icon { color: var(--text); }

.wl {
  border-bottom: 1px dashed var(--border);
}
.wl:last-child { border-bottom: none; }

.wl-head {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto minmax(120px, 1fr);
  gap: 14px;
  padding: 9px 6px;
  align-items: center;
  cursor: pointer;
  user-select: none;
  border-radius: 4px;
}
.wl-head:hover { background: var(--panel-2); }
.wl-head.static { cursor: default; }
.wl-head.static:hover { background: transparent; }

.wl-head .caret {
  color: var(--muted);
  font-size: 10px;
  text-align: center;
  width: 12px;
}
.wl-head .name {
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13.5px;
}
.wl-head .name .kind {
  color: var(--muted);
  margin-right: 8px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 600;
}
.wl-head .replicas { font-size: 13px; color: var(--muted); white-space: nowrap; }
.wl-head .replicas strong { color: var(--text); font-weight: 600; }
.wl-head .pods-mini {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  justify-content: flex-end;
}
.wl-head .pods-mini .pod {
  padding: 0;
  border: none;
  background: transparent;
}
.wl-head .pods-mini .pod .dot { width: 9px; height: 9px; }

.wl-body {
  display: none;
  padding: 6px 0 14px 30px;
}
.wl.expanded .wl-body { display: block; }
.wl-body .grid th,
.wl-body .grid td { padding: 6px 10px; font-size: 13px; }
.wl-body .grid .mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; }

.pod {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  font-size: 12px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--panel);
  cursor: default;
}
.pod .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}
.pod.running .dot { background: var(--ok); }
.pod.starting .dot { background: var(--warn); animation: pulse 1.4s ease-in-out infinite; }
.pod.terminating .dot { background: var(--term); animation: pulse 1.4s ease-in-out infinite; }
.pod.failed .dot, .pod.crashloopbackoff .dot, .pod.imagepullbackoff .dot, .pod.errimagepull .dot { background: var(--err); }
.pod.succeeded .dot { background: var(--info); }

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

.empty { color: var(--muted); font-style: italic; padding: 4px 0; }

/* Node status colors */
.node-ready { color: var(--ok); font-weight: 500; }
.node-notready { color: var(--err); font-weight: 500; }

/* Issues badge */
.issues-badge {
  color: var(--err);
  font-weight: 600;
}

/* Login */
body.login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--panel-2);
}
.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px 44px;
  text-align: center;
  min-width: 320px;
  box-shadow: var(--shadow);
}
.login-card .logo {
  margin: 0 auto 18px auto;
  width: 56px;
  height: 56px;
  color: var(--text);
}
.login-card h1 {
  margin: 0 0 6px 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.2px;
}
.login-card p { margin: 0 0 26px 0; font-size: 13px; color: var(--muted); }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  background: var(--btn-bg);
  color: var(--btn-fg);
  border-radius: 6px;
  font-weight: 500;
  font-size: 14px;
  transition: opacity 0.15s;
}
.btn:hover { text-decoration: none; opacity: 0.85; }
.btn .icon { color: var(--btn-fg); }
