/* ============================================
   LaboratorioSpoke - Global Styles
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #4ade80;
    /* Brighter, lime-ish green from screenshot */
    --primary-dark: #22c55e;
    --primary-light: #bbf7d0;
    --sidebar-bg: #333944;
    /* Dark gray */
    --secondary: #64748b;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --bg: #f5f6f8;
    /* Soft light gray for background */
    --bg-card: #ffffff;
    --border: #e2e8f0;
    --text: #334155;
    /* Dark text for body */
    --text-muted: #94a3b8;
    --sidebar-w: 260px;
    --sidebar-w-collapsed: 80px;
    --radius: 4px;
    /* Flatter UI from screenshot */
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    /* Softer shadows */
    --shadow-lg: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    overflow-y: auto;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
}

/* ---- LAYOUT ---- */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    transition: width 0.3s;
    z-index: 100;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.05);
    /* Softer shadow */
    flex-shrink: 0;
}

.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: margin-left 0.3s;
}

/* ---- SIDEBAR COLLAPSED STATE ---- */
.app-wrapper.sidebar-collapsed .sidebar {
    width: var(--sidebar-w-collapsed);
}

.app-wrapper.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-w-collapsed);
}

.app-wrapper.sidebar-collapsed .logo-text,
.app-wrapper.sidebar-collapsed .user-info,
.app-wrapper.sidebar-collapsed .nav-link span:not(.nav-icon),
.app-wrapper.sidebar-collapsed .btn-logout span:not(.nav-icon) {
    display: none;
}

.app-wrapper.sidebar-collapsed .sidebar-logo {
    justify-content: center;
    padding: 1.5rem 0;
}

.app-wrapper.sidebar-collapsed .sidebar-user {
    justify-content: center;
    padding: 1rem 0;
}

.app-wrapper.sidebar-collapsed .nav-link {
    justify-content: center;
    padding: 0.8rem 0;
}

.app-wrapper.sidebar-collapsed .btn-logout {
    justify-content: center;
}


.sidebar-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo .logo-img {
    max-width: 80%;
    height: auto;
    max-height: 50px;
    background-color: #ffffff;
    padding: 6px 10px;
    border-radius: 6px;
}

.sidebar-user {
    padding: 2.5rem 1rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    border-bottom: 2px solid var(--primary);
    /* Green separator */
    margin-bottom: 1rem;
}

.user-avatar-large {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 2rem;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(74, 222, 128, 0.3);
}

.user-info {
    text-align: center;
}

.user-name {
    font-size: 1rem;
    font-weight: 700;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: block;
}

.user-role {
    font-size: 0.75rem;
    color: #cbd5e1;
    text-transform: uppercase;
    display: block;
    margin-top: 0.2rem;
}

.sidebar-nav {
    padding: 0 1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.nav-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0;
    color: #cbd5e1;
    text-decoration: none;
    transition: all 0.2s;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-link-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-icon {
    display: none;
    /* Removed standard icons for flat text layout */
}

.nav-chevron {
    color: var(--primary);
    font-size: 1.1rem;
    font-weight: bold;
}

.nav-link:hover {
    color: white;
    border-bottom-color: var(--primary);
}

.nav-link.active {
    color: white;
    border-bottom-color: var(--primary);
}

.nav-link.active .nav-link-content {
    color: var(--primary);
}

.sidebar-footer {
    padding: 1rem 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-logout {
    width: 100%;
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #cbd5e1;
    padding: 0.75rem;
    cursor: pointer;
    font-size: 0.85rem;
    text-transform: uppercase;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.15s;
    border-radius: 0;
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

/* ---- TOPBAR ---- */
.topbar {
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    background: white;
    height: 60px;
    /* Fixed height for sharp look */
    border-bottom: 2px solid var(--border);
    box-shadow: none;
}

.sidebar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--text);
    padding: 0.5rem;
    margin-right: 1.5rem;
}

.topbar-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 1;
}

.topbar-title {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text);
    letter-spacing: -0.02em;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--secondary);
}

.topbar-user-badge {
    width: 32px;
    height: 32px;
    background: var(--primary);
    border-radius: 50%;
    display: block;
}

.page-body {
    padding: 0.75rem 1.5rem;
    flex: 1;
}

/* ---- PAGES ---- */
.page-container {
    max-width: 1200px;
    margin: 0 auto;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
}

/* ---- BUTTONS ---- */
.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.5rem 1.25rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: background 0.15s;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: default;
}

.btn-primary.btn-large {
    padding: 0.75rem 2rem;
    font-size: 1rem;
}

