:root {
    color-scheme: dark;
    --bg: #08141a;
    --bg-deep: #061015;
    --surface: #11212a;
    --surface-2: #172a35;
    --surface-3: #1d3340;
    --line: #28414f;
    --line-soft: rgba(127, 161, 178, .16);
    --text: #f4f8fa;
    --muted: #8fa6b3;
    --green: #5bd56a;
    --green-2: #46c7ad;
    --green-soft: rgba(91, 213, 106, .12);
    --red: #ff626d;
    --red-soft: rgba(255, 98, 109, .12);
    --yellow: #f3c654;
    --blue: #55a7ff;
    --shadow: 0 24px 70px rgba(0, 0, 0, .28);
    --radius: 20px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 86% 0, rgba(56, 160, 124, .12), transparent 29rem),
        linear-gradient(145deg, var(--bg-deep), var(--bg) 42%, #0a171d);
    color: var(--text);
    font-family: Inter, Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
}
button, input, select { font: inherit; }
button { color: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
    outline: 2px solid var(--green);
    outline-offset: 2px;
}

.app-shell { min-height: 100vh; }
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    display: flex;
    width: 260px;
    flex-direction: column;
    padding: 24px 18px 18px;
    border-right: 1px solid var(--line-soft);
    background: rgba(7, 17, 23, .92);
    backdrop-filter: blur(20px);
}
.brand, .auth-brand { display: flex; align-items: center; gap: 12px; }
.brand img, .auth-brand img {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    object-fit: cover;
    box-shadow: 0 0 0 1px var(--line), 0 8px 24px rgba(0, 0, 0, .24);
}
.brand div, .auth-brand div, .sidebar-account div { display: grid; gap: 2px; min-width: 0; }
.brand strong, .auth-brand strong { font-size: 17px; font-weight: 900; letter-spacing: -.02em; }
.brand span, .auth-brand span, .sidebar-account span { color: var(--muted); font-size: 12px; }
.main-nav { display: grid; gap: 8px; margin-top: 38px; }
.nav-item {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    padding: 0 14px;
    border: 1px solid transparent;
    border-radius: 14px;
    background: transparent;
    color: var(--muted);
    font-weight: 750;
    text-align: left;
    transition: .18s ease;
}
.nav-item span {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    color: inherit;
    font-size: 19px;
}
.nav-item:hover { color: var(--text); background: rgba(255, 255, 255, .035); }
.nav-item.active { color: var(--green); border-color: rgba(91, 213, 106, .18); background: var(--green-soft); }
.security-card {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: auto;
    padding: 13px;
    border: 1px solid rgba(91, 213, 106, .18);
    border-radius: 14px;
    background: rgba(91, 213, 106, .07);
}
.security-card i, .system-indicator i {
    width: 8px;
    height: 8px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 0 5px rgba(91, 213, 106, .1);
}
.security-card div { display: grid; gap: 3px; }
.security-card strong { font-size: 12px; }
.security-card span { color: var(--muted); font-size: 10px; }
.sidebar-account {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) 34px;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
    padding-top: 16px;
    border-top: 1px solid var(--line-soft);
}
.admin-avatar {
    display: grid !important;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    color: #06140a;
    background: linear-gradient(135deg, var(--green), var(--green-2));
    font-size: 16px;
    font-weight: 900;
}
.sidebar-account strong { overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.sidebar-account button, .icon-button {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--surface);
    color: var(--muted);
}

