/* SafeCPM Admin — design tokens copied from SafePaaS DevOps app.css.
   Per M4-A directive: use DevOps tokens directly (not safepaas-brand overrides),
   so SafeCPM looks like a sibling of devops.safepaas.com. */

:root {
  --bg: #eef0f6;
  --bg-alt: #e8ebf3;
  --white: #ffffff;
  --surface: #ffffff;
  --canvas: #fafbfe;
  --border: #d0d4e3;
  --border-light: #f1f3f8;
  --text: #1a1d2e;
  --text-strong: #3d4160;
  --muted: #4a4e68;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-light: #eef2ff;
  --accent-border: #c7d2fe;
  --green: #16a34a;
  --green-bg: #f0fdf4;
  --green-border: #bbf7d0;
  --orange: #d97706;
  --orange-bg: #fffbeb;
  --orange-border: #fde68a;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --red-border: #fecaca;
  --blue: #2563eb;
  --blue-bg: #eff6ff;
  --blue-border: #bfdbfe;
  --gray-bg: #ebedf2;
  --gray-text: #6b7089;
  --gray-border: #c0c5d8;
  --shadow: 0 1px 4px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg: 0 4px 16px rgba(0,0,0,.12);
  --r: 12px;
  --f: 'Inter', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { font-family: var(--f); }
body {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: var(--f); cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
code, pre { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 12px; }

/* ============ Login ============ */
.login-container {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  padding: 24px;
}
.login-box {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}
.login-box .logo {
  font-size: 22px; font-weight: 700; color: var(--accent);
  text-align: center; margin-bottom: 4px;
}
.login-box .lede {
  font-size: 13px; color: var(--muted); text-align: center; margin-bottom: 28px;
}
.login-box .btn-google {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--accent); color: var(--white);
  border: 0; border-radius: 8px;
  padding: 12px 18px;
  font-size: 14px; font-weight: 600;
  min-height: 44px;
  transition: background .15s;
}
.login-box .btn-google:hover { background: var(--accent-hover); }
.login-box .btn-google:focus-visible { outline: 3px solid var(--accent-border); outline-offset: 2px; }
.login-box .footer-note {
  margin-top: 28px; padding-top: 20px;
  border-top: 1px solid var(--border-light);
  font-size: 12px; color: var(--muted); text-align: center;
}

/* ============ Banners ============ */
.banner {
  border: 1px solid;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 18px;
  font-size: 13px;
  display: flex; gap: 10px; align-items: flex-start;
}
.banner .banner-icon {
  font-weight: 700; flex-shrink: 0;
  font-size: 14px; line-height: 18px;
}
.banner .banner-body { flex: 1; }
.banner .banner-title { font-weight: 600; margin-bottom: 2px; }
.banner-error       { background: var(--red-bg); border-color: var(--red-border); color: var(--red); }
.banner-permission  { background: var(--orange-bg); border-color: var(--orange-border); color: var(--orange); }
.banner-offline     { background: var(--gray-bg); border-color: var(--gray-border); color: var(--gray-text); }
.banner-info        { background: var(--blue-bg); border-color: var(--blue-border); color: var(--blue); }
/* CPM-52 Phase 2: warn + success variants added for the provisioning wizard's
   intermediate states (partial PKCE → orange-warn) and finalize (green-success). */
.banner-warn        { background: var(--orange-bg); border-color: var(--orange-border); color: var(--orange); }
.banner-success     { background: var(--green-bg); border-color: var(--green-border); color: var(--green); }
.banner-loading     { background: var(--blue-bg); border-color: var(--blue-border); color: var(--blue); }

/* ============ App shell ============ */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 14px 32px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 10;
}
.topbar .brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; color: var(--accent); font-size: 15px;
}
.topbar .brand-pill {
  background: var(--accent-light); color: var(--accent);
  padding: 3px 8px; border-radius: 6px;
  font-size: 11px; font-weight: 600; letter-spacing: .3px;
}
.topbar .user-meta {
  display: flex; align-items: center; gap: 16px;
  color: var(--muted); font-size: 13px;
}
.topbar .user-meta strong { color: var(--text-strong); font-weight: 500; }
.topbar .btn-logout {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  padding: 6px 12px; border-radius: 6px; font-size: 12px;
  min-height: 32px; transition: background .15s, color .15s;
}
.topbar .btn-logout:hover { background: var(--bg-alt); color: var(--text); }

.page { padding: 28px 32px 64px; max-width: 1080px; width: 100%; margin: 0 auto; }
.page-title { font-size: 24px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.page-lede { font-size: 14px; color: var(--muted); margin-bottom: 24px; }

/* ============ Tabs ============ */
.tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  overflow-x: auto;
}
.tab {
  background: transparent; border: 0;
  padding: 10px 16px;
  font-size: 13px; font-weight: 500; color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  display: inline-flex; align-items: center; gap: 8px;
  white-space: nowrap;
  min-height: 40px;
  transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--text-strong); }
