@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=DM+Serif+Display&display=swap');

* { margin: 0; padding: 0; box-sizing: border-box; }
::selection { background: hsl(172 50% 36% / 0.2); color: hsl(220 55% 18%); }
html { scroll-behavior: smooth; }

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: hsl(40 20% 96%);
    color: hsl(220 40% 13%);
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px 20px 40px;
}

/* ── Hero ── */

.hero {
    position: relative;
    overflow: hidden;
    background-color: hsl(220 55% 18%);
    border-radius: 1.5rem;
    padding: 3rem 2rem;
    color: hsl(40 33% 97%);
    margin-bottom: 1.5rem;
}

.hero-circle-1 {
    position: absolute;
    top: 0; right: 0;
    width: 16rem; height: 16rem;
    border-radius: 50%;
    background: hsla(172 50% 36% / 0.1);
    transform: translate(33%, -50%);
}

.hero-circle-2 {
    position: absolute;
    bottom: 0; left: 0;
    width: 12rem; height: 12rem;
    border-radius: 50%;
    background: hsla(172 50% 36% / 0.05);
    transform: translate(-25%, 50%);
}

.hero-content { position: relative; z-index: 1; }

.hero-top {
    display: flex;
    align-items: center;
    gap: 2.5rem;
}

.hero-text { flex: 1; }

.hero-motto {
    flex-shrink: 0;
    text-align: right;
}

.hero-quote {
    font-size: 0.8rem;
    color: hsla(40 33% 97% / 0.6);
    line-height: 1.5;
    font-style: italic;
}

.hero-quote-bold {
    color: hsl(172 50% 36%);
    font-weight: 600;
    font-style: normal;
}

.hero-label {
    color: hsl(172 50% 36%);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    margin-bottom: 0.75rem;
}

.hero h1 {
    font-family: 'DM Serif Display', serif;
    font-size: 3rem;
    margin: 0 0 1rem;
    line-height: 1.1;
}

.hero-desc {
    color: hsla(40 33% 97% / 0.7);
    font-size: 0.9rem;
    max-width: 32rem;
    margin-bottom: 2rem;
    line-height: 1.6;
}

.hero-stats { display: flex; flex-wrap: nowrap; gap: 1rem; }

.hero-stat {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: hsla(40 33% 97% / 0.1);
    backdrop-filter: blur(8px);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
}

.hero-stat-icon { color: hsl(172 50% 36%); width: 20px; height: 20px; }
.hero-stat-value { font-size: 1.125rem; font-weight: 700; }
.hero-stat-label { font-size: 0.7rem; color: hsla(40 33% 97% / 0.6); }

/* ── Filters ── */

.filters {
    display: flex;
    gap: 10px;
    padding: 16px 0;
    margin-bottom: 8px;
    flex-wrap: wrap;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    background: hsl(40 20% 96%);
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.filters.scrolled {
    border-bottom-color: hsl(40 18% 88%);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.search-wrapper {
    position: relative;
    width: 300px;
    flex: 0 0 auto;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px; height: 16px;
    color: hsl(220 15% 60%);
    pointer-events: none;
}

.search-wrapper input[type="text"] {
    width: 100%;
    padding: 10px 14px 10px 36px;
    border: 1px solid hsl(40 18% 88%);
    border-radius: 0.75rem;
    font-size: 0.9rem;
    font-family: inherit;
    background: white;
    color: hsl(220 40% 13%);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-wrapper input[type="text"]:focus {
    outline: none;
    border-color: hsl(172 50% 36%);
    box-shadow: 0 0 0 3px hsla(172 50% 36% / 0.12);
}

.search-wrapper input[type="text"]::placeholder { color: hsl(220 15% 60%); }

.filters select {
    padding: 10px 14px;
    border: 1px solid hsl(40 18% 88%);
    border-radius: 0.75rem;
    font-size: 0.9rem;
    font-family: inherit;
    background: white;
    color: hsl(220 40% 13%);
    width: 250px;
    flex: 0 0 auto;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2394a3b8'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    padding-right: 32px;
}

.filters select:focus {
    outline: none;
    border-color: hsl(172 50% 36%);
    box-shadow: 0 0 0 3px hsla(172 50% 36% / 0.12);
}

.filters select[name="year"] { width: 150px; }
.filters button { display: none; }

.filters .reset {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 14px;
    color: hsl(220 15% 50%);
    text-decoration: none;
    font-size: 0.85rem;
    font-family: inherit;
    border-radius: 0.5rem;
    transition: color 0.15s, background 0.15s;
}

.filters .reset:hover {
    color: hsl(0 70% 50%);
    background: hsl(0 70% 97%);
}

/* ── Contract cards ── */

.grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.contract-card {
    background: #fff;
    border: 1px solid hsl(40 18% 88%);
    border-radius: 1rem;
    padding: 1.25rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.contract-card:hover {
    border-color: hsla(172 50% 36% / 0.4);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08);
}

.contract-card.card-expanded {
    border-color: hsl(172 50% 36%);
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.1);
}

.card-icon {
    flex-shrink: 0;
    width: 2.5rem; height: 2.5rem;
    border-radius: 0.75rem;
    background: hsl(40 20% 94%);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.contract-card:hover .card-icon { background: hsla(172 50% 36% / 0.1); }

.card-icon svg {
    width: 16px; height: 16px;
    color: hsl(220 15% 50%);
    transition: color 0.3s;
}

.contract-card:hover .card-icon svg { color: hsl(172 50% 36%); }

.card-body { flex: 1; min-width: 0; }

.card-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: hsl(220 40% 13%);
    line-height: 1.4;
    margin: 0 0 0.5rem;
    transition: color 0.3s;
}

.contract-card:hover .card-title { color: hsl(172 50% 36%); }

.card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }

.card-year {
    display: inline-flex;
    padding: 0.15rem 0.625rem;
    border-radius: 0.375rem;
    background: hsla(220 55% 18% / 0.1);
    color: hsl(220 55% 18%);
    font-size: 0.75rem;
    font-weight: 600;
}

.card-dept {
    font-size: 0.75rem;
    color: hsl(172 50% 36%);
    font-weight: 500;
}

.card-amount {
    font-size: 0.75rem;
    color: hsl(30 80% 40%);
    font-weight: 600;
}

/* ── Card detail (expanded) ── */

.card-detail {
    width: 100%;
    margin-top: 0.5rem;
    padding-top: 1rem;
    border-top: 1px solid hsl(40 18% 92%);
    font-size: 0.88rem;
    line-height: 1.6;
    animation: fadeIn 0.25s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

.card-detail p { margin-bottom: 8px; color: hsl(220 15% 40%); }
.card-detail p strong { color: hsl(220 40% 13%); font-weight: 600; }

.content {
    background: hsl(40 20% 97%);
    padding: 14px;
    border-radius: 0.75rem;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 0.82rem;
    max-height: 400px;
    overflow-y: auto;
    margin: 12px 0;
    font-family: inherit;
    color: hsl(220 15% 40%);
    border: 1px solid hsl(40 18% 92%);
}

.source-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 10px;
    color: hsl(172 50% 36%);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 6px 14px;
    border-radius: 0.5rem;
    transition: background 0.15s;
}

.source-link:hover { background: hsla(172 50% 36% / 0.08); }

.loading { color: hsl(220 15% 60%); font-style: italic; font-size: 0.85rem; }
.error { color: hsl(0 70% 50%); font-weight: 500; }

/* ── Detail sections ── */

.detail-section {
    margin: 12px 0;
    padding: 14px 18px;
    background: hsl(40 20% 97%);
    border-radius: 0.75rem;
    border: 1px solid hsl(40 18% 90%);
}

.detail-section h4 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: hsl(172 50% 36%);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid hsl(40 18% 90%);
    font-weight: 600;
}

