html,
body {
    background: #f6f7f5;
    color: #1f2a28;
    font-family: "Segoe UI", Arial, sans-serif;
}

h1,
h2 {
    letter-spacing: 0;
}

h1 {
    font-size: 1.9rem;
    font-weight: 650;
    margin: 0;
}

h2 {
    font-size: 1.2rem;
}

h1:focus {
    outline: none;
}

a,
.btn-link {
    color: #1f6f5f;
}

.btn-primary {
    background-color: #1f6f5f;
    border-color: #1f6f5f;
    color: #fff;
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: #18584c;
    border-color: #18584c;
}

.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-select:focus,
.form-check-input:focus {
    box-shadow: 0 0 0 0.15rem rgba(31, 111, 95, 0.22);
}

.content {
    max-width: 1160px;
    padding-top: 1.5rem;
}

.page-header {
    align-items: flex-start;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.action-cell {
    min-width: 160px;
    white-space: nowrap;
}

.meeting-table {
    background: #fff;
    border: 1px solid #dfe4df;
}

.meeting-table th {
    color: #5d6965;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
}

.status-badge {
    background: #e9f3ee;
    border: 1px solid #b9d9c9;
    border-radius: 999px;
    color: #15543f;
    display: inline-flex;
    font-size: 0.85rem;
    font-weight: 650;
    line-height: 1;
    padding: 0.45rem 0.65rem;
}

.status-badge.job-status-queued {
    background: #eef2ff;
    border-color: #c7d2fe;
    color: #3730a3;
}

.status-badge.job-status-running {
    background: #fff7ed;
    border-color: #fed7aa;
    color: #9a3412;
}

.status-badge.job-status-completed {
    background: #ecfdf5;
    border-color: #bbf7d0;
    color: #047857;
}

.status-badge.job-status-failed {
    background: #fef2f2;
    border-color: #fecaca;
    color: #b91c1c;
}

.toast-host {
    position: fixed;
    right: 1rem;
    top: 1rem;
    z-index: 1100;
}

.app-toast {
    border-radius: 8px;
    box-shadow: 0 12px 30px rgba(31, 42, 40, 0.18);
    color: #fff;
    font-weight: 650;
    min-width: 240px;
    padding: 0.75rem 1rem;
}

.app-toast-success {
    background: #1f6f5f;
}

.app-toast-error {
    background: #b42318;
}

.empty-state,
.form-panel,
.notes-section,
.audio-recorder,
.audio-section,
.transcription-section,
.glossary-section,
.settings-section {
    background: #fff;
    border: 1px solid #dfe4df;
    border-radius: 8px;
    padding: 1rem;
}

.empty-state {
    max-width: 560px;
}

.form-panel {
    max-width: 760px;
}

.detail-grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    margin-bottom: 1rem;
}

.detail-grid > div {
    background: #fff;
    border: 1px solid #dfe4df;
    border-radius: 8px;
    padding: 0.9rem;
}

.detail-label {
    color: #5d6965;
    display: block;
    font-size: 0.8rem;
    margin-bottom: 0.35rem;
    text-transform: uppercase;
}

.section-header,
.audio-recorder-header {
    align-items: flex-start;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.audio-recorder,
.audio-section,
.transcription-section,
.glossary-section,
.settings-section {
    margin-top: 1rem;
}

.microphone-test-panel {
    background: #f6f7f5;
    border: 1px solid #dfe4df;
    border-radius: 8px;
    margin-bottom: 1rem;
    padding: 1rem;
}

.microphone-test-panel h3 {
    font-size: 1rem;
    font-weight: 650;
    margin: 0;
}

.microphone-grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: minmax(220px, 1.4fr) minmax(160px, 1fr) minmax(160px, 1fr);
    margin-bottom: 1rem;
}

.microphone-grid label {
    color: #5d6965;
    display: flex;
    flex-direction: column;
    font-size: 0.85rem;
    font-weight: 650;
    gap: 0.35rem;
}

.audio-level-panel {
    display: grid;
    gap: 0.45rem;
    margin-bottom: 0.8rem;
}

.audio-level-bar {
    background: #e7ebe8;
    border: 1px solid #d1d9d4;
    border-radius: 999px;
    height: 14px;
    overflow: hidden;
}

.audio-level-fill {
    background: #9aa7a1;
    height: 100%;
    transition: width 0.18s ease, background-color 0.18s ease;
}

.audio-level-low {
    background: #c58b1f;
}

.audio-level-good {
    background: #1f6f5f;
}

.audio-level-high {
    background: #b42318;
}

.audio-level-meta {
    align-items: center;
    color: #5d6965;
    display: flex;
    justify-content: space-between;
}

.microphone-playback {
    border-top: 1px solid #dfe4df;
    margin-top: 1rem;
    padding-top: 1rem;
}

