:root {
    --cw-navy: #123262;
    --cw-navy-dark: #0c2447;
    --cw-orange: #f5821f;
    --cw-orange-dark: #d96c0f;

    /* Status palette - fixed meaning, not decorative */
    --cw-good: #0ca30c;
    --cw-warning: #fab219;
    --cw-serious: #ec835a;
    --cw-critical: #d03b3b;
    --cw-muted: #898781;

    --cw-ink-primary: #0b0b0b;
    --cw-ink-secondary: #52514e;

    --cw-sidebar-width: 272px;
    --cw-topbar-height: 68px;
}

/* Brand color utilities - use alongside Bootstrap's own bg- and text- utilities.
   The Bootstrap CDN build has no navy or orange theme colors, so these
   fill that one gap; everything else (spacing, flex, grid, radius,
   shadow) should use plain Bootstrap utility classes, not new custom CSS. */
.bg-navy { background-color: var(--cw-navy) !important; }
.bg-navy-dark { background-color: var(--cw-navy-dark) !important; }
.bg-orange { background-color: var(--cw-orange) !important; }
.bg-good { background-color: var(--cw-good) !important; }
.bg-muted { background-color: var(--cw-muted) !important; }
.text-navy { color: var(--cw-navy) !important; }
.text-orange { color: var(--cw-orange) !important; }
.cw-icon-box {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}
.cw-icon-box-sm {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}

body {
    background-color: #eef1f6;
}

/* ===== App shell: sidebar + topbar ===== */
.cw-app {
    display: flex;
    min-height: 100vh;
}
.cw-sidebar {
    width: var(--cw-sidebar-width);
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--cw-navy) 0%, var(--cw-navy-dark) 100%);
    color: #fff;
    padding: 1.5rem 1.25rem;
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    transition: width .2s ease, padding .2s ease;
}
/* Only this inner area scrolls - the footer (settings + collapse) stays put. */
.cw-sidebar-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: none;
}
.cw-sidebar-scroll::-webkit-scrollbar {
    display: none;
}
/* Collapsed state - toggled by #cwSidebarToggle in sidebar_content.html */
.cw-app.cw-sidebar-collapsed {
    --cw-sidebar-width: 76px;
}
.cw-app.cw-sidebar-collapsed .cw-sidebar {
    padding-left: .6rem;
    padding-right: .6rem;
}
.cw-app.cw-sidebar-collapsed .cw-sidebar-label {
    display: none;
}
.cw-app.cw-sidebar-collapsed .cw-sidebar-nav .nav-link {
    justify-content: center;
}
.cw-sidebar-footer {
    flex-shrink: 0;
    padding-top: 1rem;
    margin-top: .5rem;
    border-top: 1px solid rgba(255, 255, 255, .1);
    display: flex;
    align-items: center;
    gap: .6rem;
}
.cw-sidebar-settings-btn {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .1);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
}
.cw-sidebar-settings-btn:hover {
    background: rgba(255, 255, 255, .18);
    color: #fff;
}
.cw-sidebar-collapse-btn {
    flex: 1;
    border: none;
    background: var(--cw-orange);
    color: #fff;
    font-weight: 700;
    border-radius: 2rem;
    padding: .5rem 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
}
.cw-sidebar-collapse-btn:hover {
    background: var(--cw-orange-dark);
}
.cw-app.cw-sidebar-collapsed .cw-sidebar-footer {
    flex-direction: column;
}
.cw-app.cw-sidebar-collapsed .cw-sidebar-collapse-btn {
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
    padding: 0;
}
.cw-sidebar-toggle-icon {
    transition: transform .2s ease;
}
.cw-app.cw-sidebar-collapsed .cw-sidebar-toggle-icon {
    transform: rotate(180deg);
}
.offcanvas.cw-sidebar-mobile .offcanvas-body {
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1.25rem;
}
.cw-sidebar-nav .nav-link {
    color: rgba(255, 255, 255, .85);
    border-radius: .6rem;
    padding: .7rem .75rem;
    margin-bottom: .1rem;
    display: flex;
    align-items: center;
    gap: .65rem;
    font-size: .92rem;
    font-weight: 600;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.cw-sidebar-nav .nav-link:last-child {
    border-bottom: none;
}
.cw-sidebar-nav .nav-link i {
    font-size: 1.05rem;
    width: 1.2rem;
    text-align: center;
}
.cw-sidebar-nav .nav-link:hover {
    background: rgba(255, 255, 255, .08);
    color: #fff;
}
.cw-sidebar-nav .nav-link.active {
    background: var(--cw-orange);
    color: #fff;
    border-bottom-color: transparent;
    box-shadow: 0 4px 10px rgba(245, 130, 31, .35);
}

.cw-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.cw-topbar {
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    padding: .85rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--cw-topbar-height);
    z-index: 15;
    transition: left .2s ease;
}
@media (min-width: 992px) {
    .cw-topbar {
        left: var(--cw-sidebar-width);
    }
}
.cw-topbar-header {
    display: flex;
    align-items: center;
    gap: .85rem;
    min-width: 0;
}
.cw-topbar-icon {
    width: 42px;
    height: 42px;
    border-radius: .65rem;
    background: var(--cw-orange);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}
