* { box-sizing: border-box; }

:root {
    --page-bg: #f5f6f8;
    --panel-bg: #ffffff;
    --text: #20242a;
    --muted: #68707a;
    --border: #d8dde3;
    --accent: #1f4f79;
    --accent-dark: #173c5c;
    --soft: #eef3f7;
    --danger-bg: #fff2f2;
    --danger-border: #e8b4b4;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--page-bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
}

body {
    min-width: 320px;
}

.page-shell {
    width: min(1500px, calc(100% - 32px));
    margin: 0 auto;
    padding: 24px 0 40px;
}

.page-header {
    background: var(--accent);
    color: #fff;
    padding: 22px 24px;
    border-radius: 10px 10px 0 0;
}

.page-header h1 {
    margin: 0 0 4px;
    font-size: clamp(1.5rem, 3vw, 2rem);
}

.page-header p {
    margin: 0;
    opacity: .9;
}

.search-panel,
.results-panel,
.legal-placeholder {
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-top: 0;
    padding: 20px 24px;
}

.search-panel h2,
.results-panel h2 {
    margin: 0;
    font-size: 1.1rem;
}

.search-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 14px;
    margin-top: 16px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field label {
    font-weight: 700;
    font-size: .9rem;
}

.field input,
.field select {
    width: 100%;
    min-height: 42px;
    border: 1px solid #b9c1c9;
    border-radius: 6px;
    padding: 8px 10px;
    font: inherit;
    background: #fff;
}

.field input:focus,
.field select:focus {
    outline: 3px solid rgba(31, 79, 121, .15);
    border-color: var(--accent);
}

.search-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.btn {
    border: 1px solid transparent;
    border-radius: 6px;
    min-height: 42px;
    padding: 8px 18px;
    font-weight: 700;
    cursor: pointer;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-dark);
}

.btn-secondary {
    background: #fff;
    border-color: #aeb6bf;
    color: var(--text);
}

.error-box {
    margin-top: 16px;
    padding: 12px 14px;
    border: 1px solid var(--danger-border);
    background: var(--danger-bg);
    border-radius: 6px;
}

.results-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.result-count {
    color: var(--muted);
    font-size: .9rem;
}

.results-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.inmate-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    min-width: 1050px;
}

.inmate-table th {
    background: var(--soft);
    text-align: left;
    padding: 11px 10px;
    border-bottom: 1px solid var(--border);
    font-size: .85rem;
}

.inmate-table td {
    vertical-align: top;
    padding: 12px 10px;
    border-bottom: 1px solid var(--border);
    overflow-wrap: anywhere;
}

.inmate-table tbody tr:last-child td {
    border-bottom: 0;
}

.inmate-table .photo-col { width: 96px; }
.inmate-table .age-col { width: 65px; }
.inmate-table .custody-col { width: 115px; }
.inmate-table th:nth-child(2) { width: 190px; }
.inmate-table th:nth-child(5) { width: 180px; }
.inmate-table th:nth-child(6) { width: 280px; }
.inmate-table th:nth-child(7) { width: 135px; }

.name-cell {
    font-weight: 700;
}

.photo-frame {
    width: 72px;
    height: 84px;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    background: #f0f2f4;
    display: flex;
    align-items: center;
    justify-content: center;
}

.inmate-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.photo-placeholder {
    display: none;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 6px;
    color: var(--muted);
    text-align: center;
    font-size: .72rem;
}

.photo-placeholder.visible {
    display: flex;
}

.charge-stack {
    padding-top: 8px !important;
    padding-bottom: 8px !important;
}

.charge-line {
    display: block;
    min-height: 31px;
    padding: 5px 0;
    border-bottom: 1px solid #edf0f2;
}

.charge-line:last-child {
    border-bottom: 0;
}

.severity-cell .charge-line {
    font-weight: 700;
}

.no-results {
    padding: 26px;
    text-align: center;
    color: var(--muted);
}

.legal-placeholder {
    color: var(--muted);
    font-size: .85rem;
    border-radius: 0 0 10px 10px;
}

