:root {
    --brand-primary: #173f35;
    --brand-secondary: #2f6b5a;
    --brand-accent: #c68b59;
    --brand-background: #f6f4ee;
    --brand-ink: #17231f;
    --brand-muted: #64736d;
    --brand-border: #dfe6e1;
    --brand-surface: #ffffff;
    --brand-primary-soft: #e7f0ec;
    --brand-accent-soft: #f5e9dd;
    --brand-shadow: 0 18px 45px rgba(23, 63, 53, 0.09);
}

html {
    color-scheme: light;
}

body.app-shell,
body.app-auth {
    font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    color: var(--brand-ink);
}

body.app-shell {
    background: var(--brand-background) !important;
}

.app-shell main {
    background-color: var(--brand-background) !important;
    background-image:
        radial-gradient(circle at 92% 4%, rgba(198, 139, 89, 0.08), transparent 22rem),
        linear-gradient(180deg, rgba(255, 255, 255, 0.52), transparent 18rem);
}

.app-shell input,
.app-shell textarea,
.app-shell select,
.app-auth input {
    border-color: var(--brand-border) !important;
}

.app-shell input:focus,
.app-shell textarea:focus,
.app-shell select:focus,
.app-auth input:focus {
    border-color: var(--brand-secondary) !important;
    box-shadow: 0 0 0 3px rgba(47, 107, 90, 0.12);
}

.app-shell a:focus-visible,
.app-shell button:focus-visible,
.app-shell input:focus-visible,
.app-shell textarea:focus-visible,
.app-shell select:focus-visible,
.app-auth a:focus-visible,
.app-auth button:focus-visible,
.app-auth input:focus-visible {
    outline: 3px solid rgba(198, 139, 89, 0.48);
    outline-offset: 2px;
}

.app-sidebar {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 248, 0.98)) !important;
    border-color: var(--brand-border) !important;
    box-shadow: 12px 0 40px rgba(23, 63, 53, 0.06) !important;
}

.app-brand {
    min-height: 5.5rem;
    border-color: var(--brand-border) !important;
    background: linear-gradient(135deg, rgba(231, 240, 236, 0.72), rgba(255, 255, 255, 0.96));
}

.app-brand__lockup {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 0.75rem;
}

.app-brand__mark {
    display: grid;
    width: 2.55rem;
    height: 2.55rem;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 0.9rem;
    color: #fff;
    background: linear-gradient(145deg, var(--brand-secondary), var(--brand-primary));
    box-shadow: 0 10px 22px rgba(23, 63, 53, 0.2);
}

.app-brand__name {
    color: var(--brand-primary);
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0.025em;
    line-height: 1.18;
}

.app-brand__tagline {
    margin-top: 0.18rem;
    color: var(--brand-muted);
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    line-height: 1.25;
    text-transform: uppercase;
}

.app-nav-section-label {
    color: var(--brand-muted) !important;
    letter-spacing: 0.16em !important;
}

.app-nav-link,
.app-sidebar nav a {
    position: relative;
    border: 1px solid transparent;
}

.app-nav-link:hover,
.app-sidebar nav a:hover {
    color: var(--brand-primary) !important;
    background: rgba(231, 240, 236, 0.7) !important;
}

.app-nav-link.is-active,
.app-sidebar .app-nav-link.bg-blue-50,
.app-sidebar .app-nav-link.bg-gray-50.text-gray-900,
.app-sidebar nav a.bg-blue-50,
.app-sidebar nav a.bg-gray-50.text-gray-900 {
    color: var(--brand-primary) !important;
    border-color: rgba(47, 107, 90, 0.18) !important;
    background: linear-gradient(135deg, rgba(231, 240, 236, 0.96), rgba(255, 255, 255, 0.94)) !important;
    box-shadow: 0 8px 18px rgba(23, 63, 53, 0.07) !important;
}

.app-nav-link.is-active::before,
.app-sidebar nav a.bg-blue-50::before,
.app-sidebar nav a.bg-gray-50.text-gray-900::before {
    position: absolute;
    top: 0.55rem;
    bottom: 0.55rem;
    left: -0.28rem;
    width: 0.2rem;
    border-radius: 999px;
    background: var(--brand-accent);
    content: "";
}

.app-sidebar-footer {
    border-color: var(--brand-border) !important;
    background: rgba(231, 240, 236, 0.42) !important;
}

.app-shell [class~="bg-[#2B3674]"],
.app-shell .bg-blue-600,
.app-auth .bg-blue-600 {
    background-color: var(--brand-primary) !important;
}

