* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: var(--fs-body)/1.45 var(--font); -webkit-font-smoothing: antialiased;
  padding-bottom: calc(80px + env(safe-area-inset-bottom)); overflow-x: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 6px; max-width: 1240px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.logo { flex: none; width: 34px; height: 34px; border-radius: 10px; background: var(--surface-dark); color: var(--bg); display: grid; place-items: center; font-weight: 700; }
.name { font-weight: 600; font-size: 15px; }
.sub { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-right { display: flex; align-items: center; gap: 8px; flex: none; }
.brand > div:last-child { min-width: 0; }
.icon-btn { width: 36px; height: 36px; border-radius: var(--r-pill); border: 0; background: var(--surface); box-shadow: var(--shadow); font-size: 17px; }
.icon-btn[data-busy="1"] { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: var(--r-pill); background: var(--surface);
  box-shadow: var(--shadow); font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); }
.chip.live[data-state="ok"] .dot { background: var(--ok); }
.chip.live[data-state="bad"] .dot { background: var(--bad); }
.chip.live[data-state="busy"] .dot { background: var(--text-muted); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.tabs { position: sticky; top: 0; z-index: 5; display: flex; gap: 6px; padding: 8px 16px 10px; overflow-x: auto; scrollbar-width: none;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); max-width: 1240px; margin: 0 auto; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; border: 0; padding: 8px 14px; border-radius: var(--r-pill); background: var(--surface); box-shadow: var(--shadow);
  font-size: 13px; font-weight: 500; display: inline-flex; gap: 6px; align-items: center; transition: transform .15s var(--ease-out); }
.tab:active { transform: scale(.97); }
.tab[aria-selected="true"] { background: var(--surface-dark); color: var(--bg); }
.badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 600;
  display: inline-grid; place-items: center; }

main { max-width: 1240px; margin: 0 auto; padding: 4px 16px 24px; }
.gate { text-align: center; padding: 60px 16px; color: var(--text-muted); }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin: 6px 0 14px; flex-wrap: wrap; }
.crumb { font-size: 12px; color: var(--text-muted); }
h1 { font-size: 26px; font-weight: 600; margin: 2px 0 0; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 600; margin: 0; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }

.grid { display: grid; gap: var(--gap); grid-template-columns: 1fr; }
@media (min-width: 900px) {
  .grid.two { grid-template-columns: 2fr 1fr; }
  .grid.halves { grid-template-columns: 1fr 1fr; }
}
.card { background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow); padding: 18px; min-width: 0;
  animation: enter .4s var(--ease-out) both; transition: box-shadow .3s; }
.card[data-state="done"] { box-shadow: var(--glow-ok); }
.card[data-state="fail"] { background: var(--bad); color: #fff; }
.card[data-state="fail"] .muted { color: #fff; }
@keyframes enter { from { opacity: 0; transform: translateY(14px); } }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }

.summary { font-size: 16px; line-height: 1.5; }
.summary .bad { color: var(--bad); font-weight: 600; }

.kpis { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 900px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 340px) { .kpis { grid-template-columns: 1fr; } }
.kpi { text-align: left; border: 0; background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow); padding: 14px 16px;
  transition: transform .2s var(--ease-out); animation: enter .4s var(--ease-out) both; }
.kpi:hover { transform: translateY(-2px); }
.kpi .lab { font-size: var(--fs-label); color: var(--text-muted); }
.kpi .num { font-size: var(--fs-kpi); font-weight: 600; line-height: 1.2; }
.kpi .ctx { font-size: 12px; color: var(--text-muted); }
.kpi.hero { background: var(--surface-dark); color: var(--bg); }
.kpi.hero .lab, .kpi.hero .ctx { color: color-mix(in srgb, var(--bg) 70%, transparent); }

.list { list-style: none; margin: 0; padding: 0; }
.row { padding: 12px 0; border-top: 1px solid var(--line); display: flex; gap: 10px; align-items: flex-start; }
.row:first-child { border-top: 0; padding-top: 2px; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 500; overflow-wrap: anywhere; }
.row .body { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 4px; }
.row .meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; overflow-wrap: anywhere; }
.row[data-state="done"] { opacity: .55; }
.clip { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.clip.open { -webkit-line-clamp: unset; }
.more { border: 0; background: none; padding: 0; color: var(--text-muted); font-size: 12px; text-decoration: underline; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.btn { border: 0; border-radius: var(--r-pill); padding: 8px 16px; font-weight: 500; font-size: 13px; background: var(--accent); color: #fff;
  transition: transform .15s var(--ease-out), background .2s; min-height: 36px; }
.btn:active { transform: scale(.97); }
.btn.dark { background: var(--surface-dark); color: var(--bg); }
.btn.ghost { background: transparent; box-shadow: inset 0 0 0 1px var(--line); color: var(--text); }
.btn.danger-armed { background: var(--bad); color: #fff; animation: shake .3s; }
.btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

.tag { display: inline-block; padding: 2px 8px; border-radius: var(--r-pill); font-size: 11px; font-weight: 500; background: var(--line); color: var(--text); }
.tag.ok { background: var(--ok-soft); color: #166534; }
.tag.bad { background: var(--bad-soft); color: #991B1B; }
.tag.warn { background: var(--warn-soft); color: #92400E; }
.tag.info { background: var(--info-soft); }

.seg { display: inline-flex; background: var(--surface); box-shadow: var(--shadow); border-radius: var(--r-pill); padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; border-radius: var(--r-pill); padding: 6px 12px; font-size: 13px; }
.seg button[aria-pressed="true"] { background: var(--surface-dark); color: var(--bg); }

.meter { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 6px; }
.meter > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.meter.warn > i { background: var(--warn); }
.meter.bad > i { background: var(--bad); }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; margin-top: 6px; }
.stat .k { font-size: 12px; color: var(--text-muted); }
.stat .v { font-size: 18px; font-weight: 600; }

.empty { color: var(--text-muted); padding: 6px 0; }
.err { color: var(--bad); display: flex; justify-content: space-between; gap: 8px; align-items: center; flex-wrap: wrap; }
.skeleton { height: 14px; margin: 10px 0; }
.skeleton.tall { height: 64px; }
pre.brief { white-space: pre-wrap; font: inherit; margin: 0; overflow-wrap: anywhere; }

form.add { display: flex; gap: 8px; flex-wrap: wrap; }
form.add input { flex: 1 1 180px; min-width: 0; border: 1px solid var(--line); background: var(--bg); color: var(--text); border-radius: var(--r-ctl);
  padding: 9px 12px; font: inherit; }
form.add input[type="datetime-local"] { flex: 0 1 200px; }

.toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20;
  background: var(--surface-dark); color: var(--bg); border-radius: var(--r-pill); padding: 10px 10px 10px 16px; display: flex; gap: 10px;
  align-items: center; max-width: calc(100vw - 32px); box-shadow: 0 8px 30px rgb(0 0 0 / .25); animation: enter .3s var(--ease-out); }
.toast[hidden] { display: none; }
.toast span { overflow-wrap: anywhere; font-size: 13px; }
.toast button { border: 0; border-radius: var(--r-pill); background: var(--accent); color: #fff; padding: 6px 12px; font-weight: 600; flex: none; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .card, .kpi, .toast { animation: none; } }
