:root {
    color-scheme: light;
    --bg: #eef2f7;
    --panel: #ffffff;
    --text: #111827;
    --muted: #64748b;
    --border: #d8e0ea;
    --accent: #2563eb;
    --accent-soft: #eff6ff;
    --accent-hover: #1d4ed8;
    --success-bg: #ecfdf3;
    --success-text: #166534;
    --success-border: #bbf7d0;
    --error-bg: #fef2f2;
    --error-text: #991b1b;
    --error-border: #fecaca;
    --loading-bg: #eff6ff;
    --loading-text: #1e40af;
    --loading-border: #bfdbfe;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    color: var(--text);
    background:
        linear-gradient(135deg, rgba(37, 99, 235, 0.12), transparent 34%),
        linear-gradient(315deg, rgba(20, 184, 166, 0.12), transparent 28%),
        var(--bg);
}

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

.upload-panel {
    width: min(100%, 560px);
    padding: 34px;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(255, 255, 255, 0.78);
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.14);
    transition: width 180ms ease;
}

.upload-panel--wide {
    width: min(100%, 960px);
}

.header {
    margin-bottom: 28px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.brand__logo {
    position: relative;
    width: 52px;
    height: 52px;
    flex: 0 0 52px;
    overflow: hidden;
    border-radius: 12px;
    background: #ffffff;
}

.brand__logo img {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 92px;
    height: 92px;
    max-width: none;
    transform: translate(-50%, -50%);
}

.eyebrow {
    margin: 0;
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    font-size: clamp(28px, 5vw, 36px);
    line-height: 1.08;
}

.lead {
    margin: 14px 0 0;
    color: var(--muted);
    font-size: 16px;
    line-height: 1.55;
}

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

.tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 22px;
    padding: 4px;
    border-radius: 10px;
    background: #e9eef5;
}

.tabs__button {
    min-height: 42px;
    padding: 8px 12px;
    border-radius: 7px;
    color: var(--muted);
    background: transparent;
    font-size: 14px;
}

.tabs__button:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.6);
    transform: none;
}

.tabs__button--active,
.tabs__button--active:hover {
    color: var(--text);
    background: #ffffff;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.12);
}

.tabs__button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.tab-panel[hidden] {
    display: none;
}

.manual-form {
    display: grid;
    gap: 18px;
}

.manual-form__field {
    display: grid;
    gap: 8px;
    font-weight: 700;
}

.manual-form input[type="text"] {
    min-height: 48px;
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    background: #ffffff;
    font: inherit;
    font-weight: 400;
}

.manual-form input[type="text"]:focus {
    border-color: var(--accent);
    outline: 2px solid rgba(37, 99, 235, 0.18);
}

.manual-form input[type="file"] {
    max-width: none;
    padding: 12px;
    border: 1px dashed var(--border);
    border-radius: 8px;
    background: #f8fafc;
    font-weight: 400;
}

.file-field {
    display: grid;
    gap: 8px;
    min-height: 156px;
    place-items: center;
    padding: 22px;
    border: 1px dashed var(--border);
    border-radius: 8px;
    background: #f8fafc;
    text-align: center;
    cursor: pointer;
    transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.file-field:hover,
.file-field:focus-within,
.file-field--dragover {
    border-color: var(--accent);
    background: var(--accent-soft);
    box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.18);
}

.file-field__title {
    font-weight: 700;
}

