/* === Reset & Base === */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}

/* === Header === */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.logo-icon { width: 24px; height: 24px; color: var(--accent); }
.header h1 { font-size: 18px; font-weight: 600; }
.server-name {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-card);
  padding: 2px 8px;
  border-radius: 4px;
  font-family: 'SF Mono', 'Consolas', monospace;
}
.header-right { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  position: relative;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

/* === File Manager Upload === */
.fm-upload-btn {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  position: relative;
}
.fm-upload-btn:hover {
  background: var(--accent);
  color: white;
}
.fm-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
}
.badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}
.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* === Connection Status === */
.connection-status { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--red);
  transition: background 0.3s;
}
.status-dot.connected { background: var(--accent); }
.status-text { color: var(--text-muted); }

/* === Navigation === */
.nav {
  display: flex;
  gap: 4px;
  padding: 8px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}
.nav-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}
.nav-btn svg { width: 16px; height: 16px; }
.nav-btn:hover { background: var(--bg-card); color: var(--text-primary); }
.nav-btn.active { background: var(--accent-dim); color: var(--accent); }

/* === Main === */
.main { padding: 20px 24px; max-width: 1200px; margin: 0 auto; }
.page { display: none; }
.page.active { display: block; }

/* === Cards === */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
}
.card-title svg { width: 18px; height: 18px; color: var(--accent); }
.card-link {
  display: block;
  text-align: center;
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.card-link:hover { text-decoration: underline; }

/* === Gauge Row === */
.gauge-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}
.gauge-card { text-align: center; padding: 24px 16px; }
.gauge-container {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto 12px;
}
.gauge-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.gauge-bg {
  fill: none;
  stroke: var(--gauge-track);
  stroke-width: 8;
}
.gauge-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 326.73;
  stroke-dashoffset: 326.73;
  transition: stroke-dashoffset 0.8s ease, stroke 0.3s;
}
.gauge-value {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 28px;
  font-weight: 700;
  font-family: 'SF Mono', 'Consolas', monospace;
}
.gauge-label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.gauge-sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* === Info Row === */
.info-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

/* === Network === */
.net-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.net-box {
  background: var(--bg-input);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}
.net-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; margin-bottom: 4px; }
.net-value { font-size: 20px; font-weight: 700; font-family: 'SF Mono', 'Consolas', monospace; }
.net-box.rx .net-value { color: var(--blue); }
.net-box.tx .net-value { color: var(--yellow); }

/* === Data Tables === */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left;
  padding: 8px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}
.data-table td { padding: 6px 8px; border-bottom: 1px solid var(--border-light); }
.data-table .val { text-align: right; font-family: 'SF Mono', 'Consolas', monospace; }

/* === Stats === */
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
}
.stat-label { color: var(--text-secondary); font-size: 13px; }
.stat-value { font-weight: 600; font-size: 13px; font-family: 'SF Mono', 'Consolas', monospace; }
.divider { border-top: 1px solid var(--border); margin: 12px 0; }
.section-title { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }

/* === Services === */
.services-list { display: flex; flex-direction: column; gap: 4px; }
.service-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; }
.service-name { color: var(--text-secondary); font-size: 13px; }
.service-status { font-size: 12px; font-weight: 600; }
.service-status.active { color: var(--accent); }
.service-status.inactive { color: var(--red); }

/* === Process Table === */
.proc-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 12px; }
.proc-controls { display: flex; gap: 8px; }
.search-input, .sort-select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
}
.search-input:focus, .sort-select:focus { border-color: var(--accent); }
.search-input { width: 200px; }
.proc-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.proc-table th {
  text-align: left;
  padding: 8px 6px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}
.proc-table td { padding: 6px; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
.proc-name {
  color: var(--text-primary);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  cursor: help;
}
.proc-pid { font-family: 'SF Mono', 'Consolas', monospace; color: var(--blue); font-size: 12px; }
.proc-cpu { color: var(--accent); font-weight: 600; font-family: 'SF Mono', 'Consolas', monospace; }
.proc-mem { color: var(--yellow); font-family: 'SF Mono', 'Consolas', monospace; }
.proc-status { font-size: 11px; padding: 2px 6px; border-radius: 4px; }
.proc-status.running { background: var(--accent-dim); color: var(--accent); }
.proc-status.sleeping { background: var(--blue-dim); color: var(--blue); }
.proc-status.zombie { background: var(--red-dim); color: var(--red); }
.proc-status.stopped { background: var(--yellow-dim); color: var(--yellow); }

/* === Process Actions === */
.proc-actions { display: flex; gap: 4px; }
.proc-actions.full { flex-direction: row; }
.proc-btn {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  transition: all 0.2s;
}
.proc-btn:hover { border-color: var(--accent); color: var(--accent); }
.proc-btn.danger:hover { border-color: var(--red); color: var(--red); }

/* === Alert Config === */
.alert-config { display: flex; flex-direction: column; gap: 12px; }
.alert-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: var(--bg-input);
  border-radius: 8px;
}
.alert-row-label { font-weight: 600; min-width: 60px; }
.alert-row-controls { display: flex; align-items: center; gap: 12px; flex: 1; }
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--progress-bg);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.3s;
}
.toggle.active { background: var(--accent); }
.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.3s;
}
.toggle.active::after { transform: translateX(20px); }
.threshold-input {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 6px 10px;
  border-radius: 6px;
  width: 80px;
  font-size: 13px;
  text-align: center;
}