.tab[aria-selected="true"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.tab .badge-count {
  display: inline-block; min-width: 20px;
  padding: 1px 6px; border-radius: 10px;
  background: var(--accent-light); color: var(--accent);
  font-size: 11px; font-weight: 600; text-align: center;
}
.tab[aria-selected="false"] .badge-count { background: var(--gray-bg); color: var(--gray-text); }

/* ============ Setting cards ============ */
.cards-grid { display: flex; flex-direction: column; gap: 18px; }
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px 22px;
  box-shadow: var(--shadow);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 8px; flex-wrap: wrap;
}
.card-title {
  font-family: 'SF Mono', monospace;
  font-size: 13px; font-weight: 600; color: var(--text-strong);
}
.card-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge {
  font-size: 10px; font-weight: 600;
  padding: 2px 8px; border-radius: 10px;
  letter-spacing: .3px; text-transform: uppercase;
}
.badge-sensitive { background: var(--orange-bg); color: var(--orange); border: 1px solid var(--orange-border); }
.badge-set      { background: var(--green-bg);  color: var(--green);  border: 1px solid var(--green-border); }
.badge-unset    { background: var(--gray-bg);   color: var(--gray-text); border: 1px solid var(--gray-border); }
.card-description { font-size: 13px; color: var(--muted); margin-bottom: 14px; }

.field-label {
  display: block;
  font-size: 11px; font-weight: 500; color: var(--muted);
  text-transform: uppercase; letter-spacing: .5px;
  margin-bottom: 6px;
}
.field-input,
.field-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--white);
  color: var(--text);
  font-family: var(--f);
  font-size: 14px;
  min-height: 44px;
  transition: border-color .15s, box-shadow .15s;
}
.field-input:focus,
.field-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-border);
}
.field-textarea {
  font-family: 'SF Mono', monospace; font-size: 12px;
  min-height: 88px; resize: vertical;
}
.field-redacted {
  font-family: 'SF Mono', monospace;
  font-size: 13px;
  color: var(--gray-text);
  letter-spacing: 4px;
  user-select: none;
}
.field-redacted-row {
  padding: 10px 14px;
  background: var(--gray-bg);
  border: 1px solid var(--gray-border);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; min-height: 44px;
}
.field-redacted-row .btn-reveal {
  background: transparent; border: 0;
  color: var(--accent); font-size: 12px; font-weight: 500;
  padding: 4px 8px;
}
.field-redacted-row .btn-reveal:hover { text-decoration: underline; }

.card-footer {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  margin-top: 16px; padding-top: 12px;
  border-top: 1px solid var(--border-light);
}
.audit-meta {
  font-size: 11px; color: var(--muted);
}
.audit-meta .meta-strong { color: var(--text-strong); font-weight: 500; }

.btn-save {
  background: var(--accent); color: var(--white);
  border: 0; border-radius: 8px;
  padding: 8px 18px;
  font-size: 13px; font-weight: 600;
  min-height: 36px;
  transition: background .15s;
}
.btn-save:hover:not(:disabled) { background: var(--accent-hover); }
.btn-save:focus-visible { outline: 3px solid var(--accent-border); outline-offset: 2px; }

.btn-secondary {
  background: var(--white); color: var(--text-strong);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px; font-weight: 500;
  min-height: 36px;
}
.btn-secondary:hover { background: var(--bg-alt); }

/* ============ Skeleton + empty + error states ============ */
.skel { background: var(--bg-alt); border-radius: 4px; animation: shimmer 1.4s ease-in-out infinite; }
@keyframes shimmer {
  0%, 100% { opacity: .55; }
  50% { opacity: .9; }
}
.skel-line  { height: 14px; margin-bottom: 8px; }
.skel-line.short { width: 40%; }
.skel-input { height: 44px; margin-top: 6px; }

.empty-state, .loading-state, .offline-state {
  background: var(--white);
  border: 1px dashed var(--border);
  border-radius: var(--r);
  padding: 64px 32px;
  text-align: center;
  color: var(--muted);
}
.empty-state .empty-title,
.offline-state .empty-title { font-size: 16px; font-weight: 600; color: var(--text-strong); margin-bottom: 4px; }