.microphone-playback audio {
    width: 100%;
}

.glossary-editor {
    background: #f6f7f5;
    border: 1px solid #dfe4df;
    border-radius: 8px;
    margin-bottom: 1rem;
    padding: 1rem;
}

.glossary-list {
    display: grid;
    gap: 0.75rem;
}

.glossary-row {
    align-items: center;
    border-top: 1px solid #dfe4df;
    display: grid;
    gap: 0.75rem;
    grid-template-columns: minmax(0, 1fr) auto auto;
    padding-top: 0.75rem;
}

.settings-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.settings-grid {
    display: grid;
    gap: 0.9rem;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.settings-grid label,
.wide-label {
    color: #5d6965;
    display: flex;
    flex-direction: column;
    font-size: 0.85rem;
    font-weight: 650;
    gap: 0.35rem;
}

.settings-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin: 1rem 0;
}

.settings-checks label {
    align-items: center;
    display: inline-flex;
    gap: 0.4rem;
}

.prompt-textarea {
    min-height: 180px;
}

.prompt-glossary {
    min-height: 90px;
}

.prompt-preview {
    font-family: Consolas, "Liberation Mono", monospace;
    min-height: 520px;
    white-space: pre-wrap;
}

.template-list {
    border-top: 1px solid #dfe4df;
    margin-top: 1rem;
}

.template-row {
    align-items: center;
    border-bottom: 1px solid #dfe4df;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    padding: 0.85rem 0;
}

.recording-timer {
    background: #1f2a28;
    border-radius: 6px;
    color: #fff;
    font-family: Consolas, "Liberation Mono", monospace;
    font-size: 1.1rem;
    font-weight: 700;
    min-width: 96px;
    padding: 0.45rem 0.65rem;
    text-align: center;
}

.audio-table {
    margin-bottom: 0;
}

.audio-table th {
    color: #5d6965;
    font-size: 0.78rem;
    text-transform: uppercase;
}

.audio-table code {
    color: #1f2a28;
    overflow-wrap: anywhere;
}

.transcript-box {
    background: #f6f7f5;
    border: 1px solid #dfe4df;
    border-radius: 6px;
    max-height: 420px;
    overflow: auto;
    padding: 1rem;
}

.transcript-box p {
    margin-bottom: 0.75rem;
}

.transcript-box p:last-child {
    margin-bottom: 0;
}

.audio-player-panel {
    align-items: center;
    background: #f6f7f5;
    border: 1px solid #dfe4df;
    border-radius: 8px;
    display: grid;
    gap: 1rem;
    grid-template-columns: minmax(220px, 1fr) minmax(260px, 1.4fr);
    margin-bottom: 1rem;
    padding: 1rem;
}

.meeting-audio-player {
    width: 100%;
}

.transcript-time {
    color: #5d6965;
    display: inline-block;
    font-family: Consolas, "Liberation Mono", monospace;
    font-size: 0.85rem;
    min-width: 74px;
}

.version-panel {
    margin-bottom: 1rem;
}

.speaker-panel {
    background: #f6f7f5;
    border: 1px solid #dfe4df;
    border-radius: 8px;
    margin-bottom: 1rem;
    padding: 1rem;
}

.speaker-panel h3 {
    font-size: 1rem;
    font-weight: 650;
    margin: 0;
}

.speaker-editor {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: minmax(180px, 1.3fr) minmax(140px, 1fr) minmax(90px, 0.5fr) auto;
    margin-bottom: 1rem;
}

.speaker-list {
    border-top: 1px solid #dfe4df;
}

.speaker-row {
    align-items: center;
    border-bottom: 1px solid #dfe4df;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    padding: 0.75rem 0;
}

