:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --border: #d9e0e7;
    --border-strong: #b7c2cc;
    --text: #17202a;
    --muted: #687381;
    --primary: #176b5d;
    --primary-hover: #12564b;
    --success: #1f7a4d;
    --danger: #b42318;
    --warning-bg: #fff7df;
    --warning-border: #f1cf7a;
    --shadow: 0 16px 40px rgba(23, 32, 42, 0.08);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    padding: 32px;
}

button,
input {
    font: inherit;
}

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

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 24px;
    margin-bottom: 24px;
}

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

.eyebrow {
    margin: 0 0 6px;
    color: var(--muted);
    font-size: 13px;
}

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

h1 {
    margin-bottom: 0;
    font-size: 34px;
    line-height: 1.15;
    font-weight: 700;
}

h2 {
    margin-bottom: 0;
    font-size: 18px;
    line-height: 1.3;
}

h3 {
    margin-bottom: 6px;
    font-size: 18px;
    line-height: 1.35;
}

.service-state {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    background: var(--surface);
    font-size: 14px;
}

.state-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px 6px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    background: var(--surface);
    font-size: 14px;
}

.user-chip form {
    margin: 0;
}

.user-chip button {
    min-height: 28px;
    padding: 0 10px;
    border: 0;
    border-radius: 999px;
    color: var(--text);
    background: var(--surface-soft);
    cursor: pointer;
}

.user-chip button:hover {
    background: #e7ecf1;
}

.workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 420px;
    gap: 18px;
    align-items: start;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 24px;
}

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

.muted {
    color: var(--muted);
    font-size: 14px;
}

.dropzone {
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr) auto;
    gap: 18px;
    align-items: center;
    min-height: 180px;
    padding: 28px;
    border: 1.5px dashed var(--border-strong);
    border-radius: 8px;
    background: var(--surface-soft);
    cursor: pointer;
    transition: border-color 0.18s ease, background 0.18s ease;
}

.dropzone:hover,
.dropzone.dragover {
    border-color: var(--primary);
    background: #f1f7f5;
}

.file-mark {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    border-radius: 8px;
    color: var(--primary);
    background: #e7f1ee;
}

.file-mark svg {
    width: 28px;
    height: 28px;
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    line-height: 1;
    transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.btn:disabled {
    cursor: wait;
    opacity: 0.65;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.btn-secondary,
.btn-plain {
    color: var(--text);
    background: var(--surface);
    border-color: var(--border);
}

.btn-secondary:hover:not(:disabled),
.btn-plain:hover:not(:disabled) {
    border-color: var(--border-strong);
    background: var(--surface-soft);
}

.upload-progress {
    margin-top: 18px;
}

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

.progress-fill {
    width: 0%;
    height: 100%;
    border-radius: inherit;
    background: var(--primary);
    transition: width 0.24s ease;
}

#upload-status {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 14px;
}

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

.status-badge.processing,
.status-badge.pending {
    background: #fff1d6;
    color: #8a4b08;
}

.status-badge.completed {
    background: #dff3e9;
    color: var(--success);
}

.status-badge.failed,
.status-badge.expired {
    background: #fde8e6;
    color: var(--danger);
}

.empty-state {
    min-height: 250px;
    display: grid;
    place-items: center;
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--muted);
    text-align: center;
    background: var(--surface-soft);
}

.empty-state p {
    max-width: 280px;
    margin-bottom: 0;
    line-height: 1.6;
}

.progress-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 46px;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
}

#progress-text {
    color: var(--muted);
    font-weight: 700;
    text-align: right;
}

.status-message {
    margin-bottom: 14px;
    line-height: 1.55;
}

.progress-messages {
    max-height: 230px;
    overflow-y: auto;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-soft);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 13px;
}

.message-item {
    padding: 6px 0;
    color: var(--muted);
    border-bottom: 1px solid #e7ecf1;
}

.message-item:last-child {
    border-bottom: 0;
}

.result-section,
.error-section {
    padding-top: 4px;
}

.result-summary {
    display: grid;
    gap: 6px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-soft);
}

.result-label {
    color: var(--muted);
    font-size: 14px;
}

.result-summary strong {
    font-size: 24px;
}

.notice {
    margin-top: 14px;
    padding: 12px 14px;
    border: 1px solid var(--warning-border);
    border-radius: 8px;
    background: var(--warning-bg);
    color: #6f4c00;
    line-height: 1.5;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

.error-section {
    padding: 16px;
    border: 1px solid #f0b8b2;
    border-radius: 8px;
    background: #fff8f7;
}

.error-section p {
    color: var(--danger);
    line-height: 1.55;
}

.auth-body {
    display: grid;
    place-items: center;
    min-height: 100vh;
}

.auth-shell {
    width: min(420px, 100%);
}

.auth-card {
    padding: 30px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.auth-card h1 {
    margin-bottom: 8px;
}

.auth-subtitle {
    margin-bottom: 24px;
    color: var(--muted);
}

.auth-form {
    display: grid;
    gap: 16px;
}

.auth-form label {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
}

.auth-form input {
    width: 100%;
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    background: var(--surface);
}

.auth-form input:focus {
    outline: 2px solid rgba(23, 107, 93, 0.18);
    border-color: var(--primary);
}

.auth-error {
    margin-bottom: 16px;
    padding: 10px 12px;
    border: 1px solid #f0b8b2;
    border-radius: 6px;
    color: var(--danger);
    background: #fff8f7;
}

[hidden] {
    display: none !important;
}

@media (max-width: 860px) {
    body {
        padding: 18px;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

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

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

    .dropzone {
        grid-template-columns: 1fr;
        text-align: left;
    }

    .actions,
    .btn {
        width: 100%;
    }
}
