/* ==== Group Finder — Redesign 2026 ==== */

:root {
    --kai-blue: #0057B8;
    --kai-blue-dark: #003D82;
    --kai-blue-light: #E8F1FC;
    --kai-red: #c90613;
    --kai-red-hover: #C10510;
    --bg: #F5F7FA;
    --surface: #fff;
    --text: #0F172A;
    --text-secondary: #475569;
    --text-muted: #94A3B8;
    --border: #E2E8F0;
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 4px 12px rgba(15, 23, 42, 0.04);
    --radius: 14px;
    --radius-sm: 10px;
    --header-h: 60px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    color: var(--text);
    background: var(--bg);
}

a {color: var(--kai-blue); text-decoration: none; transition: color, 0.15s ease;}
a:hover {color: var(--kai-blue-dark);}
img, svg {max-width: 100%; height: auto; display: block;}

/* Header */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    height: var(--header-h);
    display: flex;
    align-items: center;
    padding: 0 12px;
}

.header-inner {
    max-width: 960px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
    font-size: 16px;
    font-weight: 500;
    flex-shrink: 0;
}


.logo-icon {
    position: relative;
    width: 36px;
    height: 36px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--kai-blue);
    font-weight: 650;
    flex-shrink: 0
}

.logo-icon-image {
    position: absolute;
    z-index: 1;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.logo-icon-image.is-loaded {
    opacity: 1;
}

.logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.logo-title {
    font-weight: 700;   
    font-size: 16px;
    letter-spacing: -0.3px;
}

.logo-sub {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

.nav {
    display: flex;
    align-items: center;
    gap: 2px;
}

.nav-toggle {display: none;}

.nav a {
    display: inline-block; /* Важно для работы трансформаций (scale) */
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 13px; /* Ваш базовый цвет ссылок */
    padding: 8px 16px; /* Примерные отступы, подставьте свои */
    border-radius: 8px; /* Скругляем углы фона для эстетики */
    text-decoration: none;
    white-space: nowrap;
    transition: 
        color 0.7s cubic-bezier(0.25, 0.8, 0.25, 1),
        background-color 0.7s cubic-bezier(0.25, 0.8, 0.25, 1),
        transform 0.7s cubic-bezier(0.175, 0.885, 0.32, 1.275)
}

.nav a:hover {
    background: var(--kai-blue-light);
    color: var(--kai-blue);
    transform: translateY(-1px)
}

.nav a.active {
    color: var(--kai-red);
    background: rgba(227, 6, 19, 0.07);
    font-weight: 600;
    transform: scale(1.02)
} 


.header-action {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.btn-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0; 
    color: var(--kai-blue);
    font: inherit;
}

.btn-icon:hover {
    border-color: var(--kai-blue);
    color: var(--kai-blue);
    background: var(--kai-blue-light);
}

.btn-icon svg {
    width: 18px;
    height: 18px;
}

/* Main */
.main {
    flex: 1;
    max-width: 640px;
    width: 100%;
    margin: 0 auto;
    padding: 20px 16px 48px;
}

/* Banner */
.banner-old {
    background: linear-gradient(135deg, #ECFDF5 0%, #D1FAE5 100%);
    border: 1px solid #A7F3D0;
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-top: 8px;
    margin-bottom: 0;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.banner-old-icon {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 10px;
    background: #a0f1d6;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 14px;
    line-height: 1;
}

.banner-old-content {
    flex: 1;
    min-width: 0;
}

.banner-old-title {
    font-weight: 600;
    font-size: 14px;
    color: #065F46;
    margin-bottom: 2px;
}

.banner-old-text {
    font-weight: 400;
    font-size: 13px;
    color: #047857;
    line-height: 1.45;
}

.banner-old a {
    color: #047857;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.banner-old a:hover {
    color: #089381;
}

/* Page header */
.page-header {
    margin-bottom: 20px;
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text);
    margin-bottom: 6px;
    line-height: 1.25;
}

.page-desc {
    font-size: 15px;
    font-weight: 450;
    color: var(--text-secondary);
    line-height: 1.45
}

/* Cards & Results */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: visible;
    margin-bottom: 16px;
    
}

#results {
    margin-top: 8px;
}

#results, .card-header {
    padding: 16px 18px 0;
}

#results, .card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

#results, .card-subtitle {
    font-size: 13px;
    color: var(--text-muted);
}

