/* managed.automation.monitoring
   Instrument-panel aesthetic: dark console, hairline rules, monospace for
   anything machine-generated, one loud accent per state. Built mobile-first —
   this is mostly read on a phone, often at 3am, usually in a hurry. */

@font-face {
  font-family: 'Plex Sans'; src: url('/fonts/ibm-plex-sans-latin-400-normal.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Plex Sans'; src: url('/fonts/ibm-plex-sans-latin-600-normal.woff2') format('woff2');
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Plex Mono'; src: url('/fonts/ibm-plex-mono-latin-400-normal.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Plex Mono'; src: url('/fonts/ibm-plex-mono-latin-500-normal.woff2') format('woff2');
  font-weight: 500; font-style: normal; font-display: swap;
}

:root {
  --ink:      #0b1118;
  --panel:    #111a25;
  --panel-2:  #16212e;
  --brand:    #2d4059;
  --line:     rgba(141, 172, 209, .13);
  --line-2:   rgba(141, 172, 209, .22);

  --text:     #e6edf6;
  --text-2:   #8ea4bd;
  --text-3:   #5b7089;

  --todo:     #ff5f52;
  --progress: #f5a623;
  --done:     #2fbf87;

  --radius:   13px;
  --tap:      44px;
  --ease:     cubic-bezier(.22, 1, .36, 1);

  /* Content column. The bars stay full-bleed (background + border span the
     viewport) but their contents indent to line up with the list column. */
  --col:      780px;
  --gutter:   max(14px, calc((100% - var(--col)) / 2 + 14px));
}

* { box-sizing: border-box; }

/* The UA rule for this is `[hidden] { display: none }`, which any author
   `display:` declaration outranks — and .login/.empty both set display:grid.
   Without this the login screen never goes away. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--ink);
  color: var(--text);
  font-family: 'Plex Sans', ui-sans-serif, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  /* faint navy glow from the top so the panel feels lit rather than flat */
  background-image:
    radial-gradient(120% 45% at 50% -8%, rgba(45, 64, 89, .55), transparent 70%);
  background-repeat: no-repeat;
}

.mono { font-family: 'Plex Mono', ui-monospace, monospace; }
.dim  { color: var(--text-3); }