.detail-grid {
    display: grid;
    grid-template-columns: minmax(180px, auto) 1fr;
    gap: 6px 16px;
    align-items: baseline;
}

.detail-label { font-weight: 600; color: hsl(220 30% 25%); font-size: 0.82rem; }
.detail-value { color: hsl(220 15% 40%); font-size: 0.82rem; word-break: break-word; }

.detail-meta {
    background: hsl(40 15% 94%);
    border-color: hsl(40 15% 87%);
}

.detail-meta h4 {
    color: hsl(220 15% 60%);
    border-color: hsl(40 15% 87%);
}

/* ── Pagination ── */

.pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: 32px;
    flex-wrap: wrap;
}

.pagination a, .pagination .current {
    padding: 10px 16px;
    border-radius: 0.5rem;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    font-family: inherit;
    transition: all 0.15s;
    min-width: 40px;
    text-align: center;
}

.pagination a {
    background: white;
    color: hsl(220 15% 40%);
    border: 1px solid hsl(40 18% 88%);
}

.pagination a:hover {
    background: hsla(172 50% 36% / 0.06);
    color: hsl(172 50% 30%);
    border-color: hsla(172 50% 36% / 0.3);
}

.pagination .current {
    background: hsl(220 55% 18%);
    color: white;
    box-shadow: 0 2px 8px hsla(220 55% 18% / 0.3);
}

.pagination .dots { padding: 10px 6px; color: hsl(220 15% 60%); }

/* ── Scroll loader ── */

.scroll-loader {
    text-align: center;
    padding: 2rem 0;
}

/* ── Back to top ── */

.back-to-top {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    border: none;
    background: hsl(220 55% 18%);
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    box-shadow: 0 4px 12px hsla(220 55% 18% / 0.3);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.25s, transform 0.25s;
    z-index: 200;
    pointer-events: none;
}

.back-to-top.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* ── Desktop/Mobile visibility ── */

.mobile-only { display: none; }

/* ── Mobile ── */

@media (max-width: 768px) {
    .desktop-only { display: none !important; }
    .mobile-only { display: block !important; }

    body { padding: 12px 12px 32px; }

    .hero {
        border-radius: 1rem;
        padding: 1.75rem 1.25rem;
    }

    .hero-top { flex-direction: column; text-align: center; gap: 1.25rem; }
    .hero-desc { margin-left: auto; margin-right: auto; }
    .hero h1 { font-size: 2rem; }

    .hero-stats {
        gap: 0.5rem;
        justify-content: center;
    }

    .hero-stat {
        padding: 0.5rem 0.625rem;
        gap: 0.5rem;
        flex: 1;
        min-width: 0;
    }

    .hero-stat-value { font-size: 0.95rem; }
    .hero-stat-label { font-size: 0.6rem; }
    .hero-stat-icon { width: 16px; height: 16px; }

    .filters {
        flex-direction: column;
        padding: 12px 0;
    }

    .search-wrapper,
    .filters select,
    .filters select[name="year"] {
        width: 100%;
    }

    .filters .reset { justify-content: center; }

    .contract-card {
        padding: 1rem;
        border-radius: 0.75rem;
    }

    .detail-grid {
        grid-template-columns: 1fr;
        gap: 2px 0;
    }

    .detail-label { margin-top: 8px; }
    .detail-section { padding: 12px 14px; }
}
