:root {
    --bg: #0f1115;
    --panel: #171a21;
    --panel-soft: #20242d;
    --text: #f5f7fb;
    --muted: #aeb6c6;
    --line: #303542;
    --red: #d81324;
    --red-dark: #a70f1c;
    --success: #27ae60;
    --warning: #f1a208;
    --danger: #e63946;
    --info: #3b82f6;
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: #f4f5f8;
    color: #1c2230;
}

a {
    color: inherit;
    text-decoration: none;
}

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #090a0d, #1b1f2a);
    padding: 24px;
}

.login-card {
    width: min(420px, 100%);
    background: #fff;
    border-radius: var(--radius);
    padding: 30px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, .28);
}

.login-brand {
    color: var(--red);
    font-weight: 800;
    font-size: 26px;
    margin-bottom: 8px;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
    background: var(--bg);
    color: var(--text);
    padding: 18px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 19px;
    padding: 8px 10px 20px;
}

.brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 7px;
    background: var(--red);
    display: grid;
    place-items: center;
    color: #fff;
}

.nav-group-title {
    color: #747e91;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: .08em;
    margin: 18px 10px 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: #d7dce7;
    margin-bottom: 3px;
}

.nav-link:hover,
.nav-link.active {
    background: var(--panel-soft);
    color: #fff;
}

.nav-link.active {
    border-left: 3px solid var(--red);
}

.content {
    min-width: 0;
    padding: 24px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.page-title {
    margin: 0;
    font-size: 26px;
    color: #12151d;
}

.muted {
    color: #697386;
}

.grid {
    display: grid;
    gap: 16px;
}

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

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

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

.card {
    background: #fff;
    border: 1px solid #e3e6ed;
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: 0 8px 30px rgba(15, 17, 21, .05);
}

.metric {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    min-height: 104px;
}

.metric strong {
    display: block;
    font-size: 28px;
    margin-top: 8px;
}

.metric-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    display: grid;
    place-items: center;
    background: #fff1f2;
    color: var(--red);
    font-weight: 800;
}

.toolbar {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: end;
}

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

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

.form-grid .span-3 {
    grid-column: span 3;
}

.form-grid .span-4 {
    grid-column: 1 / -1;
}

label {
    display: grid;
    gap: 6px;
    font-size: 13px;
    color: #354052;
    font-weight: 700;
}

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

textarea {
    min-height: 92px;
    resize: vertical;
}

.btn {
    border: 0;
    border-radius: var(--radius);
    padding: 10px 14px;
    cursor: pointer;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #e7eaf0;
    color: #171a21;
}

.btn:hover {
    filter: brightness(.96);
}

.btn-primary {
    background: var(--red);
    color: #fff;
}

.btn-dark {
    background: #111318;
    color: #fff;
}

.btn-outline {
    background: #fff;
    border: 1px solid #d6dae3;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-sm {
    padding: 7px 10px;
    font-size: 12px;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th,
td {
    text-align: left;
    padding: 12px 10px;
    border-bottom: 1px solid #edf0f5;
    vertical-align: top;
}

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

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 5px 9px;
    font-size: 12px;
    font-weight: 800;
    background: #e8edf5;
    color: #354052;
}

.badge.success {
    background: #e7f7ee;
    color: #146c3d;
}

.badge.warning {
    background: #fff4d8;
    color: #896000;
}

.badge.danger {
    background: #ffe7ea;
    color: #9d1624;
}

.badge.info {
    background: #e7f0ff;
    color: #1d4ed8;
}

.actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.inline-check {
    display: inline-flex;
    grid-template-columns: none;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 700;
}

.inline-check input {
    width: auto;
}

.alert {
    padding: 12px 14px;
    border-radius: var(--radius);
    margin-bottom: 12px;
    border: 1px solid transparent;
}

.alert.success {
    background: #e7f7ee;
    color: #146c3d;
    border-color: #bce8cc;
}

.alert.error {
    background: #ffe7ea;
    color: #9d1624;
    border-color: #ffc4cb;
}

.alert.info {
    background: #e7f0ff;
    color: #1d4ed8;
    border-color: #c7dcff;
}

