:root {
    color-scheme: light;
    --bg: #f6f5fb;
    --panel: #ffffff;
    --panel-soft: #faf9fd;
    --text: #24212f;
    --muted: #777283;
    --line: #e8e5ef;
    --primary: #6e4ad7;
    --primary-dark: #5734c2;
    --primary-soft: #eee8ff;
    --success: #16865d;
    --success-soft: #e4f6ee;
    --warning: #a45f0b;
    --warning-soft: #fff0d9;
    --danger: #bd3e55;
    --danger-soft: #fde8ed;
    font-family: Manrope, "Segoe UI", Arial, sans-serif;
}

.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; background: #251c3d; color: #fff; padding: 20px 16px; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 10px 24px; font-weight: 750; font-size: 17px; }
.role-brand { justify-content: flex-start; margin-bottom: 16px; padding: 2px 10px 18px; color: #a995d8; background: transparent; border-bottom: 1px solid rgba(255,255,255,.14); border-radius: 0; font-size: 13px; font-weight: 700; letter-spacing: .02em; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; background: #8261e8; font-size: 18px; }
.nav { display: grid; gap: 5px; }
.nav a { display: flex; align-items: center; gap: 11px; color: #cfc7e4; padding: 10px 12px; border-radius: 10px; }
.nav a:hover, .nav a.active { color: #fff; background: rgba(255,255,255,.11); }
.nav-icon { width: 18px; text-align: center; opacity: .95; }
.sidebar-footer { position: absolute; bottom: 20px; left: 16px; right: 16px; }
.logout { width: 100%; border: 0; color: #cfc7e4; text-align: left; padding: 10px 12px; border-radius: 10px; background: transparent; cursor: pointer; }
.logout:hover { color: #fff; background: rgba(255,255,255,.11); }

.main { min-width: 0; }
.content { width: 100%; max-width: 1500px; margin: 0 auto; padding: 28px 32px 40px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 20px; }
.page-head h1 { margin: 0; font-size: 27px; letter-spacing: -.02em; }
.page-head p { margin: 7px 0 0; color: var(--muted); }
.page-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.page-view-button.active { color: var(--primary-dark); background: var(--primary-soft); border-color: #d7ccf5; }
.page-view-button.active:hover { background: #e6dcff; }
.button-count { display: inline-grid; min-width: 22px; height: 22px; place-items: center; padding: 0 6px; color: inherit; background: rgba(110,74,215,.1); border-radius: 999px; font-size: 11px; }

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 15px; box-shadow: 0 8px 30px rgba(45,30,85,.035); }
.card-body { padding: 20px; }
.card-title { margin: 0 0 14px; font-size: 16px; }
.metric-label { color: var(--muted); font-size: 13px; }
.metric-value { margin-top: 9px; font-weight: 750; font-size: 28px; letter-spacing: -.03em; }
.metric-note { margin-top: 7px; color: var(--muted); font-size: 12px; }
.dashboard-page-head { padding: 4px 0; }
.dashboard-today { display: grid; min-width: 190px; gap: 4px; padding: 12px 15px; background: linear-gradient(135deg, var(--panel), var(--primary-soft)); border: 1px solid #ded5f7; border-radius: 12px; text-align: right; }
.dashboard-today span { color: var(--muted); font-size: 11px; font-weight: 650; }
.dashboard-today strong { font-size: 14px; }
.dashboard-metrics { margin-bottom: 0; }
.dashboard-metric { position: relative; display: grid; grid-template-columns: 46px minmax(0, 1fr); align-items: center; gap: 14px; min-height: 112px; padding: 18px 20px; background: linear-gradient(145deg, #fff 55%, #faf8ff); overflow: hidden; }
.dashboard-metric::after { content: ''; position: absolute; right: -22px; bottom: -36px; width: 100px; height: 100px; border-radius: 50%; background: currentColor; opacity: .045; }
.dashboard-metric-icon { display: grid; width: 46px; height: 46px; place-items: center; color: var(--primary); background: var(--primary-soft); border-radius: 14px; }
.dashboard-metric-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.dashboard-metric .metric-value { margin-top: 4px; }
.dashboard-metric .metric-note { margin-top: 3px; }
.dashboard-metric-actions .dashboard-metric-icon { color: var(--warning); background: var(--warning-soft); }
.dashboard-metric-npd .dashboard-metric-icon { color: var(--success); background: var(--success-soft); }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid transparent; border-radius: 10px; padding: 10px 14px; background: var(--primary); color: #fff; font-weight: 650; cursor: pointer; }
.button:hover { background: var(--primary-dark); }
.button.secondary { background: var(--panel); color: var(--text); border-color: var(--line); }
.button.secondary:hover { background: var(--panel-soft); }
.button.danger { background: var(--danger); }
.button.danger:hover { background: #a52f46; }
.button.secondary.danger { color: var(--danger); border-color: #f0c8d1; background: var(--panel); }
.button.secondary.danger:hover { background: var(--danger-soft); }
.button.small { padding: 7px 10px; border-radius: 8px; font-size: 13px; }

.table-wrap { overflow-x: auto; }
.sticky-table-wrap { overflow: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.sticky-table-wrap table.data thead th { position: sticky; z-index: 6; top: 0; box-shadow: inset 0 -1px 0 var(--line); }
.page-main-table { max-height: calc(100vh - 168px); }
.dashboard-plan-table { max-height: 420px; }
.document-table-scroll { max-height: calc(100vh - 330px); }
.document-history-table { max-height: 360px; margin-top: 20px; }
.service-table-scroll { max-height: min(64vh, 720px); }
.activity-log-table-wrap { max-height: calc(100vh - 315px); }
table.data { width: 100%; border-collapse: collapse; }
table.data th { padding: 12px 16px; text-align: left; color: var(--muted); background: var(--panel-soft); font-size: 12px; font-weight: 650; border-bottom: 1px solid var(--line); }
table.data td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: #fcfbfe; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.strong { font-weight: 700; }

.status { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 5px 9px; font-size: 12px; font-weight: 650; white-space: nowrap; }
.status.success { color: var(--success); background: var(--success-soft); }
.status.warning { color: var(--warning); background: var(--warning-soft); }
.status.danger { color: var(--danger); background: var(--danger-soft); }
.status.neutral { color: #625c6e; background: #efedf3; }
.contractor-contract-warning { margin-top: 5px; }

.tabs { display: flex; align-items: center; gap: 6px; margin-bottom: 20px; }
.tabs a { display: inline-flex; align-items: center; gap: 7px; padding: 8px 11px; color: var(--muted); border-radius: 9px; font-weight: 650; }
.tabs a:hover { color: var(--text); background: var(--panel); }
.tabs a.active { color: var(--primary); background: var(--primary-soft); }
.tabs a span { display: inline-grid; min-width: 22px; height: 22px; place-items: center; padding: 0 6px; border-radius: 999px; background: rgba(110,74,215,.1); font-size: 12px; }

.service-group { margin-bottom: 20px; }
.service-description { min-width: 310px; }
.service-contractors { max-width: 320px; white-space: normal; }
.service-actions { display: flex; justify-content: flex-end; gap: 7px; min-width: 126px; }

dialog.modal { width: min(760px, calc(100vw - 32px)); max-width: none; padding: 0; color: var(--text); background: transparent; border: 0; overflow: visible; }
dialog.modal::backdrop { background: rgba(24,18,39,.5); backdrop-filter: blur(2px); }
dialog.modal.modal-small { width: min(540px, calc(100vw - 32px)); }
dialog.modal.modal-wide { width: min(1040px, calc(100vw - 32px)); }
dialog.modal.modal-closure { width: min(900px, calc(100vw - 32px)); }
dialog.modal.modal-document-preview { width: min(1180px, calc(100vw - 32px)); }
.route-modal-open { overflow: hidden; }
.route-modal-overlay { position: fixed; z-index: 1000; inset: 0; display: grid; place-items: center; padding: 20px 16px; background: rgba(24,18,39,.5); backdrop-filter: blur(2px); }
.route-closure-modal { width: min(900px, calc(100vw - 32px)); }
.route-closure-modal form { display: contents; }
.modal-card { display: flex; flex-direction: column; max-height: calc(100vh - 40px); background: var(--panel); border: 1px solid var(--line); border-radius: 17px; box-shadow: 0 24px 80px rgba(35,25,62,.28); overflow: hidden; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 22px 24px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 21px; }
.modal-head p { margin: 6px 0 0; color: var(--muted); line-height: 1.45; }
.modal-close { display: grid; flex: 0 0 auto; width: 34px; height: 34px; place-items: center; padding: 0; color: var(--muted); background: var(--panel-soft); border: 1px solid var(--line); border-radius: 9px; font-size: 23px; line-height: 1; cursor: pointer; }
.modal-close:hover { color: var(--text); background: var(--primary-soft); }
.modal-body { min-height: 0; padding: 22px 24px; overflow-y: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; background: var(--panel-soft); border-top: 1px solid var(--line); }
.modal-tabs { display: flex; align-items: center; gap: 6px; margin: -4px 0 22px; padding-bottom: 12px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.modal-tabs button { display: inline-flex; align-items: center; gap: 7px; padding: 8px 11px; color: var(--muted); background: transparent; border: 0; border-radius: 9px; font-weight: 650; white-space: nowrap; cursor: pointer; }
.modal-tabs button:hover { color: var(--text); background: var(--panel-soft); }
.modal-tabs button.active { color: var(--primary); background: var(--primary-soft); }
.modal-tabs button span { display: inline-grid; min-width: 22px; height: 22px; place-items: center; padding: 0 6px; border-radius: 999px; background: rgba(110,74,215,.1); font-size: 12px; }
.modal-panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.modal-panel-head h3 { margin: 0; font-size: 18px; }
.modal-panel-head p { margin: 5px 0 0; color: var(--muted); }
.modal-callout { display: grid; gap: 6px; margin-bottom: 18px; padding: 14px; color: #5b487f; background: var(--primary-soft); border-radius: 11px; }
.modal-callout span { color: var(--muted); line-height: 1.5; }
.contractor-modal-meta { display: flex; justify-content: space-between; gap: 18px; margin: 14px 0 10px; color: var(--muted); font-size: 12px; }
.contractor-modal-meta span:first-child { flex: 0 0 auto; color: var(--primary); font-weight: 700; }
.contractor-choice-list { display: grid; max-height: 390px; border: 1px solid var(--line); border-radius: 11px; overflow-y: auto; }
.contractor-choice { display: flex; align-items: flex-start; gap: 10px; padding: 11px 13px; border-bottom: 1px solid var(--line); cursor: pointer; }
.contractor-choice:last-of-type { border-bottom: 0; }
.contractor-choice:hover { background: var(--panel-soft); }
.contractor-choice input { margin-top: 3px; accent-color: var(--primary); }
.contractor-choice span { display: grid; gap: 3px; }
.contractor-choice small { color: var(--muted); }
.delete-confirmation { display: grid; gap: 8px; padding: 14px; background: var(--danger-soft); border: 1px solid #f2c7d0; border-radius: 11px; }
.delete-confirmation strong { color: var(--danger); font-size: 16px; }
.delete-confirmation span { line-height: 1.45; }
.contractor-row-actions { display: flex; justify-content: flex-end; gap: 7px; flex-wrap: nowrap; }
.icon-action { position: relative; flex: 0 0 38px; width: 38px; height: 38px; padding: 0 !important; }
.icon-action svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-action::before, .icon-action::after { position: absolute; z-index: 40; top: 50%; visibility: hidden; pointer-events: none; opacity: 0; transition: opacity .15s ease, transform .15s ease, visibility .15s ease; }
.icon-action::before { content: ''; right: calc(100% + 3px); border: 5px solid transparent; border-left-color: #302a3b; transform: translate(4px, -50%); }
.icon-action::after { content: attr(data-tooltip); right: calc(100% + 13px); padding: 6px 9px; color: #fff; background: #302a3b; border-radius: 7px; box-shadow: 0 6px 18px rgba(35,25,62,.2); font-size: 12px; font-weight: 600; line-height: 1.2; white-space: nowrap; transform: translate(4px, -50%); }
.icon-action:hover::before, .icon-action:hover::after, .icon-action:focus-visible::before, .icon-action:focus-visible::after { visibility: visible; opacity: 1; transform: translate(0, -50%); }
.icon-action:focus-visible { outline: 2px solid #9b82e9; outline-offset: 2px; }
.npd-date { margin-top: 5px; font-size: 12px; }
.modal-summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.modal-summary-grid section { display: grid; gap: 6px; padding: 14px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel-soft); }
.modal-summary-grid span, .modal-summary-grid small { color: var(--muted); font-size: 12px; }
.modal-summary-grid strong { font-size: 16px; overflow-wrap: anywhere; }
.modal-section { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.modal-section.first { margin-top: 0; padding-top: 0; border-top: 0; }
.modal-section h3 { margin: 0 0 13px; font-size: 16px; }
.modal-section .section-head h3 { margin: 0; }
.compact-list { display: grid; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; }
.compact-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 13px; border-bottom: 1px solid var(--line); }
.compact-row:last-child { border-bottom: 0; }
.compact-row > span:first-child { min-width: 0; display: grid; gap: 3px; }
.compact-row small { color: var(--muted); }
.compact-row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 7px; flex-wrap: wrap; }
.compact-empty { padding: 28px 18px; color: var(--muted); text-align: center; }
.compact-error { color: var(--danger) !important; }
.service-permissions { display: grid; gap: 12px; }
.service-permissions-meta { display: flex; justify-content: space-between; gap: 16px; color: var(--muted); font-size: 12px; }
.service-permissions-meta span:first-child { flex: 0 0 auto; color: var(--primary); font-weight: 700; }
.matrix-create-form { align-items: center; flex-wrap: nowrap; gap: 10px; }
.matrix-month-filter { display: flex; flex: 0 0 220px; min-width: 220px; margin: 0; }
.matrix-month-filter .ui-select { width: 100%; }
.matrix-month-filter .ui-select-trigger { height: 42px; font-weight: 650; }
.matrix-action-form { display: flex; align-items: stretch; margin: 0; }
.matrix-action-button { min-width: 180px; height: 42px; min-height: 42px; padding: 10px 16px; white-space: nowrap; }
.matrix-refresh-button { background: #3c7f8b; }
.matrix-refresh-button:hover { background: #306d78; }
.matrix-period { margin-bottom: 20px; }
.matrix-period-head { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.matrix-period-head h2 { margin: 0; }
.matrix-period-totals { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; }
.matrix-period-totals span { display: grid; gap: 4px; min-width: 128px; padding: 10px 13px; border-left: 1px solid var(--line); background: var(--panel-soft); }
.matrix-period-totals span:first-child { border-left: 0; }
.matrix-period-totals small { color: var(--muted); font-size: 10px; font-weight: 650; }
.matrix-period-totals strong { font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.matrix-period-totals .paid strong { color: var(--success); }
.payout-matrix { min-width: 1040px; }
.matrix-screen { height: 100vh; overflow: hidden; }
.matrix-screen .shell { min-height: 0; height: 100vh; }
.matrix-screen .main { min-height: 0; overflow: hidden; }
.matrix-screen .content { display: flex; flex-direction: column; height: 100%; padding-bottom: 28px; overflow: hidden; }
.matrix-screen-content { display: flex; flex: 1 1 auto; min-height: 0; flex-direction: column; }
.matrix-screen-content > .page-head { flex: 0 0 auto; }
.matrix-screen-content > .matrix-period { display: flex; flex: 1 1 auto; min-height: 0; flex-direction: column; margin-bottom: 0; overflow: hidden; }
.matrix-period-head { flex: 0 0 auto; }
.matrix-table-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.matrix-table-scroll .payout-matrix thead th { position: sticky; z-index: 5; top: 0; box-shadow: inset 0 -1px 0 var(--line); }
.payout-matrix th:not(:first-child), .payout-matrix td:not(:first-child) { white-space: nowrap; }
.matrix-service-period { margin-top: 4px; font-size: 12px; }
.matrix-payout-cell { min-width: 145px; }
.matrix-payout-amount { margin: 4px 0 7px; font-weight: 700; }
.service-permission-group { border: 1px solid var(--line); border-radius: 11px; overflow: hidden; }
.service-permission-head { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; background: var(--panel-soft); cursor: pointer; }
.service-permission-head input, .service-permission-item input { margin-top: 3px; accent-color: var(--primary); }
.service-permission-head span, .service-permission-item span { display: grid; gap: 3px; }
.service-permission-head small, .service-permission-item small { color: var(--muted); font-weight: 400; line-height: 1.4; }
.service-permission-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: 290px; overflow-y: auto; }
.service-permission-item { display: flex; align-items: flex-start; gap: 9px; padding: 10px 13px; border-top: 1px solid var(--line); cursor: pointer; }
.service-permission-item:nth-child(odd) { border-right: 1px solid var(--line); }
.service-permission-item:hover { background: #fcfbfe; }
.button:disabled { cursor: not-allowed; opacity: .55; }

.settlement-toolbar { display: flex; justify-content: flex-end; gap: 9px; flex-wrap: wrap; }
#payment-plan { scroll-margin-top: 18px; }
.settlement-metric { font-size: 23px; }
.settlement-final-card { border-color: #dcd3f8; }
.settlement-final-card .section-head p, .payout-section-head p { margin: 5px 0 0; }
.final-amount-layout { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(280px, .7fr); gap: 20px; align-items: stretch; }
.final-amount-fields { align-content: start; }
.final-calculation { display: grid; align-content: center; gap: 11px; padding: 16px; border: 1px solid #d9cff7; border-radius: 12px; background: var(--primary-soft); }
.final-calculation > div { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.final-calculation span, .final-calculation small { color: var(--muted); }
.final-calculation strong { font-size: 16px; font-variant-numeric: tabular-nums; }
.final-calculation-result { padding-top: 11px; border-top: 1px solid #d2c5f5; }
.final-calculation-result strong { color: var(--primary-dark); font-size: 21px; }
.payout-inline-card { overflow: hidden; }
.payout-inline-table { min-width: 1060px; }
.payout-inline-table th, .payout-inline-table td { padding: 10px 12px; }
.payout-inline-table th:nth-child(1) { width: 116px; }
.payout-inline-table th:nth-child(2) { width: 158px; }
.payout-inline-table th:nth-child(3) { width: 150px; }
.payout-inline-table th:nth-child(4) { width: 200px; }
.payout-inline-table th:nth-child(5) { width: 122px; }
.payout-inline-table th:nth-child(6) { width: 168px; }
.payout-inline-table th:nth-child(7) { width: 164px; }
.payout-inline-row { scroll-margin-top: 18px; }
.payout-inline-row:target { background: var(--primary-soft); box-shadow: inset 3px 0 0 var(--primary); }
.payout-inline-row.is-paid { background: #fbfefd; }
.payout-name-cell strong, .payout-name-cell small, .payout-status-cell small, .payout-completion-cell small { display: block; }
.payout-name-cell small, .payout-status-cell small, .payout-completion-cell small, .payout-cell-note, .payout-action-hint { margin-top: 5px; color: var(--muted); font-size: 11px; line-height: 1.3; }
.payout-cell-value { font-variant-numeric: tabular-nums; white-space: nowrap; }
.payout-cell-input { width: 100%; min-height: 36px; padding: 7px 8px; color: var(--text); background: #fff; border: 1px solid #dcd8e7; border-radius: 8px; outline: none; }
.payout-cell-input:focus { border-color: #9b82e9; box-shadow: 0 0 0 3px rgba(110,74,215,.1); }
.payout-cell-input[readonly] { color: #5f596a; background: var(--panel-soft); cursor: default; }
.payout-money-cell { position: relative; }
.payout-money-cell input { padding-right: 28px; font-variant-numeric: tabular-nums; }
.payout-money-cell span { position: absolute; top: 50%; right: 10px; color: var(--muted); transform: translateY(-50%); pointer-events: none; }
.payout-act-number { font-weight: 650; white-space: nowrap; }
.payout-inline-actions { display: flex; gap: 6px; margin-top: 6px; }
.payout-cell-error { display: block; margin-top: 5px; color: var(--danger); font-size: 11px; }
.payout-row-actions form { margin: 0; }
.payout-row-actions form + form { margin-top: 6px; }
.payout-row-actions .button { width: 100%; white-space: nowrap; }
.payout-action-hint { display: block; text-align: center; }
.settlement-services > summary { display: flex; align-items: center; justify-content: space-between; }
.settlement-services > summary::after { content: 'Показать'; color: var(--muted); font-size: 12px; font-weight: 600; }
.settlement-services[open] > summary::after { content: 'Скрыть'; }
.settlement-services-content { margin-top: 18px; padding-top: 17px; border-top: 1px solid var(--line); }
.settlement-services-content .section-head { align-items: flex-start; }
.settlement-services-content .section-head p { margin: 0; }
dialog.modal.modal-act-preview { width: min(1120px, calc(100vw - 32px)); }
.act-preview-scroll { padding: 24px; background: #ecebf1; }
.act-preview-paper { width: min(900px, 100%); min-height: 700px; margin: 0 auto; background: #fff; box-shadow: 0 10px 32px rgba(25,20,35,.12); overflow: hidden; }
.act-preview-paper .act-document { min-width: 700px; }

.section { margin-top: 20px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.section-head h2 { margin: 0; font-size: 18px; }
.document-tabs { margin-bottom: 14px; }
.document-section { overflow: visible; }
.document-section-description { margin: 5px 0 0; }
.document-toolbar { display: flex; align-items: center; gap: 9px; margin-top: 18px; }
.document-search-shell { position: relative; flex: 1 1 360px; max-width: 520px; }
.document-search { position: relative; display: block; }
.document-search svg { position: absolute; top: 50%; left: 12px; width: 17px; height: 17px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; transform: translateY(-50%); pointer-events: none; }
.document-search input, .document-sort select { width: 100%; height: 40px; color: var(--text); background: #fff; border: 1px solid #dcd8e7; border-radius: 9px; outline: none; }
.document-search input { padding: 9px 12px 9px 38px; }
.document-search input:focus, .document-sort select:focus { border-color: #9b82e9; box-shadow: 0 0 0 3px rgba(110,74,215,.1); }
.document-search-suggestions { position: absolute; z-index: 50; top: calc(100% + 6px); left: 0; right: 0; padding: 5px; background: var(--panel); border: 1px solid var(--line); border-radius: 11px; box-shadow: 0 14px 38px rgba(45,30,85,.18); }
.document-search-suggestions button { display: flex; align-items: center; justify-content: space-between; gap: 14px; width: 100%; padding: 9px 10px; color: var(--text); text-align: left; background: transparent; border: 0; border-radius: 7px; cursor: pointer; }
.document-search-suggestions button:hover, .document-search-suggestions button.active { background: var(--primary-soft); }
.document-search-suggestions strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.document-search-suggestions small { flex: 0 0 auto; max-width: 48%; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.document-sort { display: flex; align-items: center; gap: 8px; margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.document-sort select { min-width: 190px; padding: 8px 32px 8px 10px; font-size: 13px; }
.document-reset { color: var(--primary); font-size: 13px; font-weight: 650; }
.document-reset:hover { color: var(--primary-dark); }
.activity-log-card { overflow: hidden; }
.activity-log-toolbar { display: grid; grid-template-columns: minmax(250px, 1.5fr) 150px minmax(190px, .9fr) 165px auto; align-items: end; gap: 12px; }
.activity-filter-field { display: grid; min-width: 0; gap: 6px; }
.activity-filter-field > span { color: var(--muted); font-size: 11px; font-weight: 700; }
.activity-filter-field input, .activity-filter-field select { width: 100%; height: 40px; padding: 8px 11px; color: var(--text); background: #fff; border: 1px solid #dcd8e7; border-radius: 9px; outline: none; }
.activity-filter-field input:focus, .activity-filter-field select:focus { border-color: #9b82e9; box-shadow: 0 0 0 3px rgba(110,74,215,.1); }
.activity-log-search { max-width: none; }
.activity-search-shell { min-width: 0; max-width: none; }
.activity-log-search .document-search input { padding-left: 38px; }
.activity-filter-actions { display: flex; min-height: 40px; align-items: center; gap: 9px; white-space: nowrap; }
.table-navigation { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 16px; color: var(--muted); background: var(--panel-soft); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 12px; }
.table-navigation > div { display: flex; align-items: center; gap: 8px; }
.table-navigation-button { display: inline-flex; min-width: 34px; height: 32px; align-items: center; justify-content: center; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; font-weight: 750; }
.table-navigation-button:hover { color: var(--primary); border-color: #d4cbed; }
.table-navigation-button.disabled { color: #b7b2bf; background: #f5f3f8; cursor: default; }
.table-navigation-page { min-width: 92px; text-align: center; }
.activity-log-table { min-width: 1120px; }
.activity-log-table th:nth-child(1) { width: 120px; }
.activity-log-table th:nth-child(2) { width: 170px; }
.activity-log-table th:nth-child(3) { width: 250px; }
.activity-log-table th:nth-child(4) { width: 190px; }
.activity-log-date { font-variant-numeric: tabular-nums; }
.activity-log-date strong, .activity-log-date span { display: block; }
.activity-log-date span { margin-top: 3px; }
.activity-log-date span, .activity-log-source { font-size: 11px; }
.activity-change-list { display: grid; gap: 5px; }
.activity-change-list > div { display: grid; grid-template-columns: 145px minmax(0, 1fr); gap: 8px; font-size: 11px; line-height: 1.35; }
.activity-change-list strong { color: var(--muted); }
.activity-change-list span { overflow-wrap: anywhere; }
.activity-change-list del { color: var(--danger); text-decoration-thickness: 1px; }
.quick-filters { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.quick-filter { display: inline-flex; align-items: center; gap: 7px; padding: 7px 10px; color: var(--muted); background: var(--panel-soft); border: 1px solid var(--line); border-radius: 9px; font-size: 12px; font-weight: 650; }
.quick-filter:hover { color: var(--text); border-color: #d4cbed; }
.quick-filter.active { color: var(--primary-dark); background: var(--primary-soft); border-color: #d9cff7; }
.quick-filter span { display: inline-grid; min-width: 20px; height: 20px; place-items: center; padding: 0 5px; border-radius: 999px; color: inherit; background: rgba(110,74,215,.09); font-size: 11px; }
.document-row-state { margin-top: 5px; color: var(--muted); font-size: 11px; font-weight: 600; }
.document-row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.contractor-contract-warning { margin-top: 5px; }
.calendar-summary { margin: 5px 0 0; }
.payout-calendar-card { overflow: hidden; }
.payout-calendar-wrap { overflow-x: auto; border-top: 1px solid var(--line); }
.payout-calendar { display: grid; grid-template-columns: repeat(7, minmax(82px, 1fr)); min-width: 574px; gap: 1px; background: var(--line); }
.payout-calendar-weekday { padding: 7px 8px; color: var(--muted); background: var(--panel-soft); text-align: center; font-size: 11px; font-weight: 700; }
.payout-calendar-day { min-height: 78px; padding: 8px; background: var(--panel); }
.payout-calendar-day.outside { background: #fbfafc; }
.payout-calendar-day.has-payout.tuesday { background: #f4f0ff; }
.payout-calendar-day.has-payout.friday { background: #eef8f4; }
.payout-calendar-day.has-payout.partly-completed { background: #fff7e9; }
.payout-calendar-day.has-payout.completed { background: var(--success-soft); }
.payout-calendar-day.today { box-shadow: inset 0 0 0 2px var(--primary); }
.payout-calendar-date { display: flex; align-items: baseline; gap: 5px; color: var(--muted); font-weight: 700; }
.payout-calendar-day.has-payout .payout-calendar-date { color: var(--text); }
.payout-calendar-date small { color: var(--muted); font-size: 10px; font-weight: 650; }
.payout-calendar-count { margin-top: 7px; color: var(--muted); font-size: 10px; }
.payout-calendar-day.completed .payout-calendar-count { color: var(--success); font-weight: 750; }
.payout-calendar-amount { margin-top: 2px; font-size: 13px; font-weight: 750; font-variant-numeric: tabular-nums; white-space: nowrap; }
.payout-calendar-paid { margin-top: 2px; color: var(--success); font-size: 9px; font-weight: 650; }
.calendar-carryover { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 12px 16px; background: var(--panel-soft); border-top: 1px solid var(--line); }
.calendar-carryover-head { display: grid; flex: 0 0 auto; gap: 3px; }
.calendar-carryover-head strong { font-size: 12px; }
.calendar-carryover-head small { color: var(--muted); font-size: 10px; }
.calendar-carryover-list { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.calendar-carryover-day { display: flex; align-items: center; gap: 11px; min-width: 168px; padding: 8px 11px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.calendar-carryover-day.completed { background: var(--success-soft); border-color: rgba(22,134,93,.18); }
.calendar-carryover-day.partly-completed { background: #fff7e9; }
.calendar-carryover-date { padding-right: 10px; color: var(--primary); border-right: 1px solid var(--line); font-size: 13px; font-weight: 750; white-space: nowrap; }
.calendar-carryover-day > div:last-child { display: grid; gap: 2px; }
.calendar-carryover-day > div:last-child strong { font-size: 12px; white-space: nowrap; }
.calendar-carryover-day > div:last-child small { color: var(--muted); font-size: 9px; }
.list { display: grid; }
.list-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 20px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.contract-expiry-row { grid-template-columns: minmax(0, 1fr) auto; }
.contract-expiry-main { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 20px; min-width: 0; }
.payout-row-main { min-width: 0; }
.quick-paid { display: flex; justify-content: flex-end; gap: 7px; margin-top: 8px; }
.quick-paid input { width: 132px; border: 1px solid #dcd8e7; background: #fff; border-radius: 8px; padding: 6px 8px; color: var(--text); font-size: 12px; }
.list-title { font-weight: 650; }
.list-subtitle { margin-top: 4px; color: var(--muted); font-size: 12px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field { display: grid; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label { font-weight: 650; font-size: 13px; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid #dcd8e7; background: #fff; border-radius: 9px; padding: 10px 11px; color: var(--text); outline: none; }
.field input[readonly] { color: #5f596a; background: var(--panel-soft); cursor: default; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: #9b82e9; box-shadow: 0 0 0 3px rgba(110,74,215,.1); }
.contract-renewal-source { margin: 16px 0 0; }

.ui-select { position: relative; min-width: 0; width: 100%; font-family: Manrope, "Segoe UI", Arial, sans-serif; }
.ui-select-native { position: absolute !important; width: 1px !important; height: 1px !important; margin: 0 !important; padding: 0 !important; opacity: 0 !important; pointer-events: none !important; }
.ui-select-trigger { display: flex; width: 100%; min-height: 40px; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 11px; color: var(--text); background: linear-gradient(180deg, #fff 0%, #fcfbff 100%); border: 1px solid #dcd6ea; border-radius: 9px; box-shadow: 0 1px 2px rgba(45,30,85,.04); font-family: inherit; font-size: 13px; font-weight: 600; line-height: 20px; text-align: left; cursor: pointer; transition: border-color .15s ease, box-shadow .15s ease, background .15s ease; }
.ui-select-trigger:hover { border-color: #c5b9e6; background: #fff; }
.ui-select-trigger:focus-visible, .ui-select.open .ui-select-trigger { border-color: #8c70df; box-shadow: 0 0 0 3px rgba(110,74,215,.12); outline: none; }
.ui-select-trigger:disabled { color: #aaa5b2; background: #f4f2f7; cursor: not-allowed; }
.ui-select-value { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-select-icon { display: grid; flex: 0 0 18px; width: 18px; height: 18px; place-items: center; color: var(--primary); pointer-events: none; transition: transform .15s ease; }
.ui-select.open .ui-select-icon { transform: rotate(180deg); }
.ui-select-icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ui-select-options { position: fixed; z-index: 10000; display: grid; padding: 6px; background: var(--panel); border: 1px solid #dcd6ea; border-radius: 11px; box-shadow: 0 16px 42px rgba(45,30,85,.2); overflow-y: auto; overscroll-behavior: contain; font-family: Manrope, "Segoe UI", Arial, sans-serif; }
.ui-select-option { width: 100%; padding: 9px 10px; color: var(--text); background: transparent; border: 0; border-radius: 7px; font-family: inherit; font-size: 13px; font-weight: 500; line-height: 20px; text-align: left; cursor: pointer; }
.ui-select-option:hover, .ui-select-option:focus-visible, .ui-select-option.active { color: var(--primary-dark); background: var(--primary-soft); outline: none; }
.ui-select-option[aria-selected="true"] { color: var(--primary-dark); background: var(--primary-soft); font-weight: 700; }
.ui-select-option:disabled { color: #aaa5b2; cursor: default; }
.document-sort .ui-select { min-width: 190px; }
.activity-filter-field .ui-select-trigger { height: 40px; }
.field .ui-select-trigger { min-height: 42px; padding: 10px 11px; font-size: 14px; font-weight: 500; }
.field.needs-attention label { color: var(--danger); }
.field.needs-attention input, .field.needs-attention textarea { border-color: #df8798; background: #fff8fa; box-shadow: 0 0 0 3px rgba(189,62,85,.08); }
.field.needs-attention::after { content: 'Проверьте или заполните вручную'; color: var(--danger); font-size: 11px; }
.field textarea { min-height: 90px; resize: vertical; }
.field-hint { color: var(--muted); font-size: 12px; }
.foreign-contractor-option { grid-column: 1 / -1; }
.foreign-contractor-option > label { display: grid; grid-template-columns: 18px minmax(0, 1fr); align-items: start; gap: 10px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel-soft); cursor: pointer; }
.foreign-contractor-option input[type="checkbox"] { width: 18px; height: 18px; margin: 1px 0 0; padding: 0; accent-color: var(--primary); }
.foreign-contractor-option span { display: block; min-width: 0; }
.foreign-contractor-option strong { display: block; font-size: 13px; line-height: 18px; }
.foreign-contractor-option small { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; font-weight: 400; line-height: 17px; }
.auto-service-fields { display: grid; grid-column: 1 / -1; grid-template-columns: minmax(180px, .55fr) minmax(0, 1.45fr); gap: 16px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.inline-form { display: flex; align-items: end; gap: 12px; }
.inline-form .field { min-width: 180px; }
.checks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 18px; max-height: 360px; overflow: auto; padding: 4px; }
.check { display: flex; gap: 8px; align-items: flex-start; padding: 7px; border-radius: 8px; }
.check:hover { background: var(--panel-soft); }
.check input { margin-top: 3px; }
.check small { display: block; color: var(--muted); margin-top: 2px; }

.alert { margin-bottom: 18px; border-radius: 10px; padding: 12px 14px; }
.alert.success { background: var(--success-soft); color: var(--success); }
.alert.warning { background: var(--warning-soft); color: var(--warning); }
.alert.danger { background: var(--danger-soft); color: var(--danger); }
.empty { padding: 32px 20px; text-align: center; color: var(--muted); }
.formula { padding: 14px; border-radius: 10px; color: #5b487f; background: var(--primary-soft); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.pill-list { display: flex; flex-wrap: wrap; gap: 7px; }
.pill { padding: 6px 9px; border-radius: 8px; background: var(--panel-soft); border: 1px solid var(--line); font-size: 12px; }
.upload-zone { display: flex; align-items: center; gap: 14px; padding: 18px; border: 1px dashed #b8add8; border-radius: 12px; background: var(--primary-soft); }
.upload-zone input { max-width: 320px; }
.upload-zone div { display: grid; gap: 4px; }
.upload-zone span { color: var(--muted); font-size: 12px; }
.file-picker-button { position: relative; overflow: hidden; flex: 0 0 auto; }
.file-picker-button input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.file-queue { margin-top: 14px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.file-queue-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; background: var(--panel-soft); border-bottom: 1px solid var(--line); }
.file-queue-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.file-queue-row:last-child { border-bottom: 0; }
.file-queue-row > div { min-width: 0; display: grid; gap: 3px; }
.file-queue-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-queue-row span { color: var(--muted); font-size: 12px; }
.file-queue > .field-hint:not(:empty) { padding: 10px 14px; color: var(--danger); border-top: 1px solid var(--line); }
.details-list { display: grid; gap: 11px; }
.details-list > div { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px; align-items: start; }
.details-list span { color: var(--muted); font-size: 12px; }
.details-list strong { font-weight: 600; overflow-wrap: anywhere; }
.closure-calculation { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel-soft); }
.closure-calculation > div { display: grid; gap: 5px; }
.closure-calculation span { color: var(--muted); font-size: 12px; }
.closure-calculation strong { font-size: 16px; }
.closure-calculation .closure-result { padding-left: 12px; border-left: 2px solid var(--primary); }
.modal-closure .closure-calculation { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.closure-services { margin-top: 20px; padding-top: 16px; }
.closure-services[open] .pill-list { margin-top: 14px; }
.document-preview-body { padding: 0; background: #ecebf1; overflow: hidden; }
.document-preview-body iframe { display: block; width: 100%; height: min(74vh, 850px); border: 0; background: #fff; }
.workflow-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 18px; }
.workflow-step { display: flex; align-items: center; gap: 10px; padding: 12px 14px; color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: 11px; }
.workflow-step strong { display: grid; width: 26px; height: 26px; place-items: center; border-radius: 50%; background: var(--panel-soft); }
.workflow-step.active { color: var(--text); border-color: #cfc2f5; background: var(--primary-soft); }
.workflow-step.active strong { color: #fff; background: var(--primary); }
.readiness-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.readiness-grid > div { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 4px 10px; padding: 14px; border: 1px solid var(--line); border-radius: 11px; }
.readiness-grid .status { grid-row: 1 / 3; }
.readiness-grid small { color: var(--muted); }
.action-panel > summary, .row-editor > summary { color: var(--primary); font-weight: 700; cursor: pointer; list-style: none; }
.action-panel > summary::-webkit-details-marker, .row-editor > summary::-webkit-details-marker { display: none; }
.row-editor { position: relative; }
.row-editor > summary { font-size: 12px; white-space: nowrap; }
.row-editor[open] form { position: absolute; right: 0; z-index: 5; width: 300px; display: grid; gap: 10px; padding: 14px; text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 45px rgba(45,30,85,.18); }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 10%, #eee8ff, transparent 35%), var(--bg); }
.login-card { width: 100%; max-width: 390px; padding: 30px; }
.login-card h1 { margin: 0; font-size: 24px; }
.login-card p { color: var(--muted); margin: 8px 0 24px; }

@media (max-width: 1000px) {
    .grid-4, .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .shell { grid-template-columns: 78px minmax(0, 1fr); }
    .sidebar { padding-inline: 10px; }
    .role-brand, .nav-label, .sidebar-footer .nav-label { display: none; }
    .brand { justify-content: center; padding-inline: 0; }
    .nav a, .logout { justify-content: center; }
    .activity-log-toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .activity-filter-actions { align-self: end; }
}

@media (max-width: 700px) {
    .shell { display: block; }
    .sidebar { position: static; height: auto; padding: 10px 12px; }
    .brand, .sidebar-footer { display: none; }
    .nav { grid-template-columns: repeat(auto-fit, minmax(44px, 1fr)); }
    .nav a { padding: 9px 5px; }
    .nav-label { display: none; }
    .content { padding: 20px 16px 40px; }
    .grid-4, .grid-3, .grid-2, .form-grid, .auto-service-fields, .modal-summary-grid, .service-permission-list { grid-template-columns: 1fr; }
    .closure-calculation, .modal-closure .closure-calculation { grid-template-columns: 1fr; }
    .workflow-steps, .readiness-grid { grid-template-columns: 1fr; }
    .page-head { align-items: stretch; flex-direction: column; }
    .page-actions { justify-content: flex-start; }
    .inline-form { width: 100%; align-items: stretch; flex-direction: column; }
    .modal-head, .modal-body { padding-inline: 18px; }
    .modal-actions { padding-inline: 18px; flex-wrap: wrap; }
    .modal-actions .button { flex: 1; }
    .modal-panel-head { align-items: stretch; flex-direction: column; }
    .compact-row { align-items: flex-start; flex-direction: column; }
    .compact-row-actions { justify-content: flex-start; }
    .contractor-modal-meta { flex-direction: column; gap: 5px; }
    .service-permissions-meta { flex-direction: column; gap: 5px; }
    .matrix-create-form { width: 100%; align-items: stretch; flex-direction: column; }
    .matrix-month-filter { min-width: 0; }
    .matrix-month-select select, .matrix-action-button { width: 100%; }
    .matrix-period-head { align-items: stretch; flex-direction: column; }
    .matrix-period-totals { width: 100%; overflow-x: auto; }
    .matrix-period-totals span { min-width: 112px; }
    .calendar-carryover { align-items: stretch; flex-direction: column; }
    .calendar-carryover-list { justify-content: flex-start; }
    .service-permission-item:nth-child(odd) { border-right: 0; }
    .settlement-toolbar { width: 100%; justify-content: flex-start; }
    .document-toolbar { align-items: stretch; flex-wrap: wrap; }
    .document-search-shell { flex-basis: 100%; max-width: none; }
    .document-sort { flex: 1 1 210px; margin-left: 0; }
    .activity-log-toolbar { grid-template-columns: 1fr; }
    .activity-filter-actions { justify-content: flex-start; }
    .table-navigation { align-items: flex-start; flex-direction: column; }
    .sticky-table-wrap { max-height: 65vh; }
    .matrix-screen { height: auto; overflow: auto; }
    .matrix-screen .shell { height: auto; }
    .matrix-screen .main, .matrix-screen .content { height: auto; overflow: visible; }
    .matrix-screen-content > .matrix-period { display: block; overflow: visible; }
    .matrix-table-scroll { max-height: 68vh; }
    .final-amount-layout { grid-template-columns: 1fr; }
    .act-preview-scroll { padding: 10px; overflow: auto; }
}

/* WolfFinance Studio transfer layer. The original feature selectors remain intact. */
@font-face {
    font-family: Manrope;
    src: url('/fonts/Manrope-Variable.ttf') format('truetype');
    font-style: normal;
    font-weight: 200 800;
    font-display: swap;
}

:root {
    --bg: #f7f8fb;
    --panel: #ffffff;
    --panel-soft: #f8f9fc;
    --text: #242635;
    --muted: #616677;
    --line: #dde1ea;
    --line-soft: #eceef3;
    --primary: #6856d5;
    --primary-dark: #5846c2;
    --primary-active: #4939ad;
    --primary-soft: #f0edfb;
    --success: #327367;
    --success-soft: #e7f2ee;
    --warning: #725b98;
    --warning-soft: #f2edf8;
    --danger: #a33d55;
    --danger-soft: #faedf0;
    --focus: #9380e2;
    --canvas: linear-gradient(135deg, #e8e1f1, #e4e7f0 70%, #ebe5f1);
    --workspace: radial-gradient(ellipse at 95% 0, #e2d9f85c, transparent 50%), linear-gradient(145deg, #f7f5fc, #f3f5fa 75%);
    --shadow: 0 12px 40px #1f234008;
    font-family: Manrope, "Segoe UI", Arial, sans-serif;
}

html {
    background: #e5e0ef;
    scrollbar-color: #b9b2ce #eeecf5;
    scrollbar-gutter: stable;
}

html:focus-within { scroll-behavior: smooth; }

body {
    min-width: 320px;
    min-height: 100dvh;
    background: var(--canvas);
    color: var(--text);
    font-family: Manrope, "Segoe UI", Arial, sans-serif;
    font-size: 13px;
    font-weight: 450;
    line-height: 1.55;
}

::selection { color: #31264d; background: #dcd1f5; }

* { scrollbar-color: #afb3c2 transparent; scrollbar-width: thin; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: #b8b8c8; border: 3px solid transparent; border-radius: 999px; background-clip: padding-box; }

:is(a, button, input, select, textarea, summary):focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 3px;
}

.wf-skip-link {
    position: fixed;
    z-index: 2000;
    top: 10px;
    left: 12px;
    padding: 9px 13px;
    color: #fff;
    background: var(--primary-active);
    border-radius: 8px;
    transform: translateY(-160%);
    transition: transform 180ms ease-out;
}
.wf-skip-link:focus { transform: translateY(0); }

.shell {
    grid-template-columns: 244px minmax(0, 1fr);
    min-height: 100dvh;
    padding: 10px;
}

.sidebar {
    position: sticky;
    z-index: 30;
    top: 10px;
    display: flex;
    height: calc(100dvh - 20px);
    flex-direction: column;
    padding: 18px 14px 14px;
    color: #626b80;
    background: linear-gradient(165deg, #ede9f8, #f6f5fb 58%, #ecebf6);
    border: 1px solid #ddd7eb;
    border-right: 0;
    border-radius: 18px 0 0 18px;
    overflow: hidden;
}

.brand {
    gap: 12px;
    padding: 4px 8px 18px;
    color: #303646;
    font-size: inherit;
    letter-spacing: -0.3px;
}
.brand:hover .brand-mark { transform: rotate(-4deg); }
.brand-mark {
    width: 38px;
    height: 41px;
    border-radius: 11px;
    color: #fff;
    background: linear-gradient(140deg, #9789ff, #6552d6);
    box-shadow: 0 4px 14px #0808112b;
    font-size: 24px;
    font-weight: 800;
    line-height: 1;
    transform: rotate(-7deg);
    transition: transform 220ms ease-out;
}
.brand-copy { display: grid; min-width: 0; gap: 2px; }
.brand-copy strong { color: #303646; font-size: 16px; font-weight: 750; }
.brand-copy small { color: #596175; font-size: 10px; font-weight: 520; letter-spacing: 0; }

.role-brand {
    justify-content: flex-start;
    margin: 0 8px 20px;
    padding: 10px 0 13px;
    color: #675979;
    border-bottom: 1px solid #e1dcec;
    font-size: 10px;
    font-weight: 650;
    letter-spacing: 0.02em;
}

.nav-caption {
    margin: 0 10px 7px;
    color: #596175;
    font-size: 10px;
    font-weight: 650;
    letter-spacing: 0.06em;
}

.nav { gap: 4px; }
.nav a {
    min-height: 42px;
    gap: 11px;
    padding: 10px 11px;
    color: #646e83;
    border-radius: 9px;
    font-size: 12px;
    font-weight: 570;
    transition: color 180ms ease-out, background-color 180ms ease-out, box-shadow 180ms ease-out, transform 180ms ease-out;
}
.nav a:hover { color: #5a6077; background: #f4f5fa; }
.nav a:active { transform: translateY(1px); }
.nav a.active {
    color: #574487;
    background: linear-gradient(105deg, #ddd5f3, #ebe6f8);
    box-shadow: inset 3px 0 #8971c6, inset 0 0 0 1px #cdbfe84a;
}
.nav-icon { display: grid; width: 19px; flex: 0 0 19px; place-items: center; color: #9399ac; }
.nav a.active .nav-icon { color: #8264bb; }
.nav-icon svg, .icon-button svg, .mobile-menu-button svg, .auth-btn svg, .auth-alert svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sidebar-footer {
    position: static;
    display: grid;
    margin-top: auto;
    padding-top: 13px;
    border-top: 1px solid #e5e7ef;
    gap: 8px;
}
.sidebar-user {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr);
    align-items: center;
    gap: 9px;
    padding: 8px;
    background: #ffffff;
    border: 1px solid #e1e5ee;
    border-radius: 10px;
}
.user-mark {
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    color: #8874a8;
    background: #eeebf5;
    border-radius: 9px;
    font-size: 12px;
    font-weight: 750;
}
.user-copy { display: grid; min-width: 0; gap: 1px; }
.user-copy strong, .user-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-copy strong { color: #67768b; font-size: 11px; font-weight: 650; }
.user-copy small { color: #687287; font-size: 10px; }
.logout {
    display: flex;
    min-height: 40px;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    color: #8992a6;
    border: 1px solid transparent;
    border-radius: 9px;
    font-size: 11px;
    font-weight: 570;
    transition: color 180ms ease-out, background 180ms ease-out;
}
.logout:hover { color: #685299; background: #efeff8; }

.sidebar-mobile-head, .mobile-bar { display: none; }
.nav-backdrop { position: fixed; z-index: 80; inset: 0; background: rgba(37, 30, 55, 0.38); backdrop-filter: blur(4px); }
body.nav-open { overflow: hidden; }

.main.workspace {
    min-width: 0;
    margin: 0;
    background: var(--workspace);
    border: 1px solid #ffffffb0;
    border-radius: 0 18px 18px 0;
    box-shadow: 0 8px 30px #5c48760b, inset 0 1px 0 #fff;
}
.content {
    width: 100%;
    max-width: none;
    min-height: calc(100dvh - 20px);
    padding: 24px 26px 36px;
}

.page-head {
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}
.page-head > div:first-child { min-width: 0; flex: 1; }
.page-head h1 {
    color: var(--text);
    font-size: 30px;
    font-weight: 750;
    line-height: 1.25;
    letter-spacing: -0.8px;
    text-wrap: balance;
}
.page-head p { max-width: 72ch; margin-top: 8px; color: var(--muted); font-size: 13px; line-height: 1.65; text-wrap: pretty; }
.page-actions { gap: 8px; }

.button {
    min-height: 42px;
    padding: 10px 16px;
    color: #fff;
    background: linear-gradient(115deg, #7e6be2, #6250c8);
    border-color: #705cd1;
    border-radius: 9px;
    box-shadow: 0 3px 8px #5245ad18;
    font-size: 12px;
    font-weight: 620;
    line-height: 20px;
    transition: background 190ms ease-out, border-color 190ms ease-out, color 190ms ease-out, box-shadow 190ms ease-out, transform 120ms ease-out;
}
.button:hover { background: linear-gradient(115deg, #705dd4, #5340b5); border-color: #5945ba; }
.button:active { transform: translateY(1px); }
.button:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.button.secondary {
    color: #525b72;
    background: #fff;
    border-color: #dfe3ec;
    box-shadow: none;
}
.button.secondary:hover { color: #655298; background: #f7f5fc; border-color: #c2b8dc; }
.button.danger { color: #fff; background: #a84b60; border-color: #9e4055; }
.button.danger:hover { background: #93384d; border-color: #8b3045; }
.button.secondary.danger { color: var(--danger); background: #fff; border-color: #e7cbd2; }
.button.secondary.danger:hover { color: #8c2f45; background: var(--danger-soft); border-color: #d9aeb9; }
.button.small { min-height: 34px; padding: 6px 10px; border-radius: 8px; font-size: 11px; }
.button:disabled { opacity: 0.52; box-shadow: none; }
.button .button-icon { width: 17px; height: 17px; flex: 0 0 17px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; }

.card {
    background: rgba(255, 255, 255, 0.96);
    border-color: #dcdfe8;
    border-radius: 16px;
    box-shadow: 0 8px 24px #4b386b08;
}
.card-body { padding: 20px; }
.card-title { color: #343544; font-size: 15px; font-weight: 680; }

.dashboard-today {
    padding: 12px 16px;
    background: linear-gradient(120deg, #f0edfb 0%, #f6f4fd 55%, #f8f9fd 100%);
    border-color: #e4e3ef;
    border-radius: 13px;
}
.dashboard-metric {
    min-height: 108px;
    padding: 18px 20px;
    background: linear-gradient(135deg, #fff 70%, #f7f5fc);
    border-color: #dcd8e9;
    box-shadow: 0 3px 8px #4b386b04;
}
.dashboard-metric::after { display: none; }
.dashboard-metric-icon { color: #7561bb; background: #f0ecfa; border-radius: 12px; }
.metric-label { color: #707688; font-size: 11px; font-weight: 550; }
.metric-value, .settlement-metric { color: #323543; font-size: 23px; font-weight: 680; font-variant-numeric: tabular-nums; }
.metric-note { color: #818697; font-size: 10px; }

.tabs {
    gap: 4px;
    margin-bottom: 20px;
    padding: 0 12px;
    border-bottom: 1px solid #e4e0ee;
    overflow-x: auto;
}
.tabs a {
    flex: 0 0 auto;
    min-height: 48px;
    margin-bottom: -1px;
    padding: 8px 12px;
    color: #747b8e;
    background: transparent;
    border-bottom: 2px solid transparent;
    border-radius: 9px 9px 0 0;
    font-size: 12px;
    font-weight: 650;
    white-space: nowrap;
}
.tabs a:hover { color: #655b78; background: #ece6f730; }
.tabs a.active { color: #685299; background: #f3effa; border-bottom-color: #7967c1; }
.tabs a:focus-visible { outline-offset: -4px; }

.table-wrap {
    max-width: 100%;
    border-radius: inherit;
    overscroll-behavior: contain;
}
table.data { font-variant-numeric: tabular-nums; }
table.data th {
    height: 44px;
    padding: 12px 16px;
    color: #77708a;
    background: #eeebf7;
    border-bottom-color: #e0daec;
    font-size: 11px;
    font-weight: 550;
    line-height: 18px;
    white-space: nowrap;
}
table.data td { padding: 12px 16px; border-bottom-color: #eceef3; font-size: 12px; line-height: 1.5; }
table.data tbody tr { transition: background-color 160ms ease-out; }
table.data tbody tr:hover { background: #faf9fd; }
.num, .money, [class*="amount"] { font-variant-numeric: tabular-nums; }

.status {
    min-height: 26px;
    padding: 4px 9px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 620;
}
.status.success { color: #327367; background: #e7f2ee; border-color: #cee3dc; }
.status.warning { color: #725b98; background: #f2edf8; border-color: #e2d8ed; }
.status.danger { color: #a33d55; background: #faedf0; border-color: #ebcdd4; }
.status.neutral { color: #676d7c; background: #f0f1f5; border-color: #e1e4eb; }

.field { gap: 6px; }
.field label { margin: 0; color: #697387; font-size: 12px; font-weight: 520; line-height: 18px; }
.field input, .field select, .field textarea,
.payout-cell-input, .activity-filter-field input, .activity-filter-field select,
.document-search input, .document-sort select {
    min-height: 42px;
    padding: 10px 12px;
    color: #3e485c;
    background: #fff;
    border-color: #dfe3ec;
    border-radius: 9px;
    box-shadow: none;
    font-family: Manrope, "Segoe UI", Arial, sans-serif;
    font-size: 13px;
    font-weight: 430;
    line-height: 20px;
    transition: border-color 160ms ease-out, box-shadow 160ms ease-out, background-color 160ms ease-out;
}
.field textarea { min-height: 88px; }
.document-search input, .activity-log-search .document-search input { padding-left: 38px; }
.field input:hover, .field select:hover, .field textarea:hover { border-color: #bdc4d3; }
.field input:focus, .field select:focus, .field textarea:focus,
.payout-cell-input:focus, .activity-filter-field input:focus, .activity-filter-field select:focus,
.document-search input:focus, .document-sort select:focus {
    border-color: #9581d2;
    box-shadow: 0 0 0 3px #7760c112;
    outline: none;
}
.field input:disabled, .field select:disabled, .field textarea:disabled,
.field input[readonly] { color: #9098a8; background: #f6f7fa; }

.accounting-file-picker { gap: 8px; }
.accounting-file-control {
    position: relative;
    display: flex;
    min-width: 0;
    min-height: 108px;
    align-items: center;
    gap: 17px;
    padding: 23px;
    color: #565863;
    background: #f5f6f8;
    border: 1px dashed #bcbec4;
    border-radius: 13px;
    cursor: pointer;
    transition: border-color 160ms ease-out, background-color 160ms ease-out;
}
.accounting-file-control:hover { background: #eeeef1; border-color: #6f727f; }
.accounting-file-control:focus-within { outline: 3px solid #c7c8d0; outline-offset: 3px; }
.accounting-file-control.has-files { background: #eeeff2; border-color: #aaacb7; border-style: solid; }
.accounting-file-control > input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    opacity: 0;
    border: 0;
    cursor: pointer;
}
.accounting-file-control > svg { width: 25px; height: 25px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.accounting-file-control-text { display: grid; min-width: 0; gap: 4px; pointer-events: none; }
.accounting-file-control-text strong { color: #44454d; font-size: 13px; font-weight: 700; line-height: 1.8; overflow-wrap: anywhere; }
.accounting-file-control-text small { color: #686b76; font-size: 12px; line-height: 1.8; }
.accounting-file-selected { display: grid; min-width: 0; gap: 12px; padding: 15px 17px; background: #fff; border: 1px solid #d9dade; border-radius: 11px; }
.accounting-file-name { display: grid; min-width: 0; gap: 3px; }
.accounting-file-name strong { color: #44454d; font-size: 12px; line-height: 1.8; overflow-wrap: anywhere; }
.accounting-file-name small { color: #686b76; font-size: 12px; }
.accounting-file-clear { justify-self: start; min-height: 44px; padding: 8px 11px; color: #5d6270; background: #fff; border: 1px solid #d0d1d6; border-radius: 8px; font: 600 12px/20px Manrope, sans-serif; cursor: pointer; }
.accounting-file-clear:hover { color: #963c50; border-color: #dcb6bd; }
.field-hint { color: #7a8090; font-size: 11px; line-height: 1.55; }
.form-grid { gap: 16px 18px; }
.form-actions { gap: 10px; }

.ui-select { font-family: Manrope, "Segoe UI", Arial, sans-serif; }
.ui-select-trigger {
    min-height: 42px;
    padding: 10px 12px;
    color: #3e485c;
    background: #fff;
    border-color: #dfe3ec;
    box-shadow: none;
    font-size: 13px;
    font-weight: 500;
}
.ui-select-trigger:hover { border-color: #bdc4d3; background: #fff; }
.ui-select-trigger:focus-visible, .ui-select.open .ui-select-trigger { border-color: #9581d2; box-shadow: 0 0 0 3px #7760c112; }
.ui-select-options { border-color: #dfe3ec; border-radius: 10px; box-shadow: 0 18px 50px #27233f26; font-family: Manrope, "Segoe UI", Arial, sans-serif; }
.ui-select-option { font-size: 12px; }
.ui-select-option:hover, .ui-select-option:focus-visible, .ui-select-option.active,
.ui-select-option[aria-selected="true"] { color: #615198; background: #f3effa; }

.alert {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    gap: 4px 12px;
    padding: 13px 15px;
    background: #fff;
    border: 1px solid;
    border-radius: 10px;
    font-size: 12px;
    line-height: 1.55;
}
.alert > strong { font-weight: 700; }
.alert > span, .alert > ul { grid-column: 2; }
.alert > ul { margin: 2px 0 0; padding-left: 18px; }
.alert.success { color: #327367; background: #edf6f3; border-color: #cfe2dc; }
.alert.warning { color: #725b98; background: #f5f1f9; border-color: #ded4ea; }
.alert.danger { color: #a33d55; background: #fcf1f3; border-color: #e8cbd2; }
.empty { min-height: 128px; padding: 28px 22px; color: #7d8291; background: #fbfafe; }
.empty h2 { margin: 0 0 8px; color: #464958; font-size: 17px; }

dialog.modal { color: var(--text); }
dialog.modal::backdrop { background: rgba(35, 29, 49, 0.42); backdrop-filter: blur(7px); }
.route-modal-overlay { background: rgba(35, 29, 49, 0.42); backdrop-filter: blur(7px); }
.modal-card {
    max-height: calc(100dvh - 48px);
    background: #fff;
    border-color: #e1e3eb;
    border-radius: 16px;
    box-shadow: 0 28px 90px #27203838;
}
.modal-head { padding: 20px 24px; border-bottom-color: #eceef3; background: linear-gradient(110deg, #faf8fe, #fff); }
.modal-head h2 { color: #343544; font-size: 22px; font-weight: 700; line-height: 1.35; letter-spacing: -0.4px; }
.modal-head p { color: #707789; font-size: 12px; line-height: 1.6; }
.modal-close, .icon-button {
    display: grid;
    width: 34px;
    height: 34px;
    min-height: 34px;
    place-items: center;
    padding: 0;
    color: #717b8f;
    background: #f8f9fc;
    border: 1px solid #e4e6ed;
    border-radius: 9px;
}
.modal-close { font-size: 22px; }
.modal-close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; }
.modal-close:hover, .icon-button:hover { color: #655298; background: #f0edf8; }
.modal-body { padding: 20px 24px; }
.modal-actions { padding: 14px 24px; background: #fcfcfe; border-top-color: #eceef3; }
.modal-tabs { gap: 4px; border-bottom-color: #e4e0ee; }
.modal-tabs button { min-height: 44px; padding: 8px 12px; border-bottom: 2px solid transparent; border-radius: 8px 8px 0 0; }
.modal-tabs button.active { color: #685299; background: #f3effa; border-bottom-color: #7967c1; }
.modal-callout { color: #655783; background: #f3effa; border: 1px solid #e1d8ee; border-radius: 10px; }
.modal-summary-grid section { background: #f8f9fc; border-color: #e6e9f0; border-radius: 10px; }

.icon-action { width: 38px; min-height: 38px; color: #697387; background: #fff; border-color: #dfe3ec; }
.icon-action:hover { color: #655298; background: #f7f5fc; border-color: #c2b8dc; }
.quick-filter { color: #676f82; background: #fff; border-color: #dfe3ec; }
.quick-filter.active { color: #685299; background: #f3effa; border-color: #d8cfea; }
.table-navigation { color: #707789; background: #fafbfe; border-color: #e9ecf3; }
.table-navigation-button { color: #596175; border-color: #dfe3ec; }
.table-navigation-button:hover { color: #655298; border-color: #c2b8dc; }
.upload-zone { background: #f5f1fb; border-color: #c6b8dd; }
.formula { color: #62517e; background: #f3effa; }

/* Authentication uses the same Studio palette and local type. */
.auth-body.studio-auth {
    min-height: 100dvh;
    margin: 0;
    color: #332b42;
    background: #f4f2f8;
    font-family: Manrope, "Segoe UI", Arial, sans-serif;
}
.studio-auth .auth-shell.has-marketing {
    display: grid;
    grid-template-columns: minmax(420px, 1.05fr) minmax(420px, 1fr);
    min-height: 100dvh;
}
.studio-auth .auth-marketing {
    position: relative;
    display: flex;
    min-height: 100dvh;
    flex-direction: column;
    padding: 42px 9%;
    color: #f1edf7;
    background: #221735;
    overflow: hidden;
}
.studio-auth-brand { display: flex; align-items: center; gap: 13px; color: inherit; font-size: 21px; font-weight: 750; letter-spacing: -0.7px; }
.studio-auth-brand > span {
    display: grid;
    width: 42px;
    height: 46px;
    place-items: center;
    color: #332846;
    background: #baa0e6;
    border-radius: 12px;
    font-size: 29px;
    font-weight: 800;
    transform: rotate(-7deg);
}
.studio-auth-story { position: relative; margin: auto 0; padding: 48px 0 20px; }
.studio-auth-eyebrow { color: #a597bd; font-size: 10px; font-weight: 650; letter-spacing: 0.12em; }
.studio-auth .auth-marketing h2 { max-width: 660px; margin: 0 0 20px; color: #f1edf9; font-size: clamp(34px, 3.3vw, 52px); font-weight: 700; line-height: 1.13; letter-spacing: -1.8px; text-wrap: balance; }
.studio-auth .auth-marketing h2 em { color: #bda4e7; font-style: normal; }
.studio-auth-story > p { max-width: 62ch; margin: 0; color: #a99cbf; font-size: 14px; line-height: 1.9; text-wrap: pretty; }
.studio-auth-visual { position: relative; width: 100%; max-width: 390px; height: 245px; margin-top: 36px; }
.auth-visual-card { position: absolute; width: 248px; height: 174px; padding: 24px; border-radius: 19px; box-shadow: 0 17px 35px #0c061630; }
.auth-visual-card-back { top: 5px; left: 0; color: #ab94d4; background: #403456; border: 1px solid #584972; transform: rotate(-11deg); }
.auth-visual-card-back > span { font-size: 9px; font-weight: 650; letter-spacing: 0.12em; }
.auth-visual-lines { display: grid; gap: 12px; margin-top: 27px; }
.auth-visual-lines b { display: block; width: 70%; height: 6px; background: #70579c; border-radius: 3px; }
.auth-visual-lines b:nth-child(2) { width: 45%; background: #604e7f; }
.auth-visual-lines b:nth-child(3) { width: 57%; background: #503f6e; }
.auth-visual-card-front { top: 62px; left: 91px; color: #392a53; background: #c2abe9; border: 1px solid #dccef5; transform: rotate(8deg); }
.auth-visual-card-front svg { position: absolute; top: 20px; right: 20px; width: 31px; height: 31px; padding: 6px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; border: 1px solid #9d86c6; border-radius: 50%; }
.auth-visual-card-front strong { display: block; margin: 25px 0 19px; font-size: 20px; line-height: 1.25; letter-spacing: -0.5px; }
.auth-visual-card-front span { color: #6b5690; font-size: 10px; font-weight: 650; }
.studio-auth-marketing-footer { display: flex; justify-content: space-between; gap: 20px; padding-top: 22px; color: #9b8bb7; border-top: 1px solid #4a3e60; font-size: 10px; }
.studio-auth-marketing-footer span:last-child { color: #8069a5; font-weight: 700; letter-spacing: 0.14em; }
.studio-auth .auth-card-wrap { width: 100%; max-width: 490px; align-self: center; justify-self: center; padding: 50px 32px; }
.studio-auth .auth-card { width: 100%; padding: 0; background: transparent; border: 0; box-shadow: none; }
.studio-auth-kicker { display: block; margin-bottom: 18px; color: #8673a6; font-size: 10px; font-weight: 700; letter-spacing: 0.12em; }
.studio-auth .auth-card h1 { margin: 0; color: #322941; font-size: 31px; font-weight: 750; line-height: 1.2; letter-spacing: -1px; }
.studio-auth .auth-card > p { margin: 13px 0 29px; color: #79649c; font-size: 13px; line-height: 1.8; }
.studio-auth .auth-card .field { margin-bottom: 20px; }
.studio-auth .auth-card .field label { color: #53456c; font-weight: 600; }
.studio-auth .auth-card .input { height: 51px; border-color: #d3cae2; border-radius: 10px; font-size: 14px; }
.studio-auth .auth-card .input:focus { border-color: #6c5298; box-shadow: 0 0 0 3px #8063b120; }
.studio-auth .auth-field-row { display: flex; align-items: center; justify-content: space-between; margin: 23px 0; color: #6e5b8e; font-size: 12px; }
.studio-auth .auth-field-row label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.studio-auth input[type="checkbox"] { width: 15px; height: 15px; accent-color: #3e226e; }
.studio-auth .auth-btn {
    display: flex;
    width: 100%;
    min-height: 49px;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 13px 20px;
    color: #fff;
    background: #3e226e;
    border: 1px solid #3e226e;
    border-radius: 10px;
    font: 650 13px/20px Manrope, sans-serif;
    cursor: pointer;
    transition: background-color 180ms ease-out, transform 120ms ease-out;
}
.studio-auth .auth-btn:hover { background: #30185a; }
.studio-auth .auth-btn:active { transform: translateY(1px); }
.studio-auth .auth-btn > span { margin-right: auto; }
.studio-auth .auth-btn > svg:last-child { margin-left: auto; }
.studio-auth .auth-alert { display: flex; gap: 10px; margin: 0 0 20px; padding: 13px 15px; color: #9b5b47; background: #fcf3ed; border: 1px solid #ead2c8; border-radius: 10px; font-size: 12px; line-height: 1.65; }
.studio-auth .auth-alert svg { flex: 0 0 18px; margin-top: 1px; }
.studio-auth .auth-card-help { margin: 27px 0 0 !important; padding-top: 19px; color: #8876a7 !important; border-top: 1px solid #ded7ea; font-size: 11px !important; line-height: 1.8; }

@media (max-width: 1150px) {
    .grid-4, .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dashboard-metric { padding-inline: 16px; }
}

@media (max-width: 860px) {
    html { background: #f1eff8; }
    .shell { display: block; min-height: 100dvh; padding: 0; }
    .sidebar {
        position: fixed;
        z-index: 90;
        top: 0;
        bottom: 0;
        left: 0;
        width: min(320px, calc(100vw - 42px));
        height: 100dvh;
        padding: 16px 14px max(14px, env(safe-area-inset-bottom));
        border: 0;
        border-right: 1px solid #ddd7eb;
        border-radius: 0 18px 18px 0;
        box-shadow: 18px 0 60px #24365524;
        transform: translateX(-104%);
        transition: transform 220ms ease-out;
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-mobile-head { display: flex; min-height: 44px; align-items: center; justify-content: space-between; margin-bottom: 10px; padding: 0 4px 0 9px; color: #667087; font-size: 12px; }
    .sidebar-mobile-head .icon-button { width: 44px; height: 44px; min-height: 44px; }
    .sidebar .nav { display: flex; flex-direction: column; grid-template-columns: none; }
    .role-brand, .nav-label, .sidebar-footer .nav-label { display: initial; }
    .brand { justify-content: flex-start; }
    .nav a, .logout { min-height: 44px; justify-content: flex-start; }
    .main.workspace { min-height: 100dvh; border: 0; border-radius: 0; }
    .mobile-bar {
        position: sticky;
        z-index: 60;
        top: 0;
        display: grid;
        grid-template-columns: 44px minmax(0, 1fr) auto;
        min-height: 58px;
        align-items: center;
        gap: 10px;
        padding: max(7px, env(safe-area-inset-top)) 16px 7px;
        background: rgba(247, 246, 251, 0.92);
        border-bottom: 1px solid #e0dceb;
        backdrop-filter: blur(16px);
    }
    .mobile-menu-button { display: grid; width: 44px; height: 44px; min-height: 44px; place-items: center; padding: 0; color: #6e6581; background: #fff; border: 1px solid #dddbe8; border-radius: 10px; }
    .mobile-brand { display: flex; min-width: 0; align-items: center; gap: 9px; color: #343648; }
    .mobile-brand > span { display: grid; width: 29px; height: 31px; place-items: center; color: #fff; background: linear-gradient(140deg, #9789ff, #6552d6); border-radius: 8px; font-size: 18px; font-weight: 800; transform: rotate(-6deg); }
    .mobile-brand strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
    .mobile-role { color: #626a7c; font-size: 10px; font-weight: 550; white-space: nowrap; }
    .content { min-height: calc(100dvh - 58px); padding: 20px 18px 32px; }
    .page-head { align-items: flex-start; }
    .page-head h1 { font-size: 26px; }
    .matrix-month-filter { width: 100%; flex: 0 0 auto; }
    .tabs { padding-inline: 5px; }
    .table-wrap { overflow-x: auto; }
    .studio-auth .auth-shell.has-marketing { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
    .studio-auth .auth-marketing { min-height: 0; padding: 24px 25px; border-radius: 0 0 22px 22px; }
    .studio-auth-story, .studio-auth-marketing-footer { display: none; }
    .studio-auth-brand { font-size: 19px; }
    .studio-auth-brand > span { width: 34px; height: 37px; border-radius: 10px; font-size: 25px; }
    .studio-auth .auth-card-wrap { max-width: 500px; align-self: start; padding: 38px 26px; }
}

@media (max-width: 620px) {
    .content { padding: 18px 16px 30px; }
    .page-head { gap: 14px; }
    .page-head > div:first-child { width: 100%; }
    .page-actions { width: 100%; justify-content: flex-start; }
    .page-actions .button { flex: 1 1 auto; }
    .button { min-height: 44px; }
    .button.small { min-height: 44px; }
    .icon-action { width: 44px; flex-basis: 44px; }
    .field input, .field select, .ui-select-trigger { min-height: 44px; }
    .grid-4, .grid-3, .grid-2, .form-grid, .auto-service-fields, .modal-summary-grid, .service-permission-list { grid-template-columns: 1fr; }
    .card { border-radius: 13px; }
    .card-body { padding: 16px; }
    .dashboard-metric { min-height: 96px; padding: 14px; border-radius: 13px; }
    .metric-value, .settlement-metric { font-size: 18px; }
    .tabs { margin-inline: -4px; }
    table.data { min-width: max-content; }
    table.data th, table.data td { padding-inline: 14px; }
    .modal-card { max-height: calc(100dvh - 24px); border-radius: 14px; }
    .modal-head, .modal-body { padding-inline: 18px; }
    .modal-head h2 { font-size: 20px; }
    .modal-close { width: 44px; height: 44px; min-height: 44px; }
    .modal-actions { padding: 12px 18px max(12px, env(safe-area-inset-bottom)); }
    .modal-actions .button { min-width: min(150px, 100%); }
    .alert { grid-template-columns: 1fr; }
    .alert > span, .alert > ul { grid-column: 1; }
    .studio-auth .auth-card-wrap { padding: 34px 22px; }
    .studio-auth .auth-card h1 { font-size: 28px; }
    .studio-auth .auth-card .input { font-size: 16px; }
    .studio-auth .auth-field-row label { min-height: 44px; }
}

/* Authentication motion: separate records settle into one connected workflow. */
.studio-auth ::selection { color: #f8f4ff; background: #6f54a0; }
.studio-auth [data-auth-heading-line] { display: block; }
.studio-auth [data-auth-typewriter] { position: relative; }
.auth-typewriter-copy { white-space: pre-wrap; }
.auth-typewriter-caret {
    display: inline-block;
    width: 1px;
    height: 1.06em;
    margin-left: 4px;
    background: #c8afea;
    border-radius: 1px;
    vertical-align: -0.12em;
    animation: auth-caret-pulse 720ms steps(1, end) infinite;
}
.auth-typewriter-caret.is-finished {
    opacity: 0;
    animation: auth-caret-finish 380ms ease-out forwards;
}
.studio-auth .is-auth-motion-active { will-change: transform, opacity, filter, clip-path; }
.studio-auth .studio-auth-visual {
    --auth-rotate-x: 0deg;
    --auth-rotate-y: 0deg;
    --auth-light-x: 48%;
    --auth-light-y: 54%;
    isolation: isolate;
}
.studio-auth .studio-auth-visual::before {
    content: '';
    position: absolute;
    z-index: 0;
    inset: -54px -72px -46px -58px;
    background: radial-gradient(circle at var(--auth-light-x) var(--auth-light-y), rgba(183, 151, 230, 0.17), transparent 48%);
    opacity: 0.58;
    pointer-events: none;
    transition: opacity 220ms ease-out;
}
.studio-auth .studio-auth-visual.is-auth-interactive:hover::before { opacity: 0.94; }
.studio-auth .auth-visual-card {
    --auth-card-rotation: 0deg;
    z-index: 2;
    transform: perspective(900px) rotateX(var(--auth-rotate-x)) rotateY(var(--auth-rotate-y)) rotateZ(var(--auth-card-rotation));
    transform-style: preserve-3d;
    transition: transform 260ms cubic-bezier(0.16, 1, 0.3, 1), box-shadow 220ms ease-out;
}
.studio-auth .auth-visual-card-back { --auth-card-rotation: -11deg; z-index: 2; }
.studio-auth .auth-visual-card-front { --auth-card-rotation: 8deg; z-index: 3; }
.studio-auth .studio-auth-visual.is-auth-interactive:hover .auth-visual-card-back { box-shadow: 0 20px 42px rgba(12, 6, 22, 0.23); }
.studio-auth .studio-auth-visual.is-auth-interactive:hover .auth-visual-card-front { box-shadow: 0 25px 52px rgba(12, 6, 22, 0.25); }
.auth-flow-connection {
    position: absolute;
    z-index: 1;
    top: 108px;
    left: 92px;
    width: 168px;
    height: 1px;
    background: linear-gradient(90deg, rgba(178, 143, 228, 0), rgba(205, 179, 241, 0.85) 22%, rgba(205, 179, 241, 0.72) 78%, rgba(178, 143, 228, 0));
    box-shadow: 0 0 14px rgba(189, 155, 235, 0.3);
    transform: rotate(17deg);
    transform-origin: left center;
}
.auth-flow-connection i {
    position: absolute;
    top: -3px;
    width: 7px;
    height: 7px;
    background: #c9afea;
    border: 1px solid #e0d1f5;
    border-radius: 50%;
    box-shadow: 0 0 12px rgba(194, 161, 236, 0.48);
}
.auth-flow-connection i:nth-child(1) { left: 18%; }
.auth-flow-connection i:nth-child(2) { left: 51%; }
.auth-flow-connection i:nth-child(3) { left: 82%; }
.studio-auth .auth-card .field:focus-within label { color: #4d337b; }
.studio-auth .auth-btn > svg:last-child { transition: transform 180ms cubic-bezier(0.16, 1, 0.3, 1); }
.studio-auth .auth-btn:hover > svg:last-child { transform: translateX(3px); }

@keyframes auth-caret-pulse {
    0%, 48% { opacity: 1; }
    49%, 100% { opacity: 0.2; }
}
@keyframes auth-caret-finish {
    from { opacity: 1; }
    to { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    html:focus-within { scroll-behavior: auto; }
    .auth-typewriter-caret { display: none; }
    .studio-auth .auth-visual-card { transform: rotateZ(var(--auth-card-rotation)); }
    .studio-auth .studio-auth-visual::before { opacity: 0.58; }
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
