:root {
    color-scheme: light;
    --bg: #f6f7f9;
    --panel: #ffffff;
    --text: #17202a;
    --muted: #667085;
    --line: #d9dee7;
    --primary: #0f766e;
    --primary-dark: #0b5f59;
    --secondary: #274c77;
    --danger-bg: #fff0f0;
    --danger: #a61b1b;
    --success-bg: #ecfdf3;
    --success: #0f6b3d;
    --shadow: 0 12px 30px rgba(18, 38, 63, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 15px;
    line-height: 1.45;
}

a {
    color: inherit;
}

img {
    display: block;
    max-width: 100%;
}

code {
    padding: 3px 6px;
    border-radius: 6px;
    background: #eef2f6;
    color: #1f3447;
    font-size: 0.9rem;
}

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: #eef3f1;
}

.login-panel,
.empty-state,
.upload-form,
.notes-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.login-panel {
    width: min(100%, 420px);
    padding: 30px;
}

.brand-mark {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    margin-bottom: 18px;
    border-radius: 8px;
    background: var(--primary);
    color: #ffffff;
    font-weight: 700;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 6px;
    font-size: clamp(1.5rem, 2vw, 2rem);
    line-height: 1.2;
}

h2 {
    font-size: 1.05rem;
}

.muted {
    color: var(--muted);
}

.eyebrow {
    margin-bottom: 4px;
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 22px min(4vw, 42px);
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}

.topbar h1 {
    margin-bottom: 0;
}

.topbar-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.page-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 24px auto 44px;
}

.narrow-shell {
    width: min(780px, calc(100% - 32px));
}

.button {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 14px;
    border: 1px solid transparent;
    border-radius: 7px;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

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

.button-primary {
    background: var(--primary);
    color: #ffffff;
}

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

.button-secondary {
    border-color: var(--line);
    background: #ffffff;
    color: var(--secondary);
}

.button-danger {
    border-color: #efb5b5;
    background: #ffffff;
    color: var(--danger);
}

.button-danger:hover {
    background: var(--danger-bg);
}

.button-ghost {
    background: transparent;
    color: var(--muted);
}

.button-small {
    min-height: 34px;
    padding: 7px 10px;
    font-size: 0.9rem;
}

.form-stack,
.upload-form {
    display: grid;
    gap: 18px;
}

.upload-form {
    padding: 24px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

label {
    display: grid;
    gap: 7px;
    color: #344054;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 11px 12px;
    background: #ffffff;
    color: var(--text);
    font: inherit;
    font-weight: 400;
}

input:focus,
select:focus,
textarea:focus,
button:focus,
a:focus {
    outline: 3px solid rgba(15, 118, 110, 0.2);
    outline-offset: 2px;
}

.form-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-top: 1px solid var(--line);
    padding-top: 18px;
}

.form-footer p {
    margin-bottom: 0;
}

.alert {
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: 8px;
    font-weight: 700;
}

.alert-error {
    border: 1px solid #ffd0d0;
    background: var(--danger-bg);
    color: var(--danger);
}

.alert-success {
    border: 1px solid #b8e7c9;
    background: var(--success-bg);
    color: var(--success);
}

.summary-strip,
.detail-meta {
    display: grid;
    gap: 1px;
    overflow: hidden;
    margin-bottom: 20px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--line);
}

.summary-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.detail-meta {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.summary-strip > div,
.detail-meta > div {
    min-width: 0;
    padding: 18px;
    background: #ffffff;
}

.summary-number {
    display: block;
    font-size: 1.5rem;
    font-weight: 800;
}

.summary-label,
.meta-label {
    display: block;
    color: var(--muted);
    font-size: 0.85rem;
}

.empty-state {
    padding: 34px;
    text-align: center;
}

.filter-panel {
    margin-bottom: 18px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: var(--shadow);
}

.filter-form {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(160px, 220px) minmax(160px, 220px) auto;
    gap: 14px;
    align-items: end;
}

.filter-actions {
    display: flex;
    gap: 10px;
}

.inline-form {
    display: inline-flex;
    margin: 0;
}

.sort-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: inherit;
    text-decoration: none;
}

.sort-link span {
    min-width: 34px;
    color: var(--primary);
    font-size: 0.72rem;
    font-weight: 800;
}

