* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: #f5f7fb;
    color: #1f2937;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

.auth-page {
    align-items: center;
    display: flex;
    min-height: 100vh;
    justify-content: center;
    padding: 24px;
}

.login-panel {
    background: #ffffff;
    border: 1px solid #dde3ee;
    border-radius: 8px;
    box-shadow: 0 18px 45px rgba(31, 41, 55, .08);
    max-width: 420px;
    padding: 32px;
    width: 100%;
}

.login-panel h1,
.page-title h1 {
    margin: 0;
}

.login-panel p,
.muted {
    color: #6b7280;
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    background: #111827;
    color: #e5e7eb;
    flex: 0 0 260px;
    padding: 24px 18px;
}

.brand {
    border-bottom: 1px solid rgba(255, 255, 255, .12);
    margin-bottom: 20px;
    padding-bottom: 18px;
}

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

.brand span {
    color: #9ca3af;
    font-size: 13px;
}

.nav-link {
    align-items: center;
    border-radius: 8px;
    color: #cbd5e1;
    display: flex;
    gap: 8px;
    margin: 4px 0;
    padding: 10px 12px;
}

.nav-icon {
    fill: currentColor;
    flex: 0 0 14px;
    height: 14px;
    opacity: .92;
    width: 14px;
}

.nav-link span,
.nav-logout span {
    line-height: 1;
}

.nav-link.active,
.nav-link:hover {
    background: #1f2937;
    color: #ffffff;
}

.nav-group {
    margin: 4px 0;
}

.nav-parent {
    cursor: default;
}

.nav-submenu {
    border-left: 1px solid rgba(255, 255, 255, .12);
    margin: 2px 0 8px 19px;
    padding-left: 8px;
}

.nav-sublink {
    font-size: 14px;
    margin: 2px 0;
    padding: 9px 10px;
}

.sidebar-footer {
    margin-top: 28px;
}

.nav-logout {
    width: 100%;
}

.main {
    flex: 1;
    min-width: 0;
}

.topbar {
    align-items: center;
    background: #ffffff;
    border-bottom: 1px solid #dde3ee;
    display: flex;
    justify-content: space-between;
    padding: 18px 28px;
}

.content {
    padding: 28px;
}

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

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

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

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

.card {
    background: #ffffff;
    border: 1px solid #dde3ee;
    border-radius: 8px;
    padding: 18px;
}

.metric .label {
    color: #64748b;
    font-size: 13px;
}

.metric .value {
    font-size: 28px;
    font-weight: 750;
    margin-top: 8px;
}

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

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

.table-toolbar input {
    max-width: 320px;
}

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

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

th {
    color: #64748b;
    font-size: 12px;
    text-transform: uppercase;
}

.status {
    border-radius: 999px;
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 9px;
    text-transform: capitalize;
}

.status-active,
.status-paid,
.status-sent {
    background: #dcfce7;
    color: #166534;
}

.status-inactive,
.status-cancelled {
    background: #e5e7eb;
    color: #374151;
}

.status-draft {
    background: #fef3c7;
    color: #92400e;
}

.status-overdue,
.status-failed {
    background: #fee2e2;
    color: #991b1b;
}

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

.status-minus {
    background: #fee2e2;
    color: #991b1b;
}

.btn,
button {
    align-items: center;
    background: #2563eb;
    border: 0;
    border-radius: 8px;
    color: #ffffff;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-weight: 700;
    gap: 8px;
    justify-content: center;
    min-height: 40px;
    padding: 9px 14px;
}

.btn.secondary,
button.secondary {
    background: #e5e7eb;
    color: #1f2937;
}

.btn.danger,
button.danger {
    background: #dc2626;
}

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

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

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

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

label {
    color: #374151;
    font-size: 13px;
    font-weight: 700;
}

input,
select,
textarea {
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font: inherit;
    min-height: 40px;
    padding: 9px 11px;
    width: 100%;
}

textarea {
    min-height: 96px;
}

.checkbox-list {
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    display: grid;
    gap: 8px;
    padding: 10px 11px;
}

