/*
 * Z-Neth Theme - extracted verbatim from views/layout.ejs (<style> block).
 * Drop into your static assets and include with:
 *   <link href="/css/theme.css" rel="stylesheet">
 * Requires Bootstrap 5.3+ and Font Awesome 6 (loaded BEFORE this file):
 *   <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
 *   <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
 * The theme is driven by the `data-bs-theme` attribute on <html> ("light" | "dark").
 */
:root {
    --bs-primary: #0d6efd;
    --bs-secondary: #6c757d;
    --bs-success: #198754;
    --bs-info: #0dcaf0;
    --bs-warning: #ffc107;
    --bs-danger: #dc3545;
    --bs-light: #f8f9fa;
    --bs-dark: #212529;
    --bs-body-bg: #ffffff;
    --bs-body-color: #212529;
    --bs-border-color: #dee2e6;
    --bs-card-bg: #ffffff;
    --bs-dropdown-bg: #ffffff;
    --bs-modal-bg: #ffffff;
    --bs-table-bg: #ffffff;
    --bs-table-striped-bg: #f8f9fa;
    --bs-table-hover-bg: #f5f5f5;
    --app-sidebar-width: 230px;
    --app-header-height: 3.25rem;
    --app-page-title-size: 1.35rem;
}

/* App /app/* page titles — compact heading below nav */
.app-page-title {
    font-size: var(--app-page-title-size);
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 0;
}

[data-bs-theme="dark"] {
    --bs-primary: #3d8bfd;
    --bs-secondary: #6c757d;
    --bs-success: #198754;
    --bs-info: #0dcaf0;
    --bs-warning: #ffc107;
    --bs-danger: #dc3545;
    --bs-light: #343a40;
    --bs-dark: #f8f9fa;
    --bs-body-bg: #212529;
    --bs-body-color: #f8f9fa;
    --bs-border-color: #495057;
    --bs-card-bg: #343a40;
    --bs-dropdown-bg: #343a40;
    --bs-modal-bg: #343a40;
    --bs-table-bg: #343a40;
    --bs-table-striped-bg: #2c3034;
    --bs-table-hover-bg: #495057;
}

/* Dark theme specific overrides */
[data-bs-theme="dark"] .navbar {
    background-color: #343a40 !important;
}

[data-bs-theme="dark"] .navbar-brand,
[data-bs-theme="dark"] .navbar-nav .nav-link {
    color: #f8f9fa !important;
}

[data-bs-theme="dark"] .navbar-nav .nav-link:hover {
    color: #adb5bd !important;
}

[data-bs-theme="dark"] .dropdown-menu {
    background-color: #343a40;
    border-color: #495057;
}

[data-bs-theme="dark"] .dropdown-item {
    color: #f8f9fa;
}

[data-bs-theme="dark"] .dropdown-item:hover {
    background-color: #495057;
    color: #f8f9fa;
}

[data-bs-theme="dark"] .card {
    background-color: #343a40;
    border-color: #495057;
}

[data-bs-theme="dark"] .table {
    color: #f8f9fa;
}

