:root {
    --il-primary: #3b5bdb;
    --il-primary-dark: #2f47b8;
    --il-ink: #1c2333;
    --il-muted: #6b7280;
    --il-bg: #f5f7fb;
    --il-border: #e6eaf2;
    --il-soft: #eef1f8;
}

body.app-body {
    background: var(--il-bg);
    color: var(--il-ink);
    font-size: .95rem;
}

.app-navbar {
    background: linear-gradient(90deg, var(--il-primary) 0%, #4c6ef5 100%) !important;
}

/* Match the collapsed navbar breakpoint, in browser and standalone modes. */
@media (max-width: 991.98px) {
    .app-navbar .account-dropdown {
        flex: 1;
        min-width: 0;
    }

    .app-navbar .account-dropdown > .dropdown-toggle {
        max-width: 100%;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .app-navbar .account-dropdown > .dropdown-menu {
        min-width: min(10rem, 100%);
        max-width: 100%;
    }

    .app-navbar .account-dropdown .dropdown-item {
        white-space: normal;
        overflow-wrap: anywhere;
    }
}

.brand-mark,
.brand-mark-lg {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, .2);
    color: #fff;
    border-radius: .5rem;
}

.brand-mark {
    width: 1.75rem;
    height: 1.75rem;
}

.brand-mark-lg {
    width: 3.25rem;
    height: 3.25rem;
    font-size: 1.5rem;
}

.page-title {
    color: var(--il-ink);
}

.app-footer {
    border-top: 1px solid var(--il-border);
    background: #fff;
}

/* Cards */
.card {
    border: 1px solid var(--il-border);
    border-radius: .75rem;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}

.card-header {
    background: #fff;
    border-bottom: 1px solid var(--il-border);
    border-radius: .75rem .75rem 0 0 !important;
}

/* Dashboard stat cards */
.stat-card {
    display: block;
    text-decoration: none;
    color: inherit;
    background: #fff;
    border: 1px solid var(--il-border);
    border-radius: .75rem;
    padding: 1.1rem 1.15rem;
    transition: transform .12s ease, box-shadow .12s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(16, 24, 40, .08);
    color: inherit;
}

.stat-card .stat-amount {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -.02em;
}

.stat-card .stat-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: .6rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
}

.stat-card .stat-label {
    color: var(--il-muted);
    font-size: .82rem;
}

/* Tables */
.table-docs thead th {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--il-muted);
    border-bottom: 1px solid var(--il-border);
    white-space: nowrap;
}

.table-docs td {
    vertical-align: middle;
}

.table-docs tbody tr:hover {
    background: #f8faff;
}

/* Buttons */
.btn-primary {
    background: var(--il-primary);
    border-color: var(--il-primary);
}

.btn-primary:hover,
.btn-primary:focus {
    background: var(--il-primary-dark);
    border-color: var(--il-primary-dark);
}

/* ============ Document builder ============ */
.builder-row {
    background: #fff;
    border: 1px solid var(--il-border);
    border-radius: .6rem;
    padding: .85rem .85rem .35rem;
    margin-bottom: .65rem;
}

.builder-row .row {
    margin-bottom: .5rem;
}

.builder-row label.col-form-label {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--il-muted);
    padding-bottom: .1rem;
}

.builder-row .form-control,
.builder-row .form-select {
    font-size: .92rem;
}

.private-summary {
    background: #fff8f0;
    border: 1px solid #ffd9a8;
    border-radius: .75rem;
}

.private-summary .ps-label {
    color: #b4690e;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    font-weight: 600;
}

.private-summary .ps-value {
    font-weight: 700;
    font-size: .95rem;
}

.totals-box {
    background: #fff;
    border: 1px solid var(--il-border);
    border-radius: .75rem;
}

.totals-box .tb-row {
    display: flex;
    justify-content: space-between;
    padding: .35rem 0;
    color: var(--il-muted);
    font-size: .92rem;
}

.totals-box .tb-row.tb-total {
    border-top: 1px solid var(--il-border);
    margin-top: .25rem;
    padding-top: .7rem;
    color: var(--il-ink);
    font-weight: 700;
    font-size: 1.05rem;
}

.totals-box .tb-row.tb-vat {
    color: var(--il-ink);
}

/* Search dropdown for the price book */
.item-search-panel {
    position: relative;
}

.item-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1050;
    background: #fff;
    border: 1px solid var(--il-border);
    border-radius: .5rem;
    box-shadow: 0 10px 30px rgba(16, 24, 40, .12);
    max-height: 320px;
    overflow-y: auto;
    display: none;
}

.item-search-results.show {
    display: block;
}

.item-search-results .isr-item {
    width: 100%;
    min-height: 44px;
    border: 0;
    background: #fff;
    color: inherit;
    text-align: left;
    padding: .55rem .9rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .5rem;
}

.item-search-results .isr-item:hover,
.item-search-results .isr-item:focus-visible {
    background: var(--il-soft);
}

/* Guest (auth) pages */
.guest-body {
    background: linear-gradient(160deg, #eef2ff 0%, #f5f7fb 60%);
    min-height: 100vh;
}

.guest-wrap {
    max-width: 30rem;
    margin: 0 auto;
    padding: 4vh 1rem 2rem;
}

.guest-card {
    background: #fff;
    border: 1px solid var(--il-border);
    border-radius: 1rem;
    padding: 1.75rem;
    box-shadow: 0 20px 50px rgba(16, 24, 40, .08);
}

/* Document preview */
.doc-preview {
    overflow-wrap: anywhere;
}

.doc-preview .table {
    min-width: 540px;
}

.doc-preview .table td:not(:first-child),
.doc-preview .table th:not(:first-child) {
    white-space: nowrap;
}

.doc-preview .tb-row {
    gap: 1rem;
}

.doc-preview .tb-row > span:last-child {
    white-space: nowrap;
}

.doc-preview .doc-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.doc-preview .logo-img {
    max-height: 64px;
    max-width: 160px;
}

.badge {
    font-weight: 600;
}

/* Mobile tweaks */
@media (max-width: 767.98px) {
    .stat-card .stat-amount {
        font-size: 1.15rem;
    }

    .table-docs thead {
        display: none;
    }

    .table-docs,
    .table-docs tbody,
    .table-docs tr,
    .table-docs td {
        display: block;
        width: 100%;
    }

    .table-docs tr {
        border: 1px solid var(--il-border);
        border-radius: .6rem;
        margin-bottom: .75rem;
        padding: .6rem .9rem;
        background: #fff;
    }

    .table-docs td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        border: none;
        padding: .28rem 0;
    }

    .table-docs td::before {
        content: attr(data-label);
        font-size: .7rem;
        text-transform: uppercase;
        letter-spacing: .03em;
        color: var(--il-muted);
    }

    .table-docs td .td-main {
        text-align: right;
        font-weight: 600;
    }

    .table-docs td.cell-actions {
        justify-content: flex-end;
        gap: .35rem;
    }
}

/* Utility */
.text-muted {
    color: var(--il-muted) !important;
}

.list-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: .7rem .25rem;
    border-bottom: 1px solid var(--il-border);
    text-decoration: none;
    color: inherit;
}

.list-row:last-child {
    border-bottom: none;
}

.list-row:hover {
    background: #f8faff;
}

.attention-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .65rem .25rem;
    border-bottom: 1px solid var(--il-border);
    text-decoration: none;
    color: inherit;
}

.attention-item:last-child {
    border-bottom: none;
}

.attention-item:hover {
    background: #f8faff;
}
