:root {
    --bg: #f4f6f8;
    --panel: #ffffff;
    --text: #17202a;
    --muted: #667085;
    --border: #d8dee6;
    --border-strong: #bcc6d2;
    --primary: #1f5eff;
    --primary-hover: #174bd2;
    --danger: #b42318;
    --danger-bg: #fff1f0;
    --success: #067647;
    --success-bg: #ecfdf3;
    --working: #175cd3;
    --working-bg: #eff8ff;
    --shadow: 0 10px 28px rgba(16, 24, 40, 0.07);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
}

a {
    color: inherit;
}

.page-shell {
    width: min(1050px, calc(100% - 32px));
    margin: 0 auto;
    padding: 38px 0 60px;
}

.page-shell-wide {
    width: min(1320px, calc(100% - 32px));
}

.page-header {
    margin-bottom: 24px;
}

.page-header-actions {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
}

.eyebrow {
    margin: 0 0 5px;
    color: var(--primary);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

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

h1 {
    margin-bottom: 8px;
    font-size: clamp(2rem, 4vw, 3.25rem);
    letter-spacing: -0.04em;
}

h2 {
    margin-bottom: 5px;
    font-size: 1.3rem;
}

h3 {
    margin: 0;
}

.muted {
    margin-bottom: 0;
    color: var(--muted);
    line-height: 1.5;
}

.panel {
    margin-bottom: 24px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.panel-heading {
    padding: 22px 24px;
    border-bottom: 1px solid var(--border);
}

.site-form {
    padding: 24px;
}

.site-form label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
}

.input-row {
    display: flex;
    gap: 10px;
}

input[type="text"] {
    width: 100%;
    min-width: 0;
    height: 46px;
    padding: 0 14px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: #fff;
    color: var(--text);
    font: inherit;
    outline: none;
}

input[type="text"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(31, 94, 255, 0.12);
}

.field-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.82rem;
}

.button {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 0 16px;
    font: inherit;
    font-weight: 750;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: 140ms ease;
}

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

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

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

.button-secondary:hover {
    background: #f8fafc;
}

.button-small {
    min-height: 34px;
    padding: 0 12px;
    font-size: 0.88rem;
}

.alert {
    margin-bottom: 20px;
    border-radius: 12px;
    padding: 13px 15px;
}

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

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

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

th {
    background: #f8fafc;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

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

.site-link {
    color: var(--primary);
    font-weight: 800;
    text-decoration: none;
}

.site-link:hover {
    text-decoration: underline;
}

.table-action {
    width: 1%;
    text-align: right;
}

.empty-state {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 34px 24px;
    color: var(--muted);
}

.empty-state strong {
    color: var(--text);
}

.upload-status {
    min-height: 0;
    margin-bottom: 16px;
    border-radius: 12px;
    font-weight: 700;
}

.upload-status:not(:empty) {
    padding: 12px 14px;
}

.upload-status-success {
    border: 1px solid #abefc6;
    background: var(--success-bg);
    color: var(--success);
}

.upload-status-error {
    border: 1px solid #fecdca;
    background: var(--danger-bg);
    color: var(--danger);
}

.upload-status-working {
    border: 1px solid #b2ddff;
    background: var(--working-bg);
    color: var(--working);
}

.photo-grid {
    padding: 0 24px 24px;
}

.photo-row {
    padding: 22px 0;
    border-bottom: 1px solid var(--border);
}

.photo-row:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.photo-row-heading {
    margin-bottom: 13px;
}

.photo-row-heading h3 {
    font-size: 1rem;
}

.photo-blocks {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
    gap: 14px;
}

.photo-card,
.drop-zone {
    position: relative;
    overflow: hidden;
    aspect-ratio: 4 / 3;
    border-radius: 14px;
}

.photo-card {
    border: 1px solid var(--border);
    background: #eef2f6;
}

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

.photo-label {
    position: absolute;
    left: 8px;
    bottom: 8px;
    min-width: 32px;
    border-radius: 999px;
    padding: 5px 9px;
    background: rgba(17, 24, 39, 0.82);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 800;
    text-align: center;
    backdrop-filter: blur(5px);
}

.drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 112px;
    border: 2px dashed var(--border-strong);
    background: #fbfcfe;
    color: var(--muted);
    cursor: pointer;
    outline: none;
    transition: 150ms ease;
}

.drop-zone:hover,
.drop-zone:focus,
.drop-zone.drag-over {
    border-color: var(--primary);
    background: #f2f6ff;
    color: var(--primary);
    transform: translateY(-1px);
}

.drop-zone.uploading {
    pointer-events: none;
    opacity: 0.55;
}

