:root {
    --primary: #123b63;
    --primary-strong: #0b2a47;
    --secondary: #0b8793;
    --accent: #f5b942;
    --background: #f4f8fb;
    --surface: #ffffff;
    --surface-muted: #e9f2f7;
    --text: #182331;
    --muted: #667085;
    --border: #d8e2ea;
    --shadow: 0 14px 35px rgba(18, 59, 99, .09);
    --radius: 8px;
}

* {
    letter-spacing: 0;
}

body {
    background: var(--background);
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
    color: var(--primary);
}

.btn {
    border-radius: var(--radius);
    font-weight: 650;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover,
.btn-primary:focus {
    background: var(--primary-strong);
    border-color: var(--primary-strong);
}

.form-control,
.form-select {
    border-color: var(--border);
    border-radius: var(--radius);
    min-height: 44px;
}

.form-control:focus,
.form-select:focus,
.btn:focus-visible,
a:focus-visible {
    border-color: var(--secondary);
    box-shadow: 0 0 0 .2rem rgba(11, 135, 147, .18);
    outline: none;
}

.app-topbar {
    background: rgba(255, 255, 255, .94);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1030;
    backdrop-filter: blur(10px);
}

.navbar-brand {
    color: var(--primary);
    font-weight: 800;
}

.navbar .nav-link {
    border-radius: var(--radius);
    color: var(--muted);
    font-weight: 650;
}

.navbar .nav-link.active,
.navbar .nav-link:hover {
    background: var(--surface-muted);
    color: var(--primary);
}

.app-main {
    min-height: 100vh;
}

.app-container {
    max-width: 1160px;
    padding-top: 24px;
    padding-bottom: 96px;
}

.auth-screen {
    align-items: center;
    display: flex;
    min-height: 100vh;
    padding: 24px;
}

.auth-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin: 0 auto;
    max-width: 430px;
    padding: 28px;
    width: 100%;
}

.auth-panel-wide {
    max-width: 760px;
}