@media (max-width: 900px) {
    .search-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .results-wrap {
        overflow: visible;
        border: 0;
    }

    .inmate-table,
    .inmate-table tbody,
    .inmate-table tr,
    .inmate-table td {
        display: block;
        width: 100%;
        min-width: 0;
    }

    .inmate-table {
        min-width: 0;
    }

    .inmate-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    .inmate-row {
        display: grid !important;
        grid-template-columns: 94px 1fr;
        border: 1px solid var(--border);
        border-radius: 10px;
        margin-bottom: 14px;
        overflow: hidden;
        background: #fff;
    }

    .inmate-table td {
        border-bottom: 1px solid var(--border);
        padding: 10px 12px 10px 132px;
        position: relative;
        min-height: 42px;
    }

    .inmate-table td::before {
        content: attr(data-label);
        position: absolute;
        left: 12px;
        top: 10px;
        width: 108px;
        color: var(--muted);
        font-weight: 700;
        font-size: .78rem;
    }

    .photo-cell {
        grid-row: 1 / span 3;
        grid-column: 1;
        padding: 12px !important;
        border-right: 1px solid var(--border);
    }

    .photo-cell::before {
        display: none;
    }

    .name-cell,
    .age-cell,
    .custody-cell {
        grid-column: 2;
    }

    .charge-stack {
        grid-column: 1 / -1;
        padding-left: 132px !important;
    }

    .photo-frame {
        width: 68px;
        height: 82px;
    }
}

@media (max-width: 560px) {
    .page-shell {
        width: 100%;
        padding: 0;
    }

    .page-header,
    .legal-placeholder {
        border-radius: 0;
    }

    .search-panel,
    .results-panel,
    .legal-placeholder {
        padding: 16px;
        border-left: 0;
        border-right: 0;
    }

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

    .search-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .btn {
        width: 100%;
    }

    .inmate-row {
        grid-template-columns: 84px 1fr;
    }

    .inmate-table td {
        padding-left: 112px;
    }

    .inmate-table td::before {
        width: 92px;
    }

    .charge-stack {
        padding-left: 112px !important;
    }

    .photo-frame {
        width: 58px;
        height: 74px;
    }
}


/* v3: keep each charge/description/severity record on the same physical table row. */
.inmate-table tbody tr.inmate-row td {
    border-bottom: 1px solid #edf0f2;
}

.inmate-table tbody tr.inmate-group-end td {
    border-bottom: 1px solid var(--border);
}

.charge-cell,
.description-cell,
.severity-cell {
    padding-top: 9px !important;
    padding-bottom: 9px !important;
}

.severity-cell {
    font-weight: 700;
}

@media (max-width: 900px) {
    /* Rowspan is intentionally neutralized visually on mobile by showing one compact charge block per SQL row.
       Inmate identity fields stay on the first row of each group. */
    .inmate-table tbody,
    .inmate-table tr,
    .inmate-table td {
        display: block;
    }

    .inmate-row {
        display: grid !important;
        grid-template-columns: 94px 1fr;
    }

    .inmate-row:not(.inmate-group-start) {
        grid-template-columns: 1fr;
        margin-top: -15px;
        border-top: 0;
        border-radius: 0 0 10px 10px;
    }

    .inmate-row:not(.inmate-group-start) .charge-cell,
    .inmate-row:not(.inmate-group-start) .description-cell,
    .inmate-row:not(.inmate-group-start) .severity-cell {
        grid-column: 1 / -1;
    }

    .charge-cell,
    .description-cell,
    .severity-cell {
        grid-column: 1 / -1;
        padding-left: 132px !important;
    }
}

@media (max-width: 560px) {
    .charge-cell,
    .description-cell,
    .severity-cell {
        padding-left: 112px !important;
    }
}


/* Phase 3 branding: Pennington County Sheriff's Office */
:root {
    --page-bg: #f3f1ed;
    --panel-bg: #ffffff;
    --text: #27221d;
    --muted: #6f675f;
    --border: #d8d1c8;
    --brand-brown: #3b281b;
    --brand-brown-dark: #281a11;
    --brand-gold: #c59a43;
    --brand-gold-light: #e2c47f;
    --brand-cream: #f8f4ec;
    --soft: #f1ede7;
    --danger-bg: #fff3f1;
    --danger-border: #d7a6a0;
    --accent: #6f4c2d;
    --accent-dark: #4f341e;
}

html, body {
    background: var(--page-bg);
    color: var(--text);
}

.page-shell {
    width: min(1500px, calc(100% - 32px));
    padding-top: 18px;
}

