:root {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #192026;
  background: #f4f5f2;
}
* { box-sizing: border-box; }
body { margin: 0; }
.shell { max-width: 1240px; margin: auto; padding: 28px 22px 72px; }
.topbar, .section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.topbar { align-items: center; margin-bottom: 26px; }
h1 { font-size: clamp(29px, 4vw, 42px); letter-spacing: -.04em; margin: 6px 0 0; }
h2 { font-size: 19px; letter-spacing: -.02em; margin: 0 0 8px; }
h3 { font-size: 17px; margin: 0; overflow-wrap: anywhere; }
p { color: #66716e; margin: 0 0 18px; line-height: 1.5; }
.eyebrow { font-size: 11px; font-weight: 800; letter-spacing: .1em; color: #74877d; text-transform: uppercase; }
.card { background: #fff; border: 1px solid #e2e7e1; border-radius: 18px; padding: 22px; margin-bottom: 16px; box-shadow: 0 8px 28px #153b2710; }
.narrow { max-width: 440px; margin: 10vh auto; }
.stats-heading { margin-bottom: 6px; }
.summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.summary .card { margin: 0; }
.metric { min-height: 128px; display: flex; flex-direction: column; justify-content: center; gap: 8px; }
.metric strong { font-size: clamp(23px, 3vw, 30px); line-height: 1.1; overflow-wrap: anywhere; }
.metric small, label small { color: #68736e; font-size: 12px; line-height: 1.35; }
.ai-metric strong { font-size: 19px; }
.telegram-overview { display: flex; justify-content: space-between; align-items: center; gap: 24px; }
.telegram-overview p { margin: 0; }
.telegram-service { display: flex; flex-direction: column; gap: 5px; min-width: 190px; }
.telegram-service strong { font-size: 18px; }
.telegram-service small { color: #68736e; font-size: 12px; overflow-wrap: anywhere; }
.purchase-list, .tariff-list { display: grid; gap: 12px; }
.purchase-card, .tariff-card { border: 1px solid #e2e7e1; border-radius: 14px; padding: 17px; min-width: 0; }
.purchase-card .section-head, .tariff-card .section-head { align-items: center; margin-bottom: 14px; }
.disclosure-heading, .purchase-summary { display: flex; align-items: center; gap: 12px; cursor: pointer; list-style: none; }
.disclosure-heading::-webkit-details-marker, .purchase-summary::-webkit-details-marker { display: none; }
.disclosure-heading::before, .purchase-summary::before { content: '›'; color: #176d42; font-size: 24px; line-height: 1; transition: transform .15s; flex: 0 0 auto; }
.disclosure-section[open] > .disclosure-heading::before, .purchase-row[open] > .purchase-summary::before { transform: rotate(90deg); }
.disclosure-heading h2 { margin: 0; }
.disclosure-heading .shown-count { margin-left: auto; }
.disclosure-body { margin-top: 18px; border-top: 1px solid #edf1ec; padding-top: 18px; }
.disclosure-body .section-head p { margin: 0; max-width: 760px; }
.disclosure-body .section-head { margin-bottom: 16px; }
.purchase-row { border: 1px solid #e2e7e1; border-radius: 12px; min-width: 0; }
.purchase-summary { padding: 12px 14px; flex-wrap: wrap; }
.purchase-summary strong { font-size: 14px; overflow-wrap: anywhere; }
.purchase-summary .badge { margin-left: auto; }
.purchase-detail { padding: 14px; border-top: 1px solid #edf1ec; }
.purchase-detail .purchase-facts { margin-top: 0; }
.tariff-picker { max-width: 420px; margin: 0 0 16px; }
.purchase-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.purchase-meta { font-size: 12px; margin: 0 0 12px; }
.delivery-failed { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: #a13631; background: #fbece9; border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; font-size: 13px; }
.delivery-failed button { flex: 0 0 auto; font-size: 12px; }
.tariff-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: end; }
.tariff-form button { min-height: 43px; }
.checkbox-field { display: flex; align-items: center; gap: 9px; min-height: 43px; }
.checkbox-field input { width: 19px; height: 19px; flex: 0 0 auto; }
form { display: grid; gap: 15px; }
label { font-size: 13px; font-weight: 700; display: grid; gap: 7px; min-width: 0; }
label[hidden] { display: none; }
.plan-field { display: grid; gap: 7px; min-width: 0; }
.plan-field small { color: #68736e; font-size: 12px; line-height: 1.35; }
input, select {
  font: inherit; color: inherit; border: 1px solid #cfd8d0; background: #fbfcfa;
  border-radius: 10px; padding: 11px 12px; min-width: 0; width: 100%;
}
input:focus, select:focus, button:focus-visible, summary:focus-visible { outline: 2px solid #337b52; outline-offset: 2px; }
button { font: inherit; font-weight: 700; border: 0; border-radius: 10px; padding: 11px 15px; background: #176d42; color: white; cursor: pointer; }
button:hover { filter: brightness(.94); }
button:disabled { opacity: .55; cursor: wait; }
.ghost { color: #176d42; background: #e9f2eb; }
.danger { color: #a13631; background: #fbece9; }
.form-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; }
.form-grid button { min-height: 43px; }
.filter-bar { display: grid; grid-template-columns: minmax(200px, 1fr) 200px 220px; gap: 12px; margin: 12px 0 20px; }
.shown-count { color: #68736e; font-size: 13px; white-space: nowrap; }
.license-list { display: grid; gap: 12px; }
.license { border: 1px solid #e2e7e1; border-radius: 14px; padding: 18px; }
.license-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 14px; }
.license-badges { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.badge { font-size: 11px; font-weight: 800; letter-spacing: .03em; padding: 5px 8px; border-radius: 7px; background: #e8f4e9; color: #257345; white-space: nowrap; }
.badge.expiring { background: #fff0d5; color: #895800; }
.badge.expired { background: #fff0d5; color: #895800; }
.badge.suspended, .badge.revoked { background: #fbece9; color: #a13631; }
.license-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.fact { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fact-label { color: #68736e; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.fact strong { font-size: 15px; overflow-wrap: anywhere; }
.fact small { color: #68736e; font-size: 12px; }
.usage { margin: 14px 0 8px; }
.usage progress { width: 100%; height: 8px; border: none; border-radius: 10px; overflow: hidden; }
.usage progress::-webkit-progress-bar { background: #e8eee9; }
.usage progress::-webkit-progress-value { background: #2f8859; }
.usage progress::-moz-progress-bar { background: #2f8859; }
.license-meta { font-size: 12px; color: #68736e; margin: 0; overflow-wrap: anywhere; }
.telegram-binding { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid #edf1ec; margin-top: 12px; padding-top: 12px; }
.telegram-binding-info { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; min-width: 0; overflow-wrap: anywhere; font-size: 13px; }
.telegram-binding-info strong { color: #176d42; }
.telegram-binding-info span { color: #4d5853; }
.telegram-binding button { font-size: 12px; padding: 8px 10px; flex: 0 0 auto; }
.license-management { border-top: 1px solid #edf1ec; margin-top: 16px; padding-top: 12px; }
.license-management summary { color: #176d42; font-weight: 700; font-size: 13px; cursor: pointer; width: fit-content; }
.edit-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 16px 0; }
.actions { display: flex; gap: 7px; flex-wrap: wrap; }
.actions button { font-size: 12px; padding: 9px 11px; }
.audit-list { display: grid; gap: 6px; max-height: 300px; overflow: auto; font-size: 13px; color: #4d5853; }
.audit-row { display: flex; gap: 14px; border-bottom: 1px solid #eff2ee; padding: 7px 0; }
.audit-row time { color: #7e8982; min-width: 150px; }
#message { position: fixed; right: 22px; bottom: 20px; max-width: 380px; padding: 12px 16px; background: #1d3025; color: white; border-radius: 10px; box-shadow: 0 12px 30px #0003; display: none; z-index: 10; }
#message.show { display: block; }
dialog { border: 0; border-radius: 16px; padding: 28px; max-width: 560px; box-shadow: 0 20px 70px #0005; }
dialog::backdrop { background: #18261eb0; }
dialog code { display: block; background: #eef4ef; padding: 15px; border-radius: 10px; overflow-wrap: anywhere; margin: 12px 0 18px; }
.dialog-actions { display: flex; gap: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
@media (max-width: 900px) {
  .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tariff-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .license-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-bar { grid-template-columns: minmax(160px, 1fr) minmax(140px, 1fr); }
  .filter-bar label:first-child { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
  .shell { padding: 20px 12px 54px; }
  .topbar, .section-head, .license-head { align-items: flex-start; }
  .section-head, .license-head { flex-direction: column; }
  .summary, .form-grid, .filter-bar, .edit-grid, .purchase-facts, .tariff-form { grid-template-columns: 1fr; }
  .filter-bar label:first-child { grid-column: auto; }
  .license-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .audit-row { flex-direction: column; gap: 2px; }
  .shown-count { white-space: normal; }
  .telegram-overview, .telegram-binding { flex-direction: column; align-items: flex-start; }
  .delivery-failed { flex-direction: column; align-items: flex-start; }
  .telegram-service { min-width: 0; }
  .disclosure-heading { align-items: flex-start; flex-wrap: wrap; }
  .disclosure-heading .shown-count { margin-left: 0; }
  .purchase-summary .badge { margin-left: 0; }
}