[data-bs-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > td {
    background-color: #2c3034;
}

[data-bs-theme="dark"] .table-hover > tbody > tr:hover > td {
    background-color: #495057;
}

[data-bs-theme="dark"] .modal-content {
    background-color: #343a40;
    border-color: #495057;
}

[data-bs-theme="dark"] .modal-header {
    border-bottom-color: #495057;
}

[data-bs-theme="dark"] .modal-footer {
    border-top-color: #495057;
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background-color: #495057;
    border-color: #6c757d;
    color: #f8f9fa;
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
    background-color: #495057;
    border-color: #3d8bfd;
    color: #f8f9fa;
}

[data-bs-theme="dark"] .form-control::placeholder {
    color: #adb5bd;
}

[data-bs-theme="dark"] .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

[data-bs-theme="dark"] .alert {
    border-color: #495057;
}

[data-bs-theme="dark"] .alert-success {
    background-color: #1e4d2b;
    border-color: #198754;
    color: #d1e7dd;
}

[data-bs-theme="dark"] .alert-danger {
    background-color: #4d1e1e;
    border-color: #dc3545;
    color: #f8d7da;
}

[data-bs-theme="dark"] .alert-warning {
    background-color: #4d3e1e;
    border-color: #ffc107;
    color: #fff3cd;
}

[data-bs-theme="dark"] .alert-info {
    background-color: #1e4d4d;
    border-color: #0dcaf0;
    color: #d1ecf1;
}

/* Theme toggle button */
.theme-toggle {
    background: none;
    border: none;
    color: inherit;
    padding: 0.5rem;
    border-radius: 0.375rem;
    transition: background-color 0.15s ease-in-out;
}

.theme-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .theme-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Status indicators with theme support */
.status-indicator {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}
.status-live {
    color: #28a745;
}
.status-offline {
    color: #dc3545;
}
.status-open {
    color: #28a745;
}
.status-closed {
    color: #dc3545;
}

.employee-no-shift {
    background-color: var(--bs-light) !important;
    opacity: 0.7;
}

.employee-no-shift td {
    color: var(--bs-secondary);
}

.employee-on-shift {
    background-color: #d4edda !important;
}

[data-bs-theme="dark"] .employee-on-shift {
    background-color: #1e4d2b !important;
}

.orders-table td {
    text-align: left !important;
}

/* Menu dropdown styling with theme support */
optgroup {
    font-weight: bold;
    color: var(--bs-secondary);
    background-color: var(--bs-light);
}

optgroup option {
    font-weight: normal;
    color: var(--bs-body-color);
    background-color: var(--bs-body-bg);
    padding-left: 1rem;
}

.form-select optgroup {
    font-size: 0.875rem;
    padding: 0.5rem;
}

.form-select option {
    padding: 0.5rem;
}

/* JSON Editor theme support */
[data-bs-theme="dark"] .jsoneditor {
    background-color: #343a40;
    border-color: #495057;
}

[data-bs-theme="dark"] .jsoneditor-menu {
    background-color: #495057;
    border-bottom-color: #6c757d;
}

[data-bs-theme="dark"] .jsoneditor-outer {
    background-color: #343a40;
}

[data-bs-theme="dark"] .ace-jsoneditor {
    background-color: #343a40 !important;
    color: #f8f9fa !important;
}

/* Footer dark theme support */
[data-bs-theme="dark"] footer {
    background-color: #343a40 !important;
    color: #adb5bd !important;
}

/* External Data Configuration Dark Theme Support */
[data-bs-theme="dark"] .config-card {
    background-color: var(--bs-dark);
    border-color: var(--bs-border-color);
    color: var(--bs-body-color);
}

[data-bs-theme="dark"] .config-card:hover {
    background-color: #2c3034;
    border-color: #495057;
}

[data-bs-theme="dark"] .header-row,
[data-bs-theme="dark"] .custom-field-row {
    background-color: var(--bs-dark);
    border-color: var(--bs-border-color);
    color: var(--bs-body-color);
}

[data-bs-theme="dark"] .test-result-success {
    background-color: #1e4d2b !important;
    border-color: #198754 !important;
    color: #d1e7dd !important;
}

[data-bs-theme="dark"] .test-result-error {
    background-color: #4d1e1e !important;
    border-color: #dc3545 !important;
    color: #f8d7da !important;
}

[data-bs-theme="dark"] .bg-light {
    background-color: var(--bs-dark) !important;
    color: var(--bs-body-color) !important;
}

[data-bs-theme="dark"] .card.bg-light {
    background-color: #2c3034 !important;
    color: var(--bs-body-color) !important;
}

[data-bs-theme="dark"] .alert-info {
    background-color: #1a3a4a;
    border-color: #0dcaf0;
    color: #cff4fc;
}

[data-bs-theme="dark"] .alert-warning {
    background-color: #4a3a1a;
    border-color: #ffc107;
    color: #fff3cd;
}

[data-bs-theme="dark"] .alert-danger {
    background-color: #4a1a1a;
    border-color: #dc3545;
    color: #f8d7da;
}

[data-bs-theme="dark"] .alert-success {
    background-color: #1a4a1a;
    border-color: #198754;
    color: #d1e7dd;
}

[data-bs-theme="dark"] .form-text {
    color: var(--bs-secondary) !important;
}

[data-bs-theme="dark"] .text-muted {
    color: var(--bs-secondary) !important;
}

[data-bs-theme="dark"] .border {
    border-color: var(--bs-border-color) !important;
}

[data-bs-theme="dark"] .border.rounded {
    background-color: var(--bs-dark);
}

[data-bs-theme="dark"] pre {
    background-color: var(--bs-dark);
    color: var(--bs-body-color);
    border-color: var(--bs-border-color);
}

[data-bs-theme="dark"] .table {
    color: var(--bs-body-color);
}

[data-bs-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > td {
    background-color: rgba(255, 255, 255, 0.05);
}

[data-bs-theme="dark"] .table-hover > tbody > tr:hover > td {
    background-color: rgba(255, 255, 255, 0.075);
}

[data-bs-theme="dark"] .spinner-border {
    color: var(--bs-primary);
}

[data-bs-theme="dark"] .pagination .page-link {
    background-color: var(--bs-dark);
    border-color: var(--bs-border-color);
    color: var(--bs-body-color);
}

[data-bs-theme="dark"] .pagination .page-link:hover {
    background-color: #2c3034;
    border-color: #495057;
    color: var(--bs-body-color);
}

[data-bs-theme="dark"] .pagination .page-item.active .page-link {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
}

[data-bs-theme="dark"] .pagination .page-item.disabled .page-link {
    background-color: var(--bs-dark);
    border-color: var(--bs-border-color);
    color: var(--bs-secondary);
}

/* Additional dark theme fixes for cards and footer */
[data-bs-theme="dark"] .card {
    background-color: #2c3034 !important;
    border-color: #495057 !important;
    color: var(--bs-body-color) !important;
}

[data-bs-theme="dark"] .card:hover {
    background-color: #1e2124 !important;
    border-color: #6c757d !important;
}

[data-bs-theme="dark"] .card-header {
    background-color: #212529 !important;
    border-bottom-color: #495057 !important;
    color: var(--bs-body-color) !important;
}

[data-bs-theme="dark"] .card-body {
    background-color: #2c3034 !important;
    color: var(--bs-body-color) !important;
}

[data-bs-theme="dark"] .card-footer {
    background-color: #212529 !important;
    border-top-color: #495057 !important;
    color: var(--bs-body-color) !important;
}

/* Fix footer background in dark theme */
[data-bs-theme="dark"] footer.bg-light {
    background-color: #343a40 !important;
    color: #adb5bd !important;
}

/* Ensure card body text uses readable dark-theme colors without overriding semantic headers/badges */
[data-bs-theme="dark"] .card-body,
[data-bs-theme="dark"] .card-body :not(.btn):not(.badge):not(.alert) {
    color: var(--bs-body-color);
}

[data-bs-theme="dark"] .card .text-muted {
    color: var(--bs-secondary) !important;
}

[data-bs-theme="dark"] .card-header.bg-primary.text-white,
[data-bs-theme="dark"] .card-header.bg-primary.text-white *,
[data-bs-theme="dark"] .card-header.bg-success.text-white,
[data-bs-theme="dark"] .card-header.bg-success.text-white *,
[data-bs-theme="dark"] .card-header.bg-info.text-white,
[data-bs-theme="dark"] .card-header.bg-info.text-white * {
    color: #fff !important;
}

[data-bs-theme="dark"] .card-header.bg-warning.text-dark,
[data-bs-theme="dark"] .card-header.bg-warning.text-dark * {
    color: #212529 !important;
}

.navbar-dark .navbar-nav .nav-link,
.navbar-dark .navbar-brand {
    color: #fff !important;
}

.navbar-dark .navbar-nav .nav-link:hover,
.navbar-dark .navbar-nav .nav-link:focus {
    color: #fff !important;
}

.btn-outline-secondary {
    --bs-btn-color: #495057;
    --bs-btn-border-color: #6c757d;
}

[data-bs-theme="dark"] .btn-outline-secondary {
    --bs-btn-color: #dee2e6;
    --bs-btn-border-color: #adb5bd;
}

.reminder-edit-form input,
.reminder-edit-form select {
    max-width: 100%;
    min-width: 0;
}

/* Force dark theme on all card elements with higher specificity */
[data-bs-theme="dark"] .card,
[data-bs-theme="dark"] .card.card,
[data-bs-theme="dark"] div.card,
[data-bs-theme="dark"] .config-card {
    background-color: #2c3034 !important;
    border-color: #495057 !important;
    color: var(--bs-body-color) !important;
}

[data-bs-theme="dark"] .card:hover,
[data-bs-theme="dark"] .card.card:hover,
[data-bs-theme="dark"] div.card:hover,
[data-bs-theme="dark"] .config-card:hover {
    background-color: #1e2124 !important;
    border-color: #6c757d !important;
}

/* Override any Bootstrap card styles */
[data-bs-theme="dark"] .card.bg-white,
[data-bs-theme="dark"] .card.bg-light {
    background-color: #2c3034 !important;
    color: var(--bs-body-color) !important;
}

/* Force dark theme on all elements that might be white */
[data-bs-theme="dark"] .bg-white {
    background-color: #2c3034 !important;
    color: var(--bs-body-color) !important;
}

/* Additional specificity for external data configuration cards */
[data-bs-theme="dark"] .container-fluid .card,
[data-bs-theme="dark"] .container .card,
[data-bs-theme="dark"] main .card {
    background-color: #2c3034 !important;
    border-color: #495057 !important;
    color: var(--bs-body-color) !important;
}

/* Stores page specific dark theme styling */
[data-bs-theme="dark"] .card.shadow-sm {
    background-color: #2c3034 !important;
    border-color: #495057 !important;
    color: var(--bs-body-color) !important;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.3) !important;
}

[data-bs-theme="dark"] .card.shadow-sm:hover {
    background-color: #1e2124 !important;
    border-color: #6c757d !important;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.4) !important;
}

[data-bs-theme="dark"] .card.border-info {
    background-color: #2c3034 !important;
    border-color: #0dcaf0 !important;
    color: var(--bs-body-color) !important;
}

[data-bs-theme="dark"] .card-header.bg-primary {
    background-color: #0d6efd !important;
    border-bottom-color: #0d6efd !important;
}

[data-bs-theme="dark"] .card-header.bg-info {
    background-color: #0dcaf0 !important;
    border-bottom-color: #0dcaf0 !important;
}

[data-bs-theme="dark"] .badge.bg-light {
    background-color: #6c757d !important;
    color: #f8f9fa !important;
}

[data-bs-theme="dark"] .card-text.text-muted {
    color: var(--bs-secondary) !important;
}

[data-bs-theme="dark"] .btn-outline-primary {
    border-color: #6ea8fe !important;
    color: #6ea8fe !important;
}

[data-bs-theme="dark"] .btn-outline-primary:hover {
    background-color: #0d6efd !important;
    color: #f8f9fa !important;
}

[data-bs-theme="dark"] .list-group-item .text-muted,
[data-bs-theme="dark"] .list-group-item small.text-muted {
    color: #adb5bd !important;
}

.list-group-item-action.active .text-muted,
.list-group-item-action.active small.text-muted,
.list-group-item.active .text-muted,
.list-group-item.active small.text-muted {
    color: #fff !important;
}

[data-bs-theme="dark"] .text-muted {
    color: #adb5bd !important;
}

[data-bs-theme="dark"] .text-primary {
    color: #3d8bfd !important;
}

[data-bs-theme="dark"] .text-success {
    color: #198754 !important;
}

[data-bs-theme="dark"] .text-info {
    color: #0dcaf0 !important;
}

[data-bs-theme="dark"] .text-warning {
    color: #ffc107 !important;
}

[data-bs-theme="dark"] .text-muted {
    color: var(--bs-secondary) !important;
}

/* Phase D — global polish */
.deep-link-highlight {
    outline: 2px solid var(--bs-primary);
    outline-offset: 2px;
    background-color: rgba(13, 110, 253, 0.08);
    transition: background-color 0.3s ease, outline-color 0.3s ease;
}

/* App shell — sidebar push layout */
.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.22s ease;
}

