:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --ink: #1c1b19;
  --accent: #0b6e4f;
  --muted: #5c574f;
  --warn: #c98b00;
  --danger: #9b2226;
  --panel: rgba(255, 255, 255, 0.7);
  --border: #d7d2c8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  background: linear-gradient(160deg, #efeae2, #d9e6df);
  color: var(--ink);
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

h1 {
  font-size: 1.75rem;
  margin: 0 0 0.25rem;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 1.15rem;
  margin: 1.75rem 0 0.75rem;
}

.sub { color: var(--muted); margin-bottom: 1rem; }

.banner {
  background: #fff8e7;
  border-left: 4px solid var(--warn);
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
}

.flash {
  background: #e7f6ef;
  border-left: 4px solid var(--accent);
  padding: 0.65rem 1rem;
  margin-bottom: 1rem;
}

.err {
  background: #fdecea;
  border-left: 4px solid var(--danger);
  padding: 0.65rem 1rem;
  margin-bottom: 1rem;
}

.live-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding: 0.65rem 0.85rem;
  background: var(--panel);
  border: 1px solid var(--border);
}

.live-bar .meta { margin: 0; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: #fff;
}

.badge.live { color: var(--accent); border-color: #9bcbb8; background: #e7f6ef; }
.badge.stale { color: var(--warn); border-color: #e6d19a; background: #fff8e7; }
.badge.offline { color: var(--danger); border-color: #e4b4b6; background: #fdecea; }
.badge.attention { color: var(--danger); border-color: #e4b4b6; background: #fdecea; }
.badge.sev-critical { color: #fff; background: var(--danger); border-color: var(--danger); }
.badge.sev-high { color: var(--danger); border-color: #e4b4b6; background: #fdecea; }

.attention-banner {
  background: #fdecea;
  border-left: 4px solid var(--danger);
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
}
.attention-banner strong { display: block; margin-bottom: 0.25rem; }
.attention-banner ul.attention-list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.attention-item {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: space-between;
  align-items: flex-start;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--border);
  padding: 0.55rem 0.7rem;
}
.attention-item-main { flex: 1 1 14rem; min-width: 0; }
.attention-item-main strong { margin-bottom: 0.2rem; }
.attention-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}
.attention-actions .button { font-size: 0.85rem; padding: 0.3rem 0.65rem; }
.button.secondary {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--border);
}
.button[aria-busy="true"] { opacity: 0.65; }

.row-critical td { background: rgba(155, 34, 38, 0.06); }

.detail-human h3 { margin: 0 0 0.35rem; font-size: 1.05rem; }
.detail-human p { margin: 0.35rem 0; }
.detail-human .field-label {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.detail-human details {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}
.detail-human summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.9rem;
}
.pill-row { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.5rem 0; }
.pill {
  font-size: 0.75rem;
  padding: 0.1rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
}


.auth { margin-bottom: 1.5rem; }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
}

th, td {
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th { font-size: 0.85rem; color: var(--muted); font-weight: 600; }

.ok { color: var(--accent); font-weight: 600; }
.bad { color: var(--danger); font-weight: 600; }

a.button, button.button {
  display: inline-block;
  background: var(--accent);
  color: white;
  text-decoration: none;
  padding: 0.45rem 0.9rem;
  border-radius: 4px;
  border: 0;
  cursor: pointer;
  font: inherit;
}

a.button:disabled, button.button:disabled,
a.button[aria-disabled="true"], button.button[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
}

button.secondary { background: #5c574f; }
button.linkish {
  background: transparent;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
  padding: 0;
}

.panel {
  background: rgba(255, 255, 255, 0.55);
  padding: 1rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
}

label {
  display: block;
  margin: 0.5rem 0 0.2rem;
  font-size: 0.9rem;
  color: var(--muted);
}

select, input[type="text"], input[type="search"], textarea {
  width: 100%;
  max-width: 28rem;
  padding: 0.4rem 0.5rem;
  font: inherit;
}

.row-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  align-items: center;
}

.row-actions input[type="text"] { max-width: 10rem; }

.meta { font-size: 0.85rem; color: var(--muted); }

.hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 0.75rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 0.75rem;
}

.stat {
  background: var(--panel);
  padding: 0.75rem;
  border: 1px solid var(--border);
}

.stat strong {
  display: block;
  font-size: 1.15rem;
  margin-top: 0.2rem;
}

.stat .hint-inline {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.35rem;
}

.schedule-card {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-height: 9.5rem;
}

.schedule-card h3 {
  margin: 0;
  font-size: 1rem;
}

.countdown {
  font-variant-numeric: tabular-nums;
  font-size: 1.1rem;
  font-weight: 600;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  align-items: end;
}

.filters label { margin: 0; }
.filters select, .filters input { max-width: 14rem; }

pre.snippet, pre.detail-body {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.85rem;
  margin: 0.5rem 0 0;
  color: var(--muted);
  max-height: 24rem;
  overflow: auto;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  max-width: 22rem;
  padding: 0.75rem 1rem;
  background: #1c1b19;
  color: #f6f4ef;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  z-index: 40;
}

.toast.error { background: var(--danger); }
.toast[hidden] { display: none; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(28, 27, 25, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 30;
  padding: 1rem;
}

@media (min-width: 720px) {
  .modal-backdrop {
    align-items: center;
  }
}

.modal {
  background: #fffdf8;
  border: 1px solid var(--border);
  width: min(720px, 100%);
  max-height: min(85vh, 900px);
  overflow: auto;
  padding: 1.25rem;
  border-radius: 8px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.2);
}

.modal header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
  margin-bottom: 0.75rem;
}

.modal h2 { margin: 0; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

[hidden] { display: none !important; }

@media (max-width: 640px) {
  main { padding: 1.25rem 0.85rem 3rem; }
  th, td { padding: 0.5rem; font-size: 0.9rem; }
}

/* Cursor control chat */
.chat-fab {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 40;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}
.chat-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 14, 0.35);
  z-index: 45;
}
.chat-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(440px, 100vw);
  height: 100vh;
  background: #fffdf8;
  border-left: 1px solid var(--border);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 1rem;
  overflow: hidden;
}
.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 0.75rem;
}
.chat-header h2 { margin: 0; font-size: 1.15rem; }
.chat-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: end;
}
.chat-toolbar select {
  display: block;
  margin-top: 0.2rem;
  min-width: 10rem;
}
.chat-session-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 5.5rem;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.chat-session-btn {
  width: 100%;
  text-align: left;
  background: #f4f0e6;
  border: 1px solid var(--border);
  padding: 0.35rem 0.5rem;
  cursor: pointer;
}
.chat-session-btn.active { outline: 2px solid #2f5d50; }
.chat-transcript {
  flex: 1;
  overflow: auto;
  border: 1px solid var(--border);
  padding: 0.65rem;
  background: #fff;
  min-height: 10rem;
}
.chat-msg { margin-bottom: 0.75rem; }
.chat-msg header {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  margin-bottom: 0.25rem;
}
.chat-msg-user .chat-msg-body { color: #243; }
.chat-msg-assistant .chat-msg-body { color: #1a1a1a; }
.chat-stream-live {
  border: 1px dashed #2f5d50;
  padding: 0.5rem;
  background: #f3faf6;
  max-height: 8rem;
  overflow: auto;
}
.chat-actions {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 7rem;
  overflow: auto;
}
.chat-action-card {
  border: 1px solid var(--border);
  padding: 0.4rem 0.55rem;
  background: #faf7f0;
  font-size: 0.85rem;
}
.chat-action-card p { margin: 0.2rem 0 0; }
.chat-composer textarea {
  width: 100%;
  resize: vertical;
  min-height: 4rem;
  font: inherit;
  padding: 0.5rem;
  border: 1px solid var(--border);
  background: #fff;
}
@media (max-width: 640px) {
  .chat-panel { width: 100vw; }
  .chat-fab { right: 0.75rem; bottom: 0.75rem; }
}