/* film grain — keeps large dark areas from banding on OLED phones */
.grain {
  position: fixed; inset: 0; z-index: 100; pointer-events: none; opacity: .16;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

::selection { background: var(--brand); color: #fff; }

/* ── buttons ─────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px;
  border: 1px solid transparent; border-radius: 10px;
  font: 600 14px/1 'Plex Sans', sans-serif; letter-spacing: .01em;
  cursor: pointer; text-decoration: none;
  transition: background .18s var(--ease), border-color .18s var(--ease), transform .12s var(--ease);
}
.btn:active { transform: scale(.985); }

.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover { background: #365075; }

.btn--ghost {
  width: 100%; background: transparent; color: var(--text);
  border-color: var(--line-2);
}
.btn--ghost:hover { background: var(--panel-2); border-color: var(--brand); }

/* Deletion is irreversible, so the button stays quiet until it is armed. */
.btn--danger {
  width: 100%; margin-top: 22px;
  background: transparent; color: var(--text-2);
  border-color: var(--line-2);
}
.btn--danger:hover { color: var(--todo); border-color: rgba(255, 95, 82, .45); background: rgba(255, 95, 82, .07); }
.btn--danger.is-armed {
  color: #fff; background: var(--todo); border-color: var(--todo);
  animation: nudge .3s var(--ease);
}
.btn--danger.is-armed:hover { background: #ff7063; }

.iconbtn {
  display: grid; place-items: center;
  width: 38px; height: 38px; padding: 0;
  background: transparent; color: var(--text-2);
  border: 1px solid transparent; border-radius: 9px;
  cursor: pointer; transition: color .18s, background .18s, border-color .18s;
}
.iconbtn:hover { color: var(--text); background: var(--panel-2); border-color: var(--line); }
.iconbtn.is-on { color: var(--done); border-color: rgba(47, 191, 135, .35); background: rgba(47, 191, 135, .09); }

/* ── login ───────────────────────────────────────────────────────────── */

.login { display: grid; place-items: center; min-height: 100dvh; padding: 24px; }

.login__card {
  width: 100%; max-width: 340px;
  display: flex; flex-direction: column; align-items: center;
  padding: 38px 28px 30px;
  background: linear-gradient(180deg, var(--panel), var(--ink));
  border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 30px 70px -30px rgba(0, 0, 0, .9);
  animation: rise .5s var(--ease) both;
}
.login__lockup { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.login__mark { flex: none; display: block; width: 42px; height: 42px; opacity: .97; }
.login__wordmark { display: block; width: auto; height: 24px; opacity: .97; }
.login__title {
  margin: 0 0 26px;
  font: 500 12.5px/1 'Plex Mono', monospace; letter-spacing: -.01em; text-align: center;
}
.login__label {
  align-self: flex-start;
  font: 400 11px/1 'Plex Mono', monospace; letter-spacing: .14em; text-transform: uppercase;
  color: var(--text-3); margin-bottom: 9px;
}
.login__input {
  width: 100%; min-height: var(--tap); padding: 0 14px; margin-bottom: 16px;
  background: var(--ink); color: var(--text);
  border: 1px solid var(--line-2); border-radius: 10px;
  font: 400 16px/1 'Plex Mono', monospace; /* 16px stops iOS/Android zoom-on-focus */
  outline: none; transition: border-color .18s, box-shadow .18s;
}
.login__input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(45, 64, 89, .45); }
.login__submit { width: 100%; }
.login__error {
  margin: 14px 0 0; color: var(--todo);
  font: 400 12.5px/1.4 'Plex Mono', monospace; text-align: center;
}

/* ── topbar ──────────────────────────────────────────────────────────── */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) var(--gutter) 10px;
  background: rgba(11, 17, 24, .82);
  backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--line);
}
/* Mark on the left spanning both text lines, brand wordmark above the app name.
   Both are SVG rather than PNG: the earlier raster logo was being downscaled
   ~10x and the mark's fine strokes turned to mush. */
.topbar__brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.topbar__mark { flex: none; display: block; width: 28px; height: 28px; opacity: .97; }
/* align-items must not be the default `stretch`: this is a column flex, so the
   cross axis is horizontal and a width:auto <img> would be stretched to the
   container width, letterboxing the SVG and faking a left indent. */
.topbar__stack { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
.topbar__wordmark { display: block; width: auto; height: 15px; opacity: .97; }
.topbar__app {
  margin: 0; min-width: 0;
  font: 400 10.5px/1.25 'Plex Mono', monospace; letter-spacing: -.01em;
  color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar__actions { display: flex; align-items: center; gap: 2px; flex: none; }

/* live-connection lamp — solid when the SSE stream is attached */
.live { display: grid; place-items: center; width: 22px; height: 38px; }
.live i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-3); transition: background .3s, box-shadow .3s;
}
.live.is-live i {
  background: var(--done);
  box-shadow: 0 0 0 3px rgba(47, 191, 135, .16);
  animation: pulse 2.6s ease-in-out infinite;
}

/* ── filters ─────────────────────────────────────────────────────────── */

.filters {
  position: sticky; top: 0; z-index: 15;
  display: flex; gap: 7px; padding: 12px var(--gutter);
  overflow-x: auto; scrollbar-width: none;
  background: linear-gradient(180deg, var(--ink) 65%, transparent);
}
.filters::-webkit-scrollbar { display: none; }

