:root {
    --bg: #f3f5f8;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --line: #e4e9f0;
    --text: #13253d;
    --muted: #6d7d8f;

    --brand-dark: #112b49;
    --brand-dark-2: #18385d;
    --brand-accent: #295b8f;
    --brand-soft: #e9f1fb;
    --brand-soft-text: #204d7b;

    --success-bg: #e7f4ec;
    --success-text: #2b6b46;
    --warning-bg: #fff3df;
    --warning-text: #9b6900;
    --danger-bg: #fdebec;
    --danger-text: #a33a45;
    --progress-bg: #eef2f7;
    --progress-text: #53657b;

    --shadow: 0 18px 40px rgba(17, 40, 66, 0.08);

    --radius-xl: 24px;
    --radius-lg: 18px;
    --radius-md: 16px;
    --radius-sm: 12px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
}

body {
    min-height: 100vh;
}

a {
    text-decoration: none;
    color: inherit;
}

.layout {
    min-height: 100vh;
    display: flex;
    width: 100%;
}

.sidebar {
    width: 320px;
    flex: 0 0 320px;
    background: linear-gradient(180deg, var(--brand-dark) 0%, var(--brand-dark-2) 100%);
    color: #fff;
    padding: 24px 20px;
    overflow-y: auto;
}

.sidebar-link {
    display: block;
    padding: 13px 14px;
    border-radius: 12px;
    color: rgba(255,255,255,0.92);
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 10px;
}

.sidebar-link:hover {
    background: rgba(255,255,255,0.08);
}

.sidebar-link.active {
    background: #fff;
    color: var(--brand-dark);
}

.nav-section-title {
    margin: 24px 0 12px;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(255,255,255,0.62);
}

.project-group {
    margin-bottom: 14px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 16px;
    padding: 12px;
    background: rgba(255,255,255,0.04);
}

.project-name {
    font-size: 14px;
    font-weight: 800;
    color: #fff;
    margin-bottom: 10px;
    line-height: 1.4;
}

.km-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.km-link {
    display: block;
    padding: 10px 12px;
    border-radius: 10px;
    color: rgba(255,255,255,0.86);
    font-weight: 700;
    font-size: 14px;
}

.km-link:hover {
    background: rgba(255,255,255,0.08);
}

.km-link.active {
    background: #fff;
    color: var(--brand-dark);
}

.main {
    flex: 1;
    min-width: 0;
    padding: 32px;
    overflow-x: hidden;
}

.back-link {
    display: inline-block;
    margin-bottom: 18px;
    color: var(--brand-accent);
    font-size: 14px;
    font-weight: 700;
}

.tag {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 999px;
    background: #e8edf4;
    color: #274564;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 14px;
}

.title {
    margin: 0;
    font-size: 40px;
    line-height: 1.08;
    font-weight: 800;
    color: #10233b;
}

.subtitle {
    margin: 12px 0 0;
    font-size: 18px;
    color: var(--muted);
}

.hero {
    background: linear-gradient(135deg, var(--brand-dark) 0%, var(--brand-accent) 100%);
    color: #fff;
    border-radius: var(--radius-xl);
    padding: 30px 32px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.hero h3 {
    margin: 0;
    font-size: 28px;
    line-height: 1.18;
    font-weight: 800;
}

.hero p {
    margin: 12px 0 0;
    color: rgba(255,255,255,0.88);
    font-size: 15px;
    line-height: 1.5;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    padding: 28px;
    box-shadow: var(--shadow);
}

.panel-tag {
    margin: 0 0 8px;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

.panel h3 {
    margin: 0 0 20px;
    font-size: 28px;
    line-height: 1.15;
    font-weight: 800;
    color: #10233b;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    margin-top: 24px;
    margin-bottom: 24px;
}

.summary-card,
.status-summary-card,
.status-card,
.stage-card,
.project-card,
.km-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.summary-card,
.status-summary-card,
.status-card {
    padding: 18px;
}

.summary-card span,
.status-summary-card span,
.status-card span {
    display: block;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    font-weight: 800;
    margin-bottom: 10px;
}

.summary-card strong,
.status-summary-card strong,
.status-card strong {
    display: block;
    font-size: 30px;
    font-weight: 800;
    color: #10233b;
}

.summary-card small {
    display: block;
    margin-top: 8px;
    color: var(--muted);
    font-size: 14px;
}

.projects-grid,
.km-grid,
.stage-grid,
.status-summary-grid,
.status-cards {
    display: grid;
    gap: 18px;
}

.projects-grid,
.km-grid {
    margin-top: 24px;
}

.status-summary-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 24px;
}

.status-cards {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    margin-bottom: 24px;
}

.stage-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 24px;
}

.project-card {
    display: block;
    padding: 26px;
    transition: 0.2s ease;
}

.project-card:hover {
    transform: translateY(-2px);
}

.project-card h3 {
    margin: 0 0 10px;
    font-size: 28px;
    line-height: 1.15;
    color: #10233b;
    font-weight: 800;
}

.project-card p {
    margin: 0 0 18px;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.5;
}

.meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.meta-badge,
.km-badge,
.status-badge,
.status-pill,
.pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    white-space: nowrap;
}