.btn-secondary {
    background: white;
    color: var(--text);
    border: 1px solid var(--border);
    padding: 0.5rem 1.25rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: background 0.15s;
}

.btn-secondary:hover {
    background: var(--bg);
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0.25rem;
    border-radius: 4px;
    transition: background 0.15s;
}

.btn-icon:hover {
    background: var(--bg);
}

.btn-add {
    background: var(--primary-light);
    color: var(--primary);
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s;
}

.btn-add:hover {
    background: var(--primary);
    color: white;
}

.btn-remove {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    flex-shrink: 0;
}

.btn-remove:hover {
    background: #fee2e2;
}

/* ---- FORMS ---- */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.form-group label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.875rem;
    color: var(--text);
    background: white;
    transition: border-color 0.15s;
    font-family: inherit;
    width: 100%;
    box-sizing: border-box;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    width: 100%;
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
}

/* ---- AUTOCOMPLETE ---- */
.form-group {
    position: relative;
}

.autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.autocomplete-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-light, #eee);
    transition: background 0.1s;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover {
    background: var(--primary-light, #f0f7ff);
}

.autocomplete-item strong {
    color: var(--primary);
    font-weight: 700;
}

/* ---- SEARCH ---- */
.search-bar {
    margin-bottom: 1rem;
}

.search-bar input {
    width: 100%;
    padding: 0.6rem 1rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.9rem;
    background: white;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* ---- TABLES ---- */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.data-table th {
    background: var(--bg);
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
    vertical-align: middle;
}

.data-table tbody tr:hover {
    background: #f8fafc;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

/* ---- ALERTS & BADGES ---- */
.alert-error {
    background: #fee2e2;
    color: #991b1b;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    border: 1px solid #fca5a5;
    margin: 0.75rem 0;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    border: 1px solid #fcd34d;
    margin: 0.75rem 0;
}

.info-box {
    background: #eff6ff;
    color: #1d4ed8;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
}

.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-role {
    background: #dbeafe;
    color: #1d4ed8;
    padding: 0.2rem 0.5rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-stato {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-blue {
    background: #dbeafe;
    color: #1e40af;
}

.badge-green {
    background: #dcfce7;
    color: #166534;
}

.badge-orange {
    background: #ffedd5;
    color: #9a3412;
}

.badge-gray {
    background: #f1f5f9;
    color: #475569;
}

/* ---- LOADING ---- */
.loading-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    gap: 1rem;
    color: var(--secondary);
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}

.spinner-large {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ---- WIZARD ---- */
.wizard-container {
    /*max-width: 1000px;*/
    margin: 0 auto;
    padding: 0 1rem;
    width: 100%;
}

@media (max-width: 768px) {
    .wizard-container {
        max-width: 100%;
        padding: 0 0.5rem;
    }
}

.wizard-steps {
    display: flex;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

@media (max-width: 480px) {
    .wizard-steps {
        justify-content: center;
        gap: 0.25rem;
    }
}

.step {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.step-num {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--border);
    color: var(--secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    transition: all 0.3s;
    flex-shrink: 0;
}

.step.active .step-num {
    background: var(--primary);
    color: white;
}

.step.done .step-num {
    background: var(--success);
    color: white;
}

.step-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--secondary);
    white-space: nowrap;
}

@media (max-width: 480px) {
    .step-label {
        display: none;
    }
}

.step.active .step-label {
    color: var(--primary);
    font-weight: 600;
}

.step-line {
    flex: 1;
    height: 2px;
    background: var(--border);
    margin: 0 0.5rem;
    min-width: 20px;
}

@media (max-width: 480px) {
    .step-line {
        margin: 0 0.25rem;
        min-width: 10px;
    }
}

.wizard-panel {
    background: white;
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    overflow-x: hidden;
}

@media (max-width: 768px) {
    .wizard-panel {
        padding: 1.5rem 1rem;
    }
}

@media (max-width: 480px) {
    .wizard-panel {
        padding: 1rem 0.75rem;
    }
}

.wizard-panel h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    word-break: break-word;
    overflow-wrap: break-word;
}

@media (max-width: 480px) {
    .wizard-panel h2 {
        font-size: 1.1rem;
        margin-bottom: 1rem;
    }
}

.wizard-nav {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

@media (max-width: 480px) {
    .wizard-nav {
        flex-direction: column;
        gap: 0.75rem;
    }

    .wizard-nav button {
        width: 100%;
    }
}

/* Results */
.results-list {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-height: 280px;
    overflow-y: auto;
    margin-bottom: 1rem;
}

@media (max-width: 480px) {
    .results-list {
        max-height: 200px;
    }
}

.result-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid var(--border);
}

.result-item:last-child {
    border-bottom: none;
}

.result-item:hover {
    background: var(--primary-light);
}

.result-item.selected {
    background: var(--primary-light);
    border-left: 3px solid var(--primary);
}

.patient-name {
    font-weight: 600;
    font-size: 0.9rem;
    word-break: break-word;
    overflow-wrap: break-word;
}

.patient-meta {
    font-size: 0.8rem;
    color: var(--secondary);
    word-break: break-word;
    overflow-wrap: break-word;
}

.results-small .result-item {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.selected-patient-info {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.new-patient-form {
    margin-top: 1rem;
    padding: 1.5rem;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.new-patient-form h3 {
    margin-bottom: 1rem;
    font-size: 1rem;
}

/* Esami grid */
.esami-grid {
    display: grid;
    grid-template-columns: 1fr 540px;
    gap: 1rem;
    margin-top: 1rem;
}

@media (max-width: 900px) {
    .esami-grid {
        grid-template-columns: 1fr 380px;
    }
}

@media (max-width: 768px) {
    .esami-grid {
        grid-template-columns: 1fr;
    }
}

.esami-catalog {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 1rem;
    max-height: 440px;
    overflow-y: auto;
    border: 1px solid var(--border);
}

.esami-catalog h3,
.esami-selected h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--secondary);
    margin-bottom: 0.5rem;
}

.esame-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 0.4rem;
    cursor: pointer;
    transition: all 0.15s;
    flex-wrap: wrap;
}

@media (max-width: 480px) {
    .esame-item {
        padding: 0.4rem 0.5rem;
        gap: 0.25rem;
    }
}

.esame-item:hover {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.esame-cod {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary);
    min-width: 70px;
    word-break: break-word;
}

.esame-desc {
    flex: 1;
    font-size: 0.8rem;
    word-break: break-word;
    overflow-wrap: break-word;
}

.esame-price {
    font-size: 0.8rem;
    color: var(--secondary);
    min-width: 60px;
    text-align: right;
}

.esami-selected {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 1rem;
    max-height: 440px;
    overflow-y: auto;
    border: 1px solid var(--border);
}

.esame-selected-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: white;
    border-radius: 8px;
    margin-bottom: 0.4rem;
    border: 1px solid var(--border);
}

.esame-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.esami-total {
    padding: 0.75rem;
    background: var(--primary-light);
    border-radius: 8px;
    text-align: right;
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

.empty-state {
    text-align: center;
    color: var(--secondary);
    padding: 2rem;
    font-size: 0.875rem;
}

/* Summary */
.summary-card {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    border: 1px solid var(--border);
    max-width: 900px;
}

@media (max-width: 380px) {
    .summary-card {
        padding: 1rem 0.75rem;
    }
}

.summary-section {
    margin-bottom: 1.5rem;
}

.summary-section h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.summary-esame {
    display: flex;
    justify-content: space-between;
    padding: 0.3rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.summary-esame span:first-child {
    flex: 1;
    word-break: break-word;
    overflow-wrap: break-word;
}

.summary-total {
    text-align: right;
    padding-top: 0.75rem;
    font-size: 0.9rem;
}

/* ---- PRINT ---- */
.print-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    align-items: center;
}

.print-document {
    background: white;
    padding: 2.5rem;
    max-width: 800px;
    margin: 0 auto 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}

.print-header {
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--text);
}

.print-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.print-header-azienda {
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    font-size: 0.9rem;
}

.print-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

.print-header h2 {
    font-size: 1rem;
    font-weight: 400;
    color: var(--secondary);
}

.print-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 0.75rem;
    font-size: 0.875rem;
}

.print-section {
    margin-bottom: 1.5rem;
}

.print-section h3 {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--secondary);
    margin-bottom: 0.75rem;
    letter-spacing: 0.05em;
}

.info-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.info-table td {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border);
}

