/* ECITE v3 desktop visual alignment (DarkTheme.xaml tokens) */
:root,
html.theme-dark {
    --bg-primary: #1E1E1E;
    --bg-secondary: #252526;
    --bg-tertiary: #2D2D30;
    --bg-hover: #2A2D2E;
    --bg-active: #37373D;
    --border: #3C3C3C;
    --text-primary: #CCCCCC;
    --text-secondary: #858585;
    --accent: #0078D4;
    --accent-hover: #1A8FE8;
    --status-error: #D97706;
    --status-success: #22C55E;
    --status-danger: #EF4444;
    --form-section-surface: #2A2A2D;
    --form-section-header: #323235;
    --nested-folder-surface: #252528;
    --scrollbar-track: #252526;
    --scrollbar-thumb: #4A4A4A;
    --scrollbar-thumb-hover: #5E5E5E;
    --close-hover: #C42B1C;
    --font: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.45);
}

html.theme-light {
    --bg-primary: #F3F3F3;
    --bg-secondary: #FFFFFF;
    --bg-tertiary: #EEEEEE;
    --bg-hover: #E8E8E8;
    --bg-active: #DEDEDE;
    --border: #D0D0D0;
    --text-primary: #1E1E1E;
    --text-secondary: #616161;
    --accent: #0078D4;
    --accent-hover: #106EBE;
    --status-error: #C47F00;
    --status-success: #16803C;
    --status-danger: #C42B1C;
    --form-section-surface: #FFFFFF;
    --form-section-header: #F0F0F0;
    --nested-folder-surface: #F7F7F7;
    --scrollbar-track: #F0F0F0;
    --scrollbar-thumb: #C0C0C0;
    --scrollbar-thumb-hover: #A8A8A8;
    --close-hover: #C42B1C;
    --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.12);
}

/* ===== Authenticated app shell ===== */
html {
    height: 100%;
}

body.ecite-app {
    margin: 0;
    background: var(--bg-primary);
    color: var(--text-primary);
    font: 14px/1.45 var(--font);
    height: 100%;
    overflow: hidden;
}

body.ecite-app * {
    box-sizing: border-box;
}

body.ecite-app ::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

body.ecite-app ::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

body.ecite-app ::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 4px;
}

body.ecite-app ::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

body.ecite-app a {
    color: var(--accent);
}

body.ecite-app a:hover {
    color: var(--accent-hover);
}

/* Sidebar */
body.ecite-app .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 240px;
    height: 100%;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    box-shadow: none;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 1100;
    display: flex;
    flex-direction: column;
}

body.ecite-app .sidebar.open {
    transform: translateX(0);
}

body.ecite-app .sidebar-brand {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    padding: 0 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

body.ecite-app .sidebar-brand .brand-logo {
    display: none;
    height: 28px;
    width: auto;
    max-width: 148px;
    object-fit: contain;
    flex-shrink: 0;
}

html.theme-dark body.ecite-app .sidebar-brand .brand-logo-dark {
    display: block;
}

html.theme-light body.ecite-app .sidebar-brand .brand-logo-light {
    display: block;
}

body.ecite-app .sidebar-nav {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 8px 6px;
}

body.ecite-app .sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 2px 8px;
    padding: 10px 12px;
    border-radius: 6px;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 14px;
    background: transparent;
    border: 1px solid transparent;
}

body.ecite-app .sidebar-nav a:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

body.ecite-app .sidebar-nav a.active {
    background: var(--bg-active);
    color: var(--text-primary);
}

body.ecite-app .sidebar-nav .nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: inherit;
}

body.ecite-app .sidebar-nav .nav-icon svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
    display: block;
}

body.ecite-app .sidebar-nav .nav-icon svg path {
    fill: currentColor;
}

