:root {
    --bg: #f8f8f8;
    --paper: #ffffff;
    --ink: #333333;
    --accent: #2c3e50;
    --accent-soft: #e8f0fe;
    --line: #e0e0e0;
    --header-bg: #1f2933;
    --header-text: #f4f7fb;
    --muted-text: #5b6672;
    --control-bg: #ffffff;
    --control-bg-hover: #e8edf3;
    --control-border: #b9c4d0;
    --control-text: #243444;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Roboto, sans-serif;
    color: var(--ink);
    background-color: var(--bg);
}

.site-header {
    background: var(--header-bg);
    color: var(--header-text);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    height: 54px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand {
    text-decoration: none;
    font-size: 1.1rem;
    color: var(--header-text);
}

.site-header nav {
    display: flex;
    align-items: center;
    gap: 0;
}

.site-header nav a {
    text-decoration: none;
    color: var(--header-text);
    font-size: 0.9rem;
    padding: 0 1rem;
    height: 54px;
    display: flex;
    align-items: center;
}

.site-header nav a:hover {
    color: #fff;
    background: #334150;
}

.dropdown {
    position: relative;
    cursor: pointer;
    background: #111827;
    padding: 0 1rem;
    height: 54px;
    display: flex;
    align-items: center;
    color: #fff;
}

.dropdown-menu {
    position: absolute;
    top: 54px;
    right: 0;
    background: #fff;
    border: 1px solid #d7dde4;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.18);
    min-width: 340px;
    border-radius: 0 0 6px 6px;
    padding: 0.45rem 0;
    z-index: 1000;
    overflow: hidden;
}

.dropdown-item {
    display: block;
    padding: 0.55rem 1.25rem;
    color: #1f2933;
    text-decoration: none;
    font-size: 0.9rem;
    line-height: 1.35;
}

.site-header nav a.dropdown-item {
    display: block;
    height: auto;
    padding: 0.55rem 1.25rem;
    color: #1f2933;
    white-space: normal;
}

.dropdown-item:hover {
    background: #edf3f9;
    color: #111827;
}

.site-header nav a.dropdown-item:hover {
    background: #edf3f9;
    color: #111827;
}

.dropdown-header {
    padding: 0.75rem 1.25rem 0.45rem;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--muted-text);
    border-top: 1px solid #edf0f3;
}

.dropdown-header:first-child {
    border-top: 0;
}

.layout {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.hero {
    margin-bottom: 1rem;
}

.hero h1 {
    margin: 0 0 0.8rem;
    font-size: 4.2rem;
    font-weight: 300;
    letter-spacing: -1px;
}

.lead {
    font-size: 1rem;
    color: #333;
}

.card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 2.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.hero.card {
    background: #f0f0f0;
    border: none;
    box-shadow: none;
    padding: 3rem;
}

.controls.card {
    margin-top: -1.5rem;
    border-radius: 4px;
    padding: 1.5rem;
}

.row {
    display: flex;
    gap: 0;
    margin-bottom: 0.85rem;
}

input#quick-query {
    flex-grow: 1;
    border-right: none;
    border-radius: 6px 0 0 6px;
    padding: 0.9rem 1rem;
    border: 1px solid #cfd6df;
    background: #fff;
    color: #263238;
    font-size: 1rem;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
}

input#quick-query:focus {
    border-color: #7aa7d9;
    outline: 0;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04), 0 0 0 3px rgba(51, 122, 183, 0.14);
}

button#search-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 3.4rem;
    background: #f4f7fb;
    color: #1f3b57;
    border: 1px solid #cfd6df;
    border-radius: 0 6px 6px 0;
    padding: 0 1rem;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

button#search-btn:hover:not(:disabled) {
    background: #e8f0f8;
    border-color: #b7c6d8;
    color: #15324f;
}

button#search-btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.row-advanced {
    display: flex;
    justify-content: flex-end;
}

.advanced-toggle {
    appearance: none;
    border: 1px solid transparent;
    background: transparent;
    color: #337ab7;
    cursor: pointer;
    border-radius: 999px;
    padding: 0.45rem 0.55rem 0.45rem 0.65rem;
    font: inherit;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.advanced-toggle:hover,
.advanced-toggle:focus {
    background: #eef6ff;
    color: #235f9d;
    outline: 0;
}

.advanced-toggle.is-active {
    background: #e8f2fc;
    border-color: #b7d3ef;
    color: #1f5f9f;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.toggle-switch {
    position: relative;
    width: 2rem;
    height: 1.1rem;
    border-radius: 999px;
    background: #d5dde7;
    transition: background 0.2s ease;
}

.toggle-switch::after {
    content: "";
    position: absolute;
    top: 0.18rem;
    left: 0.2rem;
    width: 0.74rem;
    height: 0.74rem;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.22);
    transition: transform 0.2s ease;
}

