:root {
  color-scheme: light;
  --bg: #f3f6fb;
  --surface: #fff;
  --text: #172338;
  --muted: #516079;
  --border: #dce4ef;
  --accent: #2455cb;
  --accent-hover: #1945b1;
  --accent-soft: #edf3ff;
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; line-height: 1.5; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 3px solid #779af0; outline-offset: 3px; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 5px; font-size: clamp(1.85rem, 5vw, 2.65rem); line-height: 1.13; letter-spacing: -.043em; }
h2 { margin-bottom: 12px; font-size: 1.2rem; letter-spacing: -.02em; }
h3 { margin-bottom: 8px; font-size: 1rem; }
p { margin-bottom: 12px; }
.muted, .help-text { color: var(--muted); }
.small, .help-text { font-size: .85rem; }
.help-text { margin: 10px 0 0; }
.eyebrow { margin-bottom: 5px; color: var(--accent); font-size: .72rem; font-weight: 750; letter-spacing: .1em; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 66px;
  padding: 12px max(22px, calc((100vw - 1120px) / 2));
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.brand { color: var(--text); font-size: 1.05rem; font-weight: 780; text-decoration: none; overflow-wrap: anywhere; }
.topbar-right { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-right > .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page { width: min(1120px, calc(100% - 44px)); min-height: calc(100vh - 164px); margin: 38px auto 52px; }
.footer { padding: 16px 22px; border-top: 1px solid var(--border); color: var(--muted); text-align: center; font-size: .8rem; }
.page-heading, .card-head, .key-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.page-heading { margin-bottom: 22px; }
.page-heading p, .card-head p, .key-heading p { margin-bottom: 0; }
.card, .stat-card, .auth-card {
  min-width: 0;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 2px 5px #1b3e7510;
}
.section-gap, .history-card { margin-top: 18px; }
.grid { display: grid; gap: 15px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.align-end { align-items: end; }
.stack { display: flex; flex-direction: column; gap: 13px; }
.inline-form, .key-actions, .copy-row, .row { display: flex; align-items: center; gap: 8px; }
.key-actions, .row { flex-wrap: wrap; }
.action-stack { display: flex; flex-wrap: wrap; gap: 8px; min-width: 180px; }
.action-stack .inline-form { flex-wrap: wrap; }
.button-row { display: flex; justify-content: flex-end; }
.full { width: 100%; }
label { display: flex; flex-direction: column; gap: 6px; color: var(--text); font-size: .88rem; font-weight: 630; }
input, textarea, select {
  min-width: 0;
  width: 100%;
  padding: 9px 11px;
  border: 1px solid #bfccdf;
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
textarea { resize: vertical; }
input::placeholder { color: #65748c; }
input[readonly] { background: #f8faff; }
.check { flex-direction: row; align-items: center; }
.check input { width: auto; }
.days-input { max-width: 76px; }
.password-input { max-width: 150px; }
.button, .btn {
  display: inline-flex;
  min-height: 42px;
  justify-content: center;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--text);
  background: #e8eef8;
  line-height: 1.25;
  font-family: inherit;
  font-size: .9rem;
  font-weight: 680;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.button:hover, .btn:hover { color: var(--text); background: #dce7f8; }
.button-primary, .btn { color: #fff; background: var(--accent); }
.button-primary:hover, .btn:hover { color: #fff; background: var(--accent-hover); }
.button-outline { border-color: #bfccdf; background: var(--surface); color: var(--text); }
.button-ghost { background: transparent; color: var(--muted); }
.button-danger, .danger { color: #9e2633; background: #fff0f1; border-color: #f2c4ca; }
.button-danger:hover, .danger:hover { color: #841f29; background: #ffe3e6; }
.button-small { min-height: 38px; padding: 6px 10px; font-size: .85rem; }
.button:disabled { border-color: var(--border); background: #e8edf5; color: #566680; cursor: not-allowed; }
.notice { display: flex; flex-wrap: wrap; gap: 5px 9px; margin: 0 0 16px; padding: 11px 14px; border: 1px solid transparent; border-radius: 11px; overflow-wrap: anywhere; }
.notice-info { color: #173b86; background: var(--accent-soft); border-color: #cbdcff; }
.notice-success { color: #16573a; background: #eaf8f0; border-color: #b9e2cc; }
.notice-error { color: #8f2632; background: #fff0f1; border-color: #f2c4ca; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: .78rem; font-weight: 680; white-space: nowrap; }
.pill-green { color: #166042; background: #e1f6ea; }
.pill-gray { color: #405374; background: #e9eff8; }
.pill-red { color: #902732; background: #fde7ea; }
.price { font-size: clamp(1.45rem, 4vw, 1.95rem); font-weight: 790; letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.auth-wrap { min-height: calc(100vh - 220px); display: grid; place-items: center; }
.auth-card { width: min(100%, 430px); padding: 28px; }
.auth-card form { margin-top: 20px; }
.auth-card > .button { margin-top: 12px; }
.text-link, .back-link { display: inline-block; margin-top: 12px; font-weight: 640; }
.tabs { display: flex; gap: 8px; padding: 4px 0 8px; overflow-x: auto; }
.tabs a { flex: none; padding: 7px 12px; border-radius: 9px; background: #e7eef9; color: #254780; text-decoration: none; }
.tabs a:hover { background: #dce8fc; }
.stat-card span, .stat-card strong { display: block; }
.stat-card span { color: var(--muted); font-size: .86rem; }
.stat-card strong { margin-top: 4px; font-size: 1.3rem; }
.table-wrap { max-width: 100%; margin-top: 10px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: .88rem; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-size: .79rem; font-weight: 690; }
td small { display: block; margin-top: 4px; }
.error-text { color: #9e2633; }
code, .small, td { overflow-wrap: anywhere; }
hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }
.search-form { max-width: 420px; margin-bottom: 12px; }
.edit-plan-form { padding-block: 9px; border-bottom: 1px solid var(--border); }

.cabinet-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(270px, 320px); gap: 18px; align-items: start; }
.key-list, .cabinet-sidebar { display: grid; min-width: 0; gap: 14px; }
.key-heading { align-items: flex-start; }
.key-heading h2 { margin-bottom: 4px; }
.key-card > .key-actions { margin: 16px 0 9px; }
.copy-status { color: var(--muted); font-size: .85rem; }
.key-details { border-top: 1px solid var(--border); }
.key-details summary { padding: 10px 0; cursor: pointer; color: #334865; font-weight: 640; }
.key-details-content { margin: 3px 0 13px; }
.subscription-key-qr { display: block; width: fit-content; margin-top: 10px; background: white; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.subscription-key-qr img { display: block; height: auto; max-width: 100%; }
.wallet-card .price { margin-bottom: 14px; }
.sidebar-link { display: flex; justify-content: space-between; gap: 6px; font-weight: 650; text-decoration: none; }
.app-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.app-links a { padding: 5px 9px; border-radius: 8px; background: #edf2fa; color: #344b73; text-decoration: none; font-size: .83rem; }
.history-card h2 { margin-bottom: 7px; }
.empty-state { padding: 34px 22px; }
.confirmation-dialog { width: min(420px, calc(100% - 32px)); padding: 22px; color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 15px 60px #182f5850; }
.confirmation-dialog::backdrop { background: #14233d6b; }
.confirmation-dialog h2, .confirmation-dialog p { margin: 0; }
.confirmation-dialog .key-actions { justify-content: flex-end; }

.checkout-shell { max-width: 900px; margin-inline: auto; }
.checkout-shell .back-link { margin: 0 0 12px; }
.checkout-card { max-width: 560px; }
.tariff-grid { align-items: stretch; }
.plan-card { display: flex; flex-direction: column; gap: 12px; }
.plan-card h2, .plan-card p { margin: 0; }
.plan-card .price { margin-top: auto; }
.summary-list { margin: 0 0 14px; }
.summary-list > div { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.summary-list dt { color: var(--muted); }
.summary-list dd { margin: 0; text-align: right; font-weight: 650; }
.summary-list .summary-total { font-size: 1.14rem; }
.summary-total dt { color: var(--text); font-weight: 710; }

@media (max-width: 850px) {
  .cabinet-layout { grid-template-columns: minmax(0, 1fr) minmax(235px, 270px); gap: 12px; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 650px) {
  .page { width: calc(100% - 28px); margin: 22px auto 36px; }
  .topbar { padding-inline: 14px; }
  .page-heading, .card-head { align-items: flex-start; flex-direction: column; }
  .grid-2, .grid-3, .grid-4, .cabinet-layout { grid-template-columns: minmax(0, 1fr); }
  .card, .stat-card, .auth-card { padding: 16px; }
  .key-heading { gap: 8px; }
  .cabinet-heading .button { width: 100%; }
  .copy-row { flex-wrap: wrap; }
  .tabular-table { min-width: 390px; }
}

.admin-tabs a[aria-current="page"] {
  color: #fff;
  background: var(--accent);
}
.admin-search .search-form { margin-bottom: 0; }
.admin-search .search-form + a { display: inline-block; margin-top: 10px; }
.admin-user-heading, .admin-user-facts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
}
.admin-user-heading { justify-content: space-between; }
.admin-user-heading h3, .admin-user-heading p { margin: 0; }
.admin-user-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}
.admin-user-actions > section {
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.admin-user-actions h4 { margin: 0 0 12px; }
.admin-key-row + .admin-key-row { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.admin-key-row .inline-form, .finance-action { align-items: flex-end; flex-wrap: wrap; }
.inbound-list, .archive-list { margin: 0; padding: 0; list-style: none; }
.archive-list li { padding: 5px 0; overflow-wrap: anywhere; }
.inbound-list li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  padding-block: 7px;
  border-bottom: 1px solid var(--border);
}
@media (max-width: 760px) {
  .admin-user-actions { grid-template-columns: minmax(0, 1fr); }
}

.inbound-name { min-width: 0; overflow-wrap: anywhere; }

.notice-green { color: #16573a; background: #eaf8f0; border-color: #b9e2cc; }
.notice-yellow { color: #6a4803; background: #fff6d9; border-color: #ecd79f; }
.notice-red { color: #8f2632; background: #fff0f1; border-color: #f2c4ca; }
.service-banner { white-space: pre-wrap; }
.incy-guide h2 { margin-top: 20px; }
.incy-guide ol { padding-left: 24px; }
.incy-guide li { margin-bottom: 8px; }

.telegram-message { white-space: pre-wrap; overflow-wrap: anywhere; }

.cabinet-install { margin-bottom: 14px; }
.cabinet-install-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
}
.cabinet-install h2 { margin-bottom: 4px; }
.cabinet-install p { margin-bottom: 0; }
.cabinet-install summary { margin-top: 10px; cursor: pointer; color: var(--accent); font-weight: 640; }
.cabinet-install ul { margin-bottom: 0; padding-left: 22px; }
.cabinet-rules { display: block; }
.cabinet-rules h2 { font-size: 1rem; margin-bottom: 5px; }
.cabinet-rules p { margin: 0; white-space: pre-wrap; }

.device-release { min-width: 130px; }
.device-release summary { color: var(--accent); cursor: pointer; font-weight: 640; }
.device-release form { margin-top: 6px; max-width: 240px; }
.device-table time { white-space: nowrap; }