.welcome-band {
    align-items: center;
    background: linear-gradient(135deg, var(--primary), #176d7b);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    color: #fff;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin-bottom: 18px;
    padding: 24px;
}

.welcome-band h1,
.page-title-row h1,
.admin-title h1 {
    font-size: clamp(1.55rem, 2.4vw, 2.35rem);
    font-weight: 800;
    margin: 0;
}

.eyebrow {
    color: var(--secondary);
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.welcome-band .eyebrow,
.welcome-band p {
    color: rgba(255, 255, 255, .86);
}

.search-hero {
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: grid;
    gap: 10px;
    grid-template-columns: auto 1fr auto;
    margin-bottom: 28px;
    padding: 10px 12px;
}

.search-hero input {
    border: 0;
    min-height: 44px;
    outline: 0;
    width: 100%;
}

.section-block {
    margin-top: 30px;
}

.section-heading,
.page-title-row,
.admin-title {
    align-items: center;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin-bottom: 14px;
}

.section-heading h2 {
    font-size: 1.05rem;
    font-weight: 800;
    margin: 0;
}

.section-heading a {
    font-size: .92rem;
    font-weight: 700;
    text-decoration: none;
}

.shortcut-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.shortcut-pill {
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    display: inline-flex;
    flex: 0 0 auto;
    gap: 8px;
    padding: 10px 14px;
    text-decoration: none;
    white-space: nowrap;
}

.filter-panel,
.research-card,
.detail-shell,
.profile-panel,
.admin-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.filter-panel {
    margin-bottom: 16px;
    padding: 18px;
}

.research-card {
    height: 100%;
    transition: transform .16s ease, box-shadow .16s ease;
}

.research-card:hover {
    box-shadow: 0 18px 42px rgba(18, 59, 99, .13);
    transform: translateY(-2px);
}

.research-card-link {
    color: inherit;
    display: block;
    height: 100%;
    padding: 18px;
    text-decoration: none;
}

.research-card h2 {
    font-weight: 800;
    line-height: 1.35;
}

.research-excerpt {
    color: #475467;
    font-size: .94rem;
    line-height: 1.5;
}

.favorite-dot {
    color: #b9c2cc;
    flex: 0 0 auto;
}

.favorite-dot.is-active {
    color: var(--accent);
}

.tag {
    background: var(--surface-muted);
    border-radius: 999px;
    color: var(--primary);
    display: inline-flex;
    font-size: .86rem;
    font-weight: 700;
    padding: 6px 10px;
}

.empty-state {
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    color: var(--muted);
    padding: 24px;
    text-align: center;
}

.detail-shell {
    overflow: hidden;
}

.detail-header {
    background: linear-gradient(135deg, #ffffff, #eaf7f8);
    border-bottom: 1px solid var(--border);
    padding: 24px;
}

.detail-header h1 {
    font-size: clamp(1.6rem, 3vw, 2.45rem);
    font-weight: 850;
    line-height: 1.15;
    margin: 12px 0 8px;
}

.lead-meta {
    color: var(--muted);
    font-size: 1.03rem;
}

.action-row,
.detail-section {
    padding: 22px 24px;
}

.action-row {
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.detail-section h2 {
    font-size: 1.1rem;
    font-weight: 800;
}

.pdf-frame {
    aspect-ratio: 16 / 10;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.pdf-frame iframe {
    border: 0;
    height: 100%;
    width: 100%;
}

.profile-panel {
    margin: 0 auto;
    max-width: 560px;
    padding: 28px;
    text-align: center;
}

.profile-avatar {
    align-items: center;
    background: var(--surface-muted);
    border-radius: 999px;
    color: var(--primary);
    display: inline-flex;
    font-size: 2rem;
    height: 82px;
    justify-content: center;
    margin-bottom: 14px;
    width: 82px;
}

.mobile-bottom-nav {
    background: rgba(255, 255, 255, .96);
    border-top: 1px solid var(--border);
    bottom: 0;
    box-shadow: 0 -12px 30px rgba(18, 59, 99, .08);
    display: grid;
    gap: 2px;
    grid-template-columns: repeat(5, 1fr);
    left: 0;
    padding: 7px max(8px, env(safe-area-inset-right)) max(7px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    position: fixed;
    right: 0;
    z-index: 1040;
}

.mobile-bottom-nav a {
    align-items: center;
    border-radius: var(--radius);
    color: var(--muted);
    display: flex;
    flex-direction: column;
    font-size: .72rem;
    font-weight: 750;
    gap: 2px;
    min-width: 0;
    padding: 7px 2px;
    text-decoration: none;
}

.mobile-bottom-nav i {
    font-size: 1.1rem;
}

.mobile-bottom-nav a.active {
    background: var(--surface-muted);
    color: var(--primary);
}

.network-status {
    background: var(--primary);
    border-radius: 999px;
    color: #fff;
    font-size: .88rem;
    left: 50%;
    opacity: 0;
    padding: 8px 14px;
    pointer-events: none;
    position: fixed;
    top: 72px;
    transform: translate(-50%, -8px);
    transition: opacity .2s ease, transform .2s ease;
    z-index: 1080;
}

.network-status.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

.offline-banner {
    align-items: center;
    background: #fff7e0;
    border: 1px solid #f3dc9c;
    border-radius: var(--radius);
    color: #694f05;
    display: none;
    gap: 10px;
    margin-bottom: 18px;
    padding: 12px 14px;
}

.offline-banner.show {
    display: flex;
}

.search-feedback {
    color: var(--muted);
    font-weight: 700;
    margin-bottom: 14px;
    min-height: 24px;
}

@media (min-width: 992px) {
    .mobile-bottom-nav {
        display: none;
    }

    .app-container {
        padding-bottom: 48px;
    }
}

@media (max-width: 575.98px) {
    .welcome-band,
    .page-title-row,
    .admin-title {
        align-items: flex-start;
        flex-direction: column;
    }

    .welcome-band {
        padding: 20px;
    }

    .search-hero {
        grid-template-columns: auto 1fr;
    }

    .search-hero .btn {
        grid-column: 1 / -1;
        width: 100%;
    }

    .action-row .btn {
        width: 100%;
    }

    .pdf-frame {
        aspect-ratio: 3 / 4;
    }
}