/* ============ Toasts ============ */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 1000;
  pointer-events: none;
}
.toast {
  background: var(--white);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  min-width: 240px; max-width: 360px;
  animation: toast-in .25s ease-out;
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 10px;
}
.toast-icon { font-size: 14px; line-height: 18px; flex-shrink: 0; font-weight: 700; }
.toast-body { flex: 1; color: var(--text-strong); }
.toast-success { border-left: 3px solid var(--green); }
.toast-success .toast-icon { color: var(--green); }
.toast-error   { border-left: 3px solid var(--red); }
.toast-error   .toast-icon { color: var(--red); }
.toast-info    { border-left: 3px solid var(--accent); }
.toast-info    .toast-icon { color: var(--accent); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============ M4-B additions ============ */

/* Topbar nav (new horizontal nav between brand and user pill) */
.topbar { padding: 12px 28px; }
.topbar .nav { display: flex; align-items: center; gap: 0; flex: 1; margin: 0 32px; flex-wrap: wrap; }
.topbar .nav a { padding: 8px 12px; font-size: 13px; color: var(--muted); text-decoration: none; border-radius: 6px; display: inline-flex; align-items: center; gap: 6px; transition: background .15s, color .15s; }
.topbar .nav a:hover { background: var(--bg); color: var(--text); }
.topbar .nav a.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }
.topbar .nav a .badge { background: var(--red); color: #fff; border-radius: 10px; padding: 1px 6px; font-size: 10px; font-weight: 700; margin-left: 4px; }
.topbar .nav .icon { width: 14px; height: 14px; }
.topbar .user { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; }
.topbar .user .avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-light); color: var(--accent); display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 11px; }

/* Page chrome */
.page-frame { padding: 24px 28px 56px; min-height: calc(100vh - 56px); background: var(--bg); }
.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 8px; flex-wrap: wrap; }
.page-header > * { min-width: 0; }
.page-title { font-size: 22px; font-weight: 700; color: var(--text); margin-bottom: 4px; display: inline-flex; align-items: center; gap: 10px; }
.page-title .icon { width: 22px; height: 22px; color: var(--accent); }
.page-lede { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Buttons */
.btn-primary { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 9px 16px; font-size: 13px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; transition: background .15s; text-decoration: none; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary .icon { width: 14px; height: 14px; }
.btn-secondary { background: var(--bg-card); color: var(--text-strong); border: 1px solid var(--border); border-radius: 8px; padding: 9px 14px; font-size: 13px; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; text-decoration: none; }
.btn-secondary:hover { background: var(--bg-alt, var(--gray-bg)); }
.btn-secondary .icon { width: 14px; height: 14px; }
.btn-danger { background: var(--bg-card); color: var(--red); border: 1px solid var(--red-border); border-radius: 8px; padding: 9px 14px; font-size: 13px; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; }
.btn-danger:hover { background: var(--red-bg); }
.btn-danger .icon { width: 14px; height: 14px; }
.btn-icon { background: transparent; color: var(--muted); border: 0; padding: 6px 8px; border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; font-size: 12px; text-decoration: none; }
.btn-icon:hover { background: var(--bg); color: var(--text); }
.btn-icon .icon { width: 14px; height: 14px; }
.btn-sm { padding: 5px 10px !important; font-size: 11px !important; min-height: 28px !important; }

/* Cards */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }

/* Stats grid */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r); padding: 14px 16px; display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow); }
.stat-card .icon-wrap { width: 36px; height: 36px; border-radius: 8px; background: var(--accent-light); color: var(--accent); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-card .icon-wrap .icon { width: 18px; height: 18px; }
.stat-card .stat-label { font-size: 11px; color: var(--muted); margin-bottom: 2px; text-transform: uppercase; letter-spacing: 0.03em; }
.stat-card .stat-val { font-size: 18px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1.2; }

/* Tables */
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; padding: 10px 14px; background: var(--bg); font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; border-bottom: 1px solid var(--border); }
table.t td { padding: 12px 14px; border-bottom: 1px solid var(--border-light); color: var(--text-strong); vertical-align: middle; }
table.t tr:hover td { background: var(--bg); }
table.t tr:last-child td { border-bottom: 0; }
table.t .num { font-family: 'SF Mono', monospace; font-size: 12px; font-variant-numeric: tabular-nums; }
table.t .strong { color: var(--text); font-weight: 600; }
table.t .mono { font-family: 'SF Mono', monospace; font-size: 12px; color: var(--muted); }

/* Pips (semantic chips) */
.pip { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; }
.pip-ok { background: var(--green-bg); color: var(--green); }
.pip-warn { background: var(--orange-bg); color: var(--orange); }
.pip-err { background: var(--red-bg); color: var(--red); }
.pip-info { background: var(--blue-bg); color: var(--blue); }
.pip-gray { background: var(--gray-bg); color: var(--gray-text); }
.pip .icon { width: 11px; height: 11px; }