.info-table td:first-child {
    background: var(--bg);
    font-weight: 500;
    width: 35%;
}

.esami-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.esami-table th {
    background: var(--text);
    color: white;
    padding: 0.4rem 0.75rem;
    text-align: left;
}

.esami-table td {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border);
}

.print-signature {
    display: flex;
    justify-content: space-between;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    font-size: 0.875rem;
}

.labels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.label-group {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 1rem;
    border: 1px solid var(--border);
}

.label-group-header {
    font-size: 0.825rem;
    font-weight: 600;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.label-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.6rem;
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
    border-left: 3px solid var(--primary);
}

.label-patient {
    font-weight: 700;
    font-size: 0.875rem;
}

.label-dob {
    color: var(--secondary);
    font-size: 0.75rem;
}

.label-esame {
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

.label-material {
    font-size: 0.75rem;
    color: var(--secondary);
    margin-top: 0.2rem;
}

.page-break {
    height: 2rem;
}

/* ---- AGENTE DASHBOARD ---- */
.date-selector {
    display: flex;
    gap: 0.75rem;
}

.date-selector select {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.875rem;
    background: white;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    background: white;
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.kpi-primary {
    border-top: 3px solid var(--primary);
}

.kpi-secondary {
    border-top: 3px solid var(--secondary);
}

.kpi-info {
    border-top: 3px solid #06b6d4;
}

.kpi-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.kpi-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
    margin-bottom: 0.5rem;
}

.kpi-trend {
    font-size: 0.825rem;
    font-weight: 500;
}

.trend-up {
    color: var(--success);
}

.trend-down {
    color: var(--danger);
}

.chart-container {
    background: white;
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

.chart-container h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
}

.chart-bars {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    height: 180px;
    padding-top: 2rem;
}

.bar-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    flex: 1;
}