body.ecite-app .sidebar-footer {
    margin-top: auto;
    padding: 8px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    text-align: left;
    font-size: 12px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

body.ecite-app .sidebar-footer .user-chip {
    display: block;
    margin: 0 0 10px;
    padding: 2px 4px 0;
    background: none;
    border: none;
    border-radius: 0;
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.35;
    word-break: break-all;
}

body.ecite-app .sidebar-footer a {
    display: block;
    padding: 10px 12px;
    margin: 2px 0;
    border-radius: 6px;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 14px;
    border: 1px solid transparent;
}

body.ecite-app .sidebar-footer a.footer-link:hover,
body.ecite-app .sidebar-footer a.footer-logout:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

body.ecite-app .sidebar-footer a.footer-logout {
    background: var(--bg-tertiary);
    border-color: var(--border);
}

body.ecite-app .sidebar-copy {
    display: block;
    margin-top: 8px;
    padding: 4px 4px 0;
    font-size: 11px;
    color: var(--text-secondary);
}

/* Main column */
body.ecite-app .main-content {
    margin-left: 0;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    transition: margin-left 0.2s ease;
    overflow: hidden;
}

/* Only shift content when the sidebar can sit beside it (desktop). */
@media (min-width: 769px) {
    body.ecite-app .main-content.shift {
        margin-left: 240px;
    }
}

body.ecite-app .header {
    position: sticky;
    top: 0;
    z-index: 200;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 60px;
    height: 60px;
    padding: 0 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

body.ecite-app .header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

body.ecite-app .header-left img {
    display: none; /* logo lives in sidebar; keep page title feel */
}

body.ecite-app .page-title {
    margin: 0;
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

body.ecite-app .menu-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 18px;
    cursor: pointer;
}

body.ecite-app .menu-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

body.ecite-app .header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

body.ecite-app .main-container {
    flex: 1 1 0%;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    padding: 24px;
    background: var(--bg-primary);
    color: var(--text-primary);
}

body.ecite-app .overlay {
    background: rgba(0, 0, 0, 0.55);
}

@media (max-width: 768px) {
    /* Document scroll is more reliable on mobile browsers than nested overflow. */
    html,
    body.ecite-app {
        height: auto;
        min-height: 100%;
        min-height: 100dvh;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    body.ecite-app .main-content {
        height: auto;
        min-height: 100dvh;
        overflow: visible;
    }

    body.ecite-app .header {
        position: sticky;
        top: 0;
        height: auto;
        min-height: 56px;
        flex-wrap: nowrap;
        padding: 8px 12px;
        gap: 8px;
    }

    body.ecite-app .header-left {
        flex: 0 1 auto;
        min-width: 0;
    }

    body.ecite-app .page-title {
        font-size: 17px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1.25;
    }

    body.ecite-app .header-right {
        flex: 1 1 auto;
        width: auto;
        min-width: 0;
        justify-content: flex-end;
    }

    body.ecite-app .agency-switcher.visible {
        width: auto;
        max-width: 100%;
        flex-direction: row;
        align-items: center;
        gap: 6px;
        min-width: 0;
    }

    body.ecite-app .agency-switcher label {
        display: none;
    }

    body.ecite-app .agency-search-wrap {
        width: min(220px, 48vw);
        min-width: 0;
        max-width: 100%;
        flex: 1 1 auto;
    }

    body.ecite-app .main-container {
        flex: none;
        overflow: visible;
        padding: 12px;
        touch-action: auto;
    }

    body.ecite-app input[type="text"],
    body.ecite-app input[type="email"],
    body.ecite-app input[type="password"],
    body.ecite-app input[type="number"],
    body.ecite-app input[type="date"],
    body.ecite-app input[type="datetime-local"],
    body.ecite-app input[type="search"],
    body.ecite-app input[type="tel"],
    body.ecite-app select,
    body.ecite-app textarea {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        font-size: 16px; /* avoids iOS focus-zoom and keeps labels readable */
    }

    body.ecite-app .form-grid,
    body.ecite-app .param-grid,
    body.ecite-app .form-row-split,
    body.ecite-app .theme-options {
        grid-template-columns: 1fr !important;
    }

    body.ecite-app .court-table-wrap,
    body.ecite-app .ord-table-wrap,
    body.ecite-app .account-table-wrap {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    body.ecite-app .sidebar {
        width: min(280px, 86vw);
        transform: translateX(-100%);
    }

    body.ecite-app .sidebar.open {
        transform: translateX(0);
    }
}

/* Agency switcher */
body.ecite-app .agency-switcher {
    display: none;
    align-items: center;
    gap: 10px;
    position: relative;
}

body.ecite-app .agency-switcher.visible {
    display: flex;
}

body.ecite-app .agency-switcher label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: none;
    letter-spacing: 0;
    white-space: nowrap;
}

body.ecite-app .agency-search-wrap {
    position: relative;
    width: min(640px, 55vw);
    min-width: 360px;
    flex: 1 1 420px;
}

@media (min-width: 769px) {
    body.ecite-app .agency-search-wrap {
        width: min(640px, 55vw);
        min-width: 360px;
        max-width: 640px;
        flex: 1 1 420px;
    }
}

body.ecite-app .agency-switcher input[type="search"],
body.ecite-app .agency-switcher input[type="text"] {
    width: 100%;
    height: 36px;
    padding: 8px 10px 8px 34px;
    border-radius: 4px;
    border: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-primary);
    background: var(--bg-primary) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%858585' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") no-repeat 10px center;
    box-shadow: none;
}

body.ecite-app .agency-switcher input::placeholder {
    color: var(--text-secondary);
}

body.ecite-app .agency-switcher input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: none;
    background-color: var(--bg-primary);
}

body.ecite-app .agency-search-results {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: var(--shadow-soft);
    overflow: hidden;
    padding: 0;
}

body.ecite-app .agency-search-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 2px;
    width: 100%;
    margin: 0;
    padding: 10px 12px;
    border: 0;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    background: transparent;
    color: var(--text-primary);
    font: inherit;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    box-shadow: none;
    appearance: none;
    -webkit-appearance: none;
}

