/* Hyve Monitor. Quiet while things are healthy, unmissable when they are not.
   Text sizes stay large on purpose: this gets read half-asleep on a phone. */
:root {
  --black: #0b0908;
  --panel: #1a1612;
  --panel-2: #241e18;
  --line: #4a4036;
  --silver: #f7f6f6;
  --grey: #b9b9bf;
  --gold: #f7b500;
  --gold-light: #fbd531;
  --ok: #3ecf8e;
  --ok-cell: #15261d;
  --down: #c9261f;
  --down-bright: #ff7a70;
  --warn: #f08c00;
  --maint: #93add1;
  --maint-cell: #1c2531;
  --hex-w: 186px;
  --hex-gap: 8px;
  --font: Bahnschrift, "DIN Alternate", "Barlow", "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { background: var(--black); }
body {
  margin: 0;
  background: var(--black);
  color: var(--silver);
  font: 400 18px/1.45 var(--font);
  font-variant-numeric: tabular-nums;
}
[hidden] { display: none !important; }
h1, h2, h3 { line-height: 1.15; margin: 0; }
h2 { font-size: 26px; font-weight: 600; }
h3 { font-size: 20px; font-weight: 600; }
a { color: var(--gold-light); }
.muted { color: var(--grey); }

button, input, select, textarea { font: inherit; color: inherit; }
button {
  min-height: 44px;
  padding: 8px 16px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--gold); }
