/* ============================================================
   ColDon Monitor — Раскладка и компоненты
   Чистый HTML/CSS, без Bootstrap. Общие классы переиспользуются
   между всеми страницами приложения.
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 1.5;
  letter-spacing: var(--tracking);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.02em; color: var(--ink); }
p { margin: 0; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-strong); }
button { font-family: inherit; }
.mono { font-family: var(--font-mono); font-feature-settings: "tnum" 1; }

/* ---------- Каркас приложения ------------------------------ */
.app {
  display: grid;
  grid-template-columns: 264px 1fr;
  /* фиксируем высоту строки, иначе авторазмерная строка растёт под контент
     и .scroll не ограничен по высоте — внутренняя прокрутка не включается */
  grid-template-rows: 100vh;
  height: 100vh;
  overflow: hidden;
}
[data-theme="terminal"] .app { grid-template-columns: 232px 1fr; }

/* ---------- Сайдбар ---------------------------------------- */
.side {
  display: flex;
  flex-direction: column;
  background: linear-gradient(176deg, var(--side-bg), var(--side-bg-2));
  color: var(--side-ink);
  border-right: 1px solid var(--side-border);
  padding: 18px 14px;
  gap: 4px;
}
.side__brand {
  display: flex; align-items: center; gap: 11px;
  padding: 6px 8px 16px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--side-border);
}
.side__brand > div { min-width: 0; }
.side__mark {
  width: 34px; height: 34px; flex: none;
  border-radius: 9px;
  background: var(--side-brand);
  display: grid; place-items: center;
  color: var(--side-bg);
  box-shadow: inset 0 0 0 1px oklch(1 0 0 / 0.15);
}
.side__mark svg { width: 20px; height: 20px; }
.side__name { font-size: 15.5px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; white-space: nowrap; }
.side__sub { font-size: 11px; color: var(--side-muted); letter-spacing: 0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.side__section {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--side-muted); font-weight: 600;
  padding: 14px 10px 6px;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav__item {
  display: flex; align-items: center; gap: 12px;
  padding: 0 12px; height: 42px;
  border-radius: var(--radius-sm);
  color: var(--side-ink);
  font-size: 14.5px; font-weight: 500;
  cursor: pointer; border: none; background: none;
  width: 100%; text-align: left;
  text-decoration: none;
  transition: background .14s ease, color .14s ease;
}
.nav__item svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav__item:hover { background: oklch(1 0 0 / 0.07); color: var(--side-ink); }
[data-theme="terminal"] .nav__item:hover { background: var(--surface-3); }
/* Активный пункт: и демо-класс is-active, и .active от Blazor NavLink */
.nav__item.is-active,
.nav__item.active {
  background: var(--side-active-bg);
  color: var(--side-active-ink);
  font-weight: 600;
}
.nav__item.is-active svg,
.nav__item.active svg { opacity: 1; }

.side__spacer { flex: 1 1 auto; }
.side__foot { border-top: 1px solid var(--side-border); padding-top: 10px; display: flex; flex-direction: column; gap: 2px; }
.side__foot form { width: 100%; }
.side__user {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 12px; border-radius: var(--radius-sm);
}
.side__avatar {
  width: 30px; height: 30px; flex: none; border-radius: 50%;
  background: var(--side-active-bg); color: var(--side-active-ink);
  display: grid; place-items: center; font-weight: 600; font-size: 13px;
}
.side__user-meta { min-width: 0; display: flex; flex-direction: column; }
.side__user-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side__user-role { font-size: 11px; color: var(--side-muted); }

/* ---------- Основная колонка ------------------------------- */
.main { display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.topbar {
  min-height: 64px; flex: none;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar__heading { min-width: 0; }
.topbar__title { font-size: 17px; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); line-height: 1.2; }
.topbar__desc { font-size: 12.5px; color: var(--muted); line-height: 1.3; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__sep { color: var(--border-strong); }
.topbar__spacer { flex: 1; }
.topbar__tools { display: flex; align-items: center; gap: 8px; flex: none; }
.topbar__divider { width: 1px; height: 24px; background: var(--border); margin: 0 2px; }
.topbar__action {
  display: inline-flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 13px; border-radius: var(--radius-sm);
  font-size: 13.5px; color: var(--ink-2); font-weight: 500;
  border: 1px solid transparent; background: none; cursor: pointer;
  text-decoration: none;
}
.topbar__action:hover { background: var(--surface-2); color: var(--ink); }
.topbar__action svg { width: 16px; height: 16px; }

.scroll { flex: 1; overflow-y: auto; }
.page { width: 100%; margin: 0; padding: 30px 32px 60px; }
.page--wide { width: 100%; }
.page__head { margin-bottom: 24px; }
.page__title { font-size: var(--fs-h1); line-height: 1.12; }
.page__desc { color: var(--ink-2); margin-top: 6px; font-size: 15px; }
.page__head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

/* ---------- Карточка --------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px var(--pad-card);
  border-bottom: 1px solid var(--border);
}
.card__title { font-size: 15px; font-weight: 600; }
.card__body { padding: var(--pad-card); }
.card + .card, .stack > * + * { margin-top: var(--gap); }

/* ---------- Кнопки ----------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px;
  border-radius: var(--radius-sm);
  font-size: 14.5px; font-weight: 600;
  border: 1px solid transparent; cursor: pointer;
  transition: background .14s ease, border-color .14s ease, box-shadow .14s ease, transform .04s ease;
  white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:active { transform: translateY(0.5px); }
.btn svg { width: 16px; height: 16px; }
.btn--primary { background: var(--brand); color: var(--brand-ink); box-shadow: var(--shadow-sm); }
.btn--primary:hover { background: var(--brand-strong); color: var(--brand-ink); }
.btn--ghost { background: var(--surface); color: var(--ink); border-color: var(--border-strong); }
.btn--ghost:hover { background: var(--surface-2); border-color: var(--muted); color: var(--ink); }
.btn--subtle { background: var(--surface-2); color: var(--ink-2); }
.btn--subtle:hover { background: var(--surface-3); color: var(--ink); }
.btn--sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 7px; }
.btn--block { width: 100%; height: 46px; font-size: 15px; }
.btn--warn { background: var(--surface); color: var(--amber); border-color: color-mix(in oklch, var(--amber) 45%, var(--border)); }
.btn--warn:hover { background: color-mix(in oklch, var(--amber) 10%, var(--surface)); }
.btn--danger { background: var(--surface); color: var(--danger); border-color: color-mix(in oklch, var(--danger) 40%, var(--border)); }
.btn--danger:hover { background: color-mix(in oklch, var(--danger) 9%, var(--surface)); }

/* ---------- Поля ввода ------------------------------------- */
.field { display: flex; flex-direction: column; gap: 7px; }
.label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.input, .select {
  height: 44px; padding: 0 14px; width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink); font-size: 15px; font-family: inherit;
  transition: border-color .14s ease, box-shadow .14s ease;
}
.input::placeholder { color: var(--muted); }
.input:focus, .select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--brand) 18%, transparent);
}
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center;
  padding-right: 38px;
}
.input--readonly { background: var(--surface-2); color: var(--ink-2); border-style: dashed; }
.check { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 14.5px; color: var(--ink-2); }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.pwd-wrap { position: relative; }
.pwd-input { padding-right: 44px !important; }
.pwd-toggle {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0; border: none; border-radius: 7px;
  background: transparent; color: var(--muted); cursor: pointer;
}
.pwd-toggle:hover { color: var(--ink); background: var(--surface-2); }
.pwd-toggle svg { width: 18px; height: 18px; }
.pwd-toggle .icon-hide { display: none; }
.pwd-toggle.is-open .icon-show { display: none; }
.pwd-toggle.is-open .icon-hide { display: block; }