body.ecite-app .agency-search-item:last-child {
    border-bottom: 0;
}

body.ecite-app .agency-search-item:hover,
body.ecite-app .agency-search-item.active {
    background: var(--bg-active);
}

body.ecite-app .agency-search-item:focus {
    outline: none;
    background: var(--bg-active);
}

body.ecite-app .agency-search-item .agency-name {
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

body.ecite-app .agency-search-item .agency-ori {
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.3;
}

body.ecite-app .agency-search-empty {
    padding: 12px;
    color: var(--text-secondary);
    font-size: 13px;
}

/* Dialogs / loading */
body.ecite-app .ui-dialog-content,
body.ecite-app .ui-loading-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

body.ecite-app .ui-dialog-header {
    background: var(--form-section-header);
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
}

body.ecite-app .ui-dialog-header h3 {
    font-size: 14px;
    font-weight: 600;
}

body.ecite-app .ui-dialog-close {
    color: var(--text-secondary);
}

body.ecite-app .ui-dialog-close:hover {
    color: #fff;
}

body.ecite-app .ui-dialog-body,
body.ecite-app .ui-loading-text {
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 400;
}

body.ecite-app .ui-dialog-btn {
    height: 36px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 0 14px;
    font-size: 13px;
}

body.ecite-app .ui-dialog-btn:hover {
    background: var(--bg-hover);
}

body.ecite-app .ui-dialog-btn-primary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

body.ecite-app .ui-dialog-btn-secondary {
    background: var(--bg-primary);
}

body.ecite-app .ui-dialog-btn-danger {
    background: var(--bg-tertiary);
    border-color: var(--status-danger);
    color: var(--status-danger);
}

body.ecite-app .ui-loading-spinner {
    border-color: var(--border);
    border-top-color: var(--accent);
}

body.ecite-app .ui-loading-modal {
    background: rgba(0, 0, 0, 0.55);
}

/* ===== Shared controls ===== */
body.ecite-app h1,
body.ecite-app h2,
body.ecite-app h3,
body.ecite-app h4 {
    color: var(--text-primary);
    font-weight: 600;
}

body.ecite-app h2 {
    font-size: 22px;
}

body.ecite-app h3 {
    font-size: 15px;
}

body.ecite-app .btn,
body.ecite-app button.btn {
    height: 36px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 0 14px;
    font-size: 13px;
    font-weight: 400;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

body.ecite-app .btn:hover,
body.ecite-app button.btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

body.ecite-app .btn-primary,
body.ecite-app button.btn-primary {
    height: 44px;
    border-radius: 8px;
    background: var(--bg-tertiary);
    border-color: var(--border);
    color: var(--text-primary);
}

body.ecite-app .btn-primary:hover,
body.ecite-app button.btn-primary:hover {
    background: var(--bg-hover);
}

body.ecite-app .btn-secondary,
body.ecite-app button.btn-secondary {
    background: var(--bg-primary);
}

body.ecite-app .btn-danger,
body.ecite-app button.btn-danger {
    background: var(--bg-tertiary);
    border-color: var(--status-danger);
    color: var(--status-danger);
}

body.ecite-app .btn-danger:hover {
    background: rgba(239, 68, 68, 0.12);
}

body.ecite-app .btn-warning,
body.ecite-app button.btn-warning {
    background: var(--bg-tertiary);
    border-color: var(--status-error);
    color: var(--status-error);
}

body.ecite-app .btn-sm,
body.ecite-app button.btn-sm {
    height: 28px;
    padding: 0 10px;
    font-size: 12px;
    border-radius: 6px;
}

body.ecite-app .btn:disabled,
body.ecite-app button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

body.ecite-app input[type="text"],
body.ecite-app input[type="email"],
body.ecite-app input[type="password"],
body.ecite-app input[type="number"],
body.ecite-app input[type="date"],
body.ecite-app input[type="datetime-local"],
body.ecite-app input[type="search"],
body.ecite-app input[type="tel"],
body.ecite-app select,
body.ecite-app textarea {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    min-height: 36px;
    padding: 8px 10px;
    font: 13px/1.4 var(--font);
}

body.ecite-app textarea {
    min-height: 80px;
}

body.ecite-app input:focus,
body.ecite-app select:focus,
body.ecite-app textarea:focus {
    outline: none;
    border-color: var(--accent);
}

body.ecite-app label {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
}

body.ecite-app .form-group label {
    margin-bottom: 4px;
}

/* Panels */
body.ecite-app .panel,
body.ecite-app .reports-section,
body.ecite-app .court-section,
body.ecite-app .ord-table-wrap,
body.ecite-app .records-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: none;
    padding: 12px;
}

body.ecite-app .reports-section,
body.ecite-app .court-section {
    margin-bottom: 12px;
}

body.ecite-app .section-header,
body.ecite-app .reports-section h3,
body.ecite-app .court-section .section-header h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

body.ecite-app .reports-section h3::before,
body.ecite-app .court-section .section-header h3::before {
    content: "";
    width: 3px;
    height: 1.1em;
    border-radius: 2px;
    background: var(--accent);
}

body.ecite-app .reports-help,
body.ecite-app .court-help,
body.ecite-app .court-subtitle,
body.ecite-app .ord-subtitle,
body.ecite-app .records-subtitle,
body.ecite-app .role-hint-block {
    color: var(--text-secondary) !important;
    font-size: 12px;
}

body.ecite-app .reports-banner,
body.ecite-app .court-banner,
body.ecite-app .ord-banner,
body.ecite-app .gap-banner {
    background: var(--form-section-surface);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: 6px;
}

body.ecite-app .gap-banner {
    color: var(--status-error);
    border-color: #6b4f1d;
    background: #2a2418;
}

body.ecite-app .gap-banner.gap-banner-overlap {
    color: var(--status-danger);
    border-color: #6b2b2b;
    background: #2a1c1c;
}

body.ecite-app .agency-badge,
body.ecite-app .mode-badge,
body.ecite-app .status-badge {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: 6px;
    font-weight: 600;
    font-size: 12px;
}

body.ecite-app .mode-badge.mode-select,
body.ecite-app .mode-badge.mode-between,
body.ecite-app .status-enabled {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

body.ecite-app .status-enabled {
    color: var(--status-success);
    border-color: rgba(34, 197, 94, 0.35);
}

body.ecite-app .status-disabled {
    color: var(--text-secondary);
}

/* Report cards / selection */
body.ecite-app .report-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
}

body.ecite-app .report-card:hover {
    background: var(--bg-hover);
    border-color: var(--border);
}

body.ecite-app .report-card.selected {
    background: var(--bg-active);
    border-color: var(--accent);
    box-shadow: none;
}

body.ecite-app .report-title {
    color: var(--text-primary);
    font-weight: 600;
}

body.ecite-app .report-desc {
    color: var(--text-secondary);
}

/* Tables — size columns to content; scroll horizontally when needed */
body.ecite-app .court-table-wrap,
body.ecite-app .ord-table-wrap,
body.ecite-app .account-table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

body.ecite-app table,
body.ecite-app .court-table,
body.ecite-app .ord-table,
body.ecite-app .account-table,
body.ecite-app .user-table {
    background: var(--bg-primary);
    color: var(--text-primary);
    border-collapse: collapse;
    width: max-content;
    min-width: 100%;
    table-layout: auto;
}

body.ecite-app th,
body.ecite-app .court-table th,
body.ecite-app .ord-table th,
body.ecite-app .account-table th,
body.ecite-app .user-table th {
    background: var(--bg-tertiary) !important;
    color: var(--text-secondary) !important;
    font-size: 12px;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    padding: 8px 10px;
    white-space: nowrap;
}

body.ecite-app td,
body.ecite-app .court-table td,
body.ecite-app .ord-table td,
body.ecite-app .account-table td,
body.ecite-app .user-table td {
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 10px;
    font-size: 13px;
    white-space: nowrap;
}

body.ecite-app tr:nth-child(even),
body.ecite-app .court-table tr:nth-child(even),
body.ecite-app .ord-table tr:nth-child(even) {
    background: var(--bg-secondary);
}

html.theme-dark body.ecite-app .court-table tr.row-gap-warning,
html.theme-dark body.ecite-app .court-table tr.row-gap-warning:nth-child(even) {
    background: #3a3018 !important;
}

html.theme-light body.ecite-app .court-table tr.row-gap-warning,
html.theme-light body.ecite-app .court-table tr.row-gap-warning:nth-child(even) {
    background: #fff3cd !important;
}

html.theme-dark body.ecite-app .court-table tr.row-overlap-warning,
html.theme-dark body.ecite-app .court-table tr.row-overlap-warning:nth-child(even) {
    background: #3a1f22 !important;
}

html.theme-light body.ecite-app .court-table tr.row-overlap-warning,
html.theme-light body.ecite-app .court-table tr.row-overlap-warning:nth-child(even) {
    background: #fdecee !important;
}

body.ecite-app .gap-banner {
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
}

html.theme-dark body.ecite-app .gap-banner {
    border-color: #6b5320;
    background: #3a3018;
    color: #f0c36d;
}

html.theme-light body.ecite-app .gap-banner {
    border-color: #f0c36d;
    background: #fff8e6;
    color: #7a5b00;
}

html.theme-dark body.ecite-app .gap-banner.gap-banner-overlap {
    border-color: #6b3038;
    background: #3a1f22;
    color: #f0a8b0;
}

html.theme-light body.ecite-app .gap-banner.gap-banner-overlap {
    border-color: #e0a0a8;
    background: #fdecee;
    color: #7a1f2b;
}

html.theme-dark body.ecite-app .gap-warning-text {
    color: #f0c36d;
}

html.theme-light body.ecite-app .gap-warning-text {
    color: #8a6d00;
}

html.theme-dark body.ecite-app .row-overlap-warning .gap-warning-text {
    color: #f0a8b0;
}

html.theme-light body.ecite-app .row-overlap-warning .gap-warning-text {
    color: #7a1f2b;
}

body.ecite-app .empty-row td {
    color: var(--text-secondary) !important;
}

/* Modals on pages — ensure overlays are fixed, not inline page content */
body.ecite-app .modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.55);
}