.workspace { min-height: 100vh; margin-left: 260px; padding: 28px clamp(22px, 3vw, 44px) 60px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.topbar h1 { margin: 3px 0 0; font-size: clamp(26px, 3vw, 36px); line-height: 1.1; letter-spacing: -.045em; }
.eyebrow { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.system-indicator { display: flex; align-items: center; gap: 9px; height: 38px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; color: var(--muted); background: var(--surface); font-size: 12px; font-weight: 700; }
.system-indicator.warning i { background: var(--yellow); box-shadow: 0 0 0 5px rgba(243, 198, 84, .1); }
.system-indicator.error i { background: var(--red); box-shadow: 0 0 0 5px rgba(255, 98, 109, .1); }

.view { display: none; animation: view-in .18s ease; }
.view.active { display: block; }
@keyframes view-in { from { opacity: .3; transform: translateY(4px); } }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat-card {
    position: relative;
    min-height: 150px;
    overflow: hidden;
    padding: 20px;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
    background: linear-gradient(145deg, rgba(25, 47, 59, .96), rgba(15, 31, 40, .96));
    box-shadow: var(--shadow);
}
.stat-card::after { content: ""; position: absolute; width: 100px; height: 100px; right: -35px; top: -35px; border-radius: 50%; background: rgba(91, 213, 106, .06); }
.stat-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; color: var(--green); background: var(--green-soft); font-size: 18px; font-weight: 900; }
.stat-card strong { display: block; margin-top: 22px; font-size: 27px; line-height: 1; letter-spacing: -.04em; }
.stat-card span:last-child { display: block; margin-top: 7px; color: var(--muted); font-size: 12px; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, .7fr); gap: 16px; margin-top: 16px; }
.panel { border: 1px solid var(--line-soft); border-radius: var(--radius); background: rgba(17, 33, 42, .88); box-shadow: var(--shadow); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 20px 22px; border-bottom: 1px solid var(--line-soft); }
.panel-heading h2 { margin: 4px 0 0; font-size: 18px; letter-spacing: -.025em; }
.text-button { border: 0; background: transparent; color: var(--green); font-size: 12px; font-weight: 800; }
.compact-list { min-height: 300px; }
.compact-transaction { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 15px 22px; border-bottom: 1px solid var(--line-soft); }
.compact-transaction:last-child { border-bottom: 0; }
.operation-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 13px; color: var(--green); background: var(--surface-3); font-size: 18px; font-weight: 900; }
.operation-copy { display: grid; gap: 4px; min-width: 0; }
.operation-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.operation-copy span { overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.operation-amount { text-align: right; font-size: 12px; font-weight: 900; }
.service-list { padding: 8px 20px 16px; }
.service-row { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; align-items: center; gap: 12px; min-height: 55px; border-bottom: 1px solid var(--line-soft); }
.service-row:last-child { border-bottom: 0; }
.service-row i { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.service-row i.off { background: var(--yellow); }
.service-row div { display: grid; gap: 3px; }
.service-row span, .service-row small { color: var(--muted); font-size: 11px; }
.service-row strong { font-size: 12px; }

.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.toolbar-wrap { flex-wrap: wrap; }
.search-field { display: flex; flex: 1 1 280px; min-width: 220px; height: 44px; align-items: center; gap: 10px; padding: 0 14px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); color: var(--muted); }
.search-field input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); }
.search-field input::placeholder { color: #69808c; }
select { min-height: 44px; padding: 0 38px 0 13px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); color: var(--text); }
.secondary-button, .primary-button { min-height: 44px; padding: 0 18px; border-radius: 13px; font-weight: 850; }
.secondary-button { border: 1px solid var(--line); background: var(--surface-2); color: var(--text); }
.primary-button { width: 100%; border: 0; background: linear-gradient(135deg, var(--green), #58cf75); color: #051309; box-shadow: 0 12px 30px rgba(91, 213, 106, .16); }
.table-panel { overflow: hidden; }
.counter { display: grid; place-items: center; min-width: 36px; height: 28px; padding: 0 9px; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); background: var(--surface-2); font-size: 11px; font-weight: 800; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 13px 18px; color: var(--muted); background: rgba(5, 15, 20, .28); font-size: 10px; letter-spacing: .06em; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { height: 67px; padding: 10px 18px; border-top: 1px solid var(--line-soft); color: #dce8ed; font-size: 12px; white-space: nowrap; }
tbody tr:hover { background: rgba(255, 255, 255, .018); }
.user-cell { display: flex; align-items: center; gap: 10px; }
.mini-avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; color: #06140a; background: linear-gradient(135deg, var(--green), var(--green-2)); font-size: 12px; font-weight: 900; }
.user-cell div { display: grid; gap: 3px; }
.user-cell span, .muted { color: var(--muted); }
.row-button { min-height: 32px; padding: 0 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); color: var(--text); font-size: 11px; font-weight: 800; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; min-height: 26px; padding: 0 9px; border-radius: 8px; background: var(--green-soft); color: var(--green); font-size: 10px; font-weight: 900; }
.status-pill::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.status-pill.pending, .status-pill.processing { color: var(--yellow); background: rgba(243, 198, 84, .1); }
.status-pill.failed, .status-pill.cancelled { color: var(--red); background: var(--red-soft); }
.status-select { min-height: 34px; max-width: 126px; padding-left: 9px; border-radius: 9px; font-size: 11px; }
.empty-row td { height: 170px; color: var(--muted); text-align: center; }

.notice { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; padding: 16px 18px; border: 1px solid rgba(85, 167, 255, .2); border-radius: 16px; background: rgba(85, 167, 255, .07); }
.notice > span { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 9px; color: var(--blue); background: rgba(85, 167, 255, .14); font-weight: 900; }
.notice div { display: grid; gap: 4px; }
.notice p { margin: 0; color: var(--muted); font-size: 11px; }
.rates-grid { display: grid; grid-template-columns: repeat(3, minmax(250px, 1fr)); gap: 14px; }
.rate-card { overflow: hidden; border: 1px solid var(--line-soft); border-radius: var(--radius); background: var(--surface); }
.rate-card header { padding: 18px; border-bottom: 1px solid var(--line-soft); }
.rate-card h2 { margin: 4px 0 0; font-size: 17px; }
.rate-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(105px, 130px) 38px; align-items: center; gap: 8px; min-height: 70px; padding: 10px 14px; border-bottom: 1px solid var(--line-soft); }
.rate-row:last-child { border-bottom: 0; }
.rate-row div { display: grid; gap: 3px; min-width: 0; }
.rate-row strong { font-size: 12px; }
.rate-row span { overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.rate-row input { width: 100%; height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; outline: 0; background: var(--bg); color: var(--text); text-align: right; font-weight: 850; }
.rate-row input:focus { border-color: var(--green); }
.rate-save { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid rgba(91, 213, 106, .2); border-radius: 10px; background: var(--green-soft); color: var(--green); font-weight: 900; }

.modal { position: fixed; inset: 0; z-index: 80; display: none; }
.modal[aria-hidden="false"] { display: block; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .72); backdrop-filter: blur(6px); }
.modal-sheet { position: absolute; top: 0; right: 0; width: min(520px, 100%); height: 100%; overflow-y: auto; border-left: 1px solid var(--line); background: var(--bg); box-shadow: -24px 0 70px rgba(0, 0, 0, .38); animation: sheet-in .2s ease; }
@keyframes sheet-in { from { transform: translateX(20px); opacity: .5; } }
.modal-sheet > header { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 22px; border-bottom: 1px solid var(--line-soft); background: rgba(8, 20, 26, .94); backdrop-filter: blur(18px); }
.modal-sheet h2 { margin: 4px 0 0; font-size: 20px; }
.modal-sheet > header button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); font-size: 20px; }
.modal-content { padding: 18px 22px 38px; }
.detail-hero { padding: 20px; border: 1px solid var(--line-soft); border-radius: 17px; background: linear-gradient(145deg, var(--surface-2), var(--surface)); }
.detail-hero h3 { margin: 0; font-size: 22px; }
.detail-hero p { margin: 6px 0 0; color: var(--muted); }
.detail-section { margin-top: 20px; }
.detail-section h4 { margin: 0 0 9px; color: var(--muted); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.detail-list { overflow: hidden; border: 1px solid var(--line-soft); border-radius: 15px; background: var(--surface); }
.detail-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; min-height: 52px; padding: 14px; border-bottom: 1px solid var(--line-soft); }
.detail-row:last-child { border-bottom: 0; }
.detail-row span { color: var(--muted); }
.detail-row strong { max-width: 62%; overflow-wrap: anywhere; text-align: right; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 100; min-width: 240px; max-width: 360px; padding: 14px 16px; border: 1px solid rgba(91, 213, 106, .25); border-radius: 13px; background: #153025; color: var(--text); box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translateY(8px); transition: .18s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-color: rgba(255, 98, 109, .3); background: #351a20; }
.loading-block:empty { position: relative; min-height: 140px; }
.loading-block:empty::after { content: "Загрузка…"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.mobile-nav { display: none; }

.auth-body { display: grid; min-height: 100vh; place-items: center; padding: 24px; }
.auth-card { width: min(440px, 100%); padding: 30px; border: 1px solid var(--line); border-radius: 24px; background: rgba(16, 33, 42, .94); box-shadow: var(--shadow); }
.auth-card-wide { width: min(620px, 100%); }
.auth-security-mark { display: inline-flex; margin-top: 26px; padding: 7px 10px; border-radius: 9px; color: var(--green); background: var(--green-soft); font-size: 10px; font-weight: 900; letter-spacing: .04em; text-transform: uppercase; }
.auth-card h1 { margin: 20px 0 0; font-size: 28px; letter-spacing: -.04em; }
.auth-lead { margin: 8px 0 0; color: var(--muted); line-height: 1.55; }
.auth-form { display: grid; gap: 16px; margin-top: 24px; }
.auth-form label { display: grid; gap: 7px; color: #d9e5ea; font-size: 12px; font-weight: 800; }
.auth-form input { width: 100%; height: 48px; padding: 0 14px; border: 1px solid var(--line); border-radius: 13px; outline: 0; background: var(--bg); color: var(--text); }
.auth-form input:focus { border-color: var(--green); box-shadow: 0 0 0 4px rgba(91, 213, 106, .08); }
.otp-input { font-size: 24px !important; font-weight: 900; letter-spacing: .28em; text-align: center; }
.password-rules, .auth-footnote { color: var(--muted); font-size: 10px; line-height: 1.5; }
.auth-footnote { margin: 18px 0 0; text-align: center; }
.form-error, .form-success { margin-top: 16px; padding: 12px 14px; border-radius: 11px; font-size: 12px; line-height: 1.45; }
.form-error { color: #ffb6bc; background: var(--red-soft); border: 1px solid rgba(255, 98, 109, .2); }
.form-success { color: #bff7c5; background: var(--green-soft); border: 1px solid rgba(91, 213, 106, .2); }
.auth-back { display: block; margin-top: 18px; color: var(--muted); text-align: center; text-decoration: none; }
.totp-setup { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 18px; align-items: center; margin-top: 22px; }
.totp-qr { width: 180px; height: 180px; padding: 6px; border-radius: 18px; background: white; }
.totp-secret-block { display: grid; gap: 8px; min-width: 0; }
.totp-secret-block span, .totp-secret-block small { color: var(--muted); font-size: 11px; line-height: 1.45; }
.totp-secret-block code { overflow-wrap: anywhere; padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--bg); color: var(--green); font-size: 13px; line-height: 1.45; }

@media (max-width: 1120px) {
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .rates-grid { grid-template-columns: repeat(2, minmax(250px, 1fr)); }
}
@media (max-width: 840px) {
    body { padding-bottom: 74px; }
    .sidebar { display: none; }
    .workspace { margin-left: 0; padding: 20px 14px 32px; }
    .topbar { margin-bottom: 20px; }
    .system-indicator { display: none; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .rates-grid { grid-template-columns: 1fr; }
    .mobile-nav { position: fixed; inset: auto 0 0; z-index: 50; display: grid; grid-template-columns: repeat(4, 1fr); min-height: 68px; padding: 7px max(7px, env(safe-area-inset-right)) max(7px, env(safe-area-inset-bottom)) max(7px, env(safe-area-inset-left)); border-top: 1px solid var(--line-soft); background: rgba(8, 20, 26, .96); backdrop-filter: blur(20px); }
    .mobile-nav button { display: grid; place-items: center; gap: 2px; border: 0; border-radius: 12px; background: transparent; color: var(--muted); font-size: 10px; font-weight: 800; }
    .mobile-nav button span { font-size: 18px; }
    .mobile-nav button.active { color: var(--green); background: var(--green-soft); }
}
@media (max-width: 560px) {
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
    .stat-card { min-height: 126px; padding: 15px; border-radius: 16px; }
    .stat-card strong { margin-top: 17px; font-size: 21px; }
    .stat-card span:last-child { font-size: 10px; }
    .panel-heading { padding: 17px 15px; }
    .compact-transaction { padding: 13px 15px; }
    .toolbar { align-items: stretch; }
    .toolbar-wrap > * { flex: 1 1 calc(50% - 5px); }
    .toolbar-wrap .search-field { flex-basis: 100%; }
    select, .secondary-button { width: 100%; }
    th, td { padding-left: 13px; padding-right: 13px; }
    .auth-body { padding: 14px; }
    .auth-card { padding: 22px 18px; border-radius: 20px; }
    .totp-setup { grid-template-columns: 1fr; justify-items: center; }
    .totp-secret-block { width: 100%; }
    .toast { right: 14px; bottom: 82px; left: 14px; min-width: 0; }
}
