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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #222636;
  --border: #2e3348;
  --text: #e0e4f0;
  --muted: #6b7280;
  --accent: #4f8ef7;
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
  --running: #818cf8;

}

body { background: var(--bg); color: var(--text); font-family: system-ui, sans-serif; font-size: 14px; }

/* Header */
header { background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 24px; }
.header-inner { display: flex; align-items: center; gap: 32px; height: 52px; }
h1 { font-size: 16px; font-weight: 700; color: var(--accent); white-space: nowrap; }
nav { display: flex; gap: 4px; }
.tab-btn { background: none; border: none; color: var(--muted); padding: 6px 14px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.tab-btn:hover { background: var(--surface2); color: var(--text); }
.tab-btn.active { background: var(--surface2); color: var(--accent); font-weight: 600; }

/* Main */
main { padding: 24px; max-width: 1400px; margin: 0 auto; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.panel-header h2 { font-size: 15px; font-weight: 600; }
.actions { display: flex; gap: 8px; align-items: center; }

/* Buttons */
button { background: var(--accent); color: #fff; border: none; padding: 6px 14px; border-radius: 6px; cursor: pointer; font-size: 13px; }
button:hover { opacity: 0.85; }
button.secondary { background: var(--surface2); color: var(--text); }
button.danger { background: var(--err); }
button.small { padding: 3px 10px; font-size: 12px; }
button.accent { background: #7c3aed; }
button.accent:hover { opacity: 0.85; }
button.btn-ai-read { background: #166534; color: #86efac; border: none; }
button.btn-ai-read:hover { opacity: 0.85; }

/* Inputs / selects */
input, select, textarea {
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  padding: 6px 10px; border-radius: 6px; font-size: 13px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
select { width: auto; min-width: 140px; }

/* Tables */
table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: 8px; overflow: hidden; }
th { background: var(--surface2); text-align: left; padding: 10px 14px; font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; }
td { padding: 10px 14px; border-top: 1px solid var(--border); vertical-align: top; }
tr:hover td { background: var(--surface2); }
.log-msg { font-family: monospace; font-size: 12px; word-break: break-all; max-width: 600px; }
.mono { font-family: monospace; font-size: 12px; }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; }
.badge-ok { background: #14532d; color: var(--ok); }
.badge-err { background: #450a0a; color: var(--err); }
.badge-warn { background: #451a03; color: var(--warn); }
.badge-running { background: #1e1b4b; color: var(--running); }button.warn { background: var(--warn); color: #000; }
.version-pill { font-family: monospace; font-size: 11px; background: var(--surface2); border: 1px solid var(--border); padding: 2px 7px; border-radius: 4px; color: var(--muted); }

/* Log groups */
.log-group { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; margin-bottom: 10px; overflow: hidden; }
.log-group-header { display: flex; gap: 10px; align-items: center; padding: 10px 14px; cursor: pointer; user-select: none; }
.log-group-header:hover { background: var(--surface2); }
.log-group-arrow { color: var(--muted); font-size: 11px; width: 12px; }
.log-group-summary { margin-left: auto; display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }
.log-group-body { overflow-x: auto; }
.log-group-body td, .log-group-body .log-msg, .log-group-body .mono { font-size: 9px; }
.log-group-body th { font-size: 8px; }
.log-group-body .badge { font-size: 8px; padding: 1px 5px; }
.log-group-body td { padding: 3px 14px; }
.log-group-body.hidden { display: none; }
.hidden { display: none; }

/* Level row coloring */
tr.level-error td { background: #1a0a0a; }
tr.level-warn td { background: #1a1200; }

/* Overview grid */
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.app-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.app-card.status-up { border-left: 3px solid var(--ok); }
.app-card.status-down { border-left: 3px solid var(--err); }
.app-card.status-degraded { border-left: 3px solid var(--warn); }
.app-card.status-unknown { border-left: 3px solid var(--muted); }
.card-title { font-weight: 700; font-size: 15px; }
.card-host { color: var(--muted); font-size: 12px; }
.card-meta { color: var(--muted); font-size: 11px; }
.app-card.platform-card { border-left: 3px solid var(--accent); }

/* Modals */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal.hidden { display: none; }
.modal-box { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 24px; width: 440px; max-height: 90vh; overflow-y: auto; }
.modal-actions { display: flex; gap: 8px; margin-top: 20px; justify-content: flex-end; }
#morph-reply-area:not(.hidden) { display: flex; }
pre { font-family: monospace; font-size: 12px; white-space: pre-wrap; word-break: break-all; background: var(--bg); padding: 12px; border-radius: 6px; max-height: 500px; overflow-y: auto; }

/* Misc */
.empty { color: var(--muted); padding: 16px; text-align: center; }
.muted { color: var(--muted); font-size: 12px; }

/* App links */
a.app-link { color: var(--accent); text-decoration: none; font-weight: 700; }
a.app-link:hover { text-decoration: underline; }
a.app-link .app-link-arrow { font-size: 11px; opacity: 0.7; margin-left: 3px; }

/* Git action buttons */
.btn-git-action {
  background: transparent;
  border: 1px solid rgba(99,102,241,0.35);
  color: #818cf8;
  border-radius: 4px;
  padding: 2px 9px;
  font-size: 11px;
  font-family: monospace;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-git-action:hover { background: rgba(99,102,241,0.15); }

/* Component Matrix */
.matrix-res-grid { display: flex; flex-wrap: wrap; gap: 16px; }
.matrix-res-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; min-width: 200px; flex: 1 1 200px; max-width: 280px; }
.matrix-res-name { font-weight: 700; font-size: 13px; margin-bottom: 10px; }
.matrix-res-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.matrix-res-label { font-size: 11px; color: var(--muted); width: 30px; flex-shrink: 0; }
.matrix-res-value { font-size: 11px; color: var(--muted); width: 62px; text-align: right; flex-shrink: 0; }
.matrix-res-subline { font-size: 10px; color: var(--muted); margin-bottom: 4px; padding-left: 38px; }
.matrix-res-runtime { font-size: 10px; color: var(--muted); margin-top: 8px; font-family: monospace; }
.res-bar-track { flex: 1; height: 6px; border-radius: 3px; background: var(--surface2); min-width: 60px; }
.res-bar-fill  { height: 6px; border-radius: 3px; transition: width 0.3s; }
.matrix-scroll { overflow-x: auto; }
.matrix-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: 8px; overflow: hidden; }
.matrix-table td.cell-shared { background: rgba(79,142,247,0.12); color: var(--accent); font-size: 11px; }
.matrix-table td.cell-mismatch { color: var(--warn); font-size: 11px; }
.matrix-table td.cell-empty { color: var(--muted); font-size: 11px; }
.matrix-table td { font-size: 12px; }
.matrix-table td.pkg-name { font-family: monospace; font-size: 11px; white-space: nowrap; }
.matrix-table tr.pkg-shared td.pkg-name { color: var(--accent); }

/* Alerts tab */
.alerts-grid { display: flex; flex-direction: column; gap: 16px; max-width: 660px; }
.alerts-section { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 16px; }
.alerts-section-title { font-size: 13px; font-weight: 600; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; }
.alerts-events { display: flex; flex-direction: column; gap: 8px; }
.alerts-events label { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.alerts-events input[type=checkbox] { width: 15px; height: 15px; flex-shrink: 0; }
.alerts-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13px; }
.alerts-row:last-child { margin-bottom: 0; }
.alerts-row label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.alerts-label { flex-shrink: 0; color: var(--muted); width: 80px; text-align: right; }

/* App summary modal */
.summary-meta-row { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.summary-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-top: 12px; }
.summary-section { background: var(--surface2); border-radius: 8px; padding: 12px; }
.summary-section-title { font-size: 12px; font-weight: 700; margin-bottom: 8px; text-transform: uppercase; letter-spacing: .04em; }
.summary-section-title.ok     { color: var(--ok); }
.summary-section-title.warn   { color: var(--warn); }
.summary-section-title.accent { color: var(--accent); }
.summary-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 5px; }
.summary-list li { font-size: 12px; line-height: 1.4; color: var(--text); }

/* Status text utility classes */
.ok   { color: var(--ok); }
.err  { color: var(--err); }
.muted { color: var(--muted); }

/* AI hint */
.ai-hint-box { display: flex; gap: 10px; align-items: flex-start; background: rgba(79,142,247,0.07); border: 1px solid rgba(79,142,247,0.2); border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; font-size: 13px; line-height: 1.5; }
.ai-hint-label { background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 4px; flex-shrink: 0; margin-top: 2px; letter-spacing: .04em; }