body.sidebar-open .app-shell {
    margin-left: var(--app-sidebar-width);
    width: calc(100% - var(--app-sidebar-width));
}

body.sidebar-open {
    overflow-x: clip;
}

/* Backdrop retained for DOM/JS compat but never shown — push layout only */
.app-sidebar-backdrop {
    display: none !important;
}

.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    width: var(--app-sidebar-width);
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--bs-body-bg);
    border-right: 1px solid var(--bs-border-color);
    box-shadow: 0 0 0 rgba(0, 0, 0, 0);
    transform: translateX(-100%);
    transition: transform 0.22s ease, box-shadow 0.22s ease;
    overflow: hidden;
}

body.sidebar-open .app-sidebar {
    transform: translateX(0);
}

.app-sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    padding: calc(var(--app-header-height) + 0.25rem) 0 0;
}

.app-sidebar-controls {
    padding: 0 0.45rem 0.4rem;
    margin-bottom: 0.2rem;
    border-bottom: 1px solid var(--bs-border-color);
}

.app-sidebar-expand-all-btn {
    display: block;
    width: 100%;
    padding: 0.35rem 0.45rem;
    font-size: 0.78rem;
    font-weight: 600;
    text-align: left;
    border: 0;
    border-radius: var(--bs-border-radius-sm, 0.25rem);
    background: transparent;
    color: var(--bs-secondary, #6c757d);
}

.app-sidebar-expand-all-btn:hover,
.app-sidebar-expand-all-btn:focus-visible {
    background: var(--bs-tertiary-bg, var(--bs-light));
    color: var(--bs-body-color);
}

.app-sidebar-expand-all-btn[aria-pressed="true"] {
    color: var(--bs-primary-text-emphasis, var(--bs-primary));
}

.app-sidebar-list {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    padding: 0 0.3rem;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding-bottom: 0.75rem;
}

.app-sidebar-section-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 0.35rem;
    padding: 0.4rem 0.45rem;
    font-size: 0.9rem;
    border: 0;
    border-radius: var(--bs-border-radius);
    background: transparent;
    color: var(--bs-body-color);
    font-weight: 600;
    text-align: left;
}

.app-sidebar-section-label {
    flex: 1 1 auto;
    min-width: 0;
}

.app-sidebar-section-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.app-sidebar-section-toggle--icon-only {
    justify-content: flex-end;
}

.app-sidebar-category-icon {
    font-size: 0.82rem;
    opacity: 0.75;
}

.app-sidebar-section-toggle:hover,
.app-sidebar-section-toggle:focus-visible {
    background: var(--bs-tertiary-bg, var(--bs-light));
}

.app-sidebar-section.is-expanded > .app-sidebar-section-toggle {
    background: var(--bs-primary-bg-subtle, rgba(13, 110, 253, 0.12));
    color: var(--bs-primary-text-emphasis, var(--bs-primary));
}

.app-sidebar-chevron {
    font-size: 0.72rem;
    opacity: 0.7;
    transition: transform 0.15s ease;
}

.app-sidebar-section.is-expanded .app-sidebar-chevron {
    transform: rotate(180deg);
}

.app-sidebar-links {
    padding: 0.1rem 0 0.25rem 0.2rem;
}

.app-sidebar-link {
    display: block;
    padding: 0.32rem 0.45rem 0.32rem 0.75rem;
    border-radius: var(--bs-border-radius-sm, 0.25rem);
    color: var(--bs-body-color);
    text-decoration: none;
    font-size: 0.875rem;
}

