/* ============================================================
   LexGo — global.css
   Design system condiviso tra lawyer.php, client.php, admin.php
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,300;0,400;0,700;0,900;1,400&family=Roboto:wght@300;400;500;700&display=swap');

/* ---- VARIABILI ---- */
:root {
    --ink:       #1C355E;
    --bg:        #eef3fa;
    --surface:   #ffffff;
    --blue:      #1C355E;
    --blue-dark: #142845;
    --blue-lt:   #d0e8f8;
    --accent:    #00A7E1;
    --muted:     #5d718e;
    --border:    #c8d6e8;
    --danger:    #c0392b;
    --success:   #1a7a4a;
    --pending:   #7a5c00;
    --radius:    12px;
    --shadow-sm: 0 2px 12px rgba(28,53,94,.10);
    --shadow-md: 0 6px 28px rgba(28,53,94,.14);
    --serif: 'Lato', sans-serif;
    --sans:  'Roboto', sans-serif;
}

/* ---- RESET ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ---- BODY ---- */
body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--ink);
    font-size: 14px;
    min-height: 100vh;
    background-image:
        radial-gradient(ellipse 60% 50% at 20% 10%, rgba(0,167,225,.07) 0%, transparent 60%),
        radial-gradient(ellipse 50% 40% at 80% 90%, rgba(28,53,94,.06) 0%, transparent 60%);
}