.agency-header {
    border-radius: 10px 10px 0 0;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,.12);
}

.agency-header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    padding: 16px 24px;
    background: var(--brand-brown-dark);
    color: #fff;
    border-bottom: 4px solid var(--brand-gold);
}

.agency-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    color: #fff;
    text-decoration: none;
}

.agency-badge-wrap {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 64px;
}

.agency-badge {
    max-width: 64px;
    max-height: 64px;
    object-fit: contain;
}

.agency-name {
    display: block;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(1.25rem, 2.8vw, 1.8rem);
    font-weight: 700;
    line-height: 1.1;
}

.agency-location {
    display: block;
    margin-top: 4px;
    color: var(--brand-gold-light);
    font-size: .88rem;
    letter-spacing: .03em;
}

.agency-contact {
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-align: right;
    font-size: .86rem;
    color: #eee8df;
}

.agency-nav {
    display: flex;
    align-items: stretch;
    background: var(--brand-brown);
    border-bottom: 1px solid #1e140d;
}

.agency-nav a,
.agency-nav-active {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 18px;
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: .9rem;
    border-right: 1px solid rgba(255,255,255,.12);
}

.agency-nav a:hover {
    background: rgba(255,255,255,.08);
}

.agency-nav-active {
    color: var(--brand-brown-dark);
    background: var(--brand-gold);
}

.page-title-band {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 126px;
    padding: 24px;
    background:
        linear-gradient(90deg, rgba(255,255,255,.98), rgba(248,244,236,.96));
    color: var(--brand-brown-dark);
}

.page-title-band .eyebrow {
    display: block;
    margin-bottom: 5px;
    color: #7b5b36;
    text-transform: uppercase;
    letter-spacing: .12em;
    font-size: .72rem;
    font-weight: 700;
}

.page-title-band h1 {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(1.8rem, 4vw, 2.55rem);
    line-height: 1.05;
}

.page-title-band p {
    margin: 7px 0 0;
    color: var(--muted);
}

.search-panel,
.results-panel {
    border-color: var(--border);
}

.search-panel h2,
.results-panel h2 {
    color: var(--brand-brown-dark);
    font-family: Georgia, "Times New Roman", serif;
}

.btn-primary {
    background: var(--brand-brown);
    border-color: var(--brand-brown);
}

.btn-primary:hover {
    background: var(--brand-brown-dark);
}

.field input:focus,
.field select:focus {
    border-color: var(--brand-gold);
    outline: 3px solid rgba(197,154,67,.22);
}

.inmate-table th {
    background: var(--brand-brown);
    color: #fff;
    border-bottom: 3px solid var(--brand-gold);
}

.inmate-table tbody tr.inmate-group-start:hover td {
    background-color: #fbf8f2;
}

.name-cell {
    color: var(--brand-brown-dark);
}

.photo-frame {
    border-color: #bfae98;
    background: #eee9e1;
    box-shadow: 0 1px 3px rgba(0,0,0,.09);
}

.site-footer {
    background: var(--brand-brown-dark);
    color: #fff;
    border-radius: 0 0 10px 10px;
    overflow: hidden;
}

.disclaimer-panel {
    padding: 20px 24px;
    background: #f5eee2;
    color: #38291d;
    border-top: 4px solid var(--brand-gold);
}

.disclaimer-panel h2 {
    margin: 0 0 8px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.15rem;
}

.disclaimer-panel p {
    margin: 0;
    line-height: 1.5;
    font-size: .85rem;
}

.footer-main {
    display: grid;
    grid-template-columns: 1.4fr .8fr .8fr;
    gap: 28px;
    padding: 24px;
}

.footer-main h2 {
    margin: 0 0 8px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.1rem;
    color: var(--brand-gold-light);
}

.footer-main p {
    margin: 0 0 10px;
    line-height: 1.5;
    font-size: .86rem;
}

