@import url("/static/fonts/fonts.css");

/* ============================================================
   usachesVPN
   Тёплая графитовая база, приглушённая латунь как акцент,
   шалфейная зелень для «работает». Без свечений и неона —
   контраст и воздух вместо спецэффектов.
   ============================================================ */

:root {
  /* Поверхности — тёплый уголь, а не холодный синий-чёрный */
  --bg:         #12110F;
  --bg-elev:    #171613;
  --surface:    #1B1A16;
  --surface-hi: #22211C;
  --line:       #2B2924;
  --line-hi:    #3A3830;

  /* Текст — тёплый белый, читается мягче чистого #fff */
  --text:   #EDE9E0;
  --text-2: #A9A396;
  --text-3: #777166;

  /* Акцент — приглушённая латунь */
  --brand:     #C9A227;
  --brand-hi:  #DFBB4B;
  --brand-ink: #17140A;
  --brand-a10: rgba(201, 162, 39, 0.10);
  --brand-a20: rgba(201, 162, 39, 0.22);

  /* Статусы — спокойные, несигнальные */
  --ok:         #8CA87A;
  --ok-a10:     rgba(140, 168, 122, 0.12);
  --warn:       #CE9A5A;
  --warn-a10:   rgba(206, 154, 90, 0.12);
  --danger:     #C4695F;
  --danger-a10: rgba(196, 105, 95, 0.12);

  --sidebar-w: 246px;
  --radius:    10px;
  --radius-sm: 7px;

  --font-display: "Source Serif 4", Georgia, "Times New Roman", serif;
  --font-body: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, "Cascadia Mono", monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.005em;
  line-height: 1.25;
  margin: 0;
}
h1 { font-size: 27px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }

a { color: var(--brand-hi); text-decoration: none; }
a:hover { text-decoration: underline; }

code, .mono { font-family: var(--font-mono); font-size: 0.9em; }
.muted { color: var(--text-2); }
.dim   { color: var(--text-3); font-size: 13px; }

/* ===================== КАРКАС ===================== */

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-elev);
  border-right: 1px solid var(--line);
  padding: 24px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 24px; color: var(--brand); flex-shrink: 0; }
.brand-mark svg { display: block; width: 100%; height: auto; }
.brand-name { font-family: var(--font-display); font-weight: 600; font-size: 16px; }
.brand-beta {
  font-family: var(--font-body);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .09em;
  color: var(--text-3);
  border: 1px solid var(--line-hi);
  border-radius: 3px;
  padding: 2px 5px;
  vertical-align: 3px;
  margin-left: 7px;
}

.nav { display: flex; flex-direction: column; gap: 1px; margin-top: 20px; }
.nav-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 18px 10px 7px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--surface-hi); color: var(--text); }
.nav-item.active .icon { color: var(--brand); }
.nav-item .icon { flex-shrink: 0; color: var(--text-3); }
.nav-item .count {
  margin-left: auto;
  background: var(--brand);
  color: var(--brand-ink);
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
}

.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }
.who { display: flex; align-items: center; gap: 10px; padding: 6px 8px; }
.who-avatar {
  width: 30px; height: 30px; flex-shrink: 0;
  border-radius: 7px;
  background: var(--surface-hi);
  border: 1px solid var(--line-hi);
  color: var(--brand);
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
}
.who-name { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-link { font-size: 12px; color: var(--text-3); }

.main { flex: 1; min-width: 0; }
.container { max-width: 900px; padding: 34px 34px 80px; margin: 0 auto; }

/* Публичная шапка (инструкция без входа) */
.public-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elev);
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-head p { margin: 6px 0 0; color: var(--text-2); font-size: 14px; }

.topbar-mobile, .tabbar { display: none; }

/* ===================== КОМПОНЕНТЫ ===================== */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 14px;
}
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.card-title { margin-bottom: 14px; }

.section { margin-bottom: 34px; }
.section > h2 { margin-bottom: 14px; }

/* Кнопки */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 17px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--brand);
  color: var(--brand-ink);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--brand-hi); text-decoration: none; }
.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; }

