/* Primum Billing — общие стили клиентских страниц и админки. */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e3e5e9;
  --border-strong: #cfd3da;
  --text: #14161a;
  --text-muted: #6a7180;
  --text-faint: #9aa1ad;
  --accent: #2f5bd7;
  --accent-hover: #2549b3;
  --accent-soft: #eaf0ff;
  --green: #12855c;
  --green-soft: #e6f6ef;
  --amber: #9a6200;
  --amber-soft: #fdf3e0;
  --red: #c02626;
  --red-soft: #fdeceb;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20, 22, 26, .06), 0 4px 16px rgba(20, 22, 26, .05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

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

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

.wrap { max-width: 720px; margin: 0 auto; padding: 32px 20px 64px; }
.wrap-wide { max-width: 1180px; }

/* ── Шапка ─────────────────────────────────────────────────────────────── */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: 14px 20px;
  display: flex; align-items: center; gap: 16px;
}
.brand { font-weight: 650; letter-spacing: -.01em; font-size: 16px; color: var(--text); }
.brand span { color: var(--accent); }
.topbar-spacer { flex: 1; }

/* ── Карточки ──────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 16px;
}
.card-tight { padding: 18px 20px; }
.card h1 { font-size: 22px; margin: 0 0 6px; letter-spacing: -.02em; }
.card h2 { font-size: 17px; margin: 0 0 14px; letter-spacing: -.01em; }
.card h3 { font-size: 14px; margin: 0 0 10px; color: var(--text-muted); font-weight: 600; }

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* ── Кнопки ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px;
  font: inherit; font-weight: 550;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: var(--accent); color: #fff;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, opacity .12s ease;
  text-decoration: none;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-lg { padding: 14px 26px; font-size: 16px; width: 100%; }
.btn-sm { padding: 7px 13px; font-size: 13px; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--accent); border-color: transparent; padding-left: 8px; padding-right: 8px; }
.btn-ghost:hover { background: var(--accent-soft); }
.btn-danger { background: var(--surface); color: var(--red); border-color: var(--border-strong); }
.btn-danger:hover { background: var(--red-soft); border-color: var(--red); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ── Формы ─────────────────────────────────────────────────────────────── */
label { display: block; font-size: 13px; font-weight: 550; color: var(--text-muted); margin-bottom: 5px; }
input[type=text], input[type=password], input[type=email], input[type=tel],
input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 10px 12px;
  font: inherit; color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  transition: border-color .12s ease, box-shadow .12s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { min-height: 72px; resize: vertical; }
.field { margin-bottom: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.id-input {
  font-family: var(--mono); font-size: 20px; letter-spacing: .12em;
  text-align: center; text-transform: uppercase; padding: 14px 12px;
}

/* ── Плашки статуса ────────────────────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-green { background: var(--green-soft); color: var(--green); }
.pill-amber { background: var(--amber-soft); color: var(--amber); }
.pill-red   { background: var(--red-soft); color: var(--red); }
.pill-gray  { background: #eef0f3; color: var(--text-muted); }

.banner {
  padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: 14px; margin-bottom: 16px;
  border: 1px solid transparent;
}
.banner-info  { background: var(--accent-soft); color: #1c3a8f; border-color: #cddcff; }
.banner-green { background: var(--green-soft); color: var(--green); border-color: #bfe6d5; }
.banner-amber { background: var(--amber-soft); color: var(--amber); border-color: #f2ddb8; }
.banner-red   { background: var(--red-soft); color: var(--red); border-color: #f5c9c6; }

/* ── Строки-реквизиты ──────────────────────────────────────────────────── */
.rows { border-top: 1px solid var(--border); }
.row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  padding: 11px 0; border-bottom: 1px solid var(--border);
}
.row-label { color: var(--text-muted); font-size: 14px; flex-shrink: 0; }
.row-value { text-align: right; font-weight: 500; }
.row-total { padding: 16px 0; }
.row-total .row-label { font-size: 15px; color: var(--text); font-weight: 600; }
.amount-big { font-size: 26px; font-weight: 650; letter-spacing: -.02em; }

