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

body {
    font-family: Inter, 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f7fb;
    padding: 18px;
    min-height: 100vh;
    color: #1f2937;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(15, 23, 42, 0.08);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 70vh;
}

header {
    background: white;
    color: #0f172a;
    padding: 20px 24px;
    border-bottom: 1px solid #e6eef8;
    display: flex;
    align-items: center;
    gap: 16px;
}

header img.logo {
    width: 44px;
    height: 44px;
}

h1 {
    font-size: 20px;
    margin-bottom: 2px;
    font-weight: 700;
    letter-spacing: -0.2px;
}

.subtitle {
    font-size: 13px;
    opacity: 0.8;
    color: #475569;
}

.credit {
    font-size: 12px;
    opacity: 0.85;
    color: #6b7280;
}

.controls {
    padding: 14px 18px;
    background: #fbfdff;
    border-bottom: 1px solid #eef2f7;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

/* visually hidden accessible labels */
.sr-only {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.search-box {
    flex: 1 1 360px;
    min-width: 220px;
}

.search-box input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #e6eef8;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.15s ease;
    background: white;
}

.search-box input:focus {
    outline: none;
    border-color: #2b6cb0;
    box-shadow: 0 6px 18px rgba(43, 108, 176, 0.06);
}

.filter-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.filter-select {
    padding: 8px 12px;
    border: 1px solid #e6eef8;
    border-radius: 8px;
    font-size: 13px;
    background: white;
    cursor: pointer;
}

.record-count {
    color: #475569;
    font-weight: 600;
    padding: 6px 10px;
    background: #ffffff;
    border-radius: 8px;
    border: 1px solid #eef2f7;
    white-space: nowrap;
    font-size: 13px;
}

.table-wrapper {
    padding: 18px;
    /* Make this the scroll container so the thead sticky works within it */
}

/* Section/role row styling */
tr.section-row td {
    background: #eef6ff;
    font-weight: 700;
    color: #0f172a;
    padding: 12px 14px;
}

tr.category-row td {
    background: #f1f7ef;
    font-weight: 800;
    color: #083344;
    padding: 12px 14px;
}

.table-container {
    overflow: auto;
    max-height: calc(100vh - 300px);
    background: white;
    border: 1px solid #eef2f7;
    border-radius: 8px;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 900px;
    background: white;
}

thead {
    background: #f8fafc;
    color: #0f172a;
    position: sticky;
    top: 0;
    z-index: 5;
    box-shadow: 0 2px 0 rgba(15, 23, 42, 0.02) inset;
}

th {
    padding: 12px 14px;
    text-align: left;
    font-weight: 700;
    font-size: 13px;
    color: #0f172a;
    position: relative;
    white-space: nowrap;
}

th::after {
    content: '';
    margin-left: 8px;
    opacity: 0.5;
    font-size: 0.9em;
}

td {
    padding: 10px 14px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 13px;
    line-height: 1.4;
    color: #334155;
    vertical-align: top;
}

tbody tr:hover {
    background-color: #fbfdff;
}

.no-results {
    padding: 24px;
    text-align: center;
    color: #6c757d;
    font-size: 1em;
    display: none;
}

.no-results.show {
    display: block;
}

footer {
    padding: 12px 18px;
    background: #fbfdff;
    border-top: 1px solid #eef2f7;
    text-align: center;
    color: #6c757d;
    font-size: 13px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 13px;
    background: #ffffff;
    color: #0f172a;
    box-shadow: 0 2px 6px rgba(2, 6, 23, 0.03);
}

.btn-primary {
    background: linear-gradient(90deg, #3b82f6, #2563eb);
    color: white;
    border-color: rgba(37, 99, 235, 0.2);
}

.btn-ghost {
    background: transparent;
    border: 1px solid #e6eef8;
}

@media (max-width: 768px) {
    .controls {
        flex-direction: column;
        align-items: stretch;
    }

    .search-box {
        order: 1;
    }

    .filter-group {
        order: 2;
    }
}

/* ── Name formatting ── */
.surname { font-weight: 700; font-size: 1.15em; }

/* ── Badges ── */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
    line-height: 1.5;
}

/* Custom Type badges */
.badge-ct-wool     { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.badge-ct-tunnage  { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.badge-ct-petty    { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.badge-ct-searcher { background: #f3e8ff; color: #6b21a8; border: 1px solid #c4b5fd; }

/* Role badges */
.badge-role-collector  { background: #fff7ed; color: #9a3412; border: 1px solid #fdba74; }
.badge-role-controller { background: #eff6ff; color: #1d4ed8; border: 1px solid #93c5fd; }
.badge-role-supervisor { background: #fdf2f8; color: #9d174d; border: 1px solid #f9a8d4; }
.badge-role-searcher   { background: #f5f3ff; color: #5b21b6; border: 1px solid #c4b5fd; }
.badge-role-surveyor   { background: #ecfdf5; color: #065f46; border: 1px solid #6ee7b7; }
.badge-role-deputy     { background: #fefce8; color: #854d0e; border: 1px solid #fde047; }
.badge-role-default    { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }
