/* ============================================================
   InnovaHR - Service Report
   Stile: light / white con accenti brand (navy, verde, arancio, giallo)
   e dettagli 3D (ombre profonde, hover con leggera rotazione)
   ============================================================ */

:root {
    --bg-page: #f4f6fb;
    --bg-panel: #ffffff;
    --surface: #ffffff;
    --surface-border: #e7eaf2;
    --surface-alt: #f7f9fc;

    --navy: #1c3868;
    --navy-dark: #142a51;
    --green: #2ea968;
    --orange: #f08e51;
    --yellow: #fadd5b;

    --text-0: #172436;
    --text-1: #5b6478;
    --text-2: #8a93a6;

    --danger: #e5484d;
    --success: #2ea968;

    --radius: 16px;
    --shadow-sm: 0 2px 8px rgba(23,36,54,0.06), 0 1px 2px rgba(23,36,54,0.05);
    --shadow-md: 0 10px 28px -8px rgba(23,36,54,0.14), 0 2px 8px rgba(23,36,54,0.06);
    --shadow-lg: 0 26px 60px -16px rgba(23,36,54,0.22), 0 8px 20px rgba(23,36,54,0.08);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
    background: var(--bg-page);
    color: var(--text-0);
    -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #d7dceb; border-radius: 10px; }
::-webkit-scrollbar-track { background: transparent; }

a { color: inherit; }

/* ---------- Login ---------- */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: 1400px;
    background:
        radial-gradient(900px 600px at 12% -10%, rgba(46,169,104,0.08), transparent 60%),
        radial-gradient(800px 600px at 100% 10%, rgba(240,142,81,0.10), transparent 55%),
        var(--bg-page);
}

.login-card {
    width: 400px;
    padding: 40px 36px;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    transform: rotateX(3deg) rotateY(-3deg);
    transition: transform .4s ease;
}
.login-card:hover { transform: rotateX(0deg) rotateY(0deg); }

.login-logo-img { display: block; width: 100%; max-width: 260px; margin: 0 auto 22px auto; }

.login-title { text-align: center; font-size: 20px; font-weight: 700; margin-bottom: 4px; color: var(--navy); }
.login-sub { text-align: center; font-size: 13px; color: var(--text-1); margin-bottom: 28px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; color: var(--text-1); margin-bottom: 6px; font-weight: 600; }
.field input, .field select, .field textarea {
    width: 100%;
    padding: 11px 14px;
    background: var(--surface-alt);
    border: 1px solid var(--surface-border);
    border-radius: 10px;
    color: var(--text-0);
    font-size: 14px;
    outline: none;
    transition: border-color .2s, box-shadow .2s, background .2s;
}
.field input:focus, .field select:focus, .field textarea:focus {
    border-color: var(--navy);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(28,56,104,0.12);
}

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 11px 20px;
    border-radius: 10px;
    border: none;
    font-size: 14px; font-weight: 600;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease, filter .15s ease;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary {
    background: linear-gradient(135deg, var(--navy), var(--navy-dark));
    color: #fff;
    box-shadow: 0 10px 24px -8px rgba(28,56,104,0.45);
    width: 100%;
}
.btn-primary:hover { filter: brightness(1.08); box-shadow: 0 14px 30px -8px rgba(28,56,104,0.55); }
.btn-secondary { background: var(--surface-alt); color: var(--text-0); border: 1px solid var(--surface-border); }
.btn-secondary:hover { background: #eef1f7; }
.btn-danger { background: rgba(229,72,77,0.1); color: var(--danger); border: 1px solid rgba(229,72,77,0.3); }
.btn-sm { padding: 6px 12px; font-size: 12px; }

.login-error {
    background: rgba(229,72,77,0.08);
    border: 1px solid rgba(229,72,77,0.3);
    color: #b3282d;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 13px;
    margin-bottom: 16px;
    display: none;
}

/* ---------- App layout ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: 250px;
    flex-shrink: 0;
    background: var(--bg-panel);
    border-right: 1px solid var(--surface-border);
    display: flex; flex-direction: column;
    padding: 20px 14px;
}

.brand { padding: 6px 8px 22px 8px; border-bottom: 1px solid var(--surface-border); margin-bottom: 14px; }
.brand-logo-img { width: 100%; max-width: 172px; display: block; }

.nav { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 14px;
    border-radius: 12px;
    color: var(--text-1);
    cursor: pointer;
    font-size: 14px; font-weight: 600;
    transition: background .15s, color .15s, transform .15s;
    user-select: none;
}
.nav-item .ic { width: 20px; text-align: center; }
.nav-item:hover { background: var(--surface-alt); color: var(--navy); transform: translateX(2px); }
.nav-item.active {
    background: linear-gradient(135deg, rgba(28,56,104,0.09), rgba(46,169,104,0.09));
    color: var(--navy);
    box-shadow: inset 0 0 0 1px rgba(28,56,104,0.14);
}

.sidebar-footer { margin-top: auto; padding: 12px 8px 0 8px; border-top: 1px solid var(--surface-border); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 10px 4px; font-size: 13px; color: var(--text-1); }
.user-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: linear-gradient(135deg, var(--green), var(--navy));
    display: flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; font-size: 13px;
}

.main { flex: 1; padding: 28px 34px; overflow-x: hidden; }

.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }

/* Pulsanti azione principali (Nuova nota / Nuovo cliente-contratto):
   larghezza fissa e sempre allineati a destra del topbar. */
.btn-fixed-width {
    width: 5cm;
    max-width: 100%;
    margin-left: auto;
    flex-shrink: 0;
}
.page-title { font-size: 22px; font-weight: 700; color: var(--navy); }
.page-sub { font-size: 13px; color: var(--text-1); margin-top: 2px; }

.section { display: none; }
.section.active { display: block; animation: fadein .25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Cards / KPI ---------- */
.grid { display: grid; gap: 18px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2,1fr);} }