/* === Alert History === */
.alert-history { max-height: 400px; overflow-y: auto; }
.alert-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--border-light);
}
.alert-item-icon { font-size: 18px; }
.alert-item-text { flex: 1; font-size: 13px; }
.alert-item-time { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.empty-state { text-align: center; color: var(--text-muted); padding: 40px; font-size: 14px; }

/* === Buttons === */
.btn {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}
.btn-ghost { background: none; border: 1px solid var(--border); color: var(--text-secondary); }
.btn-ghost:hover { border-color: var(--text-primary); color: var(--text-primary); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #cc0044; }

/* === Toast === */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--accent);
  color: #000;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s;
  z-index: 1000;
}
.toast.show { transform: translateY(0); opacity: 1; }

/* === Dialog === */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.dialog {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  min-width: 320px;
  box-shadow: var(--shadow-lg);
}
.dialog-title { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.dialog-body { font-size: 14px; color: var(--text-secondary); margin-bottom: 20px; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* === Alert Toast === */
.alert-toast {
  position: fixed;
  top: 80px;
  right: 20px;
  background: var(--bg-card);
  border: 1px solid var(--red);
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  animation: slideIn 0.3s ease;
}
.alert-toast-icon { font-size: 24px; }
.alert-toast-text { font-size: 13px; max-width: 300px; }
.alert-toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
}
@keyframes slideIn { from { transform: translateX(100px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* === Terminal === */
.terminal-card { padding: 12px; }
.terminal-card .card-title { margin-bottom: 8px; }

/* === File Manager === */
.fm-breadcrumb a { color: var(--accent); text-decoration: none; cursor: pointer; }
.fm-breadcrumb a:hover { text-decoration: underline; }
.fm-icon { font-size: 16px; }
.fm-actions { display: flex; gap: 4px; justify-content: flex-end; }

/* === Docker === */
.docker-status { font-size: 11px; padding: 2px 6px; border-radius: 4px; }
.docker-status.running { background: var(--accent-dim); color: var(--accent); }
.docker-status.exited { background: var(--red-dim); color: var(--red); }
.docker-status.paused { background: var(--yellow-dim); color: var(--yellow); }
.docker-status.created { background: var(--blue-dim); color: var(--blue); }

/* === Tools === */
.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.tool-box-wide { grid-column: 1 / -1; }
.tool-section-copy {
  max-width: 760px;
  margin: -4px 0 16px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.55;
}
.tool-box {
  position: relative;
  min-width: 0;
  background: var(--bg-input);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 16px;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.tool-box[data-state="running"] { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue-dim); }
.tool-box[data-state="success"] { border-color: var(--accent); }
.tool-box[data-state="warning"] { border-color: var(--yellow); }
.tool-box[data-state="error"] { border-color: var(--red); }
.tool-box h3 { font-size: 13px; font-weight: 600; margin-bottom: 10px; color: var(--accent); }
.tool-box-copy {
  min-height: 34px;
  margin: -4px 0 12px;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.45;
}
.tool-input-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.tool-input-row > .search-input { min-width: 120px; flex: 1 1 180px; }
.tool-input-row > .sort-select { min-width: 104px; }
.tool-port-input { flex-basis: 220px !important; font-family: 'SF Mono', 'Consolas', monospace; }
.tool-input-row .btn { min-height: 38px; }
.tool-input-row .btn:disabled { cursor: wait; opacity: 0.52; }
.tool-cancel { border-color: var(--red); color: var(--red); }
.tool-run-state {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 24px;
  margin: 2px 0 6px;
  color: var(--text-muted);
  font-size: 11px;
}
.tool-state-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.tool-run-state[data-state="running"] .tool-state-badge { border-color: var(--blue); color: var(--blue); }
.tool-run-state[data-state="running"] .tool-state-badge::before {
  width: 7px;
  height: 7px;
  border: 1px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  content: '';
  animation: toolSpin 0.8s linear infinite;
}
.tool-run-state[data-state="success"] .tool-state-badge { border-color: var(--accent); color: var(--accent); }
.tool-run-state[data-state="warning"] .tool-state-badge { border-color: var(--yellow); color: var(--yellow); }
.tool-run-state[data-state="error"] .tool-state-badge,
.tool-run-state[data-state="cancelled"] .tool-state-badge { border-color: var(--red); color: var(--red); }
.tool-result-summary {
  min-height: 34px;
  margin: 0 0 8px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.45;
}
@keyframes toolSpin { to { transform: rotate(360deg); } }
.tool-output {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  font-size: 11px;
  font-family: 'SF Mono', 'Consolas', monospace;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 200px;
  overflow-y: auto;
  line-height: 1.5;
}
.tool-output:empty { display: none; }
.network-diagnosis {
  scroll-margin-top: 96px;
  overflow: hidden;
  background:
    linear-gradient(120deg, rgba(20, 184, 166, 0.08), transparent 42%),
    var(--bg-input);
  border-color: rgba(20, 184, 166, 0.42);
  box-shadow: 0 0 0 1px rgba(20, 184, 166, 0.08);
}
.network-diagnosis[data-prepared="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim), 0 14px 34px rgba(0, 0, 0, 0.16);
}
.network-diagnosis-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.network-diagnosis-head h3 { margin: 2px 0 10px; font-size: 17px; }
.network-diagnosis-route-group {
  display: flex;
  align-items: flex-end;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}
.tool-recommended-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}
.network-diagnosis-route {
  max-width: 420px;
  color: var(--accent);
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 11px;
  line-height: 1.5;
  text-align: right;
}
.tool-primary-action {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #04130c;
  font-weight: 750;
}
.tool-primary-action:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.tool-followup {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  padding: 10px;
  background: linear-gradient(110deg, var(--accent-dim), var(--bg-primary) 72%);
  border: 1px solid var(--accent);
  border-radius: 8px;
}
.tool-followup[hidden] { display: none; }
.tool-followup p {
  min-width: 0;
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.4;
}
.tool-diagnosis-link {
  flex: 0 0 auto;
  min-height: 38px;
  border-color: var(--accent);
  color: var(--accent);
  white-space: nowrap;
}
.tool-diagnosis-link:disabled { cursor: wait; opacity: 0.52; }
.tool-check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-size: 11px;
  white-space: nowrap;
}
.tool-check input { accent-color: var(--accent); }
.diagnosis-stages {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
  padding: 0;
  list-style: none;
}
.diagnosis-stage {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-top: 3px solid var(--border);
  border-radius: 8px;
  background: var(--bg-primary);
}
.diagnosis-stage[data-state="pass"] { border-top-color: var(--accent); }
.diagnosis-stage[data-state="warn"] { border-top-color: var(--yellow); }
.diagnosis-stage[data-state="fail"] { border-top-color: var(--red); }
.diagnosis-stage[data-state="skipped"] { opacity: 0.62; }
.diagnosis-stage-name {
  display: block;
  margin-bottom: 5px;
  color: var(--text-primary);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.diagnosis-stage-code {
  display: block;
  overflow: hidden;
  margin-bottom: 4px;
  color: var(--text-muted);
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.diagnosis-stage-summary { color: var(--text-secondary); font-size: 10px; line-height: 1.4; }
.tool-raw-details { margin-top: 8px; color: var(--text-muted); font-size: 11px; }
.tool-raw-details summary { cursor: pointer; color: var(--accent); }
.tool-raw-details .tool-output { margin-top: 8px; }

/* === Uptime === */
.uptime-item { display: flex; align-items: center; gap: 16px; padding: 12px 16px; background: var(--bg-input); border-radius: 8px; margin-bottom: 8px; }
.uptime-item-name { font-weight: 600; min-width: 120px; }
.uptime-item-url { color: var(--text-muted); font-size: 12px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uptime-item-status { font-size: 13px; font-weight: 600; }
.uptime-item-status.up { color: var(--accent); }
.uptime-item-status.down { color: var(--red); }
.uptime-item-latency { font-size: 12px; color: var(--text-muted); font-family: 'SF Mono', 'Consolas', monospace; }
.uptime-item-actions { display: flex; gap: 4px; }

/* === Responsive === */

/* === Timeline Pagination === */
.timeline-pagination {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  margin-top: 24px;
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.timeline-pagination button {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
  min-height: 36px;
}
.timeline-pagination button:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--accent);
}
.timeline-pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.timeline-page-info {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 500;
}

@media (max-width: 768px) {
  .header { padding: 10px 16px; }
  .header h1 { font-size: 15px; }
  .nav { padding: 6px 16px; overflow-x: auto; }
  .nav-btn { padding: 6px 12px; font-size: 12px; white-space: nowrap; }
  .main { padding: 12px 16px; }
  .gauge-row { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .info-row { grid-template-columns: 1fr; }
  .gauge-container { width: 100px; height: 100px; }
  .gauge-value { font-size: 22px; }
  .proc-header { flex-direction: column; align-items: stretch; }
  .proc-controls { flex-direction: column; }
  .search-input { width: 100%; }
  .tool-grid { grid-template-columns: 1fr; }
  .tool-input-row { flex-wrap: wrap; }
  .tool-input-row .btn { flex: 1 1 96px; min-height: 44px; }
  .diagnosis-stages { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .timeline-item { padding: 12px 16px; }
  .timeline-dot { width: 10px; height: 10px; left: -1px; }
}

/* === Incident Timeline === */
.timeline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.timeline-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}
.timeline-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.timeline-filter-chip {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-muted);
  transition: all 0.2s;
  user-select: none;
}
.timeline-filter-chip.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}
.timeline-feed {
  position: relative;
  padding-left: 28px;
}
.timeline-feed::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}
.timeline-item {
  position: relative;
  padding: 10px 16px;
  margin-bottom: 8px;
  background: var(--bg-secondary);
  border-radius: 8px;
  border: 1px solid var(--border-light);
  transition: background 0.2s;
}
.timeline-item:hover { background: var(--bg-card); }
.timeline-dot {
  position: absolute;
  left: -24px;
  top: 14px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--bg-primary);
}
.timeline-dot.alert { background: var(--red); }
.timeline-dot.deploy { background: var(--accent); }
.timeline-dot.uptime { background: var(--yellow); }
.timeline-dot.system { background: var(--blue); }
.timeline-dot.service { background: var(--purple); }
.timeline-dot.security { background: var(--orange); }
.timeline-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.timeline-icon { font-size: 16px; }
.timeline-title { font-weight: 600; font-size: 14px; }
.timeline-time {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
  font-family: 'SF Mono', 'Consolas', monospace;
}
.timeline-detail {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}
.timeline-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}
.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 40px;
  font-size: 14px;
}

