:root {
    --navy: #0f1d3a;
    --navy-2: #172554;
    --blue: #2563eb;
    --blue-dark: #1d4ed8;
    --blue-soft: #eff6ff;
    --green: #059669;
    --green-soft: #ecfdf5;
    --amber: #d97706;
    --amber-soft: #fffbeb;
    --red: #dc2626;
    --red-soft: #fef2f2;
    --ink: #172033;
    --muted: #64748b;
    --line: #e3e9f2;
    --canvas: #f4f7fb;
    --white: #ffffff;
    --radius: 14px;
    --shadow: 0 8px 30px rgba(15, 29, 58, .06);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--canvas); font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 14px; line-height: 1.5; }
a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-dark); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 25px; line-height: 1.2; letter-spacing: -.03em; }
h2 { margin-bottom: 4px; font-size: 18px; letter-spacing: -.02em; }
h3 { margin-bottom: 5px; font-size: 16px; }
.muted { color: var(--muted); }
.eyebrow { display: block; margin-bottom: 4px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }

.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; display: flex; width: 260px; flex-direction: column; color: #dbe7ff; background: linear-gradient(180deg, #0c1730 0%, #111e3e 100%); box-shadow: 8px 0 30px rgba(15, 29, 58, .08); }
.brand { display: flex; min-height: 88px; align-items: center; gap: 12px; padding: 20px 22px; color: #fff; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand:hover { color: #fff; }
.brand-mark { display: inline-grid; width: 40px; height: 40px; flex: 0 0 40px; place-items: center; color: #fff; background: linear-gradient(145deg, #60a5fa, #2563eb); border-radius: 12px; box-shadow: 0 8px 20px rgba(37, 99, 235, .35); font-size: 19px; font-weight: 900; }
.brand strong { display: block; max-width: 160px; overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.brand small { display: block; margin-top: 2px; color: #91a4c9; font-size: 11px; }
.nav-menu { display: flex; flex: 1; flex-direction: column; gap: 5px; padding: 22px 14px; }
.nav-menu a { display: flex; align-items: center; gap: 12px; padding: 11px 13px; color: #9fb1d3; border: 1px solid transparent; border-radius: 10px; font-weight: 650; transition: .18s ease; }
.nav-menu a span { display: inline-grid; width: 22px; height: 22px; place-items: center; font-size: 18px; }
.nav-menu a:hover { color: #fff; background: rgba(255,255,255,.055); }
.nav-menu a.active { color: #fff; background: rgba(59, 130, 246, .16); border-color: rgba(96,165,250,.17); box-shadow: inset 3px 0 #60a5fa; }
.sidebar-user { display: flex; align-items: center; gap: 10px; margin: 14px; padding: 12px; background: rgba(255,255,255,.055); border: 1px solid rgba(255,255,255,.08); border-radius: 12px; }
.avatar { display: inline-grid; width: 38px; height: 38px; flex: 0 0 38px; place-items: center; color: #1d4ed8; background: #dbeafe; border-radius: 50%; font-weight: 900; }
.avatar.small { width: 34px; height: 34px; flex-basis: 34px; }
.avatar.large { width: 54px; height: 54px; flex-basis: 54px; font-size: 20px; }
.user-copy { min-width: 0; flex: 1; }
.user-copy strong, .user-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-copy strong { color: #f8fbff; font-size: 12px; }
.user-copy small { color: #93a5c7; font-size: 10px; }
.sidebar-user form { margin: 0; }
.icon-button { padding: 4px; color: #9fb1d3; background: transparent; border: 0; cursor: pointer; font-size: 20px; }
.icon-button:hover { color: #fff; }

.app-shell { min-height: 100vh; margin-left: 260px; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; min-height: 88px; align-items: center; gap: 18px; padding: 16px 32px; background: rgba(255,255,255,.93); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); }
.topbar > div { flex: 1; }
.topbar .eyebrow { margin-bottom: 2px; }
.top-user { max-width: 280px; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.menu-toggle { display: none; width: 40px; height: 40px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.main-content { width: 100%; max-width: 1540px; margin: 0 auto; padding: 28px 32px 48px; }

.page-actions { display: flex; min-height: 42px; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.page-actions p { margin: 0; }
.actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.actions.compact { justify-content: flex-end; flex-wrap: nowrap; }
.btn { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; gap: 8px; padding: 8px 15px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; font-weight: 750; line-height: 1; transition: .17s ease; }
.btn:hover { color: var(--ink); border-color: #cbd5e1; transform: translateY(-1px); }
.btn-primary { color: #fff; background: var(--blue); border-color: var(--blue); box-shadow: 0 5px 14px rgba(37,99,235,.18); }
.btn-primary:hover { color: #fff; background: var(--blue-dark); border-color: var(--blue-dark); }
.btn-secondary { color: #1e3a8a; background: #fff; border-color: #c9d5e8; }
.btn-ghost { color: var(--muted); background: transparent; border-color: transparent; }
.btn-ghost:hover { color: var(--ink); background: #e9eef6; border-color: transparent; }
.btn-success { color: #fff; background: var(--green); border-color: var(--green); }
.btn-danger-outline { color: var(--red); background: #fff; border-color: #fecaca; }
.btn-sm { min-height: 32px; padding: 6px 10px; border-radius: 8px; font-size: 12px; }
.btn-block { width: 100%; }
.btn:disabled { cursor: not-allowed; opacity: .55; transform: none; }

.card { margin-bottom: 22px; padding: 22px; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin: -2px 0 19px; padding-bottom: 16px; border-bottom: 1px solid #edf1f6; }
.card-header h2 { margin: 0; }
.card-header > a { font-size: 12px; font-weight: 750; }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card { position: relative; display: flex; min-height: 112px; align-items: center; gap: 15px; padding: 20px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow); overflow: hidden; transition: .18s ease; }
a.stat-card:hover { color: var(--ink); transform: translateY(-2px); box-shadow: 0 13px 34px rgba(15,29,58,.09); }
.stat-card::after { position: absolute; width: 80px; height: 80px; right: -32px; bottom: -40px; content: ''; border-radius: 50%; opacity: .12; }
.stat-card.blue::after { background: var(--blue); }
.stat-card.green::after { background: var(--green); }
.stat-card.amber::after { background: var(--amber); }
.stat-card.red::after { background: var(--red); }
.stat-icon { display: inline-grid; width: 46px; height: 46px; flex: 0 0 46px; place-items: center; border-radius: 12px; font-size: 20px; font-style: normal; }
.blue .stat-icon { color: var(--blue); background: var(--blue-soft); }
.green .stat-icon { color: var(--green); background: var(--green-soft); }
.amber .stat-icon { color: var(--amber); background: var(--amber-soft); }
.red .stat-icon { color: var(--red); background: var(--red-soft); }
.stat-card small, .stat-card strong { display: block; }
.stat-card small { color: var(--muted); font-size: 12px; font-weight: 650; }
.stat-card strong { margin-top: 2px; font-size: 27px; line-height: 1.15; }
.stat-card i { margin-left: auto; color: #9aa8ba; font-style: normal; }
.dashboard-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 22px; }
.dashboard-grid .span-2 { grid-column: auto; }

.table-wrap { width: calc(100% + 2px); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 10px 12px; color: #718096; background: #f8fafc; border-bottom: 1px solid var(--line); font-size: 10px; font-weight: 850; letter-spacing: .08em; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { padding: 13px 12px; border-bottom: 1px solid #edf1f6; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfdff; }
td strong, td small { display: block; }
td small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.align-right { text-align: right; }
.table-link { color: var(--ink); font-weight: 750; }
.selection-col { width: 42px; text-align: center; }
.selection-col input[type="checkbox"] { width: 16px; min-height: 16px; margin: 0; cursor: pointer; }
.selection-col input[type="checkbox"]:disabled { cursor: not-allowed; opacity: .45; }
.identity { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.identity span:last-child { min-width: 0; }
.identity strong, .identity small { display: block; }

.badge { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 999px; font-size: 10px; font-weight: 850; letter-spacing: .02em; white-space: nowrap; }
.badge-success { color: #047857; background: #d1fae5; }
.badge-warning { color: #b45309; background: #fef3c7; }
.badge-danger { color: #b91c1c; background: #fee2e2; }
.badge-neutral { color: #475569; background: #e9eef5; }

.empty-state { display: flex; min-height: 250px; align-items: center; justify-content: center; flex-direction: column; padding: 35px; text-align: center; }
.empty-state > span { display: grid; width: 52px; height: 52px; margin-bottom: 12px; place-items: center; color: var(--blue); background: var(--blue-soft); border-radius: 50%; font-size: 24px; }
.empty-state h3 { margin: 0 0 5px; }
.empty-state p { max-width: 420px; margin-bottom: 15px; color: var(--muted); }
.empty-compact { padding: 25px 10px; color: var(--muted); text-align: center; }
.activity-list { display: flex; flex-direction: column; }
.activity-item { position: relative; display: flex; gap: 11px; padding: 10px 0; }
.activity-item + .activity-item { border-top: 1px solid #edf1f6; }
.activity-dot { width: 8px; height: 8px; flex: 0 0 8px; margin-top: 6px; background: #60a5fa; border: 2px solid #dbeafe; border-radius: 50%; box-sizing: content-box; }
.activity-item strong, .activity-item small { display: block; }
.activity-item strong { font-size: 12px; text-transform: capitalize; }
.activity-item small { margin-top: 2px; color: var(--muted); font-size: 10px; }

.search-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.search-form input[type="search"], .search-form input[type="email"] { width: min(370px, 70vw); }
input, select, textarea { width: 100%; color: var(--ink); background: #fff; border: 1px solid #ccd6e4; border-radius: 9px; outline: 0; transition: .15s ease; }
input, select { min-height: 42px; padding: 9px 11px; }
textarea { min-height: 96px; padding: 10px 11px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #a0adbf; }
input:focus, select:focus, textarea:focus { border-color: #60a5fa; box-shadow: 0 0 0 3px rgba(59,130,246,.12); }
label { display: block; color: #344154; font-size: 12px; font-weight: 750; }
label > span { color: var(--red); }
label small { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; font-weight: 500; }
label input, label select, label textarea { margin-top: 6px; }
.stack-form { display: flex; flex-direction: column; gap: 16px; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px; }
.field-grid .span-2 { grid-column: span 2; }
.form-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(270px, 1fr); gap: 22px; }
.form-grid > .span-2 { grid-column: auto; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 2px; padding: 14px 0 28px; }
.info-box { margin: 16px 0; padding: 14px; color: #40506a; background: #f7f9fc; border: 1px solid #e7ecf3; border-radius: 10px; }
.info-box strong { display: block; margin-bottom: 3px; font-size: 12px; }
.info-box p { margin: 0; color: var(--muted); font-size: 11px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin: 17px 0; }
.switch-row strong, .switch-row small { display: block; }
.switch-row input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.switch-row i { position: relative; width: 44px; height: 24px; flex: 0 0 44px; background: #cbd5e1; border-radius: 999px; cursor: pointer; transition: .18s ease; }
.switch-row i::after { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; content: ''; background: #fff; border-radius: 50%; box-shadow: 0 1px 4px rgba(15,23,42,.25); transition: .18s ease; }
.switch-row input:checked + i { background: var(--blue); }
.switch-row input:checked + i::after { transform: translateX(20px); }
.check-line { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.check-line input { width: 16px; min-height: 16px; margin: 0; }
.smtp-fields { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 17px; padding: 17px; background: #f8fafc; border: 1px solid #e8edf4; border-radius: 11px; }
.smtp-fields.hidden { display: none; }
.settings-grid { display: grid; grid-template-columns: 1fr 2fr; gap: 22px; }
.settings-grid > .span-2 { grid-column: auto; }
.telegram-settings-card { grid-column: 1 / -1; }
.setup-hint { padding: 13px 15px; color: #40506a; background: #f7f9fc; border: 1px solid #e2e8f0; border-radius: 10px; font-size: 11px; line-height: 1.65; }
.setup-hint a { font-weight: 800; }
.setup-hint code { padding: 2px 5px; color: #1e3a8a; background: #e8eefc; border-radius: 5px; }
.setup-hint small { display: block; margin-top: 4px; color: var(--muted); }
.diagnostic-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.test-email-card { display: flex; align-items: center; justify-content: space-between; gap: 22px; }
.test-email-card p { margin-bottom: 0; }
.telegram-test-card { display: flex; align-items: center; justify-content: space-between; gap: 22px; }
.telegram-test-card p { margin-bottom: 0; }
.narrow-card { max-width: 650px; margin-right: auto; margin-left: auto; }
.profile-identity { margin-bottom: 20px; padding: 14px; background: #f8fafc; border-radius: 11px; }

.profile-card { display: flex; align-items: center; gap: 25px; }
.profile-main { display: flex; min-width: 310px; align-items: center; gap: 14px; }
.profile-main h2, .profile-main p { margin: 0; }
.profile-main p { margin-top: 4px; color: var(--muted); font-size: 12px; }
.heading-line { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.profile-meta { display: grid; flex: 1; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 15px; padding-left: 25px; border-left: 1px solid var(--line); }
.profile-meta small, .profile-meta strong { display: block; }
.profile-meta small { color: var(--muted); font-size: 10px; }
.profile-meta strong { margin-top: 2px; font-size: 12px; }
.note-bar { margin-bottom: 22px; padding: 13px 16px; color: #6b4b08; background: var(--amber-soft); border: 1px solid #fde68a; border-radius: 10px; font-size: 12px; }
.telegram-alert-card { margin-bottom: 22px; border-color: #bfdbfe; }
.telegram-alert-content { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.telegram-alert-content p { max-width: 760px; margin: 0; color: var(--muted); font-size: 12px; }
.telegram-alert-meta { display: flex; gap: 18px; margin-top: 12px; color: var(--muted); font-size: 11px; flex-wrap: wrap; }
.telegram-alert-meta strong { color: var(--ink); }
.manual-alert-card td:last-child small { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.manual-alert-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 18px -22px -22px; padding: 16px 22px; background: #f8fafc; border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); }
.manual-alert-toolbar .muted strong { color: var(--ink); }
.report-filter-card { padding: 17px 20px; }
.report-filter { display: grid; grid-template-columns: minmax(160px, 1.1fr) minmax(190px, 1.25fr) minmax(190px, 1.25fr) minmax(110px, .75fr) auto; align-items: end; gap: 13px; }
.report-filter .field.hidden { display: none; }
.report-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin: 2px 0 17px; }
.report-heading h2 { margin: 0; font-size: 24px; }
.report-heading p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.report-generated { color: var(--muted); font-size: 11px; white-space: nowrap; }
.finance-stat-grid .stat-card em { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; font-style: normal; font-weight: 600; }
.finance-stat-grid .stat-card strong { font-size: 24px; }
.report-definition { margin: 0 0 22px; padding: 13px 16px; color: #40506a; background: #f8fafc; border: 1px solid #dde5ef; border-radius: 10px; font-size: 11px; }
.finance-legend { display: flex; align-items: center; gap: 15px; color: var(--muted); font-size: 10px; font-weight: 750; }
.finance-legend span::before { display: inline-block; width: 9px; height: 9px; margin-right: 5px; content: ''; border-radius: 3px; }
.finance-legend .received::before { background: var(--green); }
.finance-legend .expected::before { background: var(--amber); }
.finance-timeline { display: flex; flex-direction: column; gap: 4px; }
.finance-timeline-row { display: grid; grid-template-columns: 62px minmax(0, 1fr); gap: 6px 14px; padding: 11px 10px; border-bottom: 1px solid #edf1f6; }
.finance-timeline-row:last-child { border-bottom: 0; }
.finance-period-label { grid-row: 1 / span 2; align-self: center; color: #344154; font-size: 12px; }
.finance-series { display: grid; grid-template-columns: 68px minmax(120px, 1fr) 105px 105px; align-items: center; gap: 10px; }
.finance-series > span { color: var(--muted); font-size: 10px; font-weight: 700; }
.finance-series b { font-size: 11px; text-align: right; white-space: nowrap; }
.finance-series small { color: var(--muted); font-size: 9px; white-space: nowrap; }
.finance-series progress { width: 100%; height: 9px; border: 0; border-radius: 999px; appearance: none; overflow: hidden; }
.finance-series progress::-webkit-progress-bar { background: #edf1f6; border-radius: 999px; }
.finance-series progress.received::-webkit-progress-value { background: var(--green); border-radius: 999px; }
.finance-series progress.expected::-webkit-progress-value { background: var(--amber); border-radius: 999px; }
.finance-series progress.received::-moz-progress-bar { background: var(--green); border-radius: 999px; }
.finance-series progress.expected::-moz-progress-bar { background: var(--amber); border-radius: 999px; }
.finance-breakdown-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.finance-breakdown-grid .card { min-width: 0; }
.report-empty { min-height: 190px; }
.finance-detail-card td { font-size: 12px; }
.print-only { display: none; }
.service-cards { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.service-card { padding: 18px; background: #fbfdff; border: 1px solid #dfe7f1; border-radius: 12px; }
.service-top { display: flex; gap: 12px; }
.service-icon { display: inline-grid; width: 40px; height: 40px; flex: 0 0 40px; place-items: center; color: var(--blue); background: var(--blue-soft); border-radius: 10px; font-size: 19px; }
.service-top h3 { margin-top: 7px; }
.service-top p { margin: 0; color: var(--muted); font-size: 11px; }
.service-card dl { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 8px; margin: 18px 0; padding: 13px 0; border-top: 1px solid #e7edf4; border-bottom: 1px solid #e7edf4; }
.service-card dt, .service-card dd { margin: 0; }
.service-card dt { color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.service-card dd { margin-top: 3px; font-size: 11px; font-weight: 750; }
.service-actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.inline-form { display: flex; flex: 1; align-items: center; justify-content: flex-end; gap: 6px; }
.inline-form select { width: auto; min-height: 32px; padding: 5px 26px 5px 8px; font-size: 11px; }
.renew-grid { display: grid; max-width: 1050px; margin: 0 auto; grid-template-columns: 1fr 1fr; gap: 22px; }
.detail-list { margin: 0; }
.detail-list > div { display: flex; align-items: baseline; justify-content: space-between; gap: 18px; padding: 11px 0; border-bottom: 1px solid #edf1f6; }
.detail-list > div:last-child { border-bottom: 0; }
.detail-list dt, .detail-list dd { margin: 0; }
.detail-list dt { color: var(--muted); font-size: 11px; }
.detail-list dd { max-width: 65%; font-size: 12px; font-weight: 700; text-align: right; word-break: break-word; }

.alert { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; padding: 12px 14px; border: 1px solid; border-radius: 10px; font-size: 12px; }
.alert button { margin: -3px -2px 0 auto; color: inherit; background: transparent; border: 0; cursor: pointer; font-size: 20px; line-height: 1; opacity: .65; }
.alert ul { margin: 5px 0 0; padding-left: 20px; }
.alert-success { color: #05603f; background: var(--green-soft); border-color: #a7f3d0; }
.alert-warning { color: #7c4a03; background: var(--amber-soft); border-color: #fde68a; }
.alert-danger { color: #991b1b; background: var(--red-soft); border-color: #fecaca; }
.json-detail, .error-detail { max-width: 300px; }
.json-detail code, .error-detail { display: block; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 20px 0; color: var(--muted); font-size: 12px; }
.pagination a { padding: 7px 11px; background: #fff; border: 1px solid var(--line); border-radius: 8px; font-weight: 700; }

.template-tabs { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; margin-bottom: 22px; }
.template-tab { display: flex; min-height: 58px; align-items: center; gap: 10px; padding: 11px 14px; color: var(--muted); background: #fff; border: 1px solid var(--line); border-radius: 11px; box-shadow: 0 3px 12px rgba(15,29,58,.03); }
.template-tab span { display: inline-grid; width: 32px; height: 32px; place-items: center; color: #475569; background: #eef2f7; border-radius: 9px; font-size: 16px; font-weight: 900; }
.template-tab strong { font-size: 12px; }
.template-tab:hover { color: var(--blue); border-color: #bfdbfe; transform: translateY(-1px); }
.template-tab.active { color: #1d4ed8; background: #eff6ff; border-color: #93c5fd; box-shadow: 0 6px 18px rgba(37,99,235,.09); }
.template-tab.active span { color: #fff; background: var(--blue); }
.template-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(360px, .85fr); gap: 22px; align-items: start; }
.template-editor-card { min-width: 0; }
.template-info { margin-top: 0; }
.template-body-field { display: block; margin-top: 18px; }
.template-body-field textarea { min-height: 390px; line-height: 1.55; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.placeholder-section { margin-top: 20px; padding-top: 18px; border-top: 1px solid #edf1f6; }
.placeholder-section > div:first-child strong, .placeholder-section > div:first-child small { display: block; }
.placeholder-section > div:first-child strong { font-size: 12px; }
.placeholder-section > div:first-child small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.placeholder-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 7px; margin-top: 12px; }
.placeholder-chip { display: flex; min-width: 0; align-items: center; gap: 8px; padding: 8px 9px; color: #334155; background: #f8fafc; border: 1px solid #e1e8f1; border-radius: 8px; cursor: pointer; text-align: left; transition: .15s ease; }
.placeholder-chip:hover { color: #1d4ed8; background: #eff6ff; border-color: #bfdbfe; }
.placeholder-chip code { flex: 0 0 auto; color: #1d4ed8; font-size: 10px; font-weight: 800; }
.placeholder-chip span { min-width: 0; overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.template-save-actions { margin-bottom: -8px; }
.template-preview-card { position: sticky; top: 110px; }
.live-indicator { display: inline-flex; align-items: center; gap: 6px; color: #047857; font-size: 9px; font-weight: 800; text-transform: uppercase; }
.live-indicator i { width: 7px; height: 7px; background: #10b981; border-radius: 50%; box-shadow: 0 0 0 4px #d1fae5; }
.preview-envelope { overflow: hidden; background: #eef2f7; border: 1px solid #dfe6ef; border-radius: 11px; }
.preview-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 13px 15px; background: #fff; border-bottom: 1px solid #dfe6ef; }
.preview-meta small, .preview-meta strong { display: block; }
.preview-meta small, .preview-subject small { color: var(--muted); font-size: 8px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.preview-meta strong { overflow: hidden; margin-top: 2px; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.preview-subject { padding: 12px 15px; background: #fff; border-bottom: 1px solid #dfe6ef; }
.preview-subject strong { display: block; margin-top: 3px; font-size: 11px; line-height: 1.4; }
.preview-message { margin: 14px; background: #fff; border: 1px solid #dfe6ef; border-radius: 9px; overflow: hidden; }
.preview-brand { padding: 15px 18px; color: #fff; background: var(--navy-2); font-size: 12px; font-weight: 850; }
.preview-copy { min-height: 300px; padding: 19px 18px; color: #273449; font-size: 10px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.preview-footer { margin: 0 18px; padding: 13px 0 16px; color: #94a3b8; border-top: 1px solid #e5e7eb; font-size: 8px; }
.preview-note { margin: 12px 2px 0; color: var(--muted); font-size: 9px; }
.template-tools { display: flex; align-items: center; justify-content: space-between; gap: 22px; }
.template-tools p { margin: 0; }
.template-tool-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.template-tool-actions form { margin: 0; }

.welcome-banner { position: relative; display: flex; min-height: 180px; align-items: center; justify-content: space-between; gap: 30px; margin-bottom: 22px; padding: 32px 36px; color: #fff; background: linear-gradient(125deg, #142856 0%, #1d4ed8 100%); border-radius: 16px; box-shadow: 0 16px 35px rgba(29,78,216,.16); overflow: hidden; }
.welcome-banner::before, .welcome-banner::after { position: absolute; content: ''; border: 1px solid rgba(255,255,255,.12); border-radius: 50%; }
.welcome-banner::before { width: 230px; height: 230px; right: -60px; top: -105px; }
.welcome-banner::after { width: 160px; height: 160px; right: 60px; bottom: -125px; }
.welcome-banner > div { position: relative; z-index: 1; }
.welcome-banner .eyebrow { color: #bfdbfe; }
.welcome-banner h2 { max-width: 620px; margin: 5px 0 8px; font-size: 27px; }
.welcome-banner p { max-width: 620px; margin: 0; color: #dbeafe; }
.welcome-mark { display: grid; width: 78px; height: 78px; flex: 0 0 78px; place-items: center; color: #fff; background: rgba(255,255,255,.13); border: 1px solid rgba(255,255,255,.2); border-radius: 22px; font-size: 35px; font-weight: 900; backdrop-filter: blur(5px); }
.client-stats { grid-template-columns: repeat(3, minmax(0,1fr)); }
.client-service-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; }
.client-service-card { position: relative; padding: 20px; background: #fff; border: 1px solid var(--line); border-radius: 13px; box-shadow: 0 4px 18px rgba(15,29,58,.04); }
.client-service-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; }
.client-service-card h3 { margin: 4px 0 3px; font-size: 18px; }
.domain-name { margin-bottom: 16px; color: var(--blue); font-size: 12px; font-weight: 700; }
.client-service-card dl { margin: 0; }
.client-service-card dl > div { display: flex; justify-content: space-between; gap: 15px; padding: 9px 0; border-bottom: 1px solid #edf1f6; }
.client-service-card dt, .client-service-card dd { margin: 0; font-size: 11px; }
.client-service-card dt { color: var(--muted); }
.client-service-card dd { font-weight: 750; text-align: right; }
.client-service-card .expiry-row { margin-top: 4px; padding: 12px; background: #f8fafc; border: 0; border-radius: 8px; }
.renew-warning { margin-top: 14px; padding: 10px 11px; color: #92400e; background: var(--amber-soft); border: 1px solid #fde68a; border-radius: 8px; font-size: 10px; font-weight: 650; }
.client-bottom-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.renewal-list > div { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid #edf1f6; }
.renewal-list > div:last-child { border: 0; }
.renewal-list strong, .renewal-list small { display: block; }
.renewal-list small { color: var(--muted); font-size: 10px; }
.renewal-date { color: var(--green); font-size: 12px; font-weight: 800; }

.auth-page { background: #eef3fa; }
.auth-shell { display: grid; min-height: 100vh; place-items: center; padding: 28px; }
.login-panel { display: grid; width: min(1040px, 100%); min-height: 620px; grid-template-columns: 1.08fr .92fr; background: #fff; border: 1px solid #dce5f0; border-radius: 22px; box-shadow: 0 28px 70px rgba(15,29,58,.13); overflow: hidden; }
.login-visual { position: relative; display: flex; flex-direction: column; justify-content: space-between; padding: 42px; color: #fff; background: linear-gradient(140deg, #0e1a36 0%, #172f67 58%, #1d4ed8 100%); overflow: hidden; }
.login-visual::before, .login-visual::after, .visual-orb { position: absolute; content: ''; border-radius: 50%; }
.login-visual::before { width: 360px; height: 360px; right: -170px; top: -170px; border: 1px solid rgba(255,255,255,.12); }
.login-visual::after { width: 270px; height: 270px; left: -170px; bottom: -150px; background: rgba(37,99,235,.18); }
.visual-orb { width: 180px; height: 180px; right: 30px; bottom: 110px; background: radial-gradient(circle at 35% 30%, rgba(147,197,253,.38), rgba(37,99,235,.05) 65%); filter: blur(2px); }
.login-brand { position: relative; z-index: 2; display: flex; align-items: center; gap: 12px; font-weight: 800; }
.visual-copy { position: relative; z-index: 2; max-width: 430px; }
.visual-copy .pill { display: inline-block; margin-bottom: 18px; padding: 6px 10px; color: #bfdbfe; background: rgba(255,255,255,.09); border: 1px solid rgba(255,255,255,.12); border-radius: 999px; font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.visual-copy h2 { margin-bottom: 15px; font-size: 36px; line-height: 1.12; letter-spacing: -.04em; }
.visual-copy p { max-width: 380px; color: #c9d9f5; font-size: 15px; }
.visual-card { position: relative; z-index: 2; display: flex; width: fit-content; align-items: center; gap: 11px; padding: 12px 15px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12); border-radius: 12px; backdrop-filter: blur(8px); }
.visual-card > span { display: grid; width: 27px; height: 27px; place-items: center; color: #a7f3d0; background: rgba(16,185,129,.15); border-radius: 50%; }
.visual-card strong, .visual-card small { display: block; }
.visual-card strong { font-size: 11px; }
.visual-card small { color: #9eb1d3; font-size: 9px; }
.login-form-wrap { display: grid; place-items: center; padding: 48px; }
.login-form { width: 100%; max-width: 340px; }
.login-form h1 { margin: 3px 0 8px; font-size: 30px; }
.login-form > .muted { margin-bottom: 25px; }
.login-help { margin: 25px 0 0; color: var(--muted); font-size: 10px; text-align: center; }

@media (max-width: 1180px) {
    .stat-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .client-service-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .settings-grid { grid-template-columns: 1fr; }
    .diagnostic-grid { grid-template-columns: 1fr; }
    .report-filter { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .report-filter .btn { align-self: end; }
    .profile-card { align-items: flex-start; flex-wrap: wrap; }
    .profile-meta { min-width: 55%; padding-left: 0; border-left: 0; }
    .template-layout { grid-template-columns: 1fr; }
    .template-preview-card { position: static; }
}

@media (max-width: 900px) {
    .sidebar { transform: translateX(-102%); transition: transform .2s ease; }
    .sidebar.open { transform: translateX(0); }
    .app-shell { margin-left: 0; }
    .menu-toggle { display: inline-grid; place-items: center; }
    .main-content { padding: 22px 20px 40px; }
    .topbar { padding: 14px 20px; }
    .dashboard-grid, .form-grid, .renew-grid, .client-bottom-grid { grid-template-columns: 1fr; }
    .finance-breakdown-grid { grid-template-columns: 1fr; }
    .service-cards { grid-template-columns: 1fr; }
    .login-panel { max-width: 540px; min-height: auto; grid-template-columns: 1fr; }
    .login-visual { min-height: 300px; padding: 30px; }
    .visual-copy h2 { font-size: 28px; }
    .visual-card { display: none; }
    .login-form-wrap { padding: 42px 35px; }
}

@media (max-width: 650px) {
    h1 { font-size: 21px; }
    .top-user { display: none; }
    .main-content { padding: 18px 13px 35px; }
    .page-actions { align-items: stretch; flex-direction: column; }
    .page-actions > .actions, .page-actions > .btn { width: 100%; }
    .page-actions > .actions .btn { flex: 1; }
    .manual-alert-toolbar { align-items: stretch; flex-direction: column; }
    .manual-alert-toolbar .btn { width: 100%; }
    .telegram-alert-content { align-items: stretch; flex-direction: column; }
    .telegram-alert-content .btn { width: 100%; }
    .report-filter { grid-template-columns: 1fr; }
    .report-filter .btn { width: 100%; }
    .report-heading { align-items: flex-start; flex-direction: column; }
    .finance-timeline-row { grid-template-columns: 48px minmax(0, 1fr); gap: 7px; padding-right: 0; padding-left: 0; }
    .finance-series { grid-template-columns: 58px minmax(70px, 1fr) auto; gap: 7px; }
    .finance-series small { display: none; }
    .finance-series b { font-size: 10px; }
    .search-form { width: 100%; }
    .search-form input[type="search"], .search-form input[type="email"], .search-form select { width: 100%; }
    .stat-grid, .client-stats, .client-service-grid { grid-template-columns: 1fr; }
    .stat-card { min-height: 92px; }
    .field-grid, .smtp-fields { grid-template-columns: 1fr; }
    .field-grid .span-2, .smtp-fields .span-2 { grid-column: auto; }
    .card { padding: 17px; border-radius: 12px; }
    .profile-main { min-width: 0; }
    .profile-meta { width: 100%; grid-template-columns: 1fr; }
    .profile-card > form { width: 100%; }
    .profile-card > form .btn { width: 100%; }
    .service-card dl { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .inline-form { width: 100%; justify-content: flex-start; }
    .test-email-card { align-items: stretch; flex-direction: column; }
    .telegram-test-card { align-items: stretch; flex-direction: column; }
    .telegram-test-card .btn { width: 100%; }
    .placeholder-grid { grid-template-columns: 1fr; }
    .template-tabs { grid-template-columns: 1fr; }
    .template-tools, .template-tool-actions { align-items: stretch; flex-direction: column; }
    .template-tool-actions, .template-tool-actions form, .template-tool-actions .search-form { width: 100%; }
    .template-tool-actions .btn { width: 100%; }
    .welcome-banner { padding: 26px 22px; }
    .welcome-banner h2 { font-size: 23px; }
    .welcome-mark { display: none; }
    .auth-shell { padding: 12px; }
    .login-visual { min-height: 250px; padding: 25px; }
    .visual-copy h2 { font-size: 24px; }
    .login-form-wrap { padding: 35px 25px; }
}

@media print {
    * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    body { color: #111827; background: #fff; }
    .sidebar, .topbar, .no-print { display: none !important; }
    .print-only { display: block; }
    .report-print-header { margin-bottom: 16px; padding-bottom: 12px; border-bottom: 2px solid #172033; }
    .report-print-header h1, .report-print-header p { margin: 0; }
    .report-print-header p { margin-top: 3px; color: #475569; font-size: 11px; }
    .app-shell { margin-left: 0; }
    .main-content { max-width: none; padding: 0; }
    .page-actions { min-height: 0; margin-bottom: 14px; }
    .card, .stat-card { box-shadow: none; break-inside: avoid; }
    .finance-detail-card { break-inside: auto; }
    .finance-detail-card tr { break-inside: avoid; }
    .report-heading { margin-top: 8px; }
    .report-definition { border-color: #cbd5e1; }
    a { color: inherit; }
}
