*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  margin: 0;
  background: #0f1923;
  color: #e8edf2;
  min-height: 100dvh;
}

/* ── Header (primary bar: brand + page links + user) ── */
header {
  background: #122531;
  border-bottom: 2px solid #1e3a4a;
  padding: 0 24px;
  display: flex;
  align-items: stretch;
  gap: 0;
  height: 52px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-right: 24px;
  border-right: 1px solid #1e3a4a;
  flex-shrink: 0;
}

.header-brand a {
  text-decoration: none;
}

.header-brand h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #7ecfff;
  white-space: nowrap;
}

/* Primary nav: page-level links inside header */
header nav {
  display: flex;
  align-items: stretch;
  flex: 1;
  padding-left: 8px;
}

header nav a.nav-page {
  display: flex;
  align-items: center;
  background: transparent;
  border-bottom: 3px solid transparent;
  border-top: none;
  border-left: none;
  border-right: none;
  border-radius: 0;
  color: #6b8fa3;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0 16px;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
header nav a.nav-page:hover { color: #b8d4e8; }
header nav a.nav-page.active {
  color: #7ecfff;
  border-bottom-color: #7ecfff;
}

/* ── Tab bar (secondary bar: within-page tabs) ── */
#tab-nav {
  background: #0f1923;
  border-bottom: 1px solid #1e3a4a;
  padding: 0 24px;
  display: flex;
  align-items: stretch;
  overflow-x: auto;
  scrollbar-width: none;
  height: 40px;
}
#tab-nav::-webkit-scrollbar { display: none; }

#tab-nav button {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: #6b8fa3;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0 14px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
#tab-nav button:hover { color: #b8d4e8; }
#tab-nav button.active {
  color: #7ecfff;
  border-bottom-color: #7ecfff;
}

#user-label {
  font-size: 0.78rem;
  color: #6b8fa3;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding-left: 16px;
  flex-shrink: 0;
}

.signout-btn {
  background: transparent;
  border: none;
  color: #6b8fa3;
  font-size: 0.78rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
  font-family: inherit;
}
.signout-btn:hover { color: #e8edf2; }

/* ── Main layout ── */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px;
}

/* ── Login card ── */
#login-view {
  max-width: 380px;
  margin: 80px auto;
  background: #122531;
  border: 1px solid #1e3a4a;
  border-radius: 10px;
  padding: 32px;
}

#login-view h2 {
  margin: 0 0 20px;
  font-size: 1.1rem;
  color: #7ecfff;
}

/* ── Cards ── */
.card {
  background: #122531;
  border: 1px solid #1e3a4a;
  border-radius: 8px;
  padding: 20px 24px;
}