.sort-link:not(.is-active) span {
    display: none;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: var(--shadow);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1180px;
}

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

.data-table th {
    background: #f9fafb;
    color: #475467;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0;
}

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

.thumb-button,
.image-card-button {
    display: block;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
}

.thumb-button img {
    width: 76px;
    height: 58px;
    border: 1px solid var(--line);
    border-radius: 8px;
    object-fit: cover;
    background: #f2f4f7;
}

.notes-cell {
    max-width: 230px;
    color: #475467;
}

.action-cell {
    white-space: nowrap;
}

.action-cell .inline-form {
    vertical-align: middle;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 18px;
}

.pagination a {
    min-width: 38px;
    padding: 8px 11px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #ffffff;
    color: var(--secondary);
    text-align: center;
    text-decoration: none;
    font-weight: 700;
}

.pagination a.is-active {
    border-color: var(--primary);
    background: var(--primary);
    color: #ffffff;
}

.notes-panel {
    margin-bottom: 20px;
    padding: 20px;
}

.notes-panel p {
    margin-bottom: 0;
    color: #344054;
}

.image-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.image-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.image-card-button {
    width: 100%;
}

.image-card img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    background: #f2f4f7;
}

.image-card h2 {
    margin: 0;
    padding: 14px;
}

.no-scroll {
    overflow: hidden;
}

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 72px 74px 44px;
    background: rgba(12, 18, 27, 0.92);
}

.lightbox.is-open {
    display: flex;
}

.lightbox-frame {
    display: grid;
    width: min(100%, 1100px);
    height: 100%;
    margin: 0;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 14px;
}

.lightbox-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.lightbox-caption {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    color: #ffffff;
    font-weight: 700;
}

.lightbox-count {
    color: #cfd6df;
}

.lightbox-close,
.lightbox-nav {
    position: fixed;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    font: inherit;
    font-size: 1.6rem;
    cursor: pointer;
}

.lightbox-close {
    top: 18px;
    right: 18px;
    width: 44px;
    height: 44px;
}

.lightbox-nav {
    top: 50%;
    width: 46px;
    height: 60px;
    transform: translateY(-50%);
}

.lightbox-prev {
    left: 18px;
}

.lightbox-next {
    right: 18px;
}

@media (max-width: 820px) {
    .topbar,
    .form-footer {
        align-items: stretch;
        flex-direction: column;
    }

    .topbar-actions {
        justify-content: flex-start;
    }

    .filter-form {
        grid-template-columns: 1fr;
    }

    .filter-actions {
        justify-content: flex-start;
    }

    .form-grid,
    .summary-strip,
    .detail-meta,
    .image-grid {
        grid-template-columns: 1fr;
    }

    .table-wrap {
        overflow: visible;
        border: 0;
        background: transparent;
        box-shadow: none;
    }

    .data-table {
        min-width: 0;
        border-collapse: separate;
        border-spacing: 0 14px;
    }

    .data-table thead {
        display: none;
    }

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

    .data-table tr {
        overflow: hidden;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: #ffffff;
        box-shadow: var(--shadow);
    }

    .data-table td {
        display: grid;
        grid-template-columns: 145px minmax(0, 1fr);
        gap: 12px;
        border-bottom: 1px solid var(--line);
    }

    .data-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-weight: 700;
    }

    .notes-cell {
        max-width: none;
    }

    .lightbox {
        padding: 68px 12px 28px;
    }

    .lightbox-nav {
        top: auto;
        bottom: 24px;
        transform: none;
    }

    .lightbox-prev {
        left: 14px;
    }

    .lightbox-next {
        right: 14px;
    }

    .lightbox-caption {
        padding: 0 64px;
    }
}

@media (max-width: 520px) {
    .page-shell,
    .narrow-shell {
        width: min(100% - 20px, 1180px);
        margin-top: 14px;
    }

    .login-panel,
    .upload-form {
        padding: 20px;
    }

    .button {
        width: 100%;
    }

    .data-table td {
        grid-template-columns: 1fr;
    }

    .action-cell {
        display: grid;
        gap: 8px;
        white-space: normal;
    }

    .action-cell .inline-form,
    .action-cell .inline-form .button {
        width: 100%;
    }
}