/* === Timeline Pagination === */
.timeline-pagination {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  margin-top: 24px;
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.timeline-pagination button {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
  min-height: 36px;
}
.timeline-pagination button:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--accent);
}
.timeline-pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.timeline-page-info {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 500;
}

@media (max-width: 768px) {
  .timeline-header { flex-direction: column; align-items: stretch; }
  .timeline-item { padding: 12px 16px; }
  .timeline-dot { width: 10px; height: 10px; left: -1px; }
  .forecast-grid { grid-template-columns: 1fr; }
}

/* === Predictive Forecast === */
.forecast-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 8px;
}
.forecast-stat {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: 8px;
}
.forecast-icon { font-size: 22px; }
.forecast-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; }
.forecast-val { font-size: 14px; font-weight: 600; }
.forecast-detail { font-size: 12px; color: var(--text-muted); text-align: center; }

/* === Command Palette === */
.palette-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 9999;
  display: flex;
  justify-content: center;
  padding-top: 15vh;
}
.palette-overlay.hidden { display: none; }
.palette-box {
  width: 560px;
  max-width: 90vw;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5);
  overflow: hidden;
  align-self: flex-start;
  animation: paletteIn 0.12s ease;
}
@keyframes paletteIn {
  from { opacity: 0; transform: scale(0.96) translateY(-8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.palette-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.palette-icon { font-size: 20px; }
.palette-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 16px;
  outline: none;
  font-family: inherit;
}
.palette-input::placeholder { color: var(--text-muted); }
.palette-hint {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-input);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 4px;
  font-family: 'SF Mono', 'Consolas', monospace;
}
.palette-results { max-height: 360px; overflow-y: auto; }
.palette-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  cursor: pointer;
  transition: background 0.08s;
}
.palette-item.active,
.palette-item:hover { background: var(--bg-input); }
.palette-item-icon { font-size: 18px; width: 28px; text-align: center; }
.palette-item-label { flex: 1; font-size: 14px; }
.palette-item-label mark {
  background: rgba(59, 130, 246, 0.25);
  color: var(--text-primary);
  border-radius: 2px;
}
.palette-item-shortcut { font-size: 11px; color: var(--text-muted); }
.palette-empty { padding: 32px; text-align: center; color: var(--text-muted); }
.palette-footer {
  display: flex;
  justify-content: space-between;
  padding: 10px 20px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
}

