:root {
    --ink: #17313d;
    --muted: #506875;
    --line: #dce6e9;
    --surface: #fff;
    --bg: #f3f7f7;
    --green: #0b8061;
    --green-pale: #e5f5ee;
    --amber: #a96c0d;
    --amber-pale: #fff2d9;
    --nav: #102b35;
    --focus: #087e69;
    --shadow: 0 8px 30px rgba(18, 49, 58, .055);
}

html { scroll-padding-top: 24px; }
body { font-size: 15px; line-height: 1.55; }
button, input, select, textarea { font-size: inherit; }
button:disabled { cursor: not-allowed; }
input, select, textarea { outline: revert; }
:where(a, button, input, select, textarea):focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 3px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline-offset: 1px;
    box-shadow: 0 0 0 4px rgba(8, 126, 105, .14);
}
.icon { width: 20px; height: 20px; flex: none; }
.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; }
.skip-link { position: fixed; left: 16px; top: -80px; z-index: 100; background: var(--surface); color: var(--ink); border: 2px solid var(--focus); border-radius: 10px; padding: 10px 16px; font-weight: 700; }
.skip-link:focus { top: 12px; }

.sidebar { width: 254px; padding: 28px 15px 20px; background: var(--nav); }
.brand { gap: 12px; padding: 0 10px 38px; min-height: 44px; }
.brand strong { font-size: 16px; }
.brand small { font-size: 10px; color: #a5d5c7; }
.brand-mark { width: 40px; height: 40px; box-shadow: none; background: #168d70; }
.sidebar-label { color: #a7bcc3; font-size: 11px; }
.nav-list { gap: 6px; }
.nav-item { min-height: 46px; gap: 12px; color: #c7d6da; font-size: 14px; }
.nav-item .icon { width: 19px; height: 19px; }
.nav-item:hover, .nav-item.active { background: #244653; color: #fff; }
.nav-item.active { box-shadow: inset 3px 0 #63d2a6; }
.sidebar :where(a, button):focus-visible { outline-color: #a9f0d0; }
.sidebar-bottom { border-color: #35515c; }
.sidebar-user strong { font-size: 13px; }
.sidebar-user small { font-size: 12px; color: #bacdd2; }
.logout-button { display: inline-flex; align-items: center; gap: 9px; min-height: 44px; margin-top: 8px; padding: 8px 10px 8px 45px; color: #d4e1e3; font-size: 13px; border-radius: 8px; }
.logout-button .icon { width: 17px; height: 17px; }
.logout-button:hover { background: #244653; }

.topbar { min-height: 88px; height: auto; padding: 19px 32px; }
.topbar h1 { font-size: 25px; margin-top: 3px; }
.topbar-right { font-size: 13px; color: var(--muted); }
.page-content { max-width: 1480px; padding: 32px; }
.page-heading { margin-bottom: 24px; gap: 18px; }
.section-kicker, .eyebrow { display: block; color: #447566; font-size: 11px; font-weight: 800; letter-spacing: .12em; }
.page-heading h2 { font-size: clamp(22px, 2vw, 27px); margin: 3px 0 5px; }
.page-heading p { max-width: 650px; color: var(--muted); font-size: 14px; }
.button { min-height: 44px; padding: 10px 17px; font-size: 13px; border-radius: 10px; transition: background .16s, box-shadow .16s, color .16s; }
.button:hover { transform: none; }
.button:active { box-shadow: inset 0 2px 5px rgba(0, 0, 0, .1); }
.button.primary { background: #087e60; box-shadow: 0 6px 14px rgba(8, 126, 96, .12); }
.button.primary:hover { background: #056b52; }
.button.secondary { color: #244c59; border-color: #cbdadd; }
.button.secondary:hover { background: #edf5f3; }
.button .icon { width: 17px; height: 17px; }
.button:disabled { opacity: .55; box-shadow: none; }

.metric-grid { gap: 16px; margin-bottom: 20px; }
.metric-card { min-width: 0; min-height: 190px; padding: 22px; border-color: var(--line); box-shadow: var(--shadow); }
a.metric-card:focus-visible { outline-offset: 3px; }
.metric-card:hover { box-shadow: 0 10px 26px rgba(18, 49, 58, .09); }
.metric-card.static-card:hover { transform: none; box-shadow: var(--shadow); }
.metric-icon { width: 42px; height: 42px; margin-bottom: 15px; }
.metric-icon .icon { width: 22px; height: 22px; }
.metric-icon.amber { color: var(--amber); }
.metric-icon.slate { color: #546b77; }
.metric-label { color: var(--muted); font-size: 13px; }
.metric-value { font-size: clamp(29px, 2.8vw, 36px); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.metric-value.money { font-size: clamp(25px, 2.3vw, 32px); }
.metric-note { color: var(--muted); font-size: 12px; }
.metric-action { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; color: #087e60; font-size: 12px; font-weight: 800; }
.metric-action .icon { width: 15px; height: 15px; }

.content-grid { grid-template-columns: minmax(0, 1.28fr) minmax(0, 1fr); }
.content-grid > * { min-width: 0; }
.panel { border-color: var(--line); padding: 24px; box-shadow: var(--shadow); }
.panel-heading { align-items: center; margin-bottom: 20px; }
.panel-heading > div { min-width: 0; }
.panel-heading h3 { font-size: 18px; }
.text-link { display: inline-flex; align-items: center; gap: 5px; min-height: 44px; color: #087e60; font-size: 13px; white-space: nowrap; }
.text-link .icon { width: 15px; height: 15px; }
.panel-hint { color: var(--muted); font-size: 12px; text-align: right; }
.sales-summary span, .sales-summary small { color: var(--muted); font-size: 12px; }
.sales-summary strong { font-size: clamp(19px, 2.1vw, 26px); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.chart-heading { color: var(--muted); font-size: 12px; margin-bottom: 12px; }
.bar-list { gap: 10px; }
.bar-row { grid-template-columns: 48px minmax(0, 1fr) minmax(90px, max-content); gap: 12px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.bar-row strong { color: var(--ink); font-size: 12px; }
.bar-track { height: 9px; background: #e9f0f0; }
.bar-track > div { background: #0e9973; }
.integration-row { padding: 14px 0; }
.integration-icon { width: 39px; height: 39px; color: #126c68; background: #e8f2f2; }
.integration-icon .icon { width: 20px; height: 20px; }
.integration-row strong { font-size: 14px; }
.integration-row small { color: var(--muted); font-size: 12px; }
.chip { padding: 6px 10px; font-size: 11px; }
.chip.good { color: #116341; }
.chip.muted { color: #526472; }
.sync-highlight { background: #eef6f4; padding: 16px; overflow-wrap: anywhere; }
.sync-highlight.is-error { background: #fff1ee; }
.sync-highlight span, .sync-highlight small { color: var(--muted); font-size: 12px; }
.sync-highlight strong { font-size: 14px; font-variant-numeric: tabular-nums; }
.sync-highlight.is-error strong { color: #9a3d36; }
.run-row { gap: 12px; padding: 15px 0; }
.run-row > div { min-width: 0; }
.run-row strong { font-size: 13px; }
.run-row small, .run-row time { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.run-row time { white-space: nowrap; }

.table-toolbar { align-items: end; margin-bottom: 18px; }
.toolbar-field { display: grid; gap: 7px; }
.toolbar-field.search-field { flex: 1; max-width: 380px; }
.toolbar-field label { color: #354f5d; font-size: 12px; font-weight: 800; }
.search-wrap { max-width: none; }
.search-wrap .icon { position: absolute; left: 14px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); color: #516b77; }
.search-wrap input { padding-left: 43px !important; }
.table-toolbar input, .table-toolbar select { min-height: 44px; height: 44px; border-color: #cbdadd; color: var(--ink); font-size: 14px; }
.table-toolbar select { min-width: 180px; }
.data-table { min-width: 650px; }
.data-table th { color: #48606b; font-size: 11px; background: #f4f8f8; }
.data-table td { color: #405a67; font-size: 13px; padding: 15px 13px; overflow-wrap: anywhere; }
.data-table td strong { color: var(--ink); }
.data-table tbody tr:hover { background: #f5faf8; }
.data-table .primary-cell { font-weight: 700; }
.code-link { color: #145d67; font-size: 14px; }
.row-arrow { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 9px; color: #116d60; }
.row-arrow:hover { background: #e6f4ee; }
.row-arrow .icon { width: 17px; height: 17px; }
.status-pill { font-size: 11px; padding: 6px 10px; }
.status-pill.active { color: #126d45; }
.status-pill.used { color: #855607; }
.status-pill.expired { color: #405360; }
.pagination-wrap { color: var(--muted); font-size: 13px; }
.pagination-wrap .page-control { min-height: 44px; min-width: 44px; display: inline-flex; align-items: center; justify-content: center; }
.empty-state { color: var(--muted); font-size: 14px; }
.sales-table td:nth-child(2), .sales-table th:nth-child(2), .sales-table .money-cell, .sales-table th:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.money-cell strong { font-variant-numeric: tabular-nums; }
.segmented { border: 1px solid #d4e1e1; background: #ecf2f1; }
.segmented a { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 16px; color: #395868; font-size: 13px; }
.segmented a.selected { color: #0a6d55; }
.info-note { display: flex; align-items: flex-start; gap: 10px; color: #315e5d; font-size: 13px; line-height: 1.55; }
.info-note .icon { width: 18px; height: 18px; margin-top: 1px; }

.settings-grid { align-items: start; }
.settings-heading { gap: 15px; }
.settings-heading h3 { font-size: 19px; }
.settings-heading p { color: var(--muted); font-size: 13px; line-height: 1.55; }
.settings-icon { width: 43px; height: 43px; }
.settings-icon .icon { width: 22px; height: 22px; }
.settings-form { gap: 18px; }
.field-grid { gap: 15px; }
.field label, .stack-form label { color: #334e5c; font-size: 13px; margin-bottom: 7px; }
.field input, .field textarea, .field select, .stack-form input { min-height: 44px; border-color: #cbdadd; color: var(--ink); font-size: 14px; padding: 10px 13px; }
.field textarea { min-height: 80px; }
.field small, .poll-hint { color: var(--muted); font-size: 12px; line-height: 1.5; }
.telegram-poll-controls .chip { white-space: normal; overflow-wrap: anywhere; }
.field input::placeholder, .field textarea::placeholder, .stack-form input::placeholder { color: #6b7f89; }
.check-row { min-height: 44px; color: var(--ink); font-size: 13px; }
.check-row input { width: 17px; height: 17px; }
.form-warning { color: #815212; background: #fff7e8; font-size: 12px; }
.notice { color: var(--ink); font-size: 14px; line-height: 1.5; }
.notice.error { color: #8c302b; }
.notice.success { color: #185e42; }

.back-link { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; color: #0b755c; font-size: 13px; }
.back-link .icon { width: 17px; height: 17px; }
.voucher-detail { max-width: 900px; }
.voucher-top h2 { overflow-wrap: anywhere; }
.voucher-top p { color: var(--muted); }
.detail-item span { color: var(--muted); font-size: 12px; }
.detail-item strong { color: var(--ink); }
.voucher-source { color: var(--muted); font-size: 12px; }

.login-body { background: var(--bg); }
.login-intro { background: linear-gradient(145deg, #102c36, #155246); }
.login-intro p { color: #c8e1df; font-size: 15px; }
.login-card > p { color: var(--muted); font-size: 14px; }
.login-kicker { color: #0c8061; font-size: 11px; }
.stack-form input { font-size: 15px; }
.login-foot { color: var(--muted) !important; font-size: 12px !important; }

@media (max-width: 1100px) {
    .content-grid, .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 780px) {
    .sidebar { display: grid; width: 100%; height: auto; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; padding: 13px 16px; }
    .brand { grid-column: 1; grid-row: 1; padding: 0; margin: 0; }
    .sidebar-bottom { display: block; grid-column: 2; grid-row: 1; margin: 0; padding: 0; border: 0; }
    .sidebar-user { display: none; }
    .logout-button { margin: 0; padding: 8px 10px; min-height: 44px; }
    .nav-list { grid-column: 1 / -1; grid-row: 2; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; overflow: visible; }
    .nav-item { justify-content: center; gap: 7px; padding: 9px 5px; min-height: 44px; font-size: 13px; white-space: nowrap; }
    .nav-item .icon { display: block; width: 17px; height: 17px; }
    .nav-item.active { box-shadow: inset 0 -3px #63d2a6; }
    .topbar { min-height: 75px; padding: 15px 20px; }
    .topbar h1 { font-size: 22px; }
    .page-content { padding: 24px 20px; }
    .metric-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .metric-card { min-height: 180px; }
    .panel { padding: 22px; }
    .login-scene { grid-template-columns: 1fr; }
    .login-intro { min-height: 30vh; }
    .login-panel { min-height: 70vh; }
}

@media (max-width: 620px) {
    .page-heading { flex-direction: column; align-items: stretch; }
    .page-heading form, .page-heading .button { width: 100%; }
    .metric-grid.three, .metric-grid.two { grid-template-columns: 1fr; }
    .metric-card { min-height: 142px; display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 2px 12px; align-items: center; padding: 17px; }
    .metric-icon { grid-row: 1 / span 3; margin: 0; }
    .metric-label { grid-column: 2; grid-row: 1; }
    .metric-value { grid-column: 2 / 4; grid-row: 2; margin: 0; font-size: 29px; }
    .metric-value.money { font-size: 26px; }
    .metric-note { grid-column: 2 / 4; grid-row: 3; }
    .metric-action { grid-column: 2 / 4; grid-row: 4; margin: 4px 0 0; }
    .panel-heading { gap: 10px; flex-wrap: wrap; }
    .panel-hint { text-align: left; }
    .table-scroll { overflow: visible; }
    .data-table, .data-table thead, .data-table tbody { display: block; min-width: 0; width: 100%; }
    .data-table thead { display: none; }
    .data-table tbody tr:not(.empty-row) { display: block; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; background: #fff; }
    .data-table tbody tr:not(.empty-row):hover { background: #fff; }
    .data-table td { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; width: 100%; padding: 9px 0; border-bottom: 1px solid #eaf0f0; font-size: 14px; text-align: right !important; }
    .data-table td::before { content: attr(data-label); flex: 0 0 38%; color: var(--muted); font-size: 12px; font-weight: 700; text-align: left; }
    .data-table .primary-cell { align-items: center; }
    .data-table .primary-cell .code-link { font-size: 16px; }
    .data-table .action-cell { border: 0; justify-content: flex-end; padding-bottom: 0; }
    .data-table .action-cell::before { content: none; }
    .data-table .empty-row, .data-table .empty-row td { display: block; width: 100%; text-align: center !important; }
    .data-table .empty-row td::before { content: none; }
    .table-toolbar { flex-direction: column; align-items: stretch; }
    .toolbar-field.search-field, .table-toolbar select { width: 100%; max-width: none; }
    .sales-table td:nth-child(2), .sales-table .money-cell { text-align: right; }
    .bar-row { grid-template-columns: 43px minmax(0, 1fr) minmax(80px, max-content); gap: 8px; }
    .bar-row strong { font-size: 11px; }
}

@media (max-width: 540px) {
    .sidebar { padding: 12px; }
    .brand strong { font-size: 14px; }
    .brand small { font-size: 9px; }
    .brand-mark { width: 36px; height: 36px; font-size: 20px; }
    .logout-button { font-size: 12px; }
    .logout-button .icon { width: 16px; height: 16px; }
    .nav-item { font-size: 12px; gap: 5px; }
    .nav-item .icon { width: 15px; height: 15px; }
    .topbar { padding: 14px 16px; }
    .page-content { padding: 20px 14px; }
    .panel { padding: 18px; }
    .sales-summary { gap: 12px; }
    .sales-summary > div + div { padding-left: 13px; }
    .sales-summary strong { font-size: 19px; }
    .settings-heading { gap: 11px; }
    .field-grid { grid-template-columns: 1fr; }
    .voucher-top { flex-direction: column; gap: 12px; }
    .detail-grid { grid-template-columns: 1fr; }
    .login-intro { min-height: 31vh; padding: 30px 24px; }
    .login-intro .brand-mark { margin-bottom: 12px; }
    .login-intro h1 { margin: 12px 0; }
    .login-panel { min-height: 69vh; padding: 26px 20px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