.chip {
  flex: none; display: inline-flex; align-items: center; gap: 7px;
  min-height: 34px; padding: 0 13px;
  background: var(--panel); color: var(--text-2);
  border: 1px solid var(--line); border-radius: 999px;
  font: 400 12px/1 'Plex Mono', monospace; letter-spacing: .02em;
  cursor: pointer; white-space: nowrap;
  transition: color .18s, background .18s, border-color .18s;
}
.chip b {
  font-weight: 500; font-size: 11px; color: var(--text-3);
  padding: 2px 6px; border-radius: 5px; background: rgba(141, 172, 209, .1);
  transition: color .18s, background .18s;
}
.chip:hover { color: var(--text); border-color: var(--line-2); }
.chip.is-active { color: var(--text); background: var(--brand); border-color: transparent; }
.chip.is-active b { color: #fff; background: rgba(255, 255, 255, .16); }

.chip--todo.is-active     { background: rgba(255, 95, 82, .16);  border-color: rgba(255, 95, 82, .4);  color: var(--todo); }
.chip--todo.is-active b   { background: rgba(255, 95, 82, .2);   color: var(--todo); }
.chip--progress.is-active { background: rgba(245, 166, 35, .15); border-color: rgba(245, 166, 35, .4); color: var(--progress); }
.chip--progress.is-active b { background: rgba(245, 166, 35, .2); color: var(--progress); }
.chip--done.is-active     { background: rgba(47, 191, 135, .14); border-color: rgba(47, 191, 135, .4); color: var(--done); }
.chip--done.is-active b   { background: rgba(47, 191, 135, .2);  color: var(--done); }

/* ── error list ──────────────────────────────────────────────────────── */

.list {
  display: flex; flex-direction: column; gap: 9px;
  padding: 2px var(--gutter) calc(28px + env(safe-area-inset-bottom));
}

.row {
  position: relative; display: block; width: 100%; text-align: left;
  padding: 14px 15px 14px 19px;
  background: var(--panel); color: inherit;
  border: 1px solid var(--line); border-radius: var(--radius);
  cursor: pointer; overflow: hidden;
  transition: background .18s var(--ease), border-color .18s var(--ease), transform .12s var(--ease);
  animation: rise .42s var(--ease) both;
}
.row:hover { background: var(--panel-2); border-color: var(--line-2); }
.row:active { transform: scale(.99); }

/* status rail — the fastest read on the whole screen */
.row::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--row-accent, var(--text-3));
  transition: background .3s var(--ease);
}
.row[data-status='todo']        { --row-accent: var(--todo); }
.row[data-status='in_progress'] { --row-accent: var(--progress); }
.row[data-status='done']        { --row-accent: var(--done); opacity: .62; }
.row[data-status='done']:hover  { opacity: 1; }

.row__top { display: flex; align-items: baseline; gap: 9px; margin-bottom: 5px; }
.row__workflow {
  flex: 1; min-width: 0; margin: 0;
  font: 600 14.5px/1.35 'Plex Sans', sans-serif; letter-spacing: -.005em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.row__time { flex: none; font: 400 11px/1 'Plex Mono', monospace; color: var(--text-3); }

.row__msg {
  margin: 0 0 8px;
  font: 400 12.5px/1.5 'Plex Mono', monospace; color: var(--text-2);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  line-clamp: 2; overflow: hidden;
  word-break: break-word;
}

.tag {
  display: inline-block; padding: 3px 8px;
  background: rgba(141, 172, 209, .09); color: var(--text-3);
  border: 1px solid var(--line); border-radius: 6px;
  font: 400 10.5px/1.35 'Plex Mono', monospace; letter-spacing: .03em;
}

/* a row that arrived over SSE while you were watching */
.row.is-new { animation: flash 1.5s var(--ease) both; }

/* ── empty state ─────────────────────────────────────────────────────── */

.empty { display: grid; place-items: center; padding: 70px 24px; text-align: center; }
.empty__mark {
  width: 40px; height: 40px; margin-bottom: 18px; border-radius: 50%;
  border: 1px dashed var(--line-2); opacity: .6;
}
.empty__title { margin: 0 0 5px; font: 600 15px/1 'Plex Sans', sans-serif; }
.empty__sub { margin: 0; font: 400 12.5px/1.5 'Plex Mono', monospace; color: var(--text-3); }

/* ── detail sheet ────────────────────────────────────────────────────── */

.sheet { position: fixed; inset: 0; z-index: 60; }
.sheet__scrim {
  position: absolute; inset: 0;
  background: rgba(4, 8, 12, .68); backdrop-filter: blur(3px);
  animation: fade .28s var(--ease) both;
}
.sheet__panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: 92dvh; overflow-y: auto;
  padding: 0 18px calc(26px + env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid var(--line-2);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -24px 70px -20px rgba(0, 0, 0, .85);
  animation: sheetup .42s var(--ease) both;
}
@media (min-width: 720px) {
  .sheet__panel {
    left: 50%; bottom: auto; top: 50%; right: auto;
    width: min(620px, 92vw); transform: translate(-50%, -50%);
    border-radius: 18px; border: 1px solid var(--line-2);
    animation: rise .34s var(--ease) both;
  }
}

.sheet__head { position: sticky; top: 0; padding: 0 0 14px; background: var(--panel); }
.sheet__grab {
  display: block; width: 38px; height: 4px; margin: 11px auto 16px;
  background: var(--line-2); border-radius: 2px; cursor: pointer;
}
@media (min-width: 720px) { .sheet__grab { display: none; } }

.sheet__meta { display: flex; align-items: center; gap: 9px; margin-bottom: 9px; font-size: 11.5px; }
.statusdot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: none; }
.sheet__title {
  margin: 0;
  font: 600 19px/1.3 'Plex Sans', sans-serif; letter-spacing: -.015em;
  word-break: break-word;
}