.card {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    transform-style: preserve-3d;
    transition: transform .25s ease, box-shadow .25s ease;
}
.card:hover { transform: translateY(-4px) rotateX(2deg); box-shadow: var(--shadow-md); }

.kpi-label { font-size: 12px; color: var(--text-1); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }
.kpi-value { font-size: 26px; font-weight: 800; color: var(--navy); }
.kpi-value.accent { background: linear-gradient(135deg, var(--navy), var(--green)); -webkit-background-clip: text; background-clip: text; color: transparent; }

.card-title { font-size: 15px; font-weight: 700; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; color: var(--navy); }

/* ---------- Toolbar / filters ---------- */
.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar .field { margin-bottom: 0; min-width: 160px; }
.spacer { flex: 1; }

/* ---------- Table ---------- */
.table-wrap {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
    text-align: left; padding: 12px 16px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
    color: var(--text-1); background: var(--surface-alt); border-bottom: 1px solid var(--surface-border);
    position: sticky; top: 0; font-weight: 700;
}
tbody td { padding: 12px 16px; border-bottom: 1px solid var(--surface-alt); vertical-align: middle; }
tbody tr { transition: background .15s; }
tbody tr:hover { background: var(--surface-alt); }
tbody tr:last-child td { border-bottom: none; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge-success { background: rgba(46,169,104,0.12); color: var(--success); }
.badge-muted { background: var(--surface-alt); color: var(--text-1); }
.badge-accent { background: rgba(240,142,81,0.14); color: #b8611f; }

.row-actions { display: flex; gap: 8px; }
.icon-btn {
    width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
    background: var(--surface-alt); border: 1px solid var(--surface-border); cursor: pointer; color: var(--text-0);
    transition: background .15s, transform .15s;
}
.icon-btn:hover { background: #eef1f7; transform: translateY(-1px); }
.icon-btn.danger:hover { background: rgba(229,72,77,0.12); color: var(--danger); }

.fab {
    position: fixed; right: 40px; bottom: 40px;
    width: 58px; height: 58px; border-radius: 50%;
    background: linear-gradient(135deg, var(--orange), #e5793a);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 26px; border: none; cursor: pointer;
    box-shadow: 0 16px 34px -10px rgba(240,142,81,0.65);
    transition: transform .2s ease, box-shadow .2s ease;
}
.fab:hover { transform: translateY(-3px) scale(1.05) rotate(90deg); }

/* ---------- Modal ---------- */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(23,36,54,0.35);
    backdrop-filter: blur(3px);
    display: none; align-items: center; justify-content: center; z-index: 100;
    perspective: 1600px;
}
.modal-backdrop.open { display: flex; }
.modal {
    width: 620px; max-width: 92vw; max-height: 88vh; overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: 20px;
    padding: 26px 28px;
    box-shadow: var(--shadow-lg);
    transform: translateY(30px) rotateX(8deg) scale(.96);
    opacity: 0;
    animation: modal-in .28s cubic-bezier(.2,.9,.3,1.2) forwards;
}
@keyframes modal-in { to { transform: translateY(0) rotateX(0) scale(1); opacity: 1; } }
.modal.modal-wide { width: 760px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-title { font-size: 17px; font-weight: 700; color: var(--navy); }
.modal-close { cursor: pointer; color: var(--text-1); font-size: 20px; background: none; border: none; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }

.checkbox-row { display: flex; align-items: center; gap: 10px; padding-top: 4px; }
.checkbox-row input { width: 18px; height: 18px; accent-color: var(--navy); }

.totale-preview {
    margin-top: 6px;
    padding: 16px 18px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(28,56,104,0.06), rgba(46,169,104,0.08));
    border: 1px solid rgba(28,56,104,0.16);
    display: flex; align-items: center; justify-content: space-between;
}
.totale-preview .lbl { font-size: 12px; color: var(--text-1); }
.totale-preview .val { font-size: 24px; font-weight: 800; color: var(--navy); }
.totale-breakdown { font-size: 11.5px; color: var(--text-1); margin-top: 4px; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-1); }
.empty-state .ic { font-size: 40px; margin-bottom: 10px; opacity: .6; }

.toast-wrap { position: fixed; top: 22px; right: 22px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
    padding: 12px 18px; border-radius: 12px; font-size: 13.5px; font-weight: 600;
    background: #fff; border: 1px solid var(--surface-border);
    box-shadow: var(--shadow-lg);
    animation: toast-in .25s ease;
    color: var(--text-0);
}
.toast.success { border-color: rgba(46,169,104,0.4); color: #1f7a49; }
.toast.error { border-color: rgba(229,72,77,0.4); color: #b3282d; }
@keyframes toast-in { from { opacity: 0; transform: translateX(20px);} to { opacity: 1; transform: translateX(0);} }

canvas { max-width: 100%; }

@media (max-width: 900px) {
    .sidebar { width: 76px; }
    .brand-logo-img, .nav-item span.label { display: none; }
    .main { padding: 20px; }
    .form-grid { grid-template-columns: 1fr; }
}
