:root {
    --ag-page: #f4f7fb;
    --ag-surface-low: #edf2f8;
    --ag-surface: #ffffff;
    --ag-surface-high: #ffffff;
    --ag-nav: #132036;
    --ag-card: #ffffff;
    --ag-raised: #ffffff;
    --ag-text: #142033;
    --ag-text-secondary: #53647a;
    --ag-text-muted: #78879a;
    --ag-border: #d8e0eb;
    --ag-border-panel: #c5d1df;
    --ag-border-accent: #287aa8;
    --ag-focus: #087ab7;
    --ag-accent: #086fa8;
    --ag-accent-strong: #005982;
    --ag-accent-soft: #d9effa;
    --ag-special: #914385;
    --ag-success: #167b54;
    --ag-warning: #a66700;
    --ag-danger: #b83246;
    --ag-info: #155e91;
    --ag-shadow: 0 10px 30px rgba(27, 47, 71, .08);
    --ag-radius: .75rem;
    --ag-control-radius: .5rem;
    --ag-control-height: 2.55rem;
    --ag-sidebar-width: 304px;
    --ag-topbar-height: 68px;
    --ag-gutter: clamp(1rem, 3vw, 2rem);
    --ag-transition: 200ms ease;
    --bs-body-bg: var(--ag-page);
    --bs-body-color: var(--ag-text);
    --bs-border-color: var(--ag-border);
    --bs-primary: var(--ag-accent);
    --bs-primary-rgb: 8, 111, 168;
    --bs-secondary-color: var(--ag-text-secondary);
    --bs-tertiary-bg: var(--ag-surface-low);
}

html[data-theme="dark"] {
    --ag-page: #111b2b;
    --ag-surface-low: #172337;
    --ag-surface: #1c2a40;
    --ag-surface-high: #22344f;
    --ag-nav: #0c1626;
    --ag-card: #1c2a40;
    --ag-raised: #22344f;
    --ag-text: #eff5ff;
    --ag-text-secondary: #bac7d9;
    --ag-text-muted: #92a2b8;
    --ag-border: #344660;
    --ag-border-panel: #465a75;
    --ag-border-accent: #5bc3ee;
    --ag-focus: #82dcff;
    --ag-accent: #5bc3ee;
    --ag-accent-strong: #92e2ff;
    --ag-accent-soft: #163c53;
    --ag-special: #d581c4;
    --ag-success: #57d69a;
    --ag-warning: #f1bd62;
    --ag-danger: #ff90a0;
    --ag-info: #7ad2ff;
    --ag-shadow: 0 16px 38px rgba(0, 0, 0, .25);
    --bs-body-bg: var(--ag-page);
    --bs-body-color: var(--ag-text);
    --bs-border-color: var(--ag-border);
    --bs-primary: var(--ag-accent);
    --bs-primary-rgb: 91, 195, 238;
    --bs-secondary-color: var(--ag-text-secondary);
    --bs-tertiary-bg: var(--ag-surface-low);
}

html { position: relative; min-height: 100%; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--ag-page); color: var(--ag-text); font: 15px/1.5 Inter, "Segoe UI", Arial, sans-serif; }
*, *::before, *::after { box-sizing: border-box; }
a { color: var(--ag-accent); }
a:hover { color: var(--ag-accent-strong); }

.skip-link { position: fixed; top: .5rem; left: .5rem; z-index: 20; transform: translateY(-160%); padding: .55rem .8rem; border-radius: var(--ag-control-radius); background: var(--ag-surface-high); color: var(--ag-text); box-shadow: var(--ag-shadow); }
.skip-link:focus { transform: translateY(0); }

