* { box-sizing: border-box; }
body { margin: 0; font-family: Segoe UI, Arial, sans-serif; background: #f3f4f6; color: #1f2937; }
header { background: #1e3a5f; color: #fff; display: flex; justify-content: space-between; align-items: center; padding: 10px 24px; }
header a, button.link { color: #fff; text-decoration: none; margin-left: 16px; background: none; border: 0; cursor: pointer; font: inherit; }
main { max-width: 1200px; margin: 24px auto; padding: 0 16px; }
.card { background: #fff; border-radius: 10px; padding: 16px 20px; margin-bottom: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.narrow { max-width: 480px; margin: 40px auto; }
label { display: block; margin-bottom: 12px; font-weight: 600; }
input, select, textarea { display: block; width: 100%; padding: 8px; margin-top: 4px; border: 1px solid #cbd5e1; border-radius: 6px; font: inherit; }
button, .btn { background: #1e3a5f; color: #fff; border: 0; border-radius: 6px; padding: 8px 14px; cursor: pointer; text-decoration: none; display: inline-block; font: inherit; }
button.ok { background: #15803d; } button.danger { background: #b91c1c; }
form.inline { display: inline; } form.inline select { width: auto; display: inline; }
.actions { display: flex; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.full { grid-column: 1 / -1; }
.admin-links { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin: 20px 0; }
.stat-box { text-align: center; }
.big-number { font-size: 2rem; font-weight: 700; margin: 6px 0 0; }
.admin-tabs { display: flex; gap: 12px; margin-bottom: 16px; }
.tab-link { display: inline-block; padding: 10px 16px; background: #e5e7eb; color: #1f2937; text-decoration: none; border-radius: 8px 8px 0 0; font-weight: 600; }
.tab-link.active { background: #1e3a5f; color: #fff; }
.admin-panels { display: grid; grid-template-columns: 1.2fr 1fr; gap: 20px; }
.admin-panel { min-width: 0; }
.admin-settings-form { max-width: 900px; }
.account-settings-section { max-width: 800px; padding: 16px 0; border-bottom: 1px solid #d1d5db; }
.account-settings-section h2 { margin-top: 0; }
.account-settings-form { max-width: 760px; }
.admin-settings-section { padding: 16px 0; border-bottom: 1px solid #d1d5db; }
.admin-settings-section h2 { margin-top: 0; }
.setting-color-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.setting-color-grid input[type="color"] { height: 44px; padding: 3px; }
.setting-checkbox { display: flex; align-items: center; gap: 8px; }
.setting-checkbox input[type="checkbox"] { display: inline-block; width: auto; margin: 0; }
.technician-price-fields { grid-column: 1 / -1; }
.technician-schedule-dialog { width: min(680px, calc(100% - 32px)); border: 1px solid #cbd5e1; border-radius: 6px; padding: 20px; color: #1f2937; }
.technician-schedule-dialog::backdrop { background: rgba(15,23,42,.5); }
.technician-schedule-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.technician-schedule-header h2 { margin: 0; }
.technician-schedule-input { display: flex; align-items: center; gap: 8px; }
.technician-schedule-input input { max-width: 140px; }
.inner-card { background: #f8fafc; border: 1px solid #e2e8f0; }
.compact-form-stack { display: flex; flex-direction: column; gap: 8px; }
.compact-form-stack form, .inline-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.compact-form-stack input, .inline-actions input { min-width: 120px; }
.inline-actions { align-items: flex-end; }
.inline-actions form { display: inline-flex; align-items: center; gap: 8px; }
.customer-actions-cell { min-width: 220px; }
.customer-row-actions { display: flex; flex-flow: row nowrap; align-items: center; gap: 6px; width: max-content; white-space: nowrap; }
.customer-row-actions form { display: flex; flex: 0 0 34px; margin: 0; }
.customer-row-actions .icon-button { flex: 0 0 34px; }
table { width: 100%; border-collapse: collapse; background: #fff; margin-bottom: 24px; }
th, td { padding: 8px 10px; border-bottom: 1px solid #e5e7eb; text-align: left; vertical-align: top; }
th { background: #e5e7eb; }
.intake-table { table-layout: fixed; }
.intake-table th:nth-child(1) { width: 145px; }
.intake-table th:nth-child(2) { width: 150px; }
.intake-table th:nth-child(4) { width: 110px; }
.intake-table th:nth-child(5) { width: 170px; }
.intake-table td { vertical-align: middle; }
.intake-table input, .intake-table textarea { margin: 0; border-radius: 2px; background: #fff; }
.intake-table textarea { min-height: 52px; resize: vertical; }
.intake-table td:nth-child(4) input { min-width: 72px; }
.intake-actions { white-space: nowrap; }
.intake-actions form { display: inline-block; margin: 2px; }
.intake-actions button, .intake-table button { padding: 6px 9px; border-radius: 3px; }
.intake-new-row { background: #f0fdf4; }
.report-tabs { display: flex; gap: 8px; margin: 12px 0; border-bottom: 1px solid #cbd5e1; }
.report-tabs button { border-radius: 4px 4px 0 0; }
.report-tabs button[aria-selected="true"] { background: #15803d; }
.report-panel h3 { margin-top: 16px; }
.table-scroll { max-width: 100%; overflow-x: auto; }
.report-table { min-width: 900px; table-layout: auto; }
.report-table input:not([type="checkbox"]) { min-width: 115px; }
.report-table input[type="checkbox"] { display: inline-block; width: auto; margin: 0 6px 0 0; vertical-align: middle; }
.report-table td, .report-table th { vertical-align: middle; }
.report-billable { white-space: nowrap; }
.icon-button { width: 34px; height: 34px; padding: 6px; display: inline-flex; align-items: center; justify-content: center; vertical-align: middle; border: 1px solid #cbd5e1; border-radius: 4px; background: #fff; color: #1e3a5f; }
.icon-button:hover { background: #f1f5f9; }
.icon-button.danger { color: #475569; background: #fff; }
.icon-button.confirm { color: #15803d; background: #fff; }
.icon-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-button:disabled { opacity: .4; cursor: not-allowed; }
.report-row-actions { display: flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; }
.report-row-actions form { display: inline-flex; margin: 0; }
.report-table td.report-row-actions { vertical-align: middle; }
.ticket-attachment-table { max-width: 760px; }
.ticket-attachment-table th:last-child { width: 150px; }
.ticket-attachment-table td { vertical-align: middle; }
.ticket-attachment-table .report-row-actions { white-space: nowrap; }
.ticket-attachment-table .ticket-attachment-upload { margin: 0; }
.visually-hidden-file-input { position: absolute; width: 1px; height: 1px; min-width: 0; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.ticket-attachment-table .visually-hidden-file-input:focus-visible + label { outline: 2px solid #2563eb; outline-offset: 2px; }
.ticket-message-attachments { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.ticket-message-attachments label.icon-button { margin: 0; }
.ticket-message-file-list { display: grid; gap: 6px; flex: 1 1 100%; list-style: none; margin: 0; padding: 0; }
.ticket-message-file-list li { display: flex; align-items: center; gap: 6px; min-width: 0; }
.ticket-message-file-list li span { min-width: 0; flex: 1; overflow-wrap: anywhere; }
.ticket-new-attachments { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.ticket-new-attachments span { min-width: 0; overflow-wrap: anywhere; }
.ticket-new-attachments .alert { margin: 0; }
.ticket-new-attachments .alert[hidden] { display: none; }
.ticket-new-attachment-picker { position: relative; overflow: hidden; cursor: pointer; }
.ticket-new-attachment-picker-input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; opacity: 0; cursor: pointer; }
.ticket-attachment-table[hidden] { display: none; }
.expense-attachment-upload { display: inline-flex; margin: 0; }
.attachment-upload-label { position: relative; display: inline-flex; align-items: center; gap: 8px; margin: 0; padding: 8px 12px; border: 1px solid #cbd5e1; border-radius: 4px; background: #fff; color: #1e3a5f; cursor: pointer; font-weight: 600; }
.attachment-upload-label:hover { background: #f1f5f9; }
.attachment-upload-label:focus-within { outline: 2px solid #2563eb; outline-offset: 2px; }
.report-table .expense-attachment-upload .attachment-file-input { position: absolute; width: 1px; height: 1px; min-width: 0; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.expense-attachments-dialog { width: min(1000px, calc(100% - 32px)); max-height: calc(100vh - 32px); overflow: auto; border: 1px solid #cbd5e1; border-radius: 6px; padding: 20px; color: #1f2937; }
.expense-attachments-dialog::backdrop { background: rgba(15,23,42,.55); }
.expense-attachments-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.expense-attachments-header h2 { margin: 0; font-size: 1.25rem; overflow-wrap: anywhere; }
.expense-attachments-layout { display: grid; grid-template-columns: minmax(240px, 1fr) minmax(0, 2fr); gap: 16px; min-height: 420px; }
.expense-attachment-list { min-width: 0; }
.expense-attachment-list h3 { margin-top: 0; }
.expense-attachment-item { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; align-items: center; gap: 6px; margin-bottom: 8px; }
.expense-attachment-name { min-width: 0; overflow-wrap: anywhere; text-align: left; color: #1f2937; }
.expense-attachment-item button[aria-pressed="true"] { background: #e0f2fe; }
.expense-attachment-preview { min-width: 0; min-height: 420px; background: #f8fafc; border: 1px solid #cbd5e1; padding: 12px; }
.expense-attachment-preview iframe { display: block; width: 100%; height: 65vh; border: 0; background: #fff; }
.expense-attachment-preview iframe[hidden] { display: none; }
.expense-attachment-upload { margin-top: 12px; }
.ticket-attachment-preview-dialog { width: min(1000px, calc(100% - 32px)); }
.ticket-attachment-preview-dialog .expense-attachment-preview { min-height: 55vh; }
.ticket-attachment-preview-dialog .expense-attachment-preview iframe { height: 65vh; }
.planning-controls { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.planning-view-tabs, .planning-period-controls { display: flex; align-items: center; gap: 6px; }
.planning-view-tabs button[aria-pressed="true"] { background: #15803d; }
.planning-period-controls input { width: auto; min-width: 150px; margin: 0; }
.appointment-slot-picker { display: grid; grid-template-columns: minmax(180px, 1.5fr) repeat(2, minmax(90px, .6fr)); gap: 10px; align-items: end; }
.appointment-slot-picker input[type="date"], .appointment-slot-picker select { margin-top: 4px; }
.planning-calendar-scroll { overflow-x: auto; }
.planning-calendar { display: grid; grid-template-columns: repeat(7, minmax(145px, 1fr)); gap: 1px; min-width: 1020px; background: #cbd5e1; border: 1px solid #cbd5e1; margin-bottom: 24px; }
.planning-calendar[hidden] { display: none; }
.planning-day { min-height: 150px; padding: 8px; background: #fff; }
.planning-day h3 { margin: 0 0 8px; font-size: .95rem; }
.planning-calendar-month .planning-day { min-height: 130px; }
.planning-day-outside { background: #f1f5f9; color: #64748b; }
.planning-event { display: grid; gap: 3px; margin: 0 0 6px; padding: 6px; border-left: 3px solid #64748b; background: #f8fafc; font-size: .85rem; overflow-wrap: anywhere; }
.planning-event a { color: inherit; font-weight: 600; }
.planning-event.c-giallo { border-color: #ca8a04; background: #fef9c3; }
.planning-event.c-verde { border-color: #16a34a; background: #dcfce7; }
.planning-event.c-rosso { border-color: #dc2626; background: #fee2e2; }
.planning-event.c-blu { border-color: #2563eb; background: #dbeafe; }
.planning-event.c-rosa { border-color: #db2777; background: #fce7f3; }
.planning-event.c-arancione { border-color: #ea580c; background: #ffedd5; }
.planning-event.c-marrone { border-color: #92400e; background: #fef3c7; }
.delete-confirmation { width: min(440px, calc(100% - 32px)); border: 1px solid #cbd5e1; border-radius: 6px; padding: 20px; color: #1f2937; box-shadow: 0 12px 36px rgba(15,23,42,.24); }
.delete-confirmation::backdrop { background: rgba(15,23,42,.48); }
.delete-confirmation h2 { margin-top: 0; }
.delete-confirmation .actions { justify-content: flex-end; gap: 8px; }
.delete-confirmation button.delete-cancel { background: #fff; color: #1f2937; border: 1px solid #94a3b8; }
.ticket-detail-flow { display: flex; flex-direction: column; }
#ticketAppointments { order: 1; }
#ticketDeliveries { order: 2; }
#interventionReport { order: 3; }
#ticketHistory { order: 4; }
#ticketInteractions { order: 5; }
.record-table tbody tr.record-row { cursor: pointer; }
.record-table tbody tr.record-row:hover { background: #f8fafc; }
.record-detail td { background: #f8fafc; }
.record-detail form { margin: 0; }
.c-bianco { background: #fff; } .c-giallo { background: #fde047; } .c-rosso { background: #f87171; } .c-rosa { background: #f9a8d4; }
.c-arancione { background: #fb923c; } .c-marrone { background: #a16207; }
.c-blu { background: #60a5fa; } .c-verde { background: #4ade80; }
.badge { padding: 2px 10px; border-radius: 10px; border: 1px solid #9ca3af; font-size: .9em; }
.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; }
.alert.err { background: #fee2e2; color: #991b1b; } .alert.ok { background: #dcfce7; color: #166534; }
.pre { white-space: pre-wrap; }
.timeline { list-style: none; padding: 0; }
.timeline li { background: #fff; border-left: 4px solid #1e3a5f; padding: 8px 12px; margin-bottom: 8px; }
@media (max-width: 900px) {
  .admin-panels { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
  .expense-attachments-layout { grid-template-columns: 1fr; }
  .expense-attachment-preview { min-height: 50vh; }
}
