html {
    max-width: 100%;
    overflow-x: hidden;
}

:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --line: #e5e7eb;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --success: #059669;
    --shadow: 0 14px 40px rgba(15, 23, 42, .08);
    --radius: 16px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    max-width: 100%;
    overflow-x: hidden;
}

a {
    color: inherit;
}

.app-shell {
    display: flex;
    min-height: 100vh;
    width: 100%;
    max-width: 100vw;
    overflow-x: clip;
}

.sidebar {
    width: 264px;
    flex: 0 0 264px;
    background: #0f172a;
    color: #e5e7eb;
    padding: 22px 16px;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    height: 100vh;
    z-index: 20;
    overflow-y: auto;
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 22px;
}

.brand strong {
    display: block;
    font-size: 16px;
}

.brand span {
    display: block;
    color: #94a3b8;
    font-size: 12px;
    margin-top: 2px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #2563eb, #0ea5e9);
    color: #fff;
    font-weight: 800;
    letter-spacing: .5px;
}

.brand-logo {
    width: 74px;
    height: 44px;
    padding: 2px 4px;
    border-radius: 10px;
    background: #fff;
    border: 1px solid rgba(255, 255, 255, .18);
    overflow: hidden;
}

.brand-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.money-input {
    text-align: left;
    font-variant-numeric: tabular-nums;
}

.sidebar nav {
    display: grid;
    gap: 6px;
}

.sidebar nav a {
    color: #cbd5e1;
    text-decoration: none;
    padding: 11px 12px;
    border-radius: 10px;
    transition: .15s ease;
}

.sidebar nav a:hover,
.sidebar nav a.active {
    background: rgba(255, 255, 255, .1);
    color: #fff;
}

.content {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    max-width: 100%;
    padding: 24px;
    margin-left: 264px;
    overflow-x: hidden;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 22px;
    box-shadow: var(--shadow);
}

.userbox {
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-title {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 18px;
}

.page-title h1 {
    margin: 0;
    font-size: 28px;
}

.page-title p {
    margin: 6px 0 0;
    color: var(--muted);
}

.card,
.stat-card {
    min-width: 0;
    max-width: 100%;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
    margin-bottom: 18px;
}

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

.card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.card-head h2 {
    margin-bottom: 4px;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 18px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr));
    gap: 16px;
    margin-bottom: 18px;
    min-width: 0;
    max-width: 100%;
}

.stat-card {
    text-decoration: none;
    display: block;
}

.stat-card span {
    display: block;
    color: var(--muted);
}

.stat-card strong {
    display: block;
    margin-top: 10px;
    font-size: 25px;
}

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

label {
    display: grid;
    gap: 6px;
    font-weight: 600;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    padding: 10px 12px;
    font: inherit;
    background: #fff;
    color: var(--text);
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #93c5fd;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.span-2 {
    grid-column: span 2;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: var(--primary);
    color: #fff;
    border-radius: 10px;
    padding: 10px 14px;
    min-height: 40px;
    cursor: pointer;
    text-decoration: none;
    font-weight: 700;
    transition: .15s ease;
}

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

.btn-light {
    background: #eef2ff;
    color: #1e40af;
}

.btn-light:hover {
    background: #dbeafe;
}

.btn-small {
    padding: 7px 10px;
    min-height: 34px;
    font-size: 13px;
}

.full {
    width: 100%;
}

.link {
    border: 0;
    background: transparent;
    padding: 0;
    color: var(--primary);
    cursor: pointer;
    text-decoration: none;
    font-weight: 700;
}

.link:hover {
    text-decoration: underline;
}

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

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

table {
    border-collapse: collapse;
    width: 100%;
    min-width: 760px;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 12px 10px;
    text-align: left;
    vertical-align: top;
}

th {
    color: #475569;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    background: #f8fafc;
}

tr:last-child td {
    border-bottom: 0;
}

.muted {
    color: var(--muted);
    font-size: 13px;
}

.empty {
    color: var(--muted);
    text-align: center;
    padding: 28px;
}

.badge {
    display: inline-flex;
    border-radius: 999px;
    padding: 4px 9px;
    background: #eef2ff;
    color: #3730a3;
    font-size: 12px;
    font-weight: 700;
}

.stage-new {
    background: #eff6ff;
    color: #1d4ed8;
}

.stage-work {
    background: #fff7ed;
    color: #c2410c;
}

.stage-project {
    background: #ecfdf5;
    color: #047857;
}

.stage-done {
    background: #f1f5f9;
    color: #475569;
}

.pipeline {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 12px;
}

.pipeline-stage {
    border-radius: 14px;
    padding: 14px;
    min-height: 110px;
}

.pipeline-stage strong,
.pipeline-stage span {
    display: block;
}