.app-sidebar-link:hover,
.app-sidebar-link:focus-visible {
    background: var(--bs-tertiary-bg, var(--bs-light));
    color: var(--bs-body-color);
}

.app-sidebar-pinned {
    flex-shrink: 0;
    padding: 0.45rem 0.3rem 0.75rem;
    border-top: 1px solid var(--bs-border-color);
}

.app-sidebar-link--pinned {
    display: flex;
    align-items: center;
    padding: 0.4rem 0.45rem;
    font-weight: 600;
    font-size: 0.9rem;
}

[data-bs-theme="dark"] .app-sidebar {
    background-color: #2c3034;
    border-right-color: #495057;
}

[data-bs-theme="dark"] .app-sidebar-section-toggle:hover,
[data-bs-theme="dark"] .app-sidebar-section-toggle:focus-visible,
[data-bs-theme="dark"] .app-sidebar-link:hover,
[data-bs-theme="dark"] .app-sidebar-link:focus-visible,
[data-bs-theme="dark"] .app-sidebar-expand-all-btn:hover,
[data-bs-theme="dark"] .app-sidebar-expand-all-btn:focus-visible {
    background-color: #495057;
}

/* Phase D — global toolbar, quick chat dock, activity log */
.app-header {
    position: sticky;
    top: 0;
    z-index: 1030;
}

.app-header-main {
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
    padding-left: 0;
    padding-right: 0;
}

.app-header-inner {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 0.5rem;
    width: 100%;
    max-width: 100%;
    padding-left: 0;
    padding-right: 0.75rem;
}

.app-sidebar-toggle {
    order: -1;
    flex: 0 0 auto;
    margin: 0;
    padding: 0.35rem 0.55rem;
    display: inline-flex;
    align-self: stretch;
    align-items: center;
    border-radius: 0;
    min-height: var(--app-header-height);
}

.app-sidebar-toggle:focus-visible {
    box-shadow: 0 0 0 0.2rem rgba(255, 255, 255, 0.35);
}

.app-header-actions {
    flex-shrink: 0;
    min-width: 0;
}

.app-header-actions .quick-chat-launcher,
.app-header-actions .activity-log-toolbar-btn,
.app-top-toolbar .quick-chat-launcher,
.app-top-toolbar .activity-log-toolbar-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    padding-inline: 0.45rem;
    background: none;
    border: none;
    box-shadow: none;
    color: inherit;
    line-height: 1;
    text-decoration: none;
}

.app-header-actions .quick-chat-launcher:hover,
.app-header-actions .quick-chat-launcher:focus-visible,
.app-header-actions .activity-log-toolbar-btn:hover,
.app-header-actions .activity-log-toolbar-btn:focus-visible,
.app-top-toolbar .quick-chat-launcher:hover,
.app-top-toolbar .quick-chat-launcher:focus-visible,
.app-top-toolbar .activity-log-toolbar-btn:hover,
.app-top-toolbar .activity-log-toolbar-btn:focus-visible {
    background-color: rgba(255, 255, 255, 0.1);
    border: none;
    box-shadow: none;
    color: inherit;
    text-decoration: none;
}

.app-header-actions .theme-toggle {
    line-height: 1;
    flex-shrink: 0;
}

.app-profile-dropdown {
    flex-shrink: 0;
    margin-left: 0.15rem;
}

.app-profile-toggle {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.5rem !important;
    white-space: nowrap;
}

/* Horizontal navigation bar */
.horizontal-nav {
    background-color: var(--bs-body-bg);
    border-color: var(--bs-border-color) !important;
}

body.sidebar-open .app-horizontal-nav {
    display: none !important;
}

body.nav-mode-mobile .app-horizontal-nav {
    display: none !important;
}

.horizontal-nav-list {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0.15rem;
    overflow: hidden;
    padding: 0.15rem 0;
}

body.nav-measure .horizontal-nav-list,
body.nav-mode-horizontal .horizontal-nav-list {
    flex-direction: row;
    align-items: stretch;
    overflow: hidden;
    padding: 0.15rem 0;
}

body.nav-mode-mobile .horizontal-nav-list {
    flex-direction: column;
    align-items: stretch;
    overflow: visible;
    padding: 0.5rem 0 0.75rem;
}

.horizontal-nav-item {
    flex: 0 0 auto;
}

.horizontal-nav-spacer {
    flex: 1 1 auto;
    min-width: 0.5rem;
    list-style: none;
}

.horizontal-nav-item--admin {
    flex-shrink: 0;
}

.horizontal-nav-item--legacy {
    flex-shrink: 0;
}

.horizontal-nav-link-label {
    flex: 0 1 auto;
}

.app-nav-category-icon {
    font-size: 0.85em;
    opacity: 0.78;
    flex-shrink: 0;
}

.horizontal-nav-link--icon-only {
    padding-inline: 0.65rem;
}

.horizontal-nav-link--icon-only .app-nav-category-icon {
    font-size: 0.95rem;
    opacity: 1;
}

.horizontal-nav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.45rem 0.75rem;
    border-radius: var(--bs-border-radius);
    color: var(--bs-body-color);
    text-decoration: none;
    white-space: nowrap;
    border: 0;
    background: transparent;
}

.horizontal-nav-link:hover,
.horizontal-nav-link:focus-visible {
    background-color: var(--bs-tertiary-bg, var(--bs-light));
    color: var(--bs-body-color);
}

.horizontal-nav-link.show,
.horizontal-nav-item.show > .horizontal-nav-link {
    background-color: var(--bs-primary-bg-subtle, rgba(13, 110, 253, 0.12));
    color: var(--bs-primary-text-emphasis, var(--bs-primary));
}

.horizontal-nav-more-btn {
    font-weight: 600;
}

.horizontal-nav-more {
    flex-shrink: 0;
}

.horizontal-nav-collapse.collapse:not(.show) {
    display: none;
}

body.nav-measure .horizontal-nav-collapse,
body.nav-mode-horizontal .horizontal-nav-collapse {
    display: block !important;
}

body.nav-mode-mobile .horizontal-nav-item .dropdown-menu {
    position: static !important;
    float: none;
    display: block;
    border: 0;
    box-shadow: none;
    background: transparent;
    padding: 0 0 0.35rem 0.75rem;
    margin: 0;
}

body.nav-mode-mobile .horizontal-nav-item .dropdown-item {
    padding-left: 0.5rem;
}

body.nav-mode-mobile .horizontal-nav-more {
    display: none !important;
}

[data-bs-theme="dark"] .horizontal-nav {
    background-color: #2c3034;
}

