:root {
    --bg: #f3f5fb;
    --card: #ffffff;
    --card-soft: #f8faff;
    --text: #18202a;
    --muted: #5c6675;
    --line: #d7deea;
    --line-strong: #c4cfdf;
    --primary: #1f5eff;
    --primary-dark: #1748c5;
    --header: #111827;
    --header-soft: #1b2540;
    --danger: #b42318;
    --success: #127c42;
    --warning: #b76e00;
    --shadow: 0 10px 30px rgba(20, 28, 45, 0.08);
    --shadow-soft: 0 6px 18px rgba(20, 28, 45, 0.05);
    --radius: 18px;
    --radius-sm: 14px;
    --tap: 48px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
    background: var(--bg);
    color: var(--text);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.45;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover { text-decoration: underline; }

button,
input,
select,
textarea {
    font: inherit;
}

.container {
    width: min(1080px, calc(100% - 1rem));
    margin: 0 auto;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: rgba(17, 24, 39, 0.96);
    color: #fff;
    backdrop-filter: blur(10px);
    box-shadow: 0 1px 0 rgba(255,255,255,0.08) inset;
}

.header-shell {
    padding: 0.8rem 0 0.9rem;
}

.header-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.brand-wrap {
    min-width: 0;
}

.brand {
    color: #fff;
    font-size: 1.32rem;
    font-weight: 800;
    line-height: 1.1;
}

.brand:hover { text-decoration: none; }

.tagline {
    margin: 0.28rem 0 0;
    color: rgba(255,255,255,0.72);
    max-width: 42rem;
    font-size: 0.93rem;
}

.nav-toggle {
    display: none;
    width: var(--tap);
    height: var(--tap);
    border: 1px solid rgba(255,255,255,0.14);
    background: rgba(255,255,255,0.06);
    border-radius: 14px;
    padding: 0;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 0.24rem;
    cursor: pointer;
}

.nav-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: #fff;
    border-radius: 999px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.top-nav {
    margin-top: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.nav-user-block {
    padding: 0.75rem 0.9rem;
    border-radius: 14px;
    background: rgba(255,255,255,0.08);
    min-width: 210px;
}

.nav-kicker {
    display: block;
    color: rgba(255,255,255,0.65);
    font-size: 0.78rem;
}

.nav-user-name {
    display: block;
    margin-top: 0.12rem;
    font-size: 0.98rem;
}

.nav-link {
    min-height: var(--tap);
    display: inline-flex;
    align-items: center;
    color: #fff;
    opacity: 0.94;
    padding: 0.75rem 0.95rem;
    border-radius: 14px;
    background: rgba(255,255,255,0.04);
}

.nav-link:hover {
    text-decoration: none;
    background: rgba(255,255,255,0.08);
}

.main-content {
    padding: 1rem 0 5.5rem;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem;
    margin-bottom: 1rem;
}

.card.soft {
    background: var(--card-soft);
}

.narrow-card {
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
}

.list-card { padding: 1rem; }

.auth-wrap {
    min-height: 65vh;
    display: grid;
    place-items: center;
}

h1, h2, h3 {
    margin-top: 0;
    line-height: 1.2;
}

h1 { font-size: clamp(1.45rem, 4vw, 2.15rem); }
h2 { font-size: clamp(1.12rem, 3vw, 1.45rem); }
h3 { font-size: 1.02rem; }

.muted {
    color: var(--muted);
}

.small {
    font-size: 0.9rem;
}

.help-text {
    margin: 0.2rem 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.form-grid {
    display: grid;
    gap: 0.9rem;
}

.two-col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.compact-grid {
    gap: 0.75rem;
}

.full-width {
    grid-column: 1 / -1;
}

label {
    display: grid;
    gap: 0.38rem;
    font-weight: 600;
}

label span {
    font-size: 0.95rem;
}

input, textarea, select {
    width: 100%;
    min-height: var(--tap);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 0.8rem 0.95rem;
    background: #fff;
    color: var(--text);
}

textarea { resize: vertical; min-height: 6rem; }

input:focus, textarea:focus, select:focus, button:focus {
    outline: 3px solid rgba(31, 94, 255, 0.16);
    border-color: var(--primary);
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-height: var(--tap);
    border-radius: 14px;
    padding: 0.82rem 1rem;
    font-weight: 700;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

.button:hover { text-decoration: none; }

.button.primary {
    background: var(--primary);
    color: #fff;
}

.button.primary:hover { background: var(--primary-dark); }

.button.ghost {
    background: #fff;
    border-color: var(--line);
    color: var(--text);
}

.button.ghost:hover {
    background: #f8faff;
}

.button.subtle {
    background: var(--card-soft);
    color: var(--text);
    border-color: var(--line);
}

.button.warning {
    background: #fff7ea;
    color: #825000;
    border-color: #efcf93;
}

.button.danger {
    background: #fff1f1;
    color: #a61b1b;
    border-color: #f0b6b6;
}

.button.danger:hover {
    background: #ffe2e2;
}

.inline-form {
    display: inline-flex;
    margin: 0;
}

.inline-form button {
    width: auto;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.stacked-mobile {
    align-items: stretch;
}

.button-row,
.actions-row {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.wrap { flex-wrap: wrap; }

.back-link {
    display: inline-block;
    margin-bottom: 0.45rem;
    font-weight: 700;
}

.badge {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--line);
    background: #f9fbff;
    color: #243042;
    border-radius: 999px;
    padding: 0.34rem 0.66rem;
    font-size: 0.84rem;
}

.badge.primary {
    background: #eef4ff;
    color: #1748c5;
    border-color: #bfd0ff;
}

.badge.warning {
    background: #fff7ea;
    color: #825000;
    border-color: #efcf93;
}

.hidden-form {
    display: none;
}

.trash-banner {
    border: 1px solid #efcf93;
    background: #fffaf0;
}

.trash-item {
    border-style: dashed;
}

.stats-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 1rem;
}

.stat-card {
    display: grid;
    gap: 0.2rem;
}

.stat-label {
    color: var(--muted);
    font-size: 0.92rem;
}

.stat-value {
    font-size: clamp(1.8rem, 6vw, 2.4rem);
}

.case-list,
.incident-list {
    display: grid;
    gap: 0.9rem;
}

.case-item,
.incident-item {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 0.95rem;
    display: grid;
    gap: 0.8rem;
    background: linear-gradient(180deg, #fff, #fcfdff);
}

.case-item-main h2,
.incident-main h3 {
    margin-bottom: 0.35rem;
}

.case-item-actions,
.case-item-meta,
.incident-meta {
    display: flex;
    gap: 0.55rem;
    flex-wrap: wrap;
}

.case-item-actions {
    margin-top: 0.2rem;
}

.grid-2 {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.meta-list {
    display: grid;
    gap: 0.7rem;
    margin: 0;
}

.meta-list div {
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--line);
}

.meta-list dt {
    font-weight: 700;
    color: var(--muted);
}

.meta-list dd {
    margin: 0.2rem 0 0;
}

.simple-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 0.8rem;
}

.simple-list li {
    border-bottom: 1px solid var(--line);
    padding-bottom: 0.7rem;
}

.simple-list li:last-child { border-bottom: none; padding-bottom: 0; }

.prose {
    line-height: 1.65;
}

.checkbox-row {
    display: flex;
    gap: 0.7rem;
    align-items: center;
    font-weight: 600;
}

.checkbox-row input {
    width: auto;
    min-height: auto;
    transform: scale(1.2);
}

.section-headline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.8rem;
}

.flash-stack {
    display: grid;
    gap: 0.65rem;
    margin-bottom: 1rem;
}

.flash {
    border-radius: 14px;
    padding: 0.9rem 1rem;
    border: 1px solid var(--line);
    background: #fff;
    box-shadow: var(--shadow-soft);
}

.flash-success {
    border-color: rgba(18, 124, 66, 0.35);
    background: #f1fcf5;
}

.flash-error {
    border-color: rgba(180, 35, 24, 0.35);
    background: #fff3f2;
}

.result-box {
    margin-top: 1rem;
    padding: 1rem;
    background: #f8fbff;
    border: 1px dashed #9fb8f8;
    border-radius: 12px;
}

.error-card {
    text-align: center;
}

.hero-card {
    display: grid;
    gap: 0.5rem;
}

.hero-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 0.4rem;
}

.mobile-fab {
    display: none;
    position: fixed;
    right: 1rem;
    bottom: max(1rem, env(safe-area-inset-bottom));
    z-index: 35;
    box-shadow: 0 16px 32px rgba(31, 94, 255, 0.28);
}

.collapsible-card {
    overflow: hidden;
}

.collapsible-card summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    font-weight: 800;
    padding: 0.1rem 0;
}

.collapsible-card summary::-webkit-details-marker {
    display: none;
}

.collapsible-card summary::after {
    content: "+";
    font-size: 1.2rem;
    color: var(--muted);
}

.collapsible-card[open] summary::after {
    content: "−";
}

.collapsible-content {
    padding-top: 0.9rem;
}

.incident-form-shell {
    display: grid;
    gap: 1rem;
}

.quick-capture-card {
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, #ffffff, #f8fbff);
}

.quick-capture-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 5px;
    background: var(--primary);
}

