* {
    box-sizing: border-box;
}

:root {
    --background: #f4f6f8;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --text: #1f2937;
    --muted: #667085;
    --line: #dbe2ea;
    --primary: #17324d;
    --primary-soft: #e8eef5;
    --accent: #b3212d;
    --success: #147a4b;
    --danger: #b42318;
    --shadow: 0 12px 30px rgba(16, 24, 40, 0.08);
    --radius: 16px;
}

body {
    margin: 0;
    min-width: 320px;
    background: var(--background);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
    font: inherit;
}

.app-shell {
    width: min(1800px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0 60px;
}

.app-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
    padding: 28px 30px;
    color: #fff;
    background:
        radial-gradient(circle at top right, rgba(255, 255, 255, 0.16), transparent 38%),
        linear-gradient(135deg, #11283c, #254b6d);
    border-radius: 22px;
    box-shadow: var(--shadow);
}

.eyebrow {
    margin: 0 0 6px;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.18em;
    opacity: 0.72;
}

h1 {
    margin: 0;
    font-size: clamp(1.7rem, 3vw, 2.7rem);
    line-height: 1.1;
}

.subline {
    max-width: 760px;
    margin: 12px 0 0;
    opacity: 0.82;
}

.header-actions {
    flex: 0 0 auto;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}

.stat-card {
    padding: 20px;
    background: var(--surface);
    border: 1px solid rgba(219, 226, 234, 0.9);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(16, 24, 40, 0.05);
}

.stat-label {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 700;
}

.stat-value {
    display: block;
    font-size: 1.8rem;
    line-height: 1;
    color: var(--primary);
}

.filter-panel {
    display: grid;
    grid-template-columns: repeat(6, minmax(150px, 1fr)) auto;
    gap: 14px;
    align-items: end;
    margin-bottom: 18px;
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(16, 24, 40, 0.04);
}

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

.filter-field label {
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 700;
}

.filter-field input,
.filter-field select {
    width: 100%;
    min-height: 42px;
    padding: 8px 10px;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
}

.filter-actions {
    display: flex;
}

.button {
    min-height: 42px;
    padding: 9px 15px;
    border: 0;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 750;
    transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}

.button:hover {
    transform: translateY(-1px);
}

.button:disabled {
    cursor: wait;
    opacity: 0.6;
    transform: none;
}

.button-secondary {
    color: #fff;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.26);
}

.button-ghost {
    color: var(--primary);
    background: var(--primary-soft);
}

.table-card {
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.table-scroll {
    overflow-x: auto;
}

.status-box {
    margin-bottom: 14px;
    padding: 12px 14px;
    color: var(--primary);
    background: var(--primary-soft);
    border-radius: 10px;
    font-size: 0.92rem;
}

.status-box.is-error {
    color: var(--danger);
    background: #fee4e2;
}

.status-box.is-success {
    color: var(--success);
    background: #e7f6ee;
}

.status-box[hidden] {
    display: none;
}

table.dataTable thead th {
    white-space: nowrap;
}

table.dataTable tbody td {
    vertical-align: middle;
}

td.dt-control {
    width: 36px;
    text-align: center;
    cursor: pointer;
}

td.dt-control::before {
    content: "+";
    display: inline-grid;
    place-items: center;
    width: 24px;
    height: 24px;
    color: #fff;
    background: var(--primary);
    border-radius: 999px;
    font-weight: 900;
}

tr.shown td.dt-control::before {
    content: "−";
    background: var(--accent);
}

.detail-wrap {
    padding: 12px 4px 18px 48px;
}

.detail-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.detail-heading h3 {
    margin: 0;
    color: var(--primary);
    font-size: 1rem;
}

.detail-note {
    color: var(--muted);
    font-size: 0.82rem;
}

.detail-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 12px;
}

.detail-table {
    width: 100%;
    min-width: 1000px;
    border-collapse: collapse;
    background: var(--surface-soft);
}

.detail-table th,
.detail-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.detail-table th {
    color: var(--primary);
    background: #eef3f7;
    font-size: 0.78rem;
    white-space: nowrap;
}

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

.photo-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 190px;
}

.photo-button {
    position: relative;
    width: 76px;
    height: 58px;
    padding: 0;
    overflow: hidden;
    background: #e5e7eb;
    border: 1px solid #cbd5e1;
    border-radius: 9px;
    cursor: zoom-in;
}

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

.photo-button span {
    position: absolute;
    right: 4px;
    bottom: 4px;
    padding: 2px 5px;
    color: #fff;
    background: rgba(0, 0, 0, 0.62);
    border-radius: 5px;
    font-size: 0.64rem;
}

.photo-empty {
    color: var(--muted);
    font-size: 0.85rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 9px;
    color: var(--primary);
    background: var(--primary-soft);
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 800;
}

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 18px;
    padding: 30px;
    background: rgba(8, 15, 24, 0.92);
}

.lightbox[hidden] {
    display: none;
}

.lightbox-figure {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 100%;
    max-height: 100%;
    margin: 0;
}

.lightbox-figure img {
    max-width: min(1200px, 80vw);
    max-height: 82vh;
    object-fit: contain;
    background: #111827;
    border-radius: 12px;
    box-shadow: 0 18px 70px rgba(0, 0, 0, 0.45);
}

.lightbox-figure figcaption {
    margin-top: 12px;
    color: #fff;
    text-align: center;
    font-size: 0.9rem;
}

.lightbox-close,
.lightbox-nav {
    border: 0;
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
    cursor: pointer;
}

.lightbox-close {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 46px;
    height: 46px;
    border-radius: 999px;
    font-size: 2rem;
    line-height: 1;
}

.lightbox-nav {
    width: 48px;
    height: 70px;
    border-radius: 12px;
    font-size: 2.5rem;
}

.dt-buttons {
    margin-bottom: 12px;
}

.dt-button {
    border-radius: 9px !important;
}

@media (max-width: 1250px) {
    .filter-panel {
        grid-template-columns: repeat(3, minmax(160px, 1fr));
    }
}

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

    .app-header {
        flex-direction: column;
    }

    .filter-panel {
        grid-template-columns: repeat(2, minmax(140px, 1fr));
    }

    .detail-wrap {
        padding-left: 0;
    }
}

@media (max-width: 560px) {
    .app-shell {
        width: min(100% - 18px, 1800px);
        padding-top: 10px;
    }

    .app-header {
        padding: 22px;
        border-radius: 16px;
    }

    .stats-grid,
    .filter-panel {
        grid-template-columns: 1fr;
    }

    .lightbox {
        grid-template-columns: 1fr;
        padding: 14px;
    }

    .lightbox-nav {
        position: absolute;
        bottom: 18px;
    }

    .lightbox-prev {
        left: 18px;
    }

    .lightbox-next {
        right: 18px;
    }

    .lightbox-figure img {
        max-width: 96vw;
        max-height: 78vh;
    }
}
