/* Панель мониторинга. Простая адаптивная вёрстка: телефон — одна колонка. */

:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1c2430;
  --muted: #667085;
  --line: #e2e6ec;
  --brand: #1f3a5f;
  --primary: #2563eb;
  --primary-text: #ffffff;
  --ok: #1f9d55;
  --ok-bg: #e6f6ec;
  --warn: #c98a00;
  --warn-bg: #fff6dc;
  --crit: #d93036;
  --crit-bg: #fdeaea;
  --unknown: #98a2b3;
  --unknown-bg: #eef0f3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151c;
    --card: #1a2029;
    --text: #e6e9ee;
    --muted: #98a2b3;
    --line: #2b333f;
    --brand: #8fb3e3;
    --primary: #3b82f6;
    --ok-bg: #133022;
    --warn-bg: #3a2e0c;
    --crit-bg: #3d1517;
    --unknown-bg: #262c36;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0.2em 0 0.6em; display: flex; align-items: center; gap: 0.4em; flex-wrap: wrap; }
h2 { font-size: 1.1rem; margin: 0 0 0.75em; }
h3 { font-size: 1rem; margin: 1.2em 0 0.6em; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; word-break: break-all; }
.nowrap { white-space: nowrap; }
.boot { padding: 2rem; color: var(--muted); }
[hidden] { display: none !important; }

