/* FGB Tender App — design system (light default + .dark) */

/* ── Tokens ─────────────────────────────────────────────── */
:root {
    --ui-bg: #ececef;
    --ui-sidebar: #ffffff;
    --ui-topbar: #ffffff;
    --ui-surface: #ffffff;
    --ui-surface-2: #f8fafc;
    --ui-surface-inner: #f1f5f9;
    --ui-surface-hover: #e8eaef;
    --ui-border: #c4c9d4;
    --ui-border-strong: #9aa3b2;
    --ui-border-subtle: #dde1e8;
    --ui-text: #0f172a;
    --ui-text-muted: #475569;
    --ui-text-faint: #64748b;
    --ui-shadow: 0 1px 2px rgba(15, 23, 42, 0.07), 0 0 0 1px rgba(15, 23, 42, 0.04);
    --ui-shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08);
    --ui-scrollbar: #b8bec8;
    --ui-scrollbar-hover: #8b95a5;
    --ui-prose-bg: #f8fafc;
    --ui-prose-text: #1e293b;
    --ui-tab-active-bg: #f1f5f9;
    --ui-accent: #c71309;
    --ui-accent-hover: #a80f07;
    --ui-accent-fg: #ffffff;
    --ui-accent-soft: rgba(199, 19, 9, 0.12);
    --ui-accent-ring: rgba(199, 19, 9, 0.25);
}

.dark {
    --ui-bg: #121212;
    --ui-sidebar: #1a1a1a;
    --ui-topbar: #1a1a1a;
    --ui-surface: #1e1e1e;
    --ui-surface-2: #2a2a2a;
    --ui-surface-inner: #171717;
    --ui-surface-hover: rgba(255, 255, 255, 0.06);
    --ui-border: rgba(255, 255, 255, 0.14);
    --ui-border-strong: rgba(255, 255, 255, 0.22);
    --ui-border-subtle: rgba(255, 255, 255, 0.08);
    --ui-text: #f3f4f6;
    --ui-text-muted: #cbd5e1;
    --ui-text-faint: #9ca3af;
    --ui-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
    --ui-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --ui-scrollbar: #3a3a3a;
    --ui-scrollbar-hover: #555;
    --ui-prose-bg: #1a1a1a;
    --ui-prose-text: #d4d4d4;
    --ui-tab-active-bg: rgba(255, 255, 255, 0.08);
    --ui-accent: #e82418;
    --ui-accent-hover: #f55a4f;
    --ui-accent-fg: #ffffff;
    --ui-accent-soft: rgba(232, 36, 24, 0.14);
    --ui-accent-ring: rgba(232, 36, 24, 0.3);
}

body {
    font-family: "Plus Jakarta Sans", ui-sans-serif, system-ui, sans-serif;
}

