/* Inter typeface, self-hosted under the SIL Open Font License.
   Files: static/fonts/inter-latin.woff2 and inter-latin-ext.woff2
   (variable fonts covering weights 400-800). Self-hosting keeps every
   request on this origin -- no third-party font CDN for visitors. */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url('fonts/inter-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url('fonts/inter-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

html {
    scrollbar-gutter: stable;
}

:root {
    --primary: #0170bd;
    --primary-hover: #005a9e;
    --accent: #d97706;
    --accent-hover: #b45309;
    --bg-main: #f3f2f1;
    --bg-card: #ffffff;
    --text-main: #111827;
    --text-muted: #505a5f;
    --border: #b1b4b6;
    --radius: 0px;
    --shadow: none;
    --shadow-md: none;
    --font: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --focus-yellow: #ffdd00;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font);
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/*
 * App-shell pages (map and profile grid) must fit the viewport exactly:
 * without the height pin, tall sidebar content stretches <main> beyond the
 * viewport and the lower part of the map canvas ends up below the fold.
 * The sidebar scrolls internally instead (overflow-y: auto).
 * 100dvh where supported: on mobile browsers 100vh grows taller than the
 * visible area behind the collapsed URL bar.
 */
body.app-shell {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
}

body.app-shell main {
    min-height: 0;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #b1b4b6;
    border-radius: 0;
}

::-webkit-scrollbar-thumb:hover {
    background: #505a5f;
}

header {
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    z-index: 10;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Mobile-only: opens the off-canvas filter drawer (hidden on desktop) */
#sidebar-toggle {
    display: none;
}

/* Backdrop behind the open drawer; created by main.js, styled only on
   small screens so it stays inert if a resize leaves it in the DOM. */
.sidebar-overlay {
    display: none;
}

header h1 {
    font-size: 1.125rem;
    color: var(--text-main);
    font-weight: 700;
    letter-spacing: -0.01em;
}

header a {
    text-decoration: none;
    color: inherit;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-nav span {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.flash-message {
    padding: 0.875rem 1.25rem;
    border-radius: 0;
    border: 1px solid var(--border);
    border-left-width: 6px;
    font-size: 0.8125rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
}

.flash-message.info {
    background-color: #eff6ff;
    color: #1e40af;
    border-left-color: var(--primary);
}

.flash-message.success {
    background-color: #ecfdf5;
    color: #065f46;
    border-left-color: #00703c;
}

.flash-message.danger {
    background-color: #fef2f2;
    color: #991b1b;
    border-left-color: #d4391f;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: 0;
    font-weight: 600;
    font-size: 0.8125rem;
    cursor: pointer;
    /* Uniform 2px border on every variant (transparent on filled ones)
       so outlined and filled buttons are exactly the same size. */
    border: 2px solid transparent;
    text-decoration: none;
    font-family: var(--font);
}

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

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

.btn-accent {
    background-color: var(--accent);
    color: white;
}

.btn-accent:hover {
    background-color: var(--accent-hover);
}

.btn-danger {
    background-color: #dc2626;
    color: white;
}

.btn-danger:hover {
    background-color: #b91c1c;
}

.btn-outline {
    background-color: transparent;
    border-color: var(--border);
    color: var(--text-muted);
}

.btn-outline:hover {
    background-color: var(--bg-main);
    border-color: #cbd5e1;
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    font-family: var(--font);
}

.btn-link:hover {
    text-decoration: underline;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

@media(min-width: 768px) {
    main {
        flex-direction: row;
    }
}

.sidebar {
    width: 100%;
    background-color: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    overflow-y: auto;
}

@media(min-width: 768px) {
    .sidebar {
        width: 360px;
        min-width: 360px;
    }
}

.content-area {
    flex: 1;
    position: relative;
    background-color: var(--bg-main);
    overflow: hidden;
}

.filter-box {
    background-color: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.875rem;
    margin-bottom: 0.75rem;
    min-width: 0;
    width: 100%;
}

.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    margin-bottom: 0.5rem;
}

.search-input {
    width: 100%;
    padding: 0.5rem 2rem 0.5rem 0.5rem;
    border: 1px solid #767676;
    border-radius: 0;
    font-size: 0.8125rem;
    outline: none;
    font-family: var(--font);
}

.search-input:focus {
    outline: 3px solid var(--focus-yellow);
    outline-offset: 0;
    border-color: var(--primary);
}

.search-clear-btn {
    position: absolute;
    right: 0.5rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.875rem;
    cursor: pointer;
    padding: 0.25rem;
    display: none;
    align-items: center;
    justify-content: center;
}

.search-clear-btn:hover {
    color: #dc2626;
}

.scroll-list {
    max-height: 140px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-bottom: 0.5rem;
    padding-right: 0.25rem;
}

.filter-label {
    display: flex;
    align-items: center;
    font-size: 0.8rem;
    background-color: white;
    padding: 0.375rem 0.6rem;
    border-radius: 0;
    border: 1px solid var(--border);
    cursor: pointer;
    width: 100%;
    user-select: none;
}

.filter-label:hover {
    background-color: #f9fafb;
    border-color: #cbd5e1;
}

.filter-label input[type="checkbox"] {
    accent-color: var(--primary);
    width: 0.9rem;
    height: 0.9rem;
    cursor: pointer;
}

.filter-label:has(input:checked) {
    background-color: #e8f1f8;
    border-color: #9fc7e3;
    color: var(--primary);
    font-weight: 500;
}

.view-tabs {
    display: flex;
    background-color: #e2e5e8;
    border: 1px solid var(--border);
    border-radius: 0;
    padding: 0.25rem;
    gap: 0.25rem;
}

.view-tab {
    flex: 1;
    padding: 0.45rem 0.75rem;
    font-size: 0.8125rem;
    border-radius: 0;
    cursor: pointer;
    border: none;
    background: transparent;
    color: var(--text-muted);
    text-align: center;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    height: 34px;
    white-space: nowrap;
    font-family: var(--font);
}

.view-tab.active {
    background-color: var(--primary);
    color: #ffffff;
    font-weight: 600;
    box-shadow: none;
}

.view-tab:hover:not(.active) {
    background-color: #d3d7db;
}

.detail-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.badge {
    display: inline-block;
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: 0;
    font-weight: 500;
}

.badge-gray {
    background-color: #f3f4f6;
    color: #374151;
}

.badge-indigo {
    background-color: #e0e7ff;
    color: #3730a3;
}

.badge-emerald {
    background-color: #d1fae5;
    color: #065f46;
}

.badge-amber {
    background-color: #fef3c7;
    color: #92400e;
}

.badge-red {
    background-color: #fee2e2;
    color: #991b1b;
}

/* Shared-topic highlighted badge: rendered by shared.js when a researcher's
   keyword/method matches the current user's own topics. */
.badge-shared {
    background-color: var(--primary);
    color: #ffffff;
    border: 1px solid var(--primary-hover);
    font-weight: 600;
    box-shadow: 0 0 5px rgba(1, 112, 189, 0.35);
}

.dashboard-container {
    width: 100%;
    max-width: 1100px;
    margin: 2rem auto;
    padding: 0 1.5rem;
    position: relative;
}

.profile-form {
    background-color: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 2rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    align-items: start;
}

@media(min-width: 768px) {
    .form-grid {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-group label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
}

.form-group input,
.form-group select {
    padding: 0.5rem;
    border: 1px solid #767676;
    border-radius: 0;
    font-size: 0.8125rem;
    font-family: var(--font);
}

.form-group input:focus,
.form-group select:focus {
    outline: 3px solid var(--focus-yellow);
    outline-offset: 0;
    border-color: var(--primary);
}

.readonly-input {
    background-color: var(--bg-main) !important;
    color: var(--text-muted) !important;
    cursor: not-allowed !important;
}

.visibility-box {
    background-color: #f9fafb;
    border: 1px solid var(--border);
    border-radius: 0;
    padding: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.study-item-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.75rem;
    align-items: center;
    width: 100%;
    background-color: var(--bg-main);
    padding: 0.625rem 0.875rem;
    border-radius: 0;
    border: 1px solid var(--border);
}

.study-item-row:hover {
    border-color: #cbd5e1;
    background-color: #f1f5f9;
}

@media(min-width: 640px) {
    .study-item-row {
        grid-template-columns: 120px 2fr 1fr auto;
    }
}

.study-input {
    width: 100%;
    min-width: 0;
    padding: 0.5rem;
    border: 1px solid #767676;
    border-radius: 0;
    font-size: 0.8125rem;
    font-family: var(--font);
}

.icon-danger-btn {
    background: none;
    border: none;
    color: #dc2626;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.875rem;
    padding: 0.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.icon-danger-btn:hover {
    color: #991b1b;
}

.dept-selector {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.6rem;
    max-height: 350px;
    overflow-y: auto;
    padding-top: 0.25rem;
}

.dept-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.university-group-title {
    grid-column: 1 / -1;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.25rem;
    margin-top: 0.4rem;
}

.profiles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
    padding: 0;
    align-items: start;
}

.profile-studies-list {
    max-height: 110px;
    overflow-y: auto;
    padding-right: 4px;
}

.profile-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.profile-card:hover {
    border-color: var(--primary);
}

.profile-card h3 {
    font-size: 1.1rem;
    color: var(--text-main);
}

.profile-card p {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 4px;
}

.admin-container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

.admin-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media(min-width: 1024px) {
    .admin-grid {
        grid-template-columns: 1fr 2fr;
    }
}

.admin-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.admin-table-container {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-top: 0.75rem;
}

.admin-list {
    list-style: none;
    overflow-y: auto;
}

.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.color-picker-input {
    width: 2.5rem;
    height: 2rem;
    border: 1px solid #767676;
    border-radius: 0;
    cursor: pointer;
    padding: 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
    text-align: left;
}

th {
    background-color: var(--bg-main);
    color: var(--text-muted);
    font-weight: 600;
    padding: 0.625rem 0.875rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

td {
    padding: 0.75rem 0.875rem;
    border-bottom: 1px solid var(--border);
}

tbody tr:nth-child(even) {
    background-color: #fafbfc;
}

tbody tr:hover {
    background-color: #f3f4f6;
}

.login-page {
    display: flex;
    /* Column so the login card and the footer stack instead of sitting
       side by side (body.login-page is a flex row by default). */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-main);
}

.login-card {
    background-color: var(--bg-card);
    padding: 2.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    max-width: 420px;
    width: 100%;
    border: 1px solid var(--border);
}

.login-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
    text-align: center;
    margin-bottom: 0.25rem;
}

.login-subtitle {
    font-size: 0.8125rem;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 1.5rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.login-footer {
    font-size: 0.75rem;
    text-align: center;
    color: var(--text-muted);
    margin-top: 1.5rem;
}

.danger-zone {
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-top: 2.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.danger-zone h3 {
    color: #991b1b;
    font-size: 1rem;
    font-weight: 700;
}

.danger-zone p {
    color: #b91c1c;
    font-size: 0.8125rem;
}

.hidden-element {
    display: none !important;
}

.toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toggle-checkbox {
    width: 1.15rem;
    height: 1.15rem;
    accent-color: var(--primary);
    cursor: pointer;
}

.flex {
    display: flex;
}

.flex-col {
    display: flex;
    flex-direction: column;
}

.flex-wrap {
    flex-wrap: wrap;
}

.justify-between {
    justify-content: space-between;
}

.justify-end {
    justify-content: flex-end;
}

.items-center {
    align-items: center;
}

.flex-1 {
    flex: 1;
}

.w-full {
    width: 100%;
}

.w-auto {
    width: auto;
}

.text-right {
    text-align: right;
}

.gap-1 {
    gap: 0.25rem;
}

.gap-2 {
    gap: 0.5rem;
}

.gap-3 {
    gap: 0.75rem;
}

.gap-4 {
    gap: 1rem;
}

.mt-1 {
    margin-top: 0.25rem;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mb-1 {
    margin-bottom: 0.25rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.mb-8 {
    margin-bottom: 2rem;
}

.border-b {
    border-bottom: 1px solid var(--border);
}

.text-primary {
    color: var(--primary);
}

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

.text-sm {
    font-size: 0.8125rem;
}

.text-xs {
    font-size: 0.75rem;
}

.text-lg {
    font-size: 1.1rem;
}

.text-2xl {
    font-size: 1.5rem;
}

.font-bold {
    font-weight: 700;
}

.font-semibold {
    font-weight: 600;
}

.font-mono {
    font-family: ui-monospace, 'Cascadia Code', 'Fira Code', monospace;
}

.label-uppercase {
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.view-select-wrapper {
    margin-bottom: 0.5rem;
}

.sidebar-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: var(--text-main);
}

.divider {
    border: 0;
    border-top: 1px solid var(--border);
}

.detail-section-title {
    display: block;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.unsaved-banner {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background-color: #fffbeb;
    border: 1px solid #fef3c7;
    border-radius: 0;
    padding: 0.625rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    z-index: 100;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #b45309;
}

.btn:focus-visible,
.btn-link:focus-visible,
.view-tab:focus-visible,
.search-clear-btn:focus-visible,
a:focus-visible,
input[type="checkbox"]:focus-visible,
.slider-input:focus-visible {
    outline: 3px solid var(--focus-yellow);
    outline-offset: 2px;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
    filter: grayscale(50%);
}

/* Footer */
.global-footer {
    padding: 1.5rem;
    text-align: center;
    font-size: 0.8125rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    background-color: var(--bg-card);
    z-index: 10;
    position: relative;
}

/* Footer variant for public pages (login, logged-out about/privacy):
   same links and spacing, but no background or divider line. */
.global-footer--public {
    background-color: transparent;
    border-top: none;
}
/* Utility Classes */
.cursor-pointer { cursor: pointer; }
.text-decoration-none { text-decoration: none !important; }
.select-none { user-select: none; }
.block { display: block; }

.mb-2 { margin-bottom: 0.5rem; }

/* Semantic Classes (replaces utilities) */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 1rem;
    margin-top: 0.5rem;
}

.section-divider {
    border-top: 1px solid var(--border);
    padding-top: 1.5rem;
    margin-top: 1.5rem;
}

.dashboard-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    border-top: 1px solid var(--border);
    padding-top: 1.5rem;
}

.inline-field-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.study-list-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.profile-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.profile-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0;
}

/* Flex wrapping container for badge lists inside profile cards */
.profile-badge-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

/* Hairline separators between the card's sections for readability */
.profile-section + .profile-section {
    border-top: 1px solid var(--border);
    padding-top: 0.875rem;
}

/* Department badge: contains a .color-dot followed by the dept name.
   The color-dot sits inline before the text, outside any nested wrapper. */
.profile-dept-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.action-btn-group {
    display: flex;
    gap: 0.25rem;
}

.profile-id-group {
    display: flex;
    flex-direction: column;
    margin-top: 0.25rem;
}

.profile-id-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.active-filters-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.active-filters-title {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.filter-search-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    width: 100%;
}

.slider-control-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.slider-input {
    flex: 1;
    cursor: pointer;
}

.slider-badge {
    font-size: 0.8125rem;
}

.slider-help-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.placeholder-card { padding: 1.5rem; border: 2px dashed var(--border); border-radius: var(--radius); margin-bottom: 0.5rem; }

/* Utility & Extracted Classes */
.pill-active {
    cursor: pointer;
    padding: 0.3rem 0.6rem;
    border-radius: 0;
}
.btn-sm {
    padding: 0.2rem 0.5rem;
    font-size: 0.7rem;
}
.btn-linkedin {
    color: #0a66c2;
    border-color: #0a66c2;
}
.m-0 { margin: 0; }
.block-mb-sm {
    display: block;
    margin-bottom: 2px;
}
.text-italic-sm {
    font-style: italic;
    font-size: 0.75rem;
}

/* Tooltip components (force-graph link hover overlays) */
.tooltip-container {
    text-align: left;
}

.tooltip-header {
    font-weight: bold;
    border-bottom: 1px solid rgba(255, 255, 255, 0.25);
    padding-bottom: 2px;
    margin-bottom: 4px;
}

/* =============================================================================
   Admin panel components
   ============================================================================= */

/* Inline delete forms inside table cells */
.inline-form {
    display: inline;
}

/* Admin panel list with fixed-height scrollable area */
.admin-list-scroll {
    max-height: 180px;
    overflow-y: auto;
}

/* Admin panel table wrapper with fixed-height scroll */
.admin-table-scroll {
    max-height: 240px;
    overflow-y: auto;
}

/* Small circular university-color indicator dot in the admin institutions list */
.dot-indicator {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Danger-coloured text link used in admin delete actions */
.btn-danger-text {
    background: none;
    border: none;
    color: #dc2626;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font);
    padding: 0;
}

.btn-danger-text:hover {
    text-decoration: underline;
    color: #b91c1c;
}

/* =============================================================================
   Cold-start warning banner
   Shown when the current user has not yet added keywords/methods.
   ============================================================================= */

.cold-start-warning {
    background-color: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
    padding: 1rem;
    border-radius: 0;
    text-align: center;
}

.cold-start-warning a {
    color: #92400e;
    text-decoration: underline;
}

/* Map page — inline cold-start warning is absolutely positioned above the viewport */
.cold-start-warning--map {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
}

/* =============================================================================
   Error pages (rendered by app.render_error via error.html)
   ============================================================================= */

.error-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    text-align: center;
    flex-direction: column;
    padding: 2rem;
    background: var(--bg-main);
}

.error-code {
    font-size: 8rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
    margin-bottom: 1rem;
}

.error-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.error-desc {
    color: var(--text-muted);
    margin-bottom: 2rem;
    max-width: 400px;
}

/* Grid page content wrapper: padded, independently scrollable */
.content-pad {
    padding: 2rem;
    overflow-y: auto;
}

/* =============================================================================
   Mobile layout (below 768px)
   The filter sidebar becomes an off-canvas drawer opened from the header;
   the map and grid keep the full viewport. Paddings tighten app-wide.
   ============================================================================= */

@media (max-width: 767px) {
    #sidebar-toggle {
        display: inline-flex;
    }

    body.app-shell .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(85vw, 340px);
        height: 100dvh;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        z-index: 30;
        border-right: 1px solid var(--border);
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
        box-shadow: 4px 0 12px rgba(17, 24, 39, 0.15);
    }

    .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(17, 24, 39, 0.4);
        z-index: 20;
    }

    /* Header: drop the user's name, compact the buttons; wrap as a
       fallback on very narrow screens instead of overflowing. */
    header {
        padding: 0.5rem 0.75rem;
        flex-wrap: wrap;
        row-gap: 0.35rem;
    }
    header h1 {
        font-size: 1rem;
    }
    .header-nav {
        gap: 0.5rem;
    }
    .header-nav span {
        display: none;
    }
    .header-nav .btn {
        padding: 0.4rem 0.55rem;
        font-size: 0.7rem;
    }

    /* Tighter page paddings */
    .content-pad {
        padding: 1rem;
    }
    .dashboard-container {
        margin: 1rem auto;
        padding: 0 1rem;
    }
    .profile-form {
        padding: 1.25rem;
    }
    .danger-zone {
        padding: 1rem;
    }
    .admin-container {
        margin: 1rem auto;
        padding: 0 1rem;
    }
    .login-card {
        padding: 1.5rem;
    }
    .profiles-grid {
        gap: 0.75rem;
    }

    /* The floating cold-start banner must not overflow the narrow viewport */
    .cold-start-warning--map {
        white-space: normal;
        width: max-content;
        max-width: calc(100vw - 2rem);
    }
}