.bar-value {
    font-size: 0.65rem;
    color: var(--secondary);
    white-space: nowrap;
}

.bar {
    width: 100%;
    background: #bfdbfe;
    border-radius: 4px 4px 0 0;
    min-height: 4px;
    transition: height 0.5s ease;
}

.bar-wrapper.bar-current .bar {
    background: var(--primary);
}

.bar-label {
    font-size: 0.65rem;
    color: var(--secondary);
    white-space: nowrap;
}

.breakdown-table {
    background: white;
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.breakdown-table h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

/* ---- LOGIN ---- */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}

.login-card {
    background: white;
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.logo-big {
    font-size: 3rem;
    display: block;
    margin-bottom: 0.5rem;
}

.login-logo h1 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text);
}

.login-logo p {
    color: var(--secondary);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.login-tabs {
    display: flex;
    background: var(--bg);
    border-radius: 10px;
    padding: 0.25rem;
    margin-bottom: 1.5rem;
}

.login-tabs button {
    flex: 1;
    padding: 0.5rem;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--secondary);
    transition: all 0.15s;
}

.login-tabs button.active {
    background: white;
    color: var(--primary);
    box-shadow: var(--shadow);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.btn-login {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-login:hover {
    background: var(--primary-dark);
}

.btn-login:disabled {
    opacity: 0.7;
    cursor: default;
}

/* ---- MODAL ---- */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
    padding: 0;
    margin: 0;
}

.modal {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    min-width: 320px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    box-sizing: border-box;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
}

.modal-header button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--secondary);
    border-radius: 6px;
    padding: 0.25rem;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    box-sizing: border-box;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .modal {
        width: 95%;
        max-width: 100%;
    }

    .modal-header {
        padding: 1rem 1.25rem;
    }

    .modal-body {
        padding: 1.25rem;
    }

    .modal-footer {
        padding: 0.75rem 1.25rem;
        flex-direction: column;
    }

    .modal-footer button {
        width: 100%;
    }

    .form-grid {
        gap: 0.75rem;
    }
}

/* ---- PAGINATION ---- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
    font-size: 0.875rem;
    color: var(--secondary);
}

/* ---- CHECKOUT & BOLLE ---- */
.checkout-page, .bolle-page, .bolla-detail-page {
    max-width: 1200px;
    margin: 0 auto;
}

.checkout-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 1.5rem;
}

@media (max-width: 1000px) {
    .checkout-container {
        grid-template-columns: 1fr;
    }
}

.checkout-panel {
    background: white;
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.checkout-panel h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.search-box {
    margin-bottom: 1rem;
}

.search-box input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.875rem;
}

.accettazioni-list {
    flex: 1;
    overflow-y: auto;
    max-height: 500px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem;
}

.accettazione-item {
    padding: 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.15s;
}

.accettazione-item:hover {
    background: white;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.acc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.3rem;
    gap: 0.5rem;
}

.acc-header strong {
    flex: 1;
    word-break: break-word;
}

.acc-header .badge {
    flex-shrink: 0;
}

.acc-details {
    display: flex;
    gap: 0.75rem;
    font-size: 0.75rem;
    color: var(--secondary);
}