/* --- Шапка --- */
.topbar {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: 0.6rem 1rem; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; color: var(--brand); }
.brand img { width: 24px; height: 24px; }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 0.25rem; flex: 1; }
.nav-link { padding: 0.35rem 0.7rem; border-radius: 6px; color: var(--text); }
.nav-link.active, .nav-link:hover { background: var(--bg); text-decoration: none; }
.user { display: flex; align-items: center; gap: 0.6rem; }
.user-name { display: flex; flex-direction: column; line-height: 1.15; text-align: right; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.user-name small { color: var(--muted); }
a.user-name { color: var(--text); }
.select-inline { width: auto; min-height: 40px; }
.channel { flex-direction: row; gap: 1rem; flex-wrap: wrap; }
.update-banner { position: sticky; top: 0; z-index: 20; display: flex; gap: 0.75rem; align-items: center; justify-content: center;
  padding: 0.5rem 1rem; background: var(--warn-bg); border-bottom: 1px solid var(--warn); }
.picker { display: flex; flex-direction: column; gap: 0.4rem; }
.topic-row { display: flex; gap: 0.5rem; align-items: center; }
.topic-row select { flex: 1; }

.page { max-width: 1200px; margin: 0 auto; padding: 1rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.page-actions { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.back { display: inline-block; margin-bottom: 0.5rem; }

/* --- Карточки и формы --- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.form { display: flex; flex-direction: column; gap: 0.8rem; }
.inline-form { flex-direction: row; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { flex: 1; min-width: 220px; }
.field { display: flex; flex-direction: column; gap: 0.3rem; }
.field-label { font-weight: 500; }
.field-hint { color: var(--muted); font-size: 0.85rem; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 0.6rem 0.8rem; margin: 0; display: flex; flex-direction: column; gap: 0.35rem; }
legend { padding: 0 0.3rem; font-weight: 500; }
input, select, textarea {
  font: inherit; color: inherit; background: var(--card);
  border: 1px solid var(--line); border-radius: 8px; padding: 0.5rem 0.65rem; min-height: 40px; width: 100%;
}
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; min-height: 0; padding: 0; accent-color: var(--primary); flex: none; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
input:disabled, select:disabled { opacity: 0.55; }
.check { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; }
.form-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: 0.75rem 0; }
.hints summary { cursor: pointer; color: var(--primary); }
.copy-fallback { position: fixed; left: -9999px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  font: inherit; font-weight: 500; padding: 0.5rem 0.9rem; min-height: 40px;
  border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer;
}
.btn:hover { text-decoration: none; filter: brightness(0.97); }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn-danger { color: var(--crit); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-link { background: none; border: none; color: var(--primary); padding: 0.4rem 0; cursor: pointer; font: inherit; }
.btn-small { min-height: 32px; padding: 0.25rem 0.6rem; font-size: 0.85rem; }
.toolbar { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }

.notice { border-radius: 8px; padding: 0.6rem 0.8rem; margin: 0.5rem 0; border: 1px solid transparent; }
.notice-info { background: var(--unknown-bg); }
.notice-ok { background: var(--ok-bg); border-color: var(--ok); }
.notice-warn { background: var(--warn-bg); border-color: var(--warn); }
.notice-error { background: var(--crit-bg); border-color: var(--crit); }

/* --- Статусы --- */
.dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; background: var(--unknown); flex: none; }
.dot-ok { background: var(--ok); }
.dot-warn { background: var(--warn); }
.dot-crit { background: var(--crit); }
h1 .dot { width: 14px; height: 14px; }
.badge { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.82rem; font-weight: 500; background: var(--unknown-bg); color: var(--muted); }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-crit { background: var(--crit-bg); color: var(--crit); }

/* --- Дашборд --- */
.totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.75rem; margin-bottom: 1rem; }
.total { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--unknown); border-radius: var(--radius); padding: 0.7rem 0.9rem; box-shadow: var(--shadow); }
.total-ok { border-left-color: var(--ok); }
.total-warn { border-left-color: var(--warn); }
.total-crit { border-left-color: var(--crit); }
.total-value { font-size: 1.6rem; font-weight: 600; line-height: 1.1; }
.total-label { color: var(--muted); font-size: 0.88rem; }
.filters { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.filters input[type="search"] { flex: 1; min-width: 200px; width: auto; }
.filters select { width: auto; min-width: 180px; }
.group { margin-bottom: 1.5rem; }
.group h2 { margin-bottom: 0.5rem; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0.75rem; }
.tile {
  display: block; background: var(--card); color: var(--text); border: 1px solid var(--line);
  border-top: 4px solid var(--unknown); border-radius: var(--radius); padding: 0.75rem 0.9rem; box-shadow: var(--shadow);
}
.tile:hover { text-decoration: none; border-color: var(--primary); }
.tile-ok { border-top-color: var(--ok); }
.tile-warn { border-top-color: var(--warn); }
.tile-crit { border-top-color: var(--crit); }
.tile-head { display: flex; align-items: center; gap: 0.5rem; }
.tile-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-desc { font-size: 0.88rem; margin-top: 0.15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-meta { margin-top: 0.3rem; }
.problems { margin: 0.5rem 0 0; padding-left: 1.1rem; font-size: 0.88rem; color: var(--crit); }
.problems li { margin: 0.1rem 0; }
.problems-big { font-size: 1rem; margin-bottom: 1rem; }
.empty { padding: 2rem 0; text-align: center; }

/* --- Карточка сервера --- */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 1rem; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 0.85rem; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tr.inactive td { color: var(--muted); }
tr.selected td { background: var(--unknown-bg); }
td .dot { margin-right: 0.3rem; }
.services-pick td input[type="text"] { min-width: 180px; }
.disks { display: flex; flex-direction: column; gap: 0.9rem; }
.disk-head { display: flex; gap: 0.4rem; align-items: baseline; flex-wrap: wrap; margin-bottom: 0.3rem; }
.disk-free { margin-left: auto; color: var(--muted); font-size: 0.9rem; }
.bar { height: 10px; background: var(--unknown-bg); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--unknown); }
.bar-ok { background: var(--ok); }
.bar-warn { background: var(--warn); }
.bar-crit { background: var(--crit); }
.events { list-style: none; margin: 0; padding: 0; }
.events li { display: flex; gap: 0.6rem; align-items: baseline; padding: 0.35rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.events li:last-child { border-bottom: none; }
.event-time { min-width: 120px; }
.event-obj { min-width: 60px; }
.threshold { display: flex; flex-direction: column; gap: 0.4rem; padding: 0.6rem 0; border-top: 1px solid var(--line); }
.threshold-inputs { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0.6rem; }
.token-panel .command { white-space: pre-wrap; word-break: break-all; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 0.75rem; font-size: 0.82rem; }
.steps { padding-left: 1.2rem; }

/* --- Админка --- */
.tabs { display: flex; gap: 0.25rem; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.tab { padding: 0.5rem 0.8rem; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tab.active { color: var(--text); border-bottom-color: var(--primary); }
.tab:hover { text-decoration: none; color: var(--text); }
.audit .details { max-width: 420px; }

/* --- Вход --- */
.page-login { display: flex; justify-content: center; padding-top: 10vh; }
.login-card { width: 100%; max-width: 420px; }
.login-card form { display: flex; flex-direction: column; gap: 0.8rem; margin-top: 1rem; }
.code-input { font-size: 1.6rem; letter-spacing: 0.4em; text-align: center; font-family: ui-monospace, Consolas, monospace; }

/* --- Телефон --- */
@media (max-width: 640px) {
  .page { padding: 0.75rem; }
  .topbar { gap: 0.5rem; padding: 0.5rem 0.75rem; }
  .nav { order: 3; flex-basis: 100%; }
  .user { margin-left: auto; }
  .user-name { max-width: 140px; }
  h1 { font-size: 1.3rem; }
  .tiles { grid-template-columns: 1fr; }
  .totals { grid-template-columns: repeat(2, 1fr); }
  .facts { grid-template-columns: 1fr; }
  .facts dt { margin-top: 0.4rem; }
  .filters select, .filters input[type="search"] { width: 100%; }
  .disk-free { margin-left: 0; flex-basis: 100%; }
}