body.ecite-app .modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

body.ecite-app .modal-header {
    background: var(--form-section-header);
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
}

body.ecite-app .modal-header h3 {
    font-size: 14px;
    font-weight: 600;
}

body.ecite-app .modal-header .close {
    color: var(--text-secondary);
}

body.ecite-app .modal-body {
    color: var(--text-primary);
}

/* User admin / accounts common overrides */
body.ecite-app .user-admin-page,
body.ecite-app .court-page,
body.ecite-app .ord-page,
body.ecite-app .reports-page,
body.ecite-app .records-page {
    color: var(--text-primary);
}

body.ecite-app fieldset,
body.ecite-app .role-fieldset {
    border: 1px solid var(--border) !important;
    background: var(--form-section-surface);
    border-radius: 8px !important;
    color: var(--text-primary);
}

body.ecite-app fieldset legend,
body.ecite-app .role-fieldset legend {
    color: var(--text-secondary) !important;
    font-size: 12px;
    font-weight: 600;
}

body.ecite-app .critical,
body.ecite-app .text-danger {
    color: var(--status-error) !important;
    font-weight: 600 !important;
}

/* User Admin / Account Settings residual light-theme overrides */
body.ecite-app .modal-content {
    background: var(--bg-secondary) !important;
    color: var(--text-primary);
    box-shadow: none !important;
}

body.ecite-app .modal-header {
    background: var(--form-section-header) !important;
    color: var(--text-primary) !important;
}

body.ecite-app .modal-header .close,
body.ecite-app .close {
    color: var(--text-secondary) !important;
}

body.ecite-app .form-fields label,
body.ecite-app .form-row label,
body.ecite-app .form-field label {
    color: var(--text-secondary) !important;
    font-size: 12px !important;
    font-weight: 600 !important;
}

body.ecite-app .role-hint,
body.ecite-app .role-hint-block {
    color: var(--text-secondary) !important;
}

body.ecite-app .role-fieldset label.role-disabled {
    color: var(--text-secondary) !important;
    opacity: 0.7;
}

body.ecite-app input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

body.ecite-app .th-sub {
    color: var(--text-secondary);
}

body.ecite-app .end-date-note {
    color: var(--text-secondary);
}

/* Soften page-level white panel leftovers */
body.ecite-app .court-table-wrap,
body.ecite-app .ord-toolbar input[type="search"],
body.ecite-app .court-selector select,
body.ecite-app #dateLogicSelect {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border);
}

body.ecite-app .court-form,
body.ecite-app .court-page,
body.ecite-app .ord-page,
body.ecite-app .reports-page {
    background: transparent;
}