.drop-icon {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    margin-bottom: 7px;
    border-radius: 50%;
    background: #e8eefc;
    color: var(--primary);
    font-size: 1.5rem;
    line-height: 1;
}

.drop-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 0 8px;
    text-align: center;
}

.drop-text strong {
    color: var(--text);
    font-size: 0.92rem;
}

.drop-text span {
    font-size: 0.8rem;
    font-weight: 700;
}

.drop-text small {
    font-size: 0.72rem;
}

@media (max-width: 700px) {
    .page-shell,
    .page-shell-wide {
        width: min(100% - 20px, 1320px);
        padding-top: 22px;
    }

    .page-header-actions,
    .input-row {
        flex-direction: column;
        align-items: stretch;
    }

    .page-header-actions .button,
    .input-row .button {
        width: 100%;
    }

    .panel-heading,
    .site-form,
    .photo-grid {
        padding-left: 16px;
        padding-right: 16px;
    }

    th,
    td {
        padding: 12px;
    }

    .photo-blocks {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }
}

.panel-heading-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.button-finalize {
    background: #067647;
    color: #fff;
}

.button-finalize:hover:not(:disabled) {
    background: #05603a;
}

.button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.finalized-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    border: 1px solid #abefc6;
    border-radius: 12px;
    padding: 12px 14px;
    background: var(--success-bg);
    color: var(--success);
}

.finalized-banner strong {
    border-radius: 999px;
    padding: 4px 8px;
    background: #d1fadf;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

@media (max-width: 700px) {
    .panel-heading-actions,
    .finalized-banner {
        align-items: stretch;
        flex-direction: column;
    }

    .panel-heading-actions .button-finalize {
        width: 100%;
    }
}

/* Editable photo controls */
.photo-card-editable {
    cursor: grab;
    user-select: none;
    transition: transform 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
}

.photo-card-editable:active {
    cursor: grabbing;
}

.photo-card.dragging {
    opacity: 0.45;
    transform: scale(0.98);
}

.photo-card.swap-target {
    box-shadow: 0 0 0 3px var(--primary), 0 12px 26px rgba(31, 94, 255, 0.18);
    transform: translateY(-2px);
}

.photo-remove {
    position: absolute;
    top: 7px;
    right: 7px;
    z-index: 4;
    display: grid;
    width: 27px;
    height: 27px;
    place-items: center;
    border: 1px solid rgba(180, 35, 24, 0.22);
    border-radius: 50%;
    padding: 0 0 2px;
    background: rgba(255, 255, 255, 0.94);
    color: var(--danger);
    font: inherit;
    font-size: 1.15rem;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 7px rgba(16, 24, 40, 0.18);
    transition: 120ms ease;
}

.photo-remove:hover,
.photo-remove:focus-visible {
    border-color: var(--danger);
    background: var(--danger);
    color: #fff;
    outline: none;
    transform: scale(1.06);
}

.photo-row-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.photo-row-hint {
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 650;
}

@media (max-width: 700px) {
    .photo-row-heading {
        align-items: flex-start;
        flex-direction: column;
        gap: 5px;
    }
}

/* Batch upload */
.batch-launch-panel .panel-heading-actions {
    align-items: center;
}

.batch-form-section {
    padding: 24px;
}

.batch-form-section > label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
}

.site-select {
    width: 100%;
    min-width: 0;
    height: 46px;
    padding: 0 42px 0 14px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: #fff;
    color: var(--text);
    font: inherit;
    outline: none;
}

.site-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(31, 94, 255, 0.12);
}

.site-select:disabled {
    background: #f3f4f6;
    color: var(--muted);
}

.batch-hidden {
    display: none !important;
}

.batch-drop-zone {
    display: flex;
    min-height: 190px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 7px;
    border: 2px dashed var(--border-strong);
    border-radius: 16px;
    background: #fbfcfe;
    color: var(--muted);
    text-align: center;
    cursor: pointer;
    transition: 150ms ease;
}

.batch-drop-zone:hover,
.batch-drop-zone:focus,
.batch-drop-zone.drag-over {
    border-color: var(--primary);
    background: #f2f6ff;
    color: var(--primary);
    outline: none;
}

.batch-drop-zone.batch-disabled {
    pointer-events: none;
    opacity: 0.55;
}

.batch-drop-zone strong {
    color: var(--text);
    font-size: 1rem;
}

.batch-drop-zone small {
    font-size: 0.78rem;
}

.batch-drop-icon {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border-radius: 50%;
    background: #e8eefc;
    color: var(--primary);
    font-size: 1.7rem;
    line-height: 1;
}

