:root {
  --bg: #0b1020;
  --card: #131a2e;
  --card-edge: #232d49;
  --text: #e7ecf5;
  --muted: #8b96b3;
  --down: #ef4444;
  --spike: #f59e0b;
  --backup: #38bdf8;
  --ok: #34d399;
  --accent: #6366f1;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 14px calc(24px + env(safe-area-inset-bottom));
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--down); }

.card {
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

h1 { font-size: 1.35rem; margin: 0; }
h1 span { color: var(--muted); font-weight: 500; }
h2 { font-size: 1rem; margin: 0; }

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

#login-form { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--muted);
}

input {
  background: #0d1326;
  border: 1px solid var(--card-edge);
  border-radius: 10px;
  color: var(--text);
  font-size: 1rem;
  padding: 12px;
}

input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: transparent;
}

button {
  background: var(--accent);
  color: white;
  border: 0;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  padding: 12px 16px;
  cursor: pointer;
}

button:disabled { opacity: 0.55; cursor: default; }

button.ghost {
  background: transparent;
  border: 1px solid var(--card-edge);
  color: var(--muted);
  font-weight: 500;
  padding: 8px 12px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 2px 12px;
}

.brand { display: flex; align-items: center; gap: 8px; }
.brand h1 { font-size: 1.15rem; }
.header-actions { display: flex; align-items: center; gap: 10px; }
#who { font-size: 0.85rem; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chip {
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 999px;
  padding: 3px 10px;
  background: #1c2542;
  color: var(--muted);
  white-space: nowrap;
}

.chip.kind-DOWN { background: rgba(239, 68, 68, 0.16); color: var(--down); }
.chip.kind-ERROR_SPIKE { background: rgba(245, 158, 11, 0.16); color: var(--spike); }
.chip.kind-BACKUP_MISSED { background: rgba(56, 189, 248, 0.16); color: var(--backup); }
.chip.ok { background: rgba(52, 211, 153, 0.16); color: var(--ok); }
.chip.warn { background: rgba(245, 158, 11, 0.16); color: var(--spike); }

.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }

.feed .item {
  border: 1px solid var(--card-edge);
  border-left-width: 3px;
  border-radius: 10px;
  padding: 10px 12px;
  background: #0d1326;
}

.feed .item.kind-DOWN { border-left-color: var(--down); }
.feed .item.kind-ERROR_SPIKE { border-left-color: var(--spike); }
.feed .item.kind-BACKUP_MISSED { border-left-color: var(--backup); }
.feed .item.recovered { opacity: 0.72; }
.feed .item.acked { opacity: 0.72; }

.chip.repeat { background: rgba(239, 68, 68, 0.28); color: var(--down); }
.chip.muted { background: rgba(139, 150, 179, 0.24); color: var(--muted); }

.feed .item p.acked-note { color: var(--ok); font-size: 0.82rem; }

.feed .item button.ack {
  width: 100%;
  margin-top: 8px;
  padding: 10px 16px;
  background: var(--down);
}

.feed .row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.feed .row .where { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed .row time { margin-left: auto; color: var(--muted); font-size: 0.78rem; white-space: nowrap; }
.feed .item p { margin: 6px 0 0; font-size: 0.9rem; color: #c4cddd; overflow-wrap: anywhere; }

.empty { color: var(--muted); font-size: 0.9rem; padding: 4px 2px; }

.devices { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.devices .device {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--card-edge);
  border-radius: 10px;
  padding: 8px 10px;
  background: #0d1326;
  font-size: 0.88rem;
}

.devices .device .host { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.devices .device .meta { color: var(--muted); font-size: 0.78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.devices .device .grow { min-width: 0; flex: 1; }
.devices .device button.ghost { flex: none; }

#enable-push { width: 100%; margin-top: 4px; }

/* Alert settings: kinds, quiet hours. */
#settings-form { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }

#settings-form fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#settings-form legend {
  padding: 0;
  margin-bottom: 8px;
  font-size: 0.9rem;
  color: var(--muted);
}

label.check {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 0.95rem;
}

label.check input { width: 20px; height: 20px; padding: 0; accent-color: var(--accent); flex: none; }

.quiet-fields { display: flex; flex-direction: column; gap: 10px; }
.quiet-times { display: flex; gap: 10px; }
.quiet-times label { flex: 1; }
.quiet-fields input[type="time"] { padding: 10px; }

.settings-actions { display: flex; align-items: center; gap: 12px; }
.settings-actions button { padding: 10px 16px; }
#settings-state { font-size: 0.85rem; }