.cw-topbar-title {
    font-weight: 800;
    color: var(--cw-navy);
    margin-bottom: 0;
    font-size: 1.25rem;
}
.cw-topbar-subtitle {
    color: var(--cw-ink-secondary);
    font-size: .85rem;
    margin-bottom: 0;
}
.cw-topbar-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}
/* Mobile-only brand topbar: logo + name + role tagline, replaces the per-page topbar below lg */
.cw-mobile-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 15;
    height: var(--cw-topbar-height);
    background: linear-gradient(90deg, var(--cw-navy) 0%, var(--cw-navy-dark) 100%);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
}
.cw-content {
    padding: 1.5rem;
    margin-top: var(--cw-topbar-height);
    flex: 1;
}
.offcanvas.cw-sidebar-mobile {
    width: var(--cw-sidebar-width);
    background: linear-gradient(180deg, var(--cw-navy) 0%, var(--cw-navy-dark) 100%);
    color: #fff;
}
.offcanvas.cw-sidebar-mobile .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* Bottom tab bar - mobile only, for seguranca/tesoureira */
.cw-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    background: linear-gradient(90deg, var(--cw-navy) 0%, var(--cw-navy-dark) 100%);
    display: flex;
    padding: .4rem .5rem calc(.4rem + env(safe-area-inset-bottom));
    box-shadow: 0 -2px 12px rgba(0, 0, 0, .15);
}
.cw-bottom-nav .cw-bottom-nav-link {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .15rem;
    color: rgba(255, 255, 255, .65);
    text-decoration: none;
    font-size: .72rem;
    font-weight: 600;
    padding: .4rem 0;
    border-radius: .6rem;
}
.cw-bottom-nav .cw-bottom-nav-link i {
    font-size: 1.15rem;
}
.cw-bottom-nav .cw-bottom-nav-link.active {
    color: #fff;
    background: rgba(255, 255, 255, .1);
}
.cw-bottom-nav .cw-bottom-nav-link.active i {
    color: var(--cw-orange);
}
@media (max-width: 991.98px) {
    body.cw-has-bottom-nav .cw-content {
        padding-bottom: 5.5rem;
    }
}

/* ===== Row card: mobile-friendly stand-in for a wide table row ===== */
.cw-row-card {
    background: #fff;
    border: 1px solid #edeef1;
    border-radius: .85rem;
    padding: 1rem;
    margin-bottom: .75rem;
}
.cw-row-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: .5rem;
    margin-bottom: .85rem;
    padding-bottom: .75rem;
    border-bottom: 1px solid #f1f2f4;
}
.cw-row-card-title {
    font-weight: 700;
    color: var(--cw-navy);
    font-size: 1.02rem;
    line-height: 1.25;
}
.cw-row-card-subtitle {
    color: var(--cw-ink-secondary);
    font-size: .8rem;
}
.cw-row-card-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .7rem;
    margin-bottom: .9rem;
}
.cw-row-card-field .cw-row-card-label {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .3px;
    color: var(--cw-ink-secondary);
    margin-bottom: .1rem;
}
.cw-row-card-field .cw-row-card-value {
    font-weight: 600;
    font-size: .88rem;
    color: var(--cw-ink-primary);
    word-break: break-word;
}
.cw-row-card-actions {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
}
.cw-row-card-actions .btn {
    flex: 1 1 auto;
}