.batch-selection-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 18px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #f8fafc;
}

.batch-selection-summary > div {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 3px;
}

.batch-file-list {
    display: grid;
    gap: 7px;
    margin-top: 12px;
}

.batch-file-item {
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    min-height: 42px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
}

.batch-file-item > strong {
    display: inline-grid;
    min-height: 28px;
    place-items: center;
    border-radius: 999px;
    background: #eef2ff;
    color: var(--primary);
    font-size: 0.82rem;
}

.batch-file-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.9rem;
}

.batch-file-size {
    color: var(--muted);
    font-size: 0.82rem;
    white-space: nowrap;
}

.batch-progress-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 18px;
}

.batch-progress-track {
    flex: 1;
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #e6eaf0;
}

.batch-progress-bar {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--primary);
    transition: width 180ms ease;
}

.batch-progress-wrap > span {
    min-width: 54px;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
    text-align: right;
}

.batch-upload-button {
    width: 100%;
    margin-top: 18px;
}

.batch-complete {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 18px;
    padding: 24px;
}

.batch-complete h2 {
    margin-bottom: 4px;
}

.batch-complete-icon {
    display: grid;
    width: 46px;
    height: 46px;
    place-items: center;
    border-radius: 50%;
    background: var(--success-bg);
    color: var(--success);
    font-size: 1.4rem;
    font-weight: 900;
}

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

.batch-reservation-banner {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-bottom: 16px;
    padding: 13px 15px;
    border: 1px solid #fedf89;
    border-radius: 12px;
    background: #fffaeb;
    color: #93370d;
}

.photo-row-reserved {
    background: linear-gradient(90deg, rgba(255, 250, 235, 0.55), transparent 45%);
}

.reserved-row-badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    margin-left: 10px;
    padding: 0 9px;
    border-radius: 999px;
    background: #fffaeb;
    color: #93370d;
    font-size: 0.72rem;
    font-weight: 800;
}

.reserved-row-block {
    display: flex;
    aspect-ratio: 4 / 3;
    min-height: 112px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 5px;
    border: 2px dashed #fdb022;
    border-radius: 14px;
    background: #fffaeb;
    color: #93370d;
    text-align: center;
}

.reserved-row-block span {
    max-width: 180px;
    padding: 0 8px;
    font-size: 0.74rem;
    line-height: 1.35;
}

.reserved-row-icon {
    font-size: 1.25rem;
}

@media (max-width: 700px) {
    .batch-selection-summary,
    .batch-complete,
    .batch-complete-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .batch-complete {
        display: flex;
    }

    .batch-complete-actions .button {
        width: 100%;
    }

    .batch-file-item {
        grid-template-columns: 48px minmax(0, 1fr);
    }

    .batch-file-size {
        grid-column: 2;
    }
}

.field-help {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 0.82rem;
}


.panel-footer-actions {
    display: flex;
    justify-content: center;
    padding: 0 24px 24px;
}

.button-download {
    background: #0f766e;
    color: #fff;
}

.button-download:hover {
    background: #0b5f59;
}

@media (max-width: 700px) {
    .panel-footer-actions {
        padding-left: 16px;
        padding-right: 16px;
    }

    .panel-footer-actions .button {
        width: 100%;
    }
}


.photo-card img.photo-image-retrying {
    opacity: 0.6;
}

.photo-card img.photo-image-failed {
    opacity: 0.35;
    cursor: pointer;
}

/* Finalize processing overlay */
.finalize-overlay[hidden] {
    display: none !important;
}

.finalize-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(4px);
}

body.finalize-in-progress {
    overflow: hidden;
}

.finalize-progress-card {
    width: min(560px, 100%);
    border-radius: 20px;
    padding: 30px;
    background: #fff;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.3);
    text-align: center;
}

.finalize-progress-icon {
    display: grid;
    width: 54px;
    height: 54px;
    place-items: center;
    margin: 0 auto 14px;
    border-radius: 50%;
    background: #e8f8ef;
    color: #087443;
    font-size: 1.6rem;
    font-weight: 900;
}

.finalize-progress-card h2 {
    margin-bottom: 8px;
}

.finalize-progress-message {
    min-height: 24px;
    margin-bottom: 20px;
    color: #475467;
    font-weight: 650;
}

.finalize-progress-track {
    width: 100%;
    height: 18px;
    overflow: hidden;
    border-radius: 999px;
    background: #e5e7eb;
}

.finalize-progress-bar {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: #087443;
    transition: width 180ms ease;
}

.finalize-progress-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 10px;
    color: #475467;
    font-size: 0.9rem;
}