.btn-ghost { background: var(--surface-hi); color: var(--text); border-color: var(--line-hi); }
.btn-ghost:hover { background: var(--line); }

.btn-quiet { background: transparent; color: var(--text-2); border-color: var(--line-hi); }
.btn-quiet:hover { background: var(--surface-hi); color: var(--text); }

.btn-danger { background: transparent; color: var(--danger); border-color: rgba(196,105,95,.4); }
.btn-danger:hover { background: var(--danger-a10); }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn-row form { margin: 0; }

/* Формы */
.form { display: flex; flex-direction: column; max-width: 420px; }
.form-wide { max-width: none; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > label, .label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.hint { font-size: 12px; color: var(--text-3); line-height: 1.45; }

input[type="text"], input[type="password"], input[type="number"],
input[type="file"], select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line-hi);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  transition: border-color .12s, box-shadow .12s;
}
textarea { resize: vertical; min-height: 84px; line-height: 1.55; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-a10);
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%23777166' stroke-width='1.6' d='M1 1.8 6 6.2l5-4.4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}
input[type="file"] { padding: 9px 12px; color: var(--text-2); font-size: 13px; }
input[type="file"]::file-selector-button {
  background: var(--surface-hi);
  border: 1px solid var(--line-hi);
  color: var(--text);
  border-radius: 6px;
  padding: 5px 11px;
  margin-right: 10px;
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
}

.check { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; font-size: 14px; cursor: pointer; }
.check input { width: auto; margin: 3px 0 0; accent-color: var(--brand); flex-shrink: 0; }

/* Сообщения */
.alert {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid;
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 16px;
}
.alert .icon { flex-shrink: 0; margin-top: 2px; }
.alert-success { background: var(--ok-a10);     border-color: rgba(140,168,122,.35); color: #A7C094; }
.alert-error   { background: var(--danger-a10); border-color: rgba(196,105,95,.35);  color: #D98A80; }
.alert-info    { background: var(--brand-a10);  border-color: var(--brand-a20);      color: var(--brand-hi); }
.alert-warn    { background: var(--warn-a10);   border-color: rgba(206,154,90,.35);  color: var(--warn); }
.alert a { color: inherit; text-decoration: underline; }

/* Ключи */
.key-list { display: flex; flex-direction: column; gap: 10px; }
.key-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  color: var(--text);
  transition: border-color .12s, background .12s;
}
.key-card:hover { border-color: var(--line-hi); background: var(--surface-hi); text-decoration: none; }
.key-body { min-width: 0; flex: 1; }
.key-name { font-weight: 600; font-size: 15px; display: block; }
.key-meta { color: var(--text-3); font-size: 13px; margin-top: 3px; display: block; }
.key-card .chev { color: var(--text-3); flex-shrink: 0; }

/* Пиксельный квадрат вместо кружка — отсылка к знаку бренда */
.pixel-dot { width: 8px; height: 8px; flex-shrink: 0; background: var(--text-3); }
.pixel-dot.on  { background: var(--ok); }
.pixel-dot.off { background: var(--danger); }

/* Бейджи */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 5px;
  background: var(--surface-hi);
  color: var(--text-2);
  border: 1px solid var(--line-hi);
  white-space: nowrap;
}
.badge-ok     { background: var(--ok-a10);     color: #A7C094;      border-color: rgba(140,168,122,.3); }
.badge-warn   { background: var(--warn-a10);   color: var(--warn);  border-color: rgba(206,154,90,.3); }
.badge-danger { background: var(--danger-a10); color: #D98A80;      border-color: rgba(196,105,95,.3); }
.badge-brand  { background: var(--brand-a10);  color: var(--brand-hi); border-color: var(--brand-a20); }

/* Свойство — значение */
.facts { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.fact { display: flex; justify-content: space-between; gap: 16px; padding: 13px 18px; background: var(--surface); font-size: 14px; }
.fact dt { color: var(--text-2); margin: 0; }
.fact dd { margin: 0; font-weight: 500; text-align: right; }

/* Статистика */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 12px; margin-bottom: 30px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 17px 19px; }
.stat-num { font-family: var(--font-display); font-size: 27px; font-weight: 600; line-height: 1.1; }
.stat-label { font-size: 12px; color: var(--text-3); margin-top: 5px; line-height: 1.4; }
.stat.accent .stat-num { color: var(--brand-hi); }
.stat.alert-num .stat-num { color: var(--warn); }

/* Плитки */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(232px, 1fr)); gap: 12px; }
.tile {
  display: flex;
  align-items: center;
  gap: 13px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 17px 19px;
  color: var(--text);
  font-weight: 500;
  font-size: 14px;
  transition: border-color .12s, background .12s;
}
.tile:hover { border-color: var(--line-hi); background: var(--surface-hi); text-decoration: none; }
.tile .icon { color: var(--brand); flex-shrink: 0; }
.tile .count { margin-left: auto; }