.app-shell .hover\:bg-blue-700:hover,
.app-auth .hover\:bg-blue-700:hover {
    background-color: var(--brand-secondary) !important;
}

.app-shell .bg-green-600,
.app-auth .bg-green-600 {
    background-color: var(--brand-secondary) !important;
}

.app-shell .hover\:bg-green-700:hover,
.app-auth .hover\:bg-green-700:hover {
    background-color: var(--brand-primary) !important;
}

.app-shell [class~="text-[#2B3674]"],
.app-shell .text-blue-700,
.app-shell .text-blue-600,
.app-auth .text-blue-600,
.app-auth .text-green-600 {
    color: var(--brand-primary) !important;
}

.app-shell [class~="bg-[#F4F7FE]"] {
    background-color: var(--brand-background) !important;
}

.app-shell .bg-blue-50,
.app-shell .bg-blue-100,
.app-auth .bg-blue-50 {
    background-color: var(--brand-primary-soft) !important;
}

.app-shell .border-blue-100,
.app-shell .border-blue-200,
.app-auth .border-blue-100 {
    border-color: rgba(47, 107, 90, 0.2) !important;
}

.app-shell .filter-checkbox:checked {
    border-color: var(--brand-primary) !important;
    background-color: var(--brand-primary) !important;
}