.footer-links {
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.footer-links a {
    color: #fff;
    text-decoration-color: var(--brand-gold);
    text-underline-offset: 3px;
}

.footer-bottom {
    padding: 10px 24px;
    background: #1e140d;
    color: #cfc3b5;
    text-align: center;
    font-size: .77rem;
}

@media (max-width: 800px) {
    .agency-header-inner {
        align-items: flex-start;
    }

    .agency-contact {
        display: none;
    }

    .agency-nav {
        overflow-x: auto;
        white-space: nowrap;
    }

    .footer-main {
        grid-template-columns: 1fr 1fr;
    }

    .footer-links {
        grid-column: 1 / -1;
    }
}

@media (max-width: 560px) {
    .page-shell {
        width: 100%;
        padding-top: 0;
    }

    .agency-header {
        border-radius: 0;
    }

    .agency-header-inner {
        padding: 12px 16px;
    }

    .agency-badge-wrap {
        width: 52px;
        height: 52px;
        flex-basis: 52px;
    }

    .agency-badge {
        max-width: 52px;
        max-height: 52px;
    }

    .agency-name {
        font-size: 1.15rem;
    }

    .agency-location {
        font-size: .76rem;
    }

    .agency-nav a,
    .agency-nav-active {
        min-height: 42px;
        padding: 0 14px;
        font-size: .82rem;
    }

    .page-title-band {
        min-height: 108px;
        padding: 20px 16px;
    }

    .footer-main {
        grid-template-columns: 1fr;
        padding: 20px 16px;
    }

    .footer-links {
        grid-column: auto;
    }

    .disclaimer-panel {
        padding: 18px 16px;
    }

    .site-footer {
        border-radius: 0;
    }
}



/* Phase 4 refinements */
.agency-header-inner {
    padding: 11px 20px;
    gap: 18px;
}

.agency-badge-wrap {
    width: 54px;
    height: 54px;
    flex-basis: 54px;
}

.agency-badge {
    max-width: 54px;
    max-height: 54px;
}

.agency-name {
    font-size: clamp(1.15rem, 2.4vw, 1.62rem);
}

.agency-location {
    margin-top: 2px;
    font-size: .8rem;
}

.agency-contact {
    font-size: .8rem;
}

.agency-nav a,
.agency-nav-active {
    min-height: 39px;
    padding: 0 15px;
    font-size: .84rem;
}

.page-title-band {
    min-height: 86px;
    padding: 15px 24px;
}

.page-title-band .eyebrow {
    margin-bottom: 3px;
    font-size: .68rem;
}

.page-title-band h1 {
    font-size: clamp(1.65rem, 3.3vw, 2.15rem);
}

.page-title-band p {
    margin-top: 3px;
    font-size: .9rem;
}

.search-panel {
    padding-top: 15px;
    padding-bottom: 15px;
}

.search-grid {
    margin-top: 11px;
    gap: 11px;
}

.field input,
.field select {
    min-height: 38px;
    padding-top: 6px;
    padding-bottom: 6px;
}

.search-actions {
    margin-top: 11px;
}

.btn {
    min-height: 38px;
    padding: 6px 16px;
}

.results-panel {
    padding-top: 14px;
}

.results-heading {
    margin-bottom: 8px;
    padding: 0 2px;
}

.results-wrap {
    border-radius: 7px;
}

.inmate-table th {
    padding-top: 9px;
    padding-bottom: 9px;
}

.name-link {
    appearance: none;
    border: 0;
    padding: 0;
    margin: 0;
    background: transparent;
    color: var(--brand-brown-dark);
    font: inherit;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
}

.name-link:hover,
.name-link:focus-visible {
    text-decoration: underline;
    text-decoration-color: var(--brand-gold);
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}

.photo-frame {
    appearance: none;
    padding: 0;
    cursor: pointer;
}

.photo-frame:hover,
.photo-frame:focus-visible {
    outline: 3px solid rgba(197,154,67,.28);
    outline-offset: 2px;
}

/* Mobile navigation */
.mobile-nav-toggle {
    display: none;
    width: 100%;
    min-height: 42px;
    border: 0;
    border-bottom: 1px solid rgba(255,255,255,.12);
    background: var(--brand-brown);
    color: #fff;
    padding: 0 16px;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
}

.mobile-nav-icon {
    display: inline-block;
    margin-right: 8px;
    color: var(--brand-gold-light);
    font-size: 1.05rem;
}

/* Detail modal */
.detail-modal[hidden] {
    display: none;
}

.detail-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.detail-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(24, 16, 10, .72);
}

