:root {
  color-scheme: dark;
  --ss-bg: #0f1115;
  --ss-surface: #171b22;
  --ss-surface-elevated: #1f2530;
  --ss-border: #303846;
  --ss-text-muted: #9aa4b2;
  --ss-text-primary: #e8eaed;
  --ss-accent: #5c9cff;
  --ss-success: #7ee787;
  --ss-warning: #f9cc78;
  --ss-danger: #ff8a8a;
  --ss-info: #7db2ff;
  --ss-badge-bg: #232a35;
  --ss-input-bg: #111821;
  --ss-table-bg: #141a22;
  --ss-card-bg: #171b22;
}

/* ─── Reset & Base ─── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #0f1115;
  color: #e8eaed;
  line-height: 1.5;
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.app { min-height: 100vh; display: flex; flex-direction: column; }

/* ─── Login ─── */
.login-container {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px;
}
.login-card {
  background: #1a1d24;
  border: 1px solid #2a2e38;
  border-radius: 12px;
  padding: 40px 32px;
  width: 100%; max-width: 380px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.35);
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; letter-spacing: 0.3px; }
.subtitle { margin: 0 0 24px; color: #9aa0a6; font-size: 14px; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: #9aa0a6; }
.form-group input {
  background: #0f1115;
  border: 1px solid #2a2e38;
  border-radius: 8px;
  padding: 10px 12px;
  color: #e8eaed;
  font-size: 14px;
  outline: none;
}
.form-group input:focus { border-color: #5c9cff; }
.btn {
  appearance: none;
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .05s ease, opacity .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: #5c9cff; color: #0f1115; }
.btn-ghost { background: transparent; color: #9aa0a6; border: 1px solid #2a2e38; }
.btn-block { width: 100%; }
.login-error {
  background: #2b1d1d;
  color: #ff8a8a;
  border: 1px solid #5c2a2a;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
}

/* ─── Top Bar ─── */
.top-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px;
  background: #14171d;
  border-bottom: 1px solid #22262e;
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { color: #5c9cff; font-size: 18px; }
.brand-text { font-weight: 700; font-size: 16px; }
.brand-version { color: #5f6368; font-size: 12px; margin-left: 6px; }
.top-bar-right { display: flex; align-items: center; gap: 12px; }
.user-pill {
  background: #1e222a;
  border: 1px solid #2a2e38;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px; color: #bdc1c6;
}
.status-badge {
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.3px;
  text-transform: uppercase;
}
.status-healthy { background: #1b3a2a; color: #7ee787; }
.status-degraded { background: #3a2e1b; color: #f9cc78; }
.status-critical { background: #3a1b1b; color: #ff8a8a; }
.status-unknown { background: #22262e; color: #9aa0a6; }

/* ─── Dashboard ─── */
.dashboard { padding: 20px; display: flex; flex-direction: column; gap: 16px; max-width: 1200px; margin: 0 auto; width: 100%; }

.panel {
  background: #1a1d24;
  border: 1px solid #22262e;
  border-radius: 12px;
  overflow: hidden;
}
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid #22262e;
}
.panel-header h2 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: 0.2px; }
.panel-meta { color: #9aa0a6; font-size: 12px; }
.panel-body { padding: 16px 18px; }
.panel-toggle {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between;
  background: transparent; border: none; color: #e8eaed;
  padding: 14px 18px; cursor: pointer; font-size: 15px; font-weight: 700;
}
.toggle-icon { color: #9aa0a6; font-size: 12px; }
.tier-section { margin-top: 8px; }
.tier-section h3 { margin: 0 0 10px; font-size: 13px; color: #9aa0a6; text-transform: uppercase; letter-spacing: 0.5px; }
.internal-services {
  margin-top: 0;
  padding: 14px 18px 0;
}
.internal-services .service-grid {
  padding: 0 0 14px;
}
.module-card {
  cursor: pointer;
  border-left: 3px solid #5c9cff;
}
.module-card:focus {
  outline: 2px solid #5c9cff;
  outline-offset: 2px;
}

/* ─── Module Views ─── */
.module-view {
  width: min(1200px, 100%);
  margin: 0 auto;
  padding: 20px;
}
.module-shell {
  background: #1a1d24;
  border: 1px solid #22262e;
  border-radius: 12px;
  overflow: hidden;
}
.module-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.module-open .top-bar {
  position: sticky;
}

/* ─── System Bar ─── */
.system-bar {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 16px;
  padding: 16px 18px;
}
.system-metric { display: flex; flex-direction: column; gap: 6px; }
.metric-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; color: #9aa0a6; }
.metric-value { font-size: 20px; font-weight: 700; }
.metric-bar { height: 6px; background: #22262e; border-radius: 3px; overflow: hidden; }
.metric-fill { height: 100%; border-radius: 3px; background: #5c9cff; width: 0%; transition: width .6s ease; }
.global-summary { padding: 0 18px 16px; font-size: 13px; color: #f9cc78; }

/* ─── Service Grid ─── */
.service-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; padding: 16px 18px; }
.service-card {
  background: #14171d;
  border: 1px solid #22262e;
  border-radius: 10px;
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 10px;
  transition: border-color .15s ease, box-shadow .2s ease;
}
.service-card:hover { border-color: #2a3a52; }
.service-card-header { display: flex; align-items: center; justify-content: space-between; }
.service-card-title { font-weight: 600; font-size: 14px; }
.service-card-status {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px;
  padding: 3px 8px; border-radius: 999px;
}
.status-HEALTHY { background: #1b3a2a; color: #7ee787; }
.status-DEGRADED { background: #3a2e1b; color: #f9cc78; }
.status-DOWN { background: #3a1b1b; color: #ff8a8a; }
.status-ERROR { background: #3a1b1b; color: #ff8a8a; }
.status-UNKNOWN { background: #22262e; color: #9aa0a6; }
.status-PROTECTED { background: #1b1b3a; color: #a78bfa; }
.status-MAINTENANCE { background: #3a3a1b; color: #d4d4d4; }
.status-DISABLED { background: #2a2a2a; color: #808080; }
.status-ARCHIVED { background: #22262e; color: #5f6368; }

.service-card-meta { display: flex; gap: 10px; font-size: 12px; color: #9aa0a6; }
.service-card-reasons { display: flex; flex-wrap: wrap; gap: 6px; }
.reason-pill {
  font-size: 11px; padding: 3px 8px; border-radius: 999px;
  background: #22262e; color: #bdc1c6;
}
.reason-pill.critical { background: #3a1b1b; color: #ff8a8a; }
.reason-pill.warning { background: #3a2e1b; color: #f9cc78; }
.reason-pill.info { background: #1b2a3a; color: #7ec8ff; }

/* ─── Reports Center ─── */
.reports-header { gap: 12px; }
.reports-view-toggle {
  display: inline-flex;
  background: #111821;
  border: 1px solid #2a2e38;
  border-radius: 8px;
  padding: 3px;
}
.reports-view-btn {
  border: 0;
  background: transparent;
  color: #9aa0a6;
  border-radius: 6px;
  padding: 7px 10px;
  cursor: pointer;
  font-weight: 700;
  font-size: 12px;
}
.reports-view-btn.active { background: #263244; color: #e8eaed; }
.reports-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) repeat(4, minmax(120px, 160px));
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid #22262e;
}
.reports-search,
.reports-filter {
  width: 100%;
  min-height: 40px;
  background: #111821;
  border: 1px solid #2a2e38;
  border-radius: 8px;
  color: #e8eaed;
  padding: 8px 10px;
  font-size: 13px;
}
.reports-search:focus,
.reports-filter:focus { outline: none; border-color: #5c9cff; }
.reports-content { padding: 16px 18px; }
.reports-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.report-card {
  appearance: none;
  width: 100%;
  min-height: 210px;
  text-align: left;
  background: #14171d;
  color: #e8eaed;
  border: 1px solid #22262e;
  border-radius: 8px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  cursor: pointer;
}
.report-card:hover { border-color: #355071; }
.report-card-top,
.report-card-meta,
.report-tags,
.report-viewer-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
}
.report-category { color: #7db2ff; font-size: 12px; font-weight: 700; }
.report-title {
  font-size: 14px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.report-summary {
  color: #bdc1c6;
  font-size: 13px;
  line-height: 1.45;
  flex: 1;
}
.report-card-meta { color: #9aa0a6; font-size: 12px; }
.report-tag {
  background: #202733;
  color: #bdc1c6;
  border: 1px solid #303846;
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 11px;
}
.report-badge {
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .2px;
  text-transform: uppercase;
  white-space: nowrap;
}
.report-badge.success { background: #1b3a2a; color: #7ee787; }
.report-badge.warning { background: #3a2e1b; color: #f9cc78; }
.report-badge.danger { background: #3a1b1b; color: #ff8a8a; }
.report-badge.neutral { background: #22262e; color: #bdc1c6; }
.reports-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 18px 16px;
}
.reports-pagination .btn:disabled { opacity: .45; cursor: not-allowed; }
.reports-timeline {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.report-timeline-item {
  appearance: none;
  width: 100%;
  background: #14171d;
  border: 1px solid #22262e;
  border-radius: 8px;
  color: #e8eaed;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: auto 155px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  text-align: left;
  cursor: pointer;
}
.report-timeline-item:hover { border-color: #355071; }
.report-timeline-date { color: #9aa0a6; font-size: 12px; }
.report-timeline-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.report-timeline-main strong,
.report-timeline-main span,
.report-timeline-main small { overflow-wrap: anywhere; }
.report-timeline-main small { color: #9aa0a6; font-size: 12px; }

/* ─── Report Viewer / Markdown ─── */
.report-viewer-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(0,0,0,.62);
  align-items: stretch;
  justify-content: center;
}
.report-viewer {
  width: min(1120px, 100%);
  height: 100dvh;
  background: #0f1115;
  border-left: 1px solid #303846;
  border-right: 1px solid #303846;
  display: flex;
  flex-direction: column;
}
.report-viewer-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  background: #14171d;
  border-bottom: 1px solid #22262e;
  padding: 12px 16px;
}
.report-viewer-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-self: end;
}
.report-viewer-actions .btn {
  white-space: nowrap;
}
.report-viewer-copy.is-success {
  border-color: #2a7a52;
  background: #173425;
  color: #d7ffe8;
}
.report-viewer-copy.is-error {
  border-color: #8f3a3a;
  background: #351d1d;
  color: #ffd6d6;
}
.report-viewer-title-wrap { min-width: 0; }
.report-viewer-title-wrap h2 {
  margin: 0 0 6px;
  font-size: 17px;
  overflow-wrap: anywhere;
}
.report-viewer-meta { color: #9aa0a6; font-size: 12px; }
.markdown-body {
  overflow: auto;
  padding: 24px;
  color: #e8eaed;
  line-height: 1.62;
  font-size: 15px;
}
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  margin: 1.2em 0 .45em;
  line-height: 1.2;
  color: #f1f5f9;
}
.markdown-body h1 { font-size: 28px; border-bottom: 1px solid #303846; padding-bottom: 8px; }
.markdown-body h2 { font-size: 22px; }
.markdown-body h3 { font-size: 18px; }
.markdown-body p { margin: 0 0 12px; }
.markdown-body a { color: #7db2ff; }
.markdown-body ul { padding-left: 22px; }
.markdown-body li { margin: 4px 0; }
.markdown-body code {
  background: #202733;
  border: 1px solid #303846;
  border-radius: 5px;
  padding: 1px 5px;
  color: #f9cc78;
  overflow-wrap: anywhere;
}
.markdown-body pre {
  background: #0b1017;
  border: 1px solid #303846;
  border-radius: 8px;
  padding: 14px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.markdown-body pre code {
  display: block;
  background: transparent;
  border: 0;
  padding: 0;
  color: #dce4ef;
  white-space: pre;
}
.markdown-body table {
  width: max-content;
  max-width: 100%;
  border-collapse: collapse;
  display: block;
  overflow-x: auto;
  margin: 14px 0;
}
.markdown-body th,
.markdown-body td {
  border: 1px solid #303846;
  padding: 8px 10px;
  vertical-align: top;
}
.markdown-body th { background: #1f2530; }
.markdown-body td { background: #141a22; }

/* ─── Alerts ─── */
.alert-list { padding: 8px 18px 16px; display: flex; flex-direction: column; gap: 8px; }
.alert-item {
  background: #14171d;
  border: 1px solid #22262e;
  border-radius: 8px;
  padding: 10px 12px;
  display: flex; align-items: center; gap: 10px;
}
.alert-severity {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.alert-severity.critical { background: #ff8a8a; }
.alert-severity.warning { background: #f9cc78; }
.alert-severity.info { background: #7ec8ff; }
.alert-text { font-size: 13px; }
.alert-service { color: #9aa0a6; font-size: 12px; margin-left: auto; flex-shrink: 0; }

/* ─── Queues ─── */
.queue-list { padding: 8px 18px 16px; display: flex; flex-direction: column; gap: 8px; }
.queue-item {
  background: #14171d;
  border: 1px solid #22262e;
  border-radius: 8px;
  padding: 10px 12px;
  display: flex; align-items: center; gap: 14px;
}
.queue-name { font-weight: 600; font-size: 13px; min-width: 140px; }
.queue-stats { display: flex; gap: 14px; margin-left: auto; }
.queue-stat { text-align: center; }
.queue-stat-value { font-weight: 700; font-size: 14px; }
.queue-stat-label { font-size: 11px; color: #9aa0a6; text-transform: uppercase; }

/* ─── Empty State ─── */
.empty-state { color: #5f6368; font-size: 13px; text-align: center; padding: 18px; }

/* ─── Card Actions ─── */
.card-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.card-btn {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid #2a2e38;
  color: #bdc1c6;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s ease;
}
.card-btn:hover { background: #22262e; }
.card-btn-primary {
  background: #5c9cff;
  border-color: #5c9cff;
  color: #0f1115;
  font-weight: 800;
}
.card-btn-primary:hover { background: #7db2ff; }

/* ─── Drawer ─── */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 50;
  display: flex;
  justify-content: flex-end;
}
.drawer {
  background: #14171d;
  width: 100%;
  max-width: 720px;
  border-left: 1px solid #22262e;
  display: flex;
  flex-direction: column;
  height: 100vh;
}
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid #22262e;
  flex-shrink: 0;
}
.drawer-title-wrap { display: flex; align-items: center; gap: 10px; }
.drawer-title-wrap h2 { margin: 0; font-size: 16px; }
.drawer-header-actions { display: flex; align-items: center; gap: 8px; }

.drawer-tabs {
  display: flex;
  gap: 2px;
  padding: 0 18px;
  border-bottom: 1px solid #22262e;
  overflow-x: auto;
  flex-shrink: 0;
}
.drawer-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: #9aa0a6;
  padding: 10px 12px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s ease, border-color .15s ease;
}
.drawer-tab.active { color: #e8eaed; border-bottom-color: #5c9cff; }
.drawer-tab:hover { color: #e8eaed; }

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
}
.drawer-tabpanel { display: none; }
.drawer-tabpanel.active { display: block; }

/* ─── Detail Sections ─── */
.detail-section { margin-bottom: 18px; }
.detail-section h3 {
  margin: 0 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #9aa0a6;
}
.detail-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.detail-section-header h3 { margin: 0; }
.detail-row {
  background: #1a1d24;
  border: 1px solid #22262e;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  overflow-wrap: anywhere;
}
.detail-reasons { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.detail-reason {
  background: #1a1d24;
  border: 1px solid #22262e;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  overflow-wrap: anywhere;
}

/* ─── Log View ─── */
.log-view {
  background: #0f1115;
  border: 1px solid #22262e;
  border-radius: 8px;
  padding: 12px;
  font-size: 12px;
  line-height: 1.6;
  font-family: "SF Mono", Monaco, Inconsolata, "Fira Code", monospace;
  color: #bdc1c6;
  max-height: 420px;
  overflow-y: auto;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

/* ─── Action List ─── */
.action-list { display: flex; flex-direction: column; gap: 8px; }
.action-item {
  background: #1a1d24;
  border: 1px solid #22262e;
  border-radius: 8px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.action-label { font-size: 13px; }
.action-btns { display: flex; gap: 8px; }

/* ─── Buttons ─── */
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-danger { background: #5c2a2a; color: #ff8a8a; }
.btn-danger:hover { background: #7a3a3a; }
.btn-icon {
  padding: 6px;
  line-height: 1;
  font-size: 16px;
}

/* ─── Modal ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  background: #1a1d24;
  border: 1px solid #22262e;
  border-radius: 12px;
  padding: 20px 24px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.35);
}
.modal h3 { margin: 0 0 8px; font-size: 15px; }
.modal p { margin: 0 0 16px; color: #9aa0a6; font-size: 13px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ─── Toast ─── */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #1a1d24;
  border: 1px solid #22262e;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 13px;
  z-index: 70;
  box-shadow: 0 6px 24px rgba(0,0,0,0.3);
  max-width: 90vw;
  overflow-wrap: anywhere;
}
.toast.success { border-color: #1b3a2a; color: #7ee787; }
.toast.error { border-color: #3a1b1b; color: #ff8a8a; }

/* ─── Mode Toggle ─── */
.mode-toggle {
  display: flex;
  background: #1a1d24;
  border: 1px solid #22262e;
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}
.mode-btn {
  background: transparent;
  border: none;
  color: #9aa0a6;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.mode-btn.active {
  background: #2a2e38;
  color: #e8eaed;
}

/* ─── Confidence ─── */
.confidence-pill {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: #1b3a2a;
  color: #7ee787;
}
.confidence-bar {
  padding: 12px 18px 16px;
  border-top: 1px solid #22262e;
}
.confidence-label {
  font-size: 12px;
  color: #9aa0a6;
  margin-bottom: 6px;
}
.confidence-track {
  background: #22262e;
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
  margin-bottom: 6px;
}
.confidence-fill {
  height: 100%;
  border-radius: 999px;
  background: #5c9cff;
  width: 0%;
  transition: width .3s ease, background .3s ease;
}
.confidence-fill.HEALTHY { background: #7ee787; }
.confidence-fill.DEGRADED { background: #f9cc78; }
.confidence-fill.AT_RISK { background: #ff9e42; }
.confidence-fill.CRITICAL { background: #ff8a8a; }
.confidence-value {
  font-size: 13px;
  font-weight: 600;
}
.confidence-factors {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.confidence-factor {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  background: #1a1d24;
  border: 1px solid #22262e;
  color: #bdc1c6;
}

/* ─── Timeline ─── */
.timeline-list {
  padding: 8px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
}
.timeline-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 8px 10px;
  border-radius: 8px;
  background: #1a1d24;
  border: 1px solid #22262e;
}
.timeline-dot {
  width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0; margin-top: 4px;
}
.timeline-dot.critical { background: #ff8a8a; }
.timeline-dot.warning { background: #f9cc78; }
.timeline-dot.info { background: #7ec8ff; }
.timeline-dot.recovery { background: #7ee787; }
.timeline-time {
  font-size: 11px;
  color: #5f6368;
  flex-shrink: 0;
  min-width: 42px;
}
.timeline-text {
  font-size: 13px;
  overflow-wrap: anywhere;
}
.timeline-source {
  font-size: 11px;
  color: #7ec8ff;
  margin-left: auto;
  flex-shrink: 0;
}

/* ─── Engineering Mode Visibility ─── */
body:not(.eng-mode) .eng-only { display: none !important; }
body.eng-mode .ops-only { display: none !important; }

/* ─── Runtime Mismatch Banner ─── */
.runtime-mismatch-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: #3a1b1b;
  border: 1px solid #5a2b2b;
  border-radius: 8px;
  margin: 10px 18px 0;
  color: #ff8a8a;
  font-size: 13px;
}
.mismatch-icon { font-size: 16px; }

/* ─── Freshness Badge ─── */
.freshness-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.freshness-badge.LIVE { background: #1b3a2a; color: #7ee787; }
.freshness-badge.STALE { background: #3a331b; color: #f9cc78; }
.freshness-badge.CACHED { background: #1a2a3a; color: #7ec8ff; }
.freshness-badge.UNAVAILABLE { background: #3a1b1b; color: #ff8a8a; }

/* ─── Restart Meta ─── */
.restart-meta {
  padding: 8px 12px;
  border-radius: 8px;
  background: #1a1d24;
  border: 1px solid #22262e;
  margin-bottom: 10px;
  font-size: 12px;
}
.restart-meta.cooldown { border-color: #3a331b; color: #f9cc78; }
.restart-meta.storm { border-color: #5a2b2b; color: #ff8a8a; }

/* ─── Root Cause Panel ─── */
.root-cause-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 8px 10px;
}
.root-cause-chain {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  border-radius: 8px;
  background: #1a1d24;
  border: 1px solid #22262e;
}
.root-cause-step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.root-cause-arrow {
  color: #5f6368;
}
.root-cause-confidence {
  font-size: 11px;
  color: #9aa0a6;
  margin-top: 4px;
}

/* ─── Raw JSON / Copy ─── */
.raw-json {
  background: #0d1117;
  border: 1px solid #22262e;
  border-radius: 8px;
  padding: 10px;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  color: #bdc1c6;
  max-height: 200px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ─── Offline Banner ─── */
.offline-banner {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 18px;
  background: #3a2e1b;
  border-bottom: 1px solid #7a5a1e;
  color: #f9cc78;
  font-size: 13px;
  font-weight: 650;
}
.offline-icon { font-size: 16px; }

/* ─── PWA Install Bar ─── */
.pwa-install-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 18px;
  background: #162a45;
  border-bottom: 1px solid #2a4a7a;
  color: #7db2ff;
  font-size: 13px;
  font-weight: 650;
}
.pwa-install-bar .btn-sm {
  min-height: 32px;
  padding: 6px 12px;
  font-size: 12px;
}
.pwa-install-bar.ios-hint {
  background: #1a1d24;
  border-bottom: 1px solid #2a2e38;
  color: #9aa0a6;
}

/* ─── Terminal Card ─── */
.terminal-card {
  border-left: 3px solid #5c9cff;
}
.terminal-card .service-card-meta {
  gap: 8px;
}

/* ─── Engineering Infrastructure Section ─── */
#section-engineering .panel-header h2 {
  color: #7ec8ff;
}

/* ─── Engineering Terminal ─── */
.terminal-panel {
  min-height: 560px;
}
.terminal-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 18px;
  border-bottom: 1px solid #22262e;
  background: #14171d;
}
.terminal-session.active {
  background: #5c9cff;
  border-color: #5c9cff;
  color: #0f1115;
}
.terminal-frame-wrap {
  position: relative;
  min-height: 620px;
  background: #05070a;
}
.terminal-frame-wrap iframe {
  width: 100%;
  height: min(72vh, 760px);
  min-height: 620px;
  border: 0;
  display: block;
  background: #05070a;
}
.terminal-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  color: #9aa4b2;
  text-align: center;
  background: #0f1115;
}
.terminal-placeholder strong {
  color: #e8eaed;
  font-size: 16px;
}
.terminal-placeholder.hidden {
  display: none;
}
.terminal-mobile-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 18px;
  border-top: 1px solid #22262e;
}

/* ─── Log Severity Highlighting ─── */
.log-line { display: block; padding: 2px 0; }
.log-line.critical { color: #ff8a8a; background: rgba(255,138,138,0.05); }
.log-line.error { color: #ff8a8a; }
.log-line.warning { color: #f9cc78; }
.log-line.info { color: #bdc1c6; }
.log-line.debug { color: #5f6368; }
.log-line .log-ts { color: #5f6368; font-size: 11px; margin-right: 6px; }

/* ─── Readiness List ─── */
.readiness-list {
  padding: 8px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.readiness-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #1a1d24;
  border: 1px solid #22262e;
  font-size: 13px;
}
.readiness-item .status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0;
}
.readiness-item.pass .status-dot { background: #7ee787; }
.readiness-item.warning .status-dot { background: #f9cc78; }
.readiness-item.fail .status-dot { background: #ff8a8a; }

/* ─── Dependency Chain ─── */
.dependency-chain {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 18px 16px;
}
.dependency-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #1a1d24;
  border: 1px solid #22262e;
}
.dependency-arrow {
  color: #5f6368;
  font-size: 12px;
}
.dependency-impacted {
  color: #ff8a8a;
}
.dependency-chain-svg {
  padding: 10px;
  background: #1a1d24;
  border: 1px solid #22262e;
  border-radius: 8px;
  font-family: ui-monospace, monospace;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre;
  overflow-x: auto;
}

/* ─── Queue Badges ─── */
.queue-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.queue-badge {
  font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.queue-badge.healthy { background: #1b3a2a; color: #7ee787; }
.queue-badge.warning { background: #3a331b; color: #f9cc78; }
.queue-badge.degraded { background: #3a2a1b; color: #ff9e42; }
.queue-badge.stalled { background: #3a1b1b; color: #ff8a8a; }

/* ─── Overflow Fixes ─── */
.service-card { overflow-wrap: anywhere; }
.drawer-body { overflow-wrap: anywhere; }

/* ─── Responsive ─── */
@media (max-width: 640px) {
  .terminal-panel {
    margin-left: -12px;
    margin-right: -12px;
    border-radius: 0;
  }
  .terminal-toolbar {
    position: sticky;
    top: 0;
    z-index: 6;
    padding: 10px 12px;
    overflow-x: auto;
    flex-wrap: nowrap;
  }
  .terminal-toolbar .btn {
    flex: 0 0 auto;
    min-height: 44px;
  }
  .terminal-frame-wrap,
  .terminal-frame-wrap iframe {
    min-height: calc(100vh - 196px);
    height: calc(100vh - 196px);
  }
  .terminal-mobile-actions {
    position: sticky;
    bottom: 0;
    z-index: 6;
    background: rgba(23,27,34,.96);
    padding: 10px 12px;
  }
  .terminal-mobile-actions .btn {
    min-height: 44px;
  }
  .top-bar { align-items: flex-start; flex-direction: column; gap: 10px; padding: 10px 12px; }
  .top-bar-right { width: 100%; flex-wrap: wrap; gap: 8px; }
  .top-bar-right .btn, .mode-btn, .card-btn, .drawer-tab { min-height: 44px; }
  .dashboard { padding: 12px; gap: 12px; }
  .module-view { padding: 12px; }
  .module-header-actions { width: 100%; justify-content: space-between; }
  .panel { border-radius: 8px; }
  .panel-header, .panel-body, .service-grid, .alert-list, .queue-list, .timeline-list, .readiness-list { padding-left: 12px; padding-right: 12px; }
  .reports-header { align-items: flex-start; flex-direction: column; }
  .reports-view-toggle { width: 100%; }
  .reports-view-btn { flex: 1; min-height: 40px; }
  .reports-toolbar { grid-template-columns: 1fr; padding: 12px; }
  .reports-content { padding: 12px; }
  .reports-list { display: flex; flex-direction: column; gap: 8px; }
  .report-card { min-height: 0; }
  .reports-pagination { justify-content: space-between; padding: 0 12px 12px; }
  .report-timeline-item { grid-template-columns: auto minmax(0, 1fr); }
  .report-timeline-date,
  .report-timeline-item .report-badge { grid-column: 2; }
  .report-viewer-header { grid-template-columns: 1fr; padding: 12px; }
  .report-viewer-actions { justify-self: stretch; flex-wrap: wrap; }
  .report-viewer-actions .btn { flex: 1; }
  .report-viewer-header .btn { min-height: 44px; }
  .markdown-body { padding: 16px 12px 28px; font-size: 14px; }
  .markdown-body h1 { font-size: 22px; }
  .markdown-body h2 { font-size: 19px; }
  .system-bar { grid-template-columns: 1fr 1fr; gap: 10px; }
  .service-grid { display: flex; flex-direction: column; gap: 8px; }
  .service-card { border-radius: 8px; padding: 12px; gap: 8px; }
  .service-card-header, .service-card-meta, .card-actions { align-items: flex-start; }
  .service-card-header { gap: 8px; }
  .service-card-title { flex: 1; }
  .card-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card-btn { justify-content: center; text-align: center; }
  .alert-item, .queue-item, .timeline-item, .action-item { align-items: flex-start; flex-direction: column; }
  .alert-service, .timeline-source, .queue-stats { margin-left: 0; }
  .queue-stats { width: 100%; justify-content: space-between; }
  .drawer-overlay { align-items: flex-end; justify-content: stretch; }
  .drawer { max-width: none; height: 100dvh; border-left: 0; border-radius: 0; }
  .drawer-header { align-items: flex-start; flex-direction: column; gap: 10px; padding: 12px; }
  .drawer-header-actions { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .drawer-header-actions .btn { min-height: 44px; }
  .drawer-tabs { padding: 0 12px; }
  .drawer-body { padding: 12px; }
}

@media (min-width: 641px) and (max-width: 1024px) {
  .dashboard { max-width: 100%; }
  .service-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