[data-bs-theme="dark"] .horizontal-nav-link {
    color: var(--bs-body-color);
}

[data-bs-theme="dark"] .horizontal-nav-link:hover,
[data-bs-theme="dark"] .horizontal-nav-link:focus-visible {
    background-color: #495057;
}

.app-top-toolbar {
    background-color: var(--bs-body-bg);
    border-color: var(--bs-border-color) !important;
}

.app-top-toolbar .btn-outline-secondary {
    --bs-btn-color: var(--bs-body-color);
    --bs-btn-border-color: var(--bs-border-color);
    --bs-btn-hover-color: var(--bs-body-color);
    --bs-btn-hover-bg: var(--bs-tertiary-bg);
    --bs-btn-hover-border-color: var(--bs-border-color);
    --bs-btn-active-color: var(--bs-body-color);
}

main.container {
    max-width: 100%;
    overflow-x: clip;
}

main.container .row,
main.container form,
main.container .card-body,
#projectDetailRoot {
    min-width: 0;
    max-width: 100%;
}

main.container .row > [class*="col-"] {
    min-width: 0;
}

main .col-md-8 > p.text-muted,
main .col-md-8 > .text-muted {
    color: #495057 !important;
}

[data-bs-theme="dark"] main .col-md-8 > p.text-muted,
[data-bs-theme="dark"] main .col-md-8 > .text-muted {
    color: #adb5bd !important;
}

.assistant-code-block {
    max-width: 100%;
    overflow: hidden;
    background-color: #f8f9fa;
    border-color: var(--bs-border-color) !important;
}

.assistant-code-head {
    background-color: #e9ecef;
    border-bottom: 1px solid var(--bs-border-color);
    color: #212529;
}

.assistant-code-lang {
    font-weight: 600;
    text-transform: lowercase;
}

.assistant-code-body,
.assistant-code-block pre.assistant-code-scroll,
.assistant-code-scroll {
    max-width: 100%;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
    background-color: #f1f3f5;
    color: #212529;
    border: 0;
    margin: 0;
}

.assistant-code-block code {
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
    background: transparent;
    color: inherit;
    font-family: var(--bs-font-monospace, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace);
}

[data-bs-theme="dark"] .assistant-code-block {
    background-color: #1a1d21;
    border-color: #495057 !important;
}

[data-bs-theme="dark"] .assistant-code-head {
    background-color: #2b3035;
    border-bottom-color: #495057;
    color: #e9ecef;
}

[data-bs-theme="dark"] .assistant-code-body,
[data-bs-theme="dark"] .assistant-code-block pre.assistant-code-scroll,
[data-bs-theme="dark"] .assistant-code-scroll {
    background-color: #1a1d21 !important;
    color: #e9ecef !important;
}

[data-bs-theme="dark"] .assistant-code-block pre,
[data-bs-theme="dark"] .assistant-code-block pre code,
[data-bs-theme="dark"] .assistant-code-block code {
    background-color: transparent !important;
    color: #e9ecef !important;
}

[data-bs-theme="dark"] .card-body .assistant-code-block,
[data-bs-theme="dark"] .card-body .assistant-code-block pre,
[data-bs-theme="dark"] .card-body .assistant-code-block code {
    color: #e9ecef !important;
}

[data-bs-theme="dark"] .assistant-code-head .assistant-code-action {
    --bs-btn-color: #dee2e6;
    --bs-btn-border-color: #6c757d;
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #495057;
    --bs-btn-hover-border-color: #adb5bd;
}

[data-bs-theme="dark"] .assistant-code-block .hljs,
[data-bs-theme="dark"] .assistant-code-block .hljs span {
    color: #e9ecef;
}

[data-bs-theme="dark"] #chatMessages pre,
[data-bs-theme="dark"] #chatMessages pre code {
    background-color: #1a1d21 !important;
    color: #e9ecef !important;
}

/* Capture page — card overflow containment */
#captureQueueContainer .card-body,
.capture-queue-list {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

.capture-item {
    overflow: hidden;
}

.capture-row {
    min-width: 0;
    max-width: 100%;
}

.capture-main {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

.capture-badges {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    max-width: 100%;
    width: 100%;
}

.capture-badges-left {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.capture-project-badge {
    display: inline-flex;
    align-items: center;
    max-width: min(14rem, 50%);
    overflow: hidden;
    min-width: 0;
    vertical-align: middle;
    margin-left: auto;
    flex-shrink: 0;
}

.capture-project-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.capture-body-text {
    overflow-wrap: anywhere;
    word-break: break-word;
    max-width: 100%;
}

.capture-attachments {
    min-width: 0;
    max-width: 100%;
}

.capture-attachment-thumb-wrap {
    display: inline-flex;
    flex-shrink: 0;
    max-width: 40px;
}

.capture-attachment-thumb {
    width: 40px;
    height: 40px;
    max-width: 100%;
    object-fit: cover;
    flex-shrink: 0;
}

.capture-attachment-badge {
    display: inline-flex;
    align-items: center;
    max-width: min(12rem, 100%);
    overflow: hidden;
    min-width: 0;
    vertical-align: middle;
}

.capture-attachment-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1 1 auto;
}

.capture-card-footer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-top: 1px solid var(--bs-border-color-translucent, rgba(0, 0, 0, 0.08));
    padding-top: 0.35rem;
}

.capture-card-footer .capture-actions {
    flex-shrink: 0;
}

.capture-card-datetime {
    margin-left: auto;
    font-size: 0.75rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.capture-queue-control {
    width: auto;
    min-width: 9rem;
}

#captureSortToggle {
    min-width: 2.25rem;
}

.capture-queue-section .list-group-item {
    position: relative;
}

.capture-queue-section-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    padding: 0.25rem 0.35rem;
    border: 0;
    border-radius: var(--bs-border-radius-sm, 0.25rem);
    background: transparent;
    color: var(--bs-secondary-color);
    font-size: 0.875rem;
    font-weight: 600;
    text-align: left;
}

.capture-queue-section-toggle:hover,
.capture-queue-section-toggle:focus-visible {
    background: var(--bs-tertiary-bg, var(--bs-light));
    color: var(--bs-body-color);
}

.capture-queue-section.is-expanded > .capture-queue-section-toggle {
    color: var(--bs-body-color);
}

.capture-queue-section-label {
    flex: 1 1 auto;
    min-width: 0;
}

.capture-queue-section-meta {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    flex-shrink: 0;
}

.capture-queue-chevron {
    font-size: 0.72rem;
    opacity: 0.7;
    transition: transform 0.15s ease;
}

.capture-queue-section.is-expanded .capture-queue-chevron {
    transform: rotate(180deg);
}