.quick-capture-title {
    padding-left: 0.25rem;
}

.form-note-list {
    margin: 0.35rem 0 0;
    padding-left: 1rem;
    color: var(--muted);
}

.form-note-list li + li {
    margin-top: 0.18rem;
}

.sticky-form-actions {
    position: sticky;
    bottom: 0;
    z-index: 25;
    background: rgba(243, 245, 251, 0.96);
    backdrop-filter: blur(8px);
    border-top: 1px solid rgba(196, 207, 223, 0.85);
    margin: 0 -0.35rem -0.35rem;
    padding: 0.85rem 0.35rem calc(0.4rem + env(safe-area-inset-bottom));
}

.sticky-form-actions .actions-row {
    flex-wrap: wrap;
}

.field-hint {
    margin-top: -0.1rem;
    font-size: 0.86rem;
    color: var(--muted);
}

.inline-pills {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.inline-pills .badge {
    background: #fff;
}

.filter-card {
    display: grid;
    gap: 0.8rem;
}

.quick-action-panel {
    display: grid;
    gap: 0.85rem;
}

.quick-action-panel .button {
    width: 100%;
}

.empty-state {
    padding: 1rem;
    border: 1px dashed var(--line-strong);
    border-radius: 16px;
    background: #fbfcff;
}

@media (max-width: 840px) {
    .container {
        width: min(1080px, calc(100% - 0.8rem));
    }

    .nav-toggle {
        display: inline-flex;
    }

    .top-nav {
        display: none;
        flex-direction: column;
        align-items: stretch;
        margin-top: 0.8rem;
        padding-top: 0.8rem;
        border-top: 1px solid rgba(255,255,255,0.09);
    }

    .site-header.nav-open .top-nav {
        display: flex;
    }

    .nav-user-block,
    .nav-link {
        width: 100%;
    }

    .two-col,
    .grid-2,
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .toolbar,
    .header-topbar,
    .button-row,
    .actions-row,
    .hero-actions,
    .section-headline {
        flex-direction: column;
        align-items: stretch;
    }

    .button,
    .button-row .button,
    .actions-row .button {
        width: 100%;
    }

    .mobile-fab {
        display: inline-flex;
    }

    .tagline {
        font-size: 0.88rem;
        max-width: 100%;
    }

    .card,
    .list-card {
        padding: 0.9rem;
        border-radius: 16px;
    }

    .incident-item,
    .case-item {
        padding: 0.9rem;
    }

    .sticky-form-actions {
        margin-left: -0.15rem;
        margin-right: -0.15rem;
    }
}

@media (min-width: 841px) {
    .top-nav {
        display: flex !important;
        justify-content: flex-end;
        align-items: center;
    }

    .header-shell {
        display: flex;
        justify-content: space-between;
        gap: 1rem;
        align-items: flex-start;
    }

    .header-topbar {
        flex: 1 1 auto;
    }

    .top-nav {
        margin-top: 0;
        flex: 0 0 auto;
    }
}

/* --- mobile fast v3 overrides --- */
.site-header,
.header-shell,
.header-topbar,
.top-nav,
.brand-wrap,
.tagline,
.nav-toggle {
    display: none !important;
}

body.drawer-open {
    overflow: hidden;
}

.main-content {
    padding-top: 1rem;
    padding-bottom: 6rem;
}

.menu-fab {
    position: fixed;
    top: max(0.75rem, env(safe-area-inset-top));
    right: 0.75rem;
    z-index: 60;
    width: 54px;
    height: 54px;
    border: 1px solid rgba(17, 24, 39, 0.08);
    border-radius: 18px;
    background: rgba(17, 24, 39, 0.96);
    box-shadow: 0 10px 24px rgba(17, 24, 39, 0.18);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 0.26rem;
    padding: 0;
}

.menu-fab span {
    display: block;
    width: 22px;
    height: 2px;
    border-radius: 999px;
    background: #fff;
}

.drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.36);
    z-index: 55;
}