/* Filters */
.filter-row { display: flex; gap: 10px; margin-bottom: 16px; align-items: center; flex-wrap: wrap; }
.filter-input { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; background: var(--bg-card); min-width: 240px; min-height: 36px; font-family: var(--f); }
.filter-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-border); }
.filter-select { padding: 8px 30px 8px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; background: var(--bg-card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234a4e68' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") right 10px center / 14px no-repeat; appearance: none; min-height: 36px; cursor: pointer; font-family: var(--f); }

/* Vacant / empty state */
.vacant { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 64px 24px; color: var(--muted); text-align: center; }
.vacant .icon { width: 36px; height: 36px; color: var(--muted); margin-bottom: 6px; }
.vacant strong { color: var(--text-strong); font-size: 14px; }

/* Tabs (extends M4-A baseline) */
.tabs .badge-count { background: var(--gray-bg); color: var(--gray-text); padding: 1px 6px; border-radius: 10px; font-size: 11px; font-weight: 600; margin-left: 4px; }
.tab[aria-selected="true"] .badge-count { background: var(--accent-light); color: var(--accent); }

/* Dashboard sections */
.dash-section { margin-bottom: 18px; }
.dash-section-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 18px 0 10px; display: flex; align-items: center; gap: 8px; }
.dash-section-title .num { background: var(--accent); color: #fff; width: 18px; height: 18px; border-radius: 50%; font-size: 10px; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }

/* Pool Pulse */
.pulse-card { padding: 18px 20px; }
.pulse-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; gap: 12px; flex-wrap: wrap; }
.pulse-title { font-size: 15px; font-weight: 600; color: var(--text-strong); }
.pulse-sub { font-size: 11px; color: var(--muted); }
.weather { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.weather .icon { width: 14px; height: 14px; }
.weather-clear { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }
.weather-cloudy { background: var(--blue-bg); color: var(--blue); border: 1px solid var(--blue-border); }
.weather-warning { background: var(--orange-bg); color: var(--orange); border: 1px solid var(--orange-border); }
.weather-storm { background: var(--red-bg); color: var(--red); border: 1px solid var(--red-border); }
.pulse-stat-strip { display: flex; gap: 24px; padding: 12px 4px 0; border-top: 1px solid var(--border-light); margin-top: 12px; flex-wrap: wrap; }
.pulse-stat { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.pulse-stat .icon { width: 14px; height: 14px; color: var(--accent); }
.pulse-stat strong { color: var(--text); font-weight: 600; font-size: 13px; }

/* Constellation */
.constellation-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.constellation-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r); padding: 16px 14px; text-align: center; box-shadow: var(--shadow); cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.constellation-card:hover { border-color: var(--accent-border); box-shadow: var(--shadow-lg); }
.constellation-pip { display: inline-flex; align-items: center; gap: 4px; font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; }
.constellation-pip.pip-ok { background: var(--green-bg); color: var(--green); }
.constellation-pip.pip-warn { background: var(--orange-bg); color: var(--orange); }
.constellation-pip.pip-err { background: var(--red-bg); color: var(--red); }
.constellation-pip.pip-gray { background: var(--gray-bg); color: var(--gray-text); }
.constellation-pip .icon { width: 11px; height: 11px; }
.constellation-name { font-family: 'SF Mono', monospace; font-size: 12px; font-weight: 600; color: var(--text-strong); margin-top: 4px; }
.constellation-detail { font-size: 11px; color: var(--muted); }

/* Activity timeline */
.timeline { position: relative; padding-left: 28px; }
.timeline::before { content: ''; position: absolute; left: 11px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.tl-event { position: relative; padding: 8px 0 14px; font-size: 13px; }
.tl-event::before { content: ''; position: absolute; left: -22px; top: 12px; width: 16px; height: 16px; border-radius: 50%; background: var(--bg-card); border: 2px solid var(--accent); box-sizing: border-box; }
.tl-event.warn::before { border-color: var(--orange); }
.tl-event.crit::before { border-color: var(--red); }
.tl-event.ok::before { border-color: var(--green); }
.tl-event.info::before { border-color: var(--blue); }
.tl-time { font-size: 11px; color: var(--muted); margin-bottom: 2px; font-family: 'SF Mono', monospace; }
.tl-msg { color: var(--text-strong); }
.tl-msg strong { font-weight: 600; }
.tl-meta { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* Range-bar (Gantt-style uptime) */
.range-bar { background: var(--green-bg); border-radius: 4px; height: 18px; position: relative; overflow: hidden; }
.range-bar .gap { position: absolute; top: 0; bottom: 0; background: var(--red); }

/* Modal (for API-key create dialog) */
/* CPM-55 fix: use var(--white) (defined) instead of var(--bg-card) (NOT
   defined in this DevOps-tokens app.css). The previous reference fell
   through to `background:` (transparent), so the CPM-52 wizard modal
   rendered as a see-through panel over the accounts list. Other places
   that use the .modal class (api-keys.js's create-modal) inline-style
   the overlay/modal themselves with var(--white) — they were unaffected. */
.modal { background: var(--white); border: 1px solid var(--border); border-radius: var(--r); padding: 22px 26px; max-width: 540px; box-shadow: var(--shadow-lg); position: relative; z-index: 1001; }
.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 12px; color: var(--text); display: flex; align-items: center; gap: 10px; }
.modal-title .icon { width: 18px; height: 18px; color: var(--accent); }
.modal-body { font-size: 13px; color: var(--text-strong); line-height: 1.5; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border-light); }
/* CPM-55: the wizard variant is wider (620px) and explicitly opaque so
   the underlying accounts list isn't visible through the form. */
.modal-wizard { max-width: 620px; background: var(--white); }

/* ============ CPM-52 Phase 2: Provisioning wizard ============ */
/* Multi-step wizard for new-account provisioning. Reuses .modal +
   .modal-title/body/footer. Adds: stepper indicator, form-field rows,
   code block for the PKCE URL, danger-styled "type-to-confirm" pattern. */
.wizard-stepper { display: flex; gap: 6px; margin: 0 0 18px; padding: 0; list-style: none; }
.wizard-stepper li { flex: 1; padding: 6px 8px; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); background: var(--bg-alt); border-radius: 6px; text-align: center; border: 1px solid var(--border); }
.wizard-stepper li.is-current { background: var(--accent); color: var(--white); border-color: var(--accent); }
.wizard-stepper li.is-done { background: var(--green-bg); color: var(--green); border-color: var(--green-border); }
.wizard-field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.wizard-field label { font-size: 12px; font-weight: 600; color: var(--text); }
.wizard-field input, .wizard-field select, .wizard-field textarea { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--white); color: var(--text); font-family: var(--f); font-size: 13px; }
.wizard-field input:focus, .wizard-field select:focus, .wizard-field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.wizard-field .field-help { font-size: 11px; color: var(--muted); }
.wizard-field .field-error { font-size: 11px; color: var(--red); }
.wizard-row { display: flex; gap: 10px; }
.wizard-row .wizard-field { flex: 1; min-width: 0; }
.wizard-code-block { background: var(--bg-alt); padding: 10px 12px; border-radius: 8px; font-family: 'SF Mono', 'Fira Code', monospace; font-size: 11.5px; color: var(--text); border: 1px solid var(--border); word-break: break-all; max-height: 120px; overflow-y: auto; }
.wizard-helper-p { font-size: 13px; color: var(--text-strong); margin: 0 0 12px; line-height: 1.55; }
.wizard-helper-p code { font-size: 12px; padding: 1px 5px; background: var(--bg-alt); border-radius: 4px; }
.wizard-permission-pad { padding: 28px; text-align: center; background: var(--orange-bg); border: 1px dashed var(--orange-border); border-radius: var(--r); color: var(--text-strong); }
.wizard-permission-pad h3 { margin: 0 0 6px; color: var(--orange); font-size: 14px; }
.wizard-permission-pad p { font-size: 12px; color: var(--muted); margin: 0; }
.wizard-actions-spread { display: flex; justify-content: space-between; align-items: center; }
.wizard-summary-table { width: 100%; border-collapse: collapse; font-size: 12px; margin: 8px 0 12px; }
.wizard-summary-table th { background: var(--bg); text-align: left; padding: 6px 10px; border-bottom: 2px solid var(--border); font-weight: 600; }
.wizard-summary-table td { padding: 6px 10px; border-bottom: 1px solid var(--border-light); vertical-align: top; }
.wizard-summary-table tr:last-child td { border-bottom: 0; }