.version-controls {
    align-items: center;
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.transcript-version-preview {
    max-height: 260px;
}

.segment-textarea {
    min-height: 92px;
}

.segment-state {
    background: #f1f3f2;
    border: 1px solid #dfe4df;
    border-radius: 999px;
    color: #5d6965;
    font-size: 0.78rem;
    font-weight: 700;
    justify-self: end;
    padding: 0.35rem 0.55rem;
}

.segment-state-edited {
    background: #e9f3ee;
    border-color: #b9d9c9;
    color: #15543f;
}

.quality-list {
    display: grid;
    gap: 1rem;
}

.job-actions,
.job-actions-cell {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.job-actions-cell {
    min-width: 260px;
}

.modal-backdrop-panel {
    align-items: center;
    background: rgba(31, 42, 40, 0.42);
    display: flex;
    inset: 0;
    justify-content: center;
    padding: 1rem;
    position: fixed;
    z-index: 1200;
}

.modal-panel {
    background: #fff;
    border: 1px solid #dfe4df;
    border-radius: 8px;
    box-shadow: 0 18px 46px rgba(31, 42, 40, 0.22);
    max-height: calc(100vh - 2rem);
    max-width: 920px;
    overflow: auto;
    padding: 1rem;
    width: min(920px, 100%);
}

.modal-header-row {
    align-items: flex-start;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.log-modal pre {
    background: #f6f7f5;
    border: 1px solid #dfe4df;
    border-radius: 6px;
    max-height: 360px;
    overflow: auto;
    padding: 0.75rem;
    white-space: pre-wrap;
}

.transcript-segment-modal {
    max-width: 760px;
}

.segment-modal-textarea {
    min-height: 220px;
}

.transcript-speaker-block {
    line-height: 1.8;
}

.transcript-speaker-label {
    color: #1f2a28;
    margin-right: 0.35rem;
}

.transcript-segment-inline {
    border-radius: 5px;
    padding: 0.1rem 0.15rem;
    transition: background-color 120ms ease;
}

.transcript-segment-inline-active {
    background: #e9f3ee;
    box-shadow: 0 0 0 0.15rem rgba(31, 111, 95, 0.08);
}

.transcript-segment-text {
    white-space: pre-wrap;
}

.transcript-segment-actions {
    display: inline-flex;
    gap: 0.1rem;
    margin-left: 0.15rem;
    vertical-align: text-bottom;
}

.transcript-segment-action {
    align-items: center;
    background: #fff;
    border: 1px solid #dfe4df;
    border-radius: 6px;
    color: #1f6f5f;
    display: inline-flex;
    height: 24px;
    justify-content: center;
    padding: 0;
    width: 24px;
}

.transcript-segment-action:hover:not(:disabled),
.transcript-segment-action:focus:not(:disabled) {
    background: #e9f3ee;
    border-color: #b9d9c9;
}

.transcript-segment-action:disabled {
    color: #9aa49f;
    cursor: not-allowed;
}

.btn .material-symbols-rounded {
    font-size: 1rem;
    margin-right: 0.25rem;
    vertical-align: -0.16rem;
}

.transcript-segment-action .material-symbols-rounded,
.modal-header-row .btn .material-symbols-rounded {
    margin-right: 0;
}

.sr-only {
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.quality-row {
    background: #fff;
    border: 1px solid #dfe4df;
    border-radius: 8px;
    padding: 1rem;
}

.quality-row-header {
    align-items: flex-start;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.quality-metrics {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    margin-bottom: 1rem;
}

.quality-metrics > div {
    background: #f6f7f5;
    border: 1px solid #dfe4df;
    border-radius: 6px;
    padding: 0.7rem;
}

.quality-metrics span {
    color: #5d6965;
    display: block;
    font-size: 0.76rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
}

.quality-metrics strong {
    overflow-wrap: anywhere;
}

.quality-filters,
.quality-compare {
    background: #fff;
    border: 1px solid #dfe4df;
    border-radius: 8px;
    margin-bottom: 1rem;
    padding: 1rem;
}

.quality-filters .form-grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.filter-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.9rem;
}

.checkbox-label {
    align-items: center;
    display: inline-flex;
    gap: 0.45rem;
    margin: 0;
}

.quality-section-header,
.quality-card-title,
.quality-status-stack {
    align-items: center;
    display: flex;
    gap: 0.75rem;
    justify-content: space-between;
}

.quality-section-header h2,
.quality-card-title h3 {
    margin: 0;
}

.quality-compare-grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.quality-compare-card {
    background: #fbfcfb;
    border: 1px solid #dfe4df;
    border-radius: 8px;
    min-width: 0;
    padding: 1rem;
}

.quality-row.preferred,
.quality-compare-card.preferred {
    border-color: #1f6f5f;
    box-shadow: 0 0 0 0.15rem rgba(31, 111, 95, 0.12);
}

.quality-detail-grid {
    display: grid;
    gap: 0.65rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 0 0 0.8rem;
}

.quality-detail-grid dt {
    color: #5d6965;
    font-size: 0.78rem;
}

.quality-detail-grid dd {
    font-weight: 650;
    margin: 0;
    overflow-wrap: anywhere;
}

.quality-select {
    align-items: flex-start;
    display: inline-flex;
    gap: 0.65rem;
    margin: 0;
}

.quality-select small {
    color: #5d6965;
    display: block;
    overflow-wrap: anywhere;
}

.quality-rating {
    align-items: end;
    display: grid;
    gap: 0.75rem;
    grid-template-columns: minmax(140px, 180px) minmax(240px, 1fr) minmax(120px, auto);
    margin: 0.9rem 0;
}

.quality-notes textarea {
    resize: vertical;
}

.quality-preferred-check {
    min-height: 38px;
}

.compact-alert {
    padding: 0.55rem 0.75rem;
}

.diagnostics-details {
    background: #f6f7f5;
    border: 1px solid #dfe4df;
    border-radius: 6px;
    margin-bottom: 1rem;
    padding: 0.7rem;
}

.diagnostics-details summary {
    cursor: pointer;
    font-weight: 650;
}

.diagnostics-details pre {
    margin: 0.7rem 0 0;
    max-height: 260px;
    overflow: auto;
    white-space: pre-wrap;
}

.transcript-preview {
    background: #f6f7f5;
    border: 1px solid #dfe4df;
    border-radius: 6px;
    margin-bottom: 1rem;
    padding: 0.85rem;
    white-space: pre-wrap;
}

.panel {
    background: #fff;
    border: 1px solid #dfe4df;
    border-radius: 8px;
    margin-bottom: 1rem;
    padding: 1rem;
}

.table-panel {
    overflow-x: auto;
}

.data-table {
    border-collapse: collapse;
    width: 100%;
}

.data-table th,
.data-table td {
    border-bottom: 1px solid #dfe4df;
    padding: 0.65rem;
    text-align: left;
    vertical-align: top;
}

.data-table th {
    color: #5d6965;
    font-size: 0.78rem;
    text-transform: uppercase;
}

.btn.primary {
    background: #1f6f5f;
    border-color: #1f6f5f;
    color: #fff;
}

.btn.danger {
    border-color: #b42318;
    color: #b42318;
}

.btn.small {
    font-size: 0.82rem;
    padding: 0.28rem 0.5rem;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    min-width: 260px;
}

.small {
    font-size: 0.82rem;
}

.muted {
    color: #5d6965;
}

.label {
    color: #5d6965;
    font-size: 0.78rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
}

.warning-list {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 6px;
    color: #9a3412;
    margin-top: 1rem;
    padding: 0.75rem;
}

.worker-filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    align-items: end;
}

.worker-filters label {
    display: grid;
    gap: 0.35rem;
    font-weight: 600;
}

.worker-table {
    min-width: 1180px;
}

.status-pill {
    align-items: center;
    border-radius: 999px;
    display: inline-flex;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 0.2rem 0.55rem;
}

.status-pill.queued {
    background: #eef2ff;
    color: #3730a3;
}

.status-pill.running {
    background: #fff7ed;
    color: #9a3412;
}

.status-pill.completed {
    background: #ecfdf5;
    color: #047857;
}

.status-pill.failed {
    background: #fef2f2;
    color: #b91c1c;
}

.warning-cell {
    max-width: 280px;
    white-space: normal;
}

.danger-text {
    color: #b91c1c;
}

.details-row pre {
    max-height: 320px;
    overflow: auto;
    white-space: pre-wrap;
}

.details-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #1f6f5f;
}

.invalid {
    outline: 1px solid #b42318;
}

.validation-message {
    color: #b42318;
}

#blazor-error-ui {
    background: #fff4cc;
    border-top: 1px solid #e2c56f;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.12);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    background: #b42318;
    color: white;
    padding: 1rem;
}

.blazor-error-boundary::after {
    content: "Si e verificato un errore.";
}

.loading-progress {
    display: block;
    height: 8rem;
    margin: 20vh auto 1rem auto;
    position: relative;
    width: 8rem;
}

.loading-progress circle {
    fill: none;
    stroke: #dfe4df;
    stroke-width: 0.6rem;
    transform: rotate(-90deg);
    transform-origin: 50% 50%;
}

.loading-progress circle:last-child {
    stroke: #1f6f5f;
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    font-weight: 700;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
    position: absolute;
    text-align: center;
}

.loading-progress-text::after {
    content: var(--blazor-load-percentage-text, "Caricamento");
}

code {
    color: #9f2d20;
}

@media (max-width: 640.98px) {
    .page-header {
        align-items: stretch;
        flex-direction: column;
    }

    .page-header .btn {
        width: 100%;
    }

    .action-cell {
        white-space: normal;
    }

    .section-header,
    .audio-recorder-header,
    .quality-row-header {
        align-items: stretch;
        flex-direction: column;
    }

    .audio-player-panel,
    .glossary-row,
    .microphone-grid,
    .speaker-editor {
        grid-template-columns: 1fr;
    }

    .speaker-row {
        align-items: stretch;
        flex-direction: column;
    }

    .quality-filters .form-grid,
    .quality-compare-grid,
    .quality-rating {
        grid-template-columns: 1fr;
    }

    .quality-section-header,
    .quality-card-title,
    .quality-status-stack {
        align-items: flex-start;
        flex-direction: column;
    }

    .version-controls {
        align-items: stretch;
        flex-direction: column;
    }

    .segment-state {
        justify-self: start;
    }
}
