/* ── COLOUR TOKENS ── */
:root {
    --color-bg:           #F9FAFB;
    --color-primary:      #7A918D;
    --color-secondary:    #93B1A7;
    --color-border:       #c8dcc4;
    --color-accent-light: #DBFEB8;
    --color-accent:       #C5EDAC;
}

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

/* ── BASE ── */
body {
    font-family: sans-serif;
    background: var(--color-bg);
    color: #2d3a35;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── TOP BAR ── */
.topbar {
    background: var(--color-primary);
    color: #fff;
    display: flex;
    align-items: center;
    padding: 0 20px;
    height: 54px;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0,0,0,.2);
    position: sticky;
    top: 0;
    z-index: 100;
}
.topbar-left, .topbar-right {
    flex: 1;
    display: flex;
    align-items: center;
}
.topbar-right {
    justify-content: flex-end;
    gap: 12px;
}
.topbar-center {
    flex: 2;
    text-align: center;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.topbar a {
    color: #fff;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 5px;
}
.topbar a:hover { opacity: .8; }

.icon-cog {
    font-size: 1.25rem;
    color: #fff;
    text-decoration: none;
}
.topbar-user {
    font-size: .9rem;
    opacity: .9;
}
.btn-logout {
    background: rgba(255,255,255,.15);
    border: 1px solid rgba(255,255,255,.4);
    color: #fff;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: .85rem;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
}
.btn-logout:hover { background: rgba(255,255,255,.25); }
.logout-form { margin: 0; }

/* ── LAYOUT ── */
.layout {
    display: flex;
    flex: 1;
}

/* ── SIDEBAR ── */
.sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--color-bg);
    border-right: 1px solid var(--color-border);
    padding: 16px 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.menu-group {
    margin-bottom: 4px;
}
.menu-group-label {
    background: var(--color-secondary);
    color: #fff;
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    padding: 6px 14px 5px;
}
.menu-search {
    padding: 6px 10px;
    margin: 6px 10px 4px;
    border: 1px solid #b5cdb8;
    border-radius: 4px;
    background: #fff;
    font-size: .85rem;
    color: #555;
    width: calc(100% - 20px);
    outline: none;
}
.menu-search:focus { border-color: var(--color-primary); }

.menu-link {
    display: block;
    margin: 2px 10px;
    padding: 7px 12px;
    background: var(--color-accent-light);
    border-radius: 4px;
    color: #2d4a35;
    text-decoration: none;
    font-size: .88rem;
    transition: background .15s;
}
.menu-link:hover { background: var(--color-accent); }
.menu-link-home { margin-bottom: 8px; }
.menu-link.active { background: var(--color-accent); font-weight: 600; }
.menu-link.disabled {
    opacity: .5;
    pointer-events: none;
    cursor: default;
}

