/* status in the apple.com arrangement, compact: the Store-style head, two summary tiles, then the open notices,
   the Microsoft 365 services as a System Status list and the own monitors as tiles.
   monitoring.js binds by id/class; every state below is read from what it rendered. */

/* the summary cards are last in the source (their monitor figures count the tiles above them) and are moved up here */
.st { counter-reset: st-on st-all st-down st-grp; }
.st main { display: flex; flex-direction: column; gap: 64px; }
.st main > * + * { margin-top: 0; }
.st-head { order: 0; margin-bottom: -24px; }
.global-status { order: 1; }
.st-cards { order: 2; }
.st-issues { order: 3; }
.st-services { order: 4; }
.st-uptime { order: 5; }

/* an incident or a down monitor is said once, by the ribbon under the nav (app.js); the old banner stays out */
#globalStatus { display: none !important; }

/* ---------- two summary tiles ---------- */
.st-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.st-card { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.st-card-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.st-card-head .dm-state { width: 10px; height: 10px; background: none; border: 2px solid var(--div-2); }
.st-card-title { font-size: 24px; letter-spacing: -.02em; }
.st-stamp { margin-left: auto; font-size: 13px; color: var(--mut); white-space: nowrap; }
#lastUpdated:empty::before, #uptimeUpdated:empty::before { content: 'Noch kein Stand'; }

/* one sentence that says the state in words */
.st-say { font-size: 17px; line-height: 1.41; color: var(--body); }
.st-say em { font-style: normal; font-weight: 600; }
.ol-v { display: none; }

/* the counts as a short list: dot, bold count, label */
.st-figs { display: flex; flex-direction: column; gap: 10px; padding-top: 18px; border-top: 1px solid var(--div); }
.st-figs > * { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 15px; }
.st-figs .stat-lbl { display: contents; color: var(--body); }
.st-figs .stat-dot { order: -2; }
.st-figs .stat-num { order: -1; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--ok-dot); }
#statsRow > .incident .stat-num { color: var(--down); }
#statsRow > .incident .stat-dot { background: var(--down); }
#statsRow > .advisory .stat-num { color: var(--warn); }
#statsRow > .advisory .stat-dot { background: var(--warn-dot); }
.st-fig-grp .stat-dot { background: var(--div-2); }
.st-card .btn { margin-top: auto; align-self: flex-start; }

