:root {
  color-scheme: light dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

/* .app-shell and .topbar structural chrome are owned by shell.css (loads
   after this file) — the AppShell replaced the single nav-row shell this
   file used to define. See shell.css for the sidebar/header rules. */

.app-main {
  padding: var(--sp-6);
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}

.page-title {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.15;
}

.page-subtitle {
  margin: 6px 0 0;
  max-width: 62ch;
  color: var(--text-2);
  font-size: 13.5px;
  line-height: 1.5;
}

.grid {
  display: grid;
  gap: var(--sp-5);
}

.grid--2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid--3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid--4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* ---------- Panel: the one canonical container ----------
   Structural chrome (nav/header) is a different, darker tier (--nav-bg /
   --header-bg); a panel is workspace content, so it sits visibly *above*
   the workspace background via --panel-shadow instead of just a hairline,
   which is what used to make every panel read as an identical flat box. */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--panel-shadow);
  overflow: hidden;
}

.panel__head,
.panel__body {
  padding: var(--sp-4) var(--sp-5);
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  background: var(--panel-bg-strong);
  border-bottom: 1px solid var(--border);
}

.panel__title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.005em;
}

.metric {
  padding: var(--sp-5);
  min-height: 112px;
}

.metric__label {
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.metric__value {
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 30px;
  line-height: 1;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.metric__hint {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.list {
  display: grid;
}

.list-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-2);
}

.list-row:last-child {
  border-bottom: 0;
}

.list-row:hover {
  background: var(--panel-bg-strong);
}

.thumb {
  width: 88px;
  height: 54px;
  border-radius: var(--r-xs);
  object-fit: cover;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.muted {
  color: var(--text-2);
}

.mono {
  font-family: var(--font-mono);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--sp-3);
}

.field {
  display: grid;
  gap: 6px;
}

.field label,
.field span {
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 8px 12px;
  background: var(--surface-2);
  color: var(--text);
  transition: border-color .12s, box-shadow .12s;
}

.field input:hover,
.field select:hover,
.field textarea:hover {
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
}

.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.media-card {
  display: grid;
  gap: 8px;
}

.media-card img {
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--border);
}

/* ---------- Empty / loading / error state block ----------
   One shared pattern instead of every page inventing its own "нет данных"
   div. Dashed border reads as "absence", not as another solid panel. */
.empty,
.state-block {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: var(--sp-7) var(--sp-5);
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
  text-align: center;
  color: var(--text-2);
  font-size: 13.5px;
  background: color-mix(in srgb, var(--surface) 60%, transparent);
}

.state-block__title {
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
}

.state-block--error {
  border-style: solid;
  border-color: color-mix(in srgb, var(--red) 45%, var(--border));
  background: var(--red-soft);
  color: var(--red);
}

.state-block--error .state-block__title {
  color: var(--red);
}

.state-block--offline {
  border-style: solid;
  border-color: color-mix(in srgb, var(--amber) 45%, var(--border));
  background: var(--amber-soft);
  color: var(--amber);
}

.state-block--offline .state-block__title {
  color: var(--amber);
}

.field-value {
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}

.toast-root {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  display: grid;
  gap: 10px;
}

.toast {
  min-width: 280px;
  max-width: 420px;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.toast--error {
  border-color: var(--red);
}

.toast--ok {
  border-color: var(--green);
}

@media (max-width: 1100px) {
  .grid--4,
  .grid--3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app-main {
    padding: var(--sp-4);
  }

  .grid--2,
  .grid--3,
  .grid--4,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .page-head {
    display: grid;
  }
}

/* A8n.7.4.4.35s: media/clip health indicator (left of the SSE indicator). */
.media-health { cursor: pointer; user-select: none; }
.media-health .media-health__text { white-space: nowrap; }
.media-health.mh-healthy i { background: var(--green); }
.media-health.mh-degraded i { background: #e0a200; }
.media-health.mh-failed i { background: var(--red); }
.media-health.mh-unknown i { background: var(--muted); }
.media-health.mh-recovering i {
  background: #2f6fed;
  animation: mh-pulse 1.2s ease-in-out infinite;
}
@keyframes mh-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
.media-health.is-stale { opacity: 0.6; }
@media (max-width: 720px) {
  .media-health .media-health__text { display: none; } /* dot-only on narrow */
}

.mh-pop {
  position: fixed; top: 52px; right: 12px; z-index: 1200;
  min-width: 300px; max-width: 360px; padding: 12px 14px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  box-shadow: 0 12px 32px rgba(0,0,0,0.25); font-size: 13px;
}
.mh-pop[hidden] { display: none; }
.mh-pop__title { font-weight: 800; margin-bottom: 8px; }
.mh-pop__row { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; }
.mh-pop__k { color: var(--muted); }
.mh-pop__v { font-weight: 700; text-align: right; }
.mh-pop__v.mh-failed { color: var(--red); }
.mh-pop__v.mh-degraded { color: #e0a200; }
.mh-pop__v.mh-recovering { color: #2f6fed; }
.mh-pop__v.mh-healthy { color: var(--green); }
.mh-pop__rec { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); color: var(--red); }
.mh-pop__meta { margin-top: 8px; color: var(--muted); font-size: 12px; }
.mh-pop__actions { display: flex; gap: 8px; margin-top: 10px; }
.mh-pop__btn {
  flex: 1; height: 30px; border-radius: var(--r-xs); border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-weight: 700; cursor: pointer;
}
.mh-pop__btn:hover { background: var(--surface-hover, var(--surface)); }