.finalize-progress-meta strong {
    color: #101828;
    font-size: 1rem;
}

.finalize-progress-warning {
    margin: 22px 0 0;
    border: 1px solid #fedf89;
    border-radius: 12px;
    padding: 12px 14px;
    background: #fffaeb;
    color: #93370d;
    font-size: 0.88rem;
    font-weight: 700;
    line-height: 1.45;
}

.finalize-overlay.finalize-complete .finalize-progress-icon {
    background: #ecfdf3;
    color: #067647;
}

.finalize-overlay.finalize-error .finalize-progress-icon {
    background: #fef3f2;
    color: #b42318;
}

.finalize-overlay.finalize-error .finalize-progress-bar {
    background: #b42318;
}

@media (max-width: 700px) {
    .finalize-overlay {
        padding: 14px;
    }

    .finalize-progress-card {
        padding: 24px 18px;
    }
}


/* MyStage branding */
.brand-header {
    display: flex;
    align-items: center;
    gap: 24px;
}
.company-logo {
    display: block;
    width: 170px;
    height: auto;
    max-height: 132px;
    object-fit: contain;
    flex: 0 0 auto;
}
.brand-header > div {
    min-width: 0;
}
.brand-header h1 {
    margin-bottom: 8px;
}

/* User-entered LOT reservation */
.batch-reserve-grid {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(150px, 220px) auto;
    gap: 14px;
    align-items: end;
}
.batch-reserve-grid label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
}
.lot-number-input {
    width: 100%;
    height: 46px;
    padding: 0 14px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: #fff;
    color: var(--text);
    font: inherit;
    outline: none;
}
.lot-number-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(31, 94, 255, 0.12);
}
.batch-reserve-action .button { height: 46px; }

/* Five-LOT server pagination */
.lot-page-summary {
    padding: 14px 24px 0;
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 700;
}
.lot-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 20px 24px 24px;
    border-top: 1px solid var(--border);
}
.lot-pagination > span {
    color: var(--muted);
    padding: 0 8px;
}
.pagination-disabled {
    pointer-events: none;
    opacity: 0.45;
}

@media (max-width: 760px) {
    .brand-header { align-items: flex-start; flex-direction: column; gap: 12px; }
    .company-logo { width: 145px; max-height: none; }
    .batch-reserve-grid { grid-template-columns: 1fr; }
    .batch-reserve-action .button { width: 100%; }
    .lot-pagination { padding-left: 16px; padding-right: 16px; }
    .lot-page-summary { padding-left: 16px; padding-right: 16px; }
}

/* MyStage authentication */
.account-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}
.account-user {
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 700;
    padding-right: 4px;
}
.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: var(--bg);
}
.login-shell {
    width: min(460px, 100%);
}
.login-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 30px;
}
.login-brand {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-bottom: 26px;
}
.login-logo {
    width: 128px;
    height: auto;
    object-fit: contain;
}
.login-brand h1 {
    margin: 0 0 4px;
    font-size: 2rem;
}
.login-brand p {
    margin: 0;
    color: var(--muted);
}
.login-form,
.password-form {
    display: grid;
    gap: 10px;
}
.login-form label,
.password-form label {
    font-weight: 700;
    margin-top: 4px;
}
.login-form input,
.password-form input {
    width: 100%;
    height: 46px;
    padding: 0 14px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: #fff;
    color: var(--text);
    font: inherit;
    outline: none;
}
.login-form input:focus,
.password-form input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(31, 94, 255, 0.12);
}
.login-button {
    width: 100%;
    margin-top: 10px;
}
.password-form {
    padding: 24px;
}
.alert-success {
    border: 1px solid #abefc6;
    background: #ecfdf3;
    color: #067647;
}
.auth-settings-shell {
    max-width: 760px;
}

@media (max-width: 700px) {
    .account-actions {
        width: 100%;
        justify-content: flex-start;
    }
    .login-card {
        padding: 22px 18px;
    }
    .login-brand {
        align-items: flex-start;
        flex-direction: column;
        gap: 10px;
    }
    .login-logo {
        width: 118px;
    }
}


/* Mobile layout hardening - MyStage login-enabled build */
html {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
}

main,
header,
section,
form,
.panel,
.panel-heading,
.table-wrap,
.photo-grid,
.photo-row,
.photo-blocks,
.batch-form-section,
.login-shell,
.login-card,
.brand-header,
.account-actions {
    min-width: 0;
    max-width: 100%;
}

img,
svg,
video,
canvas {
    max-width: 100%;
}

input,
select,
textarea,
button {
    min-width: 0;
    max-width: 100%;
}

