:root {
    --bg: #eef3f9;
    --surface: #ffffff;
    --ink: #0f2337;
    --muted: #607488;
    --line: #d7e1ec;
    --brand: #ff5a1f;
    --brand-dark: #e2460d;
    --sidebar-line: rgba(216, 229, 244, 0.12);
    --sidebar-ink: #c7d5e5;
    --sidebar-active-bg: rgba(255, 255, 255, 0.14);
    --sidebar-active-line: #ff8b5f;
    --danger: #c64111;
    --warn: #9f580d;
    --ok: #14694d;
    --shadow-soft: 0 16px 38px rgba(16, 37, 57, 0.1);
}

html {
    background: var(--bg);
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 139, 95, 0.75) rgba(15, 35, 55, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Manrope", "Segoe UI", sans-serif;
    color: var(--ink);
    background: radial-gradient(circle at 92% -10%, #e6effa 0%, transparent 36%),
                linear-gradient(180deg, #f7fafe 0%, var(--bg) 100%);
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
    width: 10px;
}

html::-webkit-scrollbar-track,
body::-webkit-scrollbar-track {
    background: rgba(15, 35, 55, 0.08);
    border-radius: 999px;
}

html::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #ff8b5f 0%, #e2460d 100%);
    border-radius: 999px;
    border: 2px solid rgba(238, 243, 249, 0.95);
}

html::-webkit-scrollbar-thumb:hover,
body::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #ff9b75 0%, #f15a23 100%);
}

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

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 139, 95, 0.75) rgba(255, 255, 255, 0.08);
    background: linear-gradient(180deg, #12253d 0%, #0d1b2d 100%);
    color: var(--sidebar-ink);
    border-right: 1px solid var(--sidebar-line);
    padding: 24px 18px 18px;
    display: grid;
    grid-template-rows: auto auto 1fr auto;
    gap: 16px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 19px;
    font-weight: 800;
    letter-spacing: 0.01em;
    color: #eef6ff;
    text-decoration: none;
}

.brand-logo {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid rgba(233, 244, 255, 0.22);
    background: rgba(255, 255, 255, 0.95);
    flex: 0 0 auto;
}

.company-chip {
    border: 1px solid var(--sidebar-line);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    padding: 10px;
    display: grid;
    gap: 4px;
}

.company-chip .name {
    color: #eaf2fc;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.4;
}

.company-chip .mail {
    color: #b4c5d8;
    font-size: 12px;
    word-break: break-word;
}

.menu {
    display: grid;
    gap: 7px;
    align-content: start;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: rgba(197, 213, 230, 0.65) rgba(255, 255, 255, 0.06);
}

.sidebar::-webkit-scrollbar {
    width: 10px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.07);
    border-radius: 999px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #ff8b5f 0%, #e2460d 100%);
    border-radius: 999px;
    border: 2px solid rgba(13, 27, 45, 0.5);
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #ff9b75 0%, #f15a23 100%);
}

.menu::-webkit-scrollbar {
    height: 8px;
}

.menu::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.06);
    border-radius: 999px;
}

.menu::-webkit-scrollbar-thumb {
    background: rgba(197, 213, 230, 0.72);
    border-radius: 999px;
}

.menu::-webkit-scrollbar-thumb:hover {
    background: rgba(220, 232, 245, 0.86);
}

.menu-title {
    margin: 2px 4px 8px;
    color: #9bb0c6;
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-weight: 700;
}

.menu-item {
    border-radius: 11px;
    color: #c5d5e6;
    text-decoration: none;
    padding: 10px 11px;
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
}

.menu-item-label {
    display: inline-flex;
    align-items: center;
    gap: 9px;
}

.menu-icon {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: 0 0 auto;
    opacity: 0.95;
}

.menu-item:hover {
    color: #edf5ff;
    border-color: var(--sidebar-line);
    background: rgba(255, 255, 255, 0.05);
}

.menu-item.active {
    color: #fff;
    background: var(--sidebar-active-bg);
    border-color: rgba(255, 139, 95, 0.34);
    box-shadow: inset 2px 0 0 var(--sidebar-active-line);
}

.menu-item .soon {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #98acc1;
}

.sidebar-footer {
    border-top: 1px solid var(--sidebar-line);
    padding-top: 12px;
    display: grid;
    gap: 6px;
    font-size: 12px;
    color: #9fb2c7;
}

