:root {
  --bg: #0f1117; --surface: #1e293b; --surface2: #172033;
  --border: #334155; --text: #e2e8f0; --muted: #64748b;
  --green: #4ade80; --blue: #60a5fa; --orange: #fb923c;
  --purple: #c084fc; --yellow: #fbbf24; --red: #f87171;
  --font: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'SF Mono', 'Consolas', monospace;
}
* { box-sizing: border-box; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.6; margin: 0; }
a { color: var(--blue); }
[hidden] { display: none !important; }
body:not(.is-mobile) .only-mobile { display: none !important; }
body.is-mobile .only-desktop { display: none !important; }

.page-header { background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%); border-bottom: 1px solid var(--border); padding: 2rem 0; }
.page-header h1 { font-size: 1.6rem; font-weight: 700; margin: 0; }
.page-header .sub { color: var(--muted); font-size: 0.85rem; margin-top: 0.3rem; }
.page-header .sub a { color: var(--muted); text-decoration: none; }
.page-header .sub a:hover { color: var(--blue); }

.section-title { font-size: 0.85rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; margin: 2.5rem 0 0.8rem; padding-bottom: 0.4rem; border-bottom: 1px solid #1e293b; display: flex; align-items: center; gap: 0.6rem; }
.section-count { font-size: 0.8rem; font-weight: 400; }

.track-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 1rem; overflow: hidden; }
.track-header { padding: 1rem 1.25rem; display: flex; align-items: center; gap: 0.75rem; background: var(--surface2); cursor: pointer; user-select: none; border-bottom: 1px solid var(--border); }
.track-header:hover { background: #1d2d47; }
.track-header h5 { margin: 0; font-size: 1.05rem; font-weight: 600; flex: 1; }
.track-id-label { font-size: 0.75rem; color: var(--muted); }
.track-body { padding: 1rem 1.25rem; display: none; }
.track-body.open { display: block; }
.chevron { transition: transform 0.2s; color: var(--muted); flex-shrink: 0; font-size: 1rem; }
.chevron.open { transform: rotate(180deg); }

.badge-done   { background: #14532d; color: var(--green); border: 1px solid #166534; }
.badge-prog   { background: #1c3a5e; color: var(--blue);  border: 1px solid #1d4ed8; }
.badge-pend   { background: #2d1f00; color: var(--orange);border: 1px solid #92400e; }
.badge-noplan { background: #1a1a2e; color: var(--muted); border: 1px solid #374151; }
.status-badge { font-size: 0.75rem; padding: 0.25em 0.75em; border-radius: 20px; font-weight: 700; white-space: nowrap; }
.status-icon  { font-size: 1rem; flex-shrink: 0; }

.phase-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.phase-table th { color: var(--muted); font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); text-align: left; }
.phase-table td { padding: 0.6rem 0.6rem; border-bottom: 1px solid #162030; vertical-align: middle; }
.phase-table tbody tr.phase-row { cursor: pointer; transition: background 0.15s; }
.phase-table tbody tr.phase-row:hover { background: rgba(96,165,250,0.06); }
.phase-name { color: #cbd5e1; }
.phase-count { text-align: center; color: var(--muted); width: 80px; font-size: 0.85rem; }
.phase-progress { width: 120px; }
.phase-actions { min-width: 200px; text-align: right; white-space: nowrap; }

.pbar { background: #0f172a; border-radius: 3px; height: 6px; overflow: hidden; }
.pbar-fill { height: 100%; border-radius: 3px; transition: width 0.4s; }
.pbar-green { background: var(--green); } .pbar-blue { background: var(--blue); } .pbar-orange { background: var(--orange); } .pbar-verif { background: var(--blue); }

.summary-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.stat-cell { background: var(--surface); padding: 1.25rem 0.75rem; text-align: center; }
.stat-val { font-size: 2rem; font-weight: 800; line-height: 1; }
.stat-lbl { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 0.3rem; }

.btn-cnd { font-family: var(--font); font-size: 0.78rem; padding: 0.3em 0.7em; border-radius: 6px; cursor: pointer; font-weight: 600; transition: all 0.15s; white-space: nowrap; }
.btn-run { background: #1a3a1a; color: var(--green); border: 1px solid #166534; }
.btn-run:hover { background: #166534; color: #fff; }
.btn-verif { background: #1c3a5e; color: var(--blue); border: 1px solid #1d4ed8; }
.btn-verif:hover { background: #1d4ed8; color: #fff; }
.btn-mention { background: #1a1a2e; color: var(--purple); border: 1px solid #6b21a8; }
.btn-mention:hover { background: #6b21a8; color: #fff; }
.btn-refresh { background: #1c3a5e; color: var(--blue); border: 1px solid #1d4ed8; font-size: 0.85rem; padding: 0.4em 1em; border-radius: 6px; cursor: pointer; font-weight: 600; font-family: var(--font); }
.btn-refresh:hover { background: #1d4ed8; color: #fff; }
.btn-toolbar { font-size: 0.82rem; padding: 0.35em 0.85em; font-family: var(--font); }

.inline-panel { background: #131b2e; border: 1px solid #253350; border-radius: 8px; margin: 0.5rem 0; padding: 0.8rem 1rem; }
.inline-panel-title { font-size: 0.85rem; font-weight: 700; color: var(--muted); margin-bottom: 0.5rem; display: flex; align-items: center; gap: 0.5rem; }
.noplan-note { color: var(--muted); font-size: 0.88rem; font-style: italic; }

/* Project Docs section */
.docs-section { margin-bottom: 2rem; }
.docs-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 0; }
.docs-tab { background: var(--surface); color: var(--muted); border: 1px solid var(--border); border-bottom: none; border-radius: 6px 6px 0 0; padding: 0.4em 1em; font-size: 0.78rem; font-weight: 600; font-family: var(--font); cursor: pointer; transition: all 0.15s; }
.docs-tab:hover { color: var(--text); }
.docs-tab.active { background: var(--surface2); color: var(--green); border-color: var(--green); border-bottom: 1px solid var(--surface2); }
.docs-content { background: var(--surface2); border: 1px solid var(--border); border-top: none; border-radius: 0 0 8px 8px; padding: 1.25rem; font-size: 0.85rem; line-height: 1.7; color: #cbd5e1; overflow: hidden; }
.docs-content h1, .docs-content h2, .docs-content h3 { color: var(--text); margin: 1rem 0 0.4rem; }
.docs-content h1 { font-size: 1.1rem; } .docs-content h2 { font-size: 0.95rem; } .docs-content h3 { font-size: 0.88rem; }
.docs-content ul { padding-left: 1.2rem; } .docs-content li { margin-bottom: 0.2rem; }
.docs-content strong { color: var(--text); }
.docs-empty { color: var(--muted); font-size: 0.82rem; font-style: italic; padding: 1rem; text-align: center; }
.track-desc { font-size: 0.85rem; color: white; margin-bottom: 0.75rem; line-height: 1.5; }
.btn-copy { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 0.8rem; padding: 2px 5px; opacity: 0; transition: opacity 0.15s; vertical-align: middle; }
.track-header:hover .btn-copy { opacity: 0.7; }
.btn-copy:hover { color: var(--blue); opacity: 1 !important; }
.btn-copy.copied { color: var(--green); opacity: 1 !important; }

.task-list { padding-left: 0.5rem; }
.task-item { font-size: 0.88rem; color: white; padding: 0.25rem 0; display: flex; gap: 0.5rem; align-items: baseline; }
.task-mark { font-weight: 700; width: 18px; text-align: center; flex-shrink: 0; }
.task-done { color: var(--green); } .task-skip { color: var(--muted); } .task-pend { color: var(--orange); } .task-prog { color: var(--blue); }

/* INLINE EDITOR per plan.md */
.plan-editor { background: #0d1117; border: 1px solid #253350; border-radius: 8px; margin: 0.5rem 0; overflow: hidden; }
.plan-editor-header { padding: 0.5rem 0.8rem; background: var(--surface2); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 0.5rem; }
.plan-editor-header span { font-size: 0.8rem; color: var(--muted); flex: 1; }
.btn-save { background: #14532d; color: var(--green); border: 1px solid #166534; font-size: 0.78rem; padding: 0.25em 0.7em; border-radius: 5px; cursor: pointer; font-weight: 700; font-family: var(--font); }
.btn-save:hover { background: #166534; color: #fff; }
.btn-cancel-edit { background: transparent; color: var(--muted); border: 1px solid #374151; font-size: 0.78rem; padding: 0.25em 0.7em; border-radius: 5px; cursor: pointer; font-family: var(--font); }
.plan-editor textarea {
  width: 100%; min-height: 300px; background: #0d1117; color: var(--text);
  font-family: var(--font); font-size: 0.85rem; line-height: 1.6;
  border: none; outline: none; resize: vertical; padding: 0.8rem; tab-size: 2;
}
.plan-editor textarea:focus { box-shadow: inset 0 0 0 1px var(--blue); }

/* ============================================================ */
/* LOGIN + PROJECT PICKER                                        */
/* ============================================================ */
.center-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; }
.login-box { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 2.5rem; width: 360px; max-width: 90vw; }
.login-box .logo { font-size: 2rem; margin-bottom: 0.5rem; text-align: center; }
.login-box h2 { font-size: 1.2rem; font-weight: 700; margin: 0; text-align: center; }
.login-box .hint { color: var(--muted); font-size: 0.8rem; margin: 0.3rem 0 1.5rem; text-align: center; }
.login-box input { width: 100%; padding: 0.6rem 0.8rem; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; color: var(--text); font-family: var(--font); font-size: 0.9rem; margin-bottom: 0.8rem; }
.login-box button { width: 100%; padding: 0.6rem; background: var(--blue); color: #0f1117; border: none; border-radius: 6px; font-family: var(--font); font-size: 0.9rem; font-weight: 700; cursor: pointer; margin-top: 0.4rem; }
.login-error { color: var(--red); font-size: 0.8rem; text-align: center; margin-top: 1rem; }

.picker-box { width: 640px; max-width: 95vw; }
.picker-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0.8rem; }
.picker-item { display: flex; align-items: center; gap: 0.8rem; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1.1rem 1.25rem; color: var(--text); text-decoration: none; transition: all 0.15s; }
.picker-item:hover { border-color: var(--green); background: var(--surface2); color: var(--text); }
.picker-item .pk-label { font-weight: 700; font-size: 1rem; }
.picker-item .pk-name { color: var(--muted); font-size: 0.8rem; margin-left: auto; }

/* ============================================================ */
/* FLOATING CHAT — Multi-session con tab                        */
/* ============================================================ */
.chat-fab {
  position: fixed; bottom: 24px; right: 24px; z-index: 9998;
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, #1d4ed8, #7c3aed);
  border: 2px solid #6366f1; color: #fff; font-size: 24px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(99,102,241,0.4);
  transition: transform 0.2s, box-shadow 0.2s;
}
.chat-fab:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(99,102,241,0.5); }
.chat-fab.has-session { border-color: var(--green); box-shadow: 0 4px 20px rgba(74,222,128,0.3); }
.chat-fab-badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--green); color: #000; font-size: 0.6rem; font-weight: 800;
  border-radius: 50%; min-width: 18px; height: 18px;
  display: none; align-items: center; justify-content: center; line-height: 1;
}

.chat-modal {
  position: fixed; bottom: 90px; right: 24px; z-index: 9999;
  width: 560px; height: 500px; min-width: 400px; min-height: 340px;
  background: #0d1117; border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden;
  box-shadow: 0 12px 48px rgba(0,0,0,0.6);
  display: none; flex-direction: column;
  resize: both;
}
.chat-resize-tl { position: absolute; top: 0; left: 0; width: 14px; height: 14px; cursor: nw-resize; z-index: 10; }
.chat-modal.open { display: flex; }

.chat-modal-header {
  padding: 0.5rem 0.8rem; background: var(--surface2);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0;
  cursor: move;
}
.chat-modal-header .chat-title { font-size: 0.8rem; font-weight: 700; color: var(--green); white-space: nowrap; }
.chat-modal-header button.chat-close-btn, .chat-modal-header a.chat-close-btn {
  background: transparent; border: 1px solid #374151; color: var(--muted);
  font-size: 0.75rem; padding: 0.2em 0.5em; border-radius: 4px; cursor: pointer; font-family: var(--font); flex-shrink: 0;
}
.chat-modal-header button.chat-close-btn:hover, .chat-modal-header a.chat-close-btn:hover { color: var(--text); border-color: var(--text); }

/* Tab bar */
.chat-tab-bar {
  flex: 1; display: flex; align-items: center; gap: 2px;
  overflow-x: auto; overflow-y: hidden; padding: 0 0.3rem;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.chat-tab-bar::-webkit-scrollbar { height: 3px; }
.chat-tab-bar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.chat-tab {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: 0.25em 0.4em 0.25em 0.6em;
  font-size: 0.7rem; font-family: var(--font); color: var(--muted);
  cursor: pointer; white-space: nowrap; max-width: 200px; flex-shrink: 0;
  transition: all 0.15s;
}
.chat-tab:hover { color: var(--text); border-color: #4b5563; }
.chat-tab.active { background: #0d1117; border-color: var(--green); color: var(--green); }
.chat-tab.has-new { animation: tab-pulse 1.5s ease-in-out infinite; }
@keyframes tab-pulse { 0%,100%{border-color:var(--border)} 50%{border-color:var(--blue)} }
.chat-tab .tab-label { overflow: hidden; text-overflow: ellipsis; max-width: 130px; }
.chat-tab .tab-close { font-size: 0.85rem; color: var(--muted); cursor: pointer; padding: 2px 6px; border-radius: 4px; line-height: 1; margin-left: 2px; flex-shrink: 0; }
.chat-tab .tab-close:hover { color: var(--red); background: rgba(248,113,113,0.2); }
.tab-dot.working { animation: dot-blink 0.8s ease-in-out infinite; }
@keyframes dot-blink { 0%,100%{opacity:1} 50%{opacity:0.2} }
.chat-tab-new { color: var(--muted); font-size: 1.1rem; font-weight: 700; padding: 0 10px !important; min-width: auto; justify-content: center; }
.chat-tab-new:hover { color: var(--green); border-color: var(--green); }
.tab-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.tab-dot.on { background: var(--green); }
.tab-dot.connecting { background: var(--yellow); }
.tab-dot.off { background: #4b5563; }

/* Sessions area */
.chat-sessions-area { flex: 1; overflow: hidden; position: relative; }
.chat-session-pane { position: absolute; inset: 0; display: none; overflow: hidden; padding: 4px 0 0 6px; background: #0d1117; }
.chat-session-pane.active { display: block; }
.chat-session-pane .xterm { height: 100%; }
.chat-session-pane:not(.active) .xterm-cursor-layer { display: none !important; }
/* Scrollbar del viewport xterm visibile e sottile (desktop) */
.chat-session-pane .xterm .xterm-viewport { scrollbar-width: thin; scrollbar-color: #334155 transparent; }
.chat-session-pane .xterm .xterm-viewport::-webkit-scrollbar { width: 8px; }
.chat-session-pane .xterm .xterm-viewport::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }

.chat-notice { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 2rem; }
.chat-notice-inner { text-align: center; color: var(--muted); font-size: 0.85rem; line-height: 1.8; max-width: 340px; }
.chat-notice-inner code { display: block; font-size: 0.82rem; margin: 0.8rem 0; background: var(--surface); padding: 0.5em 1em; border-radius: 6px; border: 1px solid var(--border); }
.chat-notice-inner .btn-cnd { display: inline-block; margin-top: 1rem; }

.bridge-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }
.bridge-dot.on { background: var(--green); box-shadow: 0 0 6px var(--green); }
.bridge-dot.off { background: #4b5563; }

/* Mention phases dropdown */
.mention-btn { position: relative; }
.mention-dropdown {
  display: none; position: absolute; top: 100%; right: 0; z-index: 9999;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  min-width: 280px; max-height: 340px; overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5); margin-top: 4px;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.mention-dropdown.open { display: block; }
.mention-dropdown::-webkit-scrollbar { width: 5px; }
.mention-dropdown::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.mention-track-label { font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: 0.5em 0.8em 0.3em; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.mention-phase-item { display: flex; align-items: center; gap: 6px; padding: 0.45em 0.8em; cursor: pointer; font-size: 0.75rem; color: var(--text); transition: background 0.1s; }
.mention-phase-item:hover { background: rgba(96,165,250,0.1); }
.mention-phase-item .mp-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.mention-phase-item .mp-dot.done { background: var(--green); }
.mention-phase-item .mp-dot.prog { background: var(--blue); }
.mention-phase-item .mp-dot.pend { background: var(--orange); }
.mention-phase-item .mp-dot.verif { background: var(--purple); }
.mention-phase-item .mp-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mention-phase-item .mp-count { color: var(--muted); font-size: 0.68rem; flex-shrink: 0; }

/* Mobile session dropdown */
.chat-session-select {
  flex: 1; min-width: 0;
  font-family: var(--font); font-size: 0.75rem; font-weight: 600;
  background: var(--surface); color: var(--green);
  border: 1px solid var(--border); border-radius: 5px;
  padding: 0.2em 0.4em; cursor: pointer;
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%2364748b'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 6px center;
  padding-right: 20px;
}
.chat-session-select:focus { outline: none; border-color: var(--green); }
.chat-session-select option { background: var(--surface); color: var(--text); }

/* Toolbar tasti sotto il terminale */
.chat-key-toolbar {
  display: flex; flex-shrink: 0; align-items: center;
  background: var(--surface2); border-top: 1px solid var(--border);
  padding: 4px 6px; gap: 4px; overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.key-btn {
  font-family: var(--font); font-size: 0.72rem; font-weight: 600;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 5px; padding: 6px 10px; cursor: pointer; white-space: nowrap;
  min-height: 36px; display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.key-btn:active { background: var(--blue); color: #fff; border-color: var(--blue); }
.key-btn.key-danger:active { background: var(--red); border-color: var(--red); }
.key-btn.key-btn-active { background: var(--green); color: #0d1117; border-color: var(--green); }
.key-btn.key-btn-active:active { background: #22c55e; }
.key-btn.key-attn { border-color: var(--blue); color: var(--blue); }
.key-sep { display: inline-block; width: 1px; align-self: stretch; background: var(--border); margin: 2px 4px; }
.key-spacer { flex: 1; }

/* Drag & drop overlay sul pane terminale */
.chat-dropzone {
  position: absolute; inset: 0;
  display: none; align-items: center; justify-content: center;
  background: rgba(13,17,23,0.85);
  border: 2px dashed var(--green);
  color: var(--green); font-size: 1rem; font-weight: 600;
  pointer-events: none; z-index: 5;
  border-radius: 4px;
}
.chat-dropzone.active { display: flex; }

/* Toast */
.chat-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--surface2); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 0.6em 1em; font-size: 0.82rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  z-index: 10000; opacity: 0; transition: opacity 0.2s;
  pointer-events: none;
}
.chat-toast.show { opacity: 1; }
.chat-toast.ok { border-color: var(--green); color: var(--green); }
.chat-toast.err { border-color: var(--red); color: var(--red); }

/* Area Tabs */
.area-tabs { display: flex; gap: 6px; margin-bottom: 1.2rem; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: thin; scrollbar-color: var(--border) transparent; padding-bottom: 4px; }
.area-tabs::-webkit-scrollbar { height: 3px; }
.area-tabs::-webkit-scrollbar-thumb { background: var(--border); }
.area-tab { font-family: var(--font); font-size: 0.82rem; font-weight: 600; background: var(--surface); color: var(--muted); border: 1px solid var(--border); border-bottom: 2px solid transparent; padding: 0.5em 1em; cursor: pointer; white-space: nowrap; transition: all 0.15s; flex-shrink: 0; }
.area-tab:hover { color: var(--text); border-color: #4b5563; }
.area-tab.active { color: var(--green); border-color: var(--green); border-bottom-color: var(--green); background: var(--surface2); }
.area-tab .tab-count { font-size: 0.72rem; font-weight: 400; color: var(--muted); margin-left: 6px; }
.area-tab.active .tab-count { color: var(--green); }

@media (max-width: 576px) {
  .summary-grid { grid-template-columns: repeat(3, 1fr); }
  .phase-progress, .phase-count { display: none; }
}

/* ============================================================ */
/* MOBILE RESPONSIVE                                             */
/* ============================================================ */
@media (max-width: 768px) {
  body { font-size: 13px; }
  .page-header { padding: 1rem 0; }
  .page-header h1 { font-size: 1.15rem; }
  .page-header .sub { font-size: 0.72rem; }
  .stat-val { font-size: 1.4rem; }
  .stat-cell { padding: 0.75rem 0.4rem; }
  .stat-lbl { font-size: 0.65rem; }
  .section-title { margin: 1.5rem 0 0.6rem; font-size: 0.78rem; }
  .track-header { padding: 0.7rem 0.8rem; gap: 0.5rem; }
  .track-header h5 { font-size: 0.9rem; }
  .track-body { padding: 0.7rem 0.8rem; }
  .btn-cnd { font-size: 0.72rem; padding: 0.35em 0.6em; }
  .btn-refresh { font-size: 0.75rem; padding: 0.3em 0.7em; }
  .btn-toolbar { display: none; }

  .phase-table thead { display: none; }
  .phase-table, .phase-table tbody, .phase-table tr, .phase-table td { display: block; width: 100%; }
  .phase-table tr.phase-row { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; margin-bottom: 6px; padding: 8px 10px; }
  .phase-name { font-size: 0.82rem; font-weight: 600; margin-bottom: 4px; }
  .phase-count { text-align: left; width: auto; display: inline-block !important; font-size: 0.75rem; }
  .phase-progress { width: 100% !important; display: block !important; margin: 4px 0; }
  .phase-actions { text-align: left; min-width: auto; padding-top: 4px !important; }
  .inline-panel-row td { padding: 0 !important; }

  .chat-modal {
    position: fixed !important;
    top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important;
    width: auto !important; height: auto !important;
    border-radius: 0; border: none; min-width: 0; min-height: 0;
    resize: none;
  }
  .chat-modal-header { cursor: default; padding: 0.7rem 0.8rem !important; gap: 0.5rem !important; touch-action: none; }
  .chat-modal-header .chat-title { font-size: 1rem !important; }
  .chat-modal-header button.chat-close-btn, .chat-modal-header a.chat-close-btn { font-size: 1.1rem !important; padding: 0.4em 0.7em !important; min-width: 40px; min-height: 40px; display: flex; align-items: center; justify-content: center; }
  .chat-modal-header .chat-session-select { font-size: 0.9rem !important; min-width: 100px; padding: 0.4em 0.5em !important; min-height: 40px; }
  .mention-dropdown { min-width: 240px; max-height: 260px; left: 0; right: auto; }
  .chat-fab { bottom: 16px; right: 16px; width: 50px; height: 50px; font-size: 20px; }
  .chat-fab-badge { min-width: 16px; height: 16px; font-size: 0.55rem; }
  .chat-tab .tab-label { max-width: 90px; }
  .chat-tab { padding: 0.25em 0.4em; font-size: 0.65rem; }
  .chat-key-toolbar { padding: 6px 8px !important; gap: 5px !important; flex-wrap: wrap; justify-content: center; padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px)) !important; touch-action: none; }
  .key-btn { font-size: 0.85rem !important; padding: 10px 14px !important; min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center; }
  .key-spacer { display: none; }
  .chat-session-pane { padding: 0; }
  .chat-session-pane .xterm { overflow: hidden !important; }
  .chat-session-pane .xterm .xterm-viewport { -webkit-overflow-scrolling: touch !important; overflow-y: scroll !important; overflow-x: hidden !important; }
  .chat-session-pane .xterm .xterm-screen { overflow: hidden !important; }
  .xterm-scroll-indicator { position: absolute; top: 0; right: 2px; width: 3px; min-height: 30px; background: rgba(100,116,139,0.7); border-radius: 2px; opacity: 0; transition: opacity 0.3s ease; pointer-events: none; z-index: 10; }
  .xterm-text-overlay { position: absolute; inset: 0; z-index: 20; background: #0d1117; overflow-y: scroll; overflow-x: hidden; -webkit-overflow-scrolling: touch; -webkit-user-select: none; user-select: none; touch-action: pan-y; }
  .xterm-text-overlay-content { color: #e2e8f0; font-family: 'JetBrains Mono', monospace; font-size: 12px; line-height: 1.4; padding: 10px; white-space: pre-wrap; word-break: break-all; -webkit-user-select: none; user-select: none; touch-action: pan-y; pointer-events: none; }
  .xterm-text-overlay.select-active .xterm-text-overlay-content { -webkit-user-select: text !important; user-select: text !important; pointer-events: auto; touch-action: auto; }
}

/* ============================================================ */
/* ADMIN: gestione progetti e utenti                              */
/* ============================================================ */
.picker-item .pk-meta { color: var(--muted); font-size: 0.78rem; }
.picker-item.disabled { opacity: 0.5; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.admin-table .btn-cnd { font-size: 0.75rem; }
.admin-table th { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; padding: 0.5rem 0.7rem; border-bottom: 1px solid var(--border); text-align: left; }
.admin-table td { padding: 0.55rem 0.7rem; border-bottom: 1px solid #162030; vertical-align: middle; }
.admin-table td.actions { white-space: nowrap; text-align: right; }
.admin-table .mono { color: var(--muted); font-size: 0.78rem; }
.admin-table .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.admin-table .dot.ok { background: var(--green); } .admin-table .dot.warn { background: var(--orange); } .admin-table .dot.bad { background: var(--red); }
.admin-modal-backdrop { position: fixed; inset: 0; background: rgba(5,8,15,0.7); display: flex; align-items: center; justify-content: center; z-index: 10000; padding: 1rem; }
.admin-form { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 1.4rem 1.6rem; display: flex; flex-direction: column; gap: 0.35rem; width: 480px; max-width: 100%; max-height: 92vh; overflow-y: auto; box-shadow: 0 16px 48px rgba(0,0,0,0.6); }
.admin-form-title { font-weight: 700; color: var(--green); margin-bottom: 0.4rem; }
.admin-form label { color: var(--muted); font-size: 0.75rem; margin-top: 0.4rem; }
.admin-form input, .admin-form select, .admin-form textarea { width: 100%; padding: 0.45rem 0.6rem; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; color: var(--text); font-family: var(--font); font-size: 0.85rem; }
.admin-form label.admin-check { display: flex; align-items: center; gap: 0.5rem; color: var(--text); font-size: 0.85rem; }
.admin-form label.admin-check input { width: auto; }
.admin-checks { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; padding: 0.3rem 0; }
.admin-checks label { display: flex; align-items: center; gap: 0.35rem; color: var(--text); font-size: 0.82rem; margin: 0; }
.admin-checks input { width: auto; }
.admin-form-actions { display: flex; gap: 0.5rem; margin-top: 0.8rem; justify-content: flex-end; }
.admin-form-actions .btn-save, .admin-form-actions .btn-cancel-edit { font-size: 0.85rem; padding: 0.45em 1.1em; }
.admin-msg { font-size: 0.8rem; min-height: 1.2em; margin-top: 0.3rem; }
.admin-msg.ok { color: var(--green); } .admin-msg.err { color: var(--red); } .admin-msg.warn { color: var(--orange); }

/* ============================================================ */
/* MODALITA' TERMINALE (/p/<slug>/term/): solo xterm fullscreen  */
/* ============================================================ */
.term-only { display: none; }
body.term-mode .term-only { display: inline-block; }
body.term-mode .no-term { display: none !important; }
body.term-mode #view-dashboard > .page-header, body.term-mode #view-dashboard > .container-xl, body.term-mode .chat-fab { display: none !important; }
body.term-mode .chat-modal { position: fixed; inset: 0; width: auto !important; height: auto !important; min-width: 0; min-height: 0; border: none; border-radius: 0; resize: none; box-shadow: none; left: 0 !important; top: 0 !important; right: 0 !important; bottom: 0 !important; }
body.term-mode .chat-modal-header { cursor: default; padding-top: calc(0.5rem + env(safe-area-inset-top, 0px)); }
body.term-mode .chat-resize-tl { display: none; }
body.term-mode a.chat-close-btn { line-height: 1.2; }
body.term-mode #term-project-lbl { color: var(--muted); font-weight: 400; margin-left: 0.5rem; }
body.term-mode .chat-key-toolbar { padding-bottom: calc(4px + env(safe-area-inset-bottom, 0px)); }
.picker-item .pk-actions { margin-left: auto; display: flex; gap: 0.4rem; }
.picker-item .pk-actions .btn-cnd { text-decoration: none; }