.table-wrap {
    width: 100%;
    -webkit-overflow-scrolling: touch;
}

.login-body {
    min-height: 100vh;
    min-height: 100svh;
    width: 100%;
    padding:
        max(16px, env(safe-area-inset-top))
        max(16px, env(safe-area-inset-right))
        max(16px, env(safe-area-inset-bottom))
        max(16px, env(safe-area-inset-left));
}

.login-shell {
    width: min(460px, 100%);
    margin: 0 auto;
}

.login-card {
    width: 100%;
}

.login-form input,
.password-form input,
.lot-number-input,
.site-select,
input[type="text"],
input[type="password"],
input[type="email"] {
    font-size: 16px;
}

@media (max-width: 760px) {
    .page-shell,
    .page-shell-wide {
        width: 100%;
        max-width: 100%;
        padding:
            max(16px, env(safe-area-inset-top))
            max(12px, env(safe-area-inset-right))
            max(32px, env(safe-area-inset-bottom))
            max(12px, env(safe-area-inset-left));
    }

    .page-header,
    .page-header-actions {
        width: 100%;
    }

    .page-header-actions {
        align-items: stretch;
        flex-direction: column;
        gap: 14px;
    }

    .brand-header {
        width: 100%;
        align-items: flex-start;
        flex-direction: row;
        gap: 14px;
    }

    .company-logo {
        width: clamp(92px, 28vw, 130px);
        max-width: 34%;
        flex: 0 0 auto;
    }

    .brand-header > div {
        flex: 1 1 auto;
        min-width: 0;
    }

    .brand-header h1 {
        font-size: clamp(2rem, 11vw, 2.8rem);
        line-height: 1;
        overflow-wrap: anywhere;
    }

    .brand-header .muted {
        font-size: 0.92rem;
    }

    .account-actions {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .account-user {
        grid-column: 1 / -1;
        padding: 0 0 2px;
    }

    .account-actions .button {
        width: 100%;
    }

    .panel {
        width: 100%;
        border-radius: 14px;
    }

    .panel-heading,
    .site-form,
    .batch-form-section,
    .photo-grid {
        width: 100%;
        padding-left: 14px;
        padding-right: 14px;
    }

    .panel-heading-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .panel-heading-actions > .button,
    .panel-heading-actions > a.button,
    .panel-heading-actions > button.button {
        width: 100%;
    }

    .input-row {
        width: 100%;
        align-items: stretch;
        flex-direction: column;
    }

    .input-row .button {
        width: 100%;
    }

    .batch-reserve-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .batch-reserve-grid > * {
        min-width: 0;
    }

    .batch-selection-summary,
    .batch-complete,
    .batch-complete-actions {
        width: 100%;
    }

    .photo-blocks {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
    }

    .photo-card,
    .drop-zone,
    .reserved-row-block {
        min-width: 0;
        width: 100%;
    }

    .lot-pagination {
        width: 100%;
    }

    .lot-pagination .button {
        flex: 1 1 auto;
    }

    .finalize-progress-card {
        width: 100%;
        max-height: calc(100svh - 28px);
        overflow-y: auto;
    }

    .login-body {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .login-shell {
        width: 100%;
        max-width: 430px;
    }

    .login-card {
        border-radius: 16px;
        padding: 22px 18px;
    }

    .login-brand {
        display: grid;
        grid-template-columns: minmax(88px, 118px) minmax(0, 1fr);
        align-items: center;
        gap: 14px;
        width: 100%;
        margin-bottom: 22px;
    }

    .login-logo {
        width: 100%;
        max-width: 118px;
        height: auto;
    }

    .login-brand h1 {
        font-size: clamp(1.8rem, 9vw, 2.25rem);
        line-height: 1.05;
    }

    .login-brand p {
        font-size: 0.9rem;
        line-height: 1.4;
    }

    .login-form,
    .password-form {
        width: 100%;
    }

    .login-form input,
    .password-form input,
    .site-select,
    .lot-number-input,
    input[type="text"],
    input[type="password"],
    input[type="email"] {
        width: 100%;
        min-height: 48px;
        font-size: 16px;
    }

    .button {
        min-height: 46px;
    }
}

@media (max-width: 420px) {
    .login-body {
        align-items: flex-start;
    }

    .login-card {
        padding: 20px 15px;
    }

    .login-brand {
        grid-template-columns: 82px minmax(0, 1fr);
        gap: 12px;
    }

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

    .company-logo {
        width: 120px;
        max-width: 100%;
    }

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

    .account-user {
        grid-column: auto;
    }

    .photo-blocks {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    th,
    td {
        padding: 10px;
        font-size: 0.9rem;
    }
}