.results-list {
    max-height: 520px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.result-item {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    transition: background 0.12s ease;
}

.result-item:last-child {
    border-bottom: none;
}

.result-item:hover {
    background: #f8fafc;
}

.result-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
    line-height: 1.35;
}

.result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.result-meta span {
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 3px 10px;
    line-height: 1.3;
}

.result-meta .student-group-meta {
    color: var(--kai-blue);
    background: var(--kai-blue-light);
    border-color: #c7dcf5;
    font-weight: 600;
    white-space: nowrap;
}

.results-header {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 12px;
}

.results-close {
    width: 200px;
    height: 50px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: #94A3B8;
    line-height: 1;
    cursor: pointer;
    margin-block: 12px;
}

.results-close .close {
    font-size: 20px;
}

.results-close .close-text {
    font-size: 14px;
}

.results-close:hover {
    background: #fef2f2;
    border-color: #fecaca;
    color: #dc2626;
}

#results[hidden] {
    display: none !important;
}

.badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    color: #b45309;
    background: #fef3c7;
    border: 1px solid #fde68a;
    padding: 2px 8px;
    border-radius: 999px;
    margin-left: 6px;
    vertical-align: middle;
}

@media (max-width: 480px) {
    .result-item {
        padding: 12px 14px;
    }

    .result-name {
        font-size: 14px;
    }

    .result-meta span {
        font-size: 11px;
        padding: 3px 8px;
    }
}

/* Search + dropdown */
.search-wrap {
    padding: 14px 18px 16px;
    position: relative;
    z-index: 20;
}

.search-input {
    width: 100%;
    height: 48px;
    padding: 0 44px 0 44px;
    border: 1.5px solid var(--border);
    border-radius: 12px; ;
    font-size: 15px;
    font-family: inherit;
    color: var(--text);
    background: var(--bg);
    transition: all 0.15s ease;
    appearance: none;
    -webkit-appearance: none;
    outline: none;
}

.search-input::-webkit-search-cancel-button,
.search-input::-webkit-search-decoration {
    display: none;
    -webkit-appearance: none;
}

.search-input::placeholder {
    color: var(--text-muted);
}
.search-input:focus {
    border-color: var(--kai-blue);
    background: var(--surface);
    box-shadow: 0 0 0 3px rgba(0, 87, 184, 0.12);
}

.search-icon {
    position: absolute;
    left: 32px;
    top: 38px;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    width: 20px;
    height: 20px;
    z-index: 2;
}

.search-clear {
    position: absolute;
    right: 28px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--kai-blue);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.search-input:not(:placeholder-shown) ~ .search-clear {
    display: flex;
}

.suggestions {
    position: absolute;
    left: 18px;
    right: 18px;
    top: calc(100% - 4px);
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12), 0 2px 8px rgba(15, 23, 42, 0.06);
    max-height: 280px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    z-index: 50;
    display: none;
}

.suggestions:not([hidden]),
.suggestions.is-open {
    display: block;
}

.suggestion-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.12s ease;
    border-bottom: 1px solid var(--border);
}

.suggestion-item:last-child {border-bottom: none; border-radius: 0 0 11px 11px;}
.suggestion-item:first-child {border-radius: 11px 11px 0 0;}
.suggestion-item:only-child {border-radius: 11px;}
.suggestion-item:hover,
.suggestion-item.active,
.suggestion-item[aria-selected="true"] {
    background: var(--kai-blue-light);
}

.suggestion-num {
    font-weight: 700;
    font-size: 16px;
    color: var(--kai-blue);
    min-width: 48px;
    letter-spacing: -0.3px;
    flex-shrink: 0;
}

.suggestion-info {
    flex: 1;
    min-width: 0;
}

.suggestion-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.suggestion-meta {font-size: 12px; color: var(--text-muted); margin-top: 1px;}
.suggestion-empty {padding: 20px 16px; text-align: center; font-size: 14px; color: var(--text-muted);}

/* Filters */
.filters {
    padding: 0 18px 16px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    align-items: start;
}

