:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --panel: #ffffff;
  --text: #16181d;
  --muted: #6b7280;
  --line: #e6e8ec;
  --accent: #16181d;
  --ok: #116b38;
  --okbg: #d7f5e3;
  --warn: #8a4b00;
  --warnbg: #fdeccd;
  --bad: #b42318;
  --badbg: #fee4e2;
}

* { box-sizing: border-box; }

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

.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar__inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.brand svg { width: 26px; height: 26px; flex: none; display: block; }

.nav { display: flex; gap: 6px; flex: 1; }

.nav button {
  background: transparent;
  color: var(--muted);
  border: 0;
  padding: 8px 12px;
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
}

.nav button.active { background: #eef0f4; color: var(--text); }
.account { color: var(--muted); font-size: 13px; display: flex; gap: 12px; align-items: center; }

.page { max-width: 1080px; margin: 0 auto; padding: 24px 20px 64px; }

h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: -0.02em; }
h2 { font-size: 17px; margin: 0; }
h3 { font-size: 15px; margin: 0 0 8px; }
p { margin: 8px 0; }
.muted { color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 12px; align-items: center; }
.row--between { justify-content: space-between; }
.stack { display: grid; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }

.card {
  background: var(--panel);
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
  border: 1px solid rgba(16, 24, 40, 0.04);
}

.card--link { cursor: pointer; }
.card--link:hover { border-color: #cfd4dd; }

button, .btn {
  font: inherit;
  border: 0;
  border-radius: 9px;
  padding: 8px 13px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

button.ghost { background: #eceef2; color: var(--text); }
button.danger { background: var(--badbg); color: var(--bad); }
button:disabled { opacity: 0.5; cursor: default; }
button.sm { padding: 5px 9px; font-size: 13px; }

input, select, textarea {
  font: inherit;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d5d8de;
  border-radius: 9px;
  background: #fff;
  color: var(--text);
}

textarea { min-height: 90px; resize: vertical; }
label.field { display: grid; gap: 5px; font-size: 13px; color: var(--muted); }
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.table tr:last-child td { border-bottom: 0; }

.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #eceef2; color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--okbg); color: var(--ok); }
.badge.warn { background: var(--warnbg); color: var(--warn); }
.badge.bad { background: var(--badbg); color: var(--bad); }

.link-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: #374151;
  word-break: break-all;
}

details.section { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
details.section > summary { cursor: pointer; font-weight: 600; font-size: 14px; padding: 4px 0; }

.empty { color: var(--muted); padding: 12px 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #16181d;
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 100;
  max-width: 90vw;
}

.toast.error { background: var(--bad); }

.auth { max-width: 420px; margin: 40px auto; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tabs button { background: #eceef2; color: var(--text); }
.tabs button.active { background: var(--accent); color: #fff; }

.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.summary div { background: #f7f8fa; border-radius: 10px; padding: 12px; }
.summary strong { display: block; font-size: 22px; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow: auto;
  z-index: 50;
}

.modal__card {
  width: 100%;
  max-width: 640px;
  background: var(--panel);
  border-radius: 16px;
  padding: 20px 22px 22px;
  box-shadow: 0 24px 60px rgba(16, 24, 40, 0.25);
}

.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.modal__head h3 { margin: 0; font-size: 18px; }

.modal__close {
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 8px;
}

.modal__close:hover { background: #eef0f4; color: var(--text); }


/* ---------------------------------------------------------------- icons */
.icon { width: 18px; height: 18px; display: block; flex: none; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.icon-btn .btn-label { display: inline; }

/* ------------------------------------------------------------- mobile */
@media (max-width: 820px) {
  .topbar__inner { padding: 10px 14px; gap: 12px; flex-wrap: wrap; }
  .nav { order: 3; width: 100%; flex: none; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .nav button { white-space: nowrap; }
  .account { margin-left: auto; font-size: 12px; gap: 8px; }
  .page { padding: 16px 14px 48px; }
  h1 { font-size: 21px; }
  .row { flex-wrap: wrap; }
  .row--between { align-items: flex-start; }
  .grid-2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }

  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px;
    margin-bottom: 10px;
  }
  .table td { border: 0; padding: 3px 0; }
  .table td:empty { display: none; }
  .table tr:last-child td { border-bottom: 0; }

  .modal { padding: 0; align-items: stretch; }
  .table td[data-col]::before {
    content: attr(data-col);
    display: block;
    font-size: 11px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 2px;
  }
  .table tr td:first-child[data-col]::before { display: none; }
  .table td[data-col="#"] { display: none; }
  .table td:first-child[data-col="Тема"]::before,
  .table td:first-child[data-col="Вопрос"]::before { display: none; }
  .modal__card { max-width: none; min-height: 100vh; border-radius: 0; }
  .summary { grid-template-columns: repeat(2, 1fr); }
  .row > select { flex: 1 1 100%; order: 1; }
  .row > button { order: 2; }
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
  .tabs button { white-space: nowrap; }
}

@media (max-width: 560px) {
  .icon-btn .btn-label { display: none; }
  .icon-btn { width: 40px; height: 40px; padding: 0; }
  .icon-btn .icon { width: 19px; height: 19px; }
  .account { font-size: 11px; }
}

.consent { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; line-height: 1.45; color: var(--muted); }
.consent input { width: 16px; height: 16px; margin: 3px 0 0; flex: none; display: inline-block; }
.consent a { color: #1f5eff; text-decoration: none; }
.consent a:hover { text-decoration: underline; }

.doc-link { color: var(--muted); text-decoration: none; font-size: 13px; }
.doc-link:hover { color: var(--text); }

.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.plan-card { display: flex; flex-direction: column; gap: 10px; position: relative; padding: 18px; }
.plan-card.is-current { border-color: #1f5eff; box-shadow: 0 12px 30px rgba(31, 94, 255, 0.12); }
.plan-card__tag { position: absolute; top: -10px; left: 16px; background: #eef3ff; color: #1f5eff; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.plan-card__name { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.plan-card__price { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.plan-card__price small { font-size: 13px; font-weight: 500; color: var(--muted); }
.plan-card__features { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; font-size: 14px; color: #374151; }
.plan-card__features li::before { content: '\2713'; color: #116b38; font-weight: 700; margin-right: 7px; }
.plan-card button { margin-top: auto; }
.usage { display: grid; gap: 6px; }
.usage__top { display: flex; justify-content: space-between; font-size: 14px; }
.usage__track { height: 8px; border-radius: 999px; background: #eceef2; overflow: hidden; }
.usage__fill { height: 100%; border-radius: 999px; background: #1f5eff; }
.usage__fill.is-full { background: #b42318; }
.request-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13.5px; padding: 10px 0; border-top: 1px solid var(--line); color: #374151; }
.request-row__main { min-width: 0; }
.request-row__kind { font-weight: 500; }
.request-row__date { font-size: 12px; color: var(--muted); margin-top: 2px; }
.request-row .badge { flex: none; }

.plan-card__year { font-size: 12.5px; font-weight: 600; color: #116b38; background: #d7f5e3; border-radius: 8px; padding: 4px 9px; align-self: flex-start; }

@media (max-width: 820px) {
  .request-row { font-size: 13px; }
  .request-row .badge { font-size: 11px; padding: 2px 8px; }
  .plan-card__price { font-size: 24px; }
  .plan-card__features { font-size: 13.5px; }
}
