:root {
    color-scheme: light;
    --graphite: #1f2326;
    --graphite-soft: #30363a;
    --ink: #24282b;
    --muted: #667076;
    --line: #d8dcde;
    --paper: #ffffff;
    --background: #f3f4f2;
    --field: #f7f7f4;
    --accent: #f26a21;
    --accent-dark: #c95012;
    --success: #1d7a4d;
    --error: #b42318;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.review-form:has(#currency option[value="EUR"]:checked) #country-field,
.review-form:has(#currency option[value="EUR"]:checked) #euro-amount-field {
    display: none !important;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background:
        linear-gradient(180deg, #ffffff 0, var(--background) 260px),
        var(--background);
    font-family: Inter, "Segoe UI", system-ui, sans-serif;
}

a { color: var(--accent); }

.topbar {
    min-height: 82px;
    padding: 10px max(24px, calc((100vw - 1180px) / 2));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    color: #fff;
    background: var(--graphite);
    border-bottom: 5px solid var(--accent);
}

.brand {
    color: #fff;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 12px;
}

.brand img { width: 56px; height: 56px; object-fit: contain; }
.brand span { display: grid; gap: 2px; }
.brand strong { color: #fff; font-size: 1.2rem; letter-spacing: 0; }
.brand small { color: #d9ddde; font-size: .78rem; font-weight: 650; }
.topbar-identity {
    display: grid;
    gap: 3px;
    min-width: 220px;
    color: #d9ddde;
    font-size: .82rem;
    text-align: center;
}
.topbar-identity strong {
    color: var(--accent);
    font-size: .78rem;
    letter-spacing: .03em;
}
.user-menu {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    color: #f7f7f4;
    font-size: .88rem;
}
.container { width: min(1180px, calc(100% - 32px)); margin: 34px auto; }
.card {
    padding: 26px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 10px 24px rgba(31, 35, 38, .07);
}

.auth-card { width: min(460px, 100%); margin: 72px auto; }
.auth-card h1, .upload-card h1 { margin-top: 4px; }
.stack { display: grid; gap: 18px; }

label { display: grid; gap: 7px; font-weight: 650; }
input, select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #cdd3dc;
    border-radius: 6px;
    color: var(--ink);
    background: #fff;
    font: inherit;
}

input:focus, select:focus {
    outline: 3px solid rgba(242, 106, 33, .18);
    border-color: var(--accent);
}

button, .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 11px 16px;
    border: 1px solid #cdd3dc;
    border-radius: 6px;
    color: var(--ink);
    background: #fff;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

button:hover, .button:hover { border-color: #98a2b3; }
.primary { color: #fff; background: var(--accent); border-color: var(--accent); }
.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.secondary { background: var(--field); }
.danger {
    color: var(--error);
    background: #fff;
    border-color: #e5a3a3;
}
.danger:hover {
    color: #fff;
    background: var(--error);
    border-color: var(--error);
}
.link-button { padding: 6px 8px; border: 0; color: #fff; background: transparent; }
.link-button:hover { color: var(--accent); background: transparent; }
.eyebrow {
    margin: 0 0 5px;
    color: var(--accent);
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .09em;
    text-transform: uppercase;
}

.muted, .hint { color: var(--muted); }
.hint { margin: -9px 0 0; font-size: .84rem; }
.hero, .section-heading, .expediente, .actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.hero { margin-bottom: 28px; }
.hero h1 { margin: 4px 0; }
.hero p { margin: 6px 0 0; }
.section-heading h2 { margin: 4px 0 22px; }
.expediente { padding: 20px 0; border-top: 1px solid var(--line); }
.expediente:first-child { border-top: 0; }
.expediente p { margin: 6px 0; }
.expediente .result-message { color: var(--success); font-size: .9rem; }
.expediente-main,
.ticket-summary {
    display: grid;
    gap: 6px;
    color: inherit;
    text-decoration: none;
}
.compact-home { align-items: center; }
.actions { justify-content: flex-end; flex-wrap: wrap; }
.status {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 999px;
    color: #344054;
    background: #f2f4f7;
    font-size: .78rem;
}

.empty { padding: 24px 0; text-align: center; color: var(--muted); }
.integration-note {
    margin-top: 20px;
    padding: 14px 18px;
    color: #475467;
    background: #eef2ff;
    border-radius: 8px;
}

.notice { margin-bottom: 18px; padding: 13px 16px; border-radius: 8px; }
.notice.error { color: var(--error); background: #fef3f2; }
.notice.success { color: var(--success); background: #ecfdf3; }
.upload-card { width: min(700px, 100%); margin: 40px auto; }
.project-data-card { width: min(550px, 100%); margin: 36px auto; text-align: center; }
.project-data-card form { margin-top: 24px; text-align: left; }
.project-logo { width: 150px; height: 150px; object-fit: contain; }
.project-summary {
    display: grid;
    gap: 5px;
    margin: 18px 0;
    padding: 14px 16px;
    border-left: 4px solid var(--accent);
    background: var(--field);
}
.legacy-warning {
    color: #8a4b00;
    font-size: .82rem;
}
.drop-zone {
    padding: 36px;
    text-align: center;
    border: 2px dashed #b9c2d0;
    border-radius: 8px;
    background: var(--field);
}
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}
.capture-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}
.capture-actions button,
.capture-actions .button {
    min-width: 170px;
}
.capture-preview {
    display: grid;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    background: var(--field);
}
.capture-preview[hidden] { display: none; }
.capture-preview img {
    width: 100%;
    max-height: 360px;
    object-fit: contain;
    background: #fff;
    border: 1px solid var(--line);
}
.ticket-counter {
    color: var(--graphite);
    font-weight: 800;
}
.processing-phases { display: none; }
.upload-list {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}
.upload-list li {
    padding: 10px 12px;
    border: 1px solid var(--line);
    background: var(--field);
}

.revision-card { padding: 20px; }
.table-scroll { overflow-x: auto; }
.revision-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 980px;
}
.revision-table th,
.revision-table td {
    padding: 10px 8px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}
.revision-table th {
    color: var(--muted);
    font-size: .78rem;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.revision-table input { min-width: 110px; }
.revision-table td:nth-child(2) input { min-width: 230px; }
.source-cell { max-width: 220px; overflow-wrap: anywhere; }
.source-cell small { display: block; margin-top: 4px; color: var(--muted); }
.revision-actions { margin-top: 20px; }
.excel-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}
.status-grid { display: grid; gap: 0; }
.status-item {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding: 16px 0;
    border-bottom: 1px solid var(--line);
}
.status-item:last-child { border-bottom: 0; }
.status-item .ok { color: var(--success); }
.status-item .warning { color: #b54708; }

.review-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 16px;
    padding: 8px 4px;
    text-align: center;
}

.review-heading p { margin: 3px 0; }
.review-reference { font-size: 1.05rem; font-weight: 800; }
.review-status {
    width: 230px;
    display: grid;
    gap: 4px;
    text-align: right;
}

.review-status progress {
    width: 100%;
    height: 13px;
    accent-color: var(--accent);
}

.review-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(320px, .75fr);
    min-height: 560px;
    overflow: hidden;
    background: var(--paper);
    border: 1px solid #cfcfcf;
    box-shadow: 0 8px 24px rgba(31, 35, 38, .08);
}
.correction-highlight {
    border-color: var(--error);
    box-shadow: 0 0 0 3px rgba(176, 0, 0, .12);
}

.ticket-panel {
    min-width: 0;
    padding: 14px;
    background: #e9e9e9;
    border-right: 1px solid #cfcfcf;
}

.ticket-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    min-height: 24px;
    margin-bottom: 10px;
    color: #555;
    font-size: .84rem;
}

.ticket-toolbar span {
    max-width: 70%;
    overflow-wrap: anywhere;
    text-align: right;
}

.ticket-stage {
    height: clamp(460px, 62vh, 720px);
    display: grid;
    place-items: center;
    overflow: auto;
    background: #f0f0f0;
    border: 1px solid #d0d0d0;
}

.ticket-image {
    max-width: 92%;
    max-height: 92%;
    object-fit: contain;
    transition: transform .18s ease;
}

.ticket-document { width: 100%; height: 100%; border: 0; }
.ticket-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.review-form {
    align-content: start;
    display: grid;
    gap: 6px;
    padding: 14px 20px;
}

.review-form label { gap: 3px; font-size: .86rem; }
.review-form input,
.review-form select { padding: 7px 10px; border-radius: 3px; }
.review-save { width: 220px; margin-top: 4px; }
.review-form .status { justify-self: start; }
.review-error { margin: 0 0 4px; }
.field-invalid input,
.field-invalid select {
    border-color: var(--error);
    background: #fff8f7;
}
.field-message {
    color: var(--error);
    font-size: .78rem;
    font-weight: 650;
}

.ticket-navigation {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin: 14px 0 24px;
}

.review-output {
    padding: 22px 26px;
    background: var(--paper);
    border-top: 4px solid var(--accent);
}

.review-output h2 { margin: 0 0 4px; font-size: 1.15rem; }
.review-output p { color: var(--muted); }
.result-message { color: var(--success) !important; }
.completion-card {
    width: min(720px, 100%);
    margin: 36px auto;
    text-align: center;
    border-top: 5px solid var(--success);
}
.completion-card h1 {
    margin-bottom: 8px;
}
.completion-mark {
    width: 58px;
    height: 58px;
    margin: 0 auto 14px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: #fff;
    background: var(--success);
    font-size: 2rem;
    font-weight: 800;
}
.completion-actions {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 24px;
}
.completion-actions form { margin: 0; }
.completion-reasons {
    margin-top: 18px;
    color: var(--muted);
}
.completion-reasons p { margin: 6px 0; }
.expediente-open {
    width: min(760px, 100%);
    margin: 28px auto;
}
.scanner-recommendation {
    margin: 18px 0 0;
    padding: 13px 16px;
    color: #475467;
    background: var(--field);
    border: 1px solid var(--line);
    border-radius: 8px;
}
.scanner-recommendation a {
    font-weight: 800;
}
.expediente-action-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 22px;
}
.expediente-action-grid > * {
    min-height: 44px;
}
.expediente-action-grid .add-tickets-form {
    display: contents;
}
.expediente-action-grid .add-tickets-form button,
.expediente-action-grid > form:not(.add-tickets-form) button {
    width: 100%;
}
.add-tickets-form {
    display: grid;
    gap: 12px;
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}
.upload-status {
    justify-self: start;
}
.expediente-action-grid .upload-status {
    grid-column: 1 / -1;
}
.add-tickets-form.is-processing button {
    opacity: .65;
}
.action-menu {
    position: relative;
}
.action-menu summary {
    list-style: none;
    cursor: pointer;
}
.action-menu summary::-webkit-details-marker { display: none; }
.action-menu div {
    display: grid;
    gap: 8px;
    margin-top: 8px;
}
.ticket-list {
    display: grid;
    gap: 10px;
}
.ticket-row {
    display: grid;
    grid-template-columns: 78px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border: 1px solid var(--line);
    background: var(--paper);
}
.ticket-thumb {
    width: 78px;
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    overflow: hidden;
    color: var(--muted);
    background: var(--field);
    border: 1px solid var(--line);
    text-decoration: none;
    font-weight: 800;
}
.ticket-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.ticket-summary span {
    color: var(--muted);
    overflow-wrap: anywhere;
}
.diagnostic-panel {
    margin-top: 18px;
    padding: 14px;
    text-align: left;
    background: var(--paper);
    border: 1px solid var(--line);
}
.diagnostic-panel dl {
    display: grid;
    gap: 8px;
    margin: 12px 0 0;
}
.diagnostic-panel dl div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}
.diagnostic-panel dt {
    color: var(--muted);
    font-weight: 700;
}
.diagnostic-panel dd { margin: 0; }
button:disabled {
    color: #8a8a8a;
    background: #eeeeee;
    border-color: #d5d5d5;
    cursor: not-allowed;
}
.button.disabled {
    pointer-events: none;
    color: #8a8a8a;
    background: #eeeeee;
    border-color: #d5d5d5;
}
.processing-status {
    align-self: center;
    color: var(--muted);
    font-size: .9rem;
    font-weight: 700;
}
.document-view {
    display: grid;
    gap: 18px;
}
.document-kicker {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--success);
    font-weight: 800;
}
.document-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}
.excel-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}
.excel-summary span {
    display: grid;
    gap: 4px;
    padding: 12px 14px;
    background: var(--paper);
    border: 1px solid var(--line);
}
.excel-summary strong {
    color: var(--muted);
    font-size: .78rem;
    text-transform: uppercase;
}
.excel-preview {
    overflow: auto;
    max-height: 68vh;
    background: var(--paper);
    border: 1px solid var(--line);
}
.excel-preview table {
    width: 100%;
    min-width: 980px;
    border-collapse: collapse;
}
.excel-preview th,
.excel-preview td {
    padding: 7px 9px;
    border: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}
