/* ============================================================
   Amperofy — Design System
   Palette ufficiale Ampero.it (estratta da CSS produzione)
   ============================================================ */
:root {
  --brand:          #ef5223;
  --brand-hover:    #d8441a;
  --brand-soft:     #fde6dd;
  --brand-gradient: linear-gradient(135deg, #ff6a33 0%, #ef5223 100%);
  --dark:           #28282b;
  --dark-2:         #1a1a1c;
  --text:           #1f2937;
  --text-muted:     #6b7280;
  --border:         #e5e7eb;
  --border-strong:  #d4d4d4;
  --bg:             #f5f5f5;
  --bg-soft:        #fafafa;
  --surface:        #ffffff;
  --warm-gray:      #998e8c;

  --success:        #07bc0c;
  --warning:        #f1c40f;
  --danger:         #e74c3c;
  --info:           #3498db;

  --radius:         10px;
  --radius-sm:      6px;
  --radius-lg:      16px;
  --shadow-sm:      0 1px 2px rgba(40,40,43,.06);
  --shadow:         0 2px 8px rgba(40,40,43,.08);
  --shadow-lg:      0 8px 24px rgba(40,40,43,.12);

  --sidebar-w:      240px;
  --header-h:       56px;

  --font-body:      "acumin-pro", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

/* --- Layout --- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; grid-template-rows: var(--header-h) 1fr; grid-template-areas: "sidebar header" "sidebar main"; height: 100vh; }

.header { grid-area: header; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 20px; gap: 16px; z-index: 10; }
.header .search { flex: 1; max-width: 480px; position: relative; }
.header .search input { width: 100%; height: 36px; padding: 0 12px 0 36px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-soft); transition: border .15s, background .15s; }
.header .search input:focus { outline: none; border-color: var(--brand); background: #fff; }
.header .search::before { content: "search"; font-family: 'Material Symbols Outlined'; font-size: 18px; color: var(--text-muted); position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-variation-settings: 'wght' 500; }
.header .actions { display: flex; align-items: center; gap: 10px; }
.header .icon-btn { width: 36px; height: 36px; border: none; background: transparent; border-radius: 50%; display: grid; place-items: center; cursor: pointer; color: var(--text-muted); }
.header .icon-btn:hover { background: var(--bg); color: var(--dark); }
.header .icon-btn .material-symbols-outlined { font-size: 20px; }
.header .user { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 999px; cursor: pointer; }
.header .user:hover { background: var(--bg); }

.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 12px; flex-shrink: 0; }
.avatar.lg { width: 40px; height: 40px; font-size: 15px; }

/* --- Sidebar --- */
.sidebar { grid-area: sidebar; background: var(--dark); color: #fff; display: flex; flex-direction: column; overflow: hidden; }
.sidebar .brand { display: flex; align-items: center; padding: 10px 16px; min-height: var(--header-h); border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar .brand img { height: 63px; }
.sidebar .nav { padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; }
.sidebar .nav button { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: transparent; border: none; border-radius: var(--radius-sm); color: rgba(255,255,255,.8); cursor: pointer; text-align: left; font-size: 14px; }
.sidebar .nav button:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar .nav button.active { background: var(--brand); color: #fff; }
.sidebar .nav button .material-symbols-outlined { font-size: 20px; }
.sidebar .section-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: rgba(255,255,255,.4); padding: 14px 16px 6px; font-weight: 700; }
.sidebar .workspaces { overflow-y: auto; flex: 1; padding-bottom: 16px; }
.sidebar .ws-header { display: flex; align-items: center; gap: 8px; padding: 6px 16px; color: rgba(255,255,255,.55); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.sidebar .pipe-item { display: flex; align-items: center; gap: 10px; padding: 7px 16px 7px 28px; color: rgba(255,255,255,.75); cursor: pointer; font-size: 13px; border-left: 3px solid transparent; }
.sidebar .pipe-item:hover { background: rgba(255,255,255,.04); color: #fff; }
.sidebar .pipe-item.active { background: rgba(239,82,35,.18); color: #fff; border-left-color: var(--brand); }
.sidebar .pipe-item .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--brand); }
.sidebar .pipe-item .badge { margin-left: auto; background: rgba(255,255,255,.08); padding: 1px 7px; border-radius: 999px; font-size: 11px; }
.sidebar .footer { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.08); font-size: 11px; color: rgba(255,255,255,.4); display: flex; justify-content: space-between; }
.sidebar .footer a { color: var(--brand); text-decoration: none; }

.workspace-header-row { transition: all .15s; }
.workspace-header-row:hover .ws-add-btn { opacity: 1; }

.sidebar .ws-add-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,.08);
  border: none;
  color: rgba(255,255,255,.6);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  opacity: 0.5;
  transition: all .15s;
  padding: 0;
}

.sidebar .ws-add-btn:hover {
  background: var(--brand);
  color: #fff;
  opacity: 1;
}

.sidebar .ws-add-btn .material-symbols-outlined {
  font-size: 16px;
}

/* --- Main --- */
.main { grid-area: main; overflow: hidden; display: flex; flex-direction: column; }

.toolbar { background: var(--surface); padding: 14px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.toolbar .breadcrumb { color: var(--text-muted); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.toolbar h1 { margin: 0; font-size: 18px; font-weight: 700; color: var(--dark); }
.toolbar .spacer { flex: 1; }

/* --- Buttons --- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid transparent; background: var(--bg); color: var(--text); cursor: pointer; font-weight: 600; font-size: 13px; transition: all .15s; }
.btn:hover { background: #eaeaea; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-hover); }
.btn.ghost { background: transparent; border-color: var(--border); }
.btn.ghost:hover { background: var(--bg); border-color: var(--border-strong); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn .material-symbols-outlined { font-size: 18px; }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; background: var(--bg); border-radius: 999px; font-size: 11px; color: var(--text-muted); font-weight: 600; }
.chip.brand { background: var(--brand-soft); color: var(--brand); }

/* --- Kanban --- */
.kanban { flex: 1; overflow-x: auto; overflow-y: hidden; display: flex; gap: 14px; padding: 20px; background: var(--bg); }
.column { flex: 0 0 290px; background: rgba(255,255,255,.7); border-radius: var(--radius); display: flex; flex-direction: column; max-height: 100%; border: 1px solid var(--border); }
.column.drop-target { background: var(--brand-soft); border-color: var(--brand); }
.column .col-header { padding: 12px 14px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border); }
.column .col-header .name { font-weight: 700; color: var(--dark); }
.column .col-header .count { background: var(--bg); padding: 1px 8px; border-radius: 999px; font-size: 11px; color: var(--text-muted); font-weight: 700; }
.column .col-header .sla { margin-left: auto; font-size: 11px; color: var(--text-muted); display: flex; align-items: center; gap: 2px; }
.column .col-header .sla .material-symbols-outlined { font-size: 14px; }
.column.done .col-header .name { color: var(--success); }
.column .cards { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.column .add-card { border: none; background: transparent; padding: 8px; color: var(--text-muted); cursor: pointer; font-weight: 600; font-size: 12px; display: flex; align-items: center; gap: 4px; border-top: 1px dashed var(--border); }
.column .add-card:hover { color: var(--brand); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; cursor: pointer; box-shadow: var(--shadow-sm); transition: all .15s; user-select: none; }
.card:hover { box-shadow: var(--shadow); transform: translateY(-1px); border-color: var(--brand); }
.card.dragging { opacity: .4; }
.card .card-labels { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.card .card-labels .label { padding: 2px 7px; border-radius: 4px; font-size: 10px; font-weight: 700; color: #fff; background: var(--brand); text-transform: uppercase; letter-spacing: .02em; }
.card .card-title { font-weight: 600; color: var(--dark); margin-bottom: 8px; line-height: 1.35; }
.card .card-meta { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--text-muted); }
.card .card-meta .icon { display: inline-flex; align-items: center; gap: 2px; }
.card .card-meta .material-symbols-outlined { font-size: 14px; }
.card .card-meta .priority { margin-left: auto; }
.card .card-meta .priority.high    { color: #c44211; }
.card .card-meta .priority.urgent  { color: #c00; font-weight: 800; }
.card .card-meta .priority.low     { color: var(--success); }
.card .card-meta .badge-source { background: var(--brand-soft); color: var(--brand); padding: 1px 6px; border-radius: 3px; font-weight: 700; font-size: 10px; }

/* --- Card Detail Drawer --- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(40,40,43,.45); z-index: 40; animation: fade .15s; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 1600px; background: #fff; z-index: 50; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slide .2s; }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade  { from { opacity: 0; } to { opacity: 1; } }

.drawer-header { padding: 18px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: start; gap: 12px; }
.drawer-header .title-wrap { flex: 1; }
.drawer-header input.title { font-size: 20px; font-weight: 700; border: none; padding: 0; background: transparent; width: 100%; color: var(--dark); }
.drawer-header input.title:focus { outline: none; border-bottom: 2px solid var(--brand); }
.drawer-header .crumbs { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.drawer .meta-bar { padding: 14px 24px; background: var(--bg-soft); border-bottom: 1px solid var(--border); display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 20px; }
.drawer .meta-bar .meta-item { display: flex; flex-direction: column; gap: 2px; }
.drawer .meta-bar .meta-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 700; }
.drawer .meta-bar select, .drawer .meta-bar input { padding: 4px 6px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px 24px; display: flex; flex-direction: column; gap: 22px; }

.section-title { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin: 0 0 10px; display: flex; align-items: center; gap: 6px; }
.section-title .material-symbols-outlined { font-size: 16px; color: var(--brand); }

.field-row { display: grid; grid-template-columns: 160px 1fr; gap: 12px; align-items: start; margin-bottom: 12px; }
.field-row label { font-size: 12px; font-weight: 700; color: var(--dark); padding-top: 6px; }
.field-row label .req { color: var(--brand); }
.field-row .field-input input, .field-row .field-input textarea, .field-row .field-input select { width: 100%; padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; }
.field-row .field-input textarea { min-height: 70px; resize: vertical; }
.field-row .field-input input:focus, .field-row .field-input textarea:focus, .field-row .field-input select:focus { outline: none; border-color: var(--brand); }
.field-row .help { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.field-row .statement { background: var(--brand-soft); padding: 10px 12px; border-radius: var(--radius-sm); color: var(--dark); font-size: 13px; border-left: 3px solid var(--brand); }

.comments .comment { padding: 10px 12px; background: var(--bg-soft); border-radius: var(--radius-sm); margin-bottom: 8px; border: 1px solid var(--border); }
.comments .comment-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.comments .comment-head .who { font-weight: 700; font-size: 13px; color: var(--dark); }
.comments .comment-head .when { font-size: 11px; color: var(--text-muted); }
.comments .comment-body { font-size: 13px; color: var(--text); white-space: pre-wrap; }
.new-comment { display: flex; gap: 8px; margin-top: 10px; }
.new-comment textarea { flex: 1; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); resize: none; min-height: 40px; }
.new-comment textarea:focus { outline: none; border-color: var(--brand); }

.task-list .task-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; margin-bottom: 6px; }
.task-list .task-item.done { opacity: .55; }
.task-list .task-item.done .task-title { text-decoration: line-through; }
.task-list .task-check { width: 20px; height: 20px; border: 2px solid var(--border-strong); border-radius: 50%; display: grid; place-items: center; cursor: pointer; flex-shrink: 0; background: #fff; }
.task-list .task-check.checked { background: var(--brand); border-color: var(--brand); color: #fff; }
.task-list .task-title { font-weight: 600; color: var(--dark); flex: 1; font-size: 13px; }
.task-list .task-type { font-size: 10px; font-weight: 700; text-transform: uppercase; color: var(--brand); background: var(--brand-soft); padding: 2px 6px; border-radius: 3px; }

.history-list { font-size: 12px; color: var(--text-muted); }
.history-list .event { display: flex; gap: 10px; padding: 4px 0; border-left: 2px solid var(--border); padding-left: 12px; margin-left: 4px; }
.history-list .event::before { content: "•"; color: var(--brand); font-weight: 900; position: relative; left: -16px; }
.history-list .event .detail { color: var(--dark); }

/* --- Tasks view --- */
.tasks-view { padding: 24px; overflow-y: auto; flex: 1; }
.tasks-view .tasks-header { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.tasks-view h1 { margin: 0; font-size: 22px; }
.tasks-view .stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.tasks-view .stat { background: #fff; padding: 16px; border-radius: var(--radius); border: 1px solid var(--border); }
.tasks-view .stat .n { font-size: 28px; font-weight: 800; color: var(--dark); }
.tasks-view .stat .l { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.tasks-view .stat.primary .n { color: var(--brand); }
.tasks-view .filter-tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tasks-view .filter-tabs button { padding: 10px 16px; background: transparent; border: none; border-bottom: 2px solid transparent; cursor: pointer; font-weight: 600; color: var(--text-muted); font-size: 13px; }
.tasks-view .filter-tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }
.tasks-view .tasks-table { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.tasks-view .tasks-table .row { display: grid; grid-template-columns: 1fr 180px 110px 110px 130px 110px; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.tasks-view .tasks-table .row:last-child { border-bottom: none; }
.tasks-view .tasks-table .row.head { background: var(--bg-soft); font-size: 11px; text-transform: uppercase; color: var(--text-muted); font-weight: 700; letter-spacing: .06em; }
.tasks-view .tasks-table .row:not(.head):hover { background: var(--bg-soft); }
.tasks-view .tasks-table .t-title { font-weight: 600; color: var(--dark); }
.tasks-view .tasks-table .t-subtitle { font-size: 11px; color: var(--text-muted); }
.status-pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.status-pill.open        { background: #e0f2fe; color: #0369a1; }
.status-pill.in_progress { background: var(--brand-soft); color: var(--brand); }
.status-pill.done        { background: #d1fae5; color: #065f46; }
.status-pill.rejected    { background: #fee2e2; color: #991b1b; }

/* --- Empty state --- */
.empty { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty .material-symbols-outlined { font-size: 48px; color: var(--border-strong); }
.empty h3 { color: var(--dark); margin: 10px 0 4px; }

/* --- Modal --- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(40,40,43,.5); z-index: 60; display: grid; place-items: center; padding: 20px; animation: fade .15s; }
.modal { background: #fff; border-radius: var(--radius); max-width: 520px; width: 100%; max-height: 90vh; overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
.modal-header h2 { margin: 0; font-size: 16px; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; max-height: calc(90vh - 140px); }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* --- Portal page (public) --- */
.portal-page { min-height: 100vh; background: linear-gradient(180deg, var(--bg-soft), #fff 80%); }
.portal-hero { background: var(--dark); color: #fff; padding: 32px 24px; }
.portal-hero .wrap { max-width: 960px; margin: 0 auto; display: flex; align-items: center; gap: 20px; }
.portal-hero img { height: 36px; }
.portal-hero h1 { margin: 16px 0 6px; font-size: 28px; font-weight: 800; }
.portal-hero p { margin: 0; opacity: .75; max-width: 620px; }
.portal-container { max-width: 960px; margin: -20px auto 40px; padding: 0 24px; }
.portal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin-top: 20px; }
.portal-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; cursor: pointer; transition: all .15s; text-align: left; }
.portal-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--brand); }
.portal-card .icon-wrap { width: 44px; height: 44px; background: var(--brand-gradient); color: #fff; border-radius: var(--radius-sm); display: grid; place-items: center; margin-bottom: 12px; }
.portal-card .icon-wrap .material-symbols-outlined { font-size: 24px; }
.portal-card h3 { margin: 0 0 6px; font-size: 15px; color: var(--dark); }
.portal-card p { margin: 0; font-size: 13px; color: var(--text-muted); line-height: 1.4; }
.portal-form-wrap { max-width: 640px; margin: 24px auto; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; }
.portal-form-wrap h2 { margin: 0 0 6px; }
.portal-form-wrap .intro { color: var(--text-muted); margin-bottom: 20px; line-height: 1.5; }
.portal-form-wrap .field-row { grid-template-columns: 1fr; }
.portal-form-wrap .field-row label { padding: 0 0 4px; }
.portal-success { background: #f0fdf4; border: 1px solid #86efac; color: #065f46; border-radius: var(--radius); padding: 24px; text-align: center; }
.portal-success .material-symbols-outlined { font-size: 48px; color: var(--success); }

/* --- Utility --- */
.spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }
.scroll-y { overflow-y: auto; }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--warm-gray); }

/* ── Mobile sidebar (hamburger) ─────────────────────────── */
.menu-btn { display: none; }
.sidebar-overlay { display: none; }
/* touch-action:none lets JS own all touch events on cards,
   preventing browser from stealing scroll during drag */
.card { touch-action: none; }

/* Responsive mobile */
@media (max-width: 768px) {
  /* Layout: single-column, no sidebar gutter */
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: var(--header-h) 1fr;
    grid-template-areas: "header" "main";
  }

  /* Sidebar: fixed panel, slides in from left */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    z-index: 200;
    transform: translateX(-110%);
    transition: transform 0.25s ease;
    box-shadow: 6px 0 24px rgba(0,0,0,.25);
    overflow-y: auto;
  }
  .sidebar.mobile-open { transform: translateX(0); }

  /* Overlay dimming the rest of the screen */
  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(10,10,12,.45);
    z-index: 199;
  }

  /* Hamburger button: shown only on mobile */
  .menu-btn { display: flex !important; margin-right: 4px; }

  /* Drawer */
  .drawer { width: 100vw; }

  /* Tasks view */
  .tasks-view .stats { grid-template-columns: repeat(2, 1fr); }
  .tasks-view .tasks-table .row { grid-template-columns: 1fr; gap: 4px; }

  /* Kanban: one column fills ~88vw, snap-scroll between columns */
  .kanban { padding: 10px 8px; gap: 10px; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; }
  .column { flex: 0 0 44vw; scroll-snap-align: start; }

  /* Compact toolbar */
  .toolbar { padding: 10px 14px; flex-wrap: wrap; gap: 8px; }
  .toolbar h1 { font-size: 15px; }
  .toolbar .breadcrumb { font-size: 12px; }
  .toolbar .btn.ghost { display: none; }

  /* Touch-friendly targets */
  .card { padding: 14px 12px; }
  .btn { min-height: 40px; }
  .icon-btn { min-width: 40px; min-height: 40px; }

  /* Hide search bar */
  .header .search { display: none; }
}

/* ============================================================
   v0.2 — Login, mention, notifiche, profilo, allegati
   ============================================================ */

/* --- Login screen --- */
.app-loading { min-height: 100vh; display: grid; place-items: center; color: var(--text-muted); gap: 10px; }
.login-page {
  min-height: 100vh; display: grid; place-items: center;
  background: radial-gradient(circle at 20% 20%, rgba(239,82,35,.12), transparent 40%),
              radial-gradient(circle at 80% 60%, rgba(40,40,43,.08), transparent 40%),
              var(--bg);
  padding: 24px;
}
.login-card {
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 32px; width: 100%; max-width: 400px;
  display: flex; flex-direction: column; gap: 10px;
}
.login-logo { height: 36px; align-self: flex-start; margin-bottom: 8px; }
.login-card h1 { margin: 0; color: var(--dark); }
.login-card .sub { color: var(--text-muted); margin: 0 0 10px; }
.login-card label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; }
.login-card input {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: 14px; font-family: inherit; outline: none;
}
.login-card input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.login-error {
  background: #fde7e3; color: #a03018; padding: 10px 12px;
  border-radius: var(--radius-sm); font-size: 13px;
}
.login-btn { margin-top: 8px; padding: 12px; font-size: 15px; }
.login-footer { text-align: center; margin-top: 10px; font-size: 12px; color: var(--text-muted); }

/* --- Avatar con foto --- */
.avatar.has-photo { padding: 0; overflow: hidden; }
.avatar.has-photo img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.avatar.sm { width: 22px; height: 22px; font-size: 10px; }
.avatar.xl { width: 72px; height: 72px; font-size: 24px; border-radius: 50%; }

/* --- User button header --- */
.user-button {
  background: none; border: 1px solid transparent; cursor: pointer;
  padding: 4px 10px; border-radius: var(--radius); display: flex; align-items: center; gap: 8px;
  transition: background .12s;
}
.user-button:hover { background: var(--bg); border-color: var(--border); }

/* --- Notifiche --- */
.notif-dot {
  position: absolute; top: 2px; right: 2px;
  background: var(--brand); color: #fff;
  font-size: 10px; font-weight: 800; border-radius: 999px;
  min-width: 16px; height: 16px; padding: 0 4px;
  display: grid; place-items: center; line-height: 1;
}
.notif-backdrop { position: fixed; inset: 0; z-index: 90; }
.notif-panel {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 360px; max-width: calc(100vw - 16px);
  max-height: 70vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 100;
}

/* Mobile: pannello fisso sotto l'header, larghezza piena */
@media (max-width: 768px) {
  .notif-panel {
    position: fixed;
    top: var(--header-h);
    right: 10px;
    left: 10px;
    width: auto;
    max-height: 65vh;
    border-radius: var(--radius-lg);
  }
  .notif-backdrop { z-index: 150; }
  .notif-panel { z-index: 151; }
}
.notif-head { padding: 12px 14px; font-weight: 800; border-bottom: 1px solid var(--border); }
.notif-empty { padding: 30px; text-align: center; color: var(--text-muted); font-size: 13px; }
.notif-item {
  display: grid; grid-template-columns: 28px 1fr; gap: 10px;
  padding: 12px 14px; cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.notif-item:hover { background: var(--bg); }
.notif-item.unread { background: var(--brand-soft); }
.notif-item .notif-type .material-symbols-outlined { font-size: 22px; color: var(--brand); }
.notif-title { font-weight: 600; font-size: 13px; color: var(--dark); }
.notif-body  { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.notif-when  { font-size: 11px; color: var(--warm-gray); margin-top: 4px; }

/* --- Mention popup --- */
.mention-pop {
  position: absolute; z-index: 1000;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  min-width: 220px; max-height: 220px; overflow-y: auto; padding: 4px;
}
.mention-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: var(--radius-sm); cursor: pointer;
}
.mention-item:hover, .mention-item.active { background: var(--brand-soft); }
.mention-item .m-name { font-weight: 600; font-size: 13px; color: var(--dark); }
.mention-item .m-user { font-size: 11px; color: var(--text-muted); }
.mention-tag {
  background: var(--brand-soft); color: var(--brand);
  padding: 0 4px; border-radius: 4px; font-weight: 700;
}

/* --- Assignees multi-select --- */
.assignees-select { position: relative; }
.assignees-select .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.chip-user {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 999px; padding: 2px 8px 2px 2px; font-size: 12px;
}
.chip-user button {
  background: none; border: none; cursor: pointer; font-size: 16px; line-height: 1;
  color: var(--text-muted); padding: 0 4px;
}
.chip-user button:hover { color: var(--danger); }
.assignees-dropdown {
  position: absolute; z-index: 30; top: 100%; left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  max-height: 200px; overflow-y: auto; padding: 4px;
}
.assignees-dropdown .a-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px;
}
.assignees-dropdown .a-item:hover { background: var(--brand-soft); }
.assignees-dropdown .a-item .m-user { margin-left: auto; color: var(--text-muted); font-size: 11px; }

/* --- Attachment list --- */
.att-list {
  list-style: none; padding: 0; margin: 8px 0 0;
  display: flex; flex-direction: column; gap: 6px;
}
.att-list li {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); padding: 6px 10px;
  border-radius: var(--radius-sm); font-size: 13px;
}
.att-list li .sz { margin-left: auto; color: var(--text-muted); font-size: 11px; }
.att-list li button {
  background: none; border: none; cursor: pointer; color: var(--text-muted);
  font-size: 16px; padding: 0 4px;
}
.att-list li button:hover { color: var(--danger); }
.att-list.linked a { color: var(--dark); text-decoration: none; font-weight: 500; }
.att-list.linked a:hover { color: var(--brand); text-decoration: underline; }

/* --- Profile modal --- */
.profile-top {
  display: flex; align-items: center; gap: 14px;
  padding-bottom: 10px; margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.profile-top .avatar.xl { border-radius: 50%; box-shadow: var(--shadow); }

/* --- Portal topbar (back button sticky) --- */
.portal-topbar {
  position: sticky; top: 0; z-index: 10;
  background: rgba(255,255,255,.96); backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 10px 24px; display: flex; align-items: center; gap: 10px;
}
.portal-back { margin-top: 14px; }

/* --- Btn small helper --- */
.btn.small { padding: 4px 10px; font-size: 12px; }

/* --- Sidebar: hover workspace --- */
.sidebar .ws-header:hover { color: #fff; opacity: .95; }


/* ============================================================
   v1.0 M3 — Pannello stato lavoro (CardDrawer)
   ============================================================ */
.work-panel { background: var(--bg-subtle, #f7f7f8); border: 1px solid var(--border, #e5e5e8); border-radius: 12px; padding: 14px 16px; margin-bottom: 8px; }
.work-status-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 700; letter-spacing: .2px; }
.status-pill.ready       { background: #ececef; color: #55555e; }
.status-pill.in_progress { background: #e1efff; color: #1565c0; }
.status-pill.waiting     { background: #fff4d6; color: #9a6b00; }
.status-pill.blocked     { background: #ffe1de; color: #c62828; }
.status-pill.review      { background: #efe1ff; color: #6a2fb8; }
.status-pill.done        { background: #ddf5e2; color: #1b7f3b; }
.status-pill.cancelled   { background: #e5e5e8; color: #777; text-decoration: line-through; }
.work-times { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-muted, #77777f); margin-bottom: 10px; }
.work-times b { color: var(--text, #26262b); font-weight: 600; }
.work-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.work-actions .btn { font-size: 12.5px; }
.btn.success { background: #1b7f3b; color: #fff; border: none; }
.btn.success:hover { background: #16692f; }
.btn.danger-soft { background: #ffe1de; color: #c62828; border: none; }
.btn.danger-soft:hover { background: #ffcfc9; }
.btn.warn-soft { background: #fff4d6; color: #9a6b00; border: none; }
.progress-quick { display: flex; gap: 6px; margin-top: 10px; align-items: center; }
.progress-quick span.lbl { font-size: 12px; color: var(--text-muted, #77777f); }
.chip-btn { border: 1px solid var(--border, #ddd); background: #fff; border-radius: 999px; padding: 3px 10px; font-size: 12px; cursor: pointer; }
.chip-btn:hover { border-color: #ef5223; color: #ef5223; }
.chip-btn.active { background: #ef5223; color: #fff; border-color: #ef5223; }
.block-form { margin-top: 10px; padding: 10px; background: #fff; border: 1px solid var(--border, #e5e5e8); border-radius: 10px; }
.block-form textarea, .block-form select { width: 100%; margin-top: 6px; }
.blocker-item, .decision-item { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border-radius: 8px; margin-top: 6px; font-size: 13px; background: #fff; border: 1px solid var(--border, #e5e5e8); }
.blocker-item.open   { border-left: 4px solid #c62828; }
.blocker-item.closed { border-left: 4px solid #1b7f3b; opacity: .75; }
.decision-item.open  { border-left: 4px solid #6a2fb8; }
.decision-item.closed{ border-left: 4px solid #1b7f3b; opacity: .75; }
.delay-cause-box { margin-top: 10px; padding: 12px; background: #fff8e6; border: 1px solid #ffd76b; border-radius: 10px; }
.delay-cause-box .opts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

/* ============================================================
   v1.0 M9 — Statistiche (spec §19)
   ============================================================ */
.stats-page { padding: 24px 28px; max-width: 1320px; }
.stats-h { font-size: 22px; font-weight: 800; margin-bottom: 18px; }
.stats-sh { font-size: 15px; font-weight: 700; margin: 26px 0 10px; }
.stats-dim { color: var(--text-muted, #77777f); font-size: 12.5px; }
.stat-row { display: flex; gap: 14px; flex-wrap: wrap; }
.stat-tile { background: var(--bg-subtle, #f7f7f8); border: 1px solid var(--border, #e5e5e8);
             border-radius: 14px; padding: 14px 20px; min-width: 130px; }
.stat-value { font-size: 30px; font-weight: 800; line-height: 1.1; }
.stat-label { font-size: 12px; color: var(--text-muted, #77777f); margin-top: 4px; }
.stats-line { display: flex; gap: 12px; align-items: center; padding: 8px 12px; border-radius: 8px;
              background: var(--bg-subtle, #f7f7f8); border: 1px solid var(--border, #e5e5e8); margin-top: 6px; font-size: 13.5px; }
.stats-line.risk { border-left: 4px solid #FFC300; }
.risk-tag { background: #fff4d6; color: #9a6b00; font-size: 12px; font-weight: 700; border-radius: 999px; padding: 3px 10px; }
.risk-tag.due { background: #ffe1de; color: #c62828; }
.team-table { border: 1px solid var(--border, #e5e5e8); border-radius: 12px; overflow: hidden; }
.tt-row { display: grid; grid-template-columns: 1.5fr .55fr .6fr .65fr 1fr .75fr .7fr .75fr 1.2fr 1.2fr;
          gap: 8px; align-items: center; padding: 10px 14px; font-size: 13px; border-top: 1px solid var(--border, #eee); }
.tt-row:first-child { border-top: none; }
.tt-head { background: var(--bg-subtle, #f7f7f8); font-weight: 700; font-size: 12px; color: var(--text-muted, #77777f); }
.tt-name { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.tt-bar-cell { display: flex; align-items: center; gap: 8px; }
.tt-bar { display: inline-block; height: 8px; border-radius: 4px; background: #ef5223; min-width: 2px; }

/* ============================================================
   v1.0 M5 — Assistente AI
   ============================================================ */
.ai-btn { display: inline-flex; align-items: center; gap: 6px; border: none; cursor: pointer;
          color: #fff; font-weight: 700; font-size: 13px; border-radius: 999px; padding: 7px 16px; }
.ai-btn:hover { filter: brightness(1.08); }
/* Due AI (owner 2026-07-26): Tecnico = arancione (prodotto esterno) · Interno = celeste (privato) */
.ai-btn.tecnico { background: linear-gradient(135deg, #ef5223, #ff8a50); }
.ai-btn.interno { background: linear-gradient(135deg, #29b6f6, #64d2ff); }
.ai-modal { max-width: 640px; width: 92vw; display: flex; flex-direction: column; }
.ai-log { min-height: 260px; max-height: 50vh; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.ai-hint { color: var(--text-muted, #77777f); font-size: 13.5px; padding: 18px; text-align: center; }
.ai-msg { max-width: 85%; padding: 10px 14px; border-radius: 14px; font-size: 13.5px; white-space: normal; }
.ai-msg.me { align-self: flex-end; background: #ef5223; color: #fff; border-bottom-right-radius: 4px; }
.ai-msg.ai { align-self: flex-start; background: var(--bg-subtle, #f2f2f4); border-bottom-left-radius: 4px; }
.ai-input { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border, #e5e5e8); }
.ai-input textarea { flex: 1; resize: none; border: 1px solid var(--border, #ddd); border-radius: 10px; padding: 10px; font-size: 13.5px; }

/* ============================================================
   v1.0 M7.2 — Pagina Second Brain
   ============================================================ */
.brain-page { display: flex; gap: 20px; padding: 22px 26px; height: 100%; overflow: hidden; }
.brain-left { flex: 1.4; display: flex; flex-direction: column; min-width: 0; }
.brain-chat { flex: 1; display: flex; flex-direction: column; background: var(--surface, #fff);
              border: 1px solid var(--border, #e5e5e8); border-radius: 14px; overflow: hidden; }
.brain-right { flex: 1; overflow-y: auto; min-width: 300px; max-width: 460px; }
.brain-box { background: var(--surface, #fff); border: 1px solid var(--border, #e5e5e8);
             border-radius: 14px; padding: 14px 16px; margin-bottom: 16px; }
.brain-doclist { margin-top: 8px; max-height: 55vh; overflow-y: auto; }
.brain-doc { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.brain-doc:hover { background: var(--bg, #f5f5f5); }
.brain-doc-title { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brain-reader { white-space: pre-wrap; font-family: Consolas, monospace; font-size: 12.5px;
                background: var(--bg-soft, #fafafa); border-radius: 10px; padding: 14px; max-height: 60vh; overflow-y: auto; }
.brain-draft { border-left: 4px solid #FFC300; background: var(--bg-soft, #fafafa);
               border-radius: 8px; padding: 10px 12px; margin-top: 8px; font-size: 13px; }
.brain-draft-content { color: var(--text-muted, #6b7280); font-size: 12px; margin-top: 4px; white-space: pre-wrap; }

/* M7.4 — selettore modello chat */
.ai-engine-bar { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--border, #e5e5e8); }
.ai-engine-bar select { border: 1px solid var(--border, #ddd); border-radius: 8px; padding: 4px 8px; font-size: 12.5px; }

/* M7.5 — segnalazione risposta AI */
.ai-flag { border: none; background: transparent; color: #999; font-size: 11.5px; cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.ai-flag:hover { background: #ffe1de; color: #c62828; }