.fieldlabel {
  margin: 22px 0 8px;
  font: 400 10.5px/1 'Plex Mono', monospace; letter-spacing: .16em; text-transform: uppercase;
  color: var(--text-3);
}
.fieldlabel:first-child { margin-top: 4px; }

.errblock {
  margin: 0; padding: 14px;
  background: var(--ink); border: 1px solid var(--line); border-radius: 10px;
  font-size: 12.5px; line-height: 1.6; color: #ffb4ac;
  white-space: pre-wrap; word-break: break-word;
  max-height: 42vh; overflow: auto;
}

.segmented {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  padding: 5px; background: var(--ink);
  border: 1px solid var(--line); border-radius: 12px;
}
.segmented button {
  min-height: 40px; padding: 0 6px;
  background: transparent; color: var(--text-2);
  border: 1px solid transparent; border-radius: 8px;
  font: 400 11.5px/1 'Plex Mono', monospace; letter-spacing: .02em;
  cursor: pointer; transition: all .18s var(--ease);
}
.segmented button:hover { color: var(--text); background: var(--panel-2); }
.segmented button[data-set='todo'].is-on        { background: rgba(255, 95, 82, .16);  color: var(--todo);     border-color: rgba(255, 95, 82, .4); }
.segmented button[data-set='in_progress'].is-on { background: rgba(245, 166, 35, .15); color: var(--progress); border-color: rgba(245, 166, 35, .4); }
.segmented button[data-set='done'].is-on        { background: rgba(47, 191, 135, .14); color: var(--done);     border-color: rgba(47, 191, 135, .4); }

/* ── toast ───────────────────────────────────────────────────────────── */

.toast {
  position: fixed; left: 50%; z-index: 80;
  bottom: calc(22px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  padding: 11px 17px; max-width: calc(100vw - 32px);
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line-2); border-radius: 10px;
  box-shadow: 0 18px 40px -14px rgba(0, 0, 0, .8);
  font: 400 12.5px/1.4 'Plex Mono', monospace; text-align: center;
  animation: rise .3s var(--ease) both;
}

/* ── motion ──────────────────────────────────────────────────────────── */

@keyframes rise    { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: none; } }
@keyframes fade    { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheetup { from { transform: translateY(100%); } to { transform: none; } }
@keyframes pulse   { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
@keyframes nudge   { 0%, 100% { transform: none; } 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
@keyframes flash {
  0%   { background: rgba(255, 95, 82, .22); border-color: rgba(255, 95, 82, .5); }
  100% { background: var(--panel); border-color: var(--line); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