.detail-panel {
    position: relative;
    z-index: 1;
    width: min(720px, 100%);
    max-height: calc(100vh - 48px);
    overflow: auto;
    display: grid;
    grid-template-columns: minmax(220px, 280px) 1fr;
    gap: 28px;
    padding: 28px;
    border-radius: 12px;
    border-top: 5px solid var(--brand-gold);
    background: #fff;
    box-shadow: 0 18px 60px rgba(0,0,0,.34);
}

.detail-close {
    position: absolute;
    right: 12px;
    top: 8px;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--brand-brown-dark);
    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
}

.detail-close:hover,
.detail-close:focus-visible {
    background: var(--soft);
}

.detail-photo-column {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.detail-photo-frame {
    aspect-ratio: 4 / 5;
    width: 100%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #c9bca9;
    border-radius: 8px;
    background: #eee9e1;
}

.detail-photo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #eee9e1;
}

.detail-photo-fallback {
    padding: 20px;
    color: var(--muted);
    text-align: center;
}

.detail-photo-link {
    color: var(--brand-brown);
    font-weight: 700;
    text-align: center;
    text-underline-offset: 3px;
}

.detail-info {
    padding-top: 18px;
}

.detail-eyebrow {
    display: block;
    margin-bottom: 4px;
    color: #7b5b36;
    text-transform: uppercase;
    letter-spacing: .12em;
    font-size: .7rem;
    font-weight: 700;
}

.detail-info h2 {
    margin: 0 0 22px;
    padding-right: 32px;
    color: var(--brand-brown-dark);
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(1.55rem, 4vw, 2.15rem);
    line-height: 1.08;
}

.detail-facts {
    margin: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--border);
}

.detail-facts div {
    min-height: 76px;
    padding: 13px 15px;
    background: #fff;
}

