/* =====================================================================
   GaduMed WorkCare - Foglio di stile
   Palette ispirata al progetto GaduMed: verde clinico, superfici chiare,
   dashboard operativa con card KPI.
   ===================================================================== */
:root {
    --green-900: #0b3d36;
    --green-800: #0f5249;
    --green-700: #126b5e;
    --green-600: #15897a;
    --green-500: #1ba596;
    --green-100: #d8f0eb;
    --green-50:  #eef9f6;
    --teal-accent: #2bb3a3;

    --ink:       #16241f;
    --muted:     #6b7d77;
    --line:      #e3eae7;
    --bg:        #f4f7f6;
    --surface:   #ffffff;

    --amber:     #d98e04;
    --red:       #c0392b;
    --blue:      #2563eb;

    --radius:    14px;
    --radius-sm: 9px;
    --shadow:    0 1px 3px rgba(16,40,34,.06), 0 8px 24px rgba(16,40,34,.06);
    --shadow-sm: 0 1px 2px rgba(16,40,34,.08);
    --sidebar-w: 248px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--ink);
    font-size: 14.5px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--green-700); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .4em; font-weight: 700; letter-spacing: -.01em; }

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

.sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--green-900), var(--green-800));
    color: #cfe6e0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    padding: 18px 14px;
    overflow-y: auto;
}
.brand {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 8px 18px;
    color: #fff;
}
.brand .logo {
    width: 38px; height: 38px; border-radius: 10px;
    background: var(--teal-accent);
    display: grid; place-items: center;
    font-weight: 800; color: #06302a; font-size: 16px;
    box-shadow: inset 0 0 0 2px rgba(255,255,255,.2);
}
.brand b { font-size: 15px; font-weight: 800; letter-spacing: .02em; }
.brand span { display: block; font-size: 11px; color: #8fc4ba; font-weight: 500; }

.nav { list-style: none; padding: 0; margin: 6px 0; }
.nav .section { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: #6fa79c; margin: 16px 10px 6px; }
.nav a {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 11px; border-radius: 10px;
    color: #cfe6e0; font-weight: 500; font-size: 13.5px;
    transition: background .15s, color .15s;
}
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.nav a.active { background: var(--green-600); color: #fff; box-shadow: var(--shadow-sm); }
.nav a .ico { width: 18px; text-align: center; font-size: 15px; opacity: .95; }

.sidebar-foot { margin-top: auto; padding: 12px 10px 4px; font-size: 11.5px; color: #6fa79c; }

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }

.topbar {
    height: 62px; background: var(--surface);
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 26px; position: sticky; top: 0; z-index: 20;
}
.topbar .page-title { font-size: 17px; font-weight: 700; }
.topbar .right { display: flex; align-items: center; gap: 16px; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--green-100); color: var(--green-800);
    display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.user-chip small { color: var(--muted); display: block; font-size: 11.5px; }

.content { padding: 26px; flex: 1; }
.content-narrow { max-width: 900px; }

/* ---------- KPI cards (stile dashboard PDF) ---------- */
.kpi-grid {
    display: grid; gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
    margin-bottom: 22px;
}
.kpi {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 18px 18px 16px;
    box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.kpi::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
    background: var(--green-500);
}
.kpi.amber::before { background: var(--amber); }
.kpi.red::before   { background: var(--red); }
.kpi.blue::before  { background: var(--blue); }
.kpi .ico { font-size: 20px; margin-bottom: 8px; display: block; }
.kpi .val { font-size: 30px; font-weight: 800; letter-spacing: -.02em; line-height: 1; }
.kpi .lab { color: var(--muted); font-size: 12.5px; margin-top: 6px; }

/* ---------- Cards generiche ---------- */
.card {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
    margin-bottom: 20px;
}
.card-head {
    padding: 15px 20px; border-bottom: 1px solid var(--line);
    display: flex; align-items: center; justify-content: space-between;
}
.card-head h3 { margin: 0; font-size: 15px; }
.card-body { padding: 18px 20px; }
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 980px) { .grid-2 { grid-template-columns: 1fr; } .sidebar { display: none; } .main { margin-left: 0; } }

/* ---------- Liste scadenze ---------- */
.task-list { list-style: none; margin: 0; padding: 0; }
.task-list li {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 4px; border-bottom: 1px solid var(--line);
}
.task-list li:last-child { border-bottom: 0; }
.task-list .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green-500); flex: none; }
.task-list .dot.amber { background: var(--amber); }
.task-list .dot.red { background: var(--red); }
.task-list .t-main { flex: 1; }
.task-list .t-main b { font-weight: 600; }
.task-list .t-date { color: var(--muted); font-size: 12.5px; }

