:root {
    --primary: #9bc53d;
    --primary-dark: #7ba32e;
    --primary-light: #b5d96a;
    --text-dark: #3d3d3d;
    --text: #4a4a4a;
    --text-light: #6b6b6b;
    --text-muted: #999999;
    --bg: #f8f9fa;
    --bg-card: #ffffff;
    --border: #e0e0e0;
    --border-light: #eeeeee;
    --score-high: #2e7d32;
    --score-high-bg: #e8f5e9;
    --score-medium: #f57c00;
    --score-medium-bg: #fff3e0;
    --score-low: #757575;
    --score-low-bg: #f5f5f5;
}

* {
    box-sizing: border-box;
}

body {
    font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 14px;
}

/* Header */
header {
    background: var(--text-dark);
    color: white;
    padding: 1.25rem 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
}

.logo {
    height: 50px;
    width: auto;
}

.header-text {
    text-align: left;
}

header h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.subtitle {
    margin: 0.25rem 0 0 0;
    opacity: 0.8;
    font-size: 0.875rem;
    font-weight: 400;
}

#metadata {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.8rem;
}

#metadata span {
    background: var(--primary);
    color: var(--text-dark);
    padding: 0.35rem 1rem;
    border-radius: 20px;
    font-weight: 600;
}

/* Main content */
main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Filters */
.filters {
    background: var(--bg-card);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.25rem;
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border: 1px solid var(--border-light);
}

.filters label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-light);
    font-weight: 500;
}

.filters input,
.filters select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.8rem;
    background: white;
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.filters input:focus,
.filters select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(155, 197, 61, 0.2);
}

.filters input[type="number"] {
    width: 70px;
}

.filters select {
    min-width: 140px;
}

.checkbox-label {
    cursor: pointer;
    user-select: none;
}

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

.download-buttons {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
}

.download-btn {
    padding: 0.5rem 1rem;
    background: var(--primary);
    color: var(--text-dark);
    border: none;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.download-btn:hover:not(:disabled) {
    background: var(--primary-dark);
    color: white;
}

.download-btn:disabled {
    background: var(--border);
    color: var(--text-muted);
    cursor: not-allowed;
}

/* Active filters */
.active-filters {
    margin-bottom: 0.75rem;
}

.filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--primary-light);
    color: var(--text-dark);
    padding: 0.4rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.filter-remove {
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.filter-remove:hover {
    opacity: 1;
}

/* Opdrachtgever link */
.opdrachtgever-link {
    color: var(--text);
    text-decoration: none;
}

.opdrachtgever-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* View toggle */
.view-toggle {
    display: flex;
    gap: 0;
    margin-bottom: 1rem;
    background: var(--bg-card);
    border-radius: 8px;
    padding: 0.25rem;
    width: fit-content;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border: 1px solid var(--border-light);
}

.view-btn {
    padding: 0.5rem 1.25rem;
    border: none;
    background: transparent;
    color: var(--text-light);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
}

.view-btn:hover:not(.active) {
    background: var(--bg);
    color: var(--text);
}

.view-btn.active {
    background: var(--primary);
    color: var(--text-dark);
    font-weight: 600;
}

/* DataTables customization */
#procurements {
    background: var(--bg-card);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border: 1px solid var(--border-light);
}

#procurements thead th {
    background: var(--text-dark);
    color: white;
    font-weight: 500;
    padding: 0.875rem 1rem;
    border-bottom: none;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

#procurements tbody td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
    font-size: 0.875rem;
}

#procurements tbody tr:hover {
    background: #f5f7f5;
}

#procurements tbody tr.even {
    background: #fafbfa;
}

#procurements tbody tr.even:hover {
    background: #f5f7f5;
}

/* DataTables controls */
.dataTables_wrapper {
    padding: 0;
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
    color: var(--text-light);
}

.dataTables_wrapper .dataTables_filter input {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    margin-left: 0.5rem;
}

.dataTables_wrapper .dataTables_filter input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(155, 197, 61, 0.2);
}

