* { box-sizing: border-box; }
body { margin: 0; color: #2c3340; background: #fff; font: 13px/1.35 "Segoe UI", Arial, sans-serif; }
svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
button, input, select { font: inherit; color: inherit; }
.app { display: flex; min-height: 100vh; }
.side { width: 168px; flex: none; border-right: 1px solid #eceff3; background: #fff; display: flex; flex-direction: column; }
.side button.nav { display: block; width: 100%; padding: 11px 16px; border: 0; background: transparent; color: #3d4553; text-align: left; cursor: pointer; }
.side button.nav.active, .side button.nav:hover { background: #f1f2f4; }
.content { flex: 1; min-width: 0; }
.ghost { display: inline-flex; align-items: center; height: 30px; padding: 0 10px; border-radius: 4px; white-space: nowrap; border: 1px solid #d9dee7; color: #667085; background: #fff; }
.page { padding: 14px 16px 28px; }
.filter { border: 1px solid #e6e9ef; border-radius: 8px; padding: 12px; }
.filter h2 { margin: 2px 2px 12px; font-size: 16px; font-weight: 650; }
.row { display: flex; align-items: center; gap: 10px; }
.row + .row, .groups { margin-top: 10px; }
.control { flex: 1; height: 36px; display: flex; align-items: center; gap: 8px; padding: 0 10px; border: 1px solid #e1e5ec; border-radius: 6px; color: #98a0ae; background: #fff; }
.control.grow { max-width: 340px; margin-left: auto; }
.control input, .control select { width: 100%; border: 0; outline: 0; background: transparent; color: #2c3340; }
.control button { border: 0; background: transparent; color: #98a0ae; cursor: pointer; display: flex; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; color: #4b5565; margin-top: 10px; }
.checks label, .chip { display: inline-flex; align-items: center; gap: 6px; }
.danger-text { color: #ef3b32; }
.groups { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.group { display: flex; align-items: center; gap: 8px; min-height: 28px; }
.group b { color: #9aa1ad; font-size: 11px; letter-spacing: .04em; }
.chip { height: 24px; padding: 0 8px; border: 1px solid #e1e5ec; border-radius: 5px; color: #667085; background: #fff; }
.stats { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 34px; margin: 8px 2px; color: #7b8494; }
.stats-main { white-space: nowrap; }
.stats b { color: #222; }
.legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.legend span, .dotline { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 10px 8px; color: #9aa3b2; font-size: 13px; font-weight: 500; text-align: left; border-bottom: 1px solid #eef1f4; white-space: nowrap; }
th span, th .sort { display: inline-flex; align-items: center; gap: 5px; }
th .sort { padding: 0; border: 0; background: transparent; color: inherit; font: inherit; cursor: pointer; }
th .sort.active { color: #2c3340; }
th .sort .arrow { display: inline-block; width: 10px; font-style: normal; font-size: 10px; color: #2f6fe4; text-align: center; }
th .sort .arrow.off { visibility: hidden; }
table.firms { table-layout: fixed; min-width: 972px; }
table.firms .c-check { width: 42px; }
table.firms .c-city { width: 180px; }
table.firms .c-emp { width: 190px; }
table.firms .c-cnt { width: 156px; }
table.firms .c-money { width: 168px; }
table.firms .c-actions { width: 52px; }
table.firms th, table.firms td { overflow: hidden; }
table.firms .name { white-space: normal; }
table.firms .pin { display: flex; max-width: 100%; min-width: 0; }
table.firms .pin svg { flex: none; }
table.firms .pin span, table.firms .clip { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.firms .pill { max-width: 100%; }
td { padding: 12px 8px; border-bottom: 1px solid #f2f4f7; vertical-align: top; }
tr:hover td { background: #fbfcfd; }
.name { font-weight: 650; }
.muted { color: #8b93a3; }
.sub { color: #7b8494; margin-top: 3px; display: flex; align-items: center; gap: 4px; }
.pin { color: #7f8ea3; display: inline-flex; align-items: center; gap: 3px; }
.count { display: inline-block; box-sizing: border-box; min-width: 22px; height: 22px; line-height: 22px; padding: 0 7px; border-radius: 11px; color: #3b82f6; background: #e8f3ff; text-align: center; vertical-align: middle; }
.pill { display: inline-block; box-sizing: border-box; height: 22px; line-height: 22px; padding: 0 8px; border-radius: 11px; color: #2ea35a; background: #e8f8ee; white-space: nowrap; vertical-align: middle; }
button.pill { border: 0; font: inherit; cursor: pointer; }
button.pill:hover { background: #dff3e6; }
.pill .bal-rub { margin-left: 0.35em; color: #98a2b3; }
.login { display: inline-block; margin-bottom: 2px; font-size: 15px; font-weight: 750; }
.num { color: #667085; white-space: nowrap; }
.vdots { display: inline-flex; flex-direction: column; gap: 3px; margin-right: 6px; vertical-align: middle; }
.circle { min-width: 22px; height: 22px; padding: 0 6px; display: inline-flex; align-items: center; justify-content: center; border-radius: 11px; color: #fff; background: #d5dbe3; }
.circle.ok { background: #43c16b; }
.product { display: flex; align-items: center; gap: 5px; margin-top: 4px; color: #667085; white-space: nowrap; }
.info { min-width: 280px; line-height: 1.45; }
.sum { color: #2a62c9; font-weight: 750; }
.actions { display: flex; align-items: center; gap: 2px; color: #667085; }
.eye { width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; padding: 0; border: 0; border-radius: 6px; color: #667085; background: transparent; cursor: pointer; }
.eye:hover { color: #2f6fe4; background: #f3f6fb; }
html.modal-open, html.modal-open body { overflow: hidden; }
.modal { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; padding: 28px 16px; background: rgba(17, 24, 39, .45); }
.modal[hidden] { display: none; }
.dialog { display: flex; flex-direction: column; width: min(640px, 100%); max-height: min(520px, calc(100vh - 56px)); overflow: hidden; border-radius: 12px; background: #fff; box-shadow: 0 18px 50px rgba(15, 23, 42, .22); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex: none; padding: 16px 16px 16px 20px; border-bottom: 1px solid #eef1f4; }
.dialog-head h2 { margin: 0; font-size: 16px; line-height: 1.35; }
.dialog .close { width: 32px; height: 32px; flex: none; border: 0; border-radius: 6px; background: transparent; color: #667085; cursor: pointer; font-size: 22px; line-height: 1; }
.dialog .close:hover { background: #f3f4f6; }
.dialog-body { min-height: 0; padding: 16px 20px 20px; overflow: auto; }
.op { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid #e8ebf0; border-radius: 10px; background: #fff; }
.op + .op { margin-top: 8px; }
.op .mark { width: 28px; height: 28px; margin-top: 1px; flex: none; display: flex; align-items: center; justify-content: center; border-radius: 50%; font-weight: 700; }
.op.plus .mark { color: #178a48; background: #e8f8ee; }
.op.minus .mark { color: #d92d20; background: #fee2e2; }
.op .body { flex: 1; min-width: 0; }
.op .top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.op .kind { font-weight: 650; line-height: 1.3; }
.op .when { margin-top: 2px; color: #8b93a3; font-size: 12px; line-height: 1.3; }
.op .sums { text-align: right; white-space: nowrap; }
.op .amount { font-weight: 750; line-height: 1.3; }
.op.minus .amount { color: #d92d20; }
.op.plus .amount { color: #178a48; }
.op .extra { margin-top: 2px; color: #8b93a3; font-size: 12px; line-height: 1.3; }
.op-note { margin-top: 6px; color: #4b5565; line-height: 1.35; }
.field { display: grid; grid-template-columns: 148px minmax(0, 1fr); gap: 12px; align-items: baseline; padding: 10px 0; border-bottom: 1px solid #f3f4f6; }
.field:last-child { border-bottom: 0; }
.field b { color: #667085; font-weight: 500; }
.phone { font-weight: 650; }
.card { display: inline-block; max-width: 430px; padding: 8px 10px; border-radius: 8px; background: #f4f7fb; }
.card .who { color: #667085; }
.note { margin-top: 5px; }
.file { margin-top: 6px; color: #98a2b3; display: flex; align-items: center; gap: 4px; }
.empty { padding: 28px 8px; color: #98a2b3; }
.pager { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 14px; }
.pager button, .pager .on { min-width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 4px; color: #3d4553; background: transparent; cursor: pointer; }
.pager .on { color: #fff; background: #2f6fe4; }
.pager .meta { margin-left: 8px; color: #8b93a3; }
.pager select { height: 28px; margin-left: 4px; border: 1px solid #e1e5ec; border-radius: 4px; background: #fff; }
.users-note { margin: 0 0 14px; color: #667085; }
.users-table { width: 100%; border-collapse: collapse; }
.users-table th, .users-table td { padding: 10px 8px; border-bottom: 1px solid #eef1f4; text-align: left; vertical-align: top; }
.users-table th { color: #8b93a3; font-weight: 500; }
.users-table label { display: flex; align-items: center; gap: 6px; margin: 4px 0; }
.limits { display: flex; gap: 10px; }
.limits input { width: 80px; height: 32px; padding: 0 8px; border: 1px solid #e1e5ec; border-radius: 6px; }
.save-access { height: 34px; margin-top: 14px; padding: 0 14px; border: 0; border-radius: 6px; color: #fff; background: #2f6fe4; cursor: pointer; }
.ok { margin-bottom: 12px; color: #178a48; }
.form-error { margin-bottom: 12px; color: #d92d20; }
.page-title { margin: 0 0 8px; font-size: 20px; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: #f3f4f6; }
.login-card { width: 360px; max-width: calc(100vw - 30px); padding: 28px; background: #fff; border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .1); }
.login-card h1 { margin: 0 0 22px; font-size: 22px; }
.login-card label { display: block; margin: 13px 0 5px; color: #4b5563; }
.login-card input { width: 100%; padding: 11px; border: 1px solid #cbd5e1; border-radius: 6px; }
.login-card button { width: 100%; margin-top: 18px; padding: 11px; border: 0; border-radius: 6px; color: #fff; background: #2563eb; cursor: pointer; }
.login-card .error { margin-bottom: 15px; padding: 10px; color: #991b1b; background: #fee2e2; border-radius: 6px; }
@media (max-width: 900px) {
    .side { width: 142px; }
    .stats, .row { align-items: flex-start; flex-wrap: wrap; }
}
@media (max-width: 760px) {
    body { font-size: 14px; }
    .app { flex-direction: column; }
    .side { position: sticky; top: 0; z-index: 8; width: 100%; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid #eceff3; }
    .side button.nav { width: auto; flex: none; white-space: nowrap; padding: 14px 14px; }
    .content { width: 100%; }
    .page { padding: 12px 12px 32px; }
    .row, .stats, .limits { flex-direction: column; align-items: stretch; }
    .control, .control.grow { max-width: none; width: 100%; margin-left: 0; height: 42px; }
    .control input, .control select, .login-card input, .limits input { font-size: 16px; }
    .stats-main { white-space: normal; }
    .legend { justify-content: flex-start; }
    .table-wrap { overflow: visible; }
    table.firms { min-width: 0; table-layout: auto; }
    table.firms thead, table.account thead, table.crm thead, table.srv thead, .users-table thead { display: none; }
    table.firms tr, table.account tr, table.crm tr, table.srv tr, .users-table tr {
        display: block;
        margin: 0 0 10px;
        padding: 12px;
        border: 1px solid #e6e9ef;
        border-radius: 12px;
    }
    table.firms td, table.account td, table.crm td, table.srv td, .users-table td {
        display: block;
        width: auto;
        padding: 3px 0;
        border: 0;
        overflow: visible;
        white-space: normal;
    }
    table.firms td:nth-child(1), table.account td:nth-child(2), table.account td:nth-child(9), table.crm td:nth-child(9) { display: none; }
    table.firms td:nth-child(2) .name, table.crm td:nth-child(3) .name, table.srv td:nth-child(3) { font-size: 16px; }
    table.firms td:nth-child(4)::before { content: "Ответственный"; display: block; color: #98a2b3; font-size: 11px; }
    table.firms td:nth-child(5), table.firms td:nth-child(6), table.firms td:nth-child(7) { display: inline-block; vertical-align: middle; margin: 8px 8px 0 0; }
    table.account td:nth-child(5)::before { content: "Дни"; display: block; color: #98a2b3; font-size: 11px; }
    table.account td:nth-child(6)::before { content: "Дни (ТИС)"; display: block; color: #98a2b3; font-size: 11px; }
    table.account td:nth-child(5), table.account td:nth-child(6), table.account td:nth-child(8) { display: inline-block; vertical-align: middle; margin: 8px 8px 0 0; }
    table.crm td:nth-child(4)::before { content: "Источник"; }
    table.crm td:nth-child(5)::before { content: "Статус"; }
    table.crm td:nth-child(6)::before { content: "Город"; }
    table.crm td:nth-child(8)::before { content: "Ответственный"; }
    table.crm td:nth-child(4)::before, table.crm td:nth-child(5)::before, table.crm td:nth-child(6)::before, table.crm td:nth-child(8)::before { display: block; color: #98a2b3; font-size: 11px; }
    table.srv td:nth-child(4) .phone { font-size: 16px; }
    .info { min-width: 0; }
    .card { max-width: none; display: block; }
    .product { white-space: normal; }
    .eye { width: 40px; height: 40px; }
    .pager button, .pager .on { min-width: 36px; height: 36px; }
    .pager .meta { margin-left: 0; }
    .modal { align-items: flex-end; padding: 0; }
    .dialog { width: 100%; max-height: calc(100vh - 12px); border-radius: 16px 16px 0 0; }
    .field { grid-template-columns: 1fr; gap: 2px; }
    .users-table { display: block; }
    .users-table tbody { display: block; }
}
