:root {
    --brand: #123a5a;
    --brand-2: #184f79;
    --brand-dark: #0c2d47;
    --accent: #18a957;
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --border: #dde5ee;
    --text: #1f2933;
    --muted: #6b7280;
    --danger: #b42318;
    --warning: #b54708;
    --shadow: 0 14px 35px rgba(25, 42, 65, .08);
    --radius: 16px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    min-height: 100vh;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, Arial, Helvetica, sans-serif;
    font-size: 15px;
    line-height: 1.45;
}

a {
    color: var(--brand);
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

.topbar {
    background: linear-gradient(135deg, var(--brand-dark), var(--brand-2));
    color: white;
}

.topbar__inner {
    width: min(1380px, calc(100% - 40px));
    min-height: 76px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 13px;
    color: white;
}

.brand__logo-wrap {
    width: 50px;
    height: 50px;
    display: grid;
    place-items: center;
    border-radius: 13px;
    background: rgba(255, 255, 255, .1);
    border: 1px solid rgba(255, 255, 255, .1);
}

.brand__logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

.brand__name,
.brand__subtitle {
    display: block;
}

.brand__name {
    font-size: 21px;
    line-height: 1.1;
}

.brand__subtitle {
    margin-top: 4px;
    color: rgba(255, 255, 255, .76);
    font-size: 12px;
    font-weight: 500;
}

.topbar__user {
    display: flex;
    align-items: center;
    gap: 15px;
    text-align: right;
}

.topbar__user strong,
.topbar__user small {
    display: block;
}

.topbar__user small {
    margin-top: 2px;
    color: rgba(255, 255, 255, .72);
    font-size: 12px;
}

.menu-toggle {
    display: none;
    width: 42px;
    height: 42px;
    border: 1px solid rgba(255, 255, 255, .2);
    border-radius: 10px;
    background: rgba(255, 255, 255, .1);
    padding: 10px;
}

.menu-toggle span {
    display: block;
    height: 2px;
    margin: 4px 0;
    background: white;
    border-radius: 2px;
}

.nav {
    background: #fff;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 4px 12px rgba(25, 42, 65, .035);
}

.nav__inner {
    width: min(1380px, calc(100% - 40px));
    min-height: 52px;
    margin: 0 auto;
    display: flex;
    align-items: stretch;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: thin;
}

.nav__link {
    display: inline-flex;
    align-items: center;
    padding: 0 12px;
    color: #526170;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 700;
}

.nav__link:hover,
.nav__link--active {
    color: var(--brand);
    background: #f5f9fd;
    border-bottom-color: var(--accent);
}

.page {
    padding: 28px 0 48px;
}

.container {
    width: min(1380px, calc(100% - 40px));
    margin: 0 auto;
}

.page-head {
    margin-bottom: 22px;
}

.page-head--actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.page-head h1 {
    margin: 0;
    font-size: clamp(27px, 3vw, 36px);
    line-height: 1.12;
    letter-spacing: -.025em;
}

.page-head p {
    margin: 7px 0 0;
    color: var(--muted);
    font-size: 16px;
}

.panel {
    margin-bottom: 20px;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.panel--compact {
    padding: 16px;
}

.panel__head {
    min-height: 74px;
    padding: 18px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    border-bottom: 1px solid var(--border);
}

.panel__head--plain {
    min-height: auto;
    padding: 0 0 20px;
    border: 0;
}

.panel__head h2 {
    margin: 0;
    font-size: 19px;
}

.panel__head p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.btn {
    min-height: 44px;
    padding: 0 17px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 800;
    transition: .17s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:disabled {
    cursor: not-allowed;
    opacity: .5;
    transform: none;
}

.btn--primary {
    color: white;
    background: var(--brand);
    box-shadow: 0 7px 17px rgba(18, 58, 90, .17);
}

.btn--primary:hover {
    background: var(--brand-dark);
}

.btn--secondary {
    color: var(--brand);
    background: white;
    border-color: #cbd8e4;
}

.btn--secondary:hover {
    background: #f5f9fc;
}

.btn--ghost {
    color: white;
    background: rgba(255, 255, 255, .09);
    border-color: rgba(255, 255, 255, .24);
}

.btn--small {
    min-height: 36px;
    padding: 0 12px;
    border-radius: 8px;
    font-size: 13px;
}

.btn--wide {
    width: 100%;
}

.alert {
    margin-bottom: 16px;
    padding: 13px 16px;
    border-radius: 11px;
    border: 1px solid transparent;
    font-weight: 700;
}

.alert--success {
    color: #166534;
    background: #dcfce7;
    border-color: #bbf7d0;
}

.alert--error {
    color: #991b1b;
    background: #fee2e2;
    border-color: #fecaca;
}

.stats-grid {
    margin-bottom: 20px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 15px;
}

.stat-card {
    min-height: 150px;
    padding: 21px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: .17s ease;
}

.stat-card:hover,
.quick-card:hover {
    transform: translateY(-2px);
    border-color: #b8cbdb;
}

.stat-card__label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.stat-card strong {
    margin: 7px 0 4px;
    color: var(--brand);
    font-size: 32px;
    line-height: 1;
}

.stat-card .stat-card__money {
    font-size: 24px;
}

.stat-card small {
    color: var(--muted);
}

.quick-grid {
    margin-bottom: 20px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 15px;
}

.quick-card {
    min-height: 94px;
    padding: 17px;
    display: flex;
    align-items: center;
    gap: 13px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    transition: .17s ease;
}

.quick-card__icon {
    width: 43px;
    height: 43px;
    flex: 0 0 43px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    color: white;
    background: var(--accent);
    font-size: 25px;
    font-weight: 800;
}

.quick-card strong,
.quick-card small {
    display: block;
}

.quick-card small {
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
}

.filters {
    margin-bottom: 17px;
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.field {
    display: block;
    min-width: 0;
}

.field--grow {
    flex: 1;
}

.field--full {
    grid-column: 1 / -1;
}

.field__label {
    display: block;
    margin-bottom: 7px;
    color: #334155;
    font-size: 13px;
    font-weight: 800;
}

.field__help {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
}

.input,
.select,
.textarea,
.file-input {
    width: 100%;
    border: 1px solid #cfd9e3;
    border-radius: 10px;
    background: white;
    color: var(--text);
}

.input,
.select {
    height: 44px;
    padding: 0 13px;
}

.textarea {
    padding: 11px 13px;
    resize: vertical;
    line-height: 1.5;
}

.file-input {
    padding: 9px;
}

.input:focus,
.select:focus,
.textarea:focus,
.file-input:focus {
    border-color: var(--brand-2);
    outline: 3px solid rgba(24, 79, 121, .11);
}

.form-card {
    padding: 23px;
}

.form-card--side {
    position: sticky;
    top: 18px;
    align-self: start;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 19px;
}

.form-stack {
    display: grid;
    gap: 17px;
}

.form-actions {
    margin-top: 24px;
    padding-top: 20px;
    display: flex;
    gap: 11px;
    border-top: 1px solid var(--border);
}

.switch-card {
    min-height: 66px;
    padding: 13px 14px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface-soft);
    cursor: pointer;
}

.switch-card input {
    margin-top: 3px;
}

.switch-card strong,
.switch-card small {
    display: block;
}

.switch-card small {
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
}

.product-preview {
    width: 180px;
    height: 140px;
    margin-bottom: 10px;
    display: block;
    object-fit: contain;
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
}

.product-thumb {
    width: 68px;
    height: 54px;
    display: grid;
    place-items: center;
    object-fit: contain;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: white;
}

.product-thumb--empty {
    color: #8a98a8;
    background: #f1f5f9;
    font-size: 11px;
    text-align: center;
}

.table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    padding: 13px 16px;
    color: #64748b;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    font-size: 11px;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: .045em;
    white-space: nowrap;
}

.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid #e7edf3;
    vertical-align: middle;
}

.data-table tbody tr:last-child td {
    border-bottom: 0;
}

.data-table tbody tr:hover {
    background: #fbfdff;
}

.table-sub {
    margin-top: 3px;
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
}

.table-link {
    font-weight: 800;
}

.table-actions {
    text-align: right;
    white-space: nowrap;
}

.status {
    min-height: 26px;
    padding: 0 9px;
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
}

.status--success {
    color: #166534;
    background: #dcfce7;
}

.status--muted {
    color: #64748b;
    background: #edf2f7;
}

.empty-state {
    padding: 48px 22px;
    text-align: center;
}

.empty-state strong {
    display: block;
    font-size: 20px;
}

.empty-state p {
    max-width: 520px;
    margin: 7px auto 19px;
    color: var(--muted);
}

.split-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 390px;
    gap: 20px;
}