/* Таблицы */
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; background: var(--surface); margin-bottom: 22px; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
thead th {
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elev);
  white-space: nowrap;
}
tbody td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-hi); }
td.actions-cell { white-space: nowrap; }
.cell-strong { font-weight: 600; }

/* Переписка — своя прокрутка, чтобы шапка/панель над чатом никуда не уезжали */
.thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 22px;
  max-height: min(55vh, 620px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 4px 2px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
}
.bubble {
  max-width: min(78%, 520px);
  padding: 11px 15px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.bubble time { display: block; margin-top: 6px; font-size: 11px; opacity: .6; }
.bubble.mine   { align-self: flex-end; background: var(--brand); color: var(--brand-ink); border-bottom-right-radius: 3px; }
.bubble.theirs { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 3px; }

.thread-list { display: flex; flex-direction: column; gap: 8px; }
.thread-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 18px;
  color: var(--text);
  transition: border-color .12s, background .12s;
}
.thread-row:hover { border-color: var(--line-hi); background: var(--surface-hi); text-decoration: none; }

/* Объявления */
.announce {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 2px solid var(--line-hi);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 10px;
}
.announce.pinned { border-left-color: var(--brand); }
.announce h3 { margin-bottom: 6px; }
.announce p { margin: 0; color: var(--text-2); font-size: 14px; white-space: pre-wrap; }
.announce time { display: block; margin-top: 10px; font-size: 12px; color: var(--text-3); }

/* Списки задач */
.todo-list { list-style: none; padding: 0; margin: 0; }
.todo-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.todo-row:last-child { border-bottom: none; padding-bottom: 0; }
.todo-row form { margin: 0; }

/* Инструкция */
.steps { display: flex; flex-direction: column; gap: 14px; }
.guide-list { margin: 0; padding-left: 20px; }
.guide-list li { margin-bottom: 9px; color: var(--text-2); line-height: 1.6; }
.guide-list li:last-child { margin-bottom: 0; }
.guide-list b { color: var(--text); font-weight: 600; }

/* Секретный код */
.secret {
  font-family: var(--font-mono);
  font-size: 17px;
  letter-spacing: .06em;
  background: var(--bg);
  border: 1px dashed var(--line-hi);
  border-radius: var(--radius-sm);
  padding: 17px;
  text-align: center;
  color: var(--brand-hi);
  word-break: break-all;
  margin: 14px 0;
}

pre.plain {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  white-space: pre-wrap;
  margin: 0 0 6px;
  color: var(--text);
  line-height: 1.6;
}

/* Пустые состояния — здесь появляется знак бренда */
.empty { text-align: center; padding: 48px 20px; border: 1px dashed var(--line-hi); border-radius: var(--radius); }
.empty-mark { width: 56px; margin: 0 auto 18px; color: var(--line-hi); }
.empty-mark svg { display: block; width: 100%; height: auto; }
.empty h2 { margin-bottom: 8px; }
.empty p { color: var(--text-2); font-size: 14px; margin: 0 auto 20px; max-width: 430px; }

/* Сворачиваемая карточка клиента над перепиской в поддержке */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 22px; }
.panel > summary {
  list-style: none; cursor: pointer; user-select: none;
  padding: 15px 18px; font-weight: 600; font-size: 14px;
  display: flex; align-items: center; gap: 8px;
}
.panel > summary::-webkit-details-marker { display: none; }
.panel > summary::before { content: "▸"; color: var(--text-3); transition: transform .15s; font-size: 11px; }
.panel[open] > summary::before { transform: rotate(90deg); }
.panel-body { padding: 0 18px 18px; border-top: 1px solid var(--line); padding-top: 16px; }
.live-hint { font-size: 12px; color: var(--text-3); }

