:root {
    color-scheme: light;
    --bg: #f5f7fa;
    --panel: #ffffff;
    --text: #18202a;
    --muted: #647282;
    --line: #d8e0e8;
    --primary: #176b87;
    --primary-dark: #0e536a;
    --danger: #b42318;
    --success-bg: #e9f7ef;
    --success-text: #146c43;
    --error-bg: #fdecec;
    --error-text: #9f1f18;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

h1,
h2,
p {
    margin: 0;
}

h1 {
    font-size: 1.35rem;
    font-weight: 700;
}

h2 {
    margin-bottom: 16px;
    font-size: 1.1rem;
}

.topbar p,
.muted {
    color: var(--muted);
}

main {
    width: min(1120px, calc(100% - 36px));
    margin: 28px auto;
}

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

.panel {
    margin-bottom: 18px;
    padding: 20px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 1px 2px rgb(16 24 40 / 6%);
}

.auth-panel {
    max-width: 440px;
    margin-inline: auto;
}

.stack {
    display: grid;
    gap: 14px;
}

label {
    display: grid;
    gap: 7px;
    font-weight: 600;
}

input,
select,
button,
.button {
    min-height: 42px;
    border-radius: 6px;
    font: inherit;
}

input,
select {
    width: 100%;
    padding: 9px 11px;
    color: var(--text);
    background: #ffffff;
    border: 1px solid #b8c4d0;
}

button,
.button {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 14px;
    color: #ffffff;
    background: var(--primary);
    border: 1px solid var(--primary);
    cursor: pointer;
    font-weight: 700;
    text-decoration: none;
}

button > span,
.button > span {
    position: relative;
    z-index: 1;
}

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

.secondary {
    color: var(--text);
    background: #ffffff;
    border-color: #b8c4d0;
}

.secondary:hover {
    color: var(--text);
    background: #edf2f7;
    border-color: #aab7c4;
}

.danger {
    background: var(--danger);
    border-color: var(--danger);
}

.upload-button {
    overflow: hidden;
}

.upload-button[disabled] {
    cursor: wait;
    opacity: 1;
}

.upload-button[disabled]:hover {
    background: var(--primary);
    border-color: var(--primary);
}

.upload-progress-fill {
    position: absolute;
    inset: 0 auto 0 0;
    width: var(--upload-progress, 0%);
    background: #104d5f;
    transition: width 140ms linear;
}

.inflight-list {
    display: grid;
    gap: 14px;
}

.inflight-item {
    display: grid;
    gap: 8px;
}

.inflight-meta {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
}

.inflight-meta strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.inflight-meta span {
    flex: none;
    color: var(--muted);
    font-size: .9rem;
}

.inflight-bar {
    height: 10px;
    overflow: hidden;
    background: #dbe6ed;
    border-radius: 999px;
}

.inflight-bar span {
    display: block;
    height: 100%;
    background: var(--primary);
    transition: width 180ms linear;
}

.alert {
    margin-bottom: 18px;
    padding: 12px 14px;
    border-radius: 6px;
    font-weight: 600;
}

.success {
    color: var(--success-text);
    background: var(--success-bg);
}

.error {
    color: var(--error-text);
    background: var(--error-bg);
}

.generated {
    display: grid;
    gap: 5px;
    margin-bottom: 14px;
    padding: 14px;
    background: #edf7fa;
    border: 1px solid #b8dce6;
    border-radius: 6px;
}

.generated span {
    color: var(--muted);
    font-size: .9rem;
    font-weight: 700;
}

.generated strong {
    overflow-wrap: anywhere;
    font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
    font-size: 1.15rem;
}

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

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

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

th {
    color: var(--muted);
    font-size: .83rem;
    text-transform: uppercase;
}

.actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    min-width: 210px;
}

.actions form {
    margin: 0;
}

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

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

    .inflight-meta {
        display: grid;
        gap: 3px;
    }

    .inflight-meta span {
        white-space: normal;
    }

    .topbar form,
    .topbar button,
    .actions a,
    .actions button {
        width: 100%;
    }
}