/* ── Tailwind gray/status fixes inside app shell (legacy markup) ── */
.ui-shell .text-gray-300 { color: #334155; }
.ui-shell .text-gray-400 { color: #475569; }
.ui-shell .text-gray-500 { color: #334155; }
.ui-shell .text-gray-600 { color: #1e293b; }
.dark .ui-shell .text-gray-300 { color: #d1d5db; }
.dark .ui-shell .text-gray-400 { color: #9ca3af; }
.dark .ui-shell .text-gray-500 { color: #9ca3af; }
.dark .ui-shell .text-gray-600 { color: #6b7280; }

.ui-shell .text-green-400 { color: #15803d; }
.ui-shell .text-red-400 { color: #b91c1c; }
.ui-shell .text-amber-400 { color: #c71309; }
.ui-shell .text-blue-400 { color: #1d4ed8; }
.dark .ui-shell .text-green-400 { color: #4ade80; }
.dark .ui-shell .text-red-400 { color: #f87171; }
.dark .ui-shell .text-amber-400 { color: #f55a4f; }
.dark .ui-shell .text-blue-400 { color: #60a5fa; }

/* Tailwind amber classes → brand red (legacy markup) */
.ui-shell [class*="text-amber-400/"],
.ui-shell [class*="text-amber-500/"] {
    color: #8b1009;
}
.dark .ui-shell [class*="text-amber-400/"],
.dark .ui-shell [class*="text-amber-500/"] {
    color: rgba(245, 90, 79, 0.9);
}
.ui-shell .text-amber-300 { color: #e82418; }
.ui-shell .text-amber-500 { color: #a80f07; }
.ui-shell .text-amber-600 { color: #8b1009; }
.dark .ui-shell .text-amber-300 { color: #f77a72; }
.dark .ui-shell .text-amber-500 { color: #f55a4f; }
.dark .ui-shell .text-amber-600 { color: #f9a8a3; }

.ui-shell [class*="bg-amber-400/10"],
.ui-shell [class*="bg-amber-500/10"] {
    background-color: rgba(199, 19, 9, 0.1) !important;
}
.ui-shell [class*="bg-amber-400/20"],
.ui-shell [class*="bg-amber-500/20"] {
    background-color: rgba(199, 19, 9, 0.18) !important;
}
.ui-shell [class*="bg-amber-500/15"] {
    background-color: rgba(199, 19, 9, 0.14) !important;
}
.ui-shell [class*="bg-amber-400/5"] {
    background-color: rgba(199, 19, 9, 0.05) !important;
}
.dark .ui-shell [class*="bg-amber-400/10"],
.dark .ui-shell [class*="bg-amber-500/10"] {
    background-color: rgba(232, 36, 24, 0.12) !important;
}
.dark .ui-shell [class*="bg-amber-400/20"],
.dark .ui-shell [class*="bg-amber-500/20"] {
    background-color: rgba(232, 36, 24, 0.2) !important;
}
.dark .ui-shell [class*="bg-amber-500/15"] {
    background-color: rgba(232, 36, 24, 0.15) !important;
}
.dark .ui-shell [class*="bg-amber-400/5"] {
    background-color: rgba(232, 36, 24, 0.06) !important;
}

.ui-shell [class*="border-amber-400/20"],
.ui-shell [class*="border-amber-500/20"] {
    border-color: rgba(199, 19, 9, 0.22) !important;
}
.ui-shell [class*="border-amber-400/30"],
.ui-shell [class*="border-amber-500/30"] {
    border-color: rgba(199, 19, 9, 0.32) !important;
}
.ui-shell [class*="border-amber-400/15"] {
    border-color: rgba(199, 19, 9, 0.18) !important;
}
.dark .ui-shell [class*="border-amber-400/20"],
.dark .ui-shell [class*="border-amber-500/20"] {
    border-color: rgba(232, 36, 24, 0.28) !important;
}
.dark .ui-shell [class*="border-amber-400/30"],
.dark .ui-shell [class*="border-amber-500/30"] {
    border-color: rgba(232, 36, 24, 0.38) !important;
}
.dark .ui-shell [class*="border-amber-400/15"] {
    border-color: rgba(232, 36, 24, 0.22) !important;
}

.ui-shell .bg-amber-400 { background-color: var(--ui-accent) !important; }
.ui-shell .hover\:bg-amber-400:hover { background-color: var(--ui-accent-hover) !important; }
.ui-shell .hover\:bg-amber-500:hover { background-color: var(--ui-accent-hover) !important; }
.ui-shell [class*="hover\:bg-amber-400/20"]:hover {
    background-color: rgba(199, 19, 9, 0.2) !important;
}
.ui-shell [class*="hover\:bg-amber-500/20"]:hover {
    background-color: rgba(199, 19, 9, 0.2) !important;
}
.ui-shell [class*="shadow-amber-400/20"] {
    --tw-shadow-color: rgba(199, 19, 9, 0.2);
}
.ui-shell [class*="focus\:ring-amber-400/50"]:focus {
    --tw-ring-color: var(--ui-accent-ring);
}
.ui-shell [class*="focus\:border-amber-400"]:focus {
    border-color: var(--ui-accent) !important;
}

.ui-section-title {
    font-size: 0.875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #8b1009;
}
.dark .ui-section-title {
    color: #f55a4f;
}

.ui-required {
    color: #c71309;
    font-weight: 700;
}
.dark .ui-required {
    color: #f55a4f;
}

.ui-hint-amber {
    color: #8b1009;
}
.dark .ui-hint-amber {
    color: rgba(245, 90, 79, 0.9);
}

.ui-text-accent {
    color: #8b1009;
}
.dark .ui-text-accent {
    color: rgba(245, 90, 79, 0.95);
}

.ui-alert-banner {
    background: #fef2f2;
    border: 1px solid #c71309;
    color: #5c0d07;
    border-radius: 0.5rem;
}
.dark .ui-alert-banner {
    background: rgba(199, 19, 9, 0.12);
    border-color: rgba(232, 36, 24, 0.35);
    color: #fca5a5;
}

.ui-alert-warning {
    background: #fef2f2;
    border: 1px solid #c71309;
    color: #5c0d07;
    border-radius: 0.5rem;
    font-size: 0.75rem;
}
.ui-alert-warning p,
.ui-alert-warning li {
    color: #8b1009;
}
.dark .ui-alert-warning {
    background: rgba(199, 19, 9, 0.12);
    border-color: rgba(232, 36, 24, 0.35);
    color: #fecaca;
}
.dark .ui-alert-warning p,
.dark .ui-alert-warning li {
    color: #fca5a5;
}

.ui-info-box {
    background: #eff6ff;
    border: 1px solid #93c5fd;
    border-radius: 0.75rem;
    color: #1e3a8a;
}
.ui-info-box .ui-info-box-title {
    color: #1d4ed8;
    font-weight: 700;
}
.dark .ui-info-box {
    background: rgba(59, 130, 246, 0.08);
    border-color: rgba(59, 130, 246, 0.25);
    color: #bfdbfe;
}
.dark .ui-info-box .ui-info-box-title {
    color: #60a5fa;
}

.ui-btn-download {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.875rem;
    border-radius: 0.75rem;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1.25;
    color: #ffffff;
    background-color: #15803d;
    border: 2px solid #15803d;
    transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}
.ui-btn-download:hover {
    color: #15803d;
    background-color: #ffffff;
}
.dark .ui-btn-download {
    background-color: #16a34a;
    border-color: #16a34a;
}
.dark .ui-btn-download:hover {
    color: #4ade80;
    background-color: transparent;
    border-color: #4ade80;
}

.ui-form-stack {
    width: 100%;
    max-width: none;
}

/* ── Shell ──────────────────────────────────────────────── */
.ui-shell {
    background-color: var(--ui-bg);
    color: var(--ui-text);
}

.ui-sidebar {
    background-color: var(--ui-sidebar);
    border-right: 1px solid var(--ui-border);
    box-shadow: var(--ui-shadow-sm);
}

.ui-sidebar-brand {
    border-bottom: 1px solid var(--ui-border);
}

.ui-brand-text {
    color: var(--ui-text);
}

.ui-brand-logo {
    height: 3.25rem;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    object-position: left center;
    display: block;
}
.ui-brand-logo--small {
    height: 2rem;
    width: 2rem;
    object-fit: contain;
    object-position: center;
    margin: 0 auto;
}

.ui-brand-logo-login {
    height: 2.75rem;
    width: auto;
    max-width: min(100%, 14rem);
    object-fit: contain;
    object-position: center;
}

.ui-nav-separator {
    border-top: 1px solid var(--ui-border-subtle);
}

.ui-nav-link {
    color: var(--ui-text-muted);
    border-left: 2px solid transparent;
}
.ui-nav-link:hover {
    background-color: var(--ui-surface-hover);
    color: var(--ui-text);
}

.ui-nav-link-active {
    background-color: var(--ui-accent-soft);
    color: #8b1009;
    border-left-color: var(--ui-accent);
    font-weight: 600;
}
.dark .ui-nav-link-active {
    color: #f55a4f;
}

.ui-nav-group-active {
    background-color: rgba(199, 19, 9, 0.08);
    color: #a80f07;
}
.dark .ui-nav-group-active {
    color: rgba(245, 90, 79, 0.92);
}

.ui-nav-sublink {
    color: var(--ui-text-faint);
}
.ui-nav-sublink:hover {
    background-color: var(--ui-surface-hover);
    color: var(--ui-text);
}
.ui-nav-sublink-active {
    background-color: var(--ui-accent-soft);
    color: #8b1009;
    font-weight: 600;
}
.dark .ui-nav-sublink-active {
    color: #f55a4f;
}

.ui-sidebar-footer {
    border-top: 1px solid var(--ui-border);
}

.ui-topbar {
    background-color: var(--ui-topbar);
    border-bottom: 1px solid var(--ui-border);
    box-shadow: 0 1px 0 var(--ui-border-subtle);
}

.ui-topbar-title {
    color: var(--ui-text);
    font-weight: 700;
}

.ui-footer {
    border-top: 1px solid var(--ui-border);
    color: var(--ui-text-muted);
    background-color: var(--ui-surface);
}

.ui-icon-btn:hover,
.ui-icon-btn-hover:hover {
    background-color: var(--ui-surface-hover);
}

/* ── Typography ─────────────────────────────────────────── */
.ui-page-title {
    font-weight: 700;
    color: var(--ui-text);
}
.ui-page-title-xl { font-size: 1.5rem; line-height: 2rem; }
.ui-page-title-lg { font-size: 1.25rem; line-height: 1.75rem; }
.ui-page-title-md { font-size: 1rem; line-height: 1.5rem; }

.ui-page-subtitle,
.ui-muted {
    color: var(--ui-text-muted);
}

.ui-caption {
    color: var(--ui-text-faint);
    font-size: 0.75rem;
}

.ui-text-strong {
    color: var(--ui-text);
    font-weight: 600;
}

.ui-text-body {
    color: var(--ui-text);
}

.ui-modal-title {
    font-weight: 600;
    color: var(--ui-text);
}

/* ── Surfaces ───────────────────────────────────────────── */
.ui-card {
    background-color: var(--ui-surface);
    border: 1px solid var(--ui-border);
    border-radius: 0.75rem;
    box-shadow: var(--ui-shadow);
}

.ui-card-inner {
    background-color: var(--ui-surface-inner);
    border: 1px solid var(--ui-border);
    border-radius: 0.75rem;
}

.ui-card-accent {
    background-color: var(--ui-surface);
    border: 1px solid var(--ui-border-strong);
    border-left: 3px solid var(--ui-accent);
    border-radius: 0.75rem;
    box-shadow: var(--ui-shadow);
}

.ui-panel-inset {
    background-color: var(--ui-surface-2);
    border: 1px solid var(--ui-border);
    border-radius: 0.5rem;
}

.ui-empty-icon {
    background-color: var(--ui-surface-2);
    border: 1px solid var(--ui-border);
}

.ui-quick-link {
    background-color: var(--ui-surface);
    border: 1px solid var(--ui-border);
    box-shadow: var(--ui-shadow);
    transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.ui-quick-link:hover {
    background-color: var(--ui-surface-2);
    border-color: var(--ui-border-strong);
}

/* ── Forms ──────────────────────────────────────────────── */
.ui-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--ui-text);
}

.ui-field {
    width: 100%;
    background-color: var(--ui-surface);
    border: 1px solid var(--ui-border-strong);
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: var(--ui-text);
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
}
.dark .ui-field {
    background-color: var(--ui-surface-2);
    box-shadow: none;
}
.ui-field::placeholder {
    color: var(--ui-text-faint);
}
.ui-field:focus {
    outline: none;
    border-color: var(--ui-accent);
    box-shadow: 0 0 0 3px var(--ui-accent-ring);
}

.ui-checkbox {
    border-radius: 0.25rem;
    border: 1px solid var(--ui-border-strong);
    background-color: var(--ui-surface);
}

.ui-file-input {
    font-size: 0.875rem;
    color: var(--ui-text-muted);
    cursor: pointer;
}
.ui-file-input::file-selector-button {
    margin-right: 0.75rem;
    padding: 0.375rem 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid var(--ui-border-strong);
    font-size: 0.75rem;
    font-weight: 600;
    background-color: var(--ui-surface-2);
    color: var(--ui-text);
    cursor: pointer;
}
.ui-file-input::file-selector-button:hover {
    background-color: var(--ui-surface-hover);
}

.file-selected-label {
    display: block;
    font-size: 0.75rem;
    margin-top: 4px;
    min-height: 1.1em;
    color: var(--ui-text-muted);
}
.file-selected-label.is-ok { color: #047857; }
.dark .file-selected-label.is-ok { color: #34d399; }
.file-selected-label.is-error { color: #b91c1c; }
.dark .file-selected-label.is-error { color: #f87171; }

/* ── Buttons ────────────────────────────────────────────── */
.ui-btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--ui-accent-fg);
    background-color: var(--ui-accent);
    border: 1px solid #a80f07;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    transition: background-color 0.15s, border-color 0.15s;
}
.ui-btn-primary:hover {
    background-color: var(--ui-accent-hover);
    border-color: #8b1009;
}

.ui-btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--ui-text);
    background-color: var(--ui-surface);
    border: 1px solid var(--ui-border-strong);
    transition: background-color 0.15s, border-color 0.15s;
}
.ui-btn-secondary:hover {
    background-color: var(--ui-surface-hover);
    border-color: var(--ui-border-strong);
}

.ui-btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--ui-text);
    background-color: var(--ui-surface);
    border: 1px solid var(--ui-border-strong);
    transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}
.ui-btn-ghost:hover {
    background-color: var(--ui-surface-hover);
    border-color: var(--ui-border-strong);
    color: var(--ui-text);
}

.ui-btn-muted {
    background-color: var(--ui-surface-2);
    color: var(--ui-text-muted);
    border: 1px solid var(--ui-border);
    border-radius: 0.5rem;
    font-weight: 500;
    transition: background-color 0.15s;
}
.ui-btn-muted:hover {
    background-color: var(--ui-surface-hover);
    color: var(--ui-text);
}

.ui-page-num {
    border: 1px solid var(--ui-border-strong);
    color: var(--ui-text-muted);
    font-weight: 600;
    background: var(--ui-surface);
}
.ui-page-num:hover {
    background: var(--ui-surface-hover);
    color: var(--ui-text);
}
.ui-page-num-active {
    background: var(--ui-accent);
    border: 1px solid #a80f07;
    color: var(--ui-accent-fg);
    font-weight: 700;
}

/* ── Tables ─────────────────────────────────────────────── */
.ui-divider-b {
    border-bottom: 1px solid var(--ui-border);
}

.ui-divider-b-subtle {
    border-bottom: 1px solid var(--ui-border-subtle);
}

.ui-thead-row,
.ui-table-head th {
    background-color: var(--ui-surface-2);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ui-text-muted);
}

.ui-table-divide > tr + tr {
    border-top: 1px solid var(--ui-border-subtle);
}

.ui-row-hover:hover {
    background-color: var(--ui-surface-hover);
}

.table-row-hover:hover td {
    background: var(--ui-surface-hover);
}

.ui-card table thead th {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ui-text-muted);
    background-color: var(--ui-surface-2);
    border-bottom: 1px solid var(--ui-border);
}

.ui-card table tbody tr {
    border-top: 1px solid var(--ui-border-subtle);
}

.ui-card table tbody tr:first-child {
    border-top: none;
}

.ui-code-pill {
    background-color: var(--ui-surface-2);
    border: 1px solid var(--ui-border-subtle);
}

.ui-badge-count {
    background-color: var(--ui-surface-2);
    border: 1px solid var(--ui-border-subtle);
    color: var(--ui-text-muted);
    font-weight: 600;
}

.ui-progress-track {
    background-color: var(--ui-border-subtle);
    border: 1px solid var(--ui-border);
}

/* ── Tabs ───────────────────────────────────────────────── */
.ui-tab {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 0.5rem 0.5rem 0 0;
    color: var(--ui-text-muted);
    border: 1px solid transparent;
    border-bottom: none;
    transition: color 0.15s, background-color 0.15s, border-color 0.15s;
}
.ui-tab:hover {
    color: var(--ui-text);
    background-color: var(--ui-surface-hover);
}

.ui-tab-active {
    color: var(--ui-text);
    background-color: var(--ui-tab-active-bg);
    border: 1px solid var(--ui-border);
    border-bottom-color: transparent;
}

.tab-underline {
    border-bottom: 2px solid transparent;
    transition: border-color 0.15s, color 0.15s;
    font-weight: 600;
}
.tab-underline.active,
.tab-underline[data-active="true"] {
    border-bottom-color: var(--ui-accent);
    color: #8b1009;
}
.dark .tab-underline.active,
.dark .tab-underline[data-active="true"] {
    color: #f55a4f;
}

/* ── Prose ──────────────────────────────────────────────── */
.ui-prose pre,
.prose-dark pre {
    background: var(--ui-prose-bg);
    border: 1px solid var(--ui-border);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    overflow-x: auto;
    font-size: 0.82rem;
    line-height: 1.65;
    color: var(--ui-prose-text);
}
.ui-prose code,
.prose-dark code {
    font-family: "Fira Code", "Cascadia Code", monospace;
}

/* ── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--ui-scrollbar); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--ui-scrollbar-hover); }

/* ── Motion ─────────────────────────────────────────────── */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
.animate-fade-in-up { animation: fadeInUp 0.3s ease both; }
.delay-1  { animation-delay: 0.05s; }
.delay-2  { animation-delay: 0.10s; }
.delay-3  { animation-delay: 0.15s; }
.delay-4  { animation-delay: 0.20s; }
.delay-5  { animation-delay: 0.25s; }
.delay-6  { animation-delay: 0.30s; }

@keyframes progress-indeterminate {
    0%   { transform: translateX(-100%) scaleX(0.5); }
    100% { transform: translateX(200%) scaleX(0.5); }
}
.progress-indeterminate {
    animation: progress-indeterminate 1.5s ease-in-out infinite;
}

/* ── Semaforo ─────────────────────────────────────────────── */
.dot-ok      { display:inline-block;width:8px;height:8px;border-radius:50%;background:#22c55e; }
.dot-warn    { display:inline-block;width:8px;height:8px;border-radius:50%;background:#f59e0b; }
.dot-error   { display:inline-block;width:8px;height:8px;border-radius:50%;background:#ef4444; }
.dot-neutral { display:inline-block;width:8px;height:8px;border-radius:50%;background:#6b7280; }

/* ── Focus ──────────────────────────────────────────────── */
input:focus, select:focus, textarea:focus, button:focus-visible {
    outline: 2px solid var(--ui-accent);
    outline-offset: 2px;
}
.ui-field:focus {
    outline: none;
}


/* ═══════════════════════════════════════════════════════
   ADDENDUM 09 — AGENTE CV
   (usa variabili del design system — light + dark auto)
   ═══════════════════════════════════════════════════════ */

/* ── Badge tab CV ─────────────────────────────────────── */
#badge-cv {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 4px;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 700;
    background-color: var(--ui-surface-2);
    color: var(--ui-text-muted);
    border: 1px solid var(--ui-border);
    vertical-align: middle;
}

/* ── Empty state ──────────────────────────────────────── */
.cv-empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--ui-text-faint);
}
.cv-empty-state .empty-icon { font-size: 3rem; margin-bottom: 1rem; }
.cv-empty-state h3 { margin-bottom: 0.5rem; color: var(--ui-text-muted); }
.cv-empty-state .hint { font-size: 0.85rem; margin-top: 1rem; }

/* ── Header CV ────────────────────────────────────────── */
.cv-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    gap: 1rem;
}
.cv-header-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--ui-text);
    margin: 0 0 2px;
}
.cv-subtitle { color: var(--ui-text-faint); font-size: 0.85rem; margin: 0; }
.cv-header-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

/* Bottone Carica CV header */
.ui-btn-cv-upload {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.4rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    background-color: var(--ui-surface-2);
    color: var(--ui-text);
    border: 1px solid var(--ui-border-strong);
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s;
}
.ui-btn-cv-upload:hover {
    background-color: var(--ui-surface-hover);
    border-color: var(--ui-accent);
}

/* ── Pannello upload CV ───────────────────────────────── */
.cv-upload-panel {
    background-color: var(--ui-surface-2);
    border: 1px solid var(--ui-border);
    border-radius: 0.75rem;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--ui-shadow-sm);
}
.cv-upload-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}
.cv-upload-title {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--ui-text);
    margin: 0;
}
.cv-upload-close {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--ui-text-faint);
    border-radius: 4px;
    display: flex;
    align-items: center;
}
.cv-upload-close:hover { color: var(--ui-text); background-color: var(--ui-surface-hover); }

.cv-upload-nota {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    background-color: var(--ui-surface-inner);
    border: 1px solid var(--ui-border-subtle);
    border-left: 3px solid var(--ui-accent);
    border-radius: 0.5rem;
    padding: 0.625rem 0.75rem;
    font-size: 0.78rem;
    color: var(--ui-text-muted);
    margin-bottom: 1rem;
    line-height: 1.5;
}
.cv-upload-nota svg { color: var(--ui-text-faint); flex-shrink: 0; }
.cv-upload-nota strong { color: var(--ui-text); }
/* Variante verde quando la figura è forzata (caricamento da sezione figura) */
.cv-upload-nota--forzata {
    background-color: color-mix(in srgb, var(--ui-success, #16a34a) 8%, var(--ui-surface-inner));
    border-color: var(--ui-border-subtle);
    border-left-color: #16a34a;
}
.cv-upload-nota--forzata svg { color: #16a34a; }
.dark .cv-upload-nota--forzata { border-left-color: #4ade80; }
.dark .cv-upload-nota--forzata svg { color: #4ade80; }
/* Garantisce icona + testo sulla stessa riga nel bottone download */
.ui-btn-download { white-space: nowrap; }

.cv-upload-form { display: flex; flex-direction: column; gap: 0.875rem; }
.cv-upload-actions { display: flex; gap: 8px; margin-top: 0.25rem; align-items: center; }

.cv-btn-avvia {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    font-weight: 700;
    background-color: #2563eb;
    color: #ffffff;
    border: none;
    cursor: pointer;
    transition: background-color 0.15s;
}
.cv-btn-avvia:hover { background-color: #1d4ed8; }

.cv-btn-annulla {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 0.875rem;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    background-color: transparent;
    color: var(--ui-text-muted);
    border: 1px solid var(--ui-border);
    cursor: pointer;
    transition: background-color 0.15s;
}
.cv-btn-annulla:hover { background-color: var(--ui-surface-hover); color: var(--ui-text); }

.cv-upload-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--ui-text-faint);
    margin-top: 4px;
}
.cv-upload-error {
    background-color: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #dc2626;
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    margin-top: 4px;
}
.dark .cv-upload-error { color: #f87171; }

/* ── Figura card ──────────────────────────────────────── */
.figura-card {
    border: 1px solid var(--ui-border);
    border-radius: 0.75rem;
    margin-bottom: 1.25rem;
    overflow: hidden;
    background-color: var(--ui-surface);
    box-shadow: var(--ui-shadow);
}
.figura-header {
    padding: 0.875rem 1.125rem;
    background-color: var(--ui-surface-2);
    border-bottom: 1px solid var(--ui-border);
}
.figura-ruolo {
    margin: 0 0 5px;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--ui-text);
}
.figura-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 5px; }
.meta-tag {
    font-size: 0.75rem;
    padding: 2px 8px;
    background-color: var(--ui-surface-inner);
    border: 1px solid var(--ui-border-subtle);
    border-radius: 12px;
    color: var(--ui-text-muted);
}
.copertura-ok { background-color: rgba(22, 163, 74, 0.12); border-color: rgba(22, 163, 74, 0.3); color: #15803d; }
.dark .copertura-ok { color: #4ade80; }
.copertura-ko { background-color: rgba(239, 68, 68, 0.1); border-color: rgba(239, 68, 68, 0.25); color: #dc2626; }
.dark .copertura-ko { color: #f87171; }
.figura-requisiti { margin: 0; font-size: 0.8rem; color: var(--ui-text-faint); line-height: 1.45; }

/* ── Tab figura ───────────────────────────────────────── */
.figura-tabs {
    display: flex;
    border-bottom: 1px solid var(--ui-border);
    background-color: var(--ui-surface);
}
.figura-tab {
    padding: 7px 14px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--ui-text-faint);
    border-bottom: 2px solid transparent;
    transition: color 0.15s;
}
.figura-tab.active { color: var(--ui-accent); border-bottom-color: var(--ui-accent); font-weight: 700; }
.figura-tab:hover:not(.active) { color: var(--ui-text-muted); }
.figura-tab-content { padding: 0.875rem 1.125rem; }

/* ── Lista CV vuota con bottone ───────────────────────── */
.cv-lista-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 1.5rem 1rem;
    text-align: center;
}
.cv-lista-vuota-msg {
    font-size: 0.85rem;
    color: var(--ui-text-faint);
    margin: 0;
}
.cv-btn-carica-figura {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.4rem 0.875rem;
    border-radius: 0.5rem;
    font-size: 0.78rem;
    font-weight: 600;
    background-color: var(--ui-surface-2);
    color: var(--ui-text-muted);
    border: 1px dashed var(--ui-border-strong);
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.cv-btn-carica-figura:hover {
    background-color: var(--ui-surface-hover);
    border-color: var(--ui-accent);
    color: var(--ui-text);
}

/* ── CV card ──────────────────────────────────────────── */
.cv-card {
    border: 1px solid var(--ui-border);
    border-radius: 0.5rem;
    padding: 0.75rem 0.875rem;
    margin-bottom: 0.625rem;
    background-color: var(--ui-surface);
    transition: border-color 0.15s;
}
.cv-card:hover { border-color: var(--ui-border-strong); }
.cv-card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.cv-card-info { flex: 1; min-width: 0; }
.cv-nome { display: block; font-weight: 600; font-size: 0.875rem; color: var(--ui-text); }
.cv-file { font-size: 0.75rem; color: var(--ui-text-faint); display: block; margin-top: 1px; }
.cv-card-stato { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex-shrink: 0; }
.punteggio-stimato { font-size: 0.75rem; color: var(--ui-text-muted); }
.cv-card-meta { margin-top: 5px; font-size: 0.75rem; color: var(--ui-text-faint); display: flex; flex-wrap: wrap; gap: 6px; }
.cv-figure-alt { color: #2563eb; }
.dark .cv-figure-alt { color: #60a5fa; }
.cv-card-azioni { display: flex; gap: 5px; margin-top: 8px; flex-wrap: wrap; }
.cv-card-elaborazione {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--ui-text-faint);
    font-size: 0.8rem;
    margin-top: 6px;
}

/* ── Badge conformita ─────────────────────────────────── */
.badge-conformita {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
    letter-spacing: 0.02em;
}
.badge-conforme { background-color: rgba(22, 163, 74, 0.15); color: #15803d; }
.dark .badge-conforme { color: #4ade80; background-color: rgba(74, 222, 128, 0.12); }
.badge-parzialmente-conforme { background-color: rgba(199, 19, 9, 0.15); color: #8b1009; }
.dark .badge-parzialmente-conforme { color: #f55a4f; background-color: rgba(232, 36, 24, 0.12); }
.badge-non-conforme { background-color: rgba(239, 68, 68, 0.12); color: #dc2626; }
.dark .badge-non-conforme { color: #f87171; background-color: rgba(248, 113, 113, 0.1); }
.badge-non-verificabile { background-color: var(--ui-surface-2); color: var(--ui-text-faint); border: 1px solid var(--ui-border); }
.badge-errore { background-color: rgba(239, 68, 68, 0.12); color: #dc2626; }
.dark .badge-errore { color: #f87171; }

/* ── Pulsanti azione card ─────────────────────────────── */
.btn-xs {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: 4px;
    border: 1px solid var(--ui-border-strong);
    background-color: var(--ui-surface-2);
    color: var(--ui-text-muted);
    cursor: pointer;
    transition: background-color 0.12s, color 0.12s;
}
.btn-xs:hover { background-color: var(--ui-surface-hover); color: var(--ui-text); }

.btn-danger-outline {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: 4px;
    border: 1px solid rgba(239, 68, 68, 0.4);
    background-color: transparent;
    color: #dc2626;
    cursor: pointer;
    transition: background-color 0.12s;
}
.dark .btn-danger-outline { color: #f87171; border-color: rgba(248, 113, 113, 0.35); }
.btn-danger-outline:hover { background-color: rgba(239, 68, 68, 0.08); }

/* ── Vista analitica ──────────────────────────────────── */
.analitico-header { display: flex; align-items: center; gap: 10px; margin-bottom: 1rem; flex-wrap: wrap; }
.analitico-header h3 { margin: 0; font-size: 0.95rem; color: var(--ui-text); }
.raccomandazione {
    background-color: var(--ui-surface-inner);
    border: 1px solid var(--ui-border-subtle);
    border-left: 3px solid #2563eb;
    padding: 0.625rem 0.875rem;
    margin-bottom: 1rem;
    font-size: 0.82rem;
    border-radius: 0 0.5rem 0.5rem 0;
    color: var(--ui-text-muted);
    line-height: 1.5;
}
.dark .raccomandazione { border-left-color: #60a5fa; }

.requisiti-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; margin-bottom: 1rem; }
.requisiti-table th {
    background-color: var(--ui-surface-2);
    color: var(--ui-text-muted);
    padding: 6px 8px;
    text-align: left;
    border: 1px solid var(--ui-border);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.requisiti-table td {
    padding: 6px 8px;
    border: 1px solid var(--ui-border);
    vertical-align: top;
    color: var(--ui-text-muted);
}
.req-conforme td { background-color: rgba(22, 163, 74, 0.04); }
.dark .req-conforme td { background-color: rgba(74, 222, 128, 0.04); }
.req-parzialmente-conforme td { background-color: rgba(199, 19, 9, 0.04); }
.req-non-conforme td { background-color: rgba(239, 68, 68, 0.04); }
.req-non-verificabile td { background-color: var(--ui-surface-inner); }

.badge-req { font-size: 0.68rem; padding: 1px 5px; border-radius: 3px; white-space: nowrap; font-weight: 700; }

.gap-bloccante { color: #dc2626; }
.dark .gap-bloccante { color: #f87171; }
.gap-normale { color: #8b1009; }
.dark .gap-normale { color: #f55a4f; }

/* ── Spinner sm ───────────────────────────────────────── */
.spinner-sm {
    width: 13px; height: 13px;
    border: 2px solid var(--ui-border);
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}
.ui-nav-heading { color: var(--ui-text-faint); }


/* ── Addendum 11: documenti, punteggio, esiti ── */
/* ═══════════════════════════════════════════════════════
   ADDENDUM 11 — Documenti, punteggi ed esiti ufficiali
   ═══════════════════════════════════════════════════════ */

/* ── Badge ─────────────────────────────────────────────── */
.badge-strong {
    font-size: 0.75rem; font-weight: 600; color: #856404; background: #fff3cd;
    border: 1px solid #ffe69c; border-radius: 4px; padding: 1px 6px;
    margin-left: 6px; vertical-align: middle;
}

/* ── Avvisi e riquadri informativi ─────────────────────── */
.doc-warning {
    margin-top: 1rem; padding: 0.85rem 1rem; background: #fff8e6;
    border: 1px solid #ffd980; border-left: 4px solid #f0a800;
    border-radius: 6px; color: #664d03; font-size: 0.9rem;
}
.alert-warning { background: #fff3cd; color: #664d03; border: 1px solid #ffe69c; border-radius: 6px; padding: 0.75rem 1rem; margin: 0.75rem 0; }
.alert-actions { margin-top: 0.75rem; display: flex; gap: 8px; flex-wrap: wrap; }

.info-box { background: #eef5ff; border: 1px solid #cfe0ff; border-radius: 6px; padding: 0.85rem 1.1rem; margin-bottom: 1.25rem; }
.info-box summary { cursor: pointer; font-weight: 600; }
.info-box ul, .info-box ol { margin: 0.5rem 0 0 1.1rem; padding: 0; }
.info-box li { margin-bottom: 4px; }
.info-box-compatto { background: #f6f8fa; border: 1px solid #e1e4e8; border-radius: 6px; padding: 0.6rem 0.9rem; margin: 0.75rem 0; font-size: 0.875rem; color: #495057; }
.info-box-compatto summary { cursor: pointer; font-weight: 600; }

/* ── Punteggio ─────────────────────────────────────────── */
.punteggio-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.punteggio-preview { min-height: 1.4rem; margin: 0.25rem 0 0.5rem; font-size: 0.9rem; }
.punteggio-ok { color: #155724; }
.punteggio-errore { color: #842029; font-weight: 600; }

/* ── Blocchi di gara_aggiorna.php ──────────────────────── */
.blocco { border: 1px solid #dee2e6; border-radius: 8px; padding: 1.25rem 1.5rem; margin-bottom: 1.5rem; background: #fff; }
.blocco h2 { margin-top: 0; font-size: 1.15rem; }
.form-aggiungi-documenti, .form-esiti-upload { margin-top: 1rem; padding-top: 1rem; border-top: 1px dashed #dee2e6; }
.form-actions { display: flex; gap: 8px; margin-top: 1.25rem; }

/* ── Stato esiti ───────────────────────────────────────── */
.esiti-stato { padding: 0.75rem 1rem; border-radius: 6px; margin: 0.75rem 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.esiti-nessuno { background: #f1f3f5; color: #495057; }
.esiti-elab { background: #e8f4f8; color: #0c5460; }
.esiti-verifica { background: #fff8e6; border: 1px solid #ffd980; }
.esiti-ok { background: #d4edda; color: #155724; }
.esiti-errore { background: #f8d7da; color: #721c24; }
.esiti-docs { list-style: none; padding: 0; margin: 0.5rem 0 1rem; }
.esiti-docs li { padding: 3px 0; font-size: 0.9rem; }
.esiti-azioni-secondarie { margin-top: 1rem; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.esiti-section { margin-top: 2rem; border-top: 2px solid #dee2e6; padding-top: 1.25rem; }

/* ── Controlli automatici ──────────────────────────────── */
.esiti-controllo { padding: 0.6rem 0.9rem; border-radius: 6px; margin-bottom: 0.5rem; font-size: 0.9rem; }
.controllo-ok { background: #d4edda; color: #155724; }
.gravita-alta { background: #fdecea; border-left: 4px solid #dc3545; }
.gravita-media { background: #fff4e5; border-left: 4px solid #fd7e14; }

/* ── Tabelle e liste della verifica ────────────────────── */
.esiti-table { width: 100%; border-collapse: collapse; margin-bottom: 0.75rem; font-size: 0.9rem; }
.esiti-table th, .esiti-table td { border: 1px solid #dee2e6; padding: 6px 8px; vertical-align: top; text-align: left; }
.esiti-table th { background: #f8f9fa; font-weight: 600; }
.esiti-table input[type=number] { width: 7rem; }
.esiti-table input[type=text], .esiti-table textarea { width: 100%; box-sizing: border-box; }
.somma-criteri { margin: 0.5rem 0 1rem; font-size: 0.875rem; color: #495057; }
.somma-ok { color: #155724; }
.somma-ko { color: #842029; font-weight: 600; }
.giudizi-lista { list-style: none; padding: 0; margin: 0 0 1rem; }
.giudizi-lista li { display: flex; align-items: flex-start; gap: 8px; padding: 8px 12px; margin-bottom: 6px; border-radius: 6px; background: #f8f9fa; border-left: 4px solid #6c757d; }
#lista-forza li { background: #f0fff4; border-left-color: #28a745; }
#lista-deboli li { background: #fff8f0; border-left-color: #fd7e14; }
.giudizio-testo { flex: 1; }
.applica-box { background: #f8f9fa; border: 1px solid #dee2e6; border-radius: 6px; padding: 0.75rem 1rem; margin: 1rem 0; }

/* ── Fonte dei giudizi nell'analisi ────────────────────── */
.fonte-badge { display: inline-block; font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; padding: 1px 6px; border-radius: 3px; margin-right: 6px; }
.fonte-commissione { background: #d4edda; color: #155724; }
.fonte-dedotta { background: #e9ecef; color: #495057; }

/* ── Archivio ──────────────────────────────────────────── */
.archivio-legenda { margin-top: 0.75rem; font-size: 0.8rem; color: #6c757d; }

.text-error { color: #842029; }

/* ── Addendum 11: campi documento (layout ordinato) ── */
.doc-field { display:flex; flex-direction:column; gap:.4rem; padding:.9rem 1rem; margin-top:.75rem;
  border:1px solid var(--ui-border); border-radius:.75rem; }
.doc-field-head { display:flex; flex-wrap:wrap; align-items:center; gap:.5rem; }
.doc-field-head label { font-size:.9rem; font-weight:600; color:var(--ui-text); }
.doc-field .form-hint, .form-hint { display:block; font-size:.78rem; line-height:1.45; color:var(--ui-text-muted); }
.doc-field input[type=file] { font-size:.85rem; color:var(--ui-text-muted); margin-top:.15rem; max-width:100%; }
.doc-field input[type=file]::file-selector-button { margin-right:.75rem; padding:.35rem .75rem; border-radius:.5rem;
  border:1px solid var(--ui-border-strong); font-size:.75rem; font-weight:600; background:transparent; color:var(--ui-text); cursor:pointer; }
.doc-field input[type=file]::file-selector-button:hover { background:var(--ui-surface-hover); }
.doc-field .file-selected-label { display:none; }
.doc-field-check { flex-direction:row; align-items:center; gap:.6rem; padding:.6rem 1rem; margin-top:.4rem; border-style:dashed; }
.doc-field-check input { width:1rem; height:1rem; accent-color:#c71309; flex-shrink:0; }
.doc-field-check span { font-size:.85rem; color:var(--ui-text); }
.badge-required, .badge-strong, .badge-optional { display:inline-block; margin:0; font-size:.68rem; font-weight:700;
  letter-spacing:.03em; text-transform:uppercase; padding:.1rem .5rem; border-radius:999px; border:1px solid transparent; }
.badge-required { color:#8b1009; background:rgba(199,19,9,.1); border-color:rgba(199,19,9,.3); }
.badge-strong   { color:#856404; background:#fff3cd; border-color:#ffe69c; }
.badge-optional { color:var(--ui-text-muted); background:transparent; border-color:var(--ui-border-strong); }
.dark .badge-required { color:#f55a4f; background:rgba(245,90,79,.12); border-color:rgba(245,90,79,.35); }
.dark .badge-strong { color:#f5c451; background:rgba(245,196,81,.12); border-color:rgba(245,196,81,.35); }
.doc-warning { background:rgba(240,168,0,.12) !important; color:var(--ui-text) !important; }
.info-box { background:transparent !important; border:1px solid var(--ui-border) !important; margin-bottom:.5rem !important; font-size:.85rem; color:var(--ui-text-muted); }
.info-box summary { color:var(--ui-text); }

[x-cloak] { display: none !important; }

.ui-wiki-active {
    background-color: var(--ui-accent-soft);
    color: #8b1009;
    font-weight: 600;
}
.dark .ui-wiki-active {
    color: #f55a4f;
}