/* m365 state, read from the rendered counters and the service list */
.st:has(#serviceGrid > .st-load) .ol-m365 .is-load,
.st:has(#serviceGrid:empty) .ol-m365 .is-err,
.st:has(#serviceGrid > :not(.st-load)):has(#statsRow > .healthy:first-child):has(#statsRow > .healthy:nth-child(2)) .ol-m365 .is-ok,
.st:has(#serviceGrid > :not(.st-load)):has(#statsRow > .healthy:first-child):has(#statsRow > .advisory) .ol-m365 .is-adv,
.st:has(#serviceGrid > :not(.st-load)):has(#statsRow > .incident) .ol-m365 .is-inc { display: inline; }
.st:has(#serviceGrid > :not(.st-load)):has(#statsRow > .healthy:first-child):has(#statsRow > .healthy:nth-child(2)) .st-card-m365 .dm-state { border: 0; background: var(--ok-dot); }
.st:has(#serviceGrid > :not(.st-load)):has(#statsRow > .healthy:first-child):has(#statsRow > .advisory) .st-card-m365 .dm-state { border: 0; background: var(--warn-dot); }
.st:has(#serviceGrid > :not(.st-load)):has(#statsRow > .incident) .st-card-m365 .dm-state { border: 0; background: var(--down); }
.ol-m365 .is-adv em { color: var(--warn); }
.ol-m365 .is-inc em, .ol-v.is-err em { color: var(--down); }
/* before the first answer and after a failed load the counts read '–': their marks read unknown */
.st:has(#serviceGrid > .st-load, #serviceGrid:empty) #statsRow .stat-num { color: var(--div-2); }
.st:has(#serviceGrid > .st-load, #serviceGrid:empty) #statsRow .stat-dot { background: none; box-shadow: inset 0 0 0 2px var(--div-2); }

/* infrastructure figures are counters over the monitor tiles (all minus down, as the top bar counts) */
.st-on::before, .st-down::before, .st-grp::before { content: '–'; color: var(--div-2); }
.st:has(.uptime-group-label) .st-on::before { content: counter(st-on); color: inherit; }
.st:has(.uptime-group-label) .st-all::before { content: '/' counter(st-all); color: var(--mut); }
.st:has(.uptime-group-label) .st-down::before { content: counter(st-down); color: inherit; }
.st:has(.uptime-group-label) .st-grp::before { content: counter(st-grp); color: inherit; }
.st:not(:has(.uptime-group-label)) .st-figs-up .stat-dot { background: none; box-shadow: inset 0 0 0 2px var(--div-2); }
.st:has(.uptime-item.down) .st-fig-down .stat-num { color: var(--down); }
.st:has(.uptime-item.down) .st-fig-down .stat-dot { background: var(--down); }

.st:has(#uptimeGroups > .st-load) .ol-up .is-load,
.st:has(#uptimeGroups > .panel) .ol-up .is-err,
.st:has(#uptimeGroups > .state-text) .ol-up .is-empty,
.st:has(.uptime-group-label):not(:has(.uptime-item.down)) .ol-up .is-ok,
.st:has(.uptime-item.down) .ol-up .is-down { display: inline; }
.st:has(.uptime-group-label):not(:has(.uptime-item.down)) .st-card-up .dm-state { border: 0; background: var(--ok-dot); }
.st:has(.uptime-item.down) .st-card-up .dm-state { border: 0; background: var(--down); }
.ol-up .is-down em { color: var(--down); }

/* monitoring.js marks a running load with .spinning */
.st-refresh::before { content: ''; display: none; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--acc-bg); border-top-color: var(--acc); animation: st-spin .8s linear infinite; }
.st-refresh.spinning { cursor: progress; }
.st-refresh.spinning::before { display: block; }

/* ---------- section heads and legends ---------- */
.st-sec { scroll-margin-top: 64px; }
.st-sec .section-head { margin-bottom: 0; align-items: center; }
.st-issues .section-head { margin-bottom: 16px; }
.st-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; padding: 12px 0 18px; font-size: 13px; color: var(--mut); }
.st-legend > span:first-child { color: var(--body); }
.lg { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.lg-cell { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.lg-bar { display: inline-block; width: 4px; height: 14px; border-radius: 2px; }
.lg-line { display: inline-block; width: 18px; height: 0; border-top: 2px solid var(--acc); }

/* filter: a segmented control (ui.css .tab-btn), the chosen segment inverted */
.svc-filter-row { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 4px; border-radius: var(--pill); background: var(--surf); }

/* ---------- loading · empty · error ---------- */
.card-body { padding: 20px 0; }
#issuesBody > .card-body { padding: 22px 28px; border-radius: var(--r); background: var(--surf); }
.state-center { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.spinner { flex: none; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--div); border-top-color: var(--acc); animation: st-spin .9s linear infinite; }
@keyframes st-spin { to { transform: rotate(360deg); } }
.state-text { font-size: 15px; color: var(--mut); }
/* monitoring.js writes its errors without the spinner: an unknown ring next to the words */
#issuesBody .state-center:not(:has(.spinner))::before,
#uptimeGroups > .panel .state-text::before,
#uptimeGroups > .state-text::before,
#serviceGrid:empty::before { content: ''; flex: none; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--div-2); }
#issuesBody .state-center:not(:has(.spinner)) .state-text,
#uptimeGroups > .panel .state-text,
#uptimeGroups > .state-text,
#serviceGrid:empty::after { color: var(--ink); }
#serviceGrid:empty { display: flex; align-items: center; gap: 12px; padding: 20px 0; font-size: 15px; border-top: 1px solid var(--div); }
#serviceGrid:empty::after { content: 'Dienststatus nicht verfügbar'; }
#uptimeGroups > .panel { border: 0; border-radius: 0; background: none; padding: 20px 0; }
#uptimeGroups > .panel .state-text, #uptimeGroups > .state-text { display: flex; align-items: center; gap: 12px; }
#uptimeGroups > .state-text { padding: 20px 0; }

.all-ok-banner { display: flex; align-items: center; gap: 10px; padding: 0 0 14px; font-size: 15px; font-weight: 600; color: var(--ink); }
.all-ok-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--ok-dot); }

.show-more-btn {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 18px;
  border: 0; border-radius: var(--pill); background: transparent; box-shadow: inset 0 0 0 1px var(--acc); color: var(--acc);
  font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: background-color .2s var(--ease), color .2s var(--ease), box-shadow .2s var(--ease);
}
.show-more-btn:hover { background: var(--acc-fill); box-shadow: inset 0 0 0 1px var(--acc-fill); color: #fff; }
/* services and monitors are the content of this page: their lists stay open, the collapse toggles go */
#svcMoreWrap, #uptimeGroups [id^="utm_"] { display: block !important; }
#serviceGrid > .show-more-btn, #uptimeGroups .show-more-btn { display: none; }

/* ---------- active notices: one tile, rows divided by inset rules ---------- */
.issues-stack { border-radius: var(--r); background: var(--surf); overflow: hidden; }
.issue-detail { margin: 0 28px; padding: 22px 0; }
.issues-stack > * + * { border-top: 1px solid var(--div); }
.issues-stack > #advisoriesHidden { border-top: 0; }
#advisoriesHidden > .issue-detail { border-top: 1px solid var(--div); }
/* the toggle row and the empty row arrive with inline padding/border */
.issues-stack > div:has(> #advisoriesBtn) { margin: 0 28px; padding: 18px 0 22px !important; border-top: 1px solid var(--div) !important; }
.issue-badge {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: var(--pill);
  background: var(--warn-bg); color: var(--warn); font-size: 12px; font-weight: 600; white-space: nowrap;
}
.issue-badge.incident { background: var(--down-bg); color: var(--down); }
.issue-service { font-size: 14px; color: var(--mut); }
.issue-title { margin-top: 10px; max-width: 72ch; font-size: 17px; font-weight: 600; line-height: 1.35; color: var(--ink); letter-spacing: -.012em; overflow-wrap: anywhere; }
.issue-description { margin-top: 6px; max-width: 82ch; font-size: 15px; color: var(--body); overflow-wrap: anywhere; }
.issue-meta { display: flex; flex-wrap: wrap; gap: 10px 36px; margin-top: 16px; }
.meta-item { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.meta-label { font-size: 12px; color: var(--mut); }
.meta-value { font-size: 14px; color: var(--ink); overflow-wrap: anywhere; }
.meta-item:last-child .meta-value { font-family: var(--mono); font-size: 13px; }
/* nothing open: a green Settings check, as in the start page rows */
.issue-detail:has(> .state-text) { padding: 20px 0 !important; }
.issue-detail > .state-text { position: relative; display: flex; align-items: center; min-height: 28px; padding-left: 40px; font-size: 15px; font-weight: 600; color: var(--ink); }
.issue-detail > .state-text::before { content: ''; position: absolute; left: 0; top: 50%; width: 28px; height: 28px; margin-top: -14px; border-radius: 7px; background: var(--ok-dot); }
.issue-detail > .state-text::after { content: ''; position: absolute; left: 11px; top: 50%; width: 6px; height: 12px; margin-top: -8.5px; border: solid #fff; border-width: 0 2.4px 2.4px 0; transform: rotate(45deg); }

/* ---------- Microsoft 365 services: a System Status list in columns ---------- */
.svc-bento-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); column-gap: 36px;
  margin: 0 !important; border-top: 1px solid var(--div);
}
.svc-bento-grid + #svcMoreWrap > .svc-bento-grid { border-top: 0; }
/* affected and healthy services flow through one grid, affected first, as on Apple's System Status */
#serviceGrid:has(> .svc-bento-grid) {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); column-gap: 36px;
  border-top: 1px solid var(--div);
}
#serviceGrid:has(> .svc-bento-grid) :is(.svc-bento-grid, #svcMoreWrap) { display: contents !important; }
.svc-bento-card {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "dot name hm" "dot st hm";
  align-items: center; column-gap: 12px; min-width: 0; min-height: 52px; padding: 10px 0;
  border-bottom: 1px solid var(--div);
}
.svc-dot-row { display: contents; }
.svc-sticker { grid-area: dot; width: 8px; height: 8px; border-radius: 50%; background: var(--ok-dot); }
.svc-sticker.advisory { background: var(--warn-dot); }
.svc-sticker.incident { background: var(--down); }
.svc-title { grid-area: name; font-size: 15px; line-height: 1.3; color: var(--ink); overflow-wrap: anywhere; }
.svc-status-text { grid-area: st; font-size: 12px; font-weight: 600; }
.svc-status-text.healthy { display: none; }
.svc-status-text.advisory { color: var(--warn); }
.svc-status-text.incident { color: var(--down); }
.svc-heatmap { grid-area: hm; display: flex; align-items: center; gap: 3px; }
.hm-cell { flex: none; width: 12px; height: 12px; border-radius: 3px; }
/* quiet days and good beats sit back a little so amber and red carry */
.hm-ok { background: color-mix(in srgb, var(--ok-dot) 55%, transparent); }
.hm-warn { background: var(--warn-dot); }
.hm-down { background: var(--down); }
.hm-none { background: none; box-shadow: inset 0 0 0 1px var(--div-2); }
/* a service that is healthy now has only closed issues behind it: those days are drawn hollow */
.svc-bento-card[data-svc-status="healthy"] :is(.hm-warn, .hm-down), .lg-cell.hm-past { background: none; box-shadow: inset 0 0 0 2px var(--down); }
.svc-bento-card[data-svc-status="healthy"] .hm-warn, .lg-cell.hm-past.warn { box-shadow: inset 0 0 0 2px var(--warn-dot); }
.lg-cell + .lg-cell { margin-left: -4px; }

/* ---------- own infrastructure: groups of monitor tiles ---------- */
#uptimeGroups > div:has(> .uptime-group-label) { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 14px; }
#uptimeGroups > div + div { margin-top: 36px; }
.uptime-group-label { padding-bottom: 12px; font-size: 17px; font-weight: 600; color: var(--ink); counter-increment: st-grp; }
#uptimeGroups .all-ok-banner { padding: 0 0 12px; font-size: 13px; font-weight: 400; color: var(--mut); }
#uptimeGroups .uptime-grid, #uptimeGroups [id^="utm_"] { flex: 1 0 100%; min-width: 0; }
/* a group with monitors down flows them and the rest through one grid, down first */
#uptimeGroups > div:has(> .uptime-grid) { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); align-items: stretch; gap: 12px; }
#uptimeGroups > div:has(> .uptime-grid) > .uptime-group-label { grid-column: 1 / -1; padding-bottom: 0; }
#uptimeGroups > div:has(> .uptime-grid) :is(.uptime-grid, [id^="utm_"]) { display: contents !important; }
.uptime-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 12px; margin: 0 !important; }
.uptime-grid + [id^="utm_"] { margin-top: 12px; }
.uptime-item { min-width: 0; border-radius: var(--r); background: var(--surf); counter-increment: st-all st-on; }
.uptime-item.down { counter-increment: st-all st-down; background: var(--down-bg); }
/* a monitor without any heartbeat is left out of the figure, as in the top bar */
.uptime-item:not(:has(.uptime-bar)) { counter-increment: none; }
.uptime-body {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "name name ping" "dot st st" "bars bars bars" "spark spark spark";
  align-items: center; gap: 4px 8px; padding: 18px 20px;
}
.uptime-top { display: contents; }
.uptime-name { grid-area: name; font-size: 15px; font-weight: 600; line-height: 1.3; color: var(--ink); overflow-wrap: anywhere; }
.uptime-item.down .uptime-name { color: var(--down); }
.uptime-ping { grid-area: ping; align-self: start; font-size: 13px; line-height: 1.5; color: var(--mut); font-variant-numeric: tabular-nums; white-space: nowrap; }
/* state mark and word come from the newest heartbeat */
.uptime-body::before { content: ''; grid-area: dot; width: 8px; height: 8px; border-radius: 50%; box-shadow: inset 0 0 0 2px var(--div-2); }
.uptime-body::after { content: 'Keine Daten'; grid-area: st; font-size: 13px; color: var(--mut); }
.uptime-item:has(.uptime-bar.unknown:last-child) .uptime-body::after { content: 'Ausstehend'; }
.uptime-item:has(.uptime-bar.up:last-child) .uptime-body::before { box-shadow: none; background: var(--ok-dot); }
.uptime-item:has(.uptime-bar.up:last-child) .uptime-body::after { content: 'Online'; }
.uptime-item.down .uptime-body::before { box-shadow: none; background: var(--down); }
.uptime-item.down .uptime-body::after { content: 'Down'; color: var(--down); font-weight: 600; }
/* heartbeat strip, newest at the right; bars arrive with inline heights, one height here and the colour carries the state */
.uptime-bars { grid-area: bars; display: flex; justify-content: flex-end; gap: 2px; height: 22px; margin-top: 10px; }
.uptime-bar { flex: 1 1 0; min-width: 2px; max-width: 6px; height: auto !important; border-radius: 1px; }
.uptime-bar.up, .lg-bar.up { background: color-mix(in srgb, var(--ok-dot) 70%, transparent); }
.uptime-bar.down-bar, .lg-bar.down-bar { background: var(--down); }
.uptime-bar.unknown, .lg-bar.unknown { background: var(--div-2); }
/* response time: the line plus its average and span */
.svc-spark { grid-area: spark; display: grid; gap: 4px; min-width: 0; margin-top: 10px; color: var(--acc); }
.svc-spark svg { display: block; width: 100%; height: 28px; }
.svc-spark path { opacity: 1; stroke-width: 1.5px; vector-effect: non-scaling-stroke; }
.svc-spark-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; color: var(--mut); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .st-cards { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .st main { gap: 48px; }
  .st-head { margin-bottom: -16px; }
  .st-card { gap: 16px; }
  .st-card-title { font-size: 21px; }
  .st-say { font-size: 16px; }
  .st-card-head { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 10px; }
  .st-stamp { grid-column: 2; margin-left: 0; }
  .st-figs { padding-top: 16px; }
  .issue-detail, .issues-stack > div:has(> #advisoriesBtn) { margin: 0 20px; }
  #issuesBody > .card-body { padding: 20px; }
  .issue-meta { gap: 10px 24px; }
  .svc-filter-row { margin-left: 0 !important; }
  .svc-bento-card { column-gap: 10px; }
  .hm-cell { width: 11px; height: 11px; }
  .svc-heatmap { gap: 2px; }
  .uptime-grid, #uptimeGroups > div:has(> .uptime-grid) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .uptime-item { border-radius: 14px; }
  .uptime-body { grid-template-areas: "name name name" "dot st ping" "bars bars bars" "spark spark spark"; padding: 14px; }
  .uptime-name { font-size: 14px; }
  .uptime-ping { align-self: center; font-size: 12px; }
  .svc-spark-meta { font-size: 11.5px; }
  .svc-spark-meta > :last-child { display: none; }
}
