/* Панель управления подписками — та же палитра, что у клиентских дашбордов */
:root {
  --bg: #f4f7f5;
  --surface: #ffffff;
  --ink: #0e1a14;
  --ink-2: #24382e;
  --muted: #61766b;
  --faint: #8a9d93;
  --line: #e3ebe6;
  --line-2: #eef3f0;
  --accent: #1d6a49;
  --accent-strong: #15523a;
  --accent-soft: #e6f2ec;
  --accent-tint: #f3f9f5;
  --warn: #a06a12;
  --warn-soft: #fdf4e3;
  --danger: #a63a2f;
  --danger-soft: #fcecea;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow-1: 0 1px 2px rgba(14, 26, 20, 0.06);
  --shadow-2: 0 2px 8px rgba(14, 26, 20, 0.07), 0 1px 2px rgba(14, 26, 20, 0.04);
  --shadow-3: 0 8px 24px rgba(14, 26, 20, 0.1), 0 2px 6px rgba(14, 26, 20, 0.05);
  --shadow-4: 0 24px 60px rgba(14, 26, 20, 0.22);
  --ring: 0 0 0 3px rgba(56, 160, 111, 0.18);
}

* { box-sizing: border-box; }

/* display у .gate и .modal перебивает служебный атрибут hidden — возвращаем ему силу */
[hidden] { display: none !important; }

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.015em; }
p { margin: 0; }
button { font: inherit; }

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

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1100px 520px at 50% -10%, #1a5a3e 0%, #123a29 42%, #0b241a 100%);
}

.gate-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: 22px;
  padding: 34px 30px 30px;
  box-shadow: var(--shadow-4);
  display: grid;
  gap: 14px;
}

.gate-card h1 { font-size: 21px; }

.gate-hint { color: var(--muted); font-size: 14px; }

.gate-card input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font: inherit;
  background: var(--accent-tint);
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.gate-card input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
  background: var(--surface);
}

.gate-error {
  color: var(--danger);
  font-size: 13.5px;
  background: var(--danger-soft);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
}

/* -------------------------------------------------------------- кнопки */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink-2);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s, color 0.15s, box-shadow 0.15s, transform 0.06s;
  box-shadow: var(--shadow-1);
}

.btn:hover { border-color: #cfe0d7; background: #fbfdfc; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(21, 82, 58, 0.28);
}

.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }

.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--muted); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.14); color: #fff; border-color: transparent; }

.btn-danger { color: var(--danger); border-color: #f0d7d3; background: var(--danger-soft); box-shadow: none; }
.btn-danger:hover { background: #f9dfdb; border-color: #e8c4be; }

.btn-sm { padding: 6px 12px; font-size: 13px; }

.icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.icon-btn:hover { background: var(--accent-soft); color: var(--ink); }

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

.app-head {
  background:
    radial-gradient(900px 380px at 12% -40%, #1a5a3e 0%, #123a29 46%, #0b241a 100%);
  color: #fff;
  padding: 30px 0 34px;
}

.app-head-in {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 26px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.app-head h1 { font-size: 24px; }

.app-sub { color: rgba(255, 255, 255, 0.68); font-size: 14px; margin-top: 5px; }

.app-actions { display: flex; gap: 9px; flex-wrap: wrap; }
.app-actions .btn { background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.24); color: #fff; box-shadow: none; }
.app-actions .btn:hover { background: rgba(255, 255, 255, 0.2); border-color: rgba(255, 255, 255, 0.34); }
.app-actions .btn-ghost { background: transparent; border-color: transparent; }
.app-actions .btn-ghost:hover { background: rgba(255, 255, 255, 0.14); }

/* --------------------------------------------------------------- контент */

.app-main {
  max-width: 1320px;
  margin: -18px auto 60px;
  padding: 0 26px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

/* Предупреждение о том, что ссылка ещё локальная */
.notice {
  background: var(--warn-soft);
  border: 1px solid #f0e0bd;
  border-radius: var(--radius-sm);
  color: #7a5410;
  font-size: 13.5px;
  padding: 11px 14px;
  margin: 0 0 16px;
}

.notice b { color: #5f4109; }

.notice.err {
  background: var(--danger-soft);
  border-color: #f0d7d3;
  color: var(--danger);
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-2);
}

.stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); font-weight: 650; }
.stat-value { font-size: 27px; font-weight: 700; letter-spacing: -0.03em; margin-top: 5px; font-variant-numeric: tabular-nums; }
.stat-value.warn { color: var(--warn); }
.stat-value.danger { color: var(--danger); }
.stat-value.ok { color: var(--accent); }

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
  align-items: center;
}

.toolbar input[type="search"],
.toolbar select {
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  box-shadow: var(--shadow-1);
}

.toolbar input[type="search"] { flex: 1 1 240px; min-width: 180px; }
.toolbar input:focus, .toolbar select:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }

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

.cards { display: grid; gap: 14px; }

.card-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  padding: 18px 20px;
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
}