#captureCompletedBody {
    margin-top: 0.15rem;
}

@media (max-width: 575.98px) {
    .capture-card-footer {
        flex-wrap: wrap;
        row-gap: 0.35rem;
    }

    .capture-card-datetime {
        margin-left: auto;
    }
}

#captureForm .row,
#captureForm select,
#captureForm textarea {
    max-width: 100%;
}

.capture-text-auto-grow {
    min-height: calc(1.5em + 0.75rem + 2px);
    resize: none;
    overflow-y: hidden;
    line-height: 1.5;
}

.capture-form-toolbar-row {
    align-items: center;
    display: flex;
    gap: 0.75rem;
    justify-content: space-between;
}

.capture-form-toolbar-actions {
    align-items: center;
    display: flex;
    flex: 0 0 auto;
    gap: 0.5rem;
    margin-left: auto;
}

.capture-form-textarea-wrap {
    min-width: 0;
    width: 100%;
}

.capture-form-textarea-wrap .capture-text-auto-grow {
    font-size: 1rem;
    width: 100%;
}

.capture-form-save-row {
    align-items: flex-end;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: space-between;
}

.capture-form-save-left {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.capture-form-project-wrap {
    align-items: center;
    display: flex;
    flex: 0 0 auto;
    flex-wrap: wrap;
    gap: 0.5rem;
    min-width: 9rem;
}

.capture-form-project-label {
    color: var(--bs-secondary-color);
    flex: 0 0 auto;
    font-size: 0.875rem;
    margin-bottom: 0;
    white-space: nowrap;
}

.capture-form-project-wrap .form-select {
    min-width: 9rem;
    width: auto;
}

#newCaptureProjectHolder {
    flex: 1 1 100%;
    margin-top: 0.25rem;
}

.capture-attachment-preview-row {
    padding-left: 0.125rem;
}

.capture-format-toolbar .btn {
    min-width: 2.25rem;
}

.capture-attach-button,
.capture-analyze-toggle {
    min-width: 2.25rem;
}

.capture-analyze-toggle.active {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
    color: #fff;
}

@media (max-width: 575.98px) {
    .capture-form-toolbar-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .capture-form-toolbar-actions {
        margin-left: 0;
        width: 100%;
    }

    .capture-form-save-row {
        align-items: stretch;
        flex-direction: column;
    }

    .capture-form-project-wrap {
        width: 100%;
    }

    .capture-form-project-wrap .form-select {
        flex: 1 1 auto;
        width: 100%;
    }
}

.quick-chat-launcher.has-unread {
    color: var(--bs-primary);
}

.quick-chat-launcher-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--bs-danger);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.activity-log-toolbar-btn .activity-log-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--bs-danger);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.quick-chat-dock {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1080;
}

.quick-chat-window {
    position: fixed;
    width: min(380px, calc(100vw - 32px));
    max-height: min(620px, calc(100vh - 48px));
    display: flex;
    flex-direction: column;
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 16px;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
    overflow: hidden;
    pointer-events: auto;
    animation: quickChatIn 160ms ease;
}

.quick-chat-window.minimized {
    width: 260px;
    max-height: none;
}

.quick-chat-window.minimized .quick-chat-body {
    display: none;
}

.quick-chat-window.minimized .quick-chat-header {
    border-bottom: 0;
}

.quick-chat-window.dragging {
    user-select: none;
    cursor: grabbing;
}

.quick-chat-body {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
}

@keyframes quickChatIn {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.quick-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    background: var(--bs-tertiary-bg);
    border-bottom: 1px solid var(--bs-border-color);
    cursor: grab;
    touch-action: none;
}

.quick-chat-window.minimized .quick-chat-header {
    cursor: pointer;
}

.quick-chat-titletext {
    min-width: 0;
}

.quick-chat-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    margin-left: 6px;
    border-radius: 9px;
    background: var(--bs-danger);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    vertical-align: middle;
}

.quick-chat-title {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.quick-chat-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--bs-primary);
    color: #fff;
    flex-shrink: 0;
}

.quick-chat-heading {
    margin: 0;
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.1;
}

.quick-chat-subheading {
    margin: 2px 0 0;
    font-size: 0.72rem;
    color: var(--bs-secondary-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

.quick-chat-header-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.quick-chat-icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--bs-secondary-color);
    transition: background-color 150ms ease, color 150ms ease;
}

.quick-chat-icon-button:hover {
    background: var(--bs-secondary-bg);
    color: var(--bs-body-color);
}

.quick-chat-icon-button.loading i {
    animation: quickChatSpin 800ms linear infinite;
}

@keyframes quickChatSpin {
    to { transform: rotate(360deg); }
}

.quick-chat-settings {
    padding: 14px;
    border-bottom: 1px solid var(--bs-border-color);
    background: var(--bs-secondary-bg);
    overflow-y: auto;
    max-height: 60%;
}

.quick-chat-settings-title {
    margin: 0 0 8px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--bs-secondary-color);
    font-weight: 700;
}

.quick-chat-field {
    display: block;
    margin-bottom: 12px;
}

.quick-chat-field > span {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.quick-chat-field select,
.quick-chat-field textarea {
    width: 100%;
    border: 1px solid var(--bs-border-color);
    border-radius: 8px;
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    padding: 8px 10px;
}

.quick-chat-field textarea {
    resize: vertical;
    font-family: var(--bs-font-monospace, monospace);
    font-size: 0.78rem;
}

.quick-chat-model-control {
    display: flex;
    gap: 6px;
}

.quick-chat-model-control select {
    flex: 1;
    min-width: 0;
}

.quick-chat-model-control .quick-chat-icon-button {
    border: 1px solid var(--bs-border-color);
    flex-shrink: 0;
}

.quick-chat-settings-note {
    font-size: 0.72rem;
    color: var(--bs-secondary-color);
    margin: 0 0 12px;
}

.quick-chat-settings-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.quick-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--bs-body-bg);
    min-height: 12rem;
    max-height: min(420px, 50vh);
}

.quick-chat-empty {
    margin: auto;
    text-align: center;
    color: var(--bs-secondary-color);
    font-size: 0.85rem;
    padding: 24px 12px;
}

