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

/* ── Base ──────────────────────────────────────────── */
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #1a1a1a;
  line-height: 1.55;
  background: #fff;
  min-height: 100vh;
}

a { color: inherit; }

/* ── Header ────────────────────────────────────────── */
.site-header {
  background: #4a1a6b;
  border-bottom: 3px solid #5c2d82;
}

.site-header-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
}

.site-logo {
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 3px;
  text-decoration: none;
}

.site-subtitle {
  color: rgba(255,255,255,0.55);
  font-size: 0.82rem;
  font-weight: 400;
  margin-left: 12px;
  padding-left: 12px;
  border-left: 1px solid rgba(255,255,255,0.2);
  letter-spacing: 0.3px;
}

.site-header .admin-tag {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: rgba(255,255,255,0.6);
  margin-left: 14px;
  padding-top: 2px;
}

.site-header nav {
  margin-left: auto;
  display: flex;
  gap: 20px;
}

.site-header nav a {
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 500;
}

.site-header nav a:hover { color: #fff; }

/* ── Status strip ──────────────────────────────────── */
.status-strip {
  padding: 14px 24px;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.status-strip--ok {
  background: #e8f5e9;
  color: #2e7d32;
}

.status-strip--issue {
  background: #fff8e1;
  color: #f57f17;
}

/* ── Page container ────────────────────────────────── */
.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

/* ── Section headers ───────────────────────────────── */
.section-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #999;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e5e5e5;
}

/* ── Component tiles ───────────────────────────────── */
.tile-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 28px;
}

.tile {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid #e5e5e5;
  background: #fafafa;
  font-size: 0.78rem;
  font-weight: 500;
  color: #444;
}

.tile-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tile-name {
  white-space: nowrap;
}