.detail-facts dt {
    color: var(--muted);
    font-size: .76rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.detail-facts dd {
    margin: 6px 0 0;
    color: var(--brand-brown-dark);
    font-size: 1.08rem;
    font-weight: 700;
}

body.detail-modal-open {
    overflow: hidden;
}

@media (max-width: 800px) {
    .agency-header-inner {
        padding: 10px 14px;
    }

    .agency-badge-wrap {
        width: 46px;
        height: 46px;
        flex-basis: 46px;
    }

    .agency-badge {
        max-width: 46px;
        max-height: 46px;
    }

    .agency-name {
        font-size: 1.08rem;
    }

    .agency-location {
        font-size: .72rem;
    }

    .mobile-nav-toggle {
        display: block;
    }

    .agency-nav {
        display: none;
        flex-direction: column;
        overflow: visible;
    }

    .agency-nav.is-open {
        display: flex;
    }

    .agency-nav a,
    .agency-nav-active {
        width: 100%;
        min-height: 40px;
        border-right: 0;
        border-bottom: 1px solid rgba(255,255,255,.09);
    }

    .page-title-band {
        min-height: 76px;
        padding: 13px 16px;
    }

    .detail-panel {
        width: min(620px, 100%);
        grid-template-columns: minmax(170px, 220px) 1fr;
        gap: 20px;
        padding: 22px;
    }
}

@media (max-width: 560px) {
    .agency-header-inner {
        padding: 9px 12px;
    }

    .agency-brand {
        gap: 9px;
    }

    .agency-badge-wrap {
        width: 40px;
        height: 40px;
        flex-basis: 40px;
    }

    .agency-badge {
        max-width: 40px;
        max-height: 40px;
    }

    .agency-name {
        font-size: 1rem;
    }

    .page-title-band {
        min-height: 70px;
        padding: 11px 14px;
    }

    .page-title-band h1 {
        font-size: 1.55rem;
    }

    .search-panel {
        padding-top: 13px;
        padding-bottom: 13px;
    }

    .detail-modal {
        align-items: flex-end;
        padding: 0;
    }

    .detail-panel {
        width: 100%;
        max-height: 92vh;
        grid-template-columns: 1fr;
        gap: 18px;
        padding: 20px 18px 24px;
        border-radius: 14px 14px 0 0;
    }

    .detail-photo-column {
        width: min(260px, 78vw);
        margin: 0 auto;
    }

    .detail-info {
        padding-top: 0;
    }

    .detail-info h2 {
        margin-bottom: 16px;
        font-size: 1.55rem;
    }

    .detail-facts {
        grid-template-columns: 1fr 1fr;
    }

    .detail-facts div {
        min-height: 66px;
        padding: 11px 12px;
    }
}


/* Phase 5: charges in inmate detail panel */
.detail-panel {
    width: min(940px, 100%);
    grid-template-columns: minmax(220px, 280px) 1fr;
}

.detail-charges {
    margin-top: 22px;
}

.detail-charges h3 {
    margin: 0 0 10px;
    color: var(--brand-brown-dark);
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.12rem;
}

.detail-charge-header,
.detail-charge-row {
    display: grid;
    grid-template-columns: minmax(130px, .8fr) minmax(260px, 1.8fr) minmax(70px, .45fr);
    gap: 0;
}

.detail-charge-header {
    overflow: hidden;
    border-radius: 7px 7px 0 0;
    background: var(--brand-brown);
    color: #fff;
    border-bottom: 3px solid var(--brand-gold);
}

.detail-charge-header span {
    padding: 8px 10px;
    font-size: .76rem;
    font-weight: 700;
}

.detail-charge-list {
    border: 1px solid var(--border);
    border-top: 0;
    border-radius: 0 0 7px 7px;
    overflow: hidden;
}

.detail-charge-row {
    background: #fff;
    border-bottom: 1px solid var(--border);
}

.detail-charge-row:last-child {
    border-bottom: 0;
}

.detail-charge-code,
.detail-charge-description,
.detail-charge-severity {
    padding: 10px;
    overflow-wrap: anywhere;
}

.detail-charge-severity {
    font-weight: 700;
}

@media (max-width: 700px) {
    .detail-charge-header {
        display: none;
    }

    .detail-charge-row {
        grid-template-columns: 1fr;
        gap: 0;
        padding: 10px 12px;
    }

    .detail-charge-code,
    .detail-charge-description,
    .detail-charge-severity {
        padding: 4px 0;
    }

    .detail-charge-code::before,
    .detail-charge-description::before,
    .detail-charge-severity::before {
        display: inline-block;
        width: 86px;
        margin-right: 6px;
        color: var(--muted);
        font-size: .72rem;
        font-weight: 700;
        text-transform: uppercase;
    }

    .detail-charge-code::before { content: "Charge"; }
    .detail-charge-description::before { content: "Description"; }
    .detail-charge-severity::before { content: "Severity"; }
}


/* Phase 6: watermarked larger inmate photo */
.detail-photo-canvas {
    display: block;
    width: 100%;
    height: auto;
    max-height: 420px;
    object-fit: contain;
    background: #eee9e1;
}

.detail-photo-source {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.detail-photo-link {
    appearance: none;
    border: 0;
    background: transparent;
    cursor: pointer;
    font: inherit;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.photo-lightbox[hidden] {
    display: none;
}

.photo-lightbox {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.photo-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(12, 8, 5, .9);
}

.photo-lightbox-panel {
    position: relative;
    z-index: 1;
    max-width: min(94vw, 1000px);
    max-height: 94vh;
    padding: 14px;
    border-radius: 10px;
    background: #16100c;
    box-shadow: 0 20px 70px rgba(0,0,0,.55);
}

.photo-lightbox-canvas {
    display: block;
    max-width: calc(94vw - 28px);
    max-height: calc(94vh - 28px);
    width: auto;
    height: auto;
}

.photo-lightbox-close {
    position: absolute;
    z-index: 2;
    right: 7px;
    top: 7px;
    width: 40px;
    height: 40px;
    border: 1px solid rgba(255,255,255,.45);
    border-radius: 50%;
    background: rgba(0,0,0,.58);
    color: #fff;
    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
}

@media (max-width: 560px) {
    .photo-lightbox {
        padding: 8px;
    }

    .photo-lightbox-panel {
        padding: 8px;
        max-width: 98vw;
    }

    .photo-lightbox-canvas {
        max-width: calc(98vw - 16px);
        max-height: calc(94vh - 16px);
    }
}

/* Phase 7: Inmate Type */
.inmate-table .type-col { width: 105px; }
.type-cell { font-weight: 700; color: var(--brand-brown-dark); }
@media (max-width: 900px) { .type-cell { grid-column: 2; } }


/* Phase 8: allow supporting browsers to skip layout/paint work for off-screen inmate groups. */
@supports (content-visibility: auto) {
    .inmate-row.inmate-group-start {
        content-visibility: auto;
        contain-intrinsic-size: 96px;
    }
}