/* Runbook */
.toc { width: 220px; flex-shrink: 0; padding: 18px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r); position: sticky; top: 16px; align-self: flex-start; box-shadow: var(--shadow); }
.toc-h { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; margin-bottom: 10px; }
.toc-link { display: block; padding: 6px 10px; font-size: 13px; color: var(--text-strong); text-decoration: none; border-radius: 6px; line-height: 1.4; }
.toc-link:hover { background: var(--bg); }
.toc-link.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }
.runbook-prose { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r); padding: 24px 28px; flex: 1; box-shadow: var(--shadow); min-width: 0; }
.runbook-prose h1 { font-size: 22px; margin: 0 0 14px; color: var(--text); }
.runbook-prose h2 { font-size: 18px; margin: 24px 0 10px; color: var(--text); padding-top: 14px; border-top: 1px solid var(--border-light); }
.runbook-prose h2:first-child { padding-top: 0; border-top: 0; }
.runbook-prose h3 { font-size: 15px; margin: 18px 0 8px; color: var(--text-strong); }
.runbook-prose p { font-size: 14px; line-height: 1.6; color: var(--text-strong); margin: 0 0 12px; }
.runbook-prose ol, .runbook-prose ul { font-size: 14px; line-height: 1.7; color: var(--text-strong); padding-left: 24px; margin-bottom: 12px; }
.runbook-prose li { margin-bottom: 4px; }
.runbook-prose code { font-family: 'SF Mono', monospace; font-size: 12px; background: var(--bg); padding: 1px 6px; border-radius: 4px; }
.runbook-prose pre { background: var(--bg); padding: 14px 18px; border-radius: 8px; overflow-x: auto; font-family: 'SF Mono', monospace; font-size: 12px; line-height: 1.5; margin: 0 0 12px; border: 1px solid var(--border-light); }
.runbook-prose pre code { background: none; padding: 0; }
.runbook-prose hr { border: none; border-top: 1px solid var(--border-light); margin: 24px 0; }
.runbook-prose a { color: var(--accent); text-decoration: none; }
.runbook-prose a:hover { text-decoration: underline; }
/* CPM-51: GFM-style markdown tables in runbook content. Matches the
   admin SPA's card aesthetic — soft borders, padded cells, accent-tinted
   header band. `display: block; overflow-x: auto` lets long tables scroll
   horizontally on narrow viewports without breaking the toc+prose flex layout. */