/* === Mission Control === */
.incident-banner {
  --mission-color: var(--red);
  position: sticky;
  top: 61px;
  z-index: 90;
  display: grid;
  grid-template-columns: 4px minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 12px 24px;
  background: linear-gradient(90deg, var(--red-dim), var(--bg-secondary) 38%);
  border-bottom: 1px solid var(--mission-color);
  box-shadow: var(--shadow-lg);
}
.incident-banner[hidden],
.mission-drawer-layer[hidden] { display: none; }
.incident-banner[data-level="attention"] {
  --mission-color: var(--yellow);
  background: linear-gradient(90deg, var(--yellow-dim), var(--bg-secondary) 38%);
}
.incident-banner[data-level="offline"] {
  --mission-color: var(--blue);
  background: linear-gradient(90deg, var(--blue-dim), var(--bg-secondary) 38%);
}
.incident-banner-mark {
  align-self: stretch;
  min-height: 42px;
  background: var(--mission-color);
  border-radius: 999px;
  box-shadow: 0 0 18px var(--mission-color);
}
.incident-banner-copy {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
}
.incident-banner-copy strong {
  overflow: hidden;
  color: var(--text-primary);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.incident-banner-copy > span {
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.incident-banner-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}
.incident-kicker,
.incident-duration {
  color: var(--mission-color);
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.incident-duration { color: var(--text-secondary); }
.incident-banner-actions,
.mission-now-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mission-btn,
.mission-text-btn,
.gauge-why,
.card-title-action,
.mission-check-btn,
.timeline-view-btn {
  appearance: none;
  border: 1px solid var(--border);
  color: var(--text-primary);
  font: inherit;
  cursor: pointer;
}
.mission-btn {
  min-height: 34px;
  padding: 7px 12px;
  background: var(--accent);
  border-color: var(--accent);
  border-radius: 7px;
  color: #04130c;
  font-size: 12px;
  font-weight: 700;
}
.mission-btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.mission-btn-quiet {
  background: var(--bg-input);
  border-color: var(--border);
  color: var(--text-secondary);
}
.mission-btn-quiet:hover { border-color: var(--accent); color: var(--text-primary); }

.mission-now {
  --mission-color: var(--blue);
  position: relative;
  overflow: hidden;
  padding: 0;
  background:
    radial-gradient(circle at 88% 8%, var(--blue-dim), transparent 32%),
    var(--bg-card);
}
.mission-now::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--mission-color);
  box-shadow: 0 0 22px var(--mission-color);
}
.mission-now[data-level="healthy"] {
  --mission-color: var(--accent);
  background:
    radial-gradient(circle at 88% 8%, var(--accent-dim), transparent 32%),
    var(--bg-card);
}
.mission-now[data-level="attention"] {
  --mission-color: var(--yellow);
  background:
    radial-gradient(circle at 88% 8%, var(--yellow-dim), transparent 32%),
    var(--bg-card);
}
.mission-now[data-level="incident"] {
  --mission-color: var(--red);
  background:
    radial-gradient(circle at 88% 8%, var(--red-dim), transparent 36%),
    var(--bg-card);
}
.mission-now-head,
.mission-now-body,
.mission-recommendation,
.mission-now-actions { padding-right: 24px; padding-left: 28px; }
.mission-now-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding-top: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-light);
}
.mission-eyebrow {
  color: var(--text-secondary);
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.mission-state-line {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 7px;
}
.mission-state-chip {
  padding: 3px 8px;
  background: var(--mission-color);
  border-radius: 999px;
  color: #07110c;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.mission-now[data-level="incident"] .mission-state-chip,
.mission-now[data-level="offline"] .mission-state-chip { color: #16030a; }
[data-theme="light"] .mission-now[data-level="incident"] .mission-state-chip,
[data-theme="light"] .mission-now[data-level="offline"] .mission-state-chip { color: #fff; }
.mission-weather { color: var(--text-secondary); font-size: 12px; }
.mission-freshness {
  color: var(--text-secondary);
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 11px;
  white-space: nowrap;
}
.mission-now-body {
  display: grid;
  grid-template-columns: minmax(240px, 0.85fr) minmax(420px, 1.35fr);
  gap: 28px;
  align-items: end;
  padding-top: 22px;
  padding-bottom: 22px;
}
.mission-brief h2 {
  max-width: 660px;
  margin-bottom: 7px;
  font-size: clamp(20px, 2.8vw, 32px);
  line-height: 1.12;
  letter-spacing: -0.035em;
}
.mission-brief p {
  max-width: 650px;
  color: var(--text-secondary);
  font-size: 13px;
}
.mission-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 9px;
}
.mission-metric {
  min-width: 0;
  padding: 12px;
  background: var(--bg-input);
}
.mission-metric dt {
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}
.mission-metric dd {
  overflow: hidden;
  margin-top: 3px;
  color: var(--text-primary);
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 15px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mission-recommendation {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 16px;
  padding-top: 13px;
  padding-bottom: 13px;
  background: var(--bg-input);
  border-top: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
}
.mission-recommendation-label {
  color: var(--mission-color);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.mission-recommendation p { color: var(--text-secondary); font-size: 12px; }
.mission-now-actions { justify-content: flex-end; padding-top: 14px; padding-bottom: 18px; }

.mission-evidence-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.mission-evidence-card { min-width: 0; margin-bottom: 0; }
.mission-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.mission-card-head .card-title { margin: 3px 0 0; }
.mission-text-btn,
.gauge-why,
.card-title-action {
  padding: 3px 7px;
  background: transparent;
  border-color: transparent;
  border-radius: 6px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}
.mission-text-btn:hover,
.gauge-why:hover,
.card-title-action:hover { background: var(--accent-dim); border-color: var(--accent); }
.card-title-action { margin-left: auto; }
.gauge-why { margin-top: 9px; }
.mission-card-summary {
  min-height: 36px;
  margin-bottom: 12px;
  color: var(--text-secondary);
  font-size: 12px;
}
.mission-change-list,
.mission-causal-list {
  display: grid;
  gap: 7px;
  list-style: none;
}
.mission-change {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: 8px;
}
.mission-change-kind,
.mission-causal-phase {
  color: var(--blue);
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.mission-change-cpu .mission-change-kind { color: var(--yellow); }
.mission-change-memory .mission-change-kind { color: var(--orange); }
.mission-change-entered .mission-change-kind { color: var(--accent); }
.mission-change-left .mission-change-kind { color: var(--text-secondary); }
.mission-change-copy { display: grid; min-width: 0; }
.mission-change-copy strong,
.mission-change-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mission-change-copy strong { font-size: 12px; }
.mission-change-copy span { color: var(--text-secondary); font-size: 11px; }
.mission-empty {
  display: block;
  padding: 16px;
  color: var(--text-secondary);
  font-size: 12px;
  text-align: center;
}
.mission-causal-event {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 9px 10px;
  border-left: 2px solid var(--border);
}
.mission-phase-change { border-left-color: var(--blue); }
.mission-phase-trigger { border-left-color: var(--red); }
.mission-phase-impact { border-left-color: var(--yellow); }
.mission-phase-recovery { border-left-color: var(--accent); }
.mission-phase-change .mission-causal-phase { color: var(--blue); }
.mission-phase-trigger .mission-causal-phase { color: var(--red); }
.mission-phase-impact .mission-causal-phase { color: var(--yellow); }
.mission-phase-recovery .mission-causal-phase { color: var(--accent); }
.mission-causal-copy,
.mission-causal-heading { min-width: 0; }
.mission-causal-copy { display: grid; gap: 2px; }
.mission-causal-heading { display: flex; align-items: baseline; gap: 8px; }
.mission-causal-heading strong {
  flex: 1;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mission-causal-heading time {
  color: var(--text-secondary);
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 10px;
  white-space: nowrap;
}
.mission-causal-detail {
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.process-diff-panel {
  margin-bottom: 16px;
  padding: 14px;
  background: linear-gradient(110deg, var(--blue-dim), var(--bg-input) 44%);
  border: 1px solid var(--border);
  border-radius: 9px;
}
.process-diff-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 5px;
}
.process-diff-heading h3 { margin-top: 2px; font-size: 15px; }
.process-diff-scope {
  padding: 3px 7px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-secondary);
  font-size: 10px;
  white-space: nowrap;
}
.process-diff-panel > p { color: var(--text-secondary); font-size: 12px; }
.process-diff-details {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.process-diff-stat {
  display: flex;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
  padding: 7px 9px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 7px;
}
.process-diff-stat strong { color: var(--accent); font-family: 'SF Mono', 'Consolas', monospace; }
.process-diff-stat span {
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.proc-delta-col { min-width: 88px; }
#page-processes .proc-table { min-width: 940px; }
.proc-delta {
  min-width: 118px;
}
.process-delta-chip {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 2px 6px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-secondary);
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 9px;
  font-weight: 700;
  margin: 2px;
  white-space: nowrap;
}
.process-delta-chip.is-entered { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.process-delta-chip.is-hot { background: var(--yellow-dim); border-color: var(--yellow); color: var(--yellow); }
.process-delta-chip.is-stable { color: var(--text-secondary); }
.process-diff-stat.is-hot strong { color: var(--yellow); }
.process-diff-stat.is-left strong { color: var(--text-secondary); }
.process-diff-detail {
  grid-column: 1 / -1;
  padding: 6px 2px 0;
  color: var(--text-secondary);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.timeline-view-toggle {
  display: inline-flex;
  padding: 3px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.timeline-view-btn {
  padding: 5px 9px;
  background: transparent;
  border-color: transparent;
  border-radius: 5px;
  color: var(--text-secondary);
  font-size: 11px;
}
.timeline-view-btn:hover { color: var(--text-primary); }
.timeline-view-btn.active,
.timeline-view-btn[aria-pressed="true"] {
  background: var(--accent-dim);
  color: var(--accent);
}
.timeline-view-note {
  margin: -8px 0 16px;
  color: var(--text-secondary);
  font-size: 11px;
}
.timeline-phase-group { margin-bottom: 18px; }
.timeline-phase-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px -28px;
  color: var(--text-secondary);
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.timeline-hour-group,
.timeline-causal-group { position: relative; margin-bottom: 18px; }
.timeline-hour-label {
  margin: 0 0 8px -28px;
  color: var(--text-secondary);
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 10px;
  font-weight: 700;
}
.timeline-hour-events,
.timeline-causal-events { display: grid; gap: 8px; }
.timeline-causal-note {
  margin: 0 0 18px -28px;
  padding: 10px 12px;
  background: var(--blue-dim);
  border: 1px solid var(--blue);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 11px;
}
.timeline-causal-group {
  margin-left: -8px;
  padding: 12px 0 4px 14px;
  border-left: 2px solid var(--border);
}
.timeline-causal-group.phase-change { border-left-color: var(--blue); }
.timeline-causal-group.phase-trigger { border-left-color: var(--red); }
.timeline-causal-group.phase-impact { border-left-color: var(--yellow); }
.timeline-causal-group.phase-recovery { border-left-color: var(--accent); }
.timeline-correlation-chain { border-left-color: var(--blue); }
.timeline-evidence-pool-label {
  margin: 20px 0 10px -8px;
  color: var(--text-secondary);
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.timeline-causal-header { margin-bottom: 10px; }
.timeline-causal-header h3 {
  color: var(--text-primary);
  font-size: 13px;
}
.timeline-causal-header p {
  max-width: 680px;
  margin-top: 2px;
  color: var(--text-secondary);
  font-size: 11px;
}
.timeline-phase-badge {
  padding: 2px 6px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-secondary);
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
}
.timeline-phase-badge.phase-change { border-color: var(--blue); color: var(--blue); }
.timeline-phase-badge.phase-trigger { border-color: var(--red); color: var(--red); }
.timeline-phase-badge.phase-impact { border-color: var(--yellow); color: var(--yellow); }
.timeline-phase-badge.phase-recovery { border-color: var(--accent); color: var(--accent); }

/* === Explanation Drawer === */
body.mission-drawer-open { overflow: hidden; }
.mission-drawer-layer {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 460px);
}
.mission-drawer-backdrop {
  grid-column: 1 / -1;
  grid-row: 1;
  width: 100%;
  height: 100%;
  padding: 0;
  background: rgba(0, 0, 0, 0.68);
  border: 0;
  cursor: default;
  opacity: 0;
  transition: opacity 0.18s ease;
}
.mission-drawer {
  grid-column: 2;
  grid-row: 1;
  overflow-y: auto;
  width: 100%;
  height: 100%;
  padding: 24px;
  background:
    radial-gradient(circle at 80% 0, var(--blue-dim), transparent 30%),
    var(--bg-card);
  border-left: 1px solid var(--border);
  box-shadow: -18px 0 60px rgba(0, 0, 0, 0.35);
  transform: translateX(100%);
  transition: transform 0.2s ease;
}
.mission-drawer-layer.is-open .mission-drawer { transform: translateX(0); }
.mission-drawer-layer.is-open .mission-drawer-backdrop { opacity: 1; }
.mission-drawer-handle { display: none; }
.mission-drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.mission-drawer-head h2 { margin-top: 5px; font-size: 21px; letter-spacing: -0.025em; }
.mission-drawer-close { flex: 0 0 auto; }
.mission-drawer-summary {
  margin: 20px 0 10px;
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.55;
}
.mission-confidence {
  display: inline-flex;
  padding: 4px 8px;
  background: var(--blue-dim);
  border: 1px solid var(--blue);
  border-radius: 999px;
  color: var(--blue);
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 10px;
  font-weight: 700;
}
.mission-drawer-section { margin-top: 26px; }
.mission-drawer-section h3 {
  margin-bottom: 10px;
  color: var(--text-secondary);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.mission-evidence-list { display: grid; gap: 7px; }
.mission-evidence-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  padding: 11px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-left: 2px solid var(--border);
  border-radius: 7px;
}
.mission-evidence-pair dt { color: var(--text-secondary); font-size: 12px; }
.mission-evidence-pair dd {
  max-width: 230px;
  overflow-wrap: anywhere;
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}
.mission-tone-normal { border-left-color: var(--accent); }
.mission-tone-attention { border-left-color: var(--yellow); }
.mission-tone-incident { border-left-color: var(--red); }
.mission-next-checks { display: flex; flex-wrap: wrap; gap: 8px; }
.mission-check-btn {
  padding: 8px 11px;
  background: var(--bg-input);
  border-radius: 7px;
  color: var(--text-secondary);
  font-size: 12px;
}
.mission-check-btn:hover { border-color: var(--accent); color: var(--text-primary); }

/* === Layout resilience and accessibility === */
html { overflow-x: hidden; }
.header,
.header-left,
.header-right,
.main,
.page,
.card,
.info-row > *,
.gauge-row > *,
.mission-evidence-row > * { min-width: 0; }
.nav {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
}
.nav-btn { flex: 0 0 auto; }
.table-scroll {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
}
.table-scroll-wide > table { min-width: 720px; }
.fm-breadcrumb { overflow-wrap: anywhere; }
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

@media (max-width: 900px) {
  .mission-now-body { grid-template-columns: 1fr; align-items: stretch; }
  .mission-evidence-row { grid-template-columns: 1fr; }
  .mission-metrics { max-width: none; }
}


/* === Timeline Pagination === */
.timeline-pagination {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  margin-top: 24px;
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.timeline-pagination button {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
  min-height: 36px;
}
.timeline-pagination button:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--accent);
}
.timeline-pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.timeline-page-info {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 500;
}

@media (max-width: 768px) {
  .header-left { overflow: hidden; }
  .header-left h1,
  .server-name { flex: 0 0 auto; }
  .nav { scroll-padding-inline: 16px; }
  .nav-btn[aria-current="page"] { scroll-margin-inline: 16px; }
  .incident-banner {
    top: 57px;
    grid-template-columns: 3px minmax(0, 1fr);
    gap: 10px;
    padding: 10px 16px;
  }
  .incident-banner-actions {
    grid-column: 2;
    justify-content: flex-start;
    margin-top: 2px;
  }
  .incident-banner-copy strong,
  .incident-banner-copy > span { white-space: normal; }
  .mission-now-head,
  .mission-now-body,
  .mission-recommendation,
  .mission-now-actions { padding-right: 17px; padding-left: 21px; }
  .mission-now-head { gap: 10px; padding-top: 16px; }
  .mission-state-line { align-items: flex-start; flex-direction: column; gap: 4px; }
  .mission-now-body { gap: 18px; padding-top: 18px; padding-bottom: 18px; }
  .mission-brief h2 { font-size: 23px; }
  .mission-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mission-recommendation { grid-template-columns: 1fr; gap: 4px; }
  .mission-now-actions { justify-content: stretch; }
  .mission-now-actions .mission-btn { flex: 1; }
  .process-diff-details { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .timeline-controls { align-items: stretch; flex-direction: column; }
  .timeline-view-toggle { align-self: flex-start; }
  .timeline-filters { max-width: 100%; }
  .timeline-dot { left: -24px; }
  .timeline-item-header { align-items: flex-start; flex-wrap: wrap; }
  .timeline-title { min-width: 0; overflow-wrap: anywhere; }
  .timeline-time { margin-left: auto; }
  .uptime-item { align-items: flex-start; flex-wrap: wrap; gap: 8px 12px; }
  .uptime-item-name { min-width: 0; }
  .uptime-item-url { flex-basis: 100%; order: 4; white-space: normal; overflow-wrap: anywhere; }
  .uptime-item-actions { margin-left: auto; }
  .dialog { width: min(100% - 32px, 440px); min-width: 0; }
  .mission-drawer-layer { grid-template-columns: 1fr; align-items: end; }
  .mission-drawer {
    grid-column: 1;
    align-self: end;
    height: min(86vh, 720px);
    padding: 14px 18px 24px;
    border-top: 1px solid var(--border);
    border-left: 0;
    border-radius: 18px 18px 0 0;
    transform: translateY(100%);
  }
  .mission-drawer-layer.is-open .mission-drawer { transform: translateY(0); }
  .mission-drawer-handle {
    display: block;
    width: 42px;
    height: 4px;
    margin: 0 auto 13px;
    background: var(--border);
    border-radius: 999px;
  }
}

  .timeline-pagination {
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px;
  }
  .timeline-pagination button {
    min-height: 44px;
    padding: 10px 14px;
    font-size: 13px;
  }
  .timeline-page-info {
    width: 100%;
    text-align: center;
    order: 3;
  }
@media (max-width: 480px) {
  .header { gap: 8px; }
  .header h1 { font-size: 14px; }
  .server-name { display: none; }
  .connection-status .status-text { display: none; }
  .main { padding-right: 12px; padding-left: 12px; }
  .gauge-row { gap: 8px; }
  .gauge-card { padding: 16px 8px; }
  .gauge-container { width: 88px; height: 88px; }
  .gauge-value { font-size: 19px; }
  .mission-freshness { max-width: 120px; white-space: normal; text-align: right; }
  .mission-now-actions { flex-direction: column; }
  .mission-now-actions .mission-btn { width: 100%; }
  .mission-change { grid-template-columns: 54px minmax(0, 1fr); }
  .mission-causal-event { grid-template-columns: 58px minmax(0, 1fr); padding-right: 0; padding-left: 8px; }
  .mission-card-head { align-items: center; }
  .process-diff-heading { align-items: stretch; flex-direction: column; }
  .process-diff-scope { align-self: flex-start; }
  .proc-controls { width: 100%; }
  .proc-controls > * { max-width: 100%; }
  .tool-input-row > .search-input { flex: 1 1 100%; min-height: 44px; }
  .tool-input-row > .sort-select { flex: 1 1 120px; min-height: 44px; }
  .tool-port-input { flex-basis: 100% !important; }
  .tool-run-state { align-items: flex-start; flex-wrap: wrap; }
  .network-diagnosis-head { flex-direction: column; gap: 4px; }
  .network-diagnosis-route-group { align-items: flex-start; width: 100%; }
  .network-diagnosis-route { max-width: 100%; text-align: left; overflow-wrap: anywhere; }
  .tool-recommended-badge { white-space: normal; }
  .tool-check { flex: 1 1 100%; min-height: 44px; }
  .tool-followup { align-items: stretch; flex-direction: column; }
  .tool-diagnosis-link { width: 100%; min-height: 44px; white-space: normal; }
  .diagnosis-stages { grid-template-columns: 1fr 1fr; }
  .uptime-item-latency { margin-left: auto; }
  .uptime-item-actions { flex-basis: 100%; margin-left: 0; }
  .uptime-item-actions .btn,
  .uptime-item-actions button { flex: 1; }
  .mission-evidence-pair { grid-template-columns: 1fr; gap: 3px; }
  .mission-evidence-pair dd { max-width: none; text-align: left; }
  /* Improved touch targets */
  .nav-btn { min-height: 44px; }
  .timeline-filter-chip { min-height: 44px; padding: 10px 14px; font-size: 13px; }
  .timeline-view-toggle button { min-height: 44px; padding: 8px 12px; }
  .btn, button { min-height: 44px; }
  .proc-controls button, .proc-controls select { min-height: 44px; }
  .uptime-item-actions button { min-height: 44px; padding: 8px 12px; }
  .mission-btn { min-height: 44px; }
  
  /* Better spacing for mobile */
  .timeline-item { padding: 14px 12px; margin-bottom: 10px; }
  .timeline-dot { width: 14px; height: 14px; top: 16px; }
  
  /* Process table mobile improvements */
  .proc-row { padding: 12px 8px; }
  .proc-row:hover { background: var(--bg-hover); }
  
  /* Docker cards */
  .docker-container { grid-template-columns: 1fr; }
  .docker-card { padding: 14px; }
  
  /* File manager */
  .file-row { padding: 12px 8px; min-height: 44px; }
  .file-actions button { min-height: 36px; padding: 6px 10px; }

}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* File Manager v2 Styles */
.fm-dropzone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 32px;
  text-align: center;
  margin: 16px 0;
  transition: all 0.3s ease;
  background: var(--bg-secondary);
}

.fm-dropzone-active {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.1);
  transform: scale(1.02);
}

.fm-dropzone-icon {
  font-size: 48px;
  margin-bottom: 8px;
  opacity: 0.5;
}

.fm-dropzone-text {
  color: var(--text-muted);
  font-size: 14px;
}

.fm-preview-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.fm-preview-card {
  background: var(--bg-primary);
  border-radius: 12px;
  max-width: 90vw;
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.fm-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.fm-preview-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.fm-preview-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s;
}

.fm-preview-close:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.fm-preview-content {
  padding: 20px;
}

.fm-preview-content img {
  max-width: 100%;
  max-height: 80vh;
  display: block;
  margin: 0 auto;
}

.fm-preview-content iframe {
  width: 800px;
  max-width: 100%;
  height: 600px;
  border: none;
}

.fm-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.fm-actions button {
  min-height: 32px;
  padding: 6px 12px;
  font-size: 12px;
}

.fm-editor-conflict {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.fm-editor-conflict-icon {
  font-size: 20px;
}

.fm-editor-conflict-text {
  flex: 1;
  color: var(--text-primary);
  font-size: 14px;
}

.fm-editor-conflict-text strong {
  color: rgb(239, 68, 68);
}

.fm-editor-conflict-button {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.fm-editor-conflict-button:hover {
  background: var(--primary-hover);
}

.fm-breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 16px;
  overflow-x: auto;
  white-space: nowrap;
}

.fm-breadcrumb a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.2s;
}

.fm-breadcrumb a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

.fm-breadcrumb-separator {
  color: var(--text-muted);
  margin: 0 2px;
}

.fm-table {
  width: 100%;
  border-collapse: collapse;
}

.fm-table th,
.fm-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.fm-table th {
  background: var(--bg-secondary);
  font-weight: 600;
  font-size: 13px;
  color: var(--text-secondary);
  position: sticky;
  top: 0;
  z-index: 1;
}

.fm-table th.sortable {
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}

.fm-table th.sortable:hover {
  background: var(--bg-tertiary);
}

.fm-table th.sortable::after {
  content: ' ↕';
  opacity: 0.3;
  font-size: 10px;
}

.fm-table th.sortable.sort-asc::after {
  content: ' ↑';
  opacity: 1;
}

.fm-table th.sortable.sort-desc::after {
  content: ' ↓';
  opacity: 1;
}

.fm-table tbody tr {
  transition: background 0.2s;
}

.fm-table tbody tr:hover {
  background: var(--bg-secondary);
}

.fm-table tbody tr.selected {
  background: rgba(59, 130, 246, 0.1);
}

.fm-table input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.fm-icon {
  width: 40px;
  text-align: center;
  font-size: 18px;
}

.fm-name a {
  color: var(--text-primary);
  text-decoration: none;
  transition: color 0.2s;
}

.fm-name a:hover {
  color: var(--primary);
}

.fm-search-sort {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.fm-search {
  flex: 1;
  min-width: 200px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  transition: border-color 0.2s;
}

.fm-search:focus {
  outline: none;
  border-color: var(--primary);
}

.fm-sort {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.2s;
}

.fm-sort:focus {
  outline: none;
  border-color: var(--primary);
}

.fm-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.fm-empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.3;
}

.fm-empty-text {
  font-size: 14px;
}

@media (max-width: 768px) {
  .fm-search-sort {
    flex-direction: column;
  }

  .fm-search,
  .fm-sort {
    min-width: 100%;
  }

  .fm-table th:nth-child(4),
  .fm-table td:nth-child(4),
  .fm-table th:nth-child(5),
  .fm-table td:nth-child(5) {
    display: none;
  }

  .fm-actions {
    flex-direction: column;
    gap: 4px;
  }

  .fm-actions button {
    width: 100%;
  }

  .fm-preview-card {
    max-width: 95vw;
    max-height: 95vh;
  }

  .fm-preview-content iframe {
    height: 500px;
  }
}