/* Вход и регистрация */
.auth-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}
.auth-box { width: 100%; max-width: 396px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 28px; }
.auth-brand .brand-mark { width: 42px; }
.auth-brand .brand-name { font-size: 21px; }
.auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 28px; }
.auth-card h1 { font-size: 22px; margin-bottom: 6px; }
.auth-sub { color: var(--text-2); font-size: 14px; margin: 0 0 22px; line-height: 1.5; }
.auth-links { margin-top: 20px; text-align: center; font-size: 13.5px; color: var(--text-2); display: flex; flex-direction: column; gap: 7px; }
.auth-foot { margin-top: 26px; text-align: center; }

.divider { display: flex; align-items: center; gap: 12px; margin: 22px 0; color: var(--text-3); font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.tg-box { display: flex; justify-content: center; min-height: 44px; }

/* Подвал */
.site-foot {
  border-top: 1px solid var(--line);
  padding-top: 20px;
  margin-top: 44px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  align-items: center;
  font-size: 13px;
  color: var(--text-3);
}
.site-foot a { color: var(--text-2); }
.site-foot a:hover { color: var(--brand-hi); }

.icon { width: 18px; height: 18px; display: inline-block; vertical-align: middle; }
.icon-sm { width: 15px; height: 15px; }

/* Индикатор на кнопке, пока идёт долгая операция */
.spinner {
  width: 13px; height: 13px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  display: inline-block;
  margin-right: 7px;
  vertical-align: -2px;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn:disabled { opacity: .75; cursor: progress; }

/* Кнопка «скопировать» */
.copy-row { display: flex; align-items: center; gap: 8px; }
.copy-row > :first-child { flex: 1; min-width: 0; }
.btn.copied { background: var(--ok); color: #14170F; border-color: var(--ok); }

/* Страницы ошибок */
.errpage { text-align: center; padding: 60px 20px; }
.errpage .empty-mark { width: 64px; margin: 0 auto 20px; color: var(--line-hi); }
.errcode { font-family: var(--font-display); font-size: 46px; font-weight: 600; color: var(--text-3); line-height: 1; }
.errpage h1 { margin: 12px 0 8px; }
.errpage p { color: var(--text-2); max-width: 420px; margin: 0 auto 22px; }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2s; }
  * { transition-duration: .01ms !important; }
}

/* ===================== АДАПТИВ ===================== */

@media (max-width: 900px) {
  .sidebar { display: none; }

  .topbar-mobile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 18px;
    border-bottom: 1px solid var(--line);
    background: var(--bg-elev);
    position: sticky;
    top: 0;
    z-index: 20;
  }

  .container { padding: 24px 18px 96px; }
  .public-head { padding: 14px 18px; }
  h1 { font-size: 22px; }
  h2 { font-size: 17px; }

  .tabbar {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--bg-elev);
    border-top: 1px solid var(--line);
    padding: 7px 6px calc(7px + env(safe-area-inset-bottom));
    z-index: 30;
  }
  .tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 5px 2px;
    color: var(--text-3);
    font-size: 10.5px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    position: relative;
  }
  .tab.active { color: var(--brand); }
  .tab:hover { text-decoration: none; }
  .tab .count {
    position: absolute;
    top: 1px;
    left: 50%;
    margin-left: 6px;
    background: var(--brand);
    color: var(--brand-ink);
    font-size: 9px;
    font-weight: 700;
    border-radius: 999px;
    padding: 0 4px;
    min-width: 14px;
    text-align: center;
    line-height: 14px;
  }

  .bubble { max-width: 86%; }
  .fact { flex-direction: column; gap: 3px; }
  .fact dd { text-align: left; }
  .thread { max-height: 42vh; }
}

@media (max-width: 560px) {
  .btn-row .btn { flex: 1 1 auto; }
  .form { max-width: none; }
}