.mobile-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(86vw, 320px);
    background: #fff;
    z-index: 58;
    transform: translateX(100%);
    transition: transform 0.22s ease;
    box-shadow: -16px 0 40px rgba(15, 23, 42, 0.18);
    padding: calc(1rem + env(safe-area-inset-top)) 1rem calc(1rem + env(safe-area-inset-bottom));
    display: grid;
    align-content: start;
    gap: 1rem;
}

body.drawer-open .mobile-drawer {
    transform: translateX(0);
}

.drawer-header {
    display: grid;
    gap: 0.2rem;
    padding: 0.9rem;
    border-radius: 16px;
    background: #f7f9fd;
    border: 1px solid var(--line);
}

.drawer-kicker,
.drawer-mail {
    margin: 0;
    color: var(--muted);
    font-size: 0.88rem;
}

.drawer-user {
    font-size: 1rem;
}

.drawer-nav {
    display: grid;
    gap: 0.65rem;
}

.drawer-link {
    min-height: var(--tap);
    display: flex;
    align-items: center;
    padding: 0.85rem 1rem;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fff;
    color: var(--text);
    font-weight: 700;
}

.drawer-link:hover {
    text-decoration: none;
    background: #f8fbff;
}

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.9rem;
    margin: 0 0 1rem;
    padding-right: 4.4rem;
}