.quick-chat-message {
    max-width: 86%;
    padding: 9px 12px;
    border-radius: 14px;
    font-size: 0.86rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

.quick-chat-message.user {
    align-self: flex-end;
    background: var(--bs-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.quick-chat-message.ai {
    align-self: flex-start;
    background: var(--bs-tertiary-bg);
    color: var(--bs-body-color);
    border-bottom-left-radius: 4px;
    white-space: normal;
}

.quick-chat-message.ai p {
    margin: 0 0 8px;
}

.quick-chat-message.ai p:last-child {
    margin-bottom: 0;
}

.quick-chat-message.system {
    align-self: center;
    background: transparent;
    color: var(--bs-secondary-color);
    font-size: 0.76rem;
    font-style: italic;
    padding: 2px 8px;
}

.quick-chat-message.pending {
    color: var(--bs-secondary-color);
    font-style: italic;
}

.quick-chat-meta {
    margin: 8px 0 0;
    font-size: 0.68rem;
    color: var(--bs-secondary-color);
}

.quick-chat-code {
    margin-top: 8px;
    border: 1px solid var(--bs-border-color);
    border-radius: 10px;
    overflow: hidden;
    background: #1e1e1e;
}

.quick-chat-code-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.2);
}

.quick-chat-code-label {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--bs-secondary-color);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.quick-chat-code-actions {
    display: flex;
    gap: 6px;
}

.quick-chat-code-button {
    font-size: 0.7rem;
    font-weight: 600;
    border: 0;
    border-radius: 6px;
    padding: 3px 9px;
    background: var(--bs-secondary-bg);
    color: var(--bs-body-color);
}

.quick-chat-code-button:hover:not(:disabled) {
    background: var(--bs-primary);
    color: #fff;
}

.quick-chat-code-button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.quick-chat-code pre {
    margin: 0;
    padding: 10px 12px;
    overflow-x: auto;
    font-family: var(--bs-font-monospace, monospace);
    font-size: 0.78rem;
    color: #f3f3f3;
}

.quick-chat-action {
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.quick-chat-action-button {
    font-size: 0.74rem;
    font-weight: 700;
    border: 1px solid var(--bs-primary);
    border-radius: 8px;
    padding: 4px 10px;
    background: transparent;
    color: var(--bs-primary);
}

.quick-chat-action-button:hover {
    background: var(--bs-primary);
    color: #fff;
}

.quick-chat-composer {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--bs-border-color);
    background: var(--bs-tertiary-bg);
}

.quick-chat-composer textarea {
    flex: 1;
    resize: none;
    max-height: 120px;
    border: 1px solid var(--bs-border-color);
    border-radius: 18px;
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    padding: 8px 14px;
    font-size: 0.86rem;
    line-height: 1.35;
}

.quick-chat-send {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 50%;
    background: var(--bs-primary);
    color: #fff;
    flex-shrink: 0;
}

.quick-chat-send:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

@media (max-width: 575.98px) {
    .app-header-actions {
        gap: 0.25rem !important;
    }

    .app-profile-toggle {
        padding: 0.35rem !important;
    }

    .quick-chat-window {
        width: calc(100vw - 16px);
        right: 8px !important;
        left: 8px !important;
    }
}

/* Activity log — bottom-right panel (legacy layout) */
.activity-log-shell {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    max-width: min(420px, calc(100vw - 40px));
    pointer-events: none;
}

.activity-log-stack {
    display: flex;
    flex-direction: column-reverse;
    align-items: flex-end;
    gap: 10px;
    width: min(420px, calc(100vw - 40px));
    max-height: min(calc(100vh - 120px), 720px);
    pointer-events: auto;
}

.activity-log-eyebrow {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--bs-secondary-color);
    font-weight: 700;
}

.toast-stack {
    display: grid;
    gap: 10px;
    width: min(420px, calc(100vw - 40px));
}

.toast-card {
    background: var(--bs-dark);
    color: var(--bs-light);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: var(--bs-border-radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    padding: 12px 12px 10px;
    pointer-events: auto;
}

.toast-card-error { border-color: rgba(var(--bs-danger-rgb), 0.45); }
.toast-card-warn { border-color: rgba(var(--bs-warning-rgb), 0.45); }
.toast-card-success { border-color: rgba(var(--bs-success-rgb), 0.4); }
.toast-card-info { border-color: rgba(var(--bs-info-rgb), 0.35); }

.toast-card-body {
    font-size: 14px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

.toast-card-meta {
    color: rgba(255, 255, 255, 0.72);
    font-size: 12px;
    margin-top: 6px;
}

.toast-card-actions,
.activity-log-item-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.activity-log-filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 12px 10px;
    border-bottom: 1px solid var(--bs-border-color);
    flex-shrink: 0;
}

.activity-log-filter {
    border: 1px solid var(--bs-border-color);
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    border-radius: 999px;
    font-size: 12px;
    line-height: 1;
    padding: 5px 10px;
    cursor: pointer;
}

.activity-log-filter:hover {
    border-color: rgba(var(--bs-primary-rgb), 0.35);
    background: var(--bs-secondary-bg);
}

.activity-log-filter.active {
    border-color: rgba(var(--bs-primary-rgb), 0.55);
    background: var(--bs-primary-bg-subtle);
    color: var(--bs-primary-text-emphasis, var(--bs-body-color));
    font-weight: 600;
}

.activity-log-panel {
    width: min(420px, calc(100vw - 40px));
    max-height: min(60vh, 520px);
    overflow: hidden;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    background: var(--bs-body-bg);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.16);
}

.activity-log-panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--bs-border-color);
}

.activity-log-panel-header h4 {
    font-size: 16px;
}

.activity-log-panel-actions {
    display: flex;
    gap: 6px;
}

.activity-log-list {
    overflow: auto;
    padding: 10px;
    display: grid;
    gap: 10px;
    min-height: 0;
}

.activity-log-item {
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    padding: 10px;
    background: var(--bs-tertiary-bg);
}

.activity-log-item-read { opacity: 0.82; }
.activity-log-item-error { border-color: var(--bs-danger-border-subtle); }
.activity-log-item-warn { border-color: var(--bs-warning-border-subtle); }
.activity-log-item-success { border-left: 3px solid var(--bs-success); }
.activity-log-item-info { border-left: 3px solid var(--bs-info); }

.activity-log-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.activity-log-item-type {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--bs-secondary-color);
}

.activity-log-item-time {
    font-size: 11px;
    color: var(--bs-secondary-color);
}

