:root {
    color-scheme: light;
    --bg: #f6f4ef;
    --panel: #ffffff;
    --panel-strong: #fff8f2;
    --ink: #1c1d1b;
    --muted: #686d64;
    --line: #ded9ce;
    --orange: #f05a16;
    --orange-dark: #cf4610;
    --green: #398533;
    --green-soft: #e8f4df;
    --red: #b42318;
    --red-soft: #fff0ed;
    --shadow: 0 18px 45px rgba(41, 35, 25, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
    font-family: Onest, "Segoe UI", system-ui, sans-serif;
    letter-spacing: 0;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background:
        linear-gradient(180deg, rgba(255,255,255,0.92), rgba(246,244,239,0.94)),
        repeating-linear-gradient(90deg, rgba(240,90,22,0.04) 0 1px, transparent 1px 104px);
}

button,
input {
    font: inherit;
}

button {
    min-height: 44px;
    border: 0;
    border-radius: 8px;
    background: var(--orange);
    color: #fff;
    font-weight: 750;
    cursor: pointer;
    touch-action: manipulation;
    transition: background-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

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

button:active {
    transform: translateY(1px);
}

button:focus-visible,
input:focus-visible {
    outline: 3px solid rgba(57, 133, 51, 0.34);
    outline-offset: 2px;
}

button:disabled {
    cursor: wait;
    opacity: 0.72;
}

input {
    min-height: 44px;
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0 12px;
    background: #fff;
    color: var(--ink);
}

input::placeholder {
    color: #9b988e;
}

.skip-link {
    position: absolute;
    left: 16px;
    top: 12px;
    z-index: 10;
    transform: translateY(-140%);
    background: var(--ink);
    color: #fff;
    padding: 8px 10px;
    border-radius: 8px;
}

.skip-link:focus {
    transform: translateY(0);
}

.shell {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: max(24px, env(safe-area-inset-top)) 0 40px;
}

.login-view {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px 0;
}

.login-panel {
    width: min(420px, 100%);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 28px;
    box-shadow: var(--shadow);
}

.brand-mark {
    width: 72px;
    height: 52px;
    display: grid;
    place-items: center;
    margin-bottom: 20px;
    border-radius: 8px;
    background: var(--orange);
    color: #fff;
    font-weight: 900;
    font-size: 30px;
}

h1,
h2,
p {
    margin: 0;
}

h1 {
    font-size: clamp(30px, 5vw, 54px);
    line-height: 0.98;
    text-wrap: balance;
}

h2 {
    font-size: 24px;
    line-height: 1.1;
}

.login-form {
    display: grid;
    gap: 12px;
    margin-top: 24px;
}

.login-form button,
.submit-row button {
    padding: 0 22px;
}

.form-error {
    min-height: 22px;
    margin-top: 12px;
    color: var(--red);
}

.app-view {
    display: grid;
    gap: 18px;
}

.topbar {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
    padding: 14px 0 8px;
}

.kicker {
    margin-bottom: 8px;
    color: var(--green);
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
}

.tabs {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.tab,
.ghost-button,
.secondary-button {
    min-height: 40px;
    padding: 0 14px;
    background: #fff;
    color: var(--ink);
    border: 1px solid var(--line);
}

.tab:hover,
.ghost-button:hover,
.secondary-button:hover {
    background: var(--panel-strong);
}

.tab.is-active {
    background: var(--green);
    border-color: var(--green);
    color: #fff;
}

.panel {
    background: rgba(255,255,255,0.86);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 18px;
}

.slot-list {
    display: grid;
    gap: 10px;
}

.slot-row {
    display: grid;
    grid-template-columns: 74px minmax(156px, 1fr) minmax(160px, 210px) minmax(116px, 0.7fr) auto;
    gap: 10px;
    align-items: center;
    min-width: 0;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.slot-preview {
    width: 72px;
    height: 72px;
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 1px dashed #cfc8bb;
    border-radius: 8px;
    background: #fbfaf7;
    color: var(--muted);
    font-size: 13px;
}

.slot-preview img {
    width: 72px;
    height: 72px;
    object-fit: contain;
    background: #fff;
}

.file-control,
.id-control {
    display: grid;
    gap: 6px;
    min-width: 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.file-control input {
    padding: 9px;
}

.slot-state {
    min-width: 0;
    color: var(--muted);
    font-size: 13px;
    overflow-wrap: anywhere;
}

.slot-row.is-ready .slot-state {
    color: var(--green);
    font-weight: 800;
}

.remove-slot {
    min-height: 38px;
    padding: 0 12px;
    background: #fff;
    border: 1px solid var(--line);
    color: var(--red);
}

.remove-slot:hover {
    background: var(--red-soft);
}

.toolbar,
.submit-row,
.history-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.soft-message,
.submit-status {
    min-height: 22px;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.sent-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-top: 16px;
    padding: 14px;
    border: 1px solid rgba(57, 133, 51, 0.28);
    border-radius: 8px;
    background: var(--green-soft);
    color: #214d20;
    font-weight: 800;
}

.history-panel {
    min-height: 320px;
}

.history-list {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.history-item {
    display: grid;
    grid-template-columns: 62px minmax(140px, 1fr) 120px 170px minmax(120px, 0.8fr);
    gap: 12px;
    align-items: center;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    min-width: 0;
}

.history-thumb {
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #fbfaf7;
    color: var(--muted);
    font-size: 12px;
    overflow: hidden;
}

.history-thumb img {
    width: 58px;
    height: 58px;
    object-fit: contain;
}

.history-main,
.history-meta,
.history-time,
.history-status {
    min-width: 0;
    overflow-wrap: anywhere;
}

.history-main strong {
    display: block;
    margin-bottom: 3px;
}

.history-meta,
.history-time {
    color: var(--muted);
    font-size: 13px;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 9px;
    border-radius: 999px;
    background: #f1eee7;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.badge.done {
    background: var(--green-soft);
    color: var(--green);
}

.badge.error {
    background: var(--red-soft);
    color: var(--red);
}

.empty-history {
    padding: 32px 12px;
    color: var(--muted);
    text-align: center;
}

[hidden] {
    display: none !important;
}

@media (prefers-reduced-motion: reduce) {
    button {
        transition: none;
    }
}

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

    .tabs {
        justify-content: flex-start;
    }

    .slot-row {
        grid-template-columns: 74px 1fr;
    }

    .id-control,
    .slot-state,
    .remove-slot {
        grid-column: 1 / -1;
    }

    .history-item {
        grid-template-columns: 62px 1fr;
    }

    .history-time,
    .history-status {
        grid-column: 1 / -1;
    }
}

@media (max-width: 520px) {
    .shell {
        width: min(100% - 20px, 1120px);
        padding-top: 14px;
    }

    .panel,
    .login-panel {
        padding: 14px;
    }

    .slot-row {
        grid-template-columns: 1fr;
    }

    .slot-preview {
        width: 100%;
        height: 150px;
    }

    .slot-preview img {
        width: 100%;
        height: 150px;
    }

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