.tile--operational { border-color: #c8e6c9; background: #f1f8e9; }
.tile--operational .tile-dot { background: #2e7d32; }

.tile--degraded { border-color: #ffe0b2; background: #fff3e0; color: #e65100; }
.tile--degraded .tile-dot { background: #e65100; }

.tile--major_outage { border-color: #ef9a9a; background: #fce4ec; color: #c62828; }
.tile--major_outage .tile-dot { background: #c62828; }

/* ── Component tags ───────────────────────────────── */
.component-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}

.component-tag {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 3px;
  letter-spacing: 0.3px;
}

.component-tag--product {
  background: #f3e8ff;
  color: #4a1a6b;
}

.component-tag--integration {
  background: #e3f2fd;
  color: #1565c0;
}

/* ── Incident list ─────────────────────────────────── */
.incident-list {
  list-style: none;
}

.incident-item {
  padding: 20px 0;
  border-bottom: 1px solid #eee;
}

.incident-item:last-child { border-bottom: none; }

.incident-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.incident-severity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot--critical { background: #c62828; }
.dot--major    { background: #e65100; }
.dot--minor    { background: #f9a825; }

.incident-severity-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #777;
}

.incident-status-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: #999;
}

.incident-status-label--resolved { color: #2e7d32; font-weight: 600; }
.incident-status-label--investigating { color: #c62828; }
.incident-status-label--identified { color: #e65100; }
.incident-status-label--monitoring { color: #1565c0; }

.incident-title {
  font-size: 1rem;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 6px;
  line-height: 1.4;
}

.incident-desc {
  font-size: 0.88rem;
  color: #555;
  line-height: 1.6;
}

.incident-desc p { margin-bottom: 6px; }
.incident-desc p:last-child { margin-bottom: 0; }

.incident-desc a {
  color: #4a1a6b;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.incident-desc a:hover {
  color: #3a1255;
}

.incident-timestamp {
  font-size: 0.75rem;
  color: #aaa;
  margin-top: 10px;
  font-variant-numeric: tabular-nums;
}

.incident-actions-inline {
  margin-left: auto;
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Timeline ─────────────────────────────────────── */
.timeline {
  margin-top: 12px;
  padding-left: 16px;
  border-left: 2px solid #e5e5e5;
}

.timeline-entry {
  padding: 10px 0 10px 16px;
  position: relative;
}

.timeline-entry::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 16px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #d0d0d0;
  border: 2px solid #fff;
}

.timeline-entry:first-child::before { background: #4a1a6b; }

.timeline-entry + .timeline-entry {
  border-top: 1px solid #f5f5f5;
}

.timeline-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.timeline-time {
  font-size: 0.73rem;
  color: #aaa;
  font-variant-numeric: tabular-nums;
}

.timeline-edit-link {
  font-size: 0.72rem;
  color: #999;
  text-decoration: none;
  margin-left: auto;
}

.timeline-edit-link:hover {
  color: #4a1a6b;
  text-decoration: underline;
}

/* ── History toggle ───────────────────────────────── */
.history-toggle {
  margin-top: 4px;
}

.history-toggle-btn {
  font-size: 0.78rem;
  font-weight: 500;
  color: #4a1a6b;
  cursor: pointer;
  padding: 6px 0;
  list-style: none;
  user-select: none;
}

.history-toggle-btn::-webkit-details-marker { display: none; }

.history-toggle-btn::before {
  content: "▸ ";
  display: inline;
  font-size: 0.7rem;
}

.history-toggle[open] > .history-toggle-btn::before {
  content: "▾ ";
}

.history-toggle-btn:hover {
  color: #3a1255;
}

.timeline--history {
  margin-top: 4px;
}

/* ── RCA toggle ───────────────────────────────────── */
.rca-toggle {
  margin-top: 10px;
}

.rca-toggle-btn {
  font-size: 0.78rem;
  font-weight: 600;
  color: #4a1a6b;
  cursor: pointer;
  padding: 6px 0;
  list-style: none;
  user-select: none;
}

.rca-toggle-btn::-webkit-details-marker { display: none; }

.rca-toggle-btn::before {
  content: "▸ ";
  display: inline;
  font-size: 0.7rem;
}

.rca-toggle[open] > .rca-toggle-btn::before {
  content: "▾ ";
}

.rca-toggle-btn:hover {
  color: #3a1255;
}

.rca-content {
  margin-top: 10px;
  padding: 16px;
  background: #f8f6fa;
  border-left: 3px solid #4a1a6b;
  border-radius: 0 4px 4px 0;
}

.rca-body h2 { font-size: 0.92rem; font-weight: 700; color: #333; margin: 12px 0 6px; }
.rca-body h3 { font-size: 0.86rem; font-weight: 600; color: #444; margin: 10px 0 4px; }
.rca-body h2:first-child, .rca-body h3:first-child { margin-top: 0; }
.rca-body ul, .rca-body ol { padding-left: 20px; margin-bottom: 8px; }
.rca-body li { margin-bottom: 2px; }
.rca-body strong { font-weight: 600; }
.rca-body hr { border: none; border-top: 1px solid #e0d8e6; margin: 12px 0; }

/* ── Info box ─────────────────────────────────────── */
.info-box {
  font-size: 0.82rem;
  line-height: 1.5;
  padding: 12px 14px;
  margin-bottom: 18px;
  background: #fffde7;
  border: 1px solid #fff9c4;
  border-radius: 4px;
  color: #6d5e00;
}

.info-box strong {
  color: #4a3f00;
}

/* ── Empty state ───────────────────────────────────── */
.empty-msg {
  color: #bbb;
  font-size: 0.9rem;
  padding: 24px 0;
}

/* ── Buttons ───────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 7px 16px;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.4;
}

.btn--primary {
  background: #4a1a6b;
  color: #fff;
  border-color: #4a1a6b;
}

.btn--primary:hover { background: #3a1255; }

.btn--ghost {
  background: transparent;
  color: #555;
  border-color: #ddd;
}

.btn--ghost:hover { border-color: #aaa; }

.btn--resolve {
  background: #2e7d32;
  color: #fff;
  border-color: #2e7d32;
}

.btn--resolve:hover { background: #1b5e20; }

.btn--sm {
  padding: 4px 10px;
  font-size: 0.72rem;
}

/* ── Flash ─────────────────────────────────────────── */
.flash {
  font-size: 0.85rem;
  padding: 10px 16px;
  margin-bottom: 24px;
  border-left: 3px solid #2e7d32;
  background: #f1f8e9;
  color: #33691e;
}

.flash--alert {
  border-left-color: #c62828;
  background: #fce4ec;
  color: #b71c1c;
}

/* ── Forms ─────────────────────────────────────────── */
.form-wrap {
  border: 1px solid #e5e5e5;
  border-radius: 4px;
  padding: 28px;
  background: #fafafa;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.field { display: flex; flex-direction: column; gap: 4px; }

.field label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #444;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.field input,
.field textarea,
.field select {
  padding: 8px 10px;
  border: 1px solid #d0d0d0;
  border-radius: 3px;
  font-size: 0.9rem;
  font-family: inherit;
  background: #fff;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: #4a1a6b;
  box-shadow: 0 0 0 2px rgba(74, 26, 107, 0.1);
}

.field textarea { resize: vertical; min-height: 100px; }

.field-row {
  display: flex;
  gap: 16px;
}

.field-row .field { flex: 1; }

.form-footer {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.form-errors {
  background: #fce4ec;
  border: 1px solid #ef9a9a;
  color: #b71c1c;
  padding: 12px 16px;
  border-radius: 3px;
  font-size: 0.85rem;
}

.form-errors ul { margin-top: 6px; padding-left: 18px; }

.field-label-text {
  font-size: 0.78rem;
  font-weight: 600;
  color: #444;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 4px;
}

.checkbox-group-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.checkbox-group-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  color: #333;
  cursor: pointer;
  padding: 2px 0;
}

.checkbox-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #4a1a6b;
}

/* ── Page title ────────────────────────────────────── */
.page-heading {
  font-size: 1.3rem;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 28px;
}

.page-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.page-toolbar .page-heading { margin-bottom: 0; }

/* ── History link ──────────────────────────────────── */
.history-link-wrap {
  text-align: center;
  padding: 28px 0 0;
  border-top: 1px solid #eee;
  margin-top: 28px;
}

.history-link {
  font-size: 0.85rem;
  font-weight: 500;
  color: #4a1a6b;
  text-decoration: none;
}

.history-link:hover {
  text-decoration: underline;
}

/* ── Filter bar ───────────────────────────────────── */
.filter-bar {
  margin-bottom: 24px;
}

.filter-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: #999;
}

select.filter-select {
  padding: 6px 10px;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  font-size: 0.82rem;
  font-family: inherit;
  color: #333;
  background: #fff;
  cursor: pointer;
  min-width: 200px;
}

select.filter-select:focus {
  outline: none;
  border-color: #4a1a6b;
  box-shadow: 0 0 0 2px rgba(74, 26, 107, 0.1);
}

/* Tom Select copies the original class to its wrapper; avoid double borders. */
.ts-wrapper.filter-select {
  border: none;
  padding: 0;
  background: transparent;
  min-width: 220px;
}

/* Tom Select custom theme (no default CSS loaded) */
.ts-wrapper { position: relative; min-width: 220px; font-size: 0.82rem; }
.ts-wrapper .ts-control {
  display: flex; align-items: center; gap: 4px;
  border: 1px solid #d0d0d0; border-radius: 4px;
  padding: 6px 28px 6px 10px; background: #fff;
  cursor: pointer; position: relative;
}
.ts-wrapper .ts-control::after {
  content: ""; position: absolute; right: 10px; top: 50%;
  margin-top: -3px; border-left: 5px solid transparent;
  border-right: 5px solid transparent; border-top: 5px solid #999;
  pointer-events: none;
}
.ts-wrapper .ts-control > input {
  border: none; outline: none; background: transparent;
  font-size: inherit; font-family: inherit; color: #333;
  flex: 1; min-width: 40px; padding: 0;
}
.ts-wrapper .ts-control > input::placeholder {
  color: transparent;
}
.ts-wrapper.focus .ts-control > input::placeholder {
  color: #9a9a9a;
}
.ts-wrapper .ts-control > .item { white-space: nowrap; }
.ts-wrapper.focus .ts-control {
  border-color: #4a1a6b;
  box-shadow: 0 0 0 2px rgba(74, 26, 107, 0.1);
}
.ts-dropdown {
  position: absolute; left: 0; right: 0; top: 100%;
  border: 1px solid #d0d0d0; border-top: none;
  border-radius: 0 0 4px 4px; background: #fff;
  z-index: 100; max-height: 240px; overflow-y: auto;
}
.ts-dropdown .ts-dropdown-content { padding: 4px 0; }
.ts-dropdown .option {
  padding: 6px 10px; cursor: pointer; font-size: 0.82rem; color: #333;
}
.ts-dropdown .option:hover, .ts-dropdown .active {
  background: #f3e8ff; color: #4a1a6b;
}
.ts-hidden-accessible { display: none; }

/* ── Pagination ───────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 28px 0;
  margin-top: 12px;
}

.pagination-info {
  font-size: 0.78rem;
  color: #999;
}

/* ── Login ─────────────────────────────────────────── */
.login-page {
  display: flex;
  justify-content: center;
  padding-top: 80px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  padding: 36px 32px;
  background: #fafafa;
}

.login-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: 0.82rem;
  color: #999;
  margin-bottom: 24px;
}

.btn--full {
  width: 100%;
  text-align: center;
}

.nav-divider {
  width: 1px;
  height: 14px;
  background: rgba(255,255,255,0.15);
}

.admin-signout {
  color: rgba(255,255,255,0.45);
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 400;
}

.admin-signout:hover { color: rgba(255,255,255,0.85); }

.login-flash {
  font-size: 0.82rem;
  padding: 8px 12px;
  border-radius: 4px;
  margin-bottom: 16px;
  background: #f1f8e9;
  color: #33691e;
}

.login-flash--alert {
  background: #fce4ec;
  color: #b71c1c;
}

/* ── Footer ────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 24px;
  font-size: 0.72rem;
  color: #bbb;
}

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 600px) {
  .site-header-inner { padding: 12px 16px; }
  .site-subtitle { font-size: 0.72rem; margin-left: 10px; padding-left: 10px; }

  .page { padding: 24px 16px 60px; }

  .tile-grid { gap: 6px; }
  .tile { font-size: 0.72rem; padding: 5px 10px; }

  .field-row { flex-direction: column; }
  .incident-actions-inline { margin-left: 0; margin-top: 8px; }
  .page-toolbar { flex-direction: column; align-items: flex-start; gap: 12px; }

  .incident-title { font-size: 0.92rem; }
  .incident-desc { font-size: 0.82rem; }
  .timeline-entry { padding: 8px 0 8px 12px; }
}

@media (max-width: 380px) {
  .site-subtitle { display: none; }
}
