:root { color-scheme: light; font-family: "Segoe UI", system-ui, sans-serif; color: #182e3a; background: #f4f7f8; }
* { box-sizing: border-box; }
body { margin: 0; }
button, input { font: inherit; }
a { color: #126c72; }
button, a, input { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #31858a; outline-offset: 4px; }
h1:focus { outline: none; }
.mud-typography, .mud-input, .mud-button-root { font-family: "Segoe UI", system-ui, sans-serif; }
.mud-button-root { text-transform: none; min-height: 44px; letter-spacing: 0; font-weight: 600; }
.mud-input-adornment button { min-width: 44px; min-height: 44px; }
.app-shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.app-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: max(20px, env(safe-area-inset-top)) max(32px, env(safe-area-inset-right)) 20px max(32px, env(safe-area-inset-left)); border-bottom: 1px solid #e3eaed; background: #fff; }
.brand { display: inline-flex; align-items: center; gap: 12px; color: #182e3a; text-decoration: none; font-weight: 700; font-size: 23px; letter-spacing: -.8px; }
.brand-accent { color: #126c72; }
.header-caption { font-size: 13px; color: #596d79; }
.main-content { flex: 1; width: 100%; display: grid; align-items: center; padding: 52px 28px; }
.login-layout { width: 100%; max-width: 420px; margin: auto; }
.eyebrow { display: block; font-size: 11px; font-weight: 700; letter-spacing: 2.5px; color: #126c72; margin-bottom: 22px; }
.login-card { padding: 32px; border: 1px solid #e0e8ea; border-radius: 20px; box-shadow: 0 16px 48px #18343f08; }
.app-logo { display: block; width: 96px; height: 96px; object-fit: contain; margin-bottom: 16px; }
.login-card h1, .home-card h2 { font-size: 25px; font-weight: 650; letter-spacing: -.6px; margin: 0 0 6px; }
.card-description { color: #596d79; font-size: 14px; margin: 0 0 20px; }
.login-submit { margin-top: 24px; min-height: 50px; box-shadow: none; }
.login-connection { display: flex; gap: 8px; justify-content: center; align-items: center; margin: 24px 0; font-size: 12px; color: #596d79; overflow-wrap: anywhere; }
.connection-dot { width: 6px; height: 6px; flex-shrink: 0; border-radius: 50%; background: #8ca5aa; }
.login-tools { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 14px; border-top: 1px solid #e6ecee; }
.version-label { font-size: 12px; color: #596d79; white-space: nowrap; }
.configuration-help { color: #596d79; font-size: 14px; line-height: 1.6; }
.validation-errors { color: #b3261e; font-size: 13px; padding-left: 20px; margin-top: 12px; }
.app-footer { display: flex; justify-content: space-between; gap: 20px; padding: 20px max(32px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(32px, env(safe-area-inset-left)); color: #596d79; font-size: 12px; }
.home-content { width: 100%; max-width: 900px; margin: auto; }
.home-content h1, .page-heading { font-size: 32px; font-weight: 650; margin-bottom: 24px; }
.home-card { border: 1px solid #e0e8ea; padding: 32px; border-radius: 20px; }
.home-card p { color: #596d79; max-width: 520px; margin: 16px 0; line-height: 1.7; }
.update-notice { position: fixed; z-index: 1400; bottom: max(16px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); width: calc(100% - 32px); max-width: 580px; padding: 16px 20px; border-radius: 16px; background: #183a40; color: #fff; box-shadow: 0 8px 32px #18343f33; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.update-notice strong { display: block; font-size: 14px; }
.update-notice p { font-size: 12px; margin: 4px 0 0; color: #d6e7e7; }
.update-notice button { background: #e0f4ef; color: #183a40; flex-shrink: 0; }
.boot-screen { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 18px; color: #596d79; }
.boot-screen strong { font-size: 24px; color: #182e3a; }
.boot-screen progress { width: 150px; accent-color: #126c72; }
#blazor-error-ui { display: none; position: fixed; z-index: 2000; bottom: 0; width: 100%; padding: 18px 48px 18px 20px; background: #fff0ce; color: #493600; box-shadow: 0 -2px 12px #0002; }
#blazor-error-ui .reload { margin-left: 12px; }
#blazor-error-ui .dismiss { position: absolute; right: 8px; top: 4px; background: none; border: none; padding: 12px; font-size: 22px; cursor: pointer; }
@media (max-width: 800px) {
    .main-content { padding: 32px 20px; }
    .header-caption { display: none; }
    .app-header { padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); }
}
@media (max-width: 420px) {
    .main-content { padding: 24px 16px; }
    .login-card { padding: 24px 20px; }
    .app-footer { padding-left: 20px; padding-right: 20px; }
    .login-tools { flex-wrap: wrap; }
    .update-notice { align-items: flex-start; flex-direction: column; gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

.documents-page { width: 100%; max-width: 1180px; margin: 0 auto; align-self: start; min-width: 0; }
.documents-heading, .files-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 24px; }
.documents-heading h1 { font-size: 28px; font-weight: 650; letter-spacing: -.6px; margin: 0 0 6px; }
.documents-heading p, .field-help { color: #596d79; font-size: 14px; }
.document-panel { padding: 24px; border: 1px solid #e0e8ea; border-radius: 16px; min-width: 0; }
.document-filters { display: grid; grid-template-columns: 1fr 1.3fr; gap: 20px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field-label { display: flex; flex-direction: column; gap: 7px; font-size: 13px; font-weight: 600; color: #405762; min-width: 0; }
.field-label input, .field-label select { font: inherit; font-size: 15px; font-weight: 400; color: #182e3a; background: #fff; width: 100%; min-height: 48px; border: 1px solid #93a7ad; border-radius: 6px; padding: 10px 12px; }
.field-label input:disabled, .field-label select:disabled { background: #f4f7f8; color: #637680; }
.third-party-field { min-width: 0; }
.third-party-controls { display: flex; gap: 4px; margin-top: 7px; min-height: 48px; }
.third-party-controls > .mud-button-root { flex: 1; text-align: left; justify-content: flex-start; overflow-wrap: anywhere; }
.document-filters > .mud-button-root { justify-self: start; }
.document-summary { display: flex; gap: 36px; padding-bottom: 24px; margin-bottom: 24px; border-bottom: 1px solid #e3eaed; }
.document-summary h2 { font-size: 26px; font-weight: 650; overflow-wrap: anywhere; }
.document-summary dl { display: flex; gap: 32px; align-items: center; margin: 0; }
.document-summary dt { font-size: 12px; color: #596d79; }
.document-summary dd { font-weight: 600; margin: 4px 0 0; overflow-wrap: anywhere; }
.files-heading h2 { font-size: 20px; font-weight: 650; }
.file-count { color: #596d79; font-weight: 400; }
.file-actions, .row-actions { display: flex; gap: 8px; align-items: center; }
.row-actions { gap: 0; }
.row-actions button { min-width: 44px; min-height: 44px; }
.files-empty, .search-hint { text-align: center; color: #596d79; padding: 36px 16px; }
.files-empty .mud-icon-root, .search-hint .mud-icon-root { font-size: 32px; color: #4d8285; margin-bottom: 12px; }
.files-empty p { color: #405762; margin-bottom: 6px; }
.files-empty span { font-size: 13px; }
.filename { display: block; color: #596d79; font-size: 12px; margin-top: 4px; }
.files-table td { overflow-wrap: anywhere; white-space: pre-wrap; max-width: 360px; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 16px; font-size: 13px; }
.form-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 24px; }
.file-choices { display: grid; gap: 12px; }
.file-choice { display: flex; flex-direction: column; gap: 10px; border: 1px dashed #93a7ad; border-radius: 8px; padding: 14px; font-weight: 600; color: #126c72; }
.file-choice input { width: 100%; min-width: 0; font-size: 13px; }
.file-choice input::file-selector-button { min-height: 44px; border: 0; border-radius: 6px; margin-right: 10px; padding: 8px 12px; cursor: pointer; color: #183a40; background: #e0f4ef; }
.selected-file { overflow-wrap: anywhere; font-size: 14px; color: #405762; margin-top: 12px; }
.field-help { margin-top: 10px; line-height: 1.5; }
@media (max-width: 600px) {
    .documents-heading, .files-heading { flex-wrap: wrap; gap: 12px; }
    .documents-heading h1 { font-size: 24px; }
    .documents-heading > .mud-button-root { margin-left: -8px; }
    .document-panel { padding: 18px 14px; }
    .document-filters { grid-template-columns: 1fr; gap: 16px; }
    .document-filters > .mud-button-root { width: 100%; }
    .document-summary, .document-summary dl { flex-direction: column; align-items: flex-start; gap: 14px; }
    .files-heading { align-items: flex-start; }
    .file-actions { flex-wrap: wrap; }
    .files-table td { max-width: none; }
    .files-table .row-actions { justify-content: flex-end; }
}

.file-identity { min-width: 0; overflow-wrap: anywhere; }

.search-options { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding-bottom: 24px; margin-bottom: 24px; border-bottom: 1px solid #e3eaed; }
.search-methods { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 7px; }
.method-button { min-height: 48px; padding: 10px 18px; border: 1px solid #93a7ad; border-radius: 8px; background: #fff; color: #405762; cursor: pointer; }
.method-button.selected { background: #e0f4ef; border-color: #126c72; color: #126c72; font-weight: 650; }
.method-button:disabled { cursor: default; opacity: .55; }
.ean-search { max-width: 620px; }
.ean-search > .mud-button-root { margin: 12px 0 24px; min-height: 52px; }
.ean-form { display: flex; align-items: flex-end; gap: 12px; }
.ean-form > label { flex: 1; }
.barcode-video { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; background: #182e3a; border-radius: 12px; margin-top: 16px; }
@media (max-width: 600px) {
    .search-options { grid-template-columns: 1fr; gap: 16px; }
    .ean-form { align-items: stretch; flex-direction: column; }
    .ean-search > .mud-button-root { width: 100%; }
}

.main-content:focus { outline: none; }

.mud-table-row.tercero-seleccionado, .mud-table-row.tercero-seleccionado:hover { background-color: #e0f4ef !important; }

/* Búsqueda y consulta documental: distribución táctil, sin tabla apilada. */
.main-content:has(.documents-page) { padding: 24px; }
.documents-page { font-family: "Segoe UI", system-ui, sans-serif; }
.documents-page:focus { outline: none; }
.document-search { max-width: 760px; margin: 0 auto; }
.document-search .search-options { gap: 16px; padding-bottom: 16px; margin-bottom: 16px; }
.document-search .document-filters { gap: 14px 20px; }
.document-search .field-label input, .document-search .field-label select { font-size: 16px; }
.document-search .third-party-controls > .mud-button-root { min-width: 0; }
.extra-filters { grid-column: 1 / -1; }
.filter-toggle { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 4px 0; border: 0; background: none; color: #126c72; text-align: left; cursor: pointer; }
.filter-toggle > :last-child { margin-left: auto; }
.date-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding-top: 10px; }
.document-filters > .mud-button-root { grid-column: 1 / -1; width: 100%; }
.view-results { margin-top: 8px; width: 100%; }
.change-document { margin: -8px 0 8px -8px; }
.documents-page:has(.document-detail) { max-width: 900px; }
.document-detail { max-width: 900px; margin: 0 auto; }
.document-summary { display: block; padding-bottom: 16px; margin-bottom: 12px; }
.document-kind { color: #596d79; font-size: 14px; }
.document-title-line { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 16px; margin-top: 2px; }
.document-summary h2 { font-size: 24px; line-height: 1.3; margin: 0; }
.document-title-line time { font-size: 14px; color: #596d79; white-space: nowrap; }
.document-summary p { margin: 6px 0 0; font-size: 15px; line-height: 1.45; overflow-wrap: anywhere; }
.files-heading { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; margin-bottom: 12px; align-items: center; }
.files-heading h2 { margin: 0; }
.refresh-files { min-width: 44px; min-height: 44px; }
.file-list { display: grid; gap: 10px; }
.file-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; border: 1px solid #e0e8ea; border-radius: 12px; background: #fff; }
.file-open { display: flex; align-items: flex-start; justify-content: flex-start; gap: 10px; min-width: 0; width: 100%; min-height: 64px; border: 0; border-radius: 12px; background: none; color: #182e3a; text-align: left; padding: 14px 4px 14px 12px; cursor: pointer; }
.file-open:hover { background: #f4f9f9; }
.file-open:disabled { cursor: default; opacity: .6; }
.file-icon { flex-shrink: 0; color: #126c72; margin-top: 2px; }
.file-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; overflow-wrap: anywhere; }
.file-text strong { font-size: 15px; line-height: 1.4; }
.file-type { font-size: 13px; line-height: 1.4; font-weight: 600; color: #126c72; }
.file-description { font-size: 14px; line-height: 1.4; white-space: pre-wrap; }
.file-text time, .file-text .filename { font-size: 12px; line-height: 1.4; color: #596d79; margin: 0; }
.file-card > .mud-menu { margin: 4px 0; }
.file-card .mud-icon-button { min-height: 44px; min-width: 44px; }
.file-menu .mud-menu-item { min-height: 44px; }
.files-empty { padding: 24px 12px; }
.document-picker { font-family: "Segoe UI", system-ui, sans-serif; height: min(740px, calc(100dvh - 48px)); }
.document-picker .mud-dialog-title { flex-shrink: 0; padding: 18px 20px 14px; border-bottom: 1px solid #e3eaed; }
.document-picker .mud-dialog-content { display: flex; flex-direction: column; min-height: 0; overflow: hidden; padding: 12px 16px; }
.document-picker-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 10px; padding: 3px; }
.document-choice { position: relative; display: flex; flex-direction: column; align-items: stretch; flex-shrink: 0; gap: 4px; width: 100%; min-height: 96px; padding: 12px 34px 12px 12px; border: 1px solid #dce7e9; border-radius: 10px; background: #fff; color: #182e3a; text-align: left; cursor: pointer; font: inherit; }
.document-choice:hover { border-color: #126c72; background: #f1f8f8; }
.document-choice:disabled { cursor: default; opacity: .6; }
.document-choice-top { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.document-choice strong { font-size: 16px; line-height: 1.4; overflow-wrap: anywhere; }
.document-choice time { font-size: 13px; color: #596d79; white-space: nowrap; }
.document-choice-type { font-size: 13px; color: #596d79; line-height: 1.4; }
.document-choice-party { font-size: 14px; line-height: 1.4; overflow-wrap: anywhere; }
.document-choice-arrow { position: absolute; right: 8px; top: calc(50% - 12px); color: #508087; }
.document-picker .mud-dialog-actions { display: block; padding: 8px 16px 12px; border-top: 1px solid #e3eaed; flex-shrink: 0; }
.document-picker .pagination { margin: 0 0 4px; }
.document-picker-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
@media (max-width: 600px) {
    .main-content:has(.documents-page) { padding: 16px 12px; }
    .document-panel { padding: 16px 14px; }
    .document-search .search-options { gap: 12px; padding-bottom: 12px; margin-bottom: 12px; }
    .document-search .document-filters { gap: 12px; }
    .date-filters { grid-template-columns: 1fr; }
    .files-heading { grid-template-columns: 1fr auto; }
    .files-heading .add-file { grid-column: 1 / -1; width: 100%; min-height: 48px; }
    .document-picker.mud-dialog { width: 100%; max-width: none; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
    .document-picker .mud-dialog-title { padding-top: max(16px, env(safe-area-inset-top)); }
    .document-picker .mud-dialog-actions { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
    .document-picker .mud-dialog-content { padding: 10px 12px; }
    .document-picker-actions .mud-button-root { font-size: 13px; }
}

/* Lector de EAN: imagen amplia y controles compactos en el móvil. */
.barcode-reader.mud-dialog { width: min(680px, calc(100vw - 32px)); max-width: none; }
.barcode-reader .mud-dialog-content { padding: 8px 16px; }
.barcode-video { display: block; width: 100%; aspect-ratio: 4 / 3; height: auto; object-fit: cover; margin: 0; }
.barcode-status { color: #596d79; font-size: 13px; line-height: 1.4; text-align: center; margin: 8px 0 0; }
@media (max-width: 600px) {
    .main-content:has(.login-layout) { padding-top: 12px; padding-bottom: 12px; }
    .login-layout .login-connection { margin: 16px 0; }
    .login-layout .login-submit { margin-top: 16px; }
    .app-shell:has(.login-layout) .app-footer { padding-top: 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
    .barcode-reader.mud-dialog { width: 100%; max-width: none; margin: 0; border-radius: 0; }
    .barcode-reader .mud-dialog-title { padding: max(12px, env(safe-area-inset-top)) 16px 8px; }
    .barcode-reader .mud-dialog-content { padding: 4px 8px 8px; }
    .barcode-reader .mud-dialog-actions { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
}

/* Same PIN access as SofyAutomocion, using each application's theme. */
.login-mode-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; border-radius: 10px; background: var(--mud-palette-background); }
.login-mode-button { min-height: 44px; border: 0; border-radius: 7px; background: transparent; color: var(--mud-palette-text-secondary); font-weight: 600; cursor: pointer; }
.login-mode-button.is-active { background: #fff; color: var(--mud-palette-primary); box-shadow: 0 1px 5px #0001; }
.login-mode-button:disabled { cursor: default; opacity: .6; }
.login-pin-field input { text-align: center; font-size: 20px; letter-spacing: 4px; }
.pin-keypad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.pin-key.mud-button-root { min-width: 0; min-height: 48px; font-size: 20px; border-radius: 8px; }
.pin-key-action.mud-button-root { font-size: 14px; }
.pin-mode .app-logo { width: 56px; height: 56px; margin-bottom: 12px; }
.pin-mode .login-card { padding-top: 24px; padding-bottom: 24px; }
.pin-mode .card-description { margin-bottom: 16px; }
.pin-mode .login-connection { margin: 16px 0; }
.pin-mode .login-submit { margin-top: 16px; }
