/* Theme tokens. Teams tells us its theme (default / dark / contrast) through TeamsJS,
   which we set as data-theme on <html>. Outside Teams we follow the system setting. */
:root {
  color-scheme: light dark;
  --bg: #ffffff; --bg-elevated: #f5f5f5; --bg-tile: #fafafa; --border: #e1e1e1;
  --text: #242424; --text-secondary: #616161; --text-muted: #8a8a8a;

  /* Status colours are constant across themes: meaning must not shift with theme. */
  --status-healthy: #13a10e; --status-attention: #f7b32b; --status-critical: #c4314b;
  --status-info: #5b5fc7; --status-neutral: #616161;
  --wash-healthy: rgba(19,161,14,.08); --wash-attention: rgba(247,179,43,.10); --wash-critical: rgba(196,49,75,.10);
  --radius: 6px;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="default"]):not([data-theme="contrast"]) {
    --bg: #1f1f1f; --bg-elevated: #2d2c2c; --bg-tile: #292828; --border: #3d3d3d;
    --text: #ffffff; --text-secondary: #adadad; --text-muted: #7a7a7a;
  }
}
:root[data-theme="default"] { color-scheme: light; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1f1f1f; --bg-elevated: #2d2c2c; --bg-tile: #292828; --border: #3d3d3d;
  --text: #ffffff; --text-secondary: #adadad; --text-muted: #7a7a7a;
}
:root[data-theme="contrast"] {
  color-scheme: dark;
  --bg: #000; --bg-elevated: #000; --bg-tile: #000; --border: #fff;
  --text: #fff; --text-secondary: #fff; --text-muted: #ffff00;
  --wash-healthy: transparent; --wash-attention: transparent; --wash-critical: transparent;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-size: 14px; line-height: 1.4; }
a { color: var(--status-info); }
:focus-visible { outline: 2px solid var(--status-info); outline-offset: 2px; }