/* ---------- Azioni rapide ---------- */
.quick { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.quick a {
    display: flex; align-items: center; gap: 9px; justify-content: center;
    padding: 13px; border: 1px dashed var(--green-500); border-radius: var(--radius-sm);
    color: var(--green-800); font-weight: 600; background: var(--green-50);
}
.quick a:hover { background: var(--green-100); text-decoration: none; }

/* ---------- Tabelle ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.8px; }
table.data th {
    text-align: left; padding: 11px 14px; color: var(--muted);
    font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
    border-bottom: 1px solid var(--line); background: var(--green-50);
}
table.data td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:hover td { background: #fafdfc; }
table.data .actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ---------- Badge ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
    background: var(--green-100); color: var(--green-800);
}
.badge.gray { background: #eceff0; color: #5b6b66; }
.badge.amber { background: #fbedcf; color: #92600a; }
.badge.red { background: #f9dcd8; color: #9a2820; }
.badge.blue { background: #dbe7fe; color: #1d4ed8; }

/* ---------- Bottoni ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 9px 16px; border-radius: 9px; font-weight: 600; font-size: 13.5px;
    border: 1px solid transparent; cursor: pointer; background: var(--green-600); color: #fff;
    transition: background .15s, box-shadow .15s; text-decoration: none;
}
.btn:hover { background: var(--green-700); text-decoration: none; }
.btn.secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.secondary:hover { background: var(--green-50); }
.btn.danger { background: var(--red); }
.btn.danger:hover { background: #a3271c; }
.btn.sm { padding: 6px 11px; font-size: 12.5px; }
.btn.ghost { background: transparent; color: var(--green-700); }
.btn.ghost:hover { background: var(--green-50); }

/* ---------- Form ---------- */
.form-grid { display: grid; gap: 16px; grid-template-columns: repeat(2, 1fr); }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
.field label { display: block; font-weight: 600; font-size: 12.8px; margin-bottom: 6px; color: #2c3d37; }
.field input, .field select, .field textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px;
    font-family: inherit; font-size: 14px; background: #fff; color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none; border-color: var(--green-500); box-shadow: 0 0 0 3px var(--green-100);
}
.field .hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.form-actions { display: flex; gap: 10px; margin-top: 22px; }

/* ---------- Checkbox grid permessi ---------- */
.perm-cats { display: grid; gap: 16px; }
.perm-cat { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; }
.perm-cat h4 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--green-700); }
.perm-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.perm-item { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }

/* ---------- Flash / alert ---------- */
.alert {
    padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; font-size: 13.8px;
    border: 1px solid; display: flex; gap: 10px; align-items: flex-start;
}
.alert.success { background: var(--green-50); border-color: var(--green-100); color: var(--green-800); }
.alert.error { background: #fdeeec; border-color: #f6d2cc; color: #9a2820; }
.alert ul { margin: 4px 0 0; padding-left: 18px; }

/* ---------- Login ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
@media (max-width: 860px) { .auth-wrap { grid-template-columns: 1fr; } .auth-side { display: none; } }
.auth-side {
    background: linear-gradient(160deg, var(--green-800), var(--green-900));
    color: #d7ece6; padding: 56px 52px; display: flex; flex-direction: column; justify-content: center;
}
.auth-side .badges { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 22px; }
.auth-side .badges span { border: 1px solid rgba(255,255,255,.25); padding: 5px 12px; border-radius: 999px; font-size: 12px; }
.auth-side h1 { color: #fff; font-size: 27px; }
.auth-side p { color: #a7cfc6; font-size: 14.5px; max-width: 380px; }
.auth-main { display: grid; place-items: center; padding: 40px; }
.auth-card { width: 100%; max-width: 360px; }
.auth-card .logo-row { display: flex; align-items: center; gap: 10px; margin-bottom: 26px; }
.auth-card .logo-row .logo {
    width: 40px; height: 40px; border-radius: 10px; background: var(--green-600);
    display: grid; place-items: center; color: #fff; font-weight: 800;
}

.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.page-actions { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; gap: 12px; }
.search-box { display: flex; gap: 8px; }
.search-box input { padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; min-width: 220px; }
