:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --ink: #14181f;
  --muted: #6b7482;
  --line: #e3e6ec;
  --accent: #1f5fd0;
  --accent-soft: #eaf1fd;
  --good: #17794a;
  --warn: #9a6410;
  --bad: #a3312a;
  --radius: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --panel: #171b21;
    --ink: #e7eaef;
    --muted: #939bab;
    --line: #262c35;
    --accent: #6ea3ff;
    --accent-soft: #1b2739;
    --good: #4fbb85;
    --warn: #d6a44a;
    --bad: #e0736a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

/* ---------- шапка ---------- */

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px; flex-wrap: wrap;
  padding: 14px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: baseline; gap: 10px; }
.logo { font-size: 17px; font-weight: 650; letter-spacing: -.01em; }
.sub { color: var(--muted); font-size: 12px; }

.tabs { display: flex; gap: 4px; }

.tab {
  padding: 7px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}
.tab:hover { color: var(--ink); background: var(--bg); }
.tab.is-active { color: var(--accent); background: var(--accent-soft); border-color: var(--line); }

/* ---------- сводка ---------- */

.stats {
  display: flex; flex-wrap: wrap; gap: 10px;
  padding: 14px 20px;
}

.stat {
  min-width: 116px;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.stat b { display: block; font-size: 20px; font-weight: 620; letter-spacing: -.02em; }
.stat span { color: var(--muted); font-size: 12px; }

/* ---------- вид ---------- */

main { padding: 0 20px 40px; }
.view { display: none; }
.view.is-active { display: block; }

.hint {
  margin-bottom: 12px; padding: 10px 14px;
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 13px;
}

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }

.filters input[type=search], .filters select, .filters button {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
}
.filters input[type=search] { flex: 1 1 260px; }
.filters button { background: var(--accent); border-color: var(--accent); color: #fff; cursor: pointer; }

.check { display: flex; align-items: center; gap: 6px; color: var(--muted); padding: 0 4px; }

.result-meta { color: var(--muted); font-size: 13px; margin-bottom: 8px; }

/* ---------- таблицы ---------- */

.table-wrap {
  overflow-x: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }

th, td {
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th { color: var(--muted); font-weight: 550; white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg); }
.num { text-align: right; }

.name-cell { font-weight: 550; color: var(--accent); cursor: pointer; }
.name-cell:hover { text-decoration: underline; }

.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

.pill {
  display: inline-block;
  padding: 1px 7px; margin: 1px 3px 1px 0;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 11px;
  white-space: nowrap;
}
.pill.tier1 { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.score { font-weight: 650; }
.score.hi { color: var(--good); }
.score.mid { color: var(--warn); }
.score.lo { color: var(--muted); }

/* ---------- карточка ---------- */

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(520px, 100vw);
  padding: 22px 24px;
  overflow-y: auto;
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: -8px 0 32px rgba(0,0,0,.12);
  z-index: 20;
}
.drawer[hidden] { display: none; }

.drawer-close {
  position: absolute; top: 12px; right: 16px;
  width: 30px; height: 30px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg); color: var(--ink);
  font-size: 18px; line-height: 1; cursor: pointer;
}

.drawer h2 { margin: 0 0 4px; font-size: 19px; letter-spacing: -.01em; }
.drawer h3 { margin: 20px 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.empty { padding: 28px; text-align: center; color: var(--muted); }

/* ---------- фонды ---------- */

.inv-cell { font-weight: 550; color: var(--accent); cursor: pointer; }
.inv-cell:hover { text-decoration: underline; }

/* ---------- браузер ---------- */

.browser-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.browser-bar button {
  padding: 7px 12px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font: inherit;
}

.browser-bar button.ghost {
  background: var(--panel);
  color: var(--ink);
  border-color: var(--line);
}

.browser-bar button:hover { filter: brightness(1.06); }

.badge {
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 12px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--panel);
}

.badge.ok { color: var(--good); border-color: var(--good); }
.badge.warn { color: var(--warn); border-color: var(--warn); }

/* Экран и журнал рядом: смотреть на браузер и читать вывод задания
   приходится одновременно, иначе непонятно, что именно он сейчас делает. */
.browser-split {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(280px, 1fr);
  gap: 12px;
  align-items: stretch;
}

@media (max-width: 1100px) {
  .browser-split { grid-template-columns: 1fr; }
}

.browser-screen {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 620px;
}

.browser-screen iframe {
  width: 100%;
  height: 100%;
  min-height: 620px;
  border: 0;
  display: block;
}

.browser-log {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  min-height: 620px;
}

.log-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  margin-bottom: 8px;
}

.browser-log pre {
  flex: 1;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--ink);
}

/* ---------- вход ---------- */

.gate {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.gate[hidden] { display: none; }

.gate-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px;
  width: min(360px, 90vw);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.gate-box h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.gate-box p { margin: 0; font-size: 13px; }

.gate-box input {
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
}

.gate-box button {
  padding: 9px 12px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font: inherit;
}

.gate-error { color: var(--bad); font-size: 13px; }
.gate-error[hidden] { display: none; }

.logout {
  margin-left: auto;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  font: inherit;
}

.logout[hidden] { display: none; }

.browser-bar select {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
}

.li-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.li-form input[type=url] { flex: 1 1 280px; }
.li-form input[type=text] { flex: 2 1 360px; }

.li-form input[type=url], .li-form input[type=text] {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
}

.li-form button {
  padding: 7px 12px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font: inherit;
}

.li-form .muted { flex: 1 1 100%; font-size: 12px; }