.activity-log-item-body {
    font-size: 13px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

.activity-log-empty {
    color: var(--bs-secondary-color);
    font-size: 13px;
    line-height: 1.45;
    padding: 8px 4px;
}

.toast-fleeting {
    position: fixed;
    left: 50%;
    bottom: 5rem;
    transform: translateX(-50%) translateY(1rem);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 2090;
    max-width: min(32rem, calc(100vw - 2rem));
}

.toast-fleeting.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

@media (max-width: 575.98px) {
    .activity-log-shell {
        right: 0.5rem;
        bottom: 0.5rem;
        max-width: calc(100vw - 1rem);
    }

    .activity-log-stack,
    .activity-log-panel,
    .toast-stack {
        width: calc(100vw - 1rem);
    }
}

/* Snippets page — code bubbles, overflow containment, dark-mode contrast */
.snippet-library-card .list-group-item {
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
    border-color: var(--bs-border-color);
}

[data-bs-theme="dark"] .snippet-library-card .list-group-item {
    background-color: var(--bs-card-bg, #2c3034);
    color: var(--bs-body-color);
    border-color: var(--bs-border-color);
}

.snippet-item {
    overflow: hidden;
}

.snippet-row {
    min-width: 0;
}

.snippet-main {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

.snippet-header {
    min-width: 0;
}

.snippet-title {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.snippet-actions {
    flex-shrink: 0;
}

.snippet-code-bubble {
    display: block;
    margin: 0;
    padding: 0.65rem 0.75rem;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: auto;
    max-height: 10rem;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
    font-family: var(--bs-font-monospace, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace);
    font-size: 0.8125rem;
    line-height: 1.45;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    background-color: var(--bs-tertiary-bg, var(--bs-light));
    color: var(--bs-body-color);
}

.snippet-item-open .snippet-code-bubble {
    max-height: 28rem;
}

.snippet-code-bubble code {
    display: block;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
    font-family: inherit;
    font-size: inherit;
    background: transparent;
    padding: 0;
    border: 0;
}

[data-bs-theme="dark"] .snippet-code-bubble {
    background-color: #1a1d21;
    border-color: var(--bs-border-color);
    color: #e9ecef;
}

[data-bs-theme="dark"] .card .snippet-code-bubble,
[data-bs-theme="dark"] .card .snippet-code-bubble pre {
    background-color: #1a1d21 !important;
    color: #e9ecef !important;
}

[data-bs-theme="dark"] .card .snippet-code-bubble .hljs,
[data-bs-theme="dark"] .card .snippet-code-bubble .hljs span {
    color: unset !important;
}

.snippet-import-candidate .card-body {
    min-width: 0;
    overflow: hidden;
}

.snippet-import-candidate textarea {
    max-width: 100%;
    word-break: break-word;
}

/* WCAG contrast — badges, outline buttons, headers, footer links */
[data-bs-theme="dark"] .badge.bg-light.text-dark,
[data-bs-theme="dark"] .card .badge.bg-light.text-dark {
    background-color: #495057 !important;
    color: #f8f9fa !important;
}

.card-header.bg-info,
.card-header.bg-info h5,
.card-header.bg-info .badge {
    color: #fff !important;
}

.card-header.bg-warning .badge.bg-light.text-dark {
    background-color: #343a40 !important;
    color: #f8f9fa !important;
}

footer.text-muted a,
footer a {
    color: #0a58ca !important;
    text-decoration: underline;
}

[data-bs-theme="dark"] footer.text-muted a,
[data-bs-theme="dark"] footer a {
    color: #9ec5fe !important;
}

.btn-outline-warning {
    --bs-btn-color: #997404;
    --bs-btn-border-color: #997404;
}

[data-bs-theme="dark"] .btn-outline-warning {
    --bs-btn-color: #ffda6a;
    --bs-btn-border-color: #ffda6a;
}

[data-bs-theme="dark"] .btn-outline-success {
    --bs-btn-color: #75b798;
    --bs-btn-border-color: #75b798;
}

[data-bs-theme="dark"] .card-header.bg-warning.text-dark,
[data-bs-theme="dark"] .card-header.bg-warning.text-dark h5,
[data-bs-theme="dark"] .card-header.bg-warning.text-dark .badge {
    color: #212529 !important;
}

[data-bs-theme="dark"] .card-header.bg-info.text-white,
[data-bs-theme="dark"] .card-header.bg-info.text-white h5,
[data-bs-theme="dark"] .card-header.bg-info.text-white .badge {
    color: #fff !important;
}

.card-header.bg-info.text-white .badge.bg-light.text-dark,
.card-header.bg-primary.text-white .badge.bg-light.text-dark,
.card-header.bg-success.text-white .badge.bg-light.text-dark {
    background-color: rgba(0, 0, 0, 0.25) !important;
    color: #fff !important;
}

.btn-outline-info {
    --bs-btn-color: #055160;
    --bs-btn-border-color: #055160;
}

[data-bs-theme="dark"] .btn-outline-info {
    --bs-btn-color: #6edff6;
    --bs-btn-border-color: #6edff6;
}

.card-body.text-center > .text-muted {
    color: #495057 !important;
}

[data-bs-theme="dark"] .card-body.text-center > .text-muted {
    color: #adb5bd !important;
}

.domain-field-text {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
    white-space: nowrap;
}

tr.is-editing .domain-field-view {
    display: none !important;
}

tr.is-editing .domain-field-edit {
    display: block !important;
}

.domain-subdomain-cell,
.domain-target-cell {
    min-width: 10rem;
}

.domain-field-actions {
    display: inline-flex;
    vertical-align: middle;
}

.subdomain-split-display,
.subdomain-split-edit {
    align-items: center;
    display: flex;
    flex-wrap: nowrap;
    gap: 0.25rem;
    min-width: 0;
}

.subdomain-split-edit .subdomain-input {
    flex: 0 1 auto;
    max-width: 12rem;
    min-width: 5rem;
}

.subdomain-split-edit .alternate-subdomain-input {
    flex: 0 1 auto;
    max-width: 12rem;
    min-width: 5rem;
}

.subdomain-prefix-label {
    flex: 0 0 auto;
}

.subdomain-suffix-label {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.alternate-subdomains-view,
.alternate-subdomains-edit {
    display: grid;
    gap: 0.25rem;
}

.alternate-subdomain-row {
    align-items: center;
}

.alternate-subdomain-add {
    flex: 0 0 auto;
}

.default-subdomain-radio-label {
    align-items: center;
    display: inline-flex;
    flex: 0 0 auto;
    line-height: 1;
    margin: 0;
}

.default-subdomain-radio {
    accent-color: var(--bs-primary, #0d6efd);
    cursor: pointer;
    flex: 0 0 auto;
    height: 1rem;
    margin: 0;
    min-height: 1rem;
    min-width: 1rem;
    width: 1rem;
}

.default-subdomain-badge {
    background-color: var(--bs-secondary-bg-subtle, #e9ecef);
    color: var(--bs-secondary-color, #6c757d);
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: lowercase;
    vertical-align: middle;
}

[data-bs-theme="dark"] .default-subdomain-badge {
    background-color: #495057;
    color: #dee2e6;
}