.checkbox-item {
    align-items: center;
    display: flex;
    gap: 8px;
    font-weight: 600;
}

.checkbox-item input {
    min-height: 16px;
    width: 16px;
}

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

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

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

.item-row {
    align-items: end;
    display: grid;
    gap: 10px;
    grid-template-columns: 1fr 120px 160px 48px;
    margin-bottom: 10px;
}

.repeater-list {
    display: grid;
    gap: 10px;
}

.repeater-row {
    align-items: center;
    display: grid;
    gap: 10px;
    grid-template-columns: 1fr 48px;
}

.pagination {
    margin-top: 16px;
}

.modal {
    align-items: center;
    background: rgba(17, 24, 39, .58);
    display: none;
    inset: 0;
    justify-content: center;
    padding: 22px;
    position: fixed;
    z-index: 1000;
}

.modal.open {
    display: flex;
}

.modal-panel {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, .28);
    max-height: calc(100vh - 44px);
    max-width: 90vw;
    overflow: auto;
    padding: 22px;
    width: 90vw;
}

.modal-header {
    align-items: center;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    margin-bottom: 18px;
    padding-bottom: 12px;
}

.modal-header h2 {
    margin: 0;
}

.icon-btn {
    aspect-ratio: 1;
    min-height: 36px;
    padding: 0;
    width: 36px;
}

.loading-row,
.empty-row {
    color: #64748b;
    text-align: center;
}

.client-primary {
    font-weight: 750;
}

.invoice-document {
    background: #ffffff;
    border: 1px solid #dde3ee;
    border-radius: 8px;
    color: #111827;
    padding: 34px;
}

.invoice-head {
    align-items: flex-start;
    display: flex;
    justify-content: space-between;
    gap: 32px;
}

.invoice-brand-row {
    align-items: center;
    display: flex;
    gap: 12px;
}

.invoice-brand-mark {
    align-items: center;
    background: #111827;
    border-radius: 8px;
    color: #ffffff;
    display: inline-flex;
    font-weight: 800;
    height: 46px;
    justify-content: center;
    width: 46px;
}

.invoice-brand-logo {
    border-radius: 8px;
    display: block;
    height: 52px;
    object-fit: cover;
    width: 56px;
}

.invoice-kicker {
    color: #64748b;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.invoice-subtitle {
    color: #64748b;
    font-size: 12px;
    margin-top: 2px;
}

.invoice-eyebrow {
    color: #64748b;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .08em;
    margin-top: 26px;
    text-transform: uppercase;
}

.invoice-title {
    font-size: 34px;
    font-weight: 800;
    line-height: 1;
    margin: 8px 0 12px;
}

.invoice-meta {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-left: auto;
    min-width: 340px;
    padding: 10px 16px;
}

.invoice-meta-row {
    align-items: center;
    display: flex;
    justify-content: space-between;
    gap: 18px;
    min-height: 42px;
    padding: 7px 0;
}

.total-row {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    padding: 7px 0;
}

.invoice-meta-row + .invoice-meta-row {
    border-top: 1px solid #e5e7eb;
}

.invoice-parties {
    border-top: 2px solid #111827;
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 28px 0 22px;
    padding-top: 14px;
}

.invoice-party {
    padding-top: 0;
}

.invoice-party h3,
.invoice-note h3 {
    color: #64748b;
    font-size: 12px;
    letter-spacing: .08em;
    margin: 0 0 10px;
    text-transform: uppercase;
}

.invoice-items th {
    background: #356b4a;
    color: #ffffff;
}

.invoice-totals {
    margin-left: auto;
    margin-top: 18px;
    max-width: 360px;
}

.grand-total {
    background: #356b4a;
    border-radius: 8px;
    color: #ffffff;
    font-size: 20px;
    font-weight: 800;
    margin-top: 8px;
    padding: 14px 16px;
}

.invoice-note {
    background: #f8fafc;
    border-radius: 8px;
    margin-top: 24px;
    padding: 16px;
}

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

    .sidebar {
        width: 100%;
    }

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

    .content,
    .topbar {
        padding: 18px;
    }
}