.filter-control {position: relative; min-width: 0;}
.filter-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.filter-trigger {
    display: flex;
    width: 100%;
    height: 38px;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 0 12px 0 14px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.filter-trigger:hover {border-color: #b8d3f1;}
.filter-trigger:focus-visible {
    outline: none;
    border-color: var(--kai-blue);
    box-shadow: 0 0 0 3px rgba(0, 87, 184, 0.1);
}
.filter-trigger-value {overflow: hidden; text-overflow: ellipsis; white-space: nowrap;}
.filter-trigger svg {width: 16px; height: 16px; flex: 0 0 16px; color: var(--text-muted); transition: transform 0.15s ease;}
.filter-control.is-open .filter-trigger {border-color: var(--kai-blue); box-shadow: 0 0 0 3px rgba(0, 87, 184, 0.1);}
.filter-control.is-open .filter-trigger svg {transform: rotate(180deg);}
.filter-control.has-selection .filter-trigger {border-color: #b8d3f1; color: var(--kai-blue-dark);}
.filter-menu {
    position: absolute;
    z-index: 30;
    top: calc(100% + 6px);
    left: 0;
    min-width: 100%;
    width: max-content;
    max-width: min(320px, calc(100vw - 40px));
    padding: 6px;
    border: 1px solid #c7dcf5;
    border-radius: 12px;
    background: var(--surface);
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.14);
}
.filter-option {display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 8px 10px; border-radius: 8px; color: var(--text-secondary); font-size: 14px; line-height: 1.35; cursor: pointer;}
.filter-option:hover, .filter-option.is-checked {background: var(--kai-blue-light); color: var(--text);}
.filter-option-input {appearance: none; -webkit-appearance: none; width: 17px; height: 17px; margin: 0; border: 1.5px solid #b8c6d8; border-radius: 5px; background: #fff; cursor: pointer; flex: 0 0 17px;}
.filter-option-input:checked {border-color: var(--kai-blue); background: var(--kai-blue); box-shadow: inset 0 0 0 3px #fff;}
.filter-option-input:focus-visible {outline: 3px solid rgba(0, 87, 184, 0.18); outline-offset: 2px;}
.filter-reset {width: 100%; margin-top: 4px; padding: 8px 10px; border: 0; border-top: 1px solid var(--border); background: transparent; color: var(--kai-blue); font: inherit; font-size: 13px; font-weight: 600; text-align: left; cursor: pointer;}
.filter-reset:hover {color: var(--kai-blue-dark);}

/* ==== Reports: date filters & sort ==== */
.filters-block {
    padding: 14px 18px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.date-row {
    display: flex;
    align-items: center;
    flex: 1 1 0;
    gap: 8px;
    min-width: 0;
}

.date-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.date-input {
    height: 38px;
    padding: 0 12px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    transition: border-color 0.15s ease;
    min-width: 0;
    width: 100%;
    flex: 1;
}

.date-input:focus {
    outline: none;
    border-color: var(--kai-blue);
    box-shadow: 0 0 0 3px rgba(0, 87, 184, 0.1);
}

@media (max-width: 480px) {
    .filters-block {
        gap: 8px;
    }
    .date-row {
        gap: 5px;
    }
    .date-input {
        padding: 0 7px;
        font-size: 13px;
    }
    .filters-block, .filter-control {
        width: 100%;
        max-width: none;
    }
}

/* Buttons */
.action-row {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 42px;
    padding: 0 18px;
    border-radius: 11px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s ease;
    border: none;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--kai-blue);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 87, 184, 0.25);
}

.btn-primary:hover {
    background: var(--kai-blue-dark);
    color: white;
}

.btn-outline {
    background: var(--surface);
    color: var(--text-secondary);
    border: 1.5px solid var(--border);
}

.btn-outline:hover {
    border-color: var(--kai-blue);
    color: var(--kai-blue);
    background: var(--kai-blue-light);
}

.btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Stats */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--kai-blue);
    letter-spacing: -0.5px;
    line-height: 1.2;
}

.stat-label {font-size: 12px; color: var(--text-muted); margin-top: 4px;}

/* Placeholder */
.placeholder {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.placeholder svg {
    width: 48px;
    height: 48px;
    margin: 0 auto 12px;
    opacity: 0.4;
}

.placeholder p {
    font-size: 14px; 
    line-height: 1.5;
}

/* Footer */
.footer {
    margin-top: auto;
    padding: 24px 16px 32px;
    background: var(--surface);
    border-top: 1px solid var(--border);
}

.footer-inner {max-width: 640px; margin: 0 auto; text-align: center;}
.footer-disclaimer {
    margin: 0 auto 14px;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text-muted);
    font-size: 12px;
    font-style: italic;
    line-height: 1.5;
}

.footer-meta {font-size: 12px; color: var(--text-muted); line-height: 1.6;}
.footer-meta a {color: var(--text-muted); text-decoration: underline; text-underline-offset: 2px;}
.footer-meta a:hover {color: var(--kai-blue);}

/* PWA install dialog */
.install-modal[hidden] {
    display: none;
}

.install-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 20px;
}