/* ---------- Таблица ---------------------------------------- */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); font-weight: 600; padding: 0 16px 12px;
  border-bottom: 1px solid var(--border);
}
.table th.num, .table td.num { text-align: right; }
.table td {
  padding: 0 16px; height: var(--row-h);
  border-bottom: 1px solid var(--border);
  font-size: 14.5px; vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background .12s ease; }
.table tbody tr:hover { background: var(--surface-2); }
.cell-strong { font-weight: 600; color: var(--ink); }
.cell-sub { color: var(--muted); font-size: 12.5px; }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.muted { color: var(--muted); }
.muted-it { color: var(--muted); font-style: italic; }

/* ---------- Бейджи / чипы ---------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.01em;
}
.badge--role { background: var(--surface-3); color: var(--ink-2); }
.badge--brand { background: var(--brand-soft); color: var(--brand-soft-ink); }
.badge--you { background: var(--surface-2); color: var(--muted); font-weight: 500; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot--ok { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in oklch, var(--ok) 22%, transparent); }
.dot--idle { background: var(--muted); }
.token {
  font-family: var(--font-mono); font-size: 12.5px;
  background: var(--surface-3); color: var(--ink-2);
  padding: 2px 8px; border-radius: 6px;
}
.token--wide {
  display: inline-block;
  max-width: min(520px, 100%);
  overflow-wrap: anywhere;
}

/* ---------- Пустые состояния / заметки --------------------- */
.note { color: var(--muted); font-size: 14px; }
.divider { height: 1px; background: var(--border); margin: 18px 0; border: none; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.inline-form { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: end; }