/* ===== Form card: two-panel (navy info + white form), stacks on mobile ===== */
.cw-form-modal {
    background: #fff;
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 0 1rem 3rem rgba(18, 50, 98, .12);
    width: 100%;
    max-width: 960px;
}
/* Same two-panel card, but rendered inside a Bootstrap modal (opens on top of the page) */
.modal-content.cw-form-modal {
    border: 0;
    max-height: 88vh;
}
.modal-content.cw-form-modal .row.g-0 {
    max-height: 88vh;
    overflow-y: auto;
}
@media (max-width: 991.98px) {
    .modal-content.cw-form-modal .row.g-0 {
        max-height: none;
    }
    .modal-fullscreen-sm-down .modal-content.cw-form-modal {
        max-height: 100vh;
        height: 100%;
        border-radius: 0;
    }
}
.cw-form-side {
    background: linear-gradient(165deg, var(--cw-navy) 0%, var(--cw-navy-dark) 100%);
    color: #fff;
    padding: 2rem 1.75rem;
}
.cw-form-side-icon {
    width: 52px;
    height: 52px;
    border-radius: .75rem;
    background: var(--cw-orange);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    margin-bottom: 1rem;
}
.cw-form-side-title {
    font-weight: 800;
    font-size: 1.2rem;
    margin-bottom: .1rem;
}
.cw-form-side-subtitle {
    color: rgba(255, 255, 255, .65);
    font-size: .78rem;
    font-weight: 600;
    letter-spacing: .5px;
    text-transform: uppercase;
    margin-bottom: 1.5rem;
}
.cw-form-step {
    background: rgba(255, 255, 255, .1);
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: .7rem;
    padding: .75rem;
    display: flex;
    align-items: center;
    gap: .65rem;
    margin-bottom: 1.5rem;
}
.cw-form-step-icon {
    width: 36px;
    height: 36px;
    border-radius: .55rem;
    background: var(--cw-orange);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.cw-form-step-title {
    font-weight: 600;
    font-size: .88rem;
    line-height: 1.2;
}
.cw-form-step-subtitle {
    font-size: .75rem;
    color: rgba(255, 255, 255, .6);
}
.cw-form-tip {
    background: rgba(255, 255, 255, .08);
    border-radius: .7rem;
    padding: .9rem;
}
.cw-form-tip-title {
    color: var(--cw-orange);
    font-weight: 700;
    font-size: .78rem;
    letter-spacing: .5px;
    margin-bottom: .35rem;
    display: flex;
    align-items: center;
    gap: .4rem;
}
.cw-form-tip p {
    font-size: .82rem;
    color: rgba(255, 255, 255, .8);
    margin-bottom: 0;
}
.cw-form-main {
    padding: 2rem 2rem 1.5rem;
    position: relative;
}
/* Compact the navy side panel into a slim horizontal header on mobile - the
   stacked icon/step/tip blocks ate too much height above the actual form. */
@media (max-width: 991.98px) {
    .cw-form-side {
        padding: 1rem 1.25rem;
        display: flex;
        align-items: center;
        gap: .75rem;
    }
    .cw-form-side-icon {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
        margin-bottom: 0;
        flex-shrink: 0;
    }
    .cw-form-side-title {
        font-size: 1rem;
        margin-bottom: 0;
        line-height: 1.2;
    }
    .cw-form-side-subtitle {
        font-size: .7rem;
        margin-bottom: 0;
    }
    .cw-form-step,
    .cw-form-tip {
        display: none;
    }
    .cw-form-main {
        padding: 1.25rem 1.25rem 1.5rem;
    }
    .cw-form-close {
        top: .85rem;
        right: .85rem;
    }
}
.cw-form-close {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid #e5e7eb;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--cw-ink-secondary);
    z-index: 5;
}
.cw-form-close:hover {
    background: #f8f9fb;
    color: var(--cw-ink-primary);
}
.cw-form-breadcrumb {
    font-size: .78rem;
    color: var(--cw-ink-secondary);
    font-weight: 600;
    margin-bottom: .35rem;
}
.cw-form-breadcrumb span {
    color: var(--cw-orange);
}
.cw-form-section-header {
    display: flex;
    align-items: center;
    gap: .6rem;
    font-weight: 700;
    color: var(--cw-navy);
    margin-bottom: 1rem;
    font-size: .95rem;
}
.cw-form-section-icon {
    width: 34px;
    height: 34px;
    border-radius: .55rem;
    background: #fdece0;
    color: var(--cw-orange);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}
.cw-form-footer {
    display: flex;
    justify-content: flex-end;
    gap: .75rem;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid #edeef1;
}