.card h2 {
  margin: 0 0 18px;
  font-size: 1rem;
  font-weight: 700;
  color: #7ecfff;
  border-bottom: 1px solid #1e3a4a;
  padding-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.card h2 .card-actions { margin-left: auto; }

/* ── Forms ── */
.form-group { margin-bottom: 14px; }

label {
  display: block;
  margin-bottom: 5px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #8da8bc;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"] {
  width: 100%;
  padding: 8px 11px;
  background: #0f1923;
  border: 1px solid #2a4a60;
  border-radius: 5px;
  color: #e8edf2;
  font-size: 0.95rem;
  font-family: inherit;
}

input[type="number"] { width: 100px; }

input:focus {
  outline: none;
  border-color: #7ecfff;
}

/* ── Buttons ── */
button {
  background: #1a6fa8;
  color: #fff;
  border: none;
  padding: 9px 18px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  transition: background 0.15s;
}

button:hover:not(:disabled) { background: #1d82c5; }
button:disabled { opacity: 0.4; cursor: default; }

button.danger { background: #8b1f2a; }
button.danger:hover:not(:disabled) { background: #a8242f; }

button.ghost {
  background: transparent;
  border: 1px solid #2a4a60;
  color: #8da8bc;
  padding: 5px 12px;
  font-size: 0.8rem;
}
button.ghost:hover:not(:disabled) { background: #1e3a4a; color: #e8edf2; }

button.success { background: #163d25; color: #4ade80; border: 1px solid #2a6640; }
button.success:hover:not(:disabled) { background: #1d5232; }

/* ── Messages ── */
.error-msg {
  background: #3a1820;
  border: 1px solid #6b2030;
  color: #f08090;
  border-radius: 5px;
  padding: 10px 14px;
  font-size: 0.88rem;
  margin-bottom: 14px;
}

.info-msg { color: #6b8fa3; font-size: 0.88rem; padding: 8px 0; }

/* ── Badges ── */
.badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge.active    { background: #163d25; color: #4ade80; border: 1px solid #2a6640; }
.badge.revoked   { background: #3a1820; color: #f08090; border: 1px solid #6b2030; }
.badge.exhausted { background: #272d35; color: #8da8bc; border: 1px solid #3a4f5e; }
.badge.pending   { background: #2a2010; color: #f0c060; border: 1px solid #6b5020; }
.badge.provisioned { background: #163d25; color: #4ade80; border: 1px solid #2a6640; }
.badge.failed    { background: #3a1820; color: #f08090; border: 1px solid #6b2030; }
.badge.demo      { background: #1a2a40; color: #7ecfff; border: 1px solid #2a4a60; }
.badge.owner     { background: #251a3a; color: #c4a0ff; border: 1px solid #4a2a6a; }
.badge.admin     { background: #1a2a40; color: #7ecfff; border: 1px solid #2a4a60; }

/* ── Tab panels ── */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Table-like lists ── */
.data-list { display: flex; flex-direction: column; gap: 8px; }

.data-row {
  background: #0f1923;
  border: 1px solid #1e3a4a;
  border-radius: 6px;
  padding: 12px 16px;
}

.data-row:hover { border-color: #2a5a70; }

.row-top {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.row-id {
  font-family: "Courier New", monospace;
  font-size: 0.9rem;
  font-weight: 700;
  color: #aee4ff;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-meta {
  font-size: 0.78rem;
  color: #6b8fa3;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: center;
}

.row-meta span { white-space: nowrap; }

details.row-detail { font-size: 0.78rem; color: #6b8fa3; margin-top: 6px; }
details.row-detail summary { cursor: pointer; color: #5ba8d4; user-select: none; }
details.row-detail ul { margin: 6px 0 0 14px; padding: 0; }
details.row-detail li { font-family: monospace; font-size: 0.82rem; margin-bottom: 2px; color: #8da8bc; }

.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }

/* ── Two-col layout ── */
@media (min-width: 640px) {
  .two-col { display: grid; grid-template-columns: 260px 1fr; gap: 24px; align-items: start; }
}

/* ── Stat strip ── */
.stat-strip {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.stat-card {
  background: #122531;
  border: 1px solid #1e3a4a;
  border-radius: 8px;
  padding: 14px 20px;
  flex: 1 1 140px;
  min-width: 120px;
}

.stat-card .stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: #7ecfff;
  line-height: 1.1;
}

.stat-card .stat-label {
  font-size: 0.75rem;
  color: #6b8fa3;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}

/* ── Filter bar ── */
.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
  align-items: center;
}

.filter-bar input[type="text"] {
  width: auto;
  flex: 1 1 200px;
  padding: 6px 10px;
  font-size: 0.85rem;
}

.filter-bar select {
  background: #0f1923;
  border: 1px solid #2a4a60;
  border-radius: 5px;
  color: #e8edf2;
  font-size: 0.85rem;
  padding: 6px 10px;
  font-family: inherit;
  cursor: pointer;
}

.filter-bar select:focus { outline: none; border-color: #7ecfff; }

/* ── Progress bars ── */
.progress-wrap {
  background: #0f1923;
  border: 1px solid #1e3a4a;
  border-radius: 4px;
  height: 10px;
  overflow: hidden;
  flex: 1 1 auto;
  min-width: 80px;
}
.progress-fill {
  height: 100%;
  border-radius: 4px;
  background: #1a6fa8;
  transition: width 0.3s;
}
.progress-fill.warn  { background: #a87a1a; }
.progress-fill.danger { background: #8b1f2a; }

.resource-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid #1a2a38;
  font-size: 0.85rem;
}
.resource-row:last-child { border-bottom: none; }
.resource-label { width: 160px; flex-shrink: 0; color: #8da8bc; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.resource-value { width: 90px; flex-shrink: 0; text-align: right; color: #e8edf2; font-family: monospace; font-size: 0.82rem; }

/* ── Log viewer ── */
#log-output {
  font-family: "Courier New", monospace;
  font-size: 0.8rem;
  line-height: 1.55;
  background: #080e15;
  border: 1px solid #1e3a4a;
  border-radius: 6px;
  padding: 14px 16px;
  overflow-y: auto;
  max-height: 600px;
  white-space: pre-wrap;
  word-break: break-all;
}
.log-line { display: flex; gap: 10px; padding: 1px 0; }
.log-line:hover { background: #0f1923; }
.log-ts   { color: #4a6a80; flex-shrink: 0; }
.log-daemon { flex-shrink: 0; width: 88px; color: #4a7a9b; overflow: hidden; text-overflow: ellipsis; }
.log-lvl  { flex-shrink: 0; width: 44px; font-weight: 700; }
.log-lvl.info  { color: #6b8fa3; }
.log-lvl.warn  { color: #f0c060; }
.log-lvl.error { color: #f08090; }
.log-msg  { color: #c8dde8; flex: 1; }