.install-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.58);
    backdrop-filter: blur(3px);
}

.install-modal-dialog {
    position: relative;
    width: min(100%, 440px);
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.24);
    padding: 24px;
}

.install-modal-dialog h2 {
    margin: 0 36px 10px 0;
    font-size: 21px;
    line-height: 1.25;
}

.install-modal-dialog p {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.55;
}

.install-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: var(--bg);
    color: var(--kai-blue);
    cursor: pointer;
    font: 700 20px/1 var(--font);
}

.install-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.install-modal-actions .btn {
    min-width: 120px;
}

/* Page Not Found */

.error-page {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
        padding: 40px 20px 60px;
        max-width: 480px;
        margin: 0 auto;
}
        
.error-code {
    font-size: 72px;
    font-weight: 700;
    color: var(--kai-blue);
    letter-spacing: -2px;
    line-height: 1;
    margin-bottom: 12px;
}

.error-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 10px;
}

.error-text {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 28px;
}

.error-action {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

/* Responsive */
@media (max-width: 360px) {
    .nav a {padding: 6px 8px; font-size: 12px;}
    .page-title {font-size: 20px;}
    .main {padding: 16px 12px 40px;}
    .filter-trigger {font-size: 13px;}
    .filters-block {gap: 6px;}
    .date-row {gap: 4px;}
    .date-input {padding: 0 4px; font-size: 12px;}
    .btn {flex: 1; min-width: 0;}
} 

@media (max-width: 30rem) {
    .header {padding: 0 10px;}
    .header-inner {gap: 0;}
    .nav a {padding: 7px 8px; font-size: 13px;}
    .has-mobile-nav .header-inner.is-compact {position: relative; justify-content: flex-start;}
    .header-inner.is-compact .nav-toggle {
        display: flex;
        min-width: 96px;
        height: 40px;
        margin-left: auto;
        padding: 0 10px;
        align-items: center;
        gap: 6px;
        justify-content: center;
        border: 1px solid var(--border);
        border-radius: 10px;
        background: var(--surface);
        color: var(--kai-blue);
        cursor: pointer;
        font: inherit;
        font-size: 14px;
        font-weight: 600;
    }
    .nav-toggle:hover {background: var(--kai-blue-light); border-color: var(--kai-blue);}
    .nav-toggle:focus-visible {outline: 3px solid rgba(0, 87, 184, 0.2); outline-offset: 2px;}
    .nav-toggle svg {width: 18px; height: 18px; flex: 0 0 auto;}
    .nav-toggle[aria-expanded="true"] svg {transform: rotate(180deg);}
    .has-mobile-nav .header-inner.is-compact .nav {
        position: absolute;
        top: calc(100% - 2px);
        right: 0;
        display: none;
        min-width: 168px;
        padding: 6px;
        border: 1px solid var(--border);
        border-radius: 12px;
        background: var(--surface);
        box-shadow: 0 10px 24px rgba(15, 23, 42, 0.14);
    }
    .has-mobile-nav .header-inner.is-compact .nav.is-open {display: grid; gap: 2px;}
    .has-mobile-nav .header-inner.is-compact .nav a {padding: 10px 12px; font-size: 14px;}
    .page-title {font-size: 22px;}
    .main {padding: 16px 12px 40px;}
    .banner-old {padding: 12px 14px;}
    .card-header {padding: 14px 14px 0;}
    .search-wrap {padding: 12px 14px 14px;}
    .search-icon {left: 28px; top: 36px;}
    .search-clear {right: 22px; top: 50%;}
    .suggestions {left: 14px; right: 14px; top: calc(100% - 4px);}
    .filters {grid-template-columns: 1fr; padding: 0 14px 14px;}
    .suggestion-item {padding: 11px 14px;}
    .action-row {flex-direction: column;}
    .action-row .btn {width: 100%;}
    .install-modal {
        align-items: end;
        padding: 12px;
    }

    .install-modal-dialog {
        width: 100%;
        padding: 22px 18px 18px;
        border-radius: 18px;
    }

    .install-modal-actions .btn {
        width: 100%;
    }
}

/* Quick actions move below the header before they can crowd navigation. */
@media (max-width: 34rem) {
    .header-action {
        position: fixed;
        right: max(14px, env(safe-area-inset-right));
        bottom: max(14px, env(safe-area-inset-bottom));
        z-index: 250;
        flex-direction: column;
        gap: 10px;
    }

    .header-action .btn-icon {
        width: 48px;
        height: 48px;
        border-color: rgba(0, 87, 184, 0.18);
        box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
    }

    .header-action .btn-icon svg {
        width: 22px;
        height: 22px;
    }

    .main {padding-bottom: 72px;}
    .footer {padding-bottom: 96px;}
}

@media (min-width: 640px) {
    .header {padding: 0 20px;}
    .main {padding: 28px 20px 56px;}
    .page-title {font-size: 26px;}
    .logo-title {font-size: 16px;}
    .nav a { padding: 8px 12px; font-size: 14px;}
}

@media (min-width: 768px) {
    .header-inner {gap: 16px;}
    .btn-icon {width: 40px; height: 40px;}
    .btn-icon svg {width: 20px; height: 20px;}
}

@media (min-width: 1024px) {
    .main {max-width: 680px;}
}

@supports (padding: max(0px)) {
    .header {
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }
    .main {
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }
    .footer {padding-bottom: max(32px, env(safe-area-inset-bottom));}
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}

/* decoration */

.action-hint {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 42px;
    padding: 0 14px;
    border-radius: 11px;
    background: #f8fafc;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
}

.action-hint-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #226bc5;
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.15);
    flex-shrink: 0;
}