.runbook-prose table { width: 100%; border-collapse: collapse; margin: 0 0 16px; font-size: 13px; line-height: 1.5; display: block; overflow-x: auto; }
.runbook-prose thead { background: var(--bg); }
.runbook-prose th { font-weight: 600; text-align: left; color: var(--text-strong); padding: 10px 14px; border-bottom: 2px solid var(--border); white-space: nowrap; }
.runbook-prose td { padding: 10px 14px; border-bottom: 1px solid var(--border-light); color: var(--text-strong); vertical-align: top; }
.runbook-prose tbody tr:last-child td { border-bottom: 0; }
.runbook-prose tbody tr:hover { background: var(--bg); }
.runbook-prose td code, .runbook-prose th code { font-size: 11.5px; }

/* Lucide icon wrapping (UI.iconNode + inline data-lucide replacement) */
.lucide-wrap { display: inline-flex; align-items: center; }
[data-lucide] { vertical-align: middle; }
.icon { display: inline-block; }

/* ============ CPM-27: Usage drill-in (per-call detail page) ============ */

/* pip-metadata: accent-tinted variant of .pip used by the recent-calls
   panel to flag rows whose request_metadata is populated. Click any such
   row to drill in and see the JSONB. */
.pip-metadata { background: var(--accent-light); color: var(--accent); border: 1px solid var(--accent-border); padding: 2px 6px; }
.pip-metadata .icon { width: 10px; height: 10px; }

/* Recent-calls panel rows on the /cpm/usage list view */
.usage-recent-row { transition: background .15s; }
.usage-recent-row:hover td { background: var(--bg) !important; }