.compact-head h1 {
    margin-bottom: 0.2rem;
    font-size: clamp(1.5rem, 7vw, 2rem);
}

.compact-head p {
    margin: 0;
}

.compact-card,
.compact-list-card {
    padding: 0.9rem;
}

.case-list-block {
    margin-bottom: 1rem;
}

.compact-meta {
    gap: 0.45rem;
}

.compact-meta .badge {
    font-size: 0.8rem;
}

.split-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.7rem;
}

.compact-stats {
    margin-top: 0.8rem;
}

.compact-empty {
    display: grid;
    gap: 0.8rem;
}

.compact-empty h2,
.compact-section-headline h2 {
    margin-bottom: 0;
}

.case-head {
    margin-bottom: 0.8rem;
}

.compact-actions {
    gap: 0.55rem;
}

.form-head {
    margin-bottom: 0.75rem;
}

.compact-quick-card {
    padding: 0.9rem;
}

.compact-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.8rem;
    margin-bottom: 0.7rem;
}

.compact-title-row h2 {
    margin-bottom: 0.1rem;
}

.compact-form-grid {
    gap: 0.8rem;
}

.compact-quick-meta {
    gap: 0.8rem;
}

.compact-quick-card textarea {
    min-height: 7.2rem;
}

.compact-sticky-actions {
    padding: 0.75rem 0 calc(0.2rem + env(safe-area-inset-bottom));
    background: linear-gradient(to top, rgba(243,245,251,0.98), rgba(243,245,251,0.9));
    border-top: 1px solid rgba(196, 207, 223, 0.7);
}