button:disabled { opacity: .55; cursor: not-allowed; }
button.primary { background: var(--gold); border-color: var(--gold); color: var(--black); font-weight: 700; }
button.primary:hover:not(:disabled) { background: var(--gold-light); }
button.danger { background: var(--down); border-color: var(--down); color: #fff; font-weight: 700; }
button.big { min-height: 56px; width: 100%; font-size: 20px; }
:focus-visible { outline: 3px solid var(--gold-light); outline-offset: 2px; }
input, select {
  min-height: 48px;
  width: 100%;
  padding: 8px 12px;
  background: var(--black);
  border: 1px solid var(--line);
  border-radius: 6px;
}
label { display: grid; gap: 6px; }

/* Sign-in and phone acknowledgement pages */
.center-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.center-card { width: min(420px, 100%); display: grid; gap: 18px; text-align: left; }
.center-card img { display: block; }
.center-card h1 { font-size: 34px; }
.center-card p { margin: 0; }
.form-error { color: var(--down-bright); min-height: 1.45em; }

/* Top of page */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px clamp(16px, 3vw, 40px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; font-size: 22px; font-weight: 600; }
.top-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

.banner { margin: 0; padding: 14px clamp(16px, 3vw, 40px); font-weight: 600; }
.banner-down { background: var(--down); color: #fff; }

.summary { padding: clamp(24px, 4vw, 48px) clamp(16px, 3vw, 40px) 24px; }
.summary[data-state="down"] { background: var(--down); }
.summary[data-state="degraded"], .summary[data-state="checking"] { background: #3a2505; }
.summary h1 { font-size: clamp(34px, 5.6vw, 68px); font-weight: 700; letter-spacing: -.01em; max-width: 24ch; }
.summary[data-state="ok"] h1 { color: var(--silver); }
.subhead { margin: 10px 0 0; font-size: 20px; }
.summary[data-state="down"] .subhead { color: #fff; }

.incidents { display: grid; gap: 12px; margin-top: 24px; max-width: 1000px; }
.incident {
  display: grid; grid-template-columns: 1fr auto; gap: 8px 20px; align-items: center;
  padding: 16px 18px; background: var(--black); border-radius: 8px;
}
.incident h3 { font-size: 22px; }
.incident p { margin: 4px 0 0; color: var(--grey); overflow-wrap: anywhere; }
.incident .since { color: var(--silver); font-weight: 600; }
.incident-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
@media (max-width: 640px) {
  .incident { grid-template-columns: 1fr; }
  .incident-actions { justify-content: stretch; }
  .incident-actions button { flex: 1; }
}

.setup { padding: 20px clamp(16px, 3vw, 40px); border-bottom: 1px solid var(--line); }
.setup ul, .setup ol { margin: 10px 0 0; padding-left: 22px; max-width: 80ch; }
.setup li { margin: 6px 0; }
#push-toggle[data-on="false"] { background: var(--gold); border-color: var(--gold); color: var(--black); font-weight: 700; }
.setup li.urgent { color: var(--down-bright); font-weight: 600; }

/* The hive: one cell per system */
#hive { padding: 12px clamp(16px, 3vw, 40px) 8px; }
.group { margin-top: 28px; }
.group h2 { margin-bottom: 14px; }
.hive-row { display: flex; gap: var(--hex-gap); margin-bottom: calc(var(--hex-w) * -0.2387 + var(--hex-gap)); }
.hive-row.offset { margin-left: calc((var(--hex-w) + var(--hex-gap)) / 2); }
.hive-row:last-child { margin-bottom: 0; }

.cell {
  --edge: var(--line);
  --fill: var(--panel);
  --ink: var(--silver);
  position: relative;
  flex: none;
  width: var(--hex-w);
  height: calc(var(--hex-w) * 1.1547);
  padding: 0;
  background: var(--edge);
  border: 0;
  border-radius: 0;
  color: var(--ink);
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}
.cell::before {
  content: "";
  position: absolute;
  inset: 3px;
  background: var(--fill);
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}
.cell:hover, .cell:focus-visible { --edge: var(--gold-light); outline: none; }
.cell-inner {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  padding: 0 22px;
  text-align: center;
}
.cell-name { font-size: 17px; font-weight: 600; line-height: 1.15; }
.cell-state { font-size: 16px; display: inline-flex; align-items: center; gap: 5px; }
.cell-ip { font-size: 14px; opacity: .85; }

.cell[data-state="ok"] { --edge: #2b6b4c; --fill: var(--ok-cell); }
.cell[data-state="ok"] .cell-state { color: var(--ok); }
.cell[data-state="down"] { --edge: #ff9b93; --fill: var(--down); --ink: #fff; }
.cell[data-state="degraded"] { --edge: #ffc266; --fill: var(--warn); --ink: var(--black); }
.cell[data-state="checking"] { --edge: var(--warn); --fill: #3a2505; }
.cell[data-state="unknown"] { --edge: #5b5b63; --fill: var(--panel); --ink: var(--grey); }
.cell[data-state="maintenance"] { --edge: var(--maint); --fill: var(--maint-cell); }
.cell[data-state="maintenance"] .cell-state { color: var(--maint); }
.cell[data-state="down"]:hover, .cell[data-state="down"]:focus-visible,
.cell[data-state="degraded"]:hover, .cell[data-state="degraded"]:focus-visible { --edge: var(--silver); }

@keyframes alarm { 50% { filter: brightness(1.35); } }
.cell[data-state="down"] { animation: alarm 1.6s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .cell[data-state="down"] { animation: none; } }

@media (max-width: 620px) {
  .hive-row, .hive-row.offset { margin: 0 0 8px; }
  .cell { width: 100%; height: auto; min-height: 64px; clip-path: none; border-radius: 8px; }
  .cell::before { inset: 2px; clip-path: none; border-radius: 6px; }
  .cell-inner { position: relative; flex-direction: row; flex-wrap: wrap; justify-content: space-between; padding: 12px 16px; text-align: left; }
  .cell-name { flex: 1 1 60%; }
  .cell-ip { flex: 1 1 100%; order: 3; }
}

/* Past incidents */
.history { padding: 36px clamp(16px, 3vw, 40px) 60px; }
.history-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 6px; max-width: 1000px; }
.history-item {
  width: 100%; min-height: 52px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 20px;
  padding: 10px 14px; text-align: left; background: var(--panel); border-color: transparent;
}
.empty { color: var(--grey); margin: 12px 0 0; }

/* Details panel */
.drawer {
  width: min(680px, 100vw); max-width: 100vw; height: 100dvh; max-height: 100dvh;
  margin: 0 0 0 auto; padding: 0;
  background: var(--panel); color: var(--silver); border: 0; border-left: 1px solid var(--line);
}
.drawer::backdrop { background: rgb(0 0 0 / 60%); }
.drawer-head {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; background: var(--panel); border-bottom: 1px solid var(--line);
}
#drawer-body { padding: 8px 20px 40px; }
.block { margin-top: 24px; }
.block h3 { margin-bottom: 10px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 12px 0 0; }
.facts dt { color: var(--grey); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.note { color: var(--grey); margin: 10px 0 0; }

.check-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.check { display: grid; grid-template-columns: 28px 1fr; gap: 2px 8px; padding: 8px 0; border-bottom: 1px solid var(--panel-2); }
.check-mark { font-weight: 700; text-align: center; }
.check-detail { grid-column: 2; color: var(--grey); overflow-wrap: anywhere; }
.check[data-result="ok"] .check-mark { color: var(--ok); }
.check[data-result="fail"] .check-mark { color: var(--down-bright); }
.check[data-result="warn"] .check-mark { color: var(--warn); }
.check[data-result="unknown"] .check-mark { color: var(--grey); }
.check[data-result="fail"] .check-label { font-weight: 700; }

.chart-title { display: flex; justify-content: space-between; margin: 16px 0 4px; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: 110px; overflow: visible; }
.chart .grid { stroke: var(--panel-2); stroke-width: 1; }
.chart .axis-label { fill: var(--grey); font-size: 13px; }
.chart .series { fill: none; stroke: var(--gold); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .cross { stroke: var(--grey); stroke-width: 1; }
.chart .dot { fill: var(--gold); stroke: var(--panel); stroke-width: 2; }
.chart-tip {
  position: absolute; top: -6px; padding: 4px 8px; pointer-events: none; white-space: nowrap;
  background: var(--black); border: 1px solid var(--line); border-radius: 4px; font-size: 15px;
}
.numbers { margin-top: 10px; }
.numbers table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.numbers th, .numbers td { text-align: right; padding: 4px 8px; border-bottom: 1px solid var(--panel-2); }
.numbers th:first-child, .numbers td:first-child { text-align: left; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; padding: 0; list-style: none; }
.chips li { padding: 2px 10px; background: var(--panel-2); border-radius: 4px; font-size: 16px; overflow-wrap: anywhere; }
details > summary { cursor: pointer; min-height: 32px; }

.form-row { display: grid; gap: 12px; margin-top: 10px; }
.form-row.inline { grid-template-columns: 1fr auto; align-items: end; }
.reason { color: var(--grey); margin: 8px 0 0; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 10px 0 10px 16px; border-left: 2px solid var(--line); }
.timeline time { display: block; color: var(--grey); font-size: 16px; }
.ticket {
  width: 100%; min-height: 240px; padding: 12px; background: var(--black); border: 1px solid var(--line); border-radius: 6px;
  font-size: 15px; line-height: 1.4; white-space: pre; overflow: auto; resize: vertical;
}
.button-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }

a.button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 16px;
  border-radius: 6px; text-decoration: none; font-weight: 700;
}
a.button.primary { background: var(--gold); color: var(--black); }
.qr { display: block; width: min(380px, 100%); height: auto; margin-top: 12px; border-radius: 6px; }
.qr rect { fill: #fff; }
.qr path { fill: #000; }
.setup-key { font-size: 20px; letter-spacing: .04em; word-spacing: .3em; overflow-wrap: anywhere; margin: 10px 0 0; }
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 10;
  max-width: calc(100vw - 32px); padding: 12px 20px;
  background: var(--silver); color: var(--black); border-radius: 6px; font-weight: 600;
}
