:root {
  --brand: #fa641e;
  --bg: #f2f2f4;
  --surface: #ffffff;
  --text: #1a1a1f;
  --muted: #6b6b76;
  --border: #e3e3e8;
  --ok: #1f9d55;
  --ok-soft: #e6f6ec;
  --warn: #d99a00;
  --warn-soft: #fff6dc;
  --partial: #ea6c13;
  --partial-soft: #fff0e5;
  --down: #d93636;
  --down-soft: #fdeaea;
  --maint: #3b6fd9;
  --maint-soft: #e9f0fd;
  --nodata: #d8d8de;
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111114;
    --surface: #1b1b20;
    --text: #ececf1;
    --muted: #9b9ba8;
    --border: #2c2c34;
    --ok-soft: #12301f;
    --warn-soft: #33290a;
    --partial-soft: #3a2210;
    --down-soft: #3a1717;
    --maint-soft: #15233f;
    --nodata: #34343d;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--brand); }
.wrap { max-width: 860px; margin: 0 auto; padding: 24px 16px 48px; }

header.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 24px; }
.brand { display: flex; align-items: center; gap: 16px; text-decoration: none; color: var(--text); }
.brand-logo { height: 52px; width: auto; display: block; }
.brand-sep { width: 1px; height: 36px; background: var(--border); }
.brand-label { font-size: 22px; font-weight: 500; color: var(--muted); letter-spacing: .01em; }
/* Public page: big, centered brand so customers immediately recognise Pigz. */
header.top.hero { flex-direction: column; justify-content: center; gap: 10px; margin: 24px 0 32px; text-align: center; }
.hero .brand { gap: 20px; }
.hero .brand-logo { height: 84px; }
.hero .brand-sep { height: 56px; }
.hero .brand-label { font-size: 34px; }
@media (max-width: 600px) {
  header.top.hero { margin: 12px 0 24px; }
  .hero .brand { gap: 14px; }
  .hero .brand-logo { height: 60px; }
  .hero .brand-sep { height: 40px; }
  .hero .brand-label { font-size: 26px; }
}
@media (max-width: 600px) {
  .brand { gap: 12px; }
  .brand-logo { height: 40px; }
  .brand-sep { height: 28px; }
  .brand-label { font-size: 18px; }
  header.top { flex-wrap: wrap; }
}
.muted { color: var(--muted); }
.small { font-size: 13px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.card h2 { font-size: 16px; margin: 0 0 12px; }

.overall { display: flex; align-items: center; gap: 12px; font-size: 18px; font-weight: 600; border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.overall.operational { background: var(--ok); color: #fff; }
.overall.degraded { background: var(--warn); color: #1a1a1f; }
.overall.partial_outage { background: var(--partial); color: #fff; }
.overall.major_outage { background: var(--down); color: #fff; }
.overall.maintenance { background: var(--maint); color: #fff; }
.overall.unknown { background: var(--nodata); color: var(--text); }

.notice { border-left: 4px solid var(--down); }
.notice.maintenance { border-left-color: var(--maint); }
.notice.impact-minor { border-left-color: var(--warn); }
.notice.impact-major { border-left-color: var(--partial); }
.notice h3 { margin: 0 0 4px; font-size: 16px; }
.update { margin-top: 12px; }
.update b { font-weight: 600; }
.update p { margin: 2px 0 0; white-space: pre-wrap; }

.component { padding: 16px 0; border-top: 1px solid var(--border); }
.component:first-of-type { border-top: 0; padding-top: 0; }
.component-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.component-name { font-weight: 600; }
.pill { font-size: 13px; font-weight: 500; white-space: nowrap; }
.pill.operational { color: var(--ok); }
.pill.degraded { color: var(--warn); }
.pill.partial_outage { color: var(--partial); }
.pill.major_outage { color: var(--down); }
.pill.maintenance { color: var(--maint); }
.pill.unknown { color: var(--muted); }

.bars { display: flex; gap: 2px; height: 32px; margin: 10px 0 4px; }
.bar { flex: 1; border-radius: 2px; background: var(--nodata); min-width: 2px; }
.bar.operational { background: var(--ok); }
.bar.degraded { background: var(--warn); }
.bar.partial { background: var(--partial); }
.bar.major { background: var(--down); }
.bars-legend { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
/* Phones: only the last 30 days fit legibly. */
@media (max-width: 600px) {
  .bar.older { display: none; }
  .legend-90 { display: none; }
}
@media (min-width: 601px) {
  .legend-30 { display: none; }
}

.history-item { padding: 12px 0; border-top: 1px solid var(--border); }
.history-item:first-child { border-top: 0; padding-top: 0; }
.history-item h3 { font-size: 15px; margin: 0; }

footer { text-align: center; margin-top: 32px; font-size: 13px; color: var(--muted); }

/* admin */
.grid { display: grid; gap: 12px; }
@media (min-width: 700px) { .grid.two { grid-template-columns: 1fr 1fr; } }
label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 4px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
}
textarea { min-height: 90px; resize: vertical; }
button {
  font: inherit; font-weight: 500; border: 0; border-radius: 8px; padding: 9px 16px;
  background: var(--text); color: var(--surface); cursor: pointer;
}
button.secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }
button:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
button.primary, form button[type=submit] { background: var(--brand); color: #fff; }
button.primary:hover, form button[type=submit]:hover { filter: brightness(1.05); }

/* component picker */
.comp-list { display: grid; gap: 8px; }
.comp-row {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg);
  transition: border-color .15s, background .15s;
}
.comp-row.on { border-color: var(--brand); background: var(--surface); }
.comp-toggle { display: flex; align-items: center; gap: 12px; margin: 0; cursor: pointer; flex: 1 1 240px; font-weight: 400; }
.comp-toggle input[type=checkbox] { width: 18px; height: 18px; flex: none; margin: 0; accent-color: var(--brand); cursor: pointer; }
.comp-title { display: block; font-weight: 600; font-size: 14px; }
.comp-desc { display: block; font-size: 12px; color: var(--muted); }
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; transition: opacity .15s; }
.comp-row:not(.on) .seg { opacity: .45; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label {
  display: flex; align-items: center; gap: 6px; margin: 0; padding: 7px 12px;
  font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;
  border-left: 1px solid var(--border); background: transparent; color: var(--text);
}
.seg label:nth-of-type(1) { border-left: 0; }
.seg label:hover { background: var(--bg); }
.seg input:checked + label { background: var(--text); color: var(--surface); }
.seg input:focus-visible + label { outline: 2px solid var(--brand); outline-offset: -2px; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.seg .short { display: none; }
@media (max-width: 600px) {
  .seg { width: 100%; flex-wrap: nowrap; }
  .seg .long { display: none; }
  .seg .short { display: inline; }
  .seg label { flex: 1; justify-content: center; padding: 8px 6px; }
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table-wrap, #components, #maintenances, #audit { overflow-x: auto; }
.publishers { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.publishers li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); font-size: 14px; overflow-wrap: anywhere; }
.publishers .avatar { width: 28px; height: 28px; flex: none; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 13px; }
.publishers .you { margin-left: auto; flex: none; white-space: nowrap; font-size: 11px; font-weight: 600; color: var(--brand); border: 1px solid var(--brand); border-radius: 999px; padding: 1px 8px; }
.token-cmd { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 10px; white-space: pre-wrap; word-break: break-all; margin: 0 0 8px; }
td, th { text-align: left; padding: 6px 4px; border-top: 1px solid var(--border); vertical-align: top; }
.msg { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; }
.msg.err { background: var(--down-soft); color: var(--down); }
.msg.ok { background: var(--ok-soft); color: var(--ok); }
.hidden { display: none !important; }
code { font-size: 12px; }