.quick-save-row {
    display: grid;
    grid-template-columns: 1fr 1.35fr;
    gap: 0.75rem;
}

.quick-save-row .button {
    width: 100%;
}

.quick-save-row .button.ghost {
    background: #fff;
}

@media (max-width: 840px) {
    .container {
        width: min(1080px, calc(100% - 0.9rem));
    }

    .main-content {
        padding-top: 0.9rem;
    }

    .page-head {
        flex-direction: column;
        align-items: stretch;
        padding-right: 4.25rem;
    }

    .page-head .button {
        width: auto;
        align-self: flex-start;
    }

    .stats-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0.65rem;
    }

    .stat-card {
        padding: 0.8rem;
    }

    .stat-label {
        font-size: 0.8rem;
    }

    .stat-value {
        font-size: 1.45rem;
    }

    .case-item,
    .incident-item {
        gap: 0.7rem;
    }

    .button,
    .button-row .button,
    .actions-row .button {
        width: 100%;
    }

    .hero-actions {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: stretch;
    }

    .hero-actions .button {
        width: auto;
        flex: 1 1 calc(50% - 0.3rem);
    }

    .split-actions,
    .quick-save-row,
    .two-col,
    .grid-2 {
        grid-template-columns: 1fr;
    }

    .mobile-fab {
        display: inline-flex;
        right: 0.9rem;
        bottom: max(0.9rem, env(safe-area-inset-bottom));
    }

    .quick-capture-card::before {
        width: 4px;
    }
}

@media (min-width: 841px) {
    .menu-fab,
    .drawer-backdrop,
    .mobile-drawer {
        display: none;
    }

    .page-head {
        padding-right: 0;
    }
}

/* --- mobile fast v4 overrides --- */
html[data-theme='light'] {
    color-scheme: light;
}

html[data-theme='dark'] {
    color-scheme: dark;
    --bg: #0b1220;
    --card: #111a2b;
    --card-soft: #0f1726;
    --text: #e5edf8;
    --muted: #9ba9bd;
    --line: #233147;
    --line-strong: #324662;
    --primary: #5b8cff;
    --primary-dark: #4475ea;
    --header: #09101d;
    --header-soft: #121b2b;
    --shadow: 0 16px 32px rgba(0, 0, 0, 0.35);
    --shadow-soft: 0 8px 22px rgba(0, 0, 0, 0.22);
}

html[data-theme='dark'] body {
    background: var(--bg);
    color: var(--text);
}

html[data-theme='dark'] a {
    color: #8fb2ff;
}

html[data-theme='dark'] input,
html[data-theme='dark'] textarea,
html[data-theme='dark'] select {
    background: #0f1726;
    color: var(--text);
    border-color: var(--line);
}

html[data-theme='dark'] .card,
html[data-theme='dark'] .flash,
html[data-theme='dark'] .case-item,
html[data-theme='dark'] .incident-item,
html[data-theme='dark'] .mobile-drawer,
html[data-theme='dark'] .drawer-link,
html[data-theme='dark'] .empty-state,
html[data-theme='dark'] .drawer-header {
    background: var(--card);
    color: var(--text);
    border-color: var(--line);
}