.sidebar-settings-link {
    margin-top: auto;
}

.sidebar-footer strong {
    color: #f0f6ff;
    font-size: 14px;
}

.content {
    padding: 22px;
}

.topbar {
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.9);
    border-radius: 16px;
    box-shadow: var(--shadow-soft);
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}

.heading {
    margin: 0;
    font-size: 26px;
    letter-spacing: -0.02em;
    line-height: 1;
}

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

.top-actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.billing-modal {
    position: fixed;
    inset: 0;
    background: rgba(8, 19, 31, 0.55);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1200;
    padding: 16px;
}

.billing-modal.open {
    display: flex;
}

.billing-modal-card {
    width: min(640px, 100%);
    border: 1px solid #d7e1ec;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 24px 56px rgba(15, 37, 57, 0.22);
    padding: 16px;
}

.billing-modal-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.billing-offer {
    border: 1px solid #d9e6f8;
    border-radius: 12px;
    background: #f4f8ff;
    color: #264866;
    padding: 10px;
    margin-top: 10px;
}

.onboarding-modal {
    position: fixed;
    inset: 0;
    background: rgba(8, 19, 31, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1250;
    padding: 16px;
}

.onboarding-modal.open {
    display: flex;
}

.onboarding-card {
    width: min(700px, 100%);
    border: 1px solid #d6e1ec;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 26px 58px rgba(15, 37, 57, 0.22);
    padding: 18px;
    display: grid;
    gap: 12px;
}

.onboarding-progress-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.onboarding-progress-track {
    flex: 1 1 auto;
    height: 8px;
    border-radius: 999px;
    border: 1px solid #d8e3ef;
    background: #eff4fa;
    overflow: hidden;
}

.onboarding-progress-track span {
    display: block;
    height: 100%;
    width: 0;
    background: linear-gradient(105deg, var(--brand), var(--brand-dark));
    transition: width .2s ease;
}

.onboarding-progress-wrap span {
    font-size: 12px;
    color: #51687e;
    font-weight: 700;
}

.onboarding-quick-actions {
    border: 1px solid #d9e3ef;
    border-radius: 13px;
    background: #f9fbfe;
    padding: 12px;
}

.onboarding-quick-actions h3 {
    margin: 0 0 10px;
    font-size: 16px;
}

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

.onboarding-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.btn {
    border: none;
    border-radius: 11px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    padding: 11px 14px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #183048;
    background: #edf3fb;
    border: 1px solid #d3deeb;
}

.btn:hover {
    background: #e5edf8;
}

.btn.primary {
    color: #fff;
    border-color: transparent;
    background: linear-gradient(105deg, var(--brand), var(--brand-dark));
    box-shadow: 0 12px 26px rgba(240, 78, 15, 0.28);
}

.btn.danger {
    color: #8a2d0c;
    background: #fff0e8;
    border-color: #f6cbb3;
}

.btn.ok {
    color: #135b43;
    background: #e8f8f1;
    border-color: #bce7d6;
}

.status {
    border: 1px solid #bde8d8;
    background: #e9faf3;
    color: #145b47;
    border-radius: 12px;
    padding: 12px;
    font-size: 14px;
    margin-bottom: 16px;
}

.status.err {
    border-color: #f3cab6;
    background: #fff2ea;
    color: #812f0a;
}

.status ul {
    margin: 8px 0 0;
    padding-left: 18px;
}

.card {
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: 14px;
    box-shadow: var(--shadow-soft);
    padding: 16px;
}

.card h2 {
    margin: 0 0 12px;
    font-size: 19px;
    letter-spacing: -0.01em;
}

.card + .card {
    margin-top: 12px;
}

.section-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 10px;
    align-items: end;
    margin-bottom: 12px;
}

.field {
    display: grid;
    gap: 5px;
    min-width: 0;
}

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

label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #5d7387;
    font-weight: 700;
}

input,
select,
textarea {
    border: 1px solid #d4deea;
    background: #fff;
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 14px;
    color: #1a3449;
    min-height: 42px;
    line-height: 1.3;
    font-family: inherit;
    width: 100%;
    max-width: 100%;
}

input[type="checkbox"],
input[type="radio"] {
    width: 16px;
    height: 16px;
    min-height: 16px;
    padding: 0;
    border-radius: 4px;
    border: 1px solid #bccddd;
    accent-color: #ff5a1f;
    background: #fff;
    vertical-align: middle;
    flex: 0 0 auto;
}