/* ── Таблицы ───────────────────────────────────────────────────────────── */
.table-scroll { overflow-x: auto; margin: 0 -4px; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
  text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; color: var(--text-faint);
  padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.data td { padding: 11px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--surface-2); }

/* ── Копирование ссылки ────────────────────────────────────────────────── */
.copy-box {
  display: flex; gap: 8px; align-items: center;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 8px 8px 12px;
}
.copy-box input {
  flex: 1; min-width: 0;   /* без min-width:0 flex-элемент не даёт себя сжать */
  border: none; background: transparent; padding: 0;
  font-family: var(--mono); font-size: 12.5px; color: var(--text-muted);
  text-overflow: ellipsis;
}
.copy-box input:focus { box-shadow: none; }

/* ── Прочее ────────────────────────────────────────────────────────────── */
.spinner {
  display: inline-block; width: 15px; height: 15px;
  border: 2px solid rgba(255,255,255,.4); border-top-color: #fff;
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton { color: transparent; background: linear-gradient(90deg,#eceef1,#f5f6f8,#eceef1);
  background-size: 200% 100%; animation: sk 1.2s ease-in-out infinite; border-radius: 6px; }
@keyframes sk { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.footer { text-align: center; color: var(--text-faint); font-size: 13px; padding: 24px 0 8px; }
.footer a { color: var(--text-muted); }

.hidden { display: none !important; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; flex-wrap: wrap; }
.tab {
  padding: 10px 16px; font-size: 14px; font-weight: 550; color: var(--text-muted);
  border: none; background: none; cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -1px; font-family: inherit;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.stat-label { font-size: 12.5px; color: var(--text-muted); margin-bottom: 6px; }
.stat-value { font-size: 24px; font-weight: 650; letter-spacing: -.02em; }
.stat-sub { font-size: 12.5px; color: var(--text-faint); margin-top: 2px; }

dialog {
  border: none; border-radius: var(--radius); padding: 0;
  box-shadow: 0 8px 40px rgba(20,22,26,.2); max-width: 640px; width: calc(100% - 32px);
}
dialog::backdrop { background: rgba(20,22,26,.45); }
.dialog-head { padding: 20px 24px 0; }
.dialog-head h2 { margin-bottom: 4px; }
.dialog-body { padding: 16px 24px; max-height: 70vh; overflow-y: auto; }
.dialog-foot { padding: 16px 24px 20px; display: flex; gap: 10px; justify-content: flex-end; border-top: 1px solid var(--border); }

/* ── Информационные страницы (оферта, реквизиты, оплата, ПД) ───────────── */
.prose { max-width: 720px; }
.prose h1 { font-size: 26px; letter-spacing: -.02em; margin: 0 0 4px; text-wrap: balance; }
.prose .lead { color: var(--text-muted); margin: 0 0 28px; }
.prose h2 {
  font-size: 16px; margin: 32px 0 10px; letter-spacing: -.01em;
  padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.prose h3 { font-size: 14px; margin: 20px 0 6px; color: var(--text); font-weight: 600; }
.prose p { margin: 0 0 12px; }
.prose ul, .prose ol { margin: 0 0 12px; padding-left: 22px; }
.prose li { margin-bottom: 6px; }
.prose ol.clauses { list-style: none; padding-left: 0; counter-reset: cl; }
.prose ol.clauses > li { counter-increment: cl; padding-left: 34px; position: relative; margin-bottom: 10px; }
.prose ol.clauses > li::before {
  content: counter(cl) '.'; position: absolute; left: 0; top: 0;
  color: var(--text-faint); font-variant-numeric: tabular-nums;
}
.prose .req { border-top: 1px solid var(--border); }
.prose .req .row-label { min-width: 190px; }
.prose .updated { color: var(--text-faint); font-size: 13px; margin-top: 32px; }
.doclinks { display: flex; gap: 6px 18px; flex-wrap: wrap; justify-content: center; margin-bottom: 8px; }
.todo {
  background: var(--amber-soft); color: var(--amber); border: 1px dashed #d9a441;
  border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13.5px; margin: 0 0 12px;
}