/* Functional search panels */
.search-panel {
    position: relative;
    overflow: visible;
    padding: 22px;
    background: linear-gradient(135deg, #fff 0%, #f0f7ff 100%);
    border-color: #d6e8fc;
    box-shadow: 0 4px 16px rgba(0, 87, 184, 0.08);
}

/* .search-panel::before {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    border-radius: var(--radius) 0 0 var(--radius);
    background: linear-gradient(180deg, var(--kai-blue), #3b82f6);
} */

.search-panel-heading {
    display: flex;
    align-items: flex-start;
    margin-bottom: 4px;
}

.search-panel-copy {min-width: 0; flex: 1;}
.feature-title {font-size: 19px; line-height: 1.3; color: var(--text); letter-spacing: -0.3px;}
.feature-text {margin-top: 5px; font-size: 14px; line-height: 1.5; color: var(--text-secondary);}
.search-panel .search-wrap {padding: 16px 0;}
.search-panel .search-icon {left: 14px; top: 40px;}
.search-panel .search-clear {right: 10px;}
.search-panel .suggestions {left: 0; right: 0; top: calc(100% - 4px);}
.search-panel .filters {padding: 0 0 16px;}
.search-panel .filters-block {padding: 4px 0 16px;}

.title-with-help {position: relative; display: flex; align-items: center; gap: 8px; width: fit-content; max-width: 100%;}

.panel-actions {display: flex; align-items: center; flex-wrap: wrap; gap: 10px;}
.form-error {margin-top: 10px; color: #b91c1c; font-size: 13px;}
.form-error[hidden] {display: none;}

/* Information blocks */
.info-card {
    margin-bottom: 16px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}
.info-card h3 {display: flex; align-items: center; gap: 8px; margin-bottom: 10px; color: var(--text); font-size: 15px; font-weight: 600;}
.info-card h3::before {content: ''; width: 4px; height: 16px; border-radius: 2px; background: var(--kai-blue);}
.info-card p, .info-card li {color: var(--text-secondary); font-size: 14px; line-height: 1.55;}
.info-card ul {margin-top: 8px; list-style: none;}
.info-card li {position: relative; margin-bottom: 6px; padding-left: 18px;}
.info-card li::before {content: '•'; position: absolute; left: 4px; color: var(--kai-blue); font-weight: 700;}
.info-card .disclaimer {margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); color: var(--text-muted); font-size: 12px; font-style: italic;}

/* Page introductions: context first, working surface immediately after */
.intro-card {
    position: relative;
    overflow: hidden;
    padding: 22px;
    border-color: #cfe2f8;
    background: linear-gradient(145deg, #ffffff 0%, #f2f8ff 100%);
    box-shadow: 0 6px 20px rgba(0, 87, 184, 0.08);
}
.intro-kicker {
    position: relative;
    z-index: 1;
    margin-bottom: 8px;
    color: var(--kai-blue);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.intro-card h1 {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    position: relative;
    z-index: 1;
    max-width: 540px;
    margin-bottom: 10px;
    color: var(--text);
    font-size: 24px;
    font-weight: 750;
    line-height: 1.25;
    letter-spacing: -0.55px;
}
.intro-title-icon {
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    margin-top: 2px;
    color: var(--kai-blue);
}
.intro-card h1 > span {min-width: 0;}
.info-card .intro-lead {
    position: relative;
    z-index: 1;
    color: #334155;
    font-size: 15px;
    line-height: 1.6;
}
.info-card .intro-features {margin-top: 14px;}
.info-card .intro-features li {margin-bottom: 7px; color: #334155;}

/* API-backed statistics */
.stat-skeleton {
    width: 78%;
    min-height: 27px;
    margin: 0 auto;
    border-radius: 6px;
    color: transparent;
    background: linear-gradient(90deg, #e7edf4 25%, #f5f8fb 50%, #e7edf4 75%);
    background-size: 200% 100%;
    animation: stat-shimmer 1.25s linear infinite;
}
.stat-unavailable {color: var(--text-muted); font-size: 18px;}
@keyframes stat-shimmer {to {background-position: -200% 0;}}

/* Separate results page */
.results-page {max-width: 760px;}
.back-link {display: inline-flex; margin-bottom: 16px; color: var(--kai-blue); font-size: 14px; font-weight: 600;}
.query-summary {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
    padding: 14px 16px;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius);
    background: #e9edf2;
}
.query-summary-title {margin: 0; color: var(--text); font-size: 15px; font-weight: 600; line-height: 1.45;}
.query-summary-value {overflow-wrap: anywhere; color: var(--text); font-weight: 700;}
.query-filters {display: flex; flex-wrap: wrap; gap: 6px;}
.query-filters:empty {display: none;}
.query-chip {padding: 4px 9px; border: 1px solid #cbd5e1; border-radius: 999px; background: var(--surface); color: var(--text-secondary); font-size: 12px;}
.btn-secondary {border: 1.5px solid #b8d3f1; background: #fff; color: var(--kai-blue);}
.btn-secondary:hover {border-color: var(--kai-blue); background: var(--kai-blue-light);}
.results-heading {display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin: 12px 0 10px;}
.results-title {margin-bottom: 4px;}
.results-count {color: var(--text-muted); font-size: 13px;}
.results-surface {overflow: hidden; margin-top: 0 !important; padding: 0 !important; font-size: inherit !important; font-weight: inherit !important;}
.results-surface[aria-busy="true"] {padding: 16px !important;}
.results-loading {display: grid; gap: 12px;}
.result-skeleton {height: 70px; border-radius: 10px; background: linear-gradient(90deg, #edf2f7 25%, #f8fafc 50%, #edf2f7 75%); background-size: 200% 100%; animation: stat-shimmer 1.25s linear infinite;}
.results-message {padding: 36px 20px; text-align: center; color: var(--text-secondary); font-size: 14px; line-height: 1.5;}
.results-message.is-error {color: #b91c1c;}
.result-list {max-height: none;}
.result-main {display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 7px; color: var(--text); font-size: 15px;}
.result-index {min-width: 22px; color: var(--text-muted); font-size: 13px; font-variant-numeric: tabular-nums; font-weight: 600;}
.result-badge {padding: 2px 8px; border: 1px solid #fde68a; border-radius: 999px; background: #fef3c7; color: #b45309; font-size: 11px; font-weight: 600;}
.results-pagination {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-top: 1px solid var(--border);
    background: #f8fafc;
}
.pagination-button {
    min-height: 38px;
    padding: 0 14px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: var(--surface);
    color: var(--kai-blue);
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}
.pagination-button:first-child {justify-self: start;}
.pagination-button:last-child {justify-self: end;}
.pagination-button:hover:not(:disabled) {border-color: var(--kai-blue); background: var(--kai-blue-light);}
.pagination-button:focus-visible {outline: 3px solid rgba(30, 111, 214, 0.2); outline-offset: 2px;}
.pagination-button:disabled {opacity: 0.45; cursor: not-allowed;}
.pagination-status {color: var(--text-secondary); font-size: 12px; font-weight: 600; white-space: nowrap;}

/* Reports: separate result list and detail view */
.report-result-link {
    display: block;
    color: inherit;
    text-decoration: none;
}
.report-result-link:hover {background: #f8fafc;}
.report-open-hint {margin-left: auto; color: var(--kai-blue); font-size: 12px; font-weight: 600; text-align: right;}
.report-detail-surface {overflow: hidden; padding: 20px;}
.report-detail-head {margin-bottom: 20px;}
.report-detail-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 14px;
}
.report-stat {
    display: grid;
    gap: 3px;
    padding: 12px 8px;
    border: 1px solid #d6e8fc;
    border-radius: 10px;
    background: #f5f9ff;
    text-align: center;
}
.report-stat b {color: var(--kai-blue); font-size: 18px;}
.report-stat span {color: var(--text-muted); font-size: 11px;}
.report-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1px;
    overflow: hidden;
    margin-bottom: 18px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--border);
}
.report-summary div {display: grid; gap: 3px; padding: 10px 12px; background: var(--surface);}
.report-summary span {color: var(--text-muted); font-size: 11px;}
.report-summary b {color: var(--text); font-size: 13px;}
.report-section {margin-top: 16px;}
.report-section-title {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto 18px;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border: 1px solid #d5dbe3;
    border-radius: 11px;
    background: #f4f6f8;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
    color: var(--text);
    cursor: pointer;
    font-size: 16px;
    font-weight: 700;
    list-style: none;
}
.report-section-title::-webkit-details-marker {display: none;}
.report-section-title::after {
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--text-secondary);
    border-bottom: 2px solid var(--text-secondary);
    content: '';
    justify-self: center;
    transform: rotate(45deg) translate(-2px, -2px);
    transition: transform 0.18s ease;
}
.report-section-title:hover {border-color: #c2cad4; background: #eef1f4;}
.report-section-title:focus-visible {outline: 3px solid rgba(71, 85, 105, 0.2); outline-offset: 2px;}
.report-section[open] > .report-section-title {border-color: #cbd2dc; background: #e7ebf0;}
.report-section[open] > .report-section-title::after {transform: rotate(225deg) translate(-1px, -1px);}
.report-section-name {min-width: 0;}
.report-section-count {padding: 3px 9px; border-radius: 999px; background: #64748b; color: #fff; font-size: 12px; font-weight: 700;}
.report-list {overflow: hidden; border: 1px solid var(--border); border-radius: 10px; list-style: none;}
.report-section[open] > .report-list {margin-top: 8px;}
.report-list li {display: grid; gap: 3px; padding: 11px 12px; border-bottom: 1px solid var(--border); background: #fff; color: var(--text-secondary); font-size: 13px; line-height: 1.45;}
.report-list li:nth-child(even) {background: #f8fafc;}
.report-list li:last-child {border-bottom: 0;}
.report-entry-title {color: var(--text); font-size: 13px;}
.report-entry-meta {color: var(--text-muted); font-size: 12px;}

@media (max-width: 480px) {
    .search-panel {padding: 18px 16px;}
    .intro-card {padding: 18px 16px;}
    .intro-card h1 {font-size: 21px;}
    .intro-title-icon {width: 22px; height: 22px;}
    .info-card .intro-lead {font-size: 14px;}
    .feature-title {font-size: 17px;}
    .panel-actions, .panel-actions .btn {width: 100%;}
    .query-summary .btn {width: 100%;}
    .results-heading {flex-direction: column;}
    .results-pagination {grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 12px 14px;}
    .pagination-status {grid-column: 1 / -1; grid-row: 1; text-align: center;}
    .pagination-button:first-child {grid-column: 1; grid-row: 2; justify-self: stretch;}
    .pagination-button:last-child {grid-column: 2; grid-row: 2; justify-self: stretch;}
    .report-detail-surface {padding: 16px;}
    .report-detail-stats {grid-template-columns: repeat(2, minmax(0, 1fr));}
    .report-section-title {padding: 13px 14px; font-size: 15px;}
}

@media (max-width: 480px) {
    .actions-row {
        flex-direction: column;
    }

    .action-hint {
        width: 100%;
        justify-content: center;
    }
}