.card-row.is-expired { border-color: #f0d7d3; background: linear-gradient(180deg, #fffafa, var(--surface) 60%); }
.card-row.is-paused { opacity: 0.78; }

.proj-name { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.proj-name h3 { font-size: 16.5px; }

.badge {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 3px 9px;
  border-radius: 999px;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge.active { background: var(--accent-soft); color: var(--accent-strong); }
.badge.trial { background: #e8eefc; color: #2b4b8f; }
.badge.expired { background: var(--danger-soft); color: var(--danger); }
.badge.paused { background: #eef0ef; color: var(--muted); }
.badge.na { background: var(--warn-soft); color: var(--warn); }

.proj-meta {
  margin-top: 7px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted);
}

.proj-meta b { color: var(--ink-2); font-weight: 600; font-variant-numeric: tabular-nums; }

.proj-domains { margin-top: 6px; font-size: 12.5px; color: var(--faint); word-break: break-word; }

.proj-side { font-size: 13px; color: var(--muted); display: grid; gap: 5px; }

.proj-side .line { display: flex; gap: 8px; align-items: baseline; }
.proj-side .line span:first-child { color: var(--faint); min-width: 92px; }

.proj-actions { display: flex; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 46px 20px;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

/* -------------------------------------------------------------- модалка */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(11, 36, 26, 0.42);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 50;
  overflow: auto;
}

.modal-card {
  width: 100%;
  max-width: 660px;
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow-4);
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  animation: pop 0.16s ease-out;
}

@keyframes pop {
  from { opacity: 0; transform: translateY(8px) scale(0.99); }
  to { opacity: 1; transform: none; }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--line-2);
}

.modal-head h2 { font-size: 18px; }
.modal-body { padding: 20px 22px 24px; overflow: auto; display: grid; gap: 18px; }

fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 12px; }

legend {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--faint);
  padding: 0 0 8px;
}

.field { display: grid; gap: 5px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: 12.5px; color: var(--faint); }

.field input, .field textarea, .field select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}

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

.field textarea { min-height: 62px; resize: vertical; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }

/* Карточка одного тарифа в настройках */
.plan-row {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 12px;
  background: var(--surface, #fff);
}

.plan-row-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.plan-row-head b { font-size: 14px; }
.plan-row-head .hint { flex: 1; font-size: 12.5px; color: var(--faint); }
.plan-row-head .icon-btn { margin-left: auto; }

.embed-box {
  display: grid;
  gap: 8px;
  background: var(--accent-tint);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
}

.embed-box code {
  font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--accent-strong);
  word-break: break-all;
  user-select: all;
}

.modal-foot { display: flex; gap: 9px; justify-content: flex-end; flex-wrap: wrap; }

.sep { height: 1px; background: var(--line-2); }

/* ------------------------------------------------------------------- тост */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  box-shadow: var(--shadow-3);
  font-size: 14px;
  z-index: 90;
  max-width: min(90vw, 560px);
  text-align: center;
  animation: toast-in 0.18s ease-out;
}

.toast.err { background: var(--danger); }

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ------------------------------------------------------- выбор срока продления */

.extend-list {
  display: grid;
  gap: 10px;
}

/* Строка выбора — это label целиком: кликать можно по любому месту,
   а не только по маленькому кружку радио-кнопки */
.extend-opt {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.extend-opt:hover {
  border-color: var(--accent);
}

/* Выбранный вариант подсвечиваем рамкой: :has поддержан во всех актуальных
   браузерах, а если нет — остаётся обычное поведение радио-кнопки */
.extend-opt:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.extend-opt input[type="radio"] {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  margin: 0;
}

.extend-body {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.extend-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.extend-until {
  font-size: 13px;
  color: var(--muted);
}

/* «Бесплатно»: цены в списке гасим — платить не придётся, и показывать
   сумму как обязательство было бы враньём */
.extend-list.is-free [data-price] {
  text-decoration: line-through;
  opacity: 0.55;
}

.extend-free {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  margin-top: 14px;
  padding: 13px 15px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: var(--accent-tint);
  cursor: pointer;
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
}

.extend-free input[type="checkbox"] {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  accent-color: var(--accent);
}

.extend-free b {
  color: var(--ink);
}

.extend-free:has(input:checked) {
  border-color: var(--accent);
  border-style: solid;
}

/* --------------------------------------------------------------- адаптив */

@media (max-width: 1080px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .card-row { grid-template-columns: minmax(0, 1fr); }
  .proj-actions { justify-content: flex-start; }
}

@media (max-width: 680px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app-main { padding: 0 16px; }
  .app-head-in { padding: 0 16px; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .modal { padding: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