.meta-badge,
.km-badge,
.pill {
    padding: 8px 12px;
    border-radius: 999px;
    background: var(--brand-soft);
    color: var(--brand-soft-text);
    font-size: 13px;
}

.status-badge,
.status-pill {
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 13px;
}

.status-progress,
.status-pill-progress,
.status-item-progress {
    background: var(--progress-bg);
    color: var(--progress-text);
}

.status-review,
.status-pill-review,
.status-item-done {
    background: var(--warning-bg);
    color: var(--warning-text);
}

.status-checked,
.status-pill-checked,
.status-item-approved {
    background: var(--success-bg);
    color: var(--success-text);
}

.status-item-not-done {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.km-card {
    padding: 24px;
}

.km-top,
.top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
}

.top {
    margin-bottom: 24px;
}

.top-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: stretch;
}

.km-title {
    margin: 0 0 8px;
    font-size: 28px;
    line-height: 1.15;
    font-weight: 800;
    color: #10233b;
}

.km-subtitle {
    margin: 0;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.5;
}

.km-tonnage,
.counter,
.info-box,
.info-card,
.note-box,
.mini-card,
.stage-box,
.preview-box,
.inline-card,
.filter-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
}

.km-tonnage,
.counter,
.info-box,
.info-card,
.note-box,
.mini-card,
.stage-box,
.preview-box {
    padding: 16px 18px;
}

.km-tonnage {
    min-width: 220px;
    text-align: right;
    background: var(--surface-2);
}

.km-tonnage span,
.counter span,
.info-box span,
.info-card span,
.preview-box span {
    display: block;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    font-weight: 800;
    margin-bottom: 8px;
}

.km-tonnage strong,
.counter strong,
.info-box strong,
.info-card strong,
.preview-box strong {
    display: block;
    font-size: 28px;
    font-weight: 800;
    color: #10233b;
}

.counter {
    min-width: 210px;
    text-align: right;
}

.preview-box {
    margin-bottom: 20px;
    background: var(--brand-soft);
    border-color: #d8e5f7;
}

.stages-grid,
.info-grid,
.info-strip,
.form-grid,
.inline-fields-2,
.inline-fields-3,
.inline-fields-10 {
    display: grid;
    gap: 16px;
}

.stages-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.info-grid,
.form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.info-strip {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 20px;
}

.inline-fields-2 {
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
}

.inline-fields-3 {
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr);
}

.inline-fields-10 {
    grid-template-columns:
        minmax(160px, 1fr)
        minmax(160px, 1fr)
        minmax(140px, 1fr)
        minmax(110px, 0.8fr)
        minmax(110px, 0.8fr)
        minmax(140px, 1fr)
        minmax(180px, 1.2fr)
        minmax(180px, 1.2fr)
        minmax(160px, 1fr)
        minmax(160px, 1fr);
    gap: 14px;
}

.stage-box h4,
.stage-card h4 {
    margin: 0 0 12px;
    font-size: 16px;
    line-height: 1.35;
    font-weight: 800;
    color: #10233b;
}

.stage-box .percent {
    font-size: 26px;
    font-weight: 800;
    color: var(--brand-soft-text);
    margin-bottom: 8px;
}

.stage-box .tonnage,
.task-note,
.note-box p,
.mini-card p {
    font-size: 14px;
    color: var(--muted);
    line-height: 1.5;
}

.stage-card {
    padding: 22px;
}

.stage-card h4 {
    font-size: 22px;
    margin-bottom: 18px;
}

.stage-stats,
.mini-list,
.inline-grid,
.messages {
    display: grid;
    gap: 12px;
}

.stage-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    font-size: 16px;
    color: var(--muted);
}

.stage-row strong {
    font-size: 16px;
    font-weight: 800;
    text-align: right;
    white-space: nowrap;
}

.field-wrap {
    display: grid;
    gap: 8px;
}

.field-wrap label {
    font-size: 13px;
    font-weight: 800;
    color: #445970;
}

input,
select,
textarea,
.form-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #d8e1eb;
    border-radius: 12px;
    background: #fff;
    color: var(--text);
    font-size: 14px;
    outline: none;
    font-family: Arial, Helvetica, sans-serif;
}

textarea {
    resize: vertical;
    min-height: 100px;
}

.filter-panel {
    padding: 22px 24px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.mode-switch {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.mode-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    border-radius: 12px;
    background: #eef2f7;
    color: var(--progress-text);
    font-size: 14px;
    font-weight: 800;
}

.mode-link.active {
    background: var(--brand-dark);
    color: #fff;
}

.date-form,
.actions,
.submit-bottom,
.section-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: flex-end;
}

.actions,
.submit-bottom {
    justify-content: flex-end;
}

.section-footer {
    justify-content: flex-start;
    margin-top: 18px;
}

.action-link,
.action-button,
.submit-button,
.save-button,
.apply-button,
.add-button,
.remove-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    font-family: Arial, Helvetica, sans-serif;
    white-space: nowrap;
}