select {
    padding-right: 34px;
    appearance: none;
    background-image:
        linear-gradient(45deg, transparent 50%, #5f7388 50%),
        linear-gradient(135deg, #5f7388 50%, transparent 50%);
    background-position:
        calc(100% - 17px) calc(50% - 2px),
        calc(100% - 12px) calc(50% - 2px);
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}

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

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #8db6e5;
    box-shadow: 0 0 0 4px rgba(47, 128, 237, 0.16);
}

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

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

th,
td {
    text-align: left;
    padding: 10px 8px;
    border-top: 1px dashed #dee7f0;
    font-size: 14px;
}

th {
    border-top: 0;
    color: #6b7f91;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
}

td {
    color: #324e66;
    vertical-align: top;
}

.client-name-link {
    color: #0e2f4d;
    text-decoration: underline;
    text-decoration-color: rgba(14, 47, 77, 0.35);
    text-underline-offset: 3px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: color 0.18s ease, text-decoration-color 0.18s ease;
}

.client-name-link::after {
    content: ">";
    font-size: 12px;
    color: #6b85a0;
    transform: translateX(0);
    transition: transform 0.18s ease, color 0.18s ease;
}

.client-name-link:hover {
    color: #144a74;
    text-decoration-color: currentColor;
}

.client-name-link:hover::after {
    color: #144a74;
    transform: translateX(2px);
}

.client-name-link:focus-visible {
    outline: 2px solid #8db6e5;
    outline-offset: 2px;
    border-radius: 4px;
}

.chip {
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    padding: 4px 9px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.chip.active,
.chip.paid {
    color: var(--ok);
    background: #e7f8ef;
    border: 1px solid #bee8d6;
}

.chip.archived,
.chip.canceled {
    color: #7a4f2b;
    background: #f4ece5;
    border: 1px solid #e2d5ca;
}

.chip.open,
.chip.issued {
    color: #1f4f82;
    background: #edf5ff;
    border: 1px solid #c9dff8;
}

.chip.soon {
    color: var(--warn);
    background: #fff4e7;
    border: 1px solid #f5d4b2;
}

.chip.overdue {
    color: #8a2f0e;
    background: #ffece3;
    border: 1px solid #f3c0aa;
    justify-content: center;
    text-align: center;
    min-width: 126px;
    line-height: 1.15;
}

.table-actions {
    display: inline-flex;
    gap: 6px;
    flex-wrap: wrap;
}

.pagination-wrap {
    margin-top: 12px;
}

.panel-pagination {
    display: flex;
    justify-content: flex-end;
}

.panel-pagination-pages {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.page-btn {
    min-width: 38px;
    height: 36px;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid #d4dfeb;
    background: #fff;
    color: #2a4a66;
    text-decoration: none;
    font-size: 13px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

a.page-btn:hover {
    background: #eff5fc;
    border-color: #bfd2e7;
    color: #193c5a;
}

.page-btn.active {
    background: linear-gradient(105deg, var(--brand), var(--brand-dark));
    border-color: transparent;
    color: #fff;
    box-shadow: 0 8px 20px rgba(240, 78, 15, 0.2);
}

.page-btn.disabled {
    opacity: 0.45;
    cursor: not-allowed;
    background: #f4f8fc;
}

.page-btn.dots {
    min-width: 28px;
    border-style: dashed;
    background: #f9fbfe;
}

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

.error-text {
    color: #9f3e13;
    font-size: 12px;
    font-weight: 600;
}

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

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

    .sidebar {
        position: static;
        height: auto;
        grid-template-rows: auto auto auto auto;
    }

    .sidebar-settings-link {
        margin-top: 0;
    }

    .menu {
        display: flex;
        gap: 8px;
        overflow-y: hidden;
        overflow-x: auto;
        padding-right: 0;
        padding-bottom: 4px;
    }

    .menu-item {
        flex: 0 0 auto;
        min-width: 190px;
    }

    .menu-title {
        display: none;
    }
}

@media (max-width: 640px) {
    .content {
        padding: 14px;
    }

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

    .top-actions {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr;
    }

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

    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    .panel-pagination {
        justify-content: flex-start;
    }

    .onboarding-quick-grid {
        grid-template-columns: 1fr;
    }
}