.file-field__hint {
    max-width: 100%;
    overflow: hidden;
    color: var(--muted);
    font-size: 14px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-field__drop-text {
    color: var(--accent);
    font-size: 14px;
    font-weight: 600;
}

input[type="file"] {
    width: 100%;
    max-width: 320px;
    color: var(--muted);
    font-size: 14px;
}

input[type="file"]::file-selector-button {
    margin-right: 12px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    background: #ffffff;
    font-weight: 600;
    cursor: pointer;
}

button {
    min-height: 48px;
    padding: 12px 18px;
    border: 0;
    border-radius: 8px;
    color: #ffffff;
    background: var(--accent);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 160ms ease, transform 160ms ease, opacity 160ms ease;
}

button:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

button:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

.status {
    margin: 18px 0 0;
    padding: 14px 16px;
    border: 1px solid;
    border-radius: 8px;
    font-size: 15px;
    line-height: 1.45;
}

.status__header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.status__dot {
    width: 10px;
    height: 10px;
    flex: 0 0 10px;
    border-radius: 50%;
    background: currentColor;
}

.status__message {
    overflow-wrap: anywhere;
}

.status__message > :first-child {
    margin-top: 0;
}

.status__message > :last-child {
    margin-bottom: 0;
}

.status__message pre {
    overflow-x: auto;
    padding: 12px;
    border-radius: 6px;
    background: rgb(0 0 0 / 8%);
    white-space: pre;
}

.status__message code {
    font-family: ui-monospace, "Cascadia Code", "Source Code Pro", monospace;
}

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

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

.status--loading {
    color: var(--loading-text);
    background: var(--loading-bg);
    border-color: var(--loading-border);
}

.feedback-form {
    display: grid;
    gap: 18px;
    margin-top: 18px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.feedback-form[hidden] {
    display: none;
}

.feedback-form__fieldset {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.feedback-form__fieldset legend,
.feedback-form__message > span {
    margin-bottom: 10px;
    font-weight: 700;
}

.feedback-form__grades {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.feedback-form__grade-hints {
    display: flex;
    justify-content: space-between;
    margin-top: 7px;
    color: var(--muted);
    font-size: 12px;
}

.feedback-option {
    position: relative;
    cursor: pointer;
}

.feedback-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.feedback-option span {
    display: grid;
    min-height: 48px;
    place-items: center;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #ffffff;
    font-weight: 600;
    text-align: center;
    transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.feedback-option input:checked + span {
    border-color: var(--accent);
    background: var(--accent-soft);
    box-shadow: inset 0 0 0 1px var(--accent);
}

.feedback-option input:focus-visible + span {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.feedback-option input:disabled + span {
    opacity: 0.65;
    cursor: not-allowed;
}

.feedback-form__message {
    display: grid;
}

.feedback-form__optional {
    color: var(--muted);
    font-size: 13px;
    font-weight: 400;
}

.feedback-form textarea {
    width: 100%;
    resize: vertical;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    background: #ffffff;
    font: inherit;
    line-height: 1.45;
}

.feedback-form textarea:focus {
    border-color: var(--accent);
    outline: 2px solid rgba(37, 99, 235, 0.18);
}

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

.feedback-form__status--success {
    color: var(--success-text);
}

.feedback-form__status--error {
    color: var(--error-text);
}

.tickets-toolbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
}

.tickets-toolbar__title {
    margin: 0;
    font-size: 22px;
}

.tickets-toolbar__description {
    margin: 6px 0 0;
    color: var(--muted);
    line-height: 1.45;
}

.tickets-toolbar__refresh {
    min-height: 40px;
    flex: 0 0 auto;
    padding: 8px 14px;
}

.tickets-status {
    color: var(--muted);
    line-height: 1.45;
}

.tickets-status--error {
    color: var(--error-text);
}

.tickets-list {
    display: grid;
    gap: 16px;
}

.ticket-card {
    min-width: 0;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #ffffff;
}

.ticket-card__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.ticket-card__id {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
    font-family: ui-monospace, "Cascadia Code", "Source Code Pro", monospace;
    font-size: 14px;
}

.ticket-card__status {
    flex: 0 0 auto;
    padding: 5px 9px;
    border: 1px solid;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

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

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

.ticket-card__status--loading {
    color: var(--loading-text);
    background: var(--loading-bg);
    border-color: var(--loading-border);
}

.ticket-card__meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 24px;
    margin: 0 0 16px;
}

.ticket-card__meta-item {
    min-width: 0;
}

.ticket-card__meta dt,
.ticket-card__field-label {
    margin-bottom: 3px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.ticket-card__meta dd {
    margin: 0;
    overflow-wrap: anywhere;
    line-height: 1.4;
}

.ticket-card__fields {
    display: grid;
    gap: 10px;
}

.ticket-card__field {
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fafc;
}

.ticket-card__field summary {
    padding: 11px 13px;
    cursor: pointer;
    overflow-wrap: anywhere;
    line-height: 1.45;
}

.ticket-card__field summary:hover {
    background: var(--accent-soft);
}

.ticket-card__field-preview {
    display: block;
    margin-top: 4px;
    color: var(--text);
    font-size: 14px;
    font-weight: 400;
    text-transform: none;
}

.ticket-card__field-content {
    padding: 0 13px 13px;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.ticket-card__field-content--markdown {
    white-space: normal;
}

.ticket-card__field-content--markdown > :first-child {
    margin-top: 0;
}

.ticket-card__field-content--markdown > :last-child {
    margin-bottom: 0;
}

.ticket-card__field-content--markdown pre {
    overflow-x: auto;
    padding: 12px;
    border-radius: 6px;
    background: rgb(0 0 0 / 8%);
    white-space: pre;
}

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

@media (max-width: 520px) {
    .page {
        padding: 16px;
    }

    .upload-panel {
        padding: 24px;
    }

    input[type="file"]::file-selector-button {
        display: block;
        width: 100%;
        margin: 0 0 10px;
    }

    .feedback-form__grades {
        gap: 6px;
    }

    .tabs__button {
        font-size: 13px;
    }

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

    .tickets-toolbar,
    .ticket-card__header {
        align-items: stretch;
        flex-direction: column;
    }

    .tickets-toolbar__refresh {
        width: 100%;
    }

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