.app-auth {
    position: relative;
    overflow-x: hidden;
    background-color: var(--brand-background) !important;
    background-image:
        radial-gradient(circle at 12% 15%, rgba(47, 107, 90, 0.18), transparent 24rem),
        radial-gradient(circle at 88% 82%, rgba(198, 139, 89, 0.18), transparent 24rem),
        linear-gradient(135deg, #f9faf7, var(--brand-background)) !important;
}

.app-auth::before,
.app-auth::after {
    position: fixed;
    z-index: 0;
    width: 18rem;
    height: 18rem;
    border: 1px solid rgba(47, 107, 90, 0.09);
    border-radius: 50%;
    content: "";
    pointer-events: none;
}

.app-auth::before {
    top: -8rem;
    right: -5rem;
    box-shadow: 0 0 0 2.5rem rgba(47, 107, 90, 0.025), 0 0 0 5rem rgba(47, 107, 90, 0.02);
}

.app-auth::after {
    bottom: -9rem;
    left: -6rem;
    box-shadow: 0 0 0 3rem rgba(198, 139, 89, 0.03), 0 0 0 6rem rgba(198, 139, 89, 0.02);
}

.app-auth-card {
    position: relative;
    z-index: 1;
    border-color: rgba(47, 107, 90, 0.14) !important;
    border-radius: 1.5rem !important;
    box-shadow: var(--brand-shadow) !important;
}

.app-auth-card::before {
    position: absolute;
    top: 0;
    right: 2.2rem;
    left: 2.2rem;
    height: 0.22rem;
    border-radius: 0 0 999px 999px;
    background: linear-gradient(90deg, var(--brand-secondary), var(--brand-accent));
    content: "";
}

.app-auth-mark {
    background: linear-gradient(145deg, var(--brand-secondary), var(--brand-primary)) !important;
    box-shadow: 0 12px 28px rgba(23, 63, 53, 0.2) !important;
}

.app-auth-title {
    color: var(--brand-primary) !important;
}

.brand-color-input {
    min-height: 3.15rem;
    padding: 0.35rem !important;
    cursor: pointer;
}

@media (max-width: 640px) {
    .app-auth {
        align-items: flex-start !important;
        padding-top: 1.25rem !important;
        padding-bottom: 1.25rem !important;
    }

    .app-auth-card {
        border-radius: 1.2rem !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .app-shell *,
    .app-auth * {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

.alphabet-nav {
    isolation: isolate;
    display: grid;
    grid-template-columns: 2.75rem minmax(0, 1fr) 2.75rem;
    align-items: stretch;
    overflow: hidden;
    border: 1px solid #e5e7eb;
    border-radius: .75rem;
    background: #fff;
    box-shadow: 0 1px 3px rgb(15 23 42 / .08);
}

.alphabet-nav__track {
    display: flex;
    align-items: center;
    gap: .2rem;
    min-width: 0;
    overflow-x: auto;
    padding: .5rem .25rem;
    overscroll-behavior-inline: contain;
    scroll-padding-inline: .5rem;
    scroll-snap-type: x proximity;
}

.alphabet-nav__letter {
    flex: 0 0 auto;
    min-width: 2rem;
    padding: .4rem .55rem;
    border-radius: .5rem;
    color: #6b7280;
    font-size: .8125rem;
    font-weight: 700;
    line-height: 1.25;
    scroll-snap-align: center;
    transition: background-color .15s ease, color .15s ease;
}

.alphabet-nav__letter:hover,
.alphabet-nav__letter:focus-visible {
    background: #f3f4f6;
    color: #111827;
}

.alphabet-nav__letter.is-active {
    background: #111827;
    color: #fff;
}

.alphabet-nav__arrow {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: #fff;
    color: #374151;
    box-shadow: 0 0 14px rgb(15 23 42 / .12);
}

.alphabet-nav__arrow:hover:not(:disabled),
.alphabet-nav__arrow:focus-visible {
    background: #f3f4f6;
    color: #111827;
}

.alphabet-nav__arrow:disabled {
    color: #d1d5db;
    box-shadow: none;
    cursor: default;
}

.filter-overlay {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 1.25rem;
    overflow: hidden;
    background: rgb(15 23 42 / .48);
    backdrop-filter: blur(2px);
}

.filter-dialog {
    display: flex;
    flex-direction: column;
    width: min(46rem, 100%);
    max-height: calc(100dvh - 2.5rem);
    margin-top: min(4.5rem, 8vh);
    overflow: hidden;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 1.25rem;
    box-shadow: 0 24px 60px rgb(15 23 42 / .28);
}

.filter-dialog__header,
.filter-dialog__footer {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: #fff;
}

.filter-dialog__header {
    border-bottom: 1px solid #f1f5f9;
}

.filter-dialog__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    flex: 0 0 auto;
    border-radius: .75rem;
    color: #475569;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.filter-dialog__close:hover,
.filter-dialog__close:focus-visible {
    color: #0f172a;
    background: #f1f5f9;
}

.filter-dialog__body {
    min-height: 0;
    padding: 1.25rem;
    overflow-y: auto;
    overscroll-behavior: contain;
}

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

.filter-dialog__section {
    min-width: 0;
    padding: 1rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
}

.filter-dialog__legend {
    width: 100%;
    margin-bottom: .75rem;
    color: #64748b;
    font-size: .7rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

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

.filter-dialog__option {
    display: flex;
    align-items: center;
    gap: .7rem;
    min-width: 0;
    min-height: 2.75rem;
    padding: .55rem .7rem;
    color: #475569;
    font-size: .82rem;
    font-weight: 600;
    line-height: 1.25;
    cursor: pointer;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: .75rem;
    transition: border-color .15s ease, color .15s ease, background-color .15s ease;
}

.filter-dialog__option:hover,
.filter-dialog__option:focus-within {
    color: #111827;
    border-color: #cbd5e1;
    background: #fff;
}

.filter-dialog__option > span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.filter-dialog__footer {
    border-top: 1px solid #f1f5f9;
}

.filter-dialog__clear,
.filter-dialog__apply {
    min-height: 2.75rem;
    padding: .7rem 1rem;
    border-radius: .75rem;
    font-size: .82rem;
    font-weight: 800;
}

.filter-dialog__clear {
    color: #475569;
    background: #fff;
    border: 1px solid #dbe1e8;
}

.filter-dialog__clear:disabled {
    color: #a8b0bc;
    background: #f8fafc;
    cursor: default;
}

.filter-dialog__apply {
    color: #fff;
    background: #111827;
    border: 1px solid #111827;
}

.filter-dialog__apply:hover,
.filter-dialog__apply:focus-visible {
    background: #1f2937;
}

@supports not (height: 100dvh) {
    .filter-dialog {
        max-height: calc(100vh - 2.5rem);
    }
}

@media (max-width: 767px) {
    .filter-overlay {
        align-items: stretch;
        padding: .5rem;
    }

    .filter-dialog {
        width: 100%;
        height: calc(100dvh - 1rem);
        max-height: none;
        margin-top: 0;
        border-radius: 1rem;
    }

    .filter-dialog__header,
    .filter-dialog__body,
    .filter-dialog__footer {
        padding: 1rem;
    }

    .filter-dialog__grid,
    .filter-dialog__options {
        grid-template-columns: 1fr;
    }

    .filter-dialog__footer {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
}

@media (min-width: 1280px) {
    .alphabet-nav__letter {
        min-width: 1.75rem;
        padding-inline: .4rem;
    }
}
