:root {
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  color: #0b1b33;
  background: #eef5ff;
  --ink: #0b1b33;
  --muted: #526682;
  --blue: #0868e6;
  --line: #dbe7f6;
  --surface: #fff;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input, select, textarea { font: inherit; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid #84b9ff;
  outline-offset: 2px;
}
a { color: #075fce; }
.top {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  height: 72px; padding: 0 max(24px,calc((100% - 1550px)/2));
  border-bottom: 1px solid #dce8f5; background: #f8fbff;
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; font-weight: 750; font-size: 18px; letter-spacing: -.4px; }
.mark { display: grid; place-items: center; flex: none; width: 37px; height: 37px; border-radius: 12px; background: linear-gradient(145deg,#3899ff,#075fe3); box-shadow: 0 4px 10px #1269e72c; }
.mark::after { content: ""; width: 20px; height: 20px; background: #fff; clip-path: polygon(0 33%,100% 0,68% 100%,47% 60%,90% 12%,39% 52%); }
.shell { max-width: 1550px; margin: auto; display: grid; grid-template-columns: 213px minmax(0,1fr); gap: 28px; padding: 25px 24px 46px; }
aside { display: flex; flex-direction: column; gap: 24px; min-width: 0; }
nav { display: grid; gap: 6px; }
nav button { border: 0; color: #3f5471; background: transparent; text-align: left; border-radius: 12px; padding: 12px 13px; cursor: pointer; font-weight: 600; }
nav button span { display: inline-block; width: 26px; color: #48729f; font-size: 18px; }
nav button:hover { background: #e4f0ff; }
nav button[aria-current="page"] { background: #d9eaff; color: #0758b9; }
.aside-status { display: flex; align-items: start; gap: 9px; padding: 14px 10px; border-top: 1px solid #d7e5f6; font-size: 13px; overflow-wrap: anywhere; }
.aside-status small { display: block; color: var(--muted); margin-top: 4px; line-height: 1.4; }
.dot { width: 8px; height: 8px; margin-top: 5px; border-radius: 50%; background: #8095af; flex: none; }
.dot.ready { background: #138859; }
.dot.error { background: #bd542a; }
main { min-width: 0; }
.hero { position: relative; overflow: hidden; display: flex; align-items: end; justify-content: space-between; gap: 22px; background: linear-gradient(115deg,#0a419e,#0759c8 60%,#1670e5); color: #fff; border-radius: 24px; padding: 28px; margin-bottom: 18px; box-shadow: 0 8px 20px #0d53b224; }
.hero::after { content: ""; position: absolute; width: 220px; height: 220px; border: 1px solid #ffffff33; box-shadow: 0 0 0 17px #ffffff0b; border-radius: 38%; transform: rotate(28deg); right: -72px; top: -128px; pointer-events: none; }
.hero > * { z-index: 1; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(25px,3.2vw,35px); letter-spacing: -1.2px; line-height: 1.12; }
h2 { font-size: 18px; letter-spacing: -.28px; }
h3 { font-size: 15px; }
.hero p { margin-top: 9px; color: #e8f2ff; max-width: 530px; line-height: 1.45; font-size: 15px; }
.page-head { display: flex; justify-content: space-between; align-items: start; gap: 14px; margin: 3px 0 17px; }
.page-head p { margin-top: 7px; color: var(--muted); line-height: 1.45; }
.metrics { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; margin-bottom: 17px; }
.metric, .card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; }
.metric { padding: 15px 16px; }
.metric strong { display: block; margin-top: 4px; font-size: 27px; font-weight: 750; letter-spacing: -.7px; }
.metric span { font-size: 13px; color: var(--muted); }
.card { padding: 18px; }
.table-card { padding: 0; overflow: hidden; }
.card + .card { margin-top: 14px; }
.filters { display: flex; align-items: end; gap: 9px; padding: 15px; flex-wrap: wrap; }
.filters label { min-width: 112px; }
.filters .search { flex: 2 1 210px; }
label { display: grid; gap: 6px; color: #334b6d; font-size: 13px; font-weight: 650; }
input, select, textarea { width: 100%; min-width: 0; border: 1px solid #cdddf0; background: #fcfdff; color: var(--ink); border-radius: 10px; padding: 9px 11px; }
input, select { min-height: 39px; }
textarea { resize: vertical; line-height: 1.55; }
.check { display: flex; align-items: center; align-self: center; gap: 6px; }
.check input { width: 16px; min-height: 0; height: 16px; accent-color: var(--blue); }
.btn { border: 1px solid #cadff8; background: #edf5ff; color: #0b5abe; padding: 9px 13px; min-height: 39px; border-radius: 11px; cursor: pointer; font-weight: 650; font-size: 13px; white-space: nowrap; }
.btn:hover { background: #deedff; }
.btn.primary { background: #0871ee; border-color: #0871ee; color: #fff; }
.btn.primary:hover { background: #075fcf; }
.btn.inverse { background: #fff; color: #075abe; border-color: #fff; }
.btn.inverse:hover { background: #eaf4ff; }
.btn.small { min-height: 33px; padding: 6px 9px; }
.btn:disabled { cursor: default; opacity: .48; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.status { display: inline-flex; align-items: center; width: fit-content; padding: 5px 9px; border-radius: 8px; font-weight: 630; font-size: 12px; background: #e9f2ff; color: #275a9e; line-height: 1.25; }
.status.neutral { background: #edf2f8; color: #475a73; }
.status.good { background: #e4f6eb; color: #176841; }
.status.wait { background: #fff2da; color: #805312; }
.status.bad { background: #ffede8; color: #903f23; }
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; text-align: left; font-size: 13px; }
th { color: var(--muted); font-weight: 620; background: #f5f9ff; white-space: nowrap; }
th, td { padding: 11px 13px; border-top: 1px solid #e8f0f9; vertical-align: middle; }
td:first-child { min-width: 220px; }
.chat-title { font-weight: 660; display: block; overflow-wrap: anywhere; }
.secondary { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; overflow-wrap: anywhere; line-height: 1.35; }
.num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.paging { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 13px 15px; border-top: 1px solid #e8f0f9; font-size: 13px; color: var(--muted); }
.empty { color: var(--muted); padding: 24px; line-height: 1.5; }
.muted { color: var(--muted); font-size: 14px; line-height: 1.48; }
.split { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; align-items: start; }
.split .card + .card { margin: 0; }
.stack { display: grid; gap: 12px; }
.form-row { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: end; gap: 10px; }
.item { display: flex; justify-content: space-between; align-items: start; gap: 10px; border-top: 1px solid #e8f0f9; padding: 11px 0; }
.item:last-child { padding-bottom: 0; }
.preview { white-space: pre-wrap; overflow-wrap: anywhere; padding: 14px; border-radius: 12px; background: #f0f6ff; color: #243f64; line-height: 1.5; min-height: 100px; }
dialog { width: min(620px,calc(100% - 22px)); max-height: calc(100dvh - 26px); border: 1px solid #d5e4f5; border-radius: 20px; background: #f8fbff; padding: 0; color: var(--ink); box-shadow: 0 24px 80px #173b6b40; }
dialog::backdrop { background: #0b224f69; }
.dialog-head { display: flex; justify-content: space-between; gap: 12px; align-items: start; padding: 19px 19px 13px; position: sticky; top: 0; background: #f8fbff; border-bottom: 1px solid #e7effa; z-index: 1; }
.dialog-body { display: grid; gap: 12px; padding: 15px 19px 19px; }
.description { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 115px; overflow: auto; color: #48607e; font-size: 13px; line-height: 1.45; }
#toast { position: fixed; bottom: 19px; right: 19px; max-width: min(440px,calc(100% - 38px)); color: #fff; background: #143960; padding: 12px 15px; border-radius: 13px; box-shadow: 0 5px 18px #14396042; z-index: 5; font-size: 14px; }
#toast.error { background: #873f2d; }
.inbox-grid {
  display: grid; grid-template-columns: minmax(220px, 295px) minmax(0, 1fr);
  padding: 0; overflow: hidden; height: min(720px, calc(100dvh - 172px)); min-height: 480px;
}
.inbox-sidebar { display: grid; grid-template-rows: auto minmax(0,1fr); min-width: 0; border-right: 1px solid var(--line); background: #fff; }
.inbox-search { display: grid; gap: 10px; padding: 14px; border-bottom: 1px solid #e8f0f9; }
.inbox-list { overflow-y: auto; }
.thread-row {
  display: flex; align-items: center; gap: 10px; width: 100%; border: 0;
  border-bottom: 1px solid #eaf0f7; background: #fff; color: var(--ink);
  padding: 12px; text-align: left; cursor: pointer;
}
.thread-row:hover, .thread-row[aria-pressed="true"] { background: #eaf4ff; }
.thread-copy, .thread-heading { display: grid; min-width: 0; gap: 4px; flex: 1; }
.thread-copy b, .thread-copy span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-copy b { font-size: 14px; }
.thread-copy span { color: var(--muted); font-size: 12px; }
.thread-copy .thread-account { color: #215d9f; font-size: 11px; }
.inbox-avatar {
  display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 13px;
  background: #dcecff; color: #164f94; font-weight: 720; font-size: 14px;
}
.unread, nav button .unread {
  display: inline-grid; place-items: center; flex: none; width: auto; min-width: 20px; min-height: 20px;
  padding: 2px 5px; border-radius: 7px; background: #0968df; color: #fff; font-size: 11px; font-weight: 700;
}
nav button .unread[hidden] { display: none; }
.inbox-chat { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0,1fr) auto; background: #f1f7ff; }
.inbox-placeholder { grid-row: 1 / -1; align-self: center; justify-self: center; text-align: center; padding: 18px; }
.inbox-placeholder p { margin-top: 7px; }
.message-symbol { display: block; width: 45px; height: 34px; background: #d6e9ff; border-radius: 12px 12px 12px 4px; margin: 0 auto 14px; }
.inbox-chat-head {
  padding: 10px 15px; display: flex; align-items: center; gap: 11px; min-height: 62px;
  border-bottom: 1px solid var(--line); background: #fff;
}
.inbox-chat-head h2 { overflow-wrap: anywhere; font-size: 16px; }
.inbox-back { display: none; }
.inbox-messages { min-height: 0; overflow-y: auto; padding: 13px 17px 17px; }
.inbox-day { margin: 12px 0; text-align: center; color: #516682; font-size: 12px; }
.inbox-older { display: block; margin: 3px auto 9px; }
.message-row { display: flex; margin-bottom: 8px; }
.message-row.out { justify-content: end; }
.message-bubble {
  max-width: min(80%, 610px); padding: 9px 12px; border: 1px solid #dce7f5; border-radius: 14px 14px 14px 4px;
  background: #fff; font-size: 14px; line-height: 1.45; overflow-wrap: anywhere;
}
.message-row.out .message-bubble { background: #dcecff; border-color: #cee3ff; border-radius: 14px 14px 4px 14px; }
.message-row.out .delivery-error { background: #fff3ea; border-color: #f0d5c7; }
.message-body { white-space: pre-wrap; }
.message-kind { font-size: 13px; color: #426087; }
.message-meta { display: flex; flex-wrap: wrap; justify-content: end; gap: 7px; margin-top: 4px; color: #4b617f; font-size: 11px; }
.message-error { margin-top: 5px; font-size: 12px; color: #883a24; }
.inbox-compose {
  display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: end; gap: 9px;
  border-top: 1px solid var(--line); background: #fff; padding: 11px 14px;
}
.inbox-compose textarea { min-height: 52px; max-height: 125px; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 155px minmax(0,1fr); padding-inline: 16px; gap: 15px; }
  .metrics { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .top { height: 58px; padding-inline: 12px; }
  .brand { font-size: 15px; gap: 8px; }
  .mark { width: 30px; height: 30px; border-radius: 9px; }
  .top .status { font-size: 10px; }
  .shell { display: block; padding: 10px 10px 28px; }
  nav { display: flex; overflow-x: auto; gap: 2px; padding-bottom: 6px; }
  nav button { white-space: nowrap; padding: 8px 10px; font-size: 13px; }
  nav button span { width: 17px; font-size: 14px; }
  .aside-status { display: none; }
  .hero { align-items: start; flex-direction: column; padding: 19px; gap: 13px; }
  .metrics { gap: 7px; }
  .metric { padding: 11px; }
  .metric strong { font-size: 22px; }
  .page-head { align-items: start; flex-direction: column; }
  .card { padding: 13px; }
  .table-card { padding: 0; }
  .inbox-grid { grid-template-columns: minmax(0,1fr); height: max(480px,calc(100dvh - 164px)); }
  .inbox-sidebar { border-right: 0; }
  .inbox-grid:not(.has-chat) .inbox-chat, .inbox-grid.has-chat .inbox-sidebar { display: none; }
  .inbox-back { display: inline-flex; align-items: center; }
  .inbox-compose { padding: 9px; }
  .message-bubble { max-width: 88%; }
}

.theme-settings { margin-bottom: 14px; }
.theme-settings label { max-width: 240px; }
.shop-filters { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; align-items: end; }
.shop-filters .btn { justify-self: start; }
.shop-item { align-items: center; }
.shop-item .actions { flex-wrap: nowrap; }
.shop-item b { overflow-wrap: anywhere; }
.shop-item strong { white-space: nowrap; }
#shop-results .paging { padding-inline: 0; }
@media (max-width: 620px) {
  .shop-filters { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .shop-item { align-items: start; }
  .shop-item .actions { align-items: end; flex-direction: column; gap: 5px; }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e8effa;
  --muted: #a6b7ce;
  --blue: #74aeff;
  --line: #30435b;
  --surface: #172436;
  --dark-raised: #1d2e44;
  --dark-highlight: #223b58;
  color: var(--ink);
  background: #101a28;
}
[data-theme="dark"] a { color: #8bc1ff; }
[data-theme="dark"] .top, [data-theme="dark"] dialog, [data-theme="dark"] .dialog-head {
  background: var(--surface); border-color: var(--line);
}
[data-theme="dark"] nav button, [data-theme="dark"] label { color: #bdcde3; }
[data-theme="dark"] nav button span { color: #8fb5e4; }
[data-theme="dark"] nav button:hover { background: var(--dark-raised); }
[data-theme="dark"] nav button[aria-current="page"] { color: #a8ceff; background: var(--dark-highlight); }
[data-theme="dark"] input, [data-theme="dark"] select, [data-theme="dark"] textarea {
  background: #111d2e; border-color: #425976;
}
[data-theme="dark"] .btn:not(.primary):not(.inverse) {
  background: var(--dark-raised); color: #a8ceff; border-color: #486384;
}
[data-theme="dark"] .btn:not(.primary):not(.inverse):hover { background: var(--dark-highlight); }
[data-theme="dark"] .status { background: #223d60; color: #b2d4ff; }
[data-theme="dark"] .status.neutral { background: #293b53; color: #ccdaec; }
[data-theme="dark"] .status.good { background: #173e34; color: #a1e5bc; }
[data-theme="dark"] .status.wait { background: #48351c; color: #f3d396; }
[data-theme="dark"] .status.bad { background: #4f302c; color: #ffbaa9; }
[data-theme="dark"] th, [data-theme="dark"] .preview { background: var(--dark-raised); color: var(--muted); }
[data-theme="dark"] :is(th,td,.item,.paging,.aside-status,.inbox-search,.thread-row,.message-bubble) {
  border-color: var(--line);
}
[data-theme="dark"] :is(.inbox-sidebar,.thread-row,.inbox-chat-head,.message-bubble,.inbox-compose) {
  background: var(--surface);
}
[data-theme="dark"] .inbox-chat { background: #111d2e; }
[data-theme="dark"] :is(.thread-row:hover,.thread-row[aria-pressed="true"],.inbox-avatar,.message-symbol,.message-row.out .message-bubble) {
  background: var(--dark-highlight); border-color: #385574;
}
[data-theme="dark"] .message-row.out .delivery-error { background: #4f302c; border-color: #71423a; }
[data-theme="dark"] :is(.message-kind,.message-meta,.inbox-day,.description) { color: var(--muted); }
[data-theme="dark"] :is(.thread-copy .thread-account,.inbox-avatar) { color: #a8ceff; }
[data-theme="dark"] .message-error { color: #ffbaa9; }

.shop-balance-header { justify-content: space-between; }
.shop-balance { display: flex; flex-wrap: wrap; gap: 12px 32px; }
.shop-balance strong { display: block; font-size: 20px; font-variant-numeric: tabular-nums; margin-top: 4px; }
#shop-confirm-text { white-space: pre-line; line-height: 1.55; }

.account-stats-row { align-items: center; }
.account-stats-row .actions { justify-content: flex-end; }
.account-stats-meta { display: grid; gap: 10px; }
.account-stats-counts { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; }
#account-stats-details > label { max-width: 420px; }
#account-restrictions > h3 { margin-bottom: 9px; }
@media (max-width: 620px) {
  .account-stats-row { align-items: start; }
  .account-stats-row .actions { flex-direction: column; align-items: end; flex-shrink: 0; max-width: 55%; }
  .account-stats-counts { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

.profile-fields { min-width: 0; border: 0; margin: 0; padding: 0; }
.profile-fields .btn { justify-self: start; }
.profile-avatar { display: grid; place-items: center; width: 88px; height: 88px;
  border: 1px solid var(--line); border-radius: 50%; overflow: hidden; }
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-avatar .muted { font-size: 12px; }