html[data-theme='dark'] .quick-capture-card {
    background: linear-gradient(180deg, #111a2b, #0d1523);
}

html[data-theme='dark'] .badge {
    background: #0f1726;
    color: var(--text);
    border-color: var(--line);
}

html[data-theme='dark'] .badge.primary,
html[data-theme='dark'] .theme-indicator {
    background: rgba(91, 140, 255, 0.14);
    color: #9ab8ff;
    border-color: rgba(91, 140, 255, 0.35);
}

html[data-theme='dark'] .badge.warning,
html[data-theme='dark'] .trash-banner {
    background: rgba(183, 110, 0, 0.18);
    color: #ffd188;
    border-color: rgba(183, 110, 0, 0.34);
}

html[data-theme='dark'] .button.ghost,
html[data-theme='dark'] .button.subtle,
html[data-theme='dark'] .drawer-link {
    background: #0f1726;
    color: var(--text);
    border-color: var(--line);
}

html[data-theme='dark'] .button.ghost:hover,
html[data-theme='dark'] .button.subtle:hover,
html[data-theme='dark'] .drawer-link:hover {
    background: #162033;
}

html[data-theme='dark'] .button.warning {
    background: rgba(183, 110, 0, 0.18);
    color: #ffd188;
    border-color: rgba(183, 110, 0, 0.34);
}

html[data-theme='dark'] .flash-success {
    background: rgba(18, 124, 66, 0.16);
    border-color: rgba(18, 124, 66, 0.35);
}

html[data-theme='dark'] .flash-error {
    background: rgba(180, 35, 24, 0.16);
    border-color: rgba(180, 35, 24, 0.35);
}

html[data-theme='dark'] .result-box {
    background: #0f1726;
    border-color: rgba(91, 140, 255, 0.42);
}

html[data-theme='dark'] .meta-list div,
html[data-theme='dark'] .simple-list li {
    border-bottom-color: var(--line);
}

html[data-theme='dark'] .drawer-backdrop {
    background: rgba(0, 0, 0, 0.54);
}

html[data-theme='dark'] .compact-sticky-actions {
    background: linear-gradient(to top, rgba(11, 18, 32, 0.98), rgba(11, 18, 32, 0.9));
    border-top-color: rgba(35, 49, 71, 0.9);
}

.main-content {
    padding-top: 0.9rem;
    padding-bottom: calc(5.75rem + env(safe-area-inset-bottom));
}

.page-head {
    padding-right: 0 !important;
}

.menu-fab {
    top: auto;
    right: auto;
    left: 0.85rem;
    bottom: calc(0.85rem + env(safe-area-inset-bottom));
    width: 50px;
    height: 50px;
    border-radius: 999px;
    z-index: 70;
}

.mobile-drawer {
    left: 0;
    right: auto;
    transform: translateX(-100%);
    border-right: 1px solid var(--line);
    box-shadow: 16px 0 40px rgba(15, 23, 42, 0.18);
}

body.drawer-open .mobile-drawer {
    transform: translateX(0);
}

.drawer-link-button {
    width: 100%;
    justify-content: space-between;
    text-align: left;
}

.theme-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.75rem;
    padding: 0.2rem 0.55rem;
    border: 1px solid #bfd0ff;
    border-radius: 999px;
    background: #eef4ff;
    color: #1748c5;
    font-size: 0.85rem;
    font-weight: 700;
}

.case-actions {
    align-items: stretch;
}

.mobile-add-fab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    position: fixed;
    right: 0.85rem;
    left: auto;
    bottom: calc(0.85rem + env(safe-area-inset-bottom));
    z-index: 52;
    width: auto !important;
    min-height: 50px;
    padding: 0.78rem 1rem;
    border-radius: 999px;
    box-shadow: 0 16px 32px rgba(31, 94, 255, 0.26);
}

.fab-plus {
    font-size: 1.15rem;
    line-height: 1;
}