/* ── MAIN CONTENT ── */
.main-content {
    flex: 1;
    padding: 28px 32px;
    overflow-y: auto;
}
.main-content.no-pad {
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ── BADGES ── */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: .78rem;
    font-weight: 600;
    background: var(--color-accent-light);
    color: #2d4a35;
    white-space: nowrap;
}
table .badge { padding: 2px 8px; font-size: .72rem; }
.badge-orange { background: #fce8c3; color: #7a4a00; }
.badge-red    { background: #fdd; color: #8b0000; }
.badge-grey   { background: #e8e8e8; color: #555; }

/* ── SIDEBAR SEARCH FORM ── */
.sidebar-search-form {
    padding: 6px 10px 4px;
    display: flex;
    gap: 4px;
}
.sidebar-search-input {
    margin: 0;
    flex: 1;
}
.sidebar-search-btn {
    padding: 4px 8px;
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: .8rem;
}

/* ── LIST: TWO-PANEL LAYOUT ── */
.list-layout {
    display: flex;
    gap: 0;
    height: 100%;
}

/* ── LIST: FILTER PANEL ── */
.filter-panel {
    width: 260px;
    flex-shrink: 0;
    background: #fff;
    border-right: 1px solid var(--color-border);
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.filter-panel h3 {
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--color-primary);
    margin-bottom: 2px;
}
.filter-panel input[type=search],
.filter-panel input[type=text],
.filter-panel select {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid #b5cdb8;
    border-radius: 4px;
    font-size: .88rem;
    background: #fff;
    color: #333;
    outline: none;
}
.filter-panel input[type=search]:focus,
.filter-panel input[type=text]:focus,
.filter-panel select:focus { border-color: var(--color-primary); }

.btn-search {
    width: 100%;
    padding: 8px;
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: .02em;
}
.btn-search:hover { background: #5d706c; }

.btn-reset {
    width: 100%;
    padding: 6px;
    background: transparent;
    color: var(--color-primary);
    border: 1px solid #b5cdb8;
    border-radius: 4px;
    font-size: .82rem;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    display: block;
}
.btn-reset:hover { background: var(--color-bg); }

.filter-divider { border: none; border-top: 1px solid #d8ebd4; margin: 2px 0; }

/* ── CPV MULTI-SELECT ── */
.dropdown-search { position: relative; }
.dropdown-search-toggle { display: none; }
.dropdown-search-trigger {
    display: block;
    position: relative;
    z-index: 102;
    width: 100%;
    padding: 7px 10px;
    border: 1px solid #b5cdb8;
    border-radius: 4px;
    font-size: .88rem;
    background: #fff;
    color: #333;
    cursor: pointer;
    box-sizing: border-box;
    user-select: none;
}
.dropdown-search-trigger::after { content: ' ▾'; }
.dropdown-search-toggle:checked ~ .dropdown-search-trigger { border-color: var(--color-primary); }
.dropdown-search-toggle:checked ~ .dropdown-search-trigger::after { content: ' ▴'; }
.dropdown-search-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100;
}
.dropdown-search-toggle:checked ~ .dropdown-search-overlay { display: block; }
.dropdown-search-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    width: 520px;
    background: #fff;
    border: 1px solid #b5cdb8;
    border-radius: 4px;
    max-height: 480px;
    overflow-y: auto;
    z-index: 101;
    box-shadow: 0 4px 12px rgba(0,0,0,.08);
}
.dropdown-search-toggle:checked ~ .dropdown-search-dropdown { display: block; }
.dropdown-search-option {
    display: block;
    padding: 5px 8px;
    margin: 2px 4px;
    border-radius: 4px;
    font-size: .85rem;
    cursor: pointer;
    color: #333;
}
.dropdown-search-option input[type=checkbox] { display: none; }
.dropdown-search-option:hover { background: #f0f0f0; }
.dropdown-search-option:has(input:checked) { background: var(--color-primary); color: #fff; }
.dropdown-search-option:has(input:checked):hover { background: #5d706c; }

/* ── LIST: RESULTS PANEL ── */
.results-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.results-header {
    padding: 10px 18px;
    background: #f4faf0;
    border-bottom: 1px solid var(--color-border);
    font-size: .82rem;
    color: #556;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.results-count {
    font-weight: 700;
    color: #2d4a35;
}
.results-table-wrap {
    flex: 1;
    overflow-y: auto;
}

/* ── LIST: TABLE ── */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: .85rem;
}
thead th {
    background: var(--color-secondary);
    color: #fff;
    padding: 8px 12px;
    text-align: left;
    font-weight: 600;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    position: sticky;
    top: 0;
    z-index: 1;
}
tbody tr {
    border-bottom: 1px solid #e4f0e0;
    transition: background .1s;
}
tbody tr:hover { background: #f0f9e8; }
tbody td {
    padding: 8px 12px;
    vertical-align: top;
}
.td-title { max-width: 340px; }
.td-title a {
    color: #2d4a35;
    text-decoration: none;
    font-weight: 500;
}
.td-title a:hover { text-decoration: underline; color: var(--color-primary); }
.td-entity { color: #555; max-width: 200px; }
.td-label { color: #777; white-space: nowrap; font-size: .78rem; }
.td-date { white-space: nowrap; color: #666; font-size: .8rem; }

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

.td-action {
    text-align: center;
    width: 42px;
    white-space: nowrap;
}
.td-action a, .td-action-disabled {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px; height: 28px;
    border-radius: 4px;
    color: var(--color-primary);
    transition: background .12s, color .12s;
}
.td-action a:hover { background: var(--color-accent); color: #2d4a35; }
.td-action-disabled { opacity: .25; cursor: default; }
.td-action svg {
    width: 16px; height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ── LIST: PAGINATION ── */
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 18px;
    border-top: 1px solid var(--color-border);
    background: #f4faf0;
    flex-shrink: 0;
    flex-wrap: wrap;
}
.pagination a, .pagination span {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: .82rem;
    text-decoration: none;
    color: #2d4a35;
    border: 1px solid #b5cdb8;
    background: var(--color-accent-light);
}
.pagination span.current {
    background: var(--color-accent);
    font-weight: 700;
    border-color: var(--color-secondary);
}
.pagination span.disabled { opacity: .4; pointer-events: none; }
.pagination a:hover { background: var(--color-accent); }

.no-results {
    padding: 48px;
    text-align: center;
    color: #888;
    font-size: .95rem;
}

/* ── DETAIL: SPLIT LAYOUT ── */
.main-content.split-main {
    display: flex;
    flex-direction: row;
    padding: 0;
    overflow: hidden;
}
.panel-check { display: none; }

.split-left {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    padding: 28px 32px;
}
.split-right {
    width: 22px;
    flex-shrink: 0;
    position: relative;
    transition: width 0.32s ease;
    background: var(--color-bg);
    border-left: 1px solid var(--color-border);
}
.panel-check:checked ~ .split-right {
    width: 50%;
}
.toggle-btn {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    background: var(--color-primary);
    color: #fff;
    cursor: pointer;
    font-size: .95rem;
    font-weight: 700;
    user-select: none;
    z-index: 1;
}
.toggle-btn:hover { background: #5a7570; }

.icon-close { display: none; }
.panel-check:checked ~ .split-right .icon-close { display: inline; }
.panel-check:checked ~ .split-right .icon-open  { display: none; }

.panel-body {
    position: absolute;
    left: 22px;
    top: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
}
.panel-body iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* ── DETAIL: CARD ── */
.detail-card {
    background: #fff;
    border-radius: 8px;
    padding: 28px 32px;
    box-shadow: 0 1px 4px rgba(0,0,0,.1);
    max-width: 720px;
}
.detail-field {
    display: flex;
    gap: 16px;
    padding: 10px 0;
    border-bottom: 1px solid #e4f0e0;
}
.detail-field:last-child { border-bottom: none; }
.detail-label {
    width: 160px;
    flex-shrink: 0;
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--color-primary);
    padding-top: 2px;
}
.detail-value {
    font-size: .9rem;
    color: #2d3a35;
}
.siblings-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
    max-width: 720px;
}
.sibling-btn {
    display: inline-block;
    padding: 5px 14px;
    border-radius: 6px;
    font-size: .8rem;
    font-weight: 600;
    background: #e8f5e2;
    color: #2d4a35;
    border: 1px solid #b6dba8;
    text-decoration: none;
    white-space: nowrap;
}
.sibling-btn:hover { background: var(--color-accent-light); }
.sibling-btn--current {
    background: #e0e0e0;
    color: #888;
    border-color: #c0c0c0;
    cursor: default;
    pointer-events: none;
}
.admin-gear-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    background: #e8f5e2;
    color: var(--color-primary);
    border: 1px solid #b6dba8;
    text-decoration: none;
    font-size: 1rem;
    flex-shrink: 0;
}
.admin-gear-btn:hover { background: var(--color-accent-light); color: #2d4a35; }

/* ── STATS ── */
.filters {
    display: flex;
    gap: 16px;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 24px;
}
.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.filters label {
    font-size: .8rem;
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.filters select {
    padding: 6px 10px;
    border: 1px solid #b5cdb8;
    border-radius: 4px;
    font-size: .95rem;
    background: #fff;
}
.btn-apply {
    padding: 7px 18px;
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: .95rem;
    cursor: pointer;
}
.btn-apply:hover { background: #5d706c; }
.chart-wrap {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,.1);
}
canvas { max-height: 420px; }

/* ── NAV HAMBURGER ── */
.nav-toggle { display: none; }
.hamburger {
    display: none;
    color: #fff;
    font-size: 1.35rem;
    cursor: pointer;
    padding: 4px 6px 4px 0;
    line-height: 1;
    margin-right: 4px;
    user-select: none;
}

/* ── FILTER PANEL TOGGLE (mobile only) ── */
.filter-toggle-check { display: none; }
.filter-toggle-btn { display: none; }

/* ── MOBILE ── */
@media (max-width: 768px) {
    /* Hamburger visible */
    .hamburger { display: flex; align-items: center; }

    /* Sidebar: stacks below topbar, hidden until toggled */
    .layout { flex-direction: column; }
    .sidebar {
        width: 100%;
        max-height: 0;
        overflow: hidden;
        border-right: none;
        padding: 0;
        transition: max-height 0.25s ease, padding 0.25s ease;
    }
    .nav-toggle:checked ~ .layout .sidebar {
        max-height: 500px;
        padding: 12px 0;
        border-bottom: 1px solid var(--color-border);
    }

    /* Main content */
    .main-content { padding: 12px 10px; }
    .main-content.no-pad {
        overflow: visible;
        height: auto;
        display: block;
    }
    .topbar-user { display: none; }
    .topbar { padding: 0 10px; }

    /* Filter toggle button */
    .filter-toggle-btn {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 11px 14px;
        background: var(--color-secondary);
        color: #fff;
        font-size: .9rem;
        font-weight: 600;
        cursor: pointer;
        user-select: none;
    }
    .filter-toggle-arrow { transition: transform 0.2s; display: inline-block; }
    .filter-toggle-check:checked ~ .filter-toggle-btn .filter-toggle-arrow { transform: rotate(180deg); }

    /* List layout */
    .list-layout { flex-direction: column; height: auto; }

    /* Filter panel: hidden on mobile, shown when toggled */
    .filter-panel {
        display: none;
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--color-border);
        max-height: 65vh;
        overflow-y: auto;
    }
    .filter-toggle-check:checked ~ .list-layout .filter-panel { display: flex; }

    /* Results panel */
    .results-panel { overflow: visible; }
    .results-table-wrap { overflow: visible; flex: none; }
    .results-header { padding: 8px 12px; font-size: .8rem; flex-wrap: wrap; }

    /* CPV dropdown: don't overflow viewport */
    .dropdown-search-dropdown { width: calc(100vw - 48px); }

    /* ── TABLE → CARDS ── */
    table { width: 100%; }
    thead { display: none; }

    /* Each row becomes a flex-wrap card:
       title (full width) → entity (full width) → status + dates (inline) → actions (inline) */
    tbody tr {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 4px 8px;
        border: 1px solid #d8ebd4;
        border-radius: 8px;
        margin: 8px;
        padding: 10px 12px;
        background: #fff;
        box-shadow: 0 1px 3px rgba(0,0,0,.04);
    }
    tbody tr:hover { background: #f0f9e8; }
    tbody td { padding: 0; border: none; flex-shrink: 0; }

    .td-title  { width: 100%; font-size: .92rem; }
    .td-entity { width: 100%; font-size: .8rem; color: #555; }

    /* JN + CPV labels: hide on mobile */
    .td-label { display: none; }

    /* Status badge: inline in the row with dates */
    .td-status { align-self: center; }

    /* Dates: inline with tiny label */
    .td-date { font-size: .78rem; color: #666; white-space: nowrap; }
    .td-date::before {
        content: attr(data-label) ': ';
        font-weight: 600;
        color: var(--color-primary);
        font-size: .7rem;
    }

    /* Actions: inline icons */
    .td-action { display: inline-flex; width: auto; }
    .td-action a, .td-action-disabled { width: 36px; height: 36px; }
    .td-action svg { width: 18px; height: 18px; }

    /* Pagination */
    .pagination { padding: 8px 10px; gap: 6px; }
    .pagination a, .pagination span { padding: 7px 14px; font-size: .9rem; }
}

/* LOGIN PAGE */
.login-page {
    background: #f0f4f0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
}
.login-wrap { flex: 1; display: flex; align-items: center; justify-content: center; }
.login-card {
    background: #fff;
    border: 1px solid #d0d8d0;
    border-radius: 4px;
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 340px;
}
.login-title {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: #2d4a35;
    margin: 0 0 1.5rem;
}
.login-field { margin-bottom: 1rem; }
.login-field label {
    display: block;
    font-size: .73rem;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: #555;
    margin-bottom: .3rem;
}
.login-field input {
    width: 100%;
    box-sizing: border-box;
    padding: .5rem .6rem;
    border: 1px solid #c0c8c0;
    border-radius: 3px;
    font-size: .95rem;
    background: #fafcfa;
}
.login-field input:focus { outline: none; border-color: #6b8f71; background: #fff; }
.login-btn {
    display: block;
    width: 100%;
    margin-top: 1.4rem;
    padding: .55rem 1rem;
    background: #6b8f71;
    color: #fff;
    border: none;
    border-radius: 3px;
    font-size: .9rem;
    font-weight: 600;
    letter-spacing: .04em;
    cursor: pointer;
}
.login-btn:hover { background: #5d7a63; }
.login-error {
    background: #fff3f3;
    border: 1px solid #e8b4b4;
    border-radius: 3px;
    padding: .6rem .8rem;
    margin-bottom: 1rem;
    font-size: .85rem;
    color: #a33;
}