/* Detail page — identity row (5 cells) */
.usage-identity { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; padding: 14px 16px; background: var(--canvas); border: 1px solid var(--border); border-radius: 10px; margin: 10px 0 14px; }
@media (max-width: 720px) { .usage-identity { grid-template-columns: repeat(2, 1fr); } }
.usage-identity-cell { min-width: 0; }
.usage-identity-label { font-size: 10px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.usage-identity-val { font-size: 12px; font-family: 'SF Mono', monospace; color: var(--text-strong); font-weight: 500; word-break: break-all; }

/* Detail page — token counters (4-up grid) */
.usage-tokens-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 10px 0 14px; }
@media (max-width: 720px) { .usage-tokens-grid { grid-template-columns: repeat(2, 1fr); } }
.usage-tokens-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.usage-tokens-label { font-size: 10px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.usage-tokens-val { font-size: 18px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1.1; }

/* Detail page — cost panel (accent-tinted) */
.usage-cost-panel { display: flex; gap: 18px; align-items: center; padding: 12px 16px; background: var(--accent-light); border: 1px solid var(--accent-border); border-radius: 10px; margin: 10px 0 14px; flex-wrap: wrap; }
.usage-cost-val { font-size: 22px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.usage-cost-meta { font-size: 12px; color: var(--text-strong); font-family: 'SF Mono', monospace; }

/* Detail page — aux row (HOME path + plugin_dirs side-by-side) */
.usage-aux-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 10px 0 14px; }
@media (max-width: 720px) { .usage-aux-row { grid-template-columns: 1fr; } }
.usage-aux-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; font-size: 12px; }
.usage-aux-label { font-size: 10px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.usage-aux-card code { font-family: 'SF Mono', monospace; color: var(--text-strong); display: block; word-break: break-all; background: var(--bg); padding: 6px 8px; border-radius: 4px; }
.usage-aux-list { list-style: none; padding: 0; margin: 4px 0 0; font-family: 'SF Mono', monospace; font-size: 11px; color: var(--text-strong); }
.usage-aux-list li { padding: 4px 8px; background: var(--bg); border-radius: 4px; margin-bottom: 4px; word-break: break-all; }
.usage-aux-list li:last-child { margin-bottom: 0; }
.usage-aux-empty { font-style: italic; color: var(--muted); font-size: 11px; padding: 6px 8px; }

/* Detail page — request_metadata section (CPM-27 collapsible JSONB display).
   Accent-tinted border-left signals "new in CPM-27"; visually distinguishes
   the additive section from the unchanged backdrop. */
.metadata-section { background: var(--bg-card); border: 1px solid var(--accent-border); border-left: 4px solid var(--accent); border-radius: 10px; margin: 16px 0; overflow: hidden; box-shadow: var(--shadow); }
.metadata-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; cursor: pointer; min-height: 48px; user-select: none; }
.metadata-header:hover { background: var(--accent-light); }
.metadata-header-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.metadata-chevron { display: inline-block; width: 18px; height: 18px; transition: transform 0.15s ease; font-size: 14px; color: var(--accent); text-align: center; line-height: 18px; flex-shrink: 0; }
.metadata-section.expanded .metadata-chevron { transform: rotate(90deg); }
.metadata-title { font-size: 14px; font-weight: 700; color: var(--text); }
.metadata-subtitle { font-size: 11px; color: var(--muted); margin-top: 2px; }
.metadata-tag { font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 4px; background: var(--accent-light); color: var(--accent); border: 1px solid var(--accent-border); letter-spacing: 0.04em; text-transform: uppercase; flex-shrink: 0; }
.metadata-tag-warn { background: var(--orange-bg); color: var(--orange); border-color: var(--orange-border); }
.metadata-body { padding: 0 16px 16px; border-top: 1px solid var(--border-light); }
.metadata-section:not(.expanded) .metadata-body { display: none; }
.metadata-pre { background: var(--canvas); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; margin: 12px 0 8px; font-family: 'SF Mono', 'Fira Code', monospace; font-size: 12px; line-height: 1.6; overflow-x: auto; color: var(--text-strong); white-space: pre; }
.metadata-helper { font-size: 11px; color: var(--muted); margin: 8px 4px 0; line-height: 1.5; font-style: italic; }
.metadata-truncation-banner { background: var(--orange-bg); border: 1px solid var(--orange-border); border-radius: 6px; padding: 8px 12px; margin: 8px 0 0; font-size: 11px; color: var(--orange); display: flex; align-items: center; gap: 8px; }
.metadata-truncation-banner .icon { width: 14px; height: 14px; flex-shrink: 0; }

/* JSON syntax tints — applied by tintJson() in usage.js */
.json-key { color: var(--accent); font-weight: 600; }
.json-string { color: var(--green); }
.json-number { color: var(--orange); font-weight: 500; }
.json-bool { color: var(--blue); font-weight: 600; }
.json-punct { color: var(--muted); }

/* ============ CPM-28: in-flight panel + conversation viewer ============ */

/* Local purple variant — borrowed from CPM-27's metadata-section convention.
   --accent (indigo) is taken by other affordances; --purple-* gives the
   in-flight panel + "New" tag a distinct identity. */
:root {
  --purple: #7c3aed;
  --purple-bg: #f5f3ff;
  --purple-border: #ddd6fe;
}

/* In-flight panel (Dashboard top, above Constellation) */
.in-flight-panel { background: var(--bg-card); border: 1px solid var(--purple-border); border-left: 4px solid var(--purple); border-radius: var(--r); margin-bottom: 18px; overflow: hidden; box-shadow: var(--shadow); }
.in-flight-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border-light); }
.in-flight-title { font-size: 14px; font-weight: 700; color: var(--text); display: inline-flex; align-items: center; gap: 8px; }
.in-flight-title .icon { width: 16px; height: 16px; color: var(--purple); }
.in-flight-summary { font-size: 12px; color: var(--muted); }
.in-flight-summary strong { color: var(--purple); font-weight: 700; }
.refresh-pill { font-size: 10px; color: var(--muted); font-family: 'SF Mono', monospace; background: var(--bg); padding: 3px 8px; border-radius: 999px; }