@media (max-width: 840px) {
    .desktop-only {
        display: none !important;
    }

    .hero-actions.case-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }

    .hero-actions.case-actions .button {
        width: 100%;
        flex: 0 0 auto;
    }

    .hero-actions.case-actions .button:only-child {
        grid-column: 1 / -1;
    }

    .toolbar.stacked-mobile .button-row.wrap {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }

    .toolbar.stacked-mobile .button-row.wrap .button {
        width: 100%;
    }
}

@media (min-width: 841px) {
    .menu-fab,
    .drawer-backdrop,
    .mobile-drawer {
        display: none;
    }

    .mobile-add-fab {
        display: none;
    }

    .desktop-only {
        display: inline-flex;
    }
}


/* --- branding integration --- */
.auth-brand {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    margin-bottom: 1.15rem;
}

.auth-brand-spacious {
    margin-bottom: 1.25rem;
}

.auth-brand-logo {
    width: 52px;
    height: 52px;
    display: block;
    flex: 0 0 52px;
}

.auth-brand-copy {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.auth-brand-copy strong {
    font-size: 1.1rem;
    line-height: 1.15;
    color: var(--text);
}

.auth-brand-copy span {
    margin-top: 0.15rem;
    font-size: 0.9rem;
    line-height: 1.2;
    color: var(--muted);
}

.drawer-header {
    gap: 0.85rem;
}

.drawer-brand {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.drawer-brand-logo {
    width: 44px;
    height: 44px;
    display: block;
    flex: 0 0 44px;
}

.drawer-brand-copy {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.drawer-brand-copy strong {
    font-size: 1rem;
    line-height: 1.15;
    color: var(--text);
}

.drawer-brand-copy span {
    margin-top: 0.12rem;
    font-size: 0.82rem;
    line-height: 1.2;
    color: var(--muted);
}

.drawer-user-card {
    display: grid;
    gap: 0.16rem;
    padding-top: 0.8rem;
    border-top: 1px solid var(--line);
}

html[data-theme='dark'] .drawer-user-card {
    border-top-color: var(--line);
}

@media (max-width: 840px) {
    .auth-brand-logo {
        width: 48px;
        height: 48px;
        flex-basis: 48px;
    }
}


/* --- PWA / install experience --- */
body.install-open {
    overflow: hidden;
}

.install-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.52);
    z-index: 79;
}

.install-sheet {
    position: fixed;
    left: 0.75rem;
    right: 0.75rem;
    bottom: calc(0.75rem + env(safe-area-inset-bottom));
    z-index: 80;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 24px;
    box-shadow: 0 22px 48px rgba(15, 23, 42, 0.28);
    padding: 1rem;
    transform: translateY(120%);
    transition: transform 0.22s ease;
    max-width: 560px;
    margin: 0 auto;
}

.install-sheet[aria-hidden='false'] {
    transform: translateY(0);
}

.install-sheet-head {
    display: flex;
    gap: 0.9rem;
    align-items: center;
    margin-bottom: 0.75rem;
}

.install-sheet-head h2 {
    margin-bottom: 0.15rem;
}

.install-sheet-head p {
    margin: 0;
}

.install-sheet-logo {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
}

.install-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-top: 1rem;
}

.install-list {
    margin: 0;
    padding-left: 1.1rem;
}

.install-list li + li {
    margin-top: 0.55rem;
}

html[data-theme='dark'] .install-sheet {
    background: var(--card);
    border-color: var(--line);
}

html[data-theme='dark'] .install-backdrop {
    background: rgba(0, 0, 0, 0.62);
}

@media (max-width: 840px) {
    .install-sheet {
        left: 0.5rem;
        right: 0.5rem;
        padding: 0.95rem;
        border-radius: 22px;
    }

    .install-actions {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 841px) {
    .install-sheet {
        bottom: 1rem;
    }
}