.pipeline-stage span {
    margin-top: 8px;
    opacity: .8;
}

.stage-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, .75);
    font-weight: 800;
    margin-bottom: 10px;
}

.alert {
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 16px;
    font-weight: 600;
}

.alert.success {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
}

.alert.error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.total {
    font-size: 24px;
    font-weight: 800;
    color: var(--primary);
    white-space: nowrap;
}

.item-form,
.quick-form,
.inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-top: 12px;
}

.item-form select {
    min-width: 260px;
    flex: 1 1 260px;
}

.item-form input,
.quick-form input,
.quick-form select,
.inline-form select {
    width: auto;
    min-width: 120px;
}

.inline {
    display: inline;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-direction: row;
    padding-top: 26px;
}

.checkbox-label input {
    width: auto;
}

.progress {
    height: 10px;
    border-radius: 999px;
    background: #e5e7eb;
    overflow: hidden;
    margin: 12px 0;
}

.progress span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #2563eb, #10b981);
}

.progress.tiny {
    width: 110px;
    height: 7px;
    margin: 0 0 4px;
}

.meta {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 7px 12px;
    margin: 14px 0;
}

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

.meta dd {
    margin: 0;
    font-weight: 600;
}

.login-page,
.plain-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: linear-gradient(135deg, #eff6ff, #f8fafc);
}

.login-card,
.card.narrow {
    width: min(460px, 100%);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 22px;
    padding: 28px;
    box-shadow: var(--shadow);
}

.login-brand {
    color: var(--text);
}

.login-brand span {
    color: var(--muted);
}

.login-card h1 {
    margin: 18px 0;
}

.demo-logins {
    margin-top: 18px;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
    color: var(--muted);
    line-height: 1.55;
    font-size: 13px;
}

@media (max-width: 900px) {
    .app-shell {
        display: block;
    }

    .sidebar {
        position: static;
        width: auto;
        height: auto;
    }

    .sidebar nav {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }

    .content {
        padding: 16px;
    }

    .topbar {
        align-items: flex-start;
        gap: 12px;
        flex-direction: column;
    }

    .grid-form {
        grid-template-columns: 1fr;
    }

    .span-2 {
        grid-column: auto;
    }

    .page-title h1 {
        font-size: 23px;
    }
}


.notice-card {
    background: #f8fafc;
}

.compact-actions {
    padding: 14px 18px;
}

.mini-list {
    border: 1px dashed var(--line);
    border-radius: 12px;
    padding: 10px 12px;
    margin: 12px 0;
    background: #f8fafc;
    color: var(--text);
}

.plain-report {
    min-height: 100vh;
    background: #f8fafc;
    padding: 24px;
}

.report-page {
    max-width: 1120px;
    margin: 0 auto;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 24px;
    box-shadow: var(--shadow);
}

.payment-grid {
    display: grid;
    grid-template-columns: 1fr 260px;
    gap: 24px;
    align-items: start;
}

.qr-card {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 14px;
    background: #fff;
}

.fake-qr {
    width: 220px;
    height: 220px;
    display: grid;
    grid-template-columns: repeat(11, 1fr);
    grid-template-rows: repeat(11, 1fr);
    gap: 3px;
    padding: 10px;
    border: 1px solid var(--line);
    background: #fff;
}

.fake-qr span {
    background: #fff;
}

.fake-qr span.on {
    background: #111827;
}

.meta.wide {
    grid-template-columns: 160px 1fr;
}

.invoice-template h1 {
    font-size: 25px;
    margin: 18px 0 8px;
}

.invoice-head,
.invoice-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.invoice-brand {
    justify-content: flex-start;
}

.invoice-brand img {
    width: 70px;
    height: 54px;
    object-fit: contain;
}

.invoice-brand strong,
.invoice-brand span {
    display: block;
}

.invoice-brand span {
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
}

.invoice-bank-table {
    min-width: 0;
    margin-bottom: 18px;
    border: 2px solid #111827;
}

.invoice-bank-table th,
.invoice-bank-table td {
    border: 1px solid #111827;
    padding: 8px 10px;
    background: #fff;
    color: #111827;
    text-transform: none;
    letter-spacing: 0;
    font-size: 13px;
}

.invoice-bank-table th {
    width: 120px;
    font-weight: 800;
}



.empty-state {
    border: 1px dashed var(--line);
    border-radius: 14px;
    padding: 18px;
    background: #f8fafc;
}

.empty-state strong {
    display: block;
    margin-bottom: 6px;
}

.gantt-wrap {
    overflow-x: auto;
    padding-bottom: 4px;
}

.gantt-range {
    min-width: 980px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 10px;
}

.gantt-range strong {
    color: var(--text);
    font-size: 14px;
}

.gantt-chart {
    min-width: 980px;
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
    background: #fff;
}