.app-shell { min-height: 100vh; display: flex; overflow: hidden; }
.app-sidebar { position: relative; flex: 0 0 var(--ag-sidebar-width); width: var(--ag-sidebar-width); min-width: 0; min-height: 100vh; max-height: 100vh; display: flex; flex-direction: column; overflow-x: hidden; overflow-y: auto; color: #1b2b42; background: linear-gradient(180deg, #f9fcff 0%, #eef5fc 52%, #e7f0f9 100%); border-right: 1px solid #c7d5e4; box-shadow: 8px 0 24px rgba(44, 87, 123, .05); transition: width var(--ag-transition), flex-basis var(--ag-transition), opacity var(--ag-transition), transform var(--ag-transition); }
.app-main { min-width: 0; min-height: 100vh; flex: 1; display: flex; flex-direction: column; }
.app-topbar { min-height: var(--ag-topbar-height); display: flex; align-items: center; gap: 1rem; padding: .7rem var(--ag-gutter); border-bottom: 1px solid var(--ag-border); background: color-mix(in srgb, var(--ag-surface) 92%, transparent); }
.app-content { width: min(100%, 1600px); margin: 0 auto; padding: 1.5rem var(--ag-gutter) 2rem; flex: 1; }

.sidebar-brand { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: 0 1rem; }
.brand-link { display: inline-flex; align-items: center; gap: .65rem; min-width: 0; color: inherit; font-weight: 760; letter-spacing: -.04em; text-decoration: none; white-space: nowrap; }
.brand-link:hover { color: inherit; }
.brand-link img { flex: 0 0 auto; object-fit: contain; }
.brand-wordmark { color: #1b2b42; font-size: 1.05rem; }
.brand-wordmark span { color: var(--ag-accent); }
.sidebar-hide { flex: 0 0 36px; width: 36px; min-height: 36px; padding: 0; border: 0; border-radius: var(--ag-control-radius); background: transparent; color: inherit; cursor: pointer; font-size: 1.75rem; line-height: 1; }
.sidebar-hide:hover { background: rgba(40, 150, 205, .1); color: #07577d; }

.sidebar-context { display: grid; gap: .15rem; min-width: 0; margin: 1rem; padding: .85rem; border: 1px solid #cbdbe8; border-radius: var(--ag-radius); background: rgba(231, 242, 251, .8); font-size: .8rem; }
.sidebar-context strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
.sidebar-context-label, .sidebar-section-label, .user-card span { color: #617992; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; }
.sidebar-nav { display: grid; gap: .2rem; padding: .25rem .65rem; }
.sidebar-link { width: 100%; min-height: 2.6rem; display: flex; align-items: center; gap: .7rem; padding: .65rem .75rem; border: 0; border-radius: var(--ag-control-radius); background: transparent; color: #39536f; text-align: left; text-decoration: none; font: inherit; font-weight: 600; cursor: pointer; }
.sidebar-link > i:first-child { width: 1.15rem; flex: 0 0 1.15rem; color: #55748f; text-align: center; }
.sidebar-link:hover { background: rgba(40, 150, 205, .1); color: #173956; }
.sidebar-link.active { background: linear-gradient(90deg, rgba(18, 153, 200, .18), rgba(18, 153, 200, .06)); color: #07577d; box-shadow: inset 3px 0 0 #1299c8; }
.sidebar-link.active > i:first-child, .sidebar-link:hover > i:first-child { color: currentColor; }
.sidebar-section-label { margin: 1rem .75rem .25rem; }
.sidebar-disclosure .disclosure-chevron { width: auto; margin-left: auto; transition: transform var(--ag-transition); }
.sidebar-disclosure[aria-expanded="true"] .disclosure-chevron { transform: rotate(180deg); }
.sidebar-subnav { display: grid; gap: .1rem; padding-left: 1.3rem; }
.sidebar-subnav[hidden] { display: none; }
.sidebar-subnav a { position: relative; padding: .38rem .7rem .38rem 1.2rem; border-radius: .4rem; color: #526c86; font-size: .85rem; text-decoration: none; }
.sidebar-subnav a::before { position: absolute; left: .45rem; content: "•"; color: #1299c8; }
.sidebar-subnav a:hover, .sidebar-subnav a.active { background: rgba(40, 150, 205, .1); color: #07577d; }

.sidebar-footer { display: grid; gap: .75rem; margin-top: auto; padding: 1rem; }
.preferences { display: grid; gap: .45rem; }
.language-switch, .theme-switch { display: flex; align-items: center; gap: .25rem; }
.language-switch form { margin: 0; }
.pref-button { min-height: 32px; display: inline-flex; align-items: center; justify-content: center; gap: .35rem; padding: .25rem .45rem; border: 1px solid var(--ag-border-panel); border-radius: var(--ag-control-radius); background: var(--ag-surface); color: var(--ag-text-secondary); font: inherit; font-size: .78rem; font-weight: 700; line-height: 1; white-space: nowrap; cursor: pointer; }
.pref-button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pref-button:hover { border-color: var(--ag-accent); color: var(--ag-accent-strong); }
.pref-button.selected, .pref-button[aria-pressed="true"] { border-color: var(--ag-accent); background: var(--ag-accent); color: #fff; }
.user-card { display: grid; min-width: 0; gap: .1rem; padding: .7rem .75rem; border: 1px solid #cbdbe8; border-radius: var(--ag-control-radius); background: rgba(255, 255, 255, .5); }
.user-card strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout-form { margin: 0; }
.logout-link { color: #9f273b; }
.logout-link:hover { color: #7f1f30; }

.topbar-context { min-width: 0; max-width: min(52rem, 60vw); display: grid; margin-inline: auto; text-align: center; line-height: 1.15; }
.topbar-context span { color: var(--ag-text-secondary); font-size: .72rem; text-transform: uppercase; letter-spacing: .09em; }
.topbar-context strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .95rem; }
.topbar-change-context { flex: 0 0 auto; }
.dashboard-action-form { margin: 0; }
.quiet-button, .icon-button { min-height: 36px; display: inline-flex; align-items: center; justify-content: center; gap: .45rem; padding: .35rem .6rem; border: 1px solid var(--ag-border); border-radius: var(--ag-control-radius); background: var(--ag-raised); color: var(--ag-text-secondary); font: inherit; font-weight: 700; cursor: pointer; }
.icon-button { width: 36px; padding: 0; }
.quiet-button:hover, .icon-button:hover { border-color: var(--ag-accent); color: var(--ag-accent-strong); }
.sidebar-open { display: none; }
html.sidebar-hidden .sidebar-open { display: inline-flex; }
html.sidebar-hidden .app-sidebar { flex-basis: 0; width: 0; padding-inline: 0; border: 0; box-shadow: none; opacity: 0; visibility: hidden; pointer-events: none; }

html[data-theme="dark"] .app-sidebar { color: #eff5ff; background: linear-gradient(180deg, var(--ag-nav), color-mix(in srgb, var(--ag-nav) 84%, #000)); border-color: color-mix(in srgb, var(--ag-border-panel) 55%, transparent); box-shadow: none; }
html[data-theme="dark"] .brand-wordmark { color: #eff5ff; }
html[data-theme="dark"] .sidebar-context { border-color: rgba(255, 255, 255, .1); background: rgba(255, 255, 255, .05); }
html[data-theme="dark"] .sidebar-context-label, html[data-theme="dark"] .sidebar-section-label, html[data-theme="dark"] .user-card span { color: #92a2b8; }
html[data-theme="dark"] .sidebar-link { color: #bac7d9; }
html[data-theme="dark"] .sidebar-link > i:first-child { color: #92a2b8; }
html[data-theme="dark"] .sidebar-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
html[data-theme="dark"] .sidebar-link.active { background: linear-gradient(90deg, rgba(91, 195, 238, .22), rgba(91, 195, 238, .06)); color: #fff; box-shadow: inset 3px 0 0 var(--ag-accent); }
html[data-theme="dark"] .sidebar-subnav a { color: #aebbd0; }
html[data-theme="dark"] .sidebar-subnav a:hover, html[data-theme="dark"] .sidebar-subnav a.active { background: rgba(255, 255, 255, .07); color: #fff; }
html[data-theme="dark"] .sidebar-hide:hover { background: rgba(255, 255, 255, .07); color: #fff; }
@@media (max-width: 700px) { .app-topbar { align-items: flex-start; flex-wrap: wrap; } .topbar-context { order: 3; flex-basis: 100%; max-width: none; } .topbar-change-context { margin-left: auto; } }
html[data-theme="dark"] .user-card { border-color: rgba(255, 255, 255, .1); background: rgba(255, 255, 255, .05); }
html[data-theme="dark"] .logout-link { color: #ff90a0; }

.sidebar-backdrop { position: fixed; inset: 0; z-index: 11; background: rgba(0, 8, 20, .55); }
.sidebar-backdrop[hidden] { display: none; }
body.drawer-open { overflow: hidden; }

.public-shell { min-height: 100vh; display: flex; flex-direction: column; }
.public-body { background: radial-gradient(circle at top right, var(--ag-accent-soft), transparent 34rem), var(--ag-page); }
.public-topbar { min-height: 76px; border-bottom: 1px solid var(--ag-border); background: var(--ag-surface); }
.public-topbar-inner { width: min(100%, 1200px); min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 0 auto; padding: .7rem var(--ag-gutter); }
.public-controls .preferences { display: flex; align-items: center; gap: .5rem; }
.public-content { width: min(100%, 1200px); margin: 0 auto; padding: 2rem var(--ag-gutter); flex: 1; }
.app-footer { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: 1.25rem var(--ag-gutter); color: var(--ag-text-muted); font-size: .8rem; }

h1, h2, h3, h4, h5 { color: var(--ag-text); letter-spacing: -.02em; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-header h1 { margin-bottom: .35rem; font-size: clamp(1.5rem, 2vw, 2rem); }
.page-header p { margin-bottom: 0; color: var(--ag-text-secondary); }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; }
.content-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
.card, .metric-card, .filter-card, .business-form, .result-summary, .modal-content, .dropdown-menu, .list-group-item { border-color: var(--ag-border); background-color: var(--ag-card); color: var(--ag-text); box-shadow: var(--ag-shadow); }
.card, .metric-card, .filter-card, .business-form, .result-summary { border: 1px solid var(--ag-border); border-radius: var(--ag-radius); }
.card { border-radius: var(--ag-radius); }
.card-header, .card-footer { border-color: var(--ag-border); background: var(--ag-surface-low); }
.metric-card { padding: 1rem; }
.metric-card strong { font-size: 1.8rem; }
.filter-card { display: flex; flex-wrap: wrap; align-items: end; gap: .8rem; margin-bottom: 1rem; padding: 1rem; }
.filter-card .field { min-width: min(100%, 190px); flex: 1; }
.filter-actions { display: flex; gap: .5rem; flex: 0 0 auto; }
.result-summary { display: flex; flex-wrap: wrap; gap: .8rem 1.5rem; margin-bottom: 1rem; padding: .8rem 1rem; }
.result-summary > * { display: grid; }
.business-form { max-width: 1100px; padding: 1.25rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.field { display: grid; gap: .35rem; }
.field label { font-size: .88rem; font-weight: 700; }
.check-field { display: flex; align-items: center; gap: .55rem; margin-block: 1rem; }
.notice { display: grid; gap: .25rem; padding: .8rem; border-left: 4px solid var(--ag-info); border-radius: var(--ag-control-radius); background: color-mix(in srgb, var(--ag-info) 10%, var(--ag-card)); }
.notice.success { border-color: var(--ag-success); background: color-mix(in srgb, var(--ag-success) 10%, var(--ag-card)); }
.notice.warning { border-color: var(--ag-warning); background: color-mix(in srgb, var(--ag-warning) 10%, var(--ag-card)); }
.notice.danger { border-color: var(--ag-danger); background: color-mix(in srgb, var(--ag-danger) 10%, var(--ag-card)); }
.empty-state { padding: 2.5rem 1rem; text-align: center; }
.text-muted { color: var(--ag-text-muted) !important; }
.dashboard-actions { display: grid; gap: .65rem; }
.dashboard-action { min-height: 3.4rem; justify-content: flex-start; gap: .8rem; padding: .8rem 1rem; text-align: left; }
.dashboard-action > i { width: 1.4rem; flex: 0 0 1.4rem; text-align: center; font-size: 1.05rem; }
.dashboard-action > span { flex: 1; text-align: center; }

.table-wrap, .table-responsive { overflow-x: auto; border: 1px solid var(--ag-border); border-radius: var(--ag-radius); background: var(--ag-card); box-shadow: var(--ag-shadow); }
.table-wrap > table { width: 100%; min-width: 720px; border-collapse: collapse; }
.table { --bs-table-bg: var(--ag-card); --bs-table-color: var(--ag-text); --bs-table-border-color: var(--ag-border); margin-bottom: 0; font-size: .88rem; }
.table > :not(caption) > * > * { padding: .65rem .75rem; vertical-align: middle; }
.table thead th, .table-dark th { border-bottom: 1px solid var(--ag-border); background: var(--ag-surface-low) !important; color: var(--ag-text-secondary) !important; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.table-striped > tbody > tr:nth-of-type(odd) > * { --bs-table-accent-bg: color-mix(in srgb, var(--ag-surface-low) 45%, transparent); color: var(--ag-text); }
.table-hover > tbody > tr:hover > * { --bs-table-accent-bg: var(--ag-accent-soft); color: var(--ag-text); }
.dataTables_wrapper, .dt-container, .dx-datagrid { color: var(--ag-text); }
.dataTables_wrapper .dataTables_length, .dataTables_wrapper .dataTables_filter, .dataTables_wrapper .dataTables_info, .dataTables_wrapper .dataTables_paginate { margin: .75rem; color: var(--ag-text-muted); }
.dt-container .dt-layout-row:not(.dt-layout-table) { margin: 0; padding: .75rem; row-gap: .5rem; }
.dt-container .dt-length, .dt-container .dt-search, .dt-container .dt-info, .dt-container .dt-paging { color: var(--ag-text-muted); }
.dt-container .pagination { gap: .25rem; margin: 0; }
.dt-container .page-link { min-width: var(--ag-control-height); min-height: var(--ag-control-height); display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--ag-border-panel); border-radius: var(--ag-control-radius) !important; background: var(--ag-surface); color: var(--ag-text-secondary); font-weight: 600; }
.dt-container .page-link:hover, .dt-container .page-link:focus { border-color: var(--ag-accent); background: var(--ag-accent-soft); color: var(--ag-accent-strong); }
.dt-container .page-item.active .page-link { border-color: var(--ag-accent); background: var(--ag-accent); color: #fff; }
.dt-container .page-item.disabled .page-link { border-color: var(--ag-border); background: var(--ag-surface-low); color: var(--ag-text-muted); opacity: .65; }
table.dataTable thead th.sorting_asc::after { content: " ▲ ASC"; }
table.dataTable thead th.sorting_desc::after { content: " ▼ DESC"; }
.sorted-column { background-color: color-mix(in srgb, var(--ag-warning) 15%, var(--ag-card)) !important; }

.form-control, .form-select, .select2-container--default .select2-selection--single { min-height: var(--ag-control-height); border-color: var(--ag-border); border-radius: var(--ag-control-radius); background-color: var(--ag-surface); color: var(--ag-text); }
.form-control::placeholder { color: var(--ag-text-muted); opacity: .85; }
.form-control:focus, .form-select:focus { border-color: var(--ag-accent); background-color: var(--ag-surface); color: var(--ag-text); box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--ag-focus) 30%, transparent); }
.form-control:read-only { background-color: var(--ag-surface-low); color: var(--ag-text-secondary); }
.form-control:disabled, .form-select:disabled { background-color: var(--ag-surface-low); color: var(--ag-text-muted); opacity: .8; }
.form-label, .form-check-label { color: var(--ag-text); font-weight: 600; }
.form-text { color: var(--ag-text-muted); }
.validation-summary-errors, .field-validation-error { color: var(--ag-danger); }
.save-validation-summary { border-left: .35rem solid var(--ag-danger); }
.page-form .input-validation-error,
.page-form input.input-validation-error,
.page-form select.input-validation-error,
.page-form textarea.input-validation-error,
.page-form .form-control.input-validation-error,
.page-form .form-select.input-validation-error,
.page-form .select2-container--default .select2-selection.input-validation-error {
    border-color: var(--ag-danger);
    box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--ag-danger) 18%, transparent);
}
.btn { min-height: var(--ag-control-height); border-radius: var(--ag-control-radius); font-weight: 600; touch-action: manipulation; }
.btn-sm { min-height: 2rem; }
.btn-primary { --bs-btn-bg: var(--ag-accent); --bs-btn-border-color: var(--ag-accent); --bs-btn-hover-bg: var(--ag-accent-strong); --bs-btn-hover-border-color: var(--ag-accent-strong); --bs-btn-active-bg: var(--ag-accent-strong); --bs-btn-active-border-color: var(--ag-accent-strong); }
.btn-outline-primary { --bs-btn-color: var(--ag-accent); --bs-btn-border-color: var(--ag-accent); --bs-btn-hover-color: #fff; --bs-btn-hover-bg: var(--ag-accent); --bs-btn-hover-border-color: var(--ag-accent); --bs-btn-active-color: #fff; --bs-btn-active-bg: var(--ag-accent-strong); --bs-btn-active-border-color: var(--ag-accent-strong); }
.btn-outline-secondary { --bs-btn-color: var(--ag-text-secondary); --bs-btn-border-color: var(--ag-border-panel); --bs-btn-hover-color: var(--ag-text); --bs-btn-hover-bg: var(--ag-surface-low); --bs-btn-hover-border-color: var(--ag-border-panel); }
.btn-success { --bs-btn-bg: var(--ag-success); --bs-btn-border-color: var(--ag-success); }
.btn-danger { --bs-btn-bg: var(--ag-danger); --bs-btn-border-color: var(--ag-danger); }
.alert { border-radius: .6rem; }
.badge { font-weight: 650; }
.dropdown-menu { padding: .4rem; }
.dropdown-item { border-radius: .35rem; color: var(--ag-text); }
.dropdown-item:hover, .dropdown-item:focus { background: var(--ag-accent-soft); color: var(--ag-text); }
.ql-toolbar.ql-snow, .ql-container.ql-snow, .select2-dropdown { border-color: var(--ag-border) !important; background: var(--ag-surface); color: var(--ag-text); }
.select2-container--default .select2-selection--single .select2-selection__rendered, .select2-container--default .select2-selection--single .select2-selection__arrow { color: var(--ag-text); }
html[data-theme="dark"] .bg-light, html[data-theme="dark"] .bg-white { background-color: var(--ag-surface-low) !important; }
html[data-theme="dark"] .text-dark { color: var(--ag-text) !important; }

.page-form { max-width: 1100px; margin-inline: auto; }
.login-form { max-width: 400px; }
textarea.form-control { resize: vertical; }
.page-actions { padding-top: 1rem; border-top: 1px solid var(--ag-border); }
.inline-editor { display: none; padding: 1rem; border: 1px solid var(--ag-border); border-radius: var(--ag-radius); background: var(--ag-surface-low); }
.email-editor, .preview-editor { min-height: 250px; }
.preview-editor .ql-editor { min-height: 250px; padding: 1rem; background: var(--ag-surface); color: var(--ag-text); }
.ratio > img, .object-fit-cover { object-fit: cover; }
.recipient-chip { display: inline-flex; align-items: center; gap: .5rem; padding: .5rem .75rem; border-radius: 999px; background: var(--ag-accent); color: #fff; font-size: .95rem; }
.recipient-chip .btn-close { filter: invert(1); opacity: .9; }
.recipient-chip .btn-close:hover { opacity: 1; }
.suggestions-box { max-height: 240px; overflow-y: auto; border: 1px solid var(--ag-border); border-radius: .375rem; }
.modal-list { max-height: 50vh; overflow-y: auto; }

.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--ag-focus); outline-offset: 3px; box-shadow: none; }

@media (max-width: 991px) {
    .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .app-shell { overflow: visible; }
    .app-sidebar, html.sidebar-hidden .app-sidebar { position: fixed; inset: 0 auto 0 0; z-index: 12; flex-basis: auto; width: min(86vw, 300px); max-height: 100vh; border-right: 1px solid var(--ag-border-panel); opacity: 1; visibility: visible; pointer-events: auto; transform: translateX(-105%); }
    body.drawer-open .app-sidebar { transform: translateX(0); }
    .app-main { width: 100%; }
    .sidebar-open, html.sidebar-hidden .sidebar-open { display: inline-flex; }
    .app-content { padding-top: 1rem; }
}

@media (max-width: 620px) {
    .public-topbar-inner, .app-footer, .page-header { align-items: flex-start; flex-direction: column; }
    .public-controls { width: 100%; }
    .public-controls .preferences { align-items: flex-start; flex-direction: column; }
    .theme-switch { flex-wrap: wrap; }
    .public-content { padding-top: 1.25rem; }
    .summary-grid, .form-grid { grid-template-columns: 1fr; }
    .filter-actions { width: 100%; }
    .filter-actions > * { flex: 1; }
    .result-summary { gap: .7rem 1.3rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}

/* Shared note priority semantics: PROJ_TODO_ITEMS.PRIORITY 1/2/3. */
.note-priority-fieldset { min-width: 0; border: 0; padding: 0; margin: 0; }
.note-priority-options { display: flex; flex-wrap: wrap; gap: .35rem; }
.note-priority-option { display: inline-flex; align-items: center; gap: .35rem; min-height: 2rem; padding: .25rem .5rem; border: 1px solid var(--note-priority-color); border-left-width: .3rem; border-radius: var(--ag-control-radius); background: color-mix(in srgb, var(--note-priority-color) 12%, var(--ag-surface)); color: var(--ag-text); cursor: pointer; font-size: .875rem; font-weight: 650; }
.note-priority-option:focus-within { outline: 2px solid var(--ag-accent); outline-offset: 2px; }
.note-priority-low, .note-priority-badge.note-priority-low, .calendar-event.note-priority-low { --note-priority-color: var(--ag-success); }
.note-priority-medium, .note-priority-badge.note-priority-medium, .calendar-event.note-priority-medium { --note-priority-color: var(--ag-warning); }
.note-priority-high, .note-priority-badge.note-priority-high, .calendar-event.note-priority-high { --note-priority-color: var(--ag-danger); }
.note-priority-unknown, .note-priority-badge.note-priority-unknown, .calendar-event.note-priority-unknown { --note-priority-color: var(--ag-text-muted); }
.legend-color.note-priority-low, .legend-color.note-priority-medium, .legend-color.note-priority-high, .legend-color.note-priority-unknown { border-left-color: var(--note-priority-color); }
.note-priority-badge { display: inline-flex; align-items: center; gap: .25rem; border-left: .3rem solid var(--note-priority-color); background: color-mix(in srgb, var(--note-priority-color) 14%, var(--ag-card)); color: var(--ag-text); }
.calendar-event.note-priority-low, .calendar-event.note-priority-medium, .calendar-event.note-priority-high, .calendar-event.note-priority-unknown { border-color: var(--note-priority-color); background: color-mix(in srgb, var(--note-priority-color) 14%, var(--ag-card)); }
.note-completed { opacity: .72; }