.selected-list {
    flex: 1;
    overflow-y: auto;
    max-height: 350px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem;
    margin-bottom: 1rem;
}

.selected-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: var(--primary-light);
    border: 1px solid var(--primary);
    border-radius: 6px;
    margin-bottom: 0.5rem;
    gap: 0.5rem;
}

.selected-content {
    flex: 1;
    min-width: 0;
}

.selected-content > div {
    word-break: break-word;
}

.selected-content .small-text {
    font-size: 0.75rem;
    color: var(--secondary);
    margin-top: 0.1rem;
}

.btn-remove {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 1rem;
    padding: 0.2rem 0.4rem;
    flex-shrink: 0;
}

.btn-remove:hover {
    background: rgba(220, 38, 38, 0.1);
    border-radius: 4px;
}

.notes-section {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    margin-bottom: 1rem;
}

.notes-section label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--secondary);
}

.notes-section textarea {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.875rem;
    min-height: 80px;
    font-family: inherit;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.action-buttons button,
.action-buttons a {
    width: 100%;
}

.no-data {
    color: var(--secondary);
    text-align: center;
    padding: 2rem 1rem;
    font-size: 0.875rem;
}

/* Bolle List */
.bolle-table-container {
    background: white;
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-top: 1.5rem;
}

.bolle-table {
    width: 100%;
    border-collapse: collapse;
}

.bolle-table thead {
    background: var(--bg);
}

.bolle-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}

.bolle-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}

.bolle-table tbody tr:hover {
    background: #f8fafc;
}

.action-cell {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn-small {
    padding: 0.35rem 0.75rem;
    font-size: 0.75rem;
    border-radius: 6px;
    text-decoration: none;
    display: inline-block;
    background: white;
    color: var(--text);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.15s;
}

.btn-small:hover {
    background: var(--bg);
}

.btn-danger {
    background: var(--danger);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-danger:hover {
    background: #991b1b;
}

.btn-danger:disabled {
    opacity: 0.6;
    cursor: default;
}

/* Bolla Detail */
.bolla-detail-page {
    margin-top: 1.5rem;
}

.bolla-header {
    background: white;
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    margin-bottom: 1.5rem;
}

.header-item label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: block;
    margin-bottom: 0.5rem;
}

.header-item span {
    font-size: 1rem;
    color: var(--text);
}

.bolla-notes {
    background: #fffbeb;
    border: 1px solid #fcd34d;
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}

.section {
    background: white;
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

.section h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.accettazioni-table {
    width: 100%;
    border-collapse: collapse;
}

.accettazioni-table thead {
    background: var(--bg);
}

.accettazioni-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}

.accettazioni-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}

.accettazioni-table tbody tr:hover {
    background: #f8fafc;
}

.add-section {
    background: #f0fdf4;
    border: 1px solid #86efac;
}

.available-list {
    max-height: 350px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem;
}

.danger-section {
    background: #fef2f2;
    border: 1px solid #fca5a5;
}

.danger-section p {
    font-size: 0.875rem;
    color: var(--text);
    margin-bottom: 1rem;
}

/* Badges */
.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

/* Alerts */
.alert-success {
    background: #dcfce7;
    color: #166534;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    border: 1px solid #86efac;
    margin: 0.75rem 0;
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    border: 1px solid #93c5fd;
    margin: 0.75rem 0;
}

/* Header Buttons */
.header-buttons {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* Print Table */
.print-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.print-table th {
    background: var(--text);
    color: white;
    padding: 0.6rem 0.75rem;
    text-align: left;
    font-weight: 600;
}

.print-table td {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
}

.print-table tbody tr:nth-child(even) {
    background: #f8fafc;
}

/* Print Footer */
.print-footer {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    text-align: right;
    font-size: 0.875rem;
}

/* Signature Styles */
.print-signature {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.signature-table {
    width: 100%;
    border-collapse: collapse;
}

.signature-box {
    width: 45%;
    text-align: center;
    padding: 1rem;
}

.signature-box p {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.signature-line {
    border-bottom: 1px solid var(--text);
    height: 60px;
    margin: 1rem 0;
}

.signature-area {
    border: 1px dashed var(--border);
    height: 80px;
    margin: 0.5rem 0;
}

/* ---- PRINT STYLES ---- */
@media print {
    .no-print {
        display: none !important;
    }

    .sidebar,
    .topbar {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
    }

    .print-document {
        box-shadow: none !important;
        border: none !important;
        page-break-after: always;
    }

    .page-break {
        page-break-after: always;
    }
}