.in-flight-row { display: grid; grid-template-columns: 110px 90px 60px 1fr 70px 60px 26px; gap: 12px; align-items: center; padding: 11px 16px; border-bottom: 1px solid var(--border-light); font-size: 12px; cursor: pointer; transition: background .15s; }
.in-flight-row:hover { background: var(--purple-bg); }
.in-flight-row:last-child { border-bottom: 0; }
.if-sel { font-family: 'SF Mono', monospace; color: var(--text-strong); font-size: 11px; }
.if-app { font-weight: 600; color: var(--text-strong); }
.if-acct { font-family: 'SF Mono', monospace; color: var(--muted); font-size: 11px; }
.if-agent { color: var(--text-strong); font-family: 'SF Mono', monospace; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.if-age { color: var(--muted); text-align: right; font-family: 'SF Mono', monospace; font-size: 11px; }
.if-age.stuck { color: var(--orange); font-weight: 700; }
.if-arrow { color: var(--muted); text-align: right; }

.pip-session { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); padding: 2px 8px; border-radius: 999px; font-size: 10px; font-weight: 600; display: inline-block; }
.pip-pending { background: var(--orange-bg); color: var(--orange); border: 1px solid var(--orange-border); padding: 2px 8px; border-radius: 999px; font-size: 10px; font-weight: 600; display: inline-block; }

/* Section tag (matches CPM-27 convention) */
.section-tag.tag-new { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); padding: 2px 7px; border-radius: 4px; font-size: 9px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }

/* Conversation viewer page (chat-style) */
.conv-page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.conv-back-link { font-size: 12px; color: var(--accent); text-decoration: none; display: inline-flex; align-items: center; gap: 4px; margin-bottom: 6px; }
.conv-back-link:hover { text-decoration: underline; }
.conv-back-link .icon { width: 12px; height: 12px; }
.conv-meta { font-size: 12px; color: var(--muted); font-family: 'SF Mono', monospace; margin-top: 4px; }
.conv-meta code { background: var(--bg); padding: 1px 6px; border-radius: 4px; }
.conv-actions { display: flex; gap: 8px; }
.btn-link-raw { font-family: 'SF Mono', monospace; font-size: 11px; }
.btn-link-raw .icon { width: 12px; height: 12px; }

.conv-inflight-badge { font-size: 11px; color: var(--orange); font-weight: 600; margin-left: 8px; }

.conv-banner { background: var(--orange-bg); border: 1px solid var(--orange-border); color: var(--orange); padding: 8px 12px; border-radius: 6px; font-size: 12px; margin: 12px 0; display: flex; align-items: center; gap: 8px; }
.conv-banner .icon { width: 14px; height: 14px; flex-shrink: 0; }

.conv-shell { background: var(--canvas); border: 1px solid var(--border); border-radius: 10px; padding: 16px; max-width: 800px; margin: 0 auto; }

.conv-msg { display: flex; gap: 10px; margin: 10px 0; }
.conv-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--bg); color: var(--muted); display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; font-family: 'SF Mono', monospace; flex-shrink: 0; }
.conv-bubble { background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; font-size: 13px; line-height: 1.55; max-width: 700px; word-wrap: break-word; }
.conv-msg.user .conv-avatar { background: var(--accent-light); color: var(--accent); }
.conv-msg.user .conv-bubble { background: var(--accent-light); border-color: var(--accent-border); color: var(--text); }
.conv-msg.assistant .conv-avatar { background: var(--purple-bg); color: var(--purple); }
.conv-msg.assistant .conv-bubble { background: var(--bg-card); border-color: var(--purple-border); }
.conv-msg.tool { margin-left: 38px; }
.conv-msg.tool .conv-bubble { background: var(--bg); border-color: var(--border); font-family: 'SF Mono', monospace; font-size: 11px; color: var(--text-strong); }
.conv-msg.system .conv-avatar { background: var(--bg); color: var(--muted); }
.conv-msg.system .conv-bubble { background: var(--bg); border-color: var(--border); font-style: italic; color: var(--muted); font-size: 12px; }
.conv-msg.unknown .conv-avatar { background: var(--bg); color: var(--muted); }
.conv-msg.unknown .conv-bubble { background: var(--bg); border-color: var(--border); font-family: 'SF Mono', monospace; font-size: 11px; }

.tool-name { color: var(--orange); font-weight: 700; margin-right: 6px; }
.conv-event-tag { font-size: 9px; font-weight: 700; padding: 2px 6px; border-radius: 4px; background: var(--bg-alt); color: var(--muted); border: 1px solid var(--border); margin-right: 6px; text-transform: uppercase; letter-spacing: 0.05em; }