.action-link,
.action-button-primary,
.submit-button,
.save-button {
    padding: 14px 18px;
    background: linear-gradient(135deg, var(--brand-dark) 0%, var(--brand-accent) 100%);
    color: #fff;
    box-shadow: var(--shadow);
}

.apply-button,
.add-button {
    padding: 12px 16px;
    background: var(--brand-soft);
    color: var(--brand-soft-text);
}

.remove-button {
    padding: 10px 14px;
    background: var(--danger-bg);
    color: var(--danger-text);
    margin-top: 14px;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--surface-2);
}

table {
    width: 100%;
    min-width: 1200px;
    border-collapse: collapse;
    table-layout: auto;
    background: #fff;
}

thead {
    background: #f7f9fc;
}

th,
td {
    padding: 16px 18px;
    border-bottom: 1px solid #edf2f7;
    vertical-align: middle;
    font-size: 14px;
    line-height: 1.35;
    white-space: normal;
    word-break: keep-all;
    overflow-wrap: break-word;
}

th {
    text-align: left;
    font-size: 13px;
    color: #66778a;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 800;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: #fbfdff;
}

td .status-badge,
td .meta-badge,
td .pill,
td .km-badge {
    white-space: nowrap;
}

td:first-child,
th:first-child {
    padding-left: 22px;
}

td:last-child,
th:last-child {
    padding-right: 22px;
}

.date-cell,
.axis-cell {
    white-space: normal;
    word-break: keep-all;
    overflow-wrap: break-word;
    font-weight: 700;
    color: #10233b;
}

.task-name,
.inline-card-title {
    font-weight: 800;
    color: #10233b;
}

.task-name {
    font-size: 17px;
    line-height: 1.35;
    margin-bottom: 6px;
}

.inline-card {
    background: var(--surface-2);
    padding: 18px;
}

.inline-card-title {
    margin: 0 0 14px;
    font-size: 16px;
}

.note-box strong,
.mini-card strong {
    display: block;
    font-weight: 800;
}

.note-box strong {
    margin-bottom: 8px;
    font-size: 15px;
}

.mini-card strong {
    font-size: 16px;
    margin-bottom: 6px;
}

.message-success,
.errors,
.status-help,
.empty {
    border-radius: 14px;
    font-size: 14px;
}

.message-success {
    padding: 14px 16px;
    background: var(--success-bg);
    color: var(--success-text);
    font-weight: 700;
}

.errors {
    margin-top: 8px;
    padding: 10px 12px;
    background: var(--danger-bg);
    color: var(--danger-text);
    font-weight: 700;
}

.status-help {
    margin-top: 10px;
    padding: 12px 14px;
    background: #fff8eb;
    color: #8b6400;
    line-height: 1.5;
}

.empty {
    padding: 40px;
    text-align: center;
    border: 1px dashed var(--line);
    background: #fbfcfe;
    color: var(--muted);
}

.is-hidden {
    display: none !important;
}

@media (max-width: 1500px) {
    .inline-fields-10 {
        grid-template-columns: repeat(2, minmax(240px, 1fr));
    }
}

@media (max-width: 1400px) {
    .stages-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .summary-grid,
    .stage-grid,
    .status-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 1300px) {
    .grid,
    .info-grid,
    .form-grid,
    .info-strip,
    .inline-fields-3,
    .inline-fields-2 {
        grid-template-columns: 1fr;
    }

    .status-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .top,
    .km-top {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 1200px) {
    .layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        flex: none;
    }

    .km-tonnage,
    .counter {
        width: 100%;
        text-align: left;
    }
}

@media (max-width: 768px) {
    .main {
        padding: 18px;
    }

    .title {
        font-size: 30px;
    }

    .hero,
    .panel,
    .project-card,
    .km-card,
    .summary-card,
    .status-summary-card,
    .status-card,
    .stage-card,
    .filter-panel {
        padding: 18px;
    }

    .projects-grid,
    .summary-grid,
    .stage-grid,
    .status-summary-grid,
    .status-cards,
    .stages-grid,
    .info-grid,
    .form-grid,
    .info-strip,
    .inline-fields-10 {
        grid-template-columns: 1fr;
    }

    th,
    td {
        padding: 14px 16px;
    }

    .project-card h3,
    .km-title,
    .panel h3,
    .hero h3,
    .stage-card h4 {
        font-size: 24px;
    }
}

.sidebar {
    display: flex;
    flex-direction: column;
}

.sidebar form[action$="/logout/"],
.sidebar-account-logout {
    margin: auto 0 0;
    padding-top: 18px;
}

.sidebar form[action$="/logout/"] button,
.sidebar-account-logout-button {
    width: 100%;
    display: block;
    appearance: none;
    border: none;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.10);
    color: rgba(255, 255, 255, 0.92);
    padding: 13px 14px;
    font-size: 14px;
    font-weight: 800;
    line-height: 1.35;
    text-align: left;
    cursor: pointer;
    font-family: Arial, Helvetica, sans-serif;
    transition: background 0.15s ease, transform 0.15s ease;
}

.sidebar form[action$="/logout/"] button:hover,
.sidebar-account-logout-button:hover {
    background: rgba(255, 255, 255, 0.16);
    transform: translateY(-1px);
}