/* Header */
.app-header { display: flex; align-items: center; gap: 16px; padding: 10px 16px;
  border-bottom: 1px solid var(--border); background: var(--bg-elevated); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.brand-mark { width: 12px; height: 12px; border-radius: 3px; background: var(--status-info); }
.header-strip { display: flex; gap: 16px; flex: 1; flex-wrap: wrap; }
.strip-item { display: inline-flex; gap: 6px; font-size: 12px; white-space: nowrap; }
.strip-item .k { color: var(--text-secondary); }
.strip-item .v { font-weight: 600; }
.who { font-size: 12px; color: var(--text-secondary); }

.tab-nav { display: flex; gap: 4px; padding: 6px 16px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab-nav a { padding: 6px 10px; border-radius: var(--radius); text-decoration: none; color: var(--text-secondary); white-space: nowrap; }
.tab-nav a[aria-current="page"] { background: var(--bg-tile); color: var(--text); font-weight: 600; }

.sample-banner { margin: 12px 16px 0; padding: 8px 12px; border-radius: var(--radius);
  border: 1px dashed var(--status-attention); background: var(--wash-attention); font-size: 13px; }

main { padding: 16px; outline: none; }

/* Status banner (Overview) */
.status-banner { display: grid; gap: 4px; padding: 12px 16px; border-radius: var(--radius);
  border: 1px solid var(--border); border-left: 4px solid var(--status-neutral); background: var(--bg-tile); margin-bottom: 16px; }
.status-banner .row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.status-banner h1 { font-size: 16px; margin: 0; letter-spacing: .04em; }
.overall { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--status-neutral); display: inline-block; }
.overall-nominal { border-left-color: var(--status-healthy); } .overall-nominal .dot { background: var(--status-healthy); }
.overall-degraded { border-left-color: var(--status-attention); } .overall-degraded .dot { background: var(--status-attention); }
.overall-critical { border-left-color: var(--status-critical); } .overall-critical .dot { background: var(--status-critical); }
.reasons { color: var(--text-secondary); font-size: 13px; }
.freshness { margin-left: auto; font-size: 12px; color: var(--text-secondary); }
.freshness.stale { color: var(--status-critical); font-weight: 600; }
.icon-btn { border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: var(--radius); padding: 2px 8px; cursor: pointer; }

/* Tile grid */
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.tile { background: var(--bg-tile); border: 1px solid var(--border); border-left: 4px solid var(--status-neutral);
  border-radius: var(--radius); padding: 16px; cursor: pointer; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; align-content: start; min-height: 190px; min-width: 0; }
.tile.wide { grid-column: span 2; }
@media (max-width: 560px) { .tile.wide { grid-column: auto; } }
@media (prefers-reduced-motion: no-preference) {
  .tile { transition: transform .12s ease, box-shadow .12s ease; }
  .tile:hover { transform: translateY(-1px); box-shadow: 0 2px 8px rgba(0,0,0,.12); }
}
.tile.status-healthy { border-left-color: var(--status-healthy); background: var(--wash-healthy); }
.tile.status-attention, .tile.status-degraded { border-left-color: var(--status-attention); background: var(--wash-attention); }
.tile.status-critical { border-left-color: var(--status-critical); background: var(--wash-critical); }
.tile-title { margin: 0; font-size: 12px; letter-spacing: .06em; color: var(--text-secondary); }
.tile-primary .value { font-size: 44px; font-weight: 600; line-height: 1; }
.tile-primary .value.zero { color: var(--text-muted); font-weight: 400; }
.tile-primary .label { display: block; font-size: 13px; color: var(--text-secondary); }
.tile-chart { height: 56px; position: relative; width: 100%; min-width: 0; overflow: hidden; }
.tile-chart canvas { max-width: 100%; }
.tile-exception { font-size: 12px; font-weight: 600; background: none; border: none; padding: 0; cursor: pointer; text-align: left; color: var(--text); }
.tile-exception.status-critical { color: var(--status-critical); }
.tile-exception.status-attention { color: #b07a00; }
:root[data-theme="dark"] .tile-exception.status-attention, :root[data-theme="contrast"] .tile-exception.status-attention { color: var(--status-attention); }
.tile-muted { font-size: 11px; color: var(--text-muted); }

.svc-list { display: grid; gap: 6px; margin: 4px 0 0; padding: 0; list-style: none; font-size: 13px; }
.svc-list li { display: grid; grid-template-columns: 14px 1fr auto auto; gap: 8px; align-items: center; }
.svc-list .num { font-variant-numeric: tabular-nums; color: var(--text-secondary); }

.activity { margin-top: 12px; }
.activity .tile-chart { height: 120px; }

/* Detail tabs — shared chrome */
.control-band { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.chip { border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: 999px; padding: 3px 10px; font-size: 12px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--status-info); border-color: var(--status-info); color: #fff; }
.search { border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: var(--radius); padding: 4px 8px; }
.context-strip { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary);
  padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elevated); margin-bottom: 12px; }
.context-strip b { color: var(--text); }

.cards { display: grid; gap: 10px; }
.card { border: 1px solid var(--border); border-left: 4px solid var(--status-neutral); border-radius: var(--radius); padding: 12px; background: var(--bg-tile); display: grid; gap: 4px; }
.card.status-critical { border-left-color: var(--status-critical); }
.card.status-attention { border-left-color: var(--status-attention); }
.card.status-healthy { border-left-color: var(--status-healthy); }
.card .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card .id { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: var(--text-secondary); }
.card .title { font-weight: 600; }
.card .meta { font-size: 12px; color: var(--text-secondary); }
.card .actions { margin-left: auto; display: flex; gap: 6px; }
.btn { border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: var(--radius); padding: 4px 10px; cursor: pointer; font-size: 12px; }
.btn.primary { background: var(--status-info); border-color: var(--status-info); color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.badge { font-size: 11px; padding: 1px 6px; border-radius: 4px; border: 1px solid var(--border); }
.badge.high { border-color: var(--status-critical); color: var(--status-critical); }

table.dense { width: 100%; border-collapse: collapse; font-size: 13px; }
table.dense th, table.dense td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
table.dense th { font-size: 12px; color: var(--text-secondary); font-weight: 600; }
table.dense td.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.pill { font-size: 11px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--border); }
.pill.blocked { border-color: var(--status-critical); color: var(--status-critical); }
.pill.running { border-color: var(--status-info); color: var(--status-info); }

.grid-4 { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.note { font-size: 12px; color: var(--text-muted); margin-top: 16px; }
.empty { padding: 24px; text-align: center; color: var(--text-secondary); border: 1px dashed var(--border); border-radius: var(--radius); }
.pill.failed { border-color: var(--status-critical); color: var(--status-critical); }
.pill.done { color: var(--text-muted); }
.pill.queued, .pill.paused { border-color: var(--status-attention); }
[data-search][hidden] { display: none; }
.card .row.nowrap { flex-wrap: nowrap; }
.card .row.nowrap .dot { flex: none; }