.advanced-toggle.is-active .toggle-switch {
    background: #337ab7;
}

.advanced-toggle.is-active .toggle-switch::after {
    transform: translateX(0.85rem);
}

.advanced-filters {
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid #dce5ee;
    border-radius: 8px;
    background: #fbfdff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.advanced-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.65rem;
    border-bottom: 1px solid #e3ebf3;
    color: #4c5d6e;
    font-size: 0.9rem;
    font-weight: 600;
}

.btn-sm {
    padding: 0.2rem 0.5rem;
    font-size: 0.8rem;
}

.btn-share {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.result-head h2 {
    font-size: 1.5rem;
    font-weight: 400;
}

.site-footer {
    margin-top: 4rem;
    padding: 2rem 0;
    color: var(--muted-text);
    background: transparent;
    border-top: 1px solid #eee;
}

.footer-inner {
    text-align: center;
}

.footer-inner small {
    display: block;
    line-height: 1.6;
}

.summary {
    font-size: 0.9rem;
    color: var(--muted-text);
}

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

.table-wrap {
    overflow: auto;
    margin-top: 1rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

th, td {
    text-align: left;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #eee;
}

th {
    background: #fbfbfb;
    font-weight: 600;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.card-collection {
    padding: 1.5rem;
}

.card-collection h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1.4rem;
    font-weight: 400;
}

.btn-link {
    display: inline-block;
    margin-top: 1rem;
    text-decoration: none;
    color: #fff;
    background: var(--accent);
    border-radius: 4px;
    padding: 0.5rem 1rem;
}

.chip, .external-link, .detail-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.85rem;
    background: #edf1f5;
    color: #243444;
    transition: all 0.2s ease;
}

.chip:hover, .external-link:hover, .detail-link:hover {
    background: #dce5ee;
    color: #111827;
}

.chip-separator {
    display: inline-block;
    margin: 0 0.35rem 0 0.1rem;
    color: #6c757d;
}

.external-link::after {
    content: "";
    width: 0.75rem;
    height: 0.75rem;
    background-color: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6' /%3E%3Cpolyline points='15 3 21 3 21 9' /%3E%3Cline x1='10' y1='14' x2='21' y2='3' /%3E%3C/svg%3E") no-repeat center;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6' /%3E%3Cpolyline points='15 3 21 3 21 9' /%3E%3Cline x1='10' y1='14' x2='21' y2='3' /%3E%3C/svg%3E") no-repeat center;
    -webkit-mask-size: contain;
    mask-size: contain;
    opacity: 0.8;
}

.detail-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    background: #edf1f5;
    color: #243444;
    border-radius: 4px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.detail-icon:hover {
    background: var(--accent);
    color: #fff;
}

.pagination {
    margin-top: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}

.filter-row {
    display: grid;
    grid-template-columns: minmax(11rem, 1fr) minmax(9rem, 1fr) minmax(12rem, 1.25fr) auto;
    gap: 0.65rem;
    margin-bottom: 0.65rem;
}

.advanced-filters input, .advanced-filters select {
    width: 100%;
    min-height: 2.4rem;
    padding: 0.55rem 0.7rem;
    border: 1px solid #d4dde7;
    border-radius: 6px;
    background: #fff;
    color: #263238;
    font: inherit;
}

.advanced-filters input:focus,
.advanced-filters select:focus {
    border-color: #7aa7d9;
    outline: 0;
    box-shadow: 0 0 0 3px rgba(51, 122, 183, 0.13);
}

.advanced-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
    padding-top: 0.85rem;
    border-top: 1px solid #e3ebf3;
}

.advanced-actions-right {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.btn-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 2.35rem;
    white-space: nowrap;
}

button.secondary {
    background: var(--control-bg);
    border: 1px solid var(--control-border);
    color: var(--control-text);
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

button.secondary:hover:not(:disabled) {
    background: var(--control-bg-hover);
    border-color: #8da0b3;
    color: #111827;
}

button.secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-sm {
    padding: 0.2rem 0.5rem !important;
    font-size: 0.8rem !important;
}

@media (max-width: 760px) {
    .controls.card {
        padding: 1rem;
    }

    .row {
        margin-bottom: 0.75rem;
    }

    .filter-row {
        grid-template-columns: 1fr;
    }

    .advanced-actions,
    .advanced-actions-right {
        align-items: stretch;
        flex-direction: column;
    }

    .btn-action,
    .filter-row button.secondary {
        width: 100%;
    }
}

[x-cloak] { display: none !important; }