.summary-line {
    margin-bottom: 16px;
    padding: 14px 17px;
    display: flex;
    gap: 30px;
    background: #eaf3f9;
    border: 1px solid #cfe1ee;
    border-radius: 12px;
}

.summary-line span {
    color: var(--muted);
}

.summary-line strong {
    margin-left: 6px;
    color: var(--brand);
}

.document-meta {
    padding: 18px;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 12px;
}

.document-meta > div {
    min-width: 0;
    padding: 12px;
    background: var(--surface-soft);
    border-radius: 10px;
}

.document-meta span,
.document-meta strong {
    display: block;
}

.document-meta span {
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.document-meta strong {
    margin-top: 4px;
}

.note-panel {
    padding: 18px 21px;
}

.note-panel p {
    margin: 5px 0;
}

.positive {
    color: #15803d;
    font-weight: 800;
}

.negative {
    color: var(--danger);
    font-weight: 800;
}

.lines-head {
    margin: 25px 0 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.lines-head h2 {
    margin: 0;
    font-size: 19px;
}

.lines-head p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.operation-lines {
    display: grid;
    gap: 11px;
}

.operation-line {
    position: relative;
    padding: 15px 48px 15px 15px;
    display: grid;
    grid-template-columns: minmax(260px, 2fr) minmax(120px, .7fr) minmax(140px, .8fr);
    align-items: end;
    gap: 12px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.operation-form[data-operation="transfer"] .operation-line,
.operation-form[data-operation="writeoff"] .operation-line {
    grid-template-columns: minmax(300px, 2fr) minmax(140px, .7fr);
}

.line-remove {
    position: absolute;
    top: 30px;
    right: 12px;
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    color: #7b8794;
    border: 0;
    border-radius: 8px;
    background: #e7edf3;
    cursor: pointer;
    font-size: 20px;
}

.line-remove:hover {
    color: white;
    background: var(--danger);
}

.inline-warning {
    margin-top: 15px;
    padding: 12px 14px;
    color: #92400e;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 10px;
}

.muted {
    color: var(--muted);
}

.auth-body {
    background:
        radial-gradient(circle at 18% 20%, rgba(24,169,87,.16), transparent 28%),
        radial-gradient(circle at 85% 78%, rgba(24,79,121,.22), transparent 34%),
        linear-gradient(135deg, #0c2d47, #164f78);
}

.auth-shell {
    min-height: 100vh;
    padding: 25px;
    display: grid;
    place-items: center;
}

.auth-panel {
    width: min(460px, 100%);
    padding: 30px;
    background: rgba(255, 255, 255, .97);
    border: 1px solid rgba(255, 255, 255, .7);
    border-radius: 20px;
    box-shadow: 0 28px 65px rgba(1, 17, 30, .28);
}

.auth-panel__brand {
    margin-bottom: 22px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.auth-panel__brand img {
    width: 64px;
    height: 64px;
    object-fit: contain;
    border-radius: 14px;
    background: #eef4f8;
}

.auth-panel__brand h1 {
    margin: 0;
    color: var(--brand);
    font-size: 23px;
}

.auth-panel__brand p {
    margin: 4px 0 0;
    color: var(--muted);
}

.auth-panel__info {
    margin-bottom: 19px;
    padding: 12px 14px;
    color: #385265;
    background: #edf5fa;
    border: 1px solid #d4e5f1;
    border-radius: 10px;
    font-size: 13px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

.error-state {
    max-width: 650px;
    margin: 40px auto;
}

@media (max-width: 1100px) {
    .stats-grid,
    .quick-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .split-layout {
        grid-template-columns: 1fr;
    }

    .form-card--side {
        position: static;
    }

    .document-meta {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .topbar__inner,
    .nav__inner,
    .container {
        width: min(100% - 26px, 1380px);
    }

    .topbar__inner {
        min-height: 68px;
    }

    .brand__logo-wrap {
        width: 45px;
        height: 45px;
    }

    .brand__logo {
        width: 35px;
        height: 35px;
    }

    .brand__name {
        font-size: 18px;
    }

    .brand__subtitle,
    .topbar__user > span {
        display: none;
    }

    .menu-toggle {
        display: block;
        margin-left: auto;
    }

    .topbar__user {
        display: none;
    }

    .nav {
        display: none;
    }

    .nav.is-open {
        display: block;
    }

    .nav__inner {
        padding: 8px 0 12px;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 5px;
        overflow: visible;
    }

    .nav__link {
        min-height: 42px;
        padding: 0 10px;
        border: 0;
        border-radius: 8px;
    }

    .nav__link--active {
        background: #eaf3f9;
    }

    .page {
        padding-top: 21px;
    }

    .page-head--actions,
    .filters,
    .form-actions,
    .lines-head {
        align-items: stretch;
        flex-direction: column;
    }

    .page-head--actions .btn,
    .filters .btn,
    .form-actions .btn {
        width: 100%;
    }

    .stats-grid,
    .quick-grid,
    .form-grid,
    .document-meta {
        grid-template-columns: 1fr;
    }

    .stat-card {
        min-height: 120px;
    }

    .operation-line,
    .operation-form[data-operation="transfer"] .operation-line,
    .operation-form[data-operation="writeoff"] .operation-line {
        padding-right: 15px;
        grid-template-columns: 1fr;
    }

    .line-remove {
        position: static;
        width: 100%;
        height: 38px;
        margin-top: 2px;
    }

    .table-wrap {
        margin: 0;
    }

    .data-table th,
    .data-table td {
        padding: 12px 13px;
    }

    .summary-line {
        flex-direction: column;
        gap: 5px;
    }

    .auth-shell {
        padding: 15px;
    }

    .auth-panel {
        padding: 23px;
    }
}

/* v2: заявки, интеграции и кабинет монтажника */
.integration-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:20px; }
.section-gap { margin-top:20px; }
.form-actions--border { margin-top:20px; padding-top:18px; border-top:1px solid var(--border); }
.mono-break { font-family:ui-monospace,SFMono-Regular,Consolas,monospace; overflow-wrap:anywhere; color:var(--muted); }
.input-group { display:flex; align-items:center; border:1px solid #cfd9e4; border-radius:10px; background:#fff; overflow:hidden; }
.input-group .input { border:0; box-shadow:none; }
.input-group span { padding:0 13px; color:var(--muted); white-space:nowrap; }
.webhook-box,.note-box,.subpanel { margin-top:18px; padding:16px; border:1px solid var(--border); border-radius:12px; background:var(--surface-soft); }
.webhook-box strong,.note-box strong,.subpanel h3 { display:block; margin:0 0 8px; }
.webhook-box code { display:block; margin-top:8px; overflow-wrap:anywhere; }
.inline-warning { margin-bottom:14px; padding:12px 14px; border-radius:10px; background:#fff7ed; color:#9a3412; border:1px solid #fed7aa; }
.summary-grid--jobs { grid-template-columns:repeat(4,minmax(0,1fr)); }
.split-layout--wide { grid-template-columns:minmax(0,2fr) minmax(320px,1fr); }
.file-grid { padding:18px 22px; display:grid; grid-template-columns:repeat(auto-fit,minmax(180px,1fr)); gap:12px; }
.file-card { padding:14px; border:1px solid var(--border); border-radius:11px; background:#fff; }
.file-card strong,.file-card small { display:block; }
.file-card small { margin-top:5px; color:var(--muted); overflow-wrap:anywhere; }
.assignee-row { padding:12px 0; display:grid; grid-template-columns:1fr 130px; gap:10px; align-items:center; border-bottom:1px solid var(--border); }
.check-label { display:flex; align-items:flex-start; gap:9px; }
.check-label span,.check-label strong,.check-label small { display:block; }
.check-label small { margin-top:3px; color:var(--muted); }
.input--compact { min-width:90px; height:38px; }
.salary-list { margin-top:20px; padding-top:16px; border-top:1px solid var(--border); }
.salary-list h3 { margin:0 0 10px; }
.salary-list div { display:flex; justify-content:space-between; gap:12px; padding:8px 0; }
.installer-cards { display:grid; grid-template-columns:repeat(auto-fit,minmax(290px,1fr)); gap:16px; }
.installer-job-card { padding:20px; color:var(--text); background:#fff; border:1px solid var(--border); border-radius:var(--radius); box-shadow:var(--shadow); transition:.16s ease; }
.installer-job-card:hover { transform:translateY(-2px); border-color:#b8cbdb; }
.installer-job-card__head { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.installer-job-card h2 { margin:16px 0 7px; font-size:20px; }
.installer-job-card p { margin:0; color:var(--muted); }
.installer-job-card__meta { margin-top:18px; display:grid; grid-template-columns:repeat(2,1fr); gap:10px; }
.installer-job-card__meta span { padding:10px; border-radius:10px; background:var(--surface-soft); color:var(--muted); font-size:12px; }
.installer-job-card__meta strong { display:block; margin-top:4px; color:var(--text); font-size:14px; }
.report-lines { margin:18px 0 12px; display:grid; gap:12px; }
.report-line { padding:14px; display:grid; grid-template-columns:minmax(0,1fr) 150px auto; gap:12px; align-items:end; border:1px solid var(--border); border-radius:12px; background:var(--surface-soft); }
.report-line__remove { margin-bottom:1px; }
.file-input { padding:10px; height:auto; }
.inline-form,.approval-actions { display:flex; align-items:center; gap:8px; }
.status--danger { color:#991b1b; background:#fee2e2; }
.installer-body .container,.installer-body .topbar__inner,.installer-body .nav__inner { width:min(1120px,calc(100% - 28px)); }

@media (max-width: 980px) {
    .integration-grid,.split-layout--wide { grid-template-columns:1fr; }
    .summary-grid--jobs { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
@media (max-width: 680px) {
    .summary-grid--jobs { grid-template-columns:1fr 1fr; }
    .report-line { grid-template-columns:1fr; }
    .report-line__remove { width:100%; }
    .inline-form { align-items:stretch; flex-direction:column; }
    .installer-job-card__meta { grid-template-columns:1fr; }
}