.alert.warning {
    background: #fff4d8;
    color: #896000;
    border-color: #f8d77b;
}

.field-missing input,
.field-missing textarea,
.field-missing select {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(230, 57, 70, .08);
}

.field-help {
    color: var(--danger);
    font-size: 12px;
    font-weight: 700;
}

.contract-preview {
    max-width: 860px;
    margin: 0 auto;
    padding: 34px;
    border: 1px solid #d8dde8;
    background: #fff;
    color: #111318;
    font-family: "Times New Roman", Times, serif;
    line-height: 1.42;
}

.contract-preview h1 {
    margin: 0 0 20px;
    text-align: center;
    font-size: 20px;
}

.contract-preview h3 {
    margin: 18px 0 8px;
    font-size: 14px;
    text-transform: uppercase;
}

.contract-preview p {
    margin: 0 0 10px;
    text-align: justify;
}

.contract-preview pre {
    white-space: pre-wrap;
    font-family: "Times New Roman", Times, serif;
    line-height: 1.55;
}

.inline-upload {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.inline-upload input[type="file"] {
    max-width: 210px;
    padding: 7px;
}

.modal {
    border: 0;
    border-radius: var(--radius);
    width: min(980px, calc(100% - 24px));
    padding: 0;
    box-shadow: 0 24px 80px rgba(0, 0, 0, .3);
}

.modal::backdrop {
    background: rgba(8, 10, 16, .62);
}

.modal-header,
.modal-footer {
    padding: 16px 18px;
    border-bottom: 1px solid #e7eaf0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.modal-footer {
    border-top: 1px solid #e7eaf0;
    border-bottom: 0;
    justify-content: flex-end;
}

.modal-body {
    padding: 18px;
}

.progress {
    height: 10px;
    background: #e8ecf3;
    border-radius: 999px;
    overflow: hidden;
}

.progress span {
    display: block;
    height: 100%;
    background: var(--red);
}

.week-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(150px, 1fr));
    gap: 10px;
    overflow-x: auto;
}

.week-grid-compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow-x: visible;
}

.week-day {
    border: 1px solid #e3e6ed;
    border-radius: var(--radius);
    padding: 12px;
    min-height: 150px;
    background: #fafbfc;
}

.week-day h3 {
    margin: 0 0 10px;
    font-size: 14px;
    color: #12151d;
}

.week-payment {
    display: grid;
    gap: 3px;
    padding: 9px;
    border-radius: var(--radius);
    background: #fff;
    border: 1px solid #edf0f5;
    margin-bottom: 8px;
}

.week-payment strong {
    color: var(--red);
}

.week-payment small {
    color: #697386;
}

.pagination {
    display: flex;
    gap: 6px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.pagination a,
.pagination span {
    padding: 8px 11px;
    border-radius: var(--radius);
    background: #fff;
    border: 1px solid #d6dae3;
}

.pagination .active {
    background: var(--red);
    color: #fff;
    border-color: var(--red);
}

.tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.tab {
    padding: 10px 12px;
    border-radius: var(--radius);
    border: 1px solid #d6dae3;
    background: #fff;
    font-weight: 700;
}

.tab.active {
    background: #111318;
    color: #fff;
}

.empty {
    padding: 28px;
    text-align: center;
    color: #697386;
}

.mobile-menu {
    display: none;
}

@media (max-width: 1024px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        left: -280px;
        z-index: 20;
        width: 260px;
        transition: left .2s ease;
    }

    .sidebar.open {
        left: 0;
    }

    .mobile-menu {
        display: inline-flex;
    }

    .grid-4,
    .grid-3,
    .grid-2,
    .form-grid {
        grid-template-columns: 1fr 1fr;
    }

    .week-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        overflow-x: visible;
    }

    .form-grid .span-2,
    .form-grid .span-3,
    .form-grid .span-4 {
        grid-column: 1 / -1;
    }
}

@media (max-width: 680px) {
    .content {
        padding: 16px;
    }

    .grid-4,
    .grid-3,
    .grid-2,
    .form-grid {
        grid-template-columns: 1fr;
    }

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

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