/* ==========================================================================
   General Shared Styles
   ========================================================================== */

/*-------- Google Fonts Import -------- */
@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@200;300;400;500;600;700;800&display=swap');

/* ---- Reset & Base ---- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: 'Manrope', sans-serif;
    /* font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; */
    font-size: 14px;
    line-height: 1.5;
    color: #1a1a2e;
    background: #f0f2f5;
    /* Full-width shell: the topbar/footer/QA banner are flex children of <body>,
       so the body must span the viewport at any zoom level. Content width is
       capped/centered by inner wrappers (.page-wrapper/.page-wrap = 1500px,
       .app-footer-inner = 1140px), not by the body. */
    width: 100%;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ---- Topbar ---- */
.topbar {
    background: #1d1d1b;
    height: 56px;
    display: flex;
    align-items: center;
    padding: 0 24px;
    border-bottom: 3px solid #0f3460;
    position: sticky;
    top: 0;
    z-index: 100;
}
.topbar-back {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: #999;
    text-decoration: none;
    margin-right: 18px;
    padding-right: 18px;
    border-right: 1px solid rgba(255,255,255,.12);
}
.topbar-back:hover { color: #fff; }
.topbar-back svg { opacity: .7; }
.topbar-brand {
    font-size: 15px;
    font-weight: 600;
    color: #e0e0e0;
    letter-spacing: .3px;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

/* ---- User Dropdown ---- */
.user-dropdown { position: relative; display: inline-block; }
.user-btn {
    background: none;
    border: 1px solid rgba(255,255,255,.15);
    border-radius: 4px;
    padding: 7px 14px;
    font-size: 13px;
    color: #ccc;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}
.user-btn:hover { background: rgba(255,255,255,.08); color: #fff; }
.user-btn svg { opacity: .7; }
.user-name { text-transform: uppercase; color: #fff; }
.caret { font-size: 9px; color: rgba(255,255,255,.4); }

/* Styled to echo the left main-menu drawer: rounded icon chips, item titles,
   chevrons and the same hover treatment (see .menu-drawer-item). */
.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    background: #fff;
    border: 1px solid #e3e7ec;
    border-radius: 12px;
    list-style: none;
    min-width: 252px;
    padding: 7px;
    margin: 0;
    z-index: 1000;
    box-shadow: 0 14px 34px rgba(15,28,54,.18);
}
.dropdown-menu.open { display: block; }
.dropdown-menu li { list-style: none; }
.dropdown-head {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 7px 10px 10px;
    margin-bottom: 5px;
    border-bottom: 1px solid #e8ebef;
}
.dropdown-head-eyebrow {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: #8a909a;
}
.dropdown-head-name {
    font-size: 13.5px;
    font-weight: 700;
    color: #1a1a2e;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* Secondary line under the full name: the username/display name, styled to read
   as quieter metadata (lighter weight + muted color) so it's clearly distinct
   from the bold full name above it. */
.dropdown-head-user {
    margin-top: 1px;
    font-size: 12px;
    font-weight: 500;
    color: #707682;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dropdown-menu li a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 8px 9px;
    border-radius: 9px;
    color: #1a1a2e;
    text-decoration: none;
    font-size: 13px;
}
.dropdown-menu li a:hover { background: #f2f6fb; }
.dropdown-ico {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: #f0f4ff;
    color: #0f3460;
}
.dropdown-label { flex: 1 1 auto; min-width: 0; font-weight: 600; }
.dropdown-chev {
    flex-shrink: 0;
    display: inline-flex;
    color: #c2c8cf;
    transition: color .15s, transform .15s;
}
.dropdown-menu li a:hover .dropdown-chev { color: #0f3460; transform: translateX(2px); }
.dropdown-menu .divider { background: #e8ebef; margin: 5px 8px; }
.dropdown-menu li a.dropdown-item--danger:hover { background: #fdf2f2; }
.dropdown-menu li a.dropdown-item--danger:hover .dropdown-ico { background: #fde8e8; color: #c0392b; }
.dropdown-menu li a.dropdown-item--danger:hover .dropdown-chev { color: #c0392b; }
.divider { height: 1px; background: #eee; }

/* ---- Page Wrapper ---- */
.page-wrapper {
    width: 100%;
    max-width: 1500px;
    margin-left: auto;
    margin-right: auto;
    padding: 32px 20px 0 24px;
    flex: 1;
}
.page-wrap {
    width: 100%;
    max-width: 1500px;
    margin-left: auto;
    margin-right: auto;
    flex: 1;
    padding: 32px 20px 0 24px;
}

/* ---- Page Header ---- */
.page-header { margin-bottom: 24px; }
.page-title {
    font-size: 22px;
    font-weight: 700;
    color: #1a1a2e;
    margin: 0 0 6px 0;
}
.page-info {
    font-size: 13px;
    color: #666;
    line-height: 1.6;
}

/* ---- Page Hero ---- */
.page-hero {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 20px 24px;
    background: #f7f8fa;
    border: 1px solid #e8e8e8;
    border-radius: 10px;
    margin-bottom: 26px;
}
.page-hero-icon {
    flex-shrink: 0;
    width: 46px;
    height: 46px;
    border-radius: 10px;
    background: #fdeee8;
    color: #e8451c;
    display: flex;
    align-items: center;
    justify-content: center;
}
.page-hero-text { flex: 1; min-width: 0; }
.page-hero-title {
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 4px 0;
    color: #1a1a2e;
}
.page-hero-desc {
    font-size: 13px;
    line-height: 1.6;
    color: #666;
}
.page-hero-desc p { margin: 0 0 6px 0; }
.page-hero-desc p:last-child { margin-bottom: 0; }
.page-hero-desc a { color: #e8451c; }
.page-hero-aside { flex-shrink: 0; align-self: center; }

@media (max-width: 640px) {
    .page-hero {
        flex-wrap: wrap;
        padding: 16px 18px;
        gap: 12px;
    }
    .page-hero-aside { flex: 1 1 100%; align-self: stretch; }
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: none;
    line-height: 1.4;
    white-space: nowrap;
    letter-spacing: .2px;
}
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-primary { background: #0f3460; color: #fff; }
.btn-primary:hover { background: #1a4a7a; }
.btn-warning { background: #f39c12; color: #fff; }
.btn-warning:hover { background: #d68910; }
.btn-success { background: #27ae60; color: #fff; }
.btn-success:hover { background: #219a52; }
.btn-info { background: #2980b9; color: #fff; }
.btn-info:hover { background: #2471a3; }
.btn-link {
    background: none;
    color: #0f3460;
    padding: 5px 6px;
    font-weight: 500;
    border: none;
}
.btn-link:hover { text-decoration: underline; }
.btn-secondary {
    background: #f0f0f0;
    color: #333;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 6px 16px;
    font-size: 13px;
    cursor: pointer;
    font-weight: 500;
}
.btn-secondary:hover {
    background: #e4e4e4;
}
/* Standard "View/Details" action button for record cards (list + grid cards).
   Outline style; goes full-width inside a mobile card (see the 700px rules). */
.btn-card-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 12px;
    padding: 6px 14px;
    border-radius: 4px;
    background: #fff;
    color: #0f3460;
    border: 1px solid #0f3460;
    cursor: pointer;
    text-decoration: none;
}
.btn-card-action:hover { background: #0f3460; color: #fff; }
.btn-outline {
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 500;
    color: #555;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn-outline:hover {
    background: #f5f7fa;
    border-color: #999;
    color: #333;
}
/* Shared disabled / pending button state. `.btn-pending` keeps the element
   clickable (so handlers can explain why it's not ready) while looking inactive;
   `:disabled` is the hard-disabled state used during in-flight requests. */
.btn:disabled,
.btn.btn-pending {
    opacity: .45;
    cursor: not-allowed;
    box-shadow: none;
}

/* ---- Back Link ---- */
.back-link {
    font-size: 13px;
    color: #0f3460;
    text-decoration: none;
    font-weight: 500;
}
.back-link:hover { text-decoration: underline; }

/* ---- Desktop/Mobile Visibility ---- */
.mobile-only { display: none; }
.desktop-only { display: inline; }

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: 80px 24px;
    color: #888;
    font-size: 15px;
    background: #fff;
    border-radius: 8px;
    border: 1px solid #d5d5d5;
}
.empty-state-icon { margin-bottom: 16px; }
.empty-state-icon svg { display: block; margin: 0 auto; }
.empty-state h3 {
    font-size: 17px;
    color: #555;
    font-weight: 600;
    margin-bottom: 8px;
}
.empty-state p { max-width: 420px; margin: 0 auto; line-height: 1.6; color: #888; font-size: 14px; }

/* ---- Collapsible Sections ---- */
.detail-sections { margin-bottom: 48px; }

.detail-section {
    background: #fff;
    border: 1px solid #d5d5d5;
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
}

.section-heading {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    font-size: 14px;
    font-weight: 700;
    color: #1a1a2e;
    cursor: pointer;
    user-select: none;
    list-style: none;
    border-left: 4px solid #0f3460;
    background: #fafbfc;
}
.section-heading::-webkit-details-marker { display: none; }
.section-heading::before {
    content: "\25B6";
    font-size: 9px;
    color: #999;
    margin-right: 10px;
    transition: transform 0.15s ease;
    display: inline-block;
}
details[open] > .section-heading::before {
    transform: rotate(90deg);
}
.section-heading:hover { background: #f0f2f5; }

.section-body { padding: 16px 20px 20px; }

/* ---- Subsection Heading ---- */
.subsection-heading {
    font-size: 14px;
    font-weight: 700;
    color: #0f3460;
    margin: 20px 0 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid #e0e0e0;
}

/* ---- Field Table ---- */
.field-table {
    width: 100%;
    border-collapse: collapse;
}
.field-table tr { border-bottom: 1px solid #f4f4f4; }
.field-table tr:last-child { border-bottom: none; }
.field-table td {
    padding: 7px 8px;
    vertical-align: top;
    font-size: 13px;
}
.field-table td.lbl {
    font-weight: 600;
    color: #555;
    width: 260px;
    white-space: nowrap;
}
.field-table td.val { color: #222; }

/* ---- Section Note ---- */
.section-note {
    background: #f8f9fb;
    border-left: 3px solid #0f3460;
    padding: 10px 14px;
    margin-bottom: 14px;
    font-size: 13px;
    color: #555;
    line-height: 1.5;
}
.section-note p { margin: 0 0 6px 0; }
.section-note p:last-child { margin-bottom: 0; }
.section-note a { color: #0f3460; }

/* ---- File Link ---- */
.file-link {
    color: #0f3460;
    text-decoration: none;
    font-weight: 500;
}
.file-link:hover { text-decoration: underline; }

/* ---- Form System ---- */
.form-row {
    margin-bottom: 16px;
}
.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #444;
    margin-bottom: 5px;
}
.req-star {
    color: #c0392b;
    font-weight: 700;
}

.form-field {
    display: block;
    width: 100%;
    max-width: 520px;
    padding: 8px 12px;
    font-size: 13px;
    color: #222;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    line-height: 1.4;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}
.form-field:focus {
    outline: none;
    border-color: #0f3460;
}
.form-field[readonly] {
    background: #f5f6f8;
    color: #666;
}
select.form-field {
    max-width: 520px;
    padding-right: 28px;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23999' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}
.form-textarea {
    resize: vertical;
    min-height: 60px;
}
.form-value-readonly {
    font-size: 13px;
    color: #555;
    padding: 8px 0;
    line-height: 1.4;
}
.form-help-text {
    font-size: 12px;
    color: #888;
    margin-top: 4px;
    line-height: 1.4;
}

/* ---- Info tooltip (reusable label/field affordance) ----
   Discoverable "(i)" icon that reveals an explanatory bubble on hover, keyboard
   focus, or tap. Markup:
     <span class="app-tip" tabindex="0" role="note" aria-label="...explanatory text...">
        <svg class="app-tip-ico" ...>...</svg>
        <span class="app-tip-bubble" role="tooltip">...explanatory text...</span>
     </span>
   Keep aria-label and the bubble text identical so AT and sighted users match.
   NOTE: the bubble is position:absolute, so an ancestor with overflow:hidden
   (e.g. .detail-section) clips it. Place the trigger where there is room above
   and to the sides; for a trigger that can sit near a clipped edge, a
   JS-positioned tooltip is the more robust choice. */
.app-tip {
    position: relative;
    display: inline-flex;
    align-items: center;
    margin-left: 2px;
    padding: 3px;            /* roomier hover/tap target around the 14px glyph */
    color: #8b8ba3;
    cursor: help;
    vertical-align: middle;
}
.app-tip:hover,
.app-tip:focus { color: #0f3460; outline: none; }
.app-tip-ico { display: block; }
.app-tip-bubble {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 9px);
    transform: translateX(-50%) translateY(4px);
    z-index: 50;
    width: 240px;
    max-width: 70vw;
    background: #1a1a2e;
    color: #e8e8ef;
    border: 1px solid #2d2d44;
    border-radius: 6px;
    padding: 9px 12px;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.5;
    text-align: left;
    white-space: normal;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .22);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .18s ease, transform .18s ease, visibility .18s;
}
.app-tip-bubble::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -6px;
    border: 6px solid transparent;
    border-top-color: #1a1a2e;
}
/* Reveal on hover/focus of the tip itself, and (convenience) when hovering the
   whole form label that contains a tip — so the user never has to land on the
   small icon or click to see it. */
.app-tip:hover .app-tip-bubble,
.app-tip:focus .app-tip-bubble,
.app-tip:focus-within .app-tip-bubble,
.form-label:hover .app-tip-bubble {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* ---- Callout Banner (reusable) ---- */
.callout-banner {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 18px;
    margin-bottom: 16px;
    border: 1px solid #d5d5d5;
    border-left: 4px solid #888;
    border-radius: 6px;
    background: #f9f9f9;
}
.callout-banner-icon {
    flex-shrink: 0;
    color: #666;
    margin-top: 1px;
}
.callout-banner-content {
    min-width: 0;
}
.callout-banner-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #666;
    margin-bottom: 3px;
}
.callout-banner-value {
    font-size: 15px;
    font-weight: 600;
    color: #1a1a2e;
    line-height: 1.4;
}
.callout-banner--warn {
    background: #fffbeb;
    border-color: #f0d77c;
    border-left-color: #d4a017;
}
.callout-banner--warn .callout-banner-icon { color: #b8860b; }
.callout-banner--warn .callout-banner-label { color: #92711a; }
.callout-banner--info {
    background: #eff6ff;
    border-color: #b3cde8;
    border-left-color: #2c5282;
}
.callout-banner--info .callout-banner-icon { color: #2c5282; }
.callout-banner--info .callout-banner-label { color: #2c5282; }
.callout-banner--success {
    background: #f0fdf4;
    border-color: #a3d5b3;
    border-left-color: #16a34a;
}
.callout-banner--success .callout-banner-icon { color: #16a34a; }
.callout-banner--success .callout-banner-label { color: #155724; }
.callout-banner--error {
    background: #fef2f2;
    border-color: #f5c6cb;
    border-left-color: #c0392b;
}
.callout-banner--error .callout-banner-icon { color: #c0392b; }
.callout-banner--error .callout-banner-label { color: #721c24; }

/* ---- Form Actions ---- */
.form-actions {
    padding-top: 16px;
    border-top: 1px solid #eee;
    margin-top: 8px;
}
.save-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid #eee;
    margin-top: 8px;
}

/* ---- Radio Pills ---- */
.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.radio-pill {
    display: inline-flex;
    cursor: pointer;
    margin: 0;
}
.radio-pill input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.radio-pill-text {
    display: inline-block;
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 500;
    color: #555;
    background: #f0f2f5;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    line-height: 1.4;
    white-space: nowrap;
}
.radio-pill input[type="radio"]:checked + .radio-pill-text {
    background: #0f3460;
    color: #fff;
    border-color: #0f3460;
}
.radio-pill:hover .radio-pill-text {
    border-color: #999;
}

/* ---- Lookup Fields ---- */
.lookup-field {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 6px 10px;
    border: 1px solid transparent;
    border-radius: 6px;
    transition: border-color .15s, background-color .15s;
}
.lookup-field.form-field-error {
    border-color: #dc2626 !important;
    background-color: #fef2f2 !important;
}
.lookup-display {
    font-size: 14px;
    color: #222;
    font-weight: 500;
    min-height: 20px;
}
.lookup-display:empty::before {
    content: "None selected";
    color: #aaa;
    font-weight: 400;
    font-style: italic;
}
.lookup-btn { flex-shrink: 0; }
.lookup-clear-btn {
    font-size: 18px;
    line-height: 1;
    padding: 2px 6px;
    color: #c00;
}

/* ---- File Uploads ---- */
.file-upload-area {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.form-field-file {
    font-size: 0;
    width: 0;
    height: 0;
    overflow: hidden;
    position: absolute;
    opacity: 0;
}
.file-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    font-size: 13px;
    font-weight: 500;
    color: #2962cc;
    background: #f0f5ff;
    border: 1px dashed #a0bfee;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    width: fit-content;
}
.file-upload-btn:hover {
    background: #e2edff;
    border-color: #6e9fe0;
}
.file-upload-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}
.file-upload-hint {
    font-size: 12px;
    color: #8a93a0;
}
.file-upload-area.drag-over,
.form-row.drag-over {
    outline: 2px dashed #6e9fe0;
    outline-offset: 3px;
    background: #f0f5ff;
    border-radius: 6px;
}
.file-upload-area.drag-over .file-upload-btn,
.form-row.drag-over .file-upload-btn {
    background: #e2edff;
    border-color: #6e9fe0;
}
.file-upload-area.drag-over .file-upload-hint,
.form-row.drag-over .file-upload-hint {
    color: #2962cc;
}

.upload-file-list {
    margin-bottom: 4px;
}
.upload-file-list:empty {
    display: none;
}
.upload-file-item {
    display: flex;
    align-items: center;
    padding: 7px 10px;
    margin-bottom: 4px;
    background: #f8f9fb;
    border: 1px solid #e2e5ea;
    border-radius: 5px;
    font-size: 13px;
    transition: background 0.12s;
}
.upload-file-item:hover {
    background: #eef1f5;
}
.upload-file-item .file-icon {
    margin-right: 8px;
    color: #6b7a8d;
    flex-shrink: 0;
}
.upload-file-item .file-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #333;
}
.upload-file-item .file-remove {
    background: none;
    border: none;
    color: #aab2bd;
    cursor: pointer;
    font-size: 18px;
    font-weight: 400;
    padding: 0 2px;
    margin-left: 10px;
    line-height: 1;
    transition: color 0.15s;
}
.upload-file-item .file-remove:hover {
    color: #c33;
}
.upload-file-item.existing-file .file-name a {
    color: #2962cc;
    text-decoration: none;
}
.upload-file-item.existing-file .file-name a:hover {
    text-decoration: underline;
}
.upload-file-item.pending-file .file-name {
    color: #555;
    font-style: italic;
}
.upload-file-item.pending-file .file-name::after {
    content: ' (pending upload)';
    font-size: 11px;
    color: #999;
    font-style: italic;
}

/* ---- Checkbox List ---- */
.checkbox-list {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px 12px;
    max-height: 200px;
    overflow-y: auto;
    background: #fff;
}
.checkbox-list label {
    display: block;
    padding: 4px 0;
    font-size: 13px;
    cursor: pointer;
}
.checkbox-list label:hover {
    background: #f5f7fa;
}
.checkbox-list input[type="checkbox"] {
    margin-right: 8px;
}
.checkbox-list-loading {
    color: #999;
    font-size: 13px;
    padding: 6px 0;
}

/* ---- Validation ---- */
.validation-summary {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    border-left: 4px solid #dc2626;
    border-radius: 6px;
    padding: 14px 18px;
    margin-bottom: 20px;
    font-size: 13px;
    color: #991b1b;
}
.validation-summary strong { display: block; margin-bottom: 6px; }
.validation-summary ul { margin: 0; padding-left: 18px; }
.validation-summary li { margin-bottom: 2px; }

.form-field-error {
    border-color: #dc2626 !important;
    background-color: #fef2f2 !important;
}
.form-field-error-file {
    outline: 2px solid #dc2626;
    outline-offset: 2px;
    border-radius: 4px;
}
.form-field.is-invalid,
.form-field.form-field-error,
select.form-field-error {
    border-color: #dc2626 !important;
    background-color: #fef2f2 !important;
}
.radio-group.is-invalid .radio-pill-text {
    border-color: #dc2626;
    background-color: #fef2f2;
}
.field-error {
    font-size: 12px;
    color: #c0392b;
    margin-top: 4px;
}
.email-error-msg {
    font-size: 12px;
    color: #c0392b;
    margin-top: 4px;
}

/* ---- Info Blocks ---- */
.section-info-block {
    background: #f0f4ff;
    border: 1px solid #c9d6f0;
    border-radius: 6px;
    padding: 14px 18px;
    margin-bottom: 18px;
    font-size: 13px;
    line-height: 1.6;
    color: #333;
}
.section-info-block p { margin: 0 0 8px; }
.section-info-block p:last-child { margin-bottom: 0; }
.section-info-block ul { margin: 4px 0 8px; }
.section-info-block li { margin-bottom: 2px; }
.section-info-block a { color: #4a6fa5; text-decoration: underline; }
.section-info-block-elevated {
    background: #fff8e1;
    border-color: #e8d48a;
}

.section-sub-heading {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a2e;
    margin: 0 0 14px;
    padding-bottom: 6px;
    border-bottom: 1px solid #e0e0e0;
}

/* ---- Context Banners ---- */
.context-banner {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: #f0f4ff;
    border: 1px solid #c9d6f0;
    border-left: 4px solid #4a6fa5;
    border-radius: 6px;
    padding: 14px 18px;
    margin-bottom: 24px;
}
.context-banner-icon {
    flex-shrink: 0;
    color: #4a6fa5;
    margin-top: 1px;
}
.context-banner-body {
    flex: 1;
    min-width: 0;
}
.context-banner-line {
    font-size: 13.5px;
    color: #1a1a2e;
    line-height: 1.6;
}
.context-banner-line .context-label {
    font-weight: 600;
    color: #333;
}
.context-banner-note {
    font-size: 12px;
    color: #667;
    margin-top: 6px;
    line-height: 1.5;
    font-style: italic;
}
.context-banner-link {
    display: inline-block;
    margin-top: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #4a6fa5;
    text-decoration: none;
}
.context-banner-link:hover {
    color: #2d4f7e;
    text-decoration: underline;
}

/* ---- Modals ---- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: rgba(0, 0, 0, .45);
    justify-content: center;
    align-items: center;
}
.modal-overlay.open { display: flex; }
.modal-dialog {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 8px 30px rgba(0,0,0,.25);
    width: 560px;
    max-width: 94vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    animation: modalIn .2s ease;
}
@keyframes modalIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e8e8e8;
}
.modal-header h2 { font-size: 16px; font-weight: 600; margin: 0; }
.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    color: #888;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.modal-close:hover { color: #333; }
.modal-body {
    padding: 20px;
    overflow-y: auto;
    position: relative;
}
.modal-body .doc-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
}
.modal-body .doc-row:last-child { border-bottom: none; }
.modal-body .doc-label {
    font-weight: 500;
    color: #555;
    min-width: 160px;
    flex-shrink: 0;
}
.modal-body .doc-value { color: #333; }
.modal-body .doc-value a { color: #1a73e8; text-decoration: none; }
.modal-body .doc-value a:hover { text-decoration: underline; }
.modal-body .doc-empty { color: #999; font-style: italic; }

.modal-md {
    width: 640px;
    max-width: 94vw;
}
.modal-lg {
    width: 840px;
    max-width: 94vw;
    max-height: 90vh;
}
.modal-loading {
    text-align: center;
    padding: 40px 20px;
    color: #888;
    font-size: 15px;
}
.modal-body-scroll {
    max-height: 78vh;
    overflow-y: auto;
    padding: 16px 24px;
}
/* ---- Modal detail header/actions (shared by subscription + capital call modals) ---- */
.detail-modal-header-info {
    font-size: 14px;
    color: #555;
    margin-bottom: 14px;
}
.detail-modal-actions {
    margin-bottom: 20px;
}

.modal-subsection {
    font-size: 14px;
    font-weight: 700;
    color: #0f3460;
    margin: 20px 0 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid #e0e0e0;
}
.modal-subsection:first-child { margin-top: 0; }

/* ---- Lookup Modal Elements ---- */
.lookup-search-row {
    margin-bottom: 12px;
}
.lookup-search-input {
    max-width: 100% !important;
}
.lookup-results {
    min-height: 80px;
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    background: #fafafa;
}
.lookup-loading,
.lookup-empty {
    text-align: center;
    padding: 24px 12px;
    font-size: 13px;
    color: #888;
}
.lookup-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.lookup-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid #eee;
    font-size: 13px;
    color: #333;
}
.lookup-item:last-child { border-bottom: none; }
.lookup-item:hover { background: #f0f4ff; }
.lookup-item-name { flex: 1; margin-right: 10px; }
.lookup-select-btn { flex-shrink: 0; }
.lookup-add-new-row {
    padding: 10px 0 0;
    text-align: left;
}

/* ---- Tabs ---- */
.contact-tabs {
    margin-bottom: 16px;
}
.contact-tab-bar {
    display: flex;
    border-bottom: 2px solid #dee2e6;
    margin-bottom: 0;
}
.contact-tab {
    padding: 9px 20px;
    font-size: 13px;
    font-weight: 500;
    color: #666;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}
.contact-tab:hover {
    color: #333;
}
.contact-tab.active {
    color: #2962cc;
    border-bottom-color: #2962cc;
}
.contact-tab-panel {
    display: none;
    padding-top: 16px;
}
.contact-tab-panel.active {
    display: block;
}

/* ---- Inner Sections ---- */
.inner-section {
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    margin-bottom: 16px;
    overflow: hidden;
}
.inner-section-heading {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    color: #0f3460;
    cursor: pointer;
    user-select: none;
    list-style: none;
    background: #f8f9fb;
}
.inner-section-heading::-webkit-details-marker { display: none; }
.inner-section-heading::before {
    content: "\25B6";
    font-size: 8px;
    color: #999;
    margin-right: 8px;
    display: inline-block;
}
details[open] > .inner-section-heading::before {
    transform: rotate(90deg);
}
.inner-section-body {
    padding: 12px 16px;
}

/* ---- Misc Shared ---- */
@keyframes fieldHighlight {
    0% { box-shadow: 0 0 0 0 rgba(204, 51, 51, 0.5); }
    50% { box-shadow: 0 0 0 4px rgba(204, 51, 51, 0.3); }
    100% { box-shadow: 0 0 0 0 rgba(204, 51, 51, 0); }
}
.field-highlight-pulse {
    animation: fieldHighlight 0.75s ease 2;
}

.saving-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e0e0e0;
    border-top-color: #0f3460;
    border-radius: 50%;
    margin: 0 auto;
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

.save-success-bar {
    background: #27ae60;
    color: #fff;
    text-align: center;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    transition: opacity 0.3s ease;
}

/* ---- Layout Shell (sidebar + main) ---- */
.layout {
    display: flex;
    gap: 28px;
    align-items: flex-start;
}
.summary-sidebar {
    width: 220px;
    flex-shrink: 0;
    position: sticky;
    top: 72px;
    max-height: calc(100vh - 90px);
    overflow-y: auto;
    background: #fff;
    border: 1px solid #e2e5ea;
    border-radius: 8px;
    padding: 0 0 8px 0;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
    align-self: flex-start;
}
.summary-sidebar-header {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #999;
    padding: 14px 16px 10px;
    border-bottom: 1px solid #eef0f3;
    margin-bottom: 4px;
}
.page-main {
    flex: 1;
    min-width: 0;
    max-width: 1150px;
    padding: 0 0 48px 0;
}

/* ---- Sidebar Summary Items ---- */
.summary-sidebar .summary-item {
    padding: 11px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-left: 3px solid transparent;
    position: relative;
    transition: background 0.12s, color 0.12s;
}
.summary-item[data-filter-category=""]              { border-left-color: #8899aa; }
.summary-item[data-filter-category="action_needed"]  { border-left-color: #3498db; }
.summary-item[data-filter-category="in_progress"]    { border-left-color: #e67e22; }
.summary-item[data-filter-category="completed"]          { border-left-color: #27ae60; }
.summary-item[data-filter-category="approved_modified"]  { border-left-color: #d4880f; }
.summary-item[data-filter-category="approved"]           { border-left-color: #2980b9; }
.summary-item[data-filter-category="pending_approval"]   { border-left-color: #e67e22; }
.summary-clickable { cursor: pointer; transition: background-color 0.15s ease; }
.summary-clickable:hover { background: #f5f7fa; }
.summary-clickable.active[data-filter-category=""]              { background: #f4f6f8; border-left-color: #8899aa; }
.summary-clickable.active[data-filter-category="action_needed"]  { background: #eef6fc; border-left-color: #3498db; }
.summary-clickable.active[data-filter-category="in_progress"]    { background: #fef5ec; border-left-color: #e67e22; }
.summary-clickable.active[data-filter-category="completed"]      { background: #edfbf3; border-left-color: #27ae60; }
.summary-clickable.active[data-filter-category="approved_modified"] { background: #fef8ec; border-left-color: #d4880f; }
.summary-clickable.active[data-filter-category="approved"]       { background: #eef3fc; border-left-color: #2980b9; }
.summary-clickable.active[data-filter-category="pending_approval"] { background: #fef5ec; border-left-color: #e67e22; }
.summary-icon {
    display: flex;
    flex-shrink: 0;
}
.summary-icon svg { display: block; }
.summary-count {
    font-size: 20px;
    font-weight: 700;
    color: #1a1a2e;
    line-height: 1;
    min-width: 24px;
}
.summary-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: #888;
    font-weight: 500;
    line-height: 1.2;
}
.summary-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* ---- Filter Row ---- */
.filter-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 18px;
    font-size: 13px;
    color: #888;
}
.filter-row .record-count {
    margin: 0;
    font-size: 13px;
}
.filter-row .record-count strong { color: #555; }
.filter-sep { color: #d0d0d0; }
.filter-select {
    padding: 6px 28px 6px 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 13px;
    color: #333;
    background: #fff;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23999' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.filter-select:focus { outline: none; border-color: #0f3460; }

/* ---- AppSelect (shared searchable dropdown — the standard filter control) ---- */
.app-select { position: relative; display: inline-block; }
.app-select-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    padding: 6px 10px;
    font-size: 13px;
    color: #333;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 5px;
    cursor: pointer;
    text-align: left;
}
.app-select-trigger:hover { border-color: #0f3460; }
.app-select.open .app-select-trigger,
.app-select--active .app-select-trigger { border-color: #0f3460; color: #0f3460; }
.app-select--active .app-select-trigger { background: #f0f4ff; }
.app-select-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-select-caret { color: #999; flex-shrink: 0; transition: transform 0.15s, color 0.15s; }
.app-select.open .app-select-caret { color: #0f3460; transform: rotate(180deg); }
.app-select-panel {
    display: none;
    position: absolute;
    z-index: 40;
    top: calc(100% + 4px);
    left: 0;
    /* Grow to fit the widest option so long labels (e.g. full investor names)
       are not clipped, but never narrower than the trigger nor wider than the
       viewport. Anything still longer than the cap wraps (see -item-text). */
    width: max-content;
    min-width: 100%;
    max-width: min(440px, calc(100vw - 24px));
    background: #fff;
    border: 1px solid #d5d5d5;
    border-radius: 6px;
    box-shadow: 0 6px 20px rgba(20, 30, 50, 0.12);
}
.app-select.open .app-select-panel { display: block; }
/* When a widened panel would spill past the right edge of the viewport, JS adds
   this class so the panel right-aligns to the trigger and stays on-screen. */
.app-select--flip-right .app-select-panel { left: auto; right: 0; }
/* On mobile the filter grid is single-column and the trigger already spans the
   row, so keep the panel at the trigger width (long labels wrap within it)
   rather than growing — a wider panel can't be kept on-screen beside a
   near-full-width trigger. */
@media (max-width: 700px) {
    .app-select-panel { width: auto; max-width: 100%; }
}
.app-select-search { padding: 8px 10px; border-bottom: 1px solid #eef0f3; }
.app-select-search-input {
    width: 100%;
    padding: 6px 10px;
    font-size: 13px;
    border: 1px solid #ddd;
    border-radius: 5px;
    outline: none;
    box-sizing: border-box;
}
.app-select-search-input:focus { border-color: #0f3460; }
/* width:max-content lets the list (and thus the panel) size to its widest
   option even though it is a vertical scroll container; max-width:100% keeps it
   within the panel's cap so long labels wrap rather than scroll horizontally. */
.app-select-list { width: max-content; min-width: 100%; max-width: 100%; max-height: 240px; overflow-y: auto; padding: 4px 0; }
.app-select-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 12px;
    font-size: 13px;
    color: #333;
    cursor: pointer;
}
.app-select-item:hover { background: #f5f7fa; }
.app-select-item--active { color: #0f3460; font-weight: 600; background: #f0f4ff; }
/* Wrap long labels (full investor names etc.) instead of clipping them with an
   ellipsis, so the whole value is always readable. */
.app-select-item-text { min-width: 0; white-space: normal; overflow-wrap: break-word; word-break: break-word; line-height: 1.35; }
.app-select-check { flex-shrink: 0; margin-top: 2px; color: #0f3460; }
/* Section header for an AppSelect built from a <select> with <optgroup>s. */
.app-select-group {
    padding: 7px 12px 3px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #94a3b8;
}
.app-select-group:not(:first-child) { margin-top: 2px; border-top: 1px solid #f1f5f9; }

.btn-clear-filters {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    font-size: 12px;
    color: #c0392b;
    background: none;
    border: 1px solid #e0c8c5;
    border-radius: 5px;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.15s, color 0.15s;
}
.btn-clear-filters:hover {
    color: #a93226;
    border-color: #c0392b;
}

/* Export CSV button standard: reuse the borderless, navy .app-grid-export style
   (defined with the AppGrid toolbar below). When placed in the outside
   .filter-row toolbar of a card list page, it sits at the top-right, opposite
   the record count; .app-grid-export already hides itself on mobile. */
.filter-row .app-grid-export { margin-left: auto; }

/* ---- Shared Sort control (.app-sort) ----
   The "Sort" dropdown + direction-toggle bar for hand-built card-list pages
   (Indicative Transactions, Initial Subscriptions, Onboarding, Additional Subs,
   Capital Calls). Markup: views/general/app_sort_control.php; behavior:
   window.AppSort (assets/general/app_sort.js). It is NOT a filter input, so it
   lives in the .filter-row toolbar OUTSIDE the collapsible AppFilters panel and
   stays a full-width sort bar on mobile (the Export button hides on mobile). */
.app-sort { display: inline-flex; align-items: center; gap: 6px; }
.app-sort-label { font-size: 12px; font-weight: 600; color: #8a94a0; }
.app-sort-select { max-width: 150px; }
.app-sort-dir {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid #d7dbe0;
    border-radius: 6px;
    background: #fff;
    color: #0f3460;
    cursor: pointer;
    flex-shrink: 0;
}
.app-sort-dir:hover { background: #f2f7fc; border-color: #0f3460; }
.app-sort-dir svg { transition: transform 0.15s ease; }
.app-sort-dir.is-asc svg { transform: rotate(180deg); } /* default arrow = desc; asc flips it up */
/* In a .filter-row toolbar, push Sort + Export to the right as a group: .app-sort
   owns the auto margin; an Export button that FOLLOWS it drops its own auto margin
   (the .filter-row .app-grid-export rule above) so the two sit together. */
.filter-row .app-sort { margin-left: auto; }
.filter-row .app-sort ~ .app-grid-export { margin-left: 0; }

/* Visibility wrapper for an OUTSIDE (mobile) Clear Filters button used with the
   AppFilters panel: hidden until a filter is active (.is-on, toggled by JS), and
   never shown on desktop (the panel header's "Clear all" handles desktop). Pair
   with .btn-clear-filters for the styling. */
.app-filter-clear-mobile { display: none; margin-bottom: 12px; }
.app-filter-clear-mobile.is-on { display: inline-flex; }
@media (min-width: 701px) { .app-filter-clear-mobile { display: none !important; } }

/* ============================================================================
 * Search & Filter panel (AppFilters) — shared, reusable. See assets/general/
 * app_filters.js. Desktop-collapsible header (count badge + Clear all), a
 * prominent search field, an auto-fitting dropdown grid of cascading AppSelects,
 * and removable active-filter chips. Mobile collapses behind .app-filter-toggle.
 * Features only style the cell/card content they inject — not this panel.
 * ========================================================================== */
.app-filter-panel {
    display: block;
    background: #fff;
    border: 1px solid #e4e8ee;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(20, 30, 50, .04),
                0 12px 32px -24px rgba(20, 30, 50, .45);
    margin-bottom: 18px;
    overflow: visible; /* let AppSelect dropdown panels overflow the card */
}

/* ---- Header strip (doubles as the desktop collapse toggle) ---- */
.app-filter-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 18px;
    border-bottom: 1px solid #eef1f5;
    background: linear-gradient(180deg, #fbfcfe 0%, #f4f7fa 100%);
    border-radius: 12px 12px 0 0;
}
.app-filter-head-l { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.app-filter-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    color: #1a2332;
    letter-spacing: .2px;
}
.app-filter-title svg { color: #0f3460; flex-shrink: 0; }
/* Active-filter count pill — revealed by JS (.is-on) when >0 filters apply.
   Lives both in the header (desktop) and the mobile toggle button. */
.app-filter-count {
    display: none;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 7px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    color: #fff;
    background: #0f3460;
    border-radius: 20px;
}
.app-filter-count.is-on { display: inline-flex; }
.app-filter-head-r { display: inline-flex; align-items: center; gap: 8px; }
/* "Clear all" lives in the header on desktop (revealed by JS .is-on). */
.app-filter-clear {
    display: none;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 600;
    color: #c0392b;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background .15s, color .15s;
}
.app-filter-clear:hover { background: #fbecec; color: #a93226; }
.app-filter-clear.is-on { display: inline-flex; }
.app-filter-head-toggle { color: #9aa4b1; flex-shrink: 0; transition: transform .15s; }
.app-filter-panel.is-expanded .app-filter-head-toggle { transform: rotate(180deg); }

/* ---- Body ---- */
.app-filter-body { padding: 16px 18px 18px; }

/* ---- Search field (leading magnifier icon) ---- */
.app-filter-search { position: relative; margin-bottom: 16px; }
.app-filter-search-ico {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    color: #9aa4b1;
    pointer-events: none;
}
.app-filter-search-input {
    width: 100%;
    max-width: 400px; /* capped on desktop; full width on mobile (see @media) */
    padding: 10px 14px 10px 38px;
    font-size: 13.5px;
    color: #1a2332;
    border: 1px solid #d8dee6;
    border-radius: 9px;
    background: #fff;
    box-sizing: border-box;
    -webkit-appearance: none;
    transition: border-color .15s, box-shadow .15s;
}
.app-filter-search-input::placeholder { color: #9aa4b1; }
.app-filter-search-input:focus {
    outline: none;
    border-color: #0f3460;
    box-shadow: 0 0 0 3px rgba(15, 52, 96, .10);
}

/* ---- Dropdown grid (neat auto-fitting columns instead of ragged wrap) ---- */
.app-filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 14px 16px;
}
.app-filter-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}
.app-filter-field label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: #8a93a0;
}
.app-filter-field .app-select { width: 100%; min-width: 0; }

/* Tune the AppSelect trigger to match this panel's taller, rounder controls
   (scoped to .app-filter-panel so the global widget is untouched elsewhere). */
.app-filter-panel .app-select-trigger {
    padding: 9px 12px;
    border-radius: 9px;
    border-color: #d8dee6;
    font-size: 13px;
    transition: border-color .15s, box-shadow .15s, background .15s;
}
.app-filter-panel .app-select-trigger:hover { border-color: #b9c3cf; }
/* Open dropdown gets the focus ring; the active (selected) state is signalled by
   the navy border + light fill from the AppSelect base, kept ring-free. */
.app-filter-panel .app-select.open .app-select-trigger {
    box-shadow: 0 0 0 3px rgba(15, 52, 96, .10);
}

/* ---- AppSelect toggle variant (segmented button group) ---- */
.app-select-toggle {
    display: inline-flex;
    border: 1px solid #d8dee6;
    border-radius: 9px;
    overflow: hidden;
    background: #f4f6f9;
}
.app-select-toggle-btn {
    appearance: none;
    border: 0;
    border-left: 1px solid #d8dee6;
    background: transparent;
    padding: 9px 14px;
    font-size: 13px;
    font-weight: 600;
    color: #5a6473;
    cursor: pointer;
    transition: background .12s, color .12s;
}
.app-select-toggle-btn:first-child { border-left: 0; }
.app-select-toggle-btn:hover:not(:disabled):not(.is-active) { background: #e9eef4; }
.app-select-toggle-btn.is-active { background: #0f3460; color: #fff; }
.app-select-toggle-btn:disabled { color: #b6bcc5; cursor: not-allowed; background: #f4f6f9; }
/* In a filter panel field, fill the column width and split evenly so it aligns
   with the other (full-width) dropdown controls. */
.app-filter-field .app-select-toggle { display: flex; width: 100%; }
.app-filter-field .app-select-toggle-btn { flex: 1 1 0; text-align: center; }

/* ---- Active-filter chips (revealed by JS .is-on) ---- */
.app-filter-chips {
    display: none;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px dashed #e7ebf0;
}
.app-filter-chips.is-on { display: flex; }
.app-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 6px 5px 12px;
    background: #eef3f9;
    border: 1px solid #d9e3ef;
    border-radius: 20px;
    font-size: 12px;
    color: #1a3354;
    max-width: 100%;
}
.app-chip-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 260px;
}
.app-chip-key { font-weight: 700; color: #0f3460; }
.app-chip-x {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    background: rgba(15, 52, 96, .10);
    color: #0f3460;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    transition: background .15s, color .15s;
}
.app-chip-x:hover { background: #0f3460; color: #fff; }

/* ---- Mobile-only collapse toggle (a polished white card button) ---- */
.app-filter-toggle {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    margin-bottom: 12px;
    padding: 13px 16px;
    background: #fff;
    border: 1px solid #e4e8ee;
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(20, 30, 50, .04),
                0 10px 26px -22px rgba(20, 30, 50, .45);
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .2px;
    color: #1a2332;
    cursor: pointer;
}
.app-filter-toggle:hover { border-color: #d3dae3; }
.app-filter-toggle-l { display: inline-flex; align-items: center; gap: 9px; min-width: 0; }
.app-filter-toggle-l > svg { color: #0f3460; flex-shrink: 0; }
.app-filter-toggle-ico { color: #9aa4b1; flex-shrink: 0; transition: transform .15s; }
.app-filter-toggle.is-open .app-filter-toggle-ico { transform: rotate(180deg); }

/* Desktop: the header strip is the collapse toggle; the body collapses beneath
   it. Default is collapsed (no .is-expanded); AppFilters remembers the user's
   choice in localStorage. Scoped to desktop widths (mobile uses the toggle). */
@media (min-width: 701px) {
    .app-filter-head { cursor: pointer; }
    .app-filter-head:hover { background: linear-gradient(180deg, #f7fafc 0%, #eef3f8 100%); }
    .app-filter-body { display: none; }
    .app-filter-panel.is-expanded .app-filter-body { display: block; }
    /* Collapsed: the header is the only visible part — fully round it + drop the
       divider so it reads as a single pill. */
    .app-filter-panel:not(.is-expanded) .app-filter-head {
        border-bottom: none;
        border-radius: 12px;
    }
}

/* Mobile (the standard 700px breakpoint): show the toggle, collapse the panel,
   hide the desktop header, stack one filter per full-width row. */
@media (max-width: 700px) {
    .app-filter-toggle { display: flex; }
    .app-filter-panel.is-collapsed { display: none; }
    .app-filter-head { display: none; }
    .app-filter-body { padding: 14px; }
    .app-filter-grid { grid-template-columns: 1fr; }
    .app-filter-field .app-select { min-width: 0; width: 100%; }
    .app-filter-search-input { font-size: 16px; max-width: 100%; } /* 16px avoids iOS focus zoom */
}

/* ---- Card Hero Row ---- */
.card-hero {
    display: flex;
    gap: 1px;
    margin: 12px 20px 0;
    background: #e2e6ea;
    border-radius: 6px;
    overflow: hidden;
}
.card-hero-item {
    flex: 1;
    padding: 10px 16px;
    background: #f7f9fb;
}
.card-hero-item:first-child {
    border-radius: 6px 0 0 6px;
}
.card-hero-item:last-child {
    border-radius: 0 6px 6px 0;
}
.card-hero-label {
    font-size: 10px;
    font-weight: 600;
    color: #778;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}
.card-hero-value {
    font-size: 16px;
    font-weight: 700;
    color: #1a2332;
    font-variant-numeric: tabular-nums;
}
.card-hero-accent {
    background: #eef3ff;
}
.card-hero-accent .card-hero-value {
    color: #0d6efd;
}

/* ---- Card Action Buttons ---- */
.btn-view-detail {
    background: #0f3460;
    color: #fff;
}
.btn-view-detail:hover {
    background: #0b2a4e;
    color: #fff;
}
.btn-download-pdf {
    background: #f8f9fa;
    color: #333;
    border: 1px solid #ddd;
}
.btn-download-pdf:hover {
    background: #e9ecef;
    color: #333;
}

/* ---- Skeleton Placeholders ---- */
.skel-text {
    display: inline-block;
    width: 72px;
    height: 12px;
    background: #e8eaed;
    border-radius: 4px;
    vertical-align: middle;
    animation: skel-pulse 1.2s ease-in-out infinite;
}
.skel-sm { width: 28px; }
.skel-card { pointer-events: none; }
@keyframes skel-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.4; }
}

/* ---- Responsive ---- */
@media (max-width: 800px) {
    .user-name { display: none; }
    .user-btn { padding: 7px 8px; }
}

@media (max-width: 640px) {
    /* Topbar */
    .topbar { padding: 0 12px; position: static; }
    .topbar-brand { display: none; }
    .desktop-only { display: none; }
    .user-name { display: none; }
    .user-btn { padding: 7px 8px; }

    /* Page wrapper */
    .page-wrapper { padding: 20px 12px 0; }

    /* Layout shell */
    .layout { display: block; }
    .summary-sidebar { display: none; }
    .page-main { padding: 0 0 20px; }
    .mobile-only { display: block; }
    .filter-row { flex-direction: column; align-items: stretch; gap: 8px; }
    .filter-row .filter-sep { display: none; }
    .filter-select { width: 100%; max-width: 100%; }
    /* Sort control becomes a full-width sort bar on mobile (stacked, always
       visible — it's not a filter input, so it never collapses). */
    .filter-row .app-sort { margin-left: 0; width: 100%; }
    .app-sort-select { max-width: none; flex: 1; }
    /* Standard: Clear Filters is full-width with centered text on mobile (it
       sits on its own row in the stacked filter bar). */
    .btn-clear-filters { width: 100%; justify-content: center; box-sizing: border-box; }

    /* Card hero */
    .card-hero { flex-direction: column; }
    .card-hero-item:first-child { border-radius: 6px 6px 0 0; }
    .card-hero-item:last-child  { border-radius: 0 0 6px 6px; }

    /* Modals */
    .modal-dialog { width: 95%; min-width: 0; }
    .modal-body { padding: 14px; }
    .modal-header { padding: 14px 16px; }
    .modal-header h2 { font-size: 15px; }

    /* Field table */
    .field-table td.lbl {
        width: auto;
        white-space: normal;
        display: block;
        padding-bottom: 0;
    }
    .field-table td.val {
        display: block;
        padding-top: 0;
        padding-bottom: 10px;
    }
    .field-table tr { display: block; }

    /* Modal doc rows (Documents, Help, Funding Instructions) */
    .modal-body .doc-row {
        flex-direction: column;
        gap: 2px;
    }
    .modal-body .doc-label {
        min-width: 0;
    }

    /* Form fields */
    .form-field, select.form-field { max-width: 100%; }
    /* .radio-group { flex-direction: column; } */
    /* .lookup-field { flex-direction: column; align-items: flex-start; } */
    .lookup-display { flex: 1; min-width: 0; word-break: break-word; }
}

/* ============================================================================
 * Data Grid (AppGrid)  -- shared, reusable table grid. See assets/general/app_grid.js
 * Standard table styling: toolbar, sticky header, sortable headers, zebra/hover/
 * selected rows, skeleton loading, empty/no-results/error states, footer with
 * load-more or pagination, column menu, and a stacked-card mobile layout.
 * ========================================================================== */
.app-grid { display: block; }

/* Toolbar (quick-search / columns / export) */
.app-grid-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.app-grid-toolbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.app-grid-toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}
.app-grid-search { position: relative; flex: 1 1 220px; max-width: 320px; }
.app-grid-search-input {
    width: 100%;
    padding: 7px 12px;
    font-size: 13px;
    border: 1px solid #d7dbe0;
    border-radius: 6px;
    color: #333;
    box-sizing: border-box;
}
.app-grid-search-input:focus { outline: none; border-color: #0f3460; }

/* Modern CSV export button -- borderless, no background, subtle hover */
.app-grid-export {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 600;
    color: #0f3460;
    background: none;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: color .15s, background .15s;
}
.app-grid-export:hover { color: #0a2747; background: #eef3f9; }
.app-grid-export svg { flex-shrink: 0; }

/* Scroll container + table. Default keeps the page as the scroll context so the
   sticky header follows page scroll; opt into horizontal scrolling per grid with
   scrollX:true (which makes the wrapper the scroll context for wide tables). */
.app-grid-scroll {
    width: 100%;
    border: 1px solid #e8eaed;
    border-radius: 8px;
    background: #fff;
}
.app-grid-scroll--x { overflow-x: auto; }
/* Click-and-drag horizontal panning (set by JS when the table overflows). */
.app-grid-scroll--draggable { cursor: grab; }
.app-grid-scroll--grabbing { cursor: grabbing; user-select: none; }
.app-grid-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    color: #333;
}
.app-grid-th {
    position: sticky;
    /* Offset by the sticky topbar height (56px) so headers tuck beneath it. */
    top: 56px;
    z-index: 2;
    background: #f7f9fb;
    text-align: left;
    font-weight: 600;
    color: #5a6573;
    padding: 10px 12px;
    /* box-shadow keeps the divider visible while the header is stuck
       (collapsed-border tables drop the cell border on scroll). */
    box-shadow: inset 0 -1px 0 #e3e7eb;
    white-space: nowrap;
    user-select: none;
}
/* In horizontal-scroll mode the wrapper itself becomes the sticky containing
   block (overflow-x:auto forces overflow-y to compute to auto), so the 56px
   topbar offset is measured from the wrapper's top — pushing the header down
   and leaving a gap above the first row. Pin it to the wrapper's top instead.
   (scrollX already trades away page-scroll stickiness, per the AppGrid docs.) */
.app-grid-scroll--x .app-grid-th { top: 0; }
/* JS-driven floating header clone for horizontal-scroll grids: shown fixed
   under the topbar while the real header is scrolled past, restoring the
   page-scroll stickiness that overflow-x scrolling otherwise disables. */
.app-grid-floathead {
    position: fixed;
    z-index: 20;
    display: none;
    overflow: hidden;
    background: #f7f9fb;
    box-shadow: 0 4px 8px rgba(15, 52, 96, 0.08);
}
.app-grid-floathead .app-grid-table { table-layout: fixed; border-collapse: collapse; }
.app-grid-floathead .app-grid-th { position: static; }
.app-grid-center { text-align: center; }
.app-grid-right  { text-align: right; }
.app-grid-th.app-grid-center .app-grid-th-label,
.app-grid-th.app-grid-right  .app-grid-th-label { justify-content: center; }

.app-grid-sortable { cursor: pointer; }
.app-grid-sortable:hover { background: #eef2f6; }
.app-grid-th-label { display: inline-flex; align-items: center; gap: 4px; }
.app-grid-sort-ico {
    display: inline-block;
    width: 0; height: 0;
    margin-left: 4px;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-bottom: 5px solid #c2c9d1;
    opacity: 0.5;
    vertical-align: middle;
}
.app-grid-th.is-sorted-asc  .app-grid-sort-ico {
    border-bottom: 5px solid #0f3460; border-top: 0; opacity: 1;
}
.app-grid-th.is-sorted-desc .app-grid-sort-ico {
    border-top: 5px solid #0f3460; border-bottom: 0; opacity: 1;
}

.app-grid-cell {
    padding: 9px 12px;
    border-bottom: 1px solid #eef1f4;
    vertical-align: middle;
}
.app-grid-row:nth-child(even) { background: #fbfcfd; }
.app-grid-row:hover { background: #f2f7fc; }
.app-grid-row.is-selected { background: #e8f1fb; }
.app-grid-row.is-selected:hover { background: #ddeafa; }

/* Optional per-record sub-row (rowDetailRender) — a full-width secondary row
   directly under its record. Zebra moves to explicit record-pair classes
   (nth-child would desync once sub-rows interleave). */
.app-grid--subrows .app-grid-row:nth-child(even) { background: none; }
.app-grid--subrows .app-grid-row--even,
.app-grid-subrow--even { background: #fbfcfd; }
.app-grid-row.has-subrow .app-grid-cell { border-bottom: 0; }
.app-grid-subcell {
    padding: 0 12px 9px;
    border-bottom: 1px solid #eef1f4;
}
/* Hovering the record highlights its sub-row too (and vice versa). */
.app-grid-row:hover + .app-grid-subrow,
.app-grid-subrow:hover { background: #f2f7fc; }

/* Selection checkbox column */
.app-grid-check {
    width: 36px;
    text-align: center;
    padding-left: 12px;
    padding-right: 6px;
}
.app-grid-check input { cursor: pointer; }

/* Skeleton rows */
.app-grid-skelrow td { padding: 11px 12px; border-bottom: 1px solid #eef1f4; }
.app-grid-skelrow .skel-text { width: 80%; }

/* State rows (empty / no-results / error) */
.app-grid-state {
    text-align: center;
    padding: 40px 20px;
    color: #888;
}
.app-grid-state-icon { margin-bottom: 12px; color: #c4ccd4; }
.app-grid-state-title { font-size: 15px; font-weight: 600; color: #555; margin-bottom: 6px; }
.app-grid-state-msg { font-size: 13px; color: #8a94a0; line-height: 1.6; }
.app-grid-state--error .app-grid-state-title { color: #c0392b; }
.app-grid-retry { margin-left: 8px; }

/* Footer: count + pager */
.app-grid-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 2px;
    flex-wrap: wrap;
}
.app-grid-count { font-size: 12px; color: #6b7480; }
.app-grid-count strong { color: #333; }
.app-grid-pager { display: flex; align-items: center; gap: 6px; }
.app-grid-pageinfo { font-size: 12px; color: #6b7480; padding: 0 4px; }
.app-grid-pgbtn {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 4px 9px;
    font-size: 12px;
    font-weight: 600;
    color: #0f3460;
    background: #fff;
    border: 1px solid #d7dbe0;
    border-radius: 6px;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}
.app-grid-pgbtn:hover:not(:disabled) { background: #f2f7fc; border-color: #0f3460; }
.app-grid-pgbtn:disabled { opacity: .45; cursor: not-allowed; }
.app-grid-pgbtn svg { flex-shrink: 0; }
.app-grid-pagesize {
    padding: 5px 8px;
    font-size: 12px;
    border: 1px solid #d7dbe0;
    border-radius: 6px;
    color: #333;
}
.app-grid-loadmore { min-width: 160px; }

/* Columns visibility menu */
.app-grid-cols { position: relative; }
.app-grid-cols-panel {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: #fff;
    border: 1px solid #d7dbe0;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(20, 30, 50, 0.12);
    padding: 8px;
    z-index: 30;
    min-width: 180px;
}
.app-grid-cols.open .app-grid-cols-panel { display: block; }
.app-grid-cols-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    font-size: 13px;
    color: #333;
    border-radius: 6px;
    cursor: pointer;
}
.app-grid-cols-item:hover { background: #f2f7fc; }

/* ---- Mobile card layout (JS toggles .app-grid--mobile via matchMedia) ---- */
/* Layout swap is class-driven (not pure media query) so JS is the single source
   of truth for which layout is rendered. */
.app-grid-cards { display: none; }
.app-grid-stateblock { display: none; }
.app-grid--mobile .app-grid-table { display: none; }
.app-grid--mobile .app-grid-cards { display: block; }
.app-grid--mobile .app-grid-scroll { border: none; background: transparent; overflow: visible; }
.app-grid--state .app-grid-stateblock { display: block; }
.app-grid--state .app-grid-table,
.app-grid--state .app-grid-cards { display: none; }

/* Mobile sort / select-all bar (shown/hidden via inline display from JS) */
.app-grid-mobilebar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.app-grid-mselect {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #2b3440;
}
.app-grid-mselect input { width: 16px; height: 16px; }
.app-grid-msort { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; }
.app-grid-msort-label { font-size: 12px; font-weight: 600; color: #8a94a0; }
.app-grid-msort-select {
    padding: 6px 28px 6px 10px;
    font-size: 13px;
    border: 1px solid #ccc;
    border-radius: 5px;
    color: #333;
    background: #fff;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23999' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    max-width: 170px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.app-grid-msort-dir {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid #d7dbe0;
    border-radius: 6px;
    background: #fff;
    color: #0f3460;
    cursor: pointer;
}
.app-grid-msort-dir:hover { background: #f2f7fc; border-color: #0f3460; }

/* The cards themselves */
.app-grid-card {
    display: flex;
    gap: 10px;
    border: 1px solid #e3e7eb;
    border-radius: 10px;
    background: #fff;
    padding: 14px;
    margin-bottom: 10px;
    box-shadow: 0 1px 2px rgba(20, 30, 50, 0.04);
}
.app-grid-card.is-selected { border-color: #0f3460; background: #f3f8fd; }
.app-grid-card-check { flex: 0 0 auto; padding-top: 2px; }
.app-grid-card-check input { width: 18px; height: 18px; }
.app-grid-card-body { flex: 1 1 auto; min-width: 0; }
.app-grid-card-title {
    font-size: 15px;
    font-weight: 700;
    color: #1d2733;
    margin-bottom: 8px;
    word-break: break-word;
}
.app-grid-card-meta { display: flex; flex-direction: column; gap: 8px; }
/* Stacked label-over-value (standard): avoids the ragged wrapping of
   side-by-side label/value on narrow screens. */
.app-grid-kv { display: flex; flex-direction: column; gap: 1px; font-size: 13px; }
.app-grid-kv-k {
    color: #8a94a0;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.app-grid-kv-v { color: #2b3440; word-break: break-word; }
/* Card action buttons (e.g. View): a full-width row at the bottom of the card. */
.app-grid-card-actions { margin-top: 12px; }
.app-grid-card-actions .btn-card-action,
.app-grid-card-actions .btn { width: 100%; }
.app-grid-skelcard { flex-direction: column; gap: 8px; }
.app-grid-skelcard .skel-text { height: 13px; }

/* Finger-friendly footer + export hidden on mobile (standard) */
@media (max-width: 700px) {
    .app-grid-export { display: none; }
    .app-grid-footer { flex-direction: column-reverse; align-items: stretch; gap: 10px; }
    .app-grid-pager { justify-content: center; }
    .app-grid-pgbtn { padding: 9px 16px; font-size: 13px; }
    .app-grid-pageinfo { font-size: 13px; }
    .app-grid-count { text-align: center; }
    .app-grid-loadmore { width: 100%; }
    /* Standard: record-card View/Details buttons go full-width on mobile. */
    .btn-card-action { width: 100%; }
    /* Standard: the mobile sort bar spans the full width (not right-aligned). */
    .app-grid-mobilebar { flex-direction: column; align-items: stretch; }
    .app-grid-msort { width: 100%; margin-left: 0; }
    .app-grid-msort-select { flex: 1; max-width: none; }
}


/* ==========================================================================
   Topbar Alerts (shared bell + items drawer)
   Markup: bell button in views/general/app_topbar.php; drawer DOM is built by
   assets/general/app_alerts.js and appended to <body>. Desktop: anchored panel
   under the topbar. Mobile (700px): full-height slide-in drawer + dim overlay.
   ========================================================================== */
.topbar-alerts-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: none;
    border: 1px solid rgba(255,255,255,.15);
    border-radius: 4px;
    color: #ccc;
    cursor: pointer;
    flex-shrink: 0;
}
.topbar-alerts-btn:hover { background: rgba(255,255,255,.08); color: #fff; }
.topbar-alerts-count {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 999px;
    background: #e8451c;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 17px;
    text-align: center;
    box-shadow: 0 0 0 2px #1d1d1b; /* ring matching the topbar background */
}
.topbar-alerts-count[hidden] { display: none; }

/* Overlay: invisible click-catcher on desktop, dim scrim on mobile. */
.alerts-overlay {
    position: fixed;
    top: 0; right: 0; bottom: 0; left: 0;
    z-index: 1100;
    background: transparent;
}
.alerts-overlay[hidden] { display: none; }

.alerts-drawer {
    position: fixed;
    top: 64px;
    right: 14px;
    z-index: 1101;
    display: flex;
    flex-direction: column;
    width: 390px;
    max-width: calc(100vw - 28px);
    max-height: calc(100vh - 84px);
    background: #fff;
    border: 1px solid #e3e7eb;
    border-radius: 12px;
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.22);
    overflow: hidden;
    animation: alerts-drop 0.16s ease-out;
}
.alerts-drawer[hidden] { display: none; }
@keyframes alerts-drop {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: none; }
}

.alerts-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 16px;
    border-bottom: 1px solid #eef1f4;
    flex-shrink: 0;
}
.alerts-title {
    flex: 1;
    min-width: 0;
    font-size: 14px;
    font-weight: 700;
    color: #1a1a2e;
}
.alerts-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: none;
    border: none;
    border-radius: 6px;
    color: #8a94a0;
    cursor: pointer;
    flex-shrink: 0;
}
.alerts-close:hover { background: #f0f2f5; color: #1a1a2e; }

.alerts-body {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
}
.alerts-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}
.alerts-item:hover { background: #f2f7fc; }
.alerts-item-ico {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    color: #0f3460;
    background: #eef3f9;
}
.alerts-item-main { flex: 1; min-width: 0; }
.alerts-item-name {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #1a1a2e;
    overflow-wrap: break-word;
}
.alerts-item-fund {
    display: block;
    font-size: 12px;
    color: #6b7480;
    margin-top: 1px;
    overflow-wrap: break-word;
}
.alerts-item-count {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    color: #0f3460;
    background: #eef3f9;
}

/* Loading / empty / error states inside the drawer body. */
.alerts-state {
    padding: 30px 16px;
    text-align: center;
}
.alerts-state-ico { display: inline-block; color: #16a34a; margin-bottom: 8px; }
.alerts-state-title { font-size: 13.5px; font-weight: 600; color: #555; }
.alerts-state-msg { font-size: 12.5px; color: #8a94a0; margin-top: 3px; }
.alerts-state .alerts-retry { margin-top: 12px; }

.alerts-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 16px;
    border-top: 1px solid #eef1f4;
    background: #f9fafb;
    font-size: 13px;
    font-weight: 600;
    color: #0f3460;
    text-decoration: none;
    flex-shrink: 0;
}
.alerts-footer:hover { background: #f2f7fc; }

@media (max-width: 700px) {
    .alerts-overlay { background: rgba(15, 23, 42, 0.45); animation: alerts-fade 0.18s ease-out; }
    .alerts-drawer {
        top: 0;
        right: 0;
        bottom: 0;
        width: 86%;
        max-width: 340px;
        max-height: none;
        border-radius: 0;
        border: none;
        animation: alerts-slide 0.2s ease-out;
    }
    body.alerts-open { overflow: hidden; }
}
@keyframes alerts-slide {
    from { transform: translateX(100%); }
    to   { transform: none; }
}
@keyframes alerts-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}


/* ==========================================================================
   Topbar Main Menu Drawer (shared hamburger + left slide-in menu)
   Markup: hamburger button + drawer include in views/general/app_topbar.php;
   drawer DOM in views/general/app_menu_drawer.php (rendered from the shared
   menu definition data/general/menu_items.php); behavior in
   assets/general/app_menu_drawer.js. The backdrop/panel layer (1200/1201)
   sits above the topbar (100), user dropdown (1000) and alerts drawer
   (1100/1101), and below modals (9000).
   ========================================================================== */
.topbar-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: none;
    border: 1px solid rgba(255,255,255,.15);
    border-radius: 4px;
    color: #ccc;
    cursor: pointer;
    flex-shrink: 0;
    margin-right: 16px;
}
.topbar-menu-btn:hover { background: rgba(255,255,255,.08); color: #fff; }

.menu-drawer-backdrop {
    position: fixed;
    top: 0; right: 0; bottom: 0; left: 0;
    z-index: 1200;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.25s ease;
}
.menu-drawer-backdrop.is-open { opacity: 1; }
.menu-drawer-backdrop[hidden] { display: none; }

.menu-drawer {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 1201;
    display: flex;
    flex-direction: column;
    width: 400px;
    max-width: calc(100vw - 48px);
    background: #fff;
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.28);
    transform: translateX(-102%);
    transition: transform 0.28s cubic-bezier(0.32, 0.72, 0.33, 1);
}
.menu-drawer.is-open { transform: none; }
.menu-drawer[hidden] { display: none; }

.menu-drawer-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: #1d1d1b;
    border-bottom: 3px solid #0f3460;
    flex-shrink: 0;
}
.menu-drawer-head-text { flex: 1; min-width: 0; }
.menu-drawer-eyebrow {
    display: block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    color: #8a94a0;
}
.menu-drawer-title {
    display: block;
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    letter-spacing: .3px;
}
.menu-drawer-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    border-radius: 6px;
    color: #9aa3ad;
    cursor: pointer;
    flex-shrink: 0;
}
.menu-drawer-close:hover { background: rgba(255,255,255,.1); color: #fff; }

.menu-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px 18px;
}

.menu-drawer-section { margin-top: 18px; }
.menu-drawer-section:first-child { margin-top: 4px; }
.menu-drawer-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: #8a909a;
    padding: 0 10px 7px;
    border-bottom: 1px solid #e8ebef;
    margin-bottom: 7px;
}

.menu-drawer-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
}
.menu-drawer-item:hover { background: #f2f6fb; }
.menu-drawer-item[hidden] { display: none; }
.menu-drawer-item-ico {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 9px;
    background: #f0f4ff;
    color: #0f3460;
}
.menu-drawer-item--primary .menu-drawer-item-ico { background: #0f3460; color: #fff; }
.menu-drawer-item-main { flex: 1; min-width: 0; }
.menu-drawer-item-title {
    display: block;
    font-size: 13.5px;
    font-weight: 600;
    color: #1a1a2e;
}
.menu-drawer-item-chev {
    flex-shrink: 0;
    color: #c2c8cf;
    transition: color 0.15s, transform 0.15s;
}
.menu-drawer-item:hover .menu-drawer-item-chev { color: #0f3460; transform: translateX(2px); }

/* "You are here" highlight (set by app_menu_drawer.js) */
.menu-drawer-item.is-current { background: #eef3f9; }
.menu-drawer-item.is-current::before {
    content: '';
    position: absolute;
    left: 0;
    top: 9px;
    bottom: 9px;
    width: 3px;
    border-radius: 2px;
    background: #0f3460;
}
.menu-drawer-item.is-current .menu-drawer-item-title { color: #0f3460; }

/* Compact live-counts strip (hydrated from landing_counts.php) */
.menu-drawer-item-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 3px 10px;
    margin-top: 3px;
}
.menu-drawer-item-metrics[hidden] { display: none; }
.mdm-metric {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #667085;
    white-space: nowrap;
}
.mdm-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}
.mdm-dot--total     { background: #8899aa; }
.mdm-dot--action    { background: #3498db; }
.mdm-dot--funding   { background: #e67e22; }
.mdm-dot--completed { background: #27ae60; }
.mdm-count { font-weight: 700; }
.mdm-metric--attention {
    background: #fff3e0;
    color: #bf5b00;
    font-weight: 600;
    border-radius: 9px;
    padding: 1px 7px 1px 5px;
}
.mdm-metric--attention .mdm-dot { box-shadow: 0 0 0 2px #fff3e0; }
.mdm-skel {
    display: inline-block;
    width: 14px;
    height: 8px;
    border-radius: 4px;
    background: #e8ebef;
    animation: mdm-skel-pulse 1.2s ease-in-out infinite;
}
@keyframes mdm-skel-pulse {
    0%, 100% { opacity: .45; }
    50%      { opacity: 1; }
}

.menu-drawer-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 13px 16px;
    border-top: 1px solid #eef1f4;
    background: #f9fafb;
    font-size: 13px;
    font-weight: 600;
    color: #0f3460;
    text-decoration: none;
    flex-shrink: 0;
}
.menu-drawer-footer:hover { background: #f2f7fc; }
/* MENU-3: "you are here" highlight for the footer "Open full menu" link — applied
   by app_menu_drawer.js when on app_main_menu.php itself (the footer is the only
   drawer entry for the home page and is NOT a .menu-drawer-item, so the item
   highlight rule above never matches it). Footer is centered, so use the same
   #eef3f9 wash as the items plus a heavier weight rather than the items' left bar. */
.menu-drawer-footer.is-current { background: #eef3f9; font-weight: 700; }

/* Staggered section entrance while the panel slides in (CSS-only) */
.menu-drawer-section,
.menu-drawer-footer {
    opacity: 0;
    transform: translateX(-10px);
    transition: opacity 0.32s ease, transform 0.32s ease;
}
.menu-drawer.is-open .menu-drawer-section,
.menu-drawer.is-open .menu-drawer-footer {
    opacity: 1;
    transform: none;
}
.menu-drawer.is-open .menu-drawer-section:nth-child(1) { transition-delay: 0.05s; }
.menu-drawer.is-open .menu-drawer-section:nth-child(2) { transition-delay: 0.11s; }
.menu-drawer.is-open .menu-drawer-section:nth-child(3) { transition-delay: 0.17s; }
.menu-drawer.is-open .menu-drawer-section:nth-child(4) { transition-delay: 0.23s; }
.menu-drawer.is-open .menu-drawer-section:nth-child(n+5) { transition-delay: 0.29s; }
.menu-drawer.is-open .menu-drawer-footer { transition-delay: 0.29s; }

body.menu-drawer-open { overflow: hidden; }

@media (max-width: 700px) {
    .menu-drawer { width: 88%; max-width: 360px; }
}

@media (prefers-reduced-motion: reduce) {
    .menu-drawer,
    .menu-drawer-backdrop,
    .menu-drawer-section,
    .menu-drawer-footer,
    .menu-drawer-item-chev { transition: none; }
    .mdm-skel { animation: none; }
}
/* Reduced-motion parity for the adjacent alerts drawer (pre-existing section
   above had no guard; kept here so both topbar drawers behave alike). */
@media (prefers-reduced-motion: reduce) {
    .alerts-drawer,
    .alerts-overlay { animation: none; }
}

/* ============================================================
   Download progress buttons (AppDownload, assets/general/app_download.js)
   Applied to a .btn while a data-dl-progress download is running.
   ============================================================ */
.btn.is-downloading {
    position: relative;
    overflow: hidden;
    pointer-events: none;
    opacity: 0.92;
}
.btn .dl-spinner {
    display: inline-block;
    width: 13px;
    height: 13px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    vertical-align: -2px;
    margin-right: 6px;
    opacity: 0.9;
    animation: spin 0.8s linear infinite;
}
.btn .dl-bar {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    width: 0;
    background: currentColor;
    opacity: 0.75;
    transition: width 0.2s ease;
}
.btn.is-dl-error {
    background: #c0392b;
    border-color: #c0392b;
    color: #fff;
}
.dl-hidden-frame { display: none; }
@media (prefers-reduced-motion: reduce) {
    .btn .dl-spinner { animation-duration: 1.6s; }
    .btn .dl-bar { transition: none; }
}

/* ==========================================================================
   Unread Data Room files badge (topbar icon + menu pills)
   Markup: topbar icon link in views/general/app_topbar.php (reuses the
   .topbar-alerts-btn square-button look + .topbar-alerts-count pill); the
   [data-dru-badge] pills sit beside the Data Rooms title in
   views/general/app_menu_drawer.php and views/main_menu/menu_view.php
   (rendered from the 'badge' key in data/general/menu_items.php).
   Hydrated by assets/general/app_dr_unread.js from
   api/data_rooms/unread_count.php — everything stays hidden at count 0.
   ========================================================================== */
/* The Investor Statements topbar icon + menu pills (app_stmts_unread.js) reuse
   the same square-button look and count-pill styles below; they're grouped here
   so the two badges never drift. */
.topbar-dru-btn, .topbar-stmts-btn { text-decoration: none; }
.topbar-dru-btn[hidden], .topbar-stmts-btn[hidden] { display: none; }

/* Count pill on a menu entry title (drawer item / main-menu tile). For Data
   Rooms (.dru-badge, app_dr_unread.js) and Investor Statements (.stmts-badge,
   app_stmts_unread.js) the menu entry links to the full list and clicking the
   pill deep-links to that item's Unread-filtered list; the To-Do entry
   (.todo-badge, app_alerts.js) already links to its list, so its pill is
   display-only. All three are cursor:pointer below. */
.dru-badge, .stmts-badge, .todo-badge {
    display: inline-block;
    min-width: 18px;
    padding: 1px 7px;
    margin-left: 6px;
    border-radius: 999px;
    background: #e8451c;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    vertical-align: 1px;
    cursor: pointer;
}
.dru-badge:hover, .stmts-badge:hover, .todo-badge:hover { background: #c93a16; }
.dru-badge[hidden], .stmts-badge[hidden], .todo-badge[hidden] { display: none; }

/* ------------------------------------------------------------------ *
 * Access Restricted modal (window.appAccessDenied — general.js)
 * Shown when a user attempts a screen-permission-gated client action (the
 * Export buttons today). Mirrors the page-level access-denied interstitial
 * (views/general/access_denied_view.php) but as a dismissible overlay. z-index
 * sits above the app's stacked modals (launchpad modals ~9000-9100) so it shows
 * even when an export button is clicked inside another modal.
 * ------------------------------------------------------------------ */
.app-deny-overlay {
    position: fixed;
    inset: 0;
    z-index: 9600;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    box-sizing: border-box;
    background: rgba(15, 52, 96, 0.45);
}
.app-deny-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(15, 52, 96, 0.28);
    padding: 32px 28px 24px;
    text-align: center;
}
.app-deny-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fdecea;
    color: #c0392b;
}
.app-deny-title {
    margin: 0 0 10px;
    font-size: 20px;
    font-weight: 700;
    color: #0f3460;
}
.app-deny-msg {
    margin: 0 0 22px;
    font-size: 14px;
    line-height: 1.6;
    color: #4a5568;
}
.app-deny-actions {
    display: flex;
    justify-content: center;
}
.app-deny-ok {
    min-width: 110px;
    justify-content: center;
}

/* ---- Idle-session timeout warning modal (assets/general/app_session_timeout.js) ----
   Mirrors the Access Restricted modal's look (same overlay/card/icon system) with
   an amber "clock" treatment and a two-button action row. z-index matches the
   modal band (above the menu drawer at 1201; see README §6). */
.app-idle-overlay {
    position: fixed;
    inset: 0;
    z-index: 9600;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    box-sizing: border-box;
    background: rgba(15, 52, 96, 0.45);
}
.app-idle-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(15, 52, 96, 0.28);
    padding: 32px 28px 24px;
    text-align: center;
}
.app-idle-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fef5e7;
    color: #d68910;
}
.app-idle-title {
    margin: 0 0 10px;
    font-size: 20px;
    font-weight: 700;
    color: #0f3460;
}
.app-idle-msg {
    margin: 0 0 22px;
    font-size: 14px;
    line-height: 1.6;
    color: #4a5568;
}
.app-idle-count {
    font-weight: 700;
    color: #0f3460;
}
.app-idle-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}
.app-idle-actions .btn {
    min-width: 130px;
    justify-content: center;
}
@media (max-width: 480px) {
    .app-idle-actions { flex-direction: column-reverse; }
    .app-idle-actions .btn { width: 100%; }
}

/* ---- Document viewer modal (assets/general/app_doc_viewer.js) ----
   Rides the shared .modal-overlay backdrop (z-index 9000 band — above the
   topbar drawers, below nothing). The dialog owns the height; the PDF.js
   viewer.html iframe (PDFs) or the scrollable image wrap fills it. */
body.docv-open { overflow: hidden; }
.docv-dialog {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 8px 30px rgba(0,0,0,.25);
    width: min(1100px, 96vw);
    height: min(900px, 92vh);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalIn .2s ease;
}
.docv-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid #e8e8e8;
}
.docv-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.docv-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.docv-download { display: inline-flex; align-items: center; gap: 6px; }
/* #525659 = the PDF.js viewer's own background, so the frame edges never
   flash white while a document loads. */
.docv-body {
    flex: 1;
    min-height: 0;
    display: flex;
    background: #525659;
}
.docv-frame { flex: 1; width: 100%; height: 100%; border: 0; }
.docv-imgwrap {
    flex: 1;
    overflow: auto;
    background: #fff;
    padding: 12px;
}
.docv-img { display: block; max-width: 100%; height: auto; margin: 0 auto; }
.docv-img-msg {
    margin: 24px auto;
    text-align: center;
    color: #666;
    font-size: 14px;
}
@media (max-width: 700px) {
    .docv-dialog {
        width: 100%;
        height: 100%;
        max-width: none;
        border-radius: 0;
    }
}