.excel-preview th {
    position: sticky;
    top: 0;
    background: #f7f7f7;
    z-index: 1;
}
.expense-preview-table td span {
    display: block;
}
.expense-preview-table th:nth-child(1),
.expense-preview-table td:nth-child(1) { width: 90px; }
.expense-preview-table th:nth-child(2),
.expense-preview-table td:nth-child(2) { width: 120px; white-space: nowrap; }
.expense-preview-table th:nth-child(4),
.expense-preview-table td:nth-child(4) { width: 120px; text-align: right; }
.expense-preview-table th:nth-child(5),
.expense-preview-table td:nth-child(5) { width: 180px; }
.expense-preview-table th:nth-child(7),
.expense-preview-table td:nth-child(7) { width: 120px; text-align: right; }
.excel-description {
    min-width: 260px;
    overflow-wrap: anywhere;
}
.zip-list {
    display: grid;
    gap: 14px;
    margin: 0;
    padding: 0;
    list-style: none;
}
.zip-list li {
    padding: 12px 14px;
    border: 1px solid var(--line);
    background: var(--field);
}
.site-footer {
    width: min(1180px, calc(100% - 32px));
    margin: 32px auto 24px;
    padding-top: 16px;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    color: var(--muted);
    border-top: 1px solid var(--line);
    font-size: .86rem;
}
.site-footer strong { color: var(--graphite); }

@media (max-width: 700px) {
    .topbar {
        align-items: stretch;
        flex-direction: column;
        gap: 12px;
    }
    .topbar-identity { text-align: left; }
    .user-menu { justify-content: space-between; }
    .container { margin-top: 28px; }
    .hero, .expediente { align-items: stretch; flex-direction: column; }
    .hero .button { width: 100%; }
    .actions { justify-content: flex-start; }
    .review-heading { align-items: stretch; flex-direction: column; }
    .review-status { width: 100%; text-align: left; }
    .review-workspace { grid-template-columns: 1fr; }
    .ticket-panel { border-right: 0; border-bottom: 1px solid #cfcfcf; }
    .ticket-stage { height: min(68vh, 520px); }
    .review-form { padding: 20px; }
    .excel-actions { align-items: stretch; flex-direction: column; }
    .excel-summary { grid-template-columns: 1fr; }
    .capture-actions { flex-direction: column; }
    .capture-actions button,
    .capture-actions .button { width: 100%; }
    .expediente-action-grid { grid-template-columns: 1fr; }
    .ticket-row { grid-template-columns: 64px minmax(0, 1fr); }
    .ticket-row form { grid-column: 1 / -1; }
    .site-footer { flex-direction: column; }
}