.dataTables_wrapper .dataTables_length select {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.35rem 0.5rem;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 0.4rem 0.75rem;
    margin: 0 2px;
    border-radius: 4px;
    border: 1px solid var(--border) !important;
    background: white !important;
    color: var(--text) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--primary) !important;
    color: var(--text-dark) !important;
    border-color: var(--primary) !important;
    font-weight: 600;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover:not(.current):not(.disabled) {
    background: var(--primary-light) !important;
    color: var(--text-dark) !important;
    border-color: var(--primary) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.disabled {
    color: var(--text-muted) !important;
    cursor: not-allowed;
}

/* Score badges */
.score {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.8rem;
    min-width: 2.25rem;
    text-align: center;
}

.score-high {
    background: var(--score-high-bg);
    color: var(--score-high);
}

.score-medium {
    background: var(--score-medium-bg);
    color: var(--score-medium);
}

.score-low {
    background: var(--score-low-bg);
    color: var(--score-low);
}

/* Country */
.country {
    font-size: 1.25rem;
    cursor: default;
}

/* Source badges */
.bron {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.bron-TenderNed {
    background: #e8f5e9;
    color: #2e7d32;
}

.bron-TED {
    background: #fff3e0;
    color: #e65100;
}

/* Links */
a {
    color: var(--primary-dark);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--text-dark);
    text-decoration: underline;
}

.title-link {
    color: var(--text);
    font-weight: 500;
}

.title-link:hover {
    color: var(--primary-dark);
    text-decoration: none;
}

.link-btn {
    display: inline-block;
    padding: 0.35rem 0.75rem;
    background: var(--primary);
    color: var(--text-dark) !important;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-decoration: none !important;
    transition: background 0.2s;
}

.link-btn:hover {
    background: var(--primary-dark);
    color: white !important;
}

.link-btn-secondary {
    background: var(--text-light);
    color: white !important;
    margin-left: 0.5rem;
}

.link-btn-secondary:hover {
    background: var(--text-dark);
}

/* Responsive child row details */
.child-details {
    padding: 0.75rem 0;
    max-width: 800px;
    overflow: hidden;
}

.child-details p {
    margin: 0.35rem 0;
    font-size: 0.8rem;
}

.child-details strong {
    color: var(--text-light);
    font-weight: 500;
}

.child-description {
    background: var(--bg);
    padding: 0.75rem;
    border-radius: 4px;
    margin-top: 0.5rem;
    white-space: pre-wrap;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
    line-height: 1.5;
    color: var(--text);
    max-width: 100%;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(61, 61, 61, 0.6);
    overflow: auto;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--bg-card);
    margin: 4% auto;
    padding: 0;
    width: 90%;
    max-width: 700px;
    border-radius: 12px;
    position: relative;
    max-height: 88vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.close {
    position: absolute;
    right: 1.25rem;
    top: 1rem;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.close:hover {
    color: var(--text);
    background: var(--bg);
}

#modal-title {
    margin: 0;
    padding: 1.5rem 3rem 1rem 1.5rem;
    color: var(--text-dark);
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.4;
    border-bottom: 3px solid var(--primary);
}

#modal-body {
    padding: 1.5rem;
}

.modal-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.modal-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.modal-field-full {
    grid-column: 1 / -1;
    margin-bottom: 0.5rem;
}

.modal-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 500;
}

.modal-value {
    font-size: 0.9rem;
    color: var(--text);
}

.modal-description {
    margin-bottom: 1.5rem;
}

.modal-description .modal-label {
    margin-bottom: 0.5rem;
    display: block;
}

.description {
    white-space: pre-wrap;
    background: var(--bg);
    padding: 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    max-height: 300px;
    overflow-y: auto;
    line-height: 1.6;
    margin: 0;
    border: 1px solid var(--border-light);
}

.modal-links {
    padding-top: 1rem;
    border-top: 1px solid var(--border-light);
}

.modal-links .link-btn {
    padding: 0.5rem 1.25rem;
    font-size: 0.85rem;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem 1.5rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--border-light);
    background: white;
    margin-top: 2rem;
}

footer p {
    margin: 0.25rem 0;
}

.footer-brand {
    font-weight: 600;
    color: var(--primary-dark);
}

/* Responsive */
@media (max-width: 768px) {
    header {
        padding: 1rem;
    }

    .header-content {
        flex-direction: column;
        gap: 0.75rem;
    }

    .header-text {
        text-align: center;
    }

    .logo {
        height: 40px;
    }

    header h1 {
        font-size: 1.25rem;
    }

    main {
        padding: 1rem;
    }

    .filters {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }

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

    .filters select {
        flex: 1;
    }

    .download-buttons {
        margin-left: 0;
        justify-content: stretch;
    }

    .download-btn {
        flex: 1;
    }

    .modal-content {
        margin: 2% auto;
        width: 95%;
        border-radius: 8px;
    }

    #modal-title {
        padding: 1.25rem 2.5rem 1rem 1.25rem;
        font-size: 1.1rem;
    }

    #modal-body {
        padding: 1.25rem;
    }

    .modal-grid {
        grid-template-columns: 1fr;
    }
}

/* Error state */
.error {
    color: #c62828;
    background: #ffebee;
    padding: 0.35rem 1rem;
    border-radius: 20px;
}

/* Sorting icons */
table.dataTable thead .sorting:after,
table.dataTable thead .sorting_asc:after,
table.dataTable thead .sorting_desc:after {
    opacity: 0.5;
}

table.dataTable thead .sorting_asc:after,
table.dataTable thead .sorting_desc:after {
    opacity: 1;
}