/* ---- LOGIN ---- */
.login-wrap { min-height:100vh; display:flex; align-items:center; justify-content:center; padding:2rem; }
.login-box  { width:100%; max-width:420px; }
.login-logo { display:flex; flex-direction:column; align-items:center; margin-bottom:2rem; }
.login-logo .badge { width:56px; height:56px; background:var(--blue); border-radius:16px; display:flex; align-items:center; justify-content:center; margin-bottom:12px; box-shadow:0 8px 24px rgba(28,53,94,.3); }
.login-logo h1 { font-family:var(--serif); font-size:1.8rem; color:var(--ink); }
.login-logo p  { font-size:12px; color:var(--muted); letter-spacing:.12em; text-transform:uppercase; margin-top:4px; }
.card { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:2.2rem 2rem 2rem; width:100%; box-shadow:var(--shadow-md); position:relative; overflow:hidden; }
.card::before { content:''; position:absolute; top:0; left:0; right:0; height:3px; background:linear-gradient(90deg,var(--blue) 0%,var(--accent) 100%); }
.card h2 { font-family:var(--serif); font-size:1.2rem; color:var(--ink); margin-bottom:.4rem; }
.card p.sub { font-size:13px; color:var(--muted); margin-bottom:1.5rem; line-height:1.6; }
.field { margin-bottom:1rem; }
.field label { display:block; font-size:11px; font-weight:600; color:var(--muted); text-transform:uppercase; letter-spacing:.08em; margin-bottom:.4rem; }
.field input { width:100%; background:#f7fafd; border:1.5px solid var(--border); border-radius:10px; padding:.75rem 1rem; font-family:var(--sans); font-size:14px; color:var(--ink); outline:none; transition:border-color .2s, box-shadow .2s; }
.field input:focus { background:#fff; border-color:var(--accent); box-shadow:0 0 0 3.5px rgba(0,167,225,.14); }
.otp-input { text-align:center; font-size:2rem; font-weight:700; letter-spacing:.4em; font-family:var(--serif); }
.error-msg { background:rgba(192,57,43,.07); border:1px solid rgba(192,57,43,.25); color:var(--danger); padding:.75rem 1rem; border-radius:10px; margin-bottom:1rem; font-size:13px; }
.info-msg  { background:rgba(0,167,225,.07); border:1px solid rgba(0,167,225,.25); color:#005f8a; padding:.75rem 1rem; border-radius:10px; margin-bottom:1rem; font-size:13px; }

/* ---- BUTTONS ---- */
.btn { display:inline-flex; align-items:center; gap:.5rem; padding:.65rem 1.3rem; border-radius:10px; border:none; cursor:pointer; font-family:var(--sans); font-size:13.5px; font-weight:500; transition:all .15s; }
.btn-primary { background:linear-gradient(135deg,var(--blue) 0%,#254a7a 100%); color:#fff; box-shadow:0 4px 14px rgba(28,53,94,.28); }
.btn-primary:hover { filter:brightness(1.08); box-shadow:0 6px 20px rgba(28,53,94,.36); transform:translateY(-1px); }
.btn-primary:disabled { opacity:.5; cursor:not-allowed; transform:none; }
.btn-ghost  { background:#fff; color:var(--muted); border:1.5px solid var(--border); }
.btn-ghost:hover  { border-color:var(--accent); color:var(--accent); }
.btn-accept { background:rgba(26,122,74,.1); color:var(--success); border:1.5px solid rgba(26,122,74,.3); }
.btn-accept:hover { background:rgba(26,122,74,.18); }
.btn-reject { background:rgba(192,57,43,.08); color:var(--danger); border:1.5px solid rgba(192,57,43,.25); }
.btn-reject:hover { background:rgba(192,57,43,.15); }
.btn-danger { background:rgba(192,57,43,.08); color:var(--danger); border:1.5px solid rgba(192,57,43,.25); }
.btn-danger:hover { background:rgba(192,57,43,.15); }
.btn-sm   { padding:.35rem .85rem; font-size:12.5px; }
.btn-full { width:100%; justify-content:center; padding:.85rem; font-size:15px; }

/* ---- LAYOUT ---- */
.app { display:flex; height:100vh; overflow:hidden; }

/* ---- SIDEBAR ---- */
.sidebar { width:220px; background:var(--blue-dark); border-right:1px solid rgba(255,255,255,.1); display:flex; flex-direction:column; flex-shrink:0; transition:width .25s cubic-bezier(.4,0,.2,1); position:relative; }
.sidebar.collapsed { width:60px; }

.sidebar-toggle { display:flex; align-items:center; justify-content:center; gap:.4rem; width:calc(100% - 1.2rem); margin:0 .6rem .6rem; padding:.45rem; border-radius:8px; background:rgba(255,255,255,.07); border:1px solid rgba(255,255,255,.12); cursor:pointer; color:rgba(255,255,255,.7); font-size:11px; font-weight:500; font-family:var(--sans); transition:background .15s, color .15s; white-space:nowrap; overflow:hidden; flex-shrink:0; }
.sidebar-toggle:hover { background:rgba(255,255,255,.14); color:#fff; }
.sidebar-toggle svg { flex-shrink:0; transition:transform .25s ease; }
.sidebar.collapsed .sidebar-toggle svg { transform:rotate(180deg); }
.sidebar-toggle-label { transition:opacity .2s, width .25s; overflow:hidden; }
.sidebar.collapsed .sidebar-toggle-label { opacity:0; width:0; }

.sidebar-logo { padding:.8rem .75rem 1rem; border-bottom:1px solid rgba(255,255,255,.08); margin-bottom:.75rem; display:flex; flex-direction:column; align-items:flex-start; overflow:hidden; flex-shrink:0; }
.sidebar-logo-full { display:flex; flex-direction:column; align-items:flex-start; width:100%; transition:opacity .2s; }
.sidebar-logo-full img { width:110px; height:auto; }
.sidebar-logo-sub { font-size:10px; color:rgba(255,255,255,.4); font-family:var(--sans); letter-spacing:.12em; text-transform:uppercase; margin-top:.35rem; white-space:nowrap; }
.sidebar-logo-compact { display:none; align-items:center; justify-content:center; width:100%; padding:.2rem 0; }
.sidebar.collapsed .sidebar-logo-full { opacity:0; height:0; overflow:hidden; margin:0; padding:0; }
.sidebar.collapsed .sidebar-logo-compact { display:flex; }

.sidebar-nav { display:flex; flex-direction:column; flex:1; padding:0 .5rem; overflow-y:auto; min-height:0; scrollbar-width:thin; scrollbar-color:rgba(255,255,255,.18) transparent; }
.sidebar-nav::-webkit-scrollbar { width:5px; }
.sidebar-nav::-webkit-scrollbar-track { background:transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background:rgba(255,255,255,.18); border-radius:4px; }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background:rgba(255,255,255,.3); }
.sidebar-bottom { padding:.75rem .5rem .75rem; border-top:1px solid rgba(255,255,255,.08); flex-shrink:0; }

/* ---- NAV ---- */
.nav-item { display:flex; align-items:center; gap:.75rem; padding:.6rem .65rem; border-radius:8px; color:rgba(255,255,255,.55); cursor:pointer; transition:all .15s; margin-bottom:2px; border:none; background:none; font-family:var(--sans); font-size:13.5px; width:100%; text-align:left; position:relative; white-space:nowrap; overflow:hidden; }
.sidebar.collapsed .nav-item { overflow:visible; }
.nav-item:hover { background:rgba(255,255,255,.08); color:#fff; }
.nav-item.active { background:rgba(0,167,225,.2); color:#fff; }
.nav-icon { display:flex; align-items:center; justify-content:center; width:20px; height:20px; flex-shrink:0; }
.nav-label { transition:opacity .2s, width .25s; overflow:hidden; }
.sidebar.collapsed .nav-label { opacity:0; width:0; }
.sidebar.collapsed .nav-item { justify-content:center; padding:.6rem 0; }
.nav-badge { position:absolute; right:.75rem; background:var(--accent); color:#fff; border-radius:20px; font-size:10px; font-weight:700; padding:.1rem .45rem; min-width:18px; text-align:center; }
.sidebar.collapsed .nav-badge { right:2px; top:3px; font-size:8px; padding:.05rem .3rem; min-width:14px; }

/* ---- MAIN AREA ---- */
/* tooltip gestito via JS */
.main { flex:1; overflow-y:auto; overflow-x:hidden; background:var(--bg); min-width:0; }
.topbar { background:var(--surface); border-bottom:1px solid var(--border); padding:1rem 2rem; display:flex; align-items:center; justify-content:space-between; box-shadow:var(--shadow-sm); position:sticky; top:0; z-index:10; }
.topbar h2 { font-family:var(--serif); font-size:1.2rem; color:var(--ink); }
.topbar-toggle { width:34px; height:34px; border-radius:8px; border:1.5px solid var(--border); background:var(--surface); cursor:pointer; display:flex; align-items:center; justify-content:center; color:var(--muted); transition:all .15s; flex-shrink:0; }
.topbar-toggle:hover { border-color:var(--accent); color:var(--accent); background:var(--blue-lt); }
.content { padding:2rem; }

/* ---- STATS (legacy) ---- */
.stats-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:1rem; margin-bottom:2rem; }
.stat-card { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:1.2rem 1.4rem; box-shadow:var(--shadow-sm); }
.stat-card .val { font-family:var(--serif); font-size:2rem; color:var(--blue); line-height:1; }
.stat-card .lbl { color:var(--muted); font-size:12px; margin-top:.35rem; }

/* ---- KPI CARDS ---- */
.kpi-top { display:flex; align-items:center; justify-content:space-between; margin-bottom:.6rem; }
.kpi-card { background:var(--surface); border:1px solid var(--border); border-radius:14px; padding:1rem 1.1rem; box-shadow:var(--shadow-sm); display:flex; flex-direction:column; gap:.5rem; position:relative; overflow:hidden; transition:box-shadow .2s; }
.kpi-card:hover { box-shadow:var(--shadow-md); }
.kpi-card::before { content:''; position:absolute; top:0; left:0; right:0; height:3px; border-radius:14px 14px 0 0; }
.kpi-card.blue::before  { background:var(--blue); }
.kpi-card.accent::before { background:var(--accent); }
.kpi-card.green::before { background:#1a7a4a; }
.kpi-card.amber::before { background:#c9a84c; }
.kpi-card.red::before   { background:#c0392b; }
.kpi-icon { width:36px; height:36px; border-radius:10px; display:flex; align-items:center; justify-content:center; flex-shrink:0; }
.kpi-icon.blue   { background:rgba(28,53,94,.1);  color:var(--blue); }
.kpi-icon.accent { background:rgba(0,167,225,.1); color:var(--accent); }
.kpi-icon.green  { background:rgba(26,122,74,.1); color:#1a7a4a; }
.kpi-icon.amber  { background:rgba(201,168,76,.12); color:#c9a84c; }
.kpi-icon.red    { background:rgba(192,57,43,.1); color:#c0392b; }
.kpi-val { font-family:var(--serif); font-size:2rem; color:var(--ink); line-height:1; font-weight:700; }
.kpi-lbl { font-size:12px; color:var(--muted); font-weight:500; }
.kpi-sub { font-size:11px; color:var(--muted); }
.kpi-badge { display:inline-flex; align-items:center; gap:.25rem; background:#fff3cd; color:#856404; border-radius:20px; padding:.15rem .6rem; font-size:11px; font-weight:600; }
.kpi-badge.red { background:#fde8e8; color:#c0392b; }
.kpi-badge.green { background:#d4edda; color:#1a7a4a; }

/* ---- BADGES ---- */
.badge { display:inline-block; padding:.22rem .7rem; border-radius:20px; font-size:11.5px; font-weight:500; }
.badge-pending  { background:rgba(122,92,0,.1);   color:var(--pending); }
.badge-accepted { background:rgba(26,122,74,.1);  color:var(--success); }
.badge-rejected { background:rgba(192,57,43,.1);  color:var(--danger);  }
.badge-closed   { background:rgba(93,113,142,.1); color:var(--muted);   }
.badge-active   { background:rgba(26,122,74,.1);  color:var(--success); }
.badge-inactive { background:rgba(192,57,43,.1);  color:var(--danger);  }
.badge-none     { background:rgba(93,113,142,.08);color:var(--muted);   }

/* ---- TCARD ---- */
.tcard { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); overflow:hidden; box-shadow:var(--shadow-sm); margin-bottom:1.5rem; }
.tcard-head { padding:.9rem 1.4rem; border-bottom:1px solid var(--border); display:flex; align-items:center; justify-content:space-between; gap:1rem; flex-wrap:wrap; background:#f7fafd; }
.tcard-title { font-weight:600; font-size:14px; color:var(--ink); }
.tcard-body { padding:1.4rem; }

/* ---- PROFILE / FORM GRID ---- */
.profile-grid { display:grid; grid-template-columns:1fr 1fr; gap:1rem; }
.profile-grid .span2 { grid-column:span 2; }
.form-grid { display:grid; grid-template-columns:1fr 1fr; gap:1rem; }
.form-grid .span2 { grid-column:span 2; }
.fg label { display:block; font-size:11px; font-weight:600; color:var(--muted); text-transform:uppercase; letter-spacing:.07em; margin-bottom:.4rem; }
.fg input, .fg select, .fg textarea { width:100%; background:#f7fafd; border:1.5px solid var(--border); border-radius:8px; padding:.65rem .9rem; color:var(--ink); font-family:var(--sans); font-size:14px; outline:none; resize:vertical; transition:border-color .2s, box-shadow .2s; }
.fg input:focus, .fg select:focus, .fg textarea:focus { background:#fff; border-color:var(--accent); box-shadow:0 0 0 3px rgba(0,167,225,.12); }
.fg input[readonly], .fg textarea[readonly] { opacity:.65; cursor:not-allowed; }
.fg .hint { font-size:11px; color:var(--muted); margin-top:.35rem; line-height:1.6; }
.spec-tag { display:inline-block; background:var(--blue-lt); color:var(--blue); border:1px solid rgba(28,53,94,.15); border-radius:20px; padding:.25rem .75rem; font-size:12px; margin:.2rem; font-weight:500; }

/* ---- FASCICOLO ---- */
.fascicolo { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); box-shadow:var(--shadow-sm); overflow:hidden; transition:box-shadow .2s; margin-bottom:1rem; }
.fascicolo:hover { box-shadow:var(--shadow-md); }
.fascicolo.pending  { border-left:3px solid #c9a84c; }
.fascicolo.accepted { border-left:3px solid var(--accent); }
.fascicolo.rejected { border-left:3px solid var(--danger); opacity:.75; }
.fascicolo.closed   { border-left:3px solid var(--muted); opacity:.75; }
.fascicolo-head { padding:1rem 1.2rem; display:flex; align-items:center; gap:1rem; cursor:pointer; background:#f7fafd; user-select:none; }
.fascicolo-head:hover { background:#eef3fa; }
.fascicolo-avatar { width:44px; height:44px; border-radius:12px; background:var(--blue); display:flex; align-items:center; justify-content:center; flex-shrink:0; color:#fff; font-family:var(--serif); font-size:1.05rem; font-weight:700; }
.fascicolo-info { flex:1; min-width:0; }
.fascicolo-name { font-weight:600; font-size:15px; color:var(--ink); }
.fascicolo-meta { font-size:12px; color:var(--muted); margin-top:.15rem; display:flex; gap:.5rem; flex-wrap:wrap; align-items:center; }
.fascicolo-badges { display:flex; align-items:center; gap:.5rem; flex-shrink:0; flex-wrap:wrap; justify-content:flex-end; }
.fascicolo-chevron { color:var(--muted); transition:transform .25s; flex-shrink:0; margin-left:.5rem; }
.fascicolo-chevron.open { transform:rotate(90deg); }
.fascicolo-body { display:none; border-top:1px solid var(--border); }
.fascicolo-body.open { display:block; }

/* ---- FTABS ---- */
.ftabs { display:flex; gap:0; border-bottom:1px solid var(--border); background:#f7fafd; overflow-x:auto; }
.ftab { padding:.7rem 1.2rem; font-size:13px; font-weight:500; color:var(--muted); cursor:pointer; border:none; background:none; border-bottom:2px solid transparent; transition:all .15s; white-space:nowrap; display:flex; align-items:center; gap:.4rem; font-family:var(--sans); }
.ftab:hover { color:var(--ink); }
.ftab.active { color:var(--blue); border-bottom-color:var(--accent); background:var(--surface); font-weight:600; }
.ftab-badge { background:var(--accent); color:#fff; border-radius:20px; font-size:10px; font-weight:700; padding:.1rem .4rem; min-width:16px; text-align:center; }
.ftab-badge.red { background:#c0392b; }
.ftab-panel { display:none; padding:1.2rem; }
.ftab-panel.active { display:block; }
/* client.php portal tab panels */
.ptab-panel { display:none; }
.ptab-panel.active { display:block; }

/* ---- SEARCH BAR ---- */
.search-bar { position:relative; display:flex; align-items:center; }
.search-bar svg { position:absolute; left:.75rem; top:50%; transform:translateY(-50%); pointer-events:none; flex-shrink:0; }
.search-bar input { width:100%; background:var(--surface); border:1.5px solid var(--border); border-radius:10px; padding:.6rem .9rem .6rem 2.2rem; font-family:var(--sans); font-size:13.5px; color:var(--ink); outline:none; transition:border-color .2s; }
.search-bar input:focus { border-color:var(--accent); box-shadow:0 0 0 3px rgba(0,167,225,.1); }
.search-bar input::placeholder { color:#aabbd0; }

/* ---- CHAT (portal row-based: lawyer + client) ---- */
.chat-wrap { display:flex; flex-direction:column; overflow:hidden; }
.chat-msgs  { flex:1; overflow-y:auto; padding:1rem; display:flex; flex-direction:column; gap:.65rem; background:var(--bg); }
.chat-bubble-row { display:flex; flex-direction:column; }
.chat-bubble-row.lawyer { align-items:flex-end; }
.chat-bubble-row.client { align-items:flex-start; }
.chat-bubble { max-width:80%; padding:.7rem 1rem; border-radius:12px; font-size:13px; line-height:1.6; }
.chat-bubble.lawyer { background:var(--blue); color:#fff; border-bottom-right-radius:4px; }
.chat-bubble.client { background:var(--surface); border:1px solid var(--border); color:var(--ink); border-bottom-left-radius:4px; }
.chat-bubble.admin  { background:#f0e6ff; border:1px solid #d6b8f5; color:var(--ink); border-bottom-left-radius:4px; }
/* client.php uses direct align-self instead of wrapper */
.chat-bubble.client-self  { align-self:flex-end; border-bottom-right-radius:4px; border-bottom-left-radius:12px; background:var(--blue); color:#fff; border:none; }
.chat-meta { font-size:10.5px; color:var(--muted); margin-top:.2rem; opacity:.65; }
.chat-input-row { display:flex; gap:.5rem; padding:.9rem 1rem; border-top:1px solid var(--border); background:#f7fafd; }
.chat-textarea { flex:1; background:#fff; border:1.5px solid var(--border); border-radius:10px; padding:.6rem .9rem; font-family:var(--sans); font-size:13.5px; outline:none; resize:none; min-height:40px; max-height:90px; transition:border-color .2s; color:var(--ink); }
.chat-textarea:focus { border-color:var(--accent); }
.chat-send { background:var(--blue); color:#fff; border:none; border-radius:10px; padding:.6rem 1rem; cursor:pointer; transition:background .15s; display:flex; align-items:center; flex-shrink:0; }
.chat-send:hover { background:var(--accent); }
.unread-badge { display:inline-flex; align-items:center; justify-content:center; background:var(--accent); color:#fff; border-radius:20px; font-size:10px; font-weight:700; padding:.1rem .45rem; min-width:18px; margin-left:.4rem; }

/* CHAT (admin assistant style) */
.chat-msg { padding:.75rem 1rem; border-radius:12px; margin-bottom:.6rem; font-size:13px; line-height:1.6; max-width:85%; white-space:pre-wrap; word-break:break-word; }
.chat-msg.user      { background:var(--blue-lt); border:1px solid rgba(28,53,94,.15); margin-left:auto; }
.chat-msg.assistant { background:#f7fafd; border:1px solid var(--border); }
.chat-role { font-size:10.5px; color:var(--muted); margin-bottom:.3rem; font-weight:600; text-transform:uppercase; letter-spacing:.07em; }

/* Chat filter buttons */
.chat-filter-btn { padding:.32rem .75rem; border-radius:20px; border:1.5px solid var(--border); background:var(--surface); color:var(--muted); font-family:var(--sans); font-size:12px; font-weight:500; cursor:pointer; transition:all .15s; white-space:nowrap; }
.chat-filter-btn:hover { border-color:var(--accent); color:var(--accent); }
.chat-filter-btn.active { background:var(--blue); border-color:var(--blue); color:#fff; }

/* ---- MODAL ---- */
.modal-overlay { position:fixed; inset:0; background:rgba(28,53,94,.45); backdrop-filter:blur(3px); z-index:100; display:none; align-items:center; justify-content:center; padding:1rem; }
.modal-overlay.open { display:flex; }
.modal { background:var(--surface); border:1px solid var(--border); border-radius:16px; width:100%; max-width:560px; max-height:92vh; overflow-y:auto; box-shadow:var(--shadow-md); }
.modal-head { padding:1.3rem 1.6rem; border-bottom:1px solid var(--border); display:flex; align-items:center; justify-content:space-between; background:#f7fafd; border-radius:16px 16px 0 0; position:sticky; top:0; z-index:1; }
.modal-head h3 { font-family:var(--serif); font-size:1.1rem; color:var(--ink); }
.modal-body { padding:1.6rem; }
.modal-foot { padding:1rem 1.6rem; border-top:1px solid var(--border); display:flex; gap:.75rem; justify-content:flex-end; background:#f7fafd; border-radius:0 0 16px 16px; position:sticky; bottom:0; }
.close-btn { background:none; border:none; color:var(--muted); cursor:pointer; font-size:22px; line-height:1; padding:.15rem .3rem; border-radius:6px; }
.close-btn:hover { background:var(--border); color:var(--ink); }
.notes-area { width:100%; background:#f7fafd; border:1.5px solid var(--border); border-radius:8px; padding:.65rem .9rem; color:var(--ink); font-family:var(--sans); font-size:13px; outline:none; resize:vertical; min-height:80px; transition:border-color .2s; }
.notes-area:focus { background:#fff; border-color:var(--accent); }

/* ---- AVAILABILITY ---- */
.avail-row { display:flex; align-items:center; gap:.6rem; margin-bottom:.5rem; flex-wrap:wrap; }
.avail-row select, .avail-row input[type=time] { background:#f7fafd; border:1.5px solid var(--border); border-radius:8px; padding:.45rem .75rem; color:var(--ink); font-family:var(--sans); font-size:13px; outline:none; transition:border-color .2s; }
.avail-row select:focus, .avail-row input[type=time]:focus { border-color:var(--accent); }
.avail-sep { color:var(--muted); font-size:13px; }

/* ---- CALENDARIO — VISTA MENSILE ---- */
.cal-grid { display:grid; grid-template-columns:repeat(7,1fr); border:1px solid var(--border); border-radius:10px; overflow:hidden; }
.cal-dow  { padding:.6rem .4rem; text-align:center; font-size:11px; font-weight:600; color:var(--muted); text-transform:uppercase; letter-spacing:.06em; background:#f7fafd; border-bottom:1px solid var(--border); }
.cal-cell { min-height:90px; padding:.4rem; border-right:1px solid var(--border); border-bottom:1px solid var(--border); vertical-align:top; cursor:default; transition:background .15s; position:relative; }
.cal-cell:nth-child(7n) { border-right:none; }
.cal-cell:last-child, .cal-cell:nth-last-child(-n+7) { border-bottom:none; }
.cal-cell.other-month { background:#fafbfd; }
.cal-cell.today { background:#e8f4fb; }
.cal-cell.weekend { background:#f9fbfe; }
.cal-day-num { font-size:12px; font-weight:600; color:var(--muted); margin-bottom:.3rem; }
.cal-cell.today .cal-day-num { width:22px; height:22px; background:var(--accent); color:#fff; border-radius:50%; display:flex; align-items:center; justify-content:center; }
.cal-event { font-size:11px; padding:.18rem .5rem; border-radius:5px; margin-bottom:.2rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; cursor:pointer; transition:filter .15s; }
.cal-event:hover { filter:brightness(.92); }
.cal-event.confirmed  { background:#d4edda; color:#1a5c38; border-left:3px solid #1a7a4a; }
.cal-event.pending    { background:#fff3cd; color:#7a5c00; border-left:3px solid #c9a84c; }
.cal-event.completed  { background:#cce0f5; color:#1C355E; border-left:3px solid #1C355E; }
.cal-event.cancelled  { background:#f8d7da; color:#8b1a1a; opacity:.6; border-left:3px solid #c0392b; }

/* ---- CALENDARIO — VISTA SETTIMANALE ---- */
.cal-week-wrap { border:1px solid var(--border); border-radius:10px; overflow:hidden; }
.cal-week-head { display:grid; grid-template-columns:52px repeat(7,1fr); background:#f7fafd; border-bottom:1px solid var(--border); }
.cal-week-head-time { padding:.5rem; border-right:1px solid var(--border); }
.cal-week-head-day { padding:.5rem .25rem; text-align:center; border-right:1px solid var(--border); font-size:11.5px; }
.cal-week-head-day:last-child { border-right:none; }
.cal-week-head-day .wk-dow { font-size:10px; font-weight:700; color:var(--muted); text-transform:uppercase; letter-spacing:.07em; }
.cal-week-head-day .wk-date { font-size:20px; font-family:var(--serif); font-weight:700; color:var(--ink); line-height:1.2; }
.cal-week-head-day.wk-today .wk-date { color:var(--accent); }
.cal-week-head-day.wk-today { background:#e8f4fb; }
.cal-week-body { display:grid; grid-template-columns:52px repeat(7,1fr); }
.cal-week-time-col { display:flex; flex-direction:column; border-right:1px solid var(--border); }
.cal-week-time-slot { height:52px; border-bottom:1px solid #f0f4f8; padding:.25rem .3rem 0; font-size:10px; color:var(--muted); text-align:right; flex-shrink:0; }
.cal-week-day-col { position:relative; border-right:1px solid var(--border); min-height:624px; }
.cal-week-day-col:last-child { border-right:none; }
.cal-week-day-col.wk-today-col { background:#f5fbfe; }
.cal-week-hour-line { position:absolute; left:0; right:0; border-top:1px solid #f0f4f8; }
.cal-week-event { position:absolute; left:2px; right:2px; border-radius:5px; padding:.2rem .4rem; font-size:10.5px; overflow:hidden; cursor:pointer; transition:filter .15s; z-index:1; }
.cal-week-event:hover { filter:brightness(.9); z-index:2; }
.cal-week-event.confirmed  { background:#d4edda; color:#1a5c38; border-left:3px solid #1a7a4a; }
.cal-week-event.pending    { background:#fff3cd; color:#7a5c00; border-left:3px solid #c9a84c; }
.cal-week-event.completed  { background:#cce0f5; color:#1C355E; border-left:3px solid #1C355E; }
.cal-week-event.cancelled  { background:#f8d7da; color:#8b1a1a; opacity:.6; border-left:3px solid #c0392b; }
.cal-now-line { position:absolute; left:0; right:0; height:2px; background:var(--accent); z-index:3; }
.cal-now-line::before { content:''; position:absolute; left:-4px; top:-4px; width:10px; height:10px; border-radius:50%; background:var(--accent); }

/* ---- CALENDARIO — VISTA AGENDA ---- */
.cal-agenda-item { display:flex; gap:1rem; padding:.85rem 1rem; background:var(--surface); border:1px solid var(--border); border-radius:10px; margin-bottom:.6rem; transition:box-shadow .15s; }
.cal-agenda-item:hover { box-shadow:var(--shadow-sm); }
.cal-agenda-date { width:48px; flex-shrink:0; text-align:center; background:var(--blue-dark); border-radius:8px; padding:.5rem .25rem; }
.cal-agenda-date .ag-day { font-size:22px; font-family:var(--serif); font-weight:700; color:#fff; line-height:1; }
.cal-agenda-date .ag-mon { font-size:10px; color:rgba(255,255,255,.6); text-transform:uppercase; letter-spacing:.06em; }
.cal-agenda-body { flex:1; min-width:0; }
.cal-agenda-time { font-size:12px; font-weight:600; color:var(--accent); margin-bottom:.2rem; }
.cal-agenda-title { font-size:14px; color:var(--ink); font-weight:500; margin-bottom:.25rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.cal-agenda-meta { font-size:12px; color:var(--muted); }

/* Toggle vista calendario */
.cal-view-toggle { display:flex; background:#f0f4f9; border-radius:8px; padding:2px; gap:2px; }
.cal-view-btn { padding:.3rem .75rem; border-radius:6px; border:none; background:none; font-size:12.5px; font-weight:500; color:var(--muted); cursor:pointer; transition:all .15s; }
.cal-view-btn.active { background:#fff; color:var(--ink); font-weight:600; box-shadow:0 1px 4px rgba(0,0,0,.1); }

/* Tooltip calendario */
.cal-tooltip { position:fixed; z-index:9999; background:var(--surface); border:1px solid var(--border); border-radius:12px; box-shadow:0 8px 32px rgba(28,53,94,.22); padding:0; width:260px; display:none; }
.cal-tooltip.visible { display:block; }
.cal-tooltip-head { padding:.65rem .9rem; border-bottom:1px solid var(--border); border-radius:12px 12px 0 0; display:flex; align-items:center; justify-content:space-between; }
.cal-tooltip-time { font-size:13px; font-weight:600; color:var(--ink); }
.cal-tooltip-body { padding:.75rem .9rem; }
.cal-tooltip-row  { display:flex; align-items:flex-start; gap:.5rem; font-size:12px; color:var(--muted); margin-bottom:.4rem; line-height:1.4; }
.cal-tooltip-row:last-child { margin-bottom:0; }
.cal-tooltip-row svg { flex-shrink:0; margin-top:1px; }
.cal-tooltip-row strong { color:var(--ink); }

/* ---- SECTIONS ---- */
.section { display:none; }
.section.active { display:block; }
.sep { border:none; border-top:1px solid var(--border); margin:1.2rem 0; }

/* ---- TOAST ---- */
#toast { position:fixed; bottom:2rem; right:2rem; z-index:999; display:flex; flex-direction:column; gap:.5rem; }
.toast-msg { background:var(--surface); border:1px solid var(--border); padding:.7rem 1.2rem; border-radius:10px; font-size:13px; box-shadow:var(--shadow-sm); animation:slideIn .2s ease; max-width:320px; }
.toast-msg.ok  { border-left:3px solid #1a7a4a; color:#1a5c38; }
.toast-msg.err { border-left:3px solid var(--danger); color:var(--danger); }
@keyframes slideIn { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- EMPTY STATE ---- */
.empty-state { text-align:center; padding:3rem 1rem; color:var(--muted); }
.empty-state svg { opacity:.3; margin-bottom:1rem; }
.empty-state p { font-size:13.5px; line-height:1.7; }

/* ---- APPUNTAMENTO PILL ---- */
.appt-pill { display:inline-flex; align-items:center; gap:.3rem; background:var(--blue-lt); color:var(--blue); border-radius:20px; padding:.22rem .65rem; font-size:11px; font-weight:500; margin-top:.35rem; }