.gantt-row {
    display: grid;
    grid-template-columns: 280px minmax(620px, 1fr);
    min-height: 48px;
    border-bottom: 1px solid var(--line);
}

.gantt-row:last-child {
    border-bottom: 0;
}

.gantt-axis-row {
    min-height: 38px;
    background: #f8fafc;
}

.gantt-label {
    padding: 10px 12px;
    border-right: 1px solid var(--line);
    overflow: hidden;
}

.gantt-label strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gantt-label span {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gantt-label-child {
    padding-left: 28px;
    background: #fbfdff;
}

.gantt-line {
    position: relative;
    min-height: 48px;
    background:
        repeating-linear-gradient(
            to right,
            rgba(226, 232, 240, .75) 0,
            rgba(226, 232, 240, .75) 1px,
            transparent 1px,
            transparent 14.285%
        );
}

.gantt-axis {
    min-height: 38px;
    background: #f8fafc;
}

.gantt-axis span {
    position: absolute;
    top: 10px;
    transform: translateX(-1px);
    color: #64748b;
    font-size: 11px;
    white-space: nowrap;
}

.gantt-bar {
    position: absolute;
    top: 12px;
    height: 24px;
    border-radius: 999px;
    background: #2563eb;
    box-shadow: 0 8px 18px rgba(37, 99, 235, .20);
    overflow: hidden;
}

.gantt-bar span {
    display: block;
    padding: 5px 9px;
    color: #fff;
    font-size: 12px;
    line-height: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gantt-task {
    height: 18px;
    top: 15px;
    background: #64748b;
    box-shadow: 0 8px 18px rgba(100, 116, 139, .18);
}

.gantt-task span {
    padding: 2px 8px;
    font-size: 11px;
}

.gantt-status-active,
.gantt-status-in_progress {
    background: #2563eb;
}

.gantt-status-planned,
.gantt-status-new {
    background: #64748b;
}

.gantt-status-paused,
.gantt-status-blocked {
    background: #d97706;
}

.gantt-status-done,
.gantt-status-archived {
    background: #059669;
}

.gantt-today {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #dc2626;
    z-index: 2;
    opacity: .85;
}

@media (max-width: 1100px) {
    .gantt-range,
    .gantt-chart {
        min-width: 860px;
    }

    .gantt-row {
        grid-template-columns: 240px minmax(560px, 1fr);
    }
}

@media print {
    .sidebar,
    .topbar,
    .btn {
        display: none !important;
    }

    .plain-report {
        background: #fff;
        padding: 0;
    }

    .report-page {
        box-shadow: none;
        border: 0;
        max-width: none;
    }
}

@media (max-width: 900px) {
    .payment-grid {
        grid-template-columns: 1fr;
    }
}

/* Dynamic admin gantt */
.gantt-pro-card {
    padding: 20px;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
}

.gantt-pro-card-head {
    margin-bottom: 16px;
}

.gantt-head-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.gantt-pro-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.gantt-pro-toolbar-left,
.gantt-pro-toolbar-right {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.gantt-pro-chip {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 0 14px;
    border: 1px solid #dbe3ef;
    border-radius: 10px;
    background: #fff;
    color: #334155;
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

.gantt-pro-chip.icon-filter::before {
    content: "⏃";
    transform: rotate(180deg);
    font-size: 12px;
    margin-right: 8px;
    opacity: .7;
}

.gantt-pro-chip.muted-chip {
    background: #f8fafc;
}

.gantt-pro-scroll {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 8px;
    border-radius: 16px;
    scrollbar-width: thin;
    scrollbar-color: #94a3b8 #eef2f7;
    overscroll-behavior-x: contain;
}

.gantt-pro-scroll::-webkit-scrollbar {
    height: 10px;
}

.gantt-pro-scroll::-webkit-scrollbar-track {
    background: #eef2f7;
    border-radius: 999px;
}

.gantt-pro-scroll::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 999px;
}

.gantt-pro-board {
    width: max-content;
    max-width: none;
    border: 1px solid #dbe3ef;
    border-radius: 16px;
    overflow: hidden;
    background: #fff;
}

.gantt-pro-header,
.gantt-pro-row {
    display: grid;
    grid-template-columns: 260px 116px 58px minmax(680px, 1fr);
}

.gantt-pro-header {
    background: #f8fafc;
    border-bottom: 1px solid #dbe3ef;
}

.gantt-pro-header-left,
.gantt-pro-header-right {
    display: contents;
}

.gantt-title-col,
.gantt-status-col,
.gantt-progress-col {
    padding: 14px 12px;
    font-size: 13px;
    font-weight: 800;
    color: #334155;
    border-right: 1px solid #e6edf5;
    display: flex;
    align-items: center;
}

.gantt-progress-col {
    justify-content: center;
}

.gantt-pro-months {
    grid-column: 4;
    display: flex;
    border-bottom: 1px solid #e6edf5;
    background: #fff;
}

.gantt-pro-month {
    padding: 8px 0;
    text-align: center;
    font-size: 13px;
    font-weight: 800;
    color: #334155;
    border-right: 1px solid #edf2f7;
}

.gantt-pro-month:last-child {
    border-right: 0;
}

.gantt-pro-days {
    grid-column: 4;
    position: relative;
    display: grid;
    background: #fff;
}

.gantt-pro-day {
    min-height: 54px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-right: 1px solid #edf2f7;
    color: #334155;
}

.gantt-pro-day strong {
    font-size: 14px;
    line-height: 1;
}

.gantt-pro-day span {
    margin-top: 4px;
    font-size: 11px;
    color: #64748b;
}

.gantt-pro-day.is-weekend {
    background: #f8fbff;
}

.gantt-pro-day.is-today {
    background: #fff5f5;
}

.gantt-pro-body {
    background: #fff;
}

.gantt-pro-row {
    min-height: 56px;
    border-bottom: 1px solid #edf2f7;
}

.gantt-pro-row:last-child {
    border-bottom: 0;
}

.gantt-pro-row.is-project {
    background: linear-gradient(90deg, #ffffff 0%, #fcfdff 100%);
}

.gantt-pro-row.is-task:nth-child(odd) {
    background: #fbfdff;
}

.gantt-pro-cell {
    position: relative;
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-right: 1px solid #edf2f7;
}

.gantt-pro-cell:last-child {
    border-right: 0;
}

.gantt-row-title {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-width: 0;
}

.gantt-row-title strong,
.gantt-row-title span {
    display: block;
}

.gantt-row-title strong {
    max-width: 190px;
    font-size: 13px;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gantt-row-title span {
    max-width: 190px;
    margin-top: 3px;
    color: #64748b;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gantt-node {
    display: inline-block;
    flex: 0 0 auto;
}

.project-node {
    width: 12px;
    height: 12px;
    margin-top: 3px;
    border-radius: 3px;
    background: linear-gradient(135deg, #2563eb, #60a5fa);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .08);
}

.task-node {
    width: 8px;
    height: 8px;
    margin-top: 5px;
    margin-left: 18px;
    border-radius: 999px;
    background: #94a3b8;
    box-shadow: -12px 0 0 -6px #cbd5e1;
}

.gantt-pro-name.is-child {
    padding-left: 6px;
}

.gantt-pro-status {
    justify-content: center;
}

.gantt-pro-progress {
    justify-content: center;
    font-weight: 800;
    color: #475569;
}

.gantt-status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 78px;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid transparent;
}

.gantt-status-pill.status-active,
.gantt-status-pill.status-in_progress {
    background: #e8f0ff;
    border-color: #c7d9ff;
    color: #2455d6;
}

.gantt-status-pill.status-planned,
.gantt-status-pill.status-new {
    background: #eef2f7;
    border-color: #dbe2ea;
    color: #475569;
}

.gantt-status-pill.status-paused,
.gantt-status-pill.status-blocked {
    background: #fff7e8;
    border-color: #fde4b7;
    color: #b86a00;
}

.gantt-status-pill.status-done,
.gantt-status-pill.status-archived {
    background: #e7f8ef;
    border-color: #bce8cf;
    color: #0c8a53;
}

.gantt-pro-track {
    padding: 0;
    overflow: hidden;
}

.gantt-track-grid {
    position: absolute;
    inset: 0;
    display: grid;
}

.gantt-grid-day {
    border-right: 1px solid #edf2f7;
}

.gantt-grid-day.is-weekend {
    background: rgba(37, 99, 235, .035);
}

.gantt-today-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #ef4444;
    z-index: 2;
    transform: translateX(-1px);
}

.gantt-today-badge {
    position: absolute;
    top: 6px;
    transform: translateX(-50%);
    background: #ef4444;
    color: #fff;
    border-radius: 7px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 800;
    line-height: 1.4;
    z-index: 3;
    white-space: nowrap;
}

.gantt-bar {
    position: absolute;
    top: 13px;
    height: 28px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 8px 18px rgba(37, 99, 235, .16);
    z-index: 4;
}

.gantt-bar-fill {
    position: absolute;
    inset: 0 auto 0 0;
    border-radius: 8px;
    opacity: .92;
}

.gantt-bar-caption {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 1px 1px rgba(0, 0, 0, .10);
    white-space: nowrap;
}

.gantt-bar-project.status-active,
.gantt-bar-task.status-in_progress {
    background: #b9d1ff;
}
.gantt-bar-project.status-active .gantt-bar-fill,
.gantt-bar-task.status-in_progress .gantt-bar-fill {
    background: linear-gradient(90deg, #3d74e7, #5a94ff);
}

.gantt-bar-project.status-planned,
.gantt-bar-task.status-new {
    background: #dde4ee;
}
.gantt-bar-project.status-planned .gantt-bar-fill,
.gantt-bar-task.status-new .gantt-bar-fill {
    background: linear-gradient(90deg, #94a3b8, #c0cad8);
}

.gantt-bar-project.status-paused,
.gantt-bar-task.status-blocked {
    background: #ffe9c6;
}
.gantt-bar-project.status-paused .gantt-bar-fill,
.gantt-bar-task.status-blocked .gantt-bar-fill {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.gantt-bar-project.status-done,
.gantt-bar-project.status-archived,
.gantt-bar-task.status-done {
    background: #ccefdc;
}
.gantt-bar-project.status-done .gantt-bar-fill,
.gantt-bar-project.status-archived .gantt-bar-fill,
.gantt-bar-task.status-done .gantt-bar-fill {
    background: linear-gradient(90deg, #17a866, #37c87c);
}

@media (max-width: 1100px) {
    .gantt-pro-toolbar {
        align-items: flex-start;
    }
}

.gantt-today-badge-head {
    top: 4px;
}


/* Anti-overflow tuning for dashboard and Gantt */
@media (max-width: 1300px) {
    .content {
        padding: 18px;
    }

    .gantt-pro-header,
    .gantt-pro-row {
        grid-template-columns: 235px 106px 52px minmax(600px, 1fr);
    }

    .gantt-title-col,
    .gantt-status-col,
    .gantt-progress-col,
    .gantt-pro-cell {
        padding-left: 10px;
        padding-right: 10px;
    }

    .gantt-row-title strong,
    .gantt-row-title span {
        max-width: 165px;
    }

    .gantt-status-pill {
        min-width: 74px;
        font-size: 11px;
    }
}

@media (max-width: 900px) {
    html,
    body {
        overflow-x: hidden;
    }

    .app-shell {
        max-width: 100%;
        overflow-x: hidden;
    }

    .content {
        max-width: 100%;
        overflow-x: hidden;
    }

    .gantt-pro-toolbar {
        align-items: stretch;
    }

    .gantt-pro-toolbar-left,
    .gantt-pro-toolbar-right {
        width: 100%;
    }

    .gantt-pro-chip {
        min-height: 34px;
        padding: 0 11px;
        font-size: 12px;
    }

    .gantt-pro-header,
    .gantt-pro-row {
        grid-template-columns: 210px 96px 48px minmax(520px, 1fr);
    }

    .gantt-pro-card {
        padding: 14px;
    }
}


/* Gantt controls: working buttons and panels */
.gantt-pro-card[data-gantt] {
    overflow: hidden;
}

.gantt-pro-toolbar {
    align-items: flex-start;
}

.gantt-select-form {
    display: inline-flex;
    align-items: center;
    margin: 0;
}

.gantt-select-form select,
.gantt-panel select,
.gantt-panel input[type="number"] {
    min-height: 38px;
    border: 1px solid #dbe3ef;
    border-radius: 10px;
    background: #fff;
    color: #334155;
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

.gantt-project-select {
    width: auto;
    min-width: 136px;
    max-width: 260px;
}

.gantt-pro-chip,
button.gantt-pro-chip,
a.gantt-pro-chip {
    border: 1px solid #dbe3ef;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    font: inherit;
    font-weight: 700;
}

button.gantt-pro-chip {
    appearance: none;
}

.gantt-pro-chip:hover,
.gantt-pro-chip.is-active {
    border-color: #bcd0f7;
    background: #eef4ff;
    color: #1e40af;
}

.gantt-pro-toolbar-right .gantt-pro-chip.is-active {
    box-shadow: inset 0 0 0 1px rgba(37, 99, 235, .18);
}

.gantt-panels {
    display: grid;
    gap: 10px;
    margin: 0 0 12px;
}

.gantt-panel {
    display: none;
    grid-template-columns: repeat(4, minmax(170px, 1fr));
    gap: 12px;
    align-items: end;
    padding: 12px;
    border: 1px solid #dbe3ef;
    border-radius: 14px;
    background: #f8fafc;
}

.gantt-panel.is-open {
    display: grid;
}

.gantt-panel label {
    gap: 6px;
    margin: 0;
    color: #334155;
    font-size: 12px;
}

.gantt-panel .gantt-check {
    min-height: 38px;
    align-items: center;
    padding-top: 18px;
    font-size: 13px;
}

.gantt-panel .gantt-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

.gantt-panel-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.gantt-panel-note {
    color: #64748b;
    font-size: 12px;
    line-height: 1.45;
}

.gantt-pro-scroll {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scrollbar-gutter: stable;
}

.gantt-pro-scroll::-webkit-scrollbar {
    height: 10px;
}

.gantt-pro-scroll::-webkit-scrollbar-track {
    background: #eef2f7;
    border-radius: 999px;
}

.gantt-pro-scroll::-webkit-scrollbar-thumb {
    background: #9aa7b8;
    border-radius: 999px;
}

.gantt-pro-scroll::-webkit-scrollbar-thumb:hover {
    background: #7b8797;
}

.gantt-pro-days,
.gantt-track-grid {
    min-width: 0;
}

.gantt-today-pulse .gantt-today-line,
.gantt-today-pulse .gantt-today-badge {
    animation: ganttTodayPulse 1.2s ease;
}

@keyframes ganttTodayPulse {
    0%, 100% {
        box-shadow: none;
        opacity: .95;
    }
    50% {
        box-shadow: 0 0 0 8px rgba(239, 68, 68, .16);
        opacity: 1;
    }
}

@media (max-width: 1100px) {
    .gantt-panel {
        grid-template-columns: repeat(2, minmax(180px, 1fr));
    }
}

@media (max-width: 700px) {
    .gantt-panel {
        grid-template-columns: 1fr;
    }

    .gantt-panel .gantt-check {
        padding-top: 0;
    }

    .gantt-pro-toolbar-left,
    .gantt-pro-toolbar-right {
        gap: 8px;
    }

    .gantt-project-select {
        width: 100%;
        max-width: none;
    }

    .gantt-select-form {
        flex: 1 1 100%;
    }
}


/* Sidebar fixed paint fix.
   Левое меню фиксируется на весь экран, поэтому при прокрутке
   оно больше не заканчивается посередине страницы и не оставляет
   незакрашенную область слева. */
:root {
    --sidebar-width: 264px;
}

html,
body {
    min-height: 100%;
    overflow-x: hidden;
}

.app-shell {
    display: block;
    min-height: 100vh;
    width: 100%;
    max-width: 100%;
    overflow: visible;
}

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    height: auto;
    min-height: 100vh;
    z-index: 100;
    background: #0f172a;
    overflow-y: auto;
    overflow-x: hidden;
}

.content {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    max-width: none;
    min-width: 0;
    overflow-x: hidden;
}

@media (max-width: 900px) {
    .app-shell {
        display: block;
        overflow: visible;
    }

    .sidebar {
        position: static;
        width: 100%;
        height: auto;
        min-height: 0;
        max-height: none;
        inset: auto;
    }

    .content {
        margin-left: 0;
        width: 100%;
        max-width: 100%;
        padding: 16px;
    }
}


.project-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.mini-project-card {
    display: grid;
    gap: 5px;
    padding: 14px;
    border: 1px solid #dbe3ef;
    border-radius: 14px;
    background: #fff;
    text-decoration: none;
    box-shadow: 0 6px 18px rgba(15, 23, 42, .04);
}

.mini-project-card:hover,
.mini-project-card.active {
    border-color: #93c5fd;
    background: #eff6ff;
}

.mini-project-card strong {
    color: #1f2937;
}

.mini-project-card span,
.mini-project-card small {
    color: #64748b;
}

.hotline-new-row td,
.hotline-new-row strong {
    color: #dc2626;
}

.hotline-new-row .badge {
    background: #fef2f2;
    color: #b91c1c;
}


/* Settings page */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
    gap: 18px;
    margin-bottom: 18px;
}

.settings-card {
    margin-bottom: 18px;
}

.settings-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.settings-card-head h2 {
    margin-bottom: 4px;
}

.switch-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #f8fafc;
    font-size: 13px;
    font-weight: 700;
}

.switch-label input[type="checkbox"] {
    width: auto;
}

.settings-form textarea {
    min-height: 94px;
}


.settings-subsection {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.settings-card-head-compact {
    margin-bottom: 10px;
}

.settings-card-head-compact h3 {
    margin: 0 0 4px;
    font-size: 16px;
}

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

.settings-proxy-grid label:nth-child(2) {
    grid-column: span 1;
}

@media (max-width: 760px) {
    .settings-proxy-grid {
        grid-template-columns: 1fr;
    }
}

.settings-actions {
    margin-top: 14px;
}

.settings-help {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 14px;
}

.settings-help div {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px;
    background: #f8fafc;
}

.settings-help strong,
.settings-help span {
    display: block;
}

.settings-help span {
    margin-top: 6px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.row-actions {
    display: flex;
    flex-direction: column;
    gap: 7px;
    align-items: flex-start;
}

.row-actions .inline-form {
    margin-top: 0;
}

.empty-state span {
    display: block;
    margin-top: 4px;
}

/* Payment document styled by the uploaded payment sample */
.payment-report-body {
    background: #fff;
    padding: 0;
}

.payment-sample-page {
    width: min(940px, calc(100vw - 44px));
    max-width: calc(100vw - 44px);
    min-height: auto;
    margin: 26px auto 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    box-sizing: border-box;
    overflow: hidden;
    color: #111;
    font-family: Arial, Helvetica, sans-serif;
    font-size: clamp(7px, 0.94vw, 12px);
    line-height: 1.08;
}

.payment-sample-page,
.payment-sample-page *,
.payment-sample-page *::before,
.payment-sample-page *::after {
    box-sizing: border-box;
}

.payment-print-actions {
    position: fixed;
    right: 24px;
    top: 20px;
    z-index: 10;
    text-align: right;
    margin: 0;
}

.payment-bank-box,
.payment-meta-table,
.payment-items-table {
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
    color: #111;
    table-layout: fixed;
}

.payment-bank-box td {
    border: 1.2px solid #111;
    padding: .16em .22em;
    vertical-align: top;
    background: #fff;
    overflow-wrap: anywhere;
    word-break: break-word;
    font-size: .8em;
}

.payment-bank-box .bank-name {
    height: 2.6em;
}

.payment-bank-box .bank-label,
.payment-bank-box .bank-value {
    font-size: .86em;
    font-weight: 400;
}

.payment-bank-box .bank-account {
    vertical-align: top;
}

.payment-bank-box .recipient-name {
    height: 5.9em;
    vertical-align: middle;
    font-size: .92em;
}

.payment-bank-box .bank-bottom-label {
    vertical-align: bottom;
}

.payment-purpose-text {
    height: 5.3em;
    font-size: .84em;
}
.payment-bank-box tr.purpose-value-row td,
.payment-bank-box tr.purpose-label-row td {
    border-bottom: 1.2px solid #111;
}


.bank-qr-cell {
    width: 12%;
    min-width: 12%;
    max-width: 12%;
    text-align: center;
    vertical-align: top !important;
    overflow: hidden;
}

.payment-qr {
    width: min(7.2em, 86%);
    aspect-ratio: 1 / 1;
    display: grid;
    grid-template-columns: repeat(14, 1fr);
    grid-template-rows: repeat(14, 1fr);
    gap: 1px;
    margin: .12em auto .6em;
    padding: .24em;
    border: 1.2px solid #111;
    background: #fff;
}

.payment-qr span { background: #fff; }
.payment-qr span.on { background: #111; }

.qr-caption {
    font-size: .8em;
    line-height: 1.15;
}

.payment-title {
    margin: .58em 0 .56em;
    padding: 0 0 .48em;
    border-bottom: 3px solid #111;
    font-size: 1.88em;
    line-height: 1.08;
    color: #111;
    font-weight: 700;
}

.payment-meta-table {
    margin-bottom: .55em;
}

.payment-meta-table th,
.payment-meta-table td {
    border: 0;
    padding: .24em 0;
    background: #fff;
    color: #111;
    font-size: .9em;
    text-transform: none;
    letter-spacing: 0;
    vertical-align: top;
}

.payment-meta-table th {
    width: 19.5%;
    text-align: left;
    font-weight: 400;
}

.payment-meta-table td {
    font-weight: 700;
}

.payment-items-table { margin-top: .4em; }

.payment-items-table th,
.payment-items-table td {
    border: 1.4px solid #111;
    padding: .2em .24em;
    background: #fff;
    color: #111;
    text-transform: none;
    letter-spacing: 0;
    font-size: .86em;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.payment-items-table th {
    text-align: center;
    font-weight: 700;
}

.payment-items-table .col-num,
.payment-items-table .center {
    text-align: center;
}

.payment-items-table .num {
    text-align: right;
    white-space: nowrap;
}

.payment-items-table tbody td {
    min-height: 2.05em;
}
.payment-items-table tbody tr.payment-item-row td {
    border-bottom: 1.2px solid #111;
}


.payment-items-table tfoot td {
    border-top: 0;
    border-bottom: 0;
    border-left: 0;
    border-right: 0;
    padding: .1em .32em;
    font-weight: 700;
    background: #fff;
}

.payment-items-table tfoot tr:first-child td { padding-top: .18em; }
.payment-items-table tfoot tr:last-child td { padding-bottom: .18em; }
.payment-items-table tfoot .total-label { text-align: right; }

.payment-summary,
.payment-words,
.payment-warning,
.payment-note {
    margin: .55em 0 0;
    color: #111;
    font-size: .9em;
}

.payment-words strong {
    font-size: 1em;
    font-weight: 700;
}

.payment-warning {
    color: #ff0000;
    font-weight: 700;
    max-width: 78%;
}

.payment-note {
    max-width: 74%;
}

.payment-signature {
    margin-top: .72em;
    padding-top: .6em;
    border-top: 2px solid #111;
    display: grid;
    grid-template-columns: 11% 12% 13% 1fr;
    gap: .7em;
    align-items: end;
    color: #111;
    font-size: .9em;
    font-weight: 700;
}

.payment-signature .sign-role { line-height: 1.05; }

.payment-signature .sign-line {
    border-bottom: 2px solid #111;
    height: 1.22em;
    text-align: center;
    font-size: .58em;
    font-weight: 400;
}

.payment-signature .sign-line span {
    position: relative;
    top: 1.38em;
}

.payment-signature .sign-name { padding-bottom: .2em; }
.payment-signature .sign-line.wide { min-width: 18em; }

@media screen and (max-width: 900px) {
    .payment-report-body { padding: 0 !important; }
    .payment-sample-page {
        width: calc(100vw - 28px);
        max-width: calc(100vw - 28px);
        margin-top: 30px;
        font-size: clamp(6px, 1.05vw, 9px);
    }
    .payment-warning,
    .payment-note { max-width: 100%; }
    .payment-signature { grid-template-columns: 12% 12% 13% 1fr; }
    .payment-signature .sign-line.wide { min-width: 12em; }
}

@page {
    size: A4 portrait;
    margin: 5mm;
}

@media print {
    html,
    body {
        width: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
    }

    .plain-report,
    .payment-report-body {
        padding: 0 !important;
        margin: 0 !important;
        background: #fff !important;
    }

    .report-page,
    .payment-sample-page {
        width: 100% !important;
        max-width: 100% !important;
        min-height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        overflow: hidden !important;
        font-size: 8.8px !important;
    }

    .payment-print-actions {
        display: none !important;
    }

    .payment-report-body * {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}




/* v10 payment print fixes: strict A4 width and required bottom borders */
.payment-bank-box,
.payment-meta-table,
.payment-items-table {
    min-width: 0 !important;
}

.payment-bank-box tr.purpose-value-row td,
.payment-bank-box tr.purpose-label-row td {
    border-bottom: 1.4px solid #111 !important;
}

.payment-items-table thead th,
.payment-items-table tbody tr.payment-item-row td {
    border-bottom: 1.4px solid #111 !important;
}

@media print {
    .payment-sample-page {
        width: 100% !important;
        max-width: 100% !important;
        overflow: visible !important;
    }

    .payment-bank-box,
    .payment-meta-table,
    .payment-items-table {
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* Project archive, act receipts and grouped files */
.page-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 0 18px;
}

.page-tabs a {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 9px 14px;
    border: 1px solid #d7deea;
    background: #fff;
    color: #24324a;
    text-decoration: none;
    font-weight: 700;
}

.page-tabs a.active {
    border-color: #8fb5ff;
    background: #eef5ff;
    color: #1554c5;
}

.work-progress-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 22px;
    margin: 8px 0 16px;
    font-size: 14px;
}

.work-progress-summary span {
    white-space: nowrap;
}

.document-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
    margin-bottom: 8px;
}

.receipt-upload-form {
    display: grid;
    gap: 8px;
    min-width: 260px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #e1e6ef;
}

.receipt-upload-form label {
    display: grid;
    gap: 5px;
    font-size: 12px;
    font-weight: 700;
}

.receipt-upload-form input[type="file"] {
    width: 100%;
}

.paid-label {
    display: inline-flex;
    margin-top: 5px;
    padding: 3px 8px;
    background: #e9f8ef;
    border: 1px solid #9eddb5;
    color: #176b38;
    font-size: 12px;
    font-weight: 800;
}

.archive-admin-actions {
    display: grid;
    gap: 12px;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid #e0e5ed;
}

.archive-files > div {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
}

.danger-btn {
    background: #fff1f1 !important;
    border-color: #e7a3a3 !important;
    color: #ad2020 !important;
}

.foreman-estimate-card {
    border-left: 4px solid #2d6cdf;
}

.estimate-project-group + .estimate-project-group {
    margin-top: 16px;
}

.client-act-form {
    display: grid;
    grid-template-columns: minmax(120px, 160px) minmax(150px, 1fr) auto;
    gap: 8px;
    margin-top: 10px;
}

@media (max-width: 900px) {
    .client-act-form {
        grid-template-columns: 1fr;
    }

    .receipt-upload-form {
        min-width: 220px;
    }
}

.contract-template-form {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e1e6ef;
}

.company-share-form {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
}

.compact-money-input {
    width: 140px;
    min-width: 120px;
}

@media (max-width: 900px) {
    .company-share-form {
        flex-wrap: wrap;
    }

    .compact-money-input {
        width: 100%;
    }
}
