/* Nexotime web: layout a barra laterale, schede bianche su fondo grigio chiaro. */
:root {
  --bg: #f2f6f8;
  --card: #ffffff;
  --border: #c6d2d9;
  --line: #e4eaee;
  --text: #333333;
  --muted: #8a9aa5;
  --blue: #03a9f4;
  --blue-dark: #0288d1;
  --blue-soft: #e1f5fe;
  --red: #f44336;
  --red-dark: #d32f2f;
  --day: #e4eaee;
  --radius: 2px;
  --sidebar: 220px;
  --topbar: 56px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
[hidden] { display: none !important; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
input, select, button { font: inherit; color: inherit; }
input, select {
  border: 1px solid var(--border); border-radius: var(--radius); background: #fff;
  padding: 7px 10px; outline: none; min-width: 0;
}
input:focus, select:focus { border-color: var(--blue); }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

/* Pulsanti */
.btn {
  border: 1px solid var(--border); background: #fff; border-radius: var(--radius);
  padding: 8px 16px; cursor: pointer; white-space: nowrap; font-weight: 500;
}
.btn:hover { background: #f7f9fa; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-dark); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger:hover { background: var(--red-dark); }
.btn.link { border: none; background: none; color: var(--blue); padding: 8px 6px; }
.btn.link.red { color: var(--red); }
.btn.block { display: block; width: 100%; }
.icon {
  border: none; background: none; cursor: pointer; padding: 6px; border-radius: var(--radius);
  color: var(--muted); display: inline-flex; align-items: center; justify-content: center;
}
.icon:hover { color: var(--text); background: var(--bg); }

/* Barra in alto e laterale */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--topbar); background: #fff;
  border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; padding: 0 12px; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 600; letter-spacing: .2px; }
.brand.big { font-size: 24px; justify-content: center; margin-bottom: 12px; }
.logo {
  width: 28px; height: 28px; border-radius: 6px; background: var(--blue); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px;
}
.big .logo { width: 36px; height: 36px; font-size: 20px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.running-pill {
  background: var(--blue-soft); color: var(--blue-dark); border-radius: 14px; padding: 4px 12px;
  font-weight: 600; cursor: pointer; max-width: 50vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.menu-toggle { display: none; }
.sidebar {
  position: fixed; top: var(--topbar); bottom: 0; left: 0; width: var(--sidebar); background: #fff;
  border-right: 1px solid var(--border); padding: 8px 0; z-index: 15; overflow-y: auto;
}
.sidebar a {
  display: flex; align-items: center; gap: 14px; padding: 11px 20px; color: #555; text-decoration: none;
  border-left: 3px solid transparent;
}
.sidebar a:hover { background: var(--bg); }
.sidebar a.active { background: var(--blue-soft); color: var(--blue-dark); border-left-color: var(--blue); font-weight: 600; }
.nav-label { padding: 18px 20px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.main { margin: var(--topbar) 0 0 var(--sidebar); padding: 24px 28px 60px; max-width: calc(1240px + var(--sidebar)); }
.page-title { display: flex; align-items: center; gap: 12px; margin: 0 0 18px; }
.page-title h1 { font-size: 22px; font-weight: 400; margin: 0; }
.page-title .spacer { flex: 1; }

/* Schede */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }

/* Barra del timer */
.timerbar { display: flex; align-items: center; min-height: 66px; padding: 0 0 0 16px; margin-bottom: 26px; gap: 4px; }
.timerbar .tb-desc { flex: 1; border: none; font-size: 15px; padding: 10px 4px; }
.proj-pick {
  border: none; background: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 10px; border-radius: var(--radius); max-width: 300px; white-space: nowrap; overflow: hidden;
}
.proj-pick:hover { background: var(--bg); }
.proj-pick .plus { color: var(--blue); display: inline-flex; align-items: center; gap: 6px; }
.proj-pick .name { overflow: hidden; text-overflow: ellipsis; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.vsep { width: 1px; align-self: stretch; margin: 14px 4px; border-left: 1px dotted var(--border); }
.tb-cost { color: var(--muted); min-width: 80px; text-align: right; padding: 0 8px; }
.tb-time { font-size: 18px; font-weight: 600; min-width: 96px; text-align: center; font-variant-numeric: tabular-nums; }
.timerbar .btn.go { min-width: 96px; margin: 0 12px; padding: 10px 16px; letter-spacing: .5px; }
.tb-manual { display: flex; align-items: center; gap: 6px; }
.tb-manual input { padding: 6px 6px; }
.tb-manual input[type=time] { width: 92px; }
.tb-manual input[type=date] { width: 140px; }
.modes { display: flex; flex-direction: column; border-left: 1px solid var(--line); align-self: stretch; }
.modes button { flex: 1; border: none; background: none; cursor: pointer; color: var(--border); padding: 0 10px; }
.modes button.on { color: var(--blue); }
.modes svg { width: 17px; height: 17px; }

/* Elenco voci */
.week-head { display: flex; justify-content: space-between; align-items: baseline; margin: 22px 0 8px; color: #666; }
.week-head b { color: var(--text); font-size: 16px; }
.day { margin-bottom: 14px; }
.day-head {
  display: flex; justify-content: space-between; align-items: center; background: var(--day);
  padding: 9px 16px; color: #666; border-bottom: 1px solid var(--border);
}
.day-head b { color: var(--text); font-weight: 600; }
.entry {
  display: flex; align-items: center; gap: 10px; padding: 10px 8px 10px 16px; border-bottom: 1px solid var(--line);
  cursor: pointer; min-height: 56px;
}
.entry:last-child { border-bottom: none; }
.entry:hover { background: #fafcfd; }
.entry.running { background: var(--blue-soft); }
.e-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.e-desc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.e-proj { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.e-cost { color: var(--muted); min-width: 84px; text-align: right; }
.e-range { color: #666; min-width: 120px; text-align: center; padding: 0 8px; border-left: 1px dotted var(--border); border-right: 1px dotted var(--border); }
.e-dur { font-weight: 600; min-width: 80px; text-align: center; font-variant-numeric: tabular-nums; }
.cost-sep:not(:empty)::before { content: " · "; color: var(--muted); font-weight: 400; }
.cost-sep { font-weight: 400; color: #666; }
.load-more { display: block; margin: 20px auto; }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty svg { width: 46px; height: 46px; stroke-width: 1.2; color: var(--border); }

/* Tabelle (progetti, clienti, report) */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-weight: 500; color: #666; background: var(--day); padding: 10px 14px;
  border-bottom: 1px solid var(--border); font-size: 13px; white-space: nowrap;
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: #fafcfd; }
.table .r { text-align: right; }
.table tfoot td { font-weight: 600; background: #fafcfd; border-top: 1px solid var(--border); }
.archived td { color: var(--muted); }
.toolbar { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.toolbar input[type=search] { flex: 1; min-width: 160px; }
.tag { font-size: 11px; background: var(--day); color: #666; border-radius: 10px; padding: 2px 8px; margin-left: 6px; }
.rate-src { font-size: 12px; color: var(--muted); }

/* Report */
.filters { display: flex; gap: 10px; align-items: center; padding: 12px 14px; flex-wrap: wrap; margin-bottom: 16px; }
.filters .range { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.filters .range-label { min-width: 170px; text-align: center; font-weight: 500; }
.summary { display: flex; gap: 0; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.summary > div { padding: 14px 20px; border-right: 1px solid var(--line); }
.summary .lbl { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .6px; }
.summary .val { font-size: 22px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.summary .actions { margin-left: auto; border-right: none; display: flex; gap: 8px; align-items: center; }
.chart { padding: 18px 16px 8px; }
.chart svg { width: 100%; height: auto; stroke: none; display: block; }
.chart text { fill: #888; font-size: 11px; }
.report-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; margin-top: 16px; }
.donut { display: flex; flex-direction: column; align-items: center; padding: 20px; }
.donut svg { width: 200px; height: 200px; stroke: none; }
.legend { width: 100%; margin-top: 14px; }
.legend div { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.legend .pct { margin-left: auto; color: var(--muted); }
.bar-cell { width: 120px; }
.pbar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.pbar i { display: block; height: 100%; }
.section-title { font-size: 15px; font-weight: 600; padding: 12px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }

/* Impostazioni */
.settings .card { padding: 20px; margin-bottom: 16px; max-width: 620px; }
.settings h2 { font-size: 16px; margin: 0 0 4px; }
.settings p { margin: 0 0 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* Finestre, menu, avvisi */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px; z-index: 50; }
.modal { background: #fff; width: 100%; max-width: 520px; border-radius: 3px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal header h2 { font-size: 18px; font-weight: 400; margin: 0; }
.modal .body { padding: 18px 20px; display: grid; gap: 14px; }
.modal footer { display: flex; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
.modal footer .spacer { flex: 1; }
label { display: grid; gap: 6px; color: #666; font-size: 13px; }
label input, label select { color: var(--text); font-size: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 12px; }
.hint { font-size: 12px; color: var(--muted); }
.colors { display: flex; gap: 8px; flex-wrap: wrap; }
.colors button { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border); cursor: pointer; }
.colors button.on { box-shadow: 0 0 0 2px var(--text); }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
.popover {
  position: absolute; z-index: 60; background: #fff; border: 1px solid var(--border); border-radius: 3px;
  box-shadow: 0 6px 24px rgba(0,0,0,.15); min-width: 220px; max-width: 340px;
}
.popover input { margin: 10px; width: calc(100% - 20px); }
.popover .list { max-height: 300px; overflow-y: auto; padding-bottom: 6px; }
.popover .grp { padding: 8px 14px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.popover .opt { display: flex; align-items: center; gap: 8px; padding: 8px 14px; cursor: pointer; white-space: nowrap; }
.popover .opt:hover, .popover .opt.on { background: var(--bg); }
.popover .opt.add { color: var(--blue); border-top: 1px solid var(--line); }
.popover .opt.red { color: var(--red); }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #333; color: #fff;
  padding: 10px 18px; border-radius: 3px; z-index: 80; box-shadow: 0 4px 16px rgba(0,0,0,.25);
}
.toast.err { background: var(--red-dark); }
.alert { background: #fdecea; color: #b71c1c; border-radius: 3px; padding: 10px 12px; font-size: 13px; }

/* Accesso e installazione */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { background: #fff; border: 1px solid var(--border); border-radius: 3px; padding: 30px; width: 100%; max-width: 420px; display: grid; gap: 14px; }
.auth-card h1 { font-size: 20px; font-weight: 400; margin: 0; text-align: center; }
.auth-card p { margin: 0; }
.auth-card hr { border: none; border-top: 1px solid var(--line); margin: 4px 0; width: 100%; }

/* Telefono e tablet */
@media (max-width: 860px) {
  .menu-toggle { display: inline-flex; }
  .sidebar { transform: translateX(-100%); transition: transform .2s; box-shadow: 4px 0 20px rgba(0,0,0,.1); }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; padding: 16px 12px 60px; }
  .timerbar { flex-wrap: wrap; padding: 8px 0 8px 12px; }
  .timerbar .tb-desc { flex-basis: 100%; }
  .modes { flex-direction: row; border-left: none; align-self: center; }
  .modes button { padding: 8px; }
  .e-range, .e-cost { display: none; }
  .report-grid { grid-template-columns: 1fr; }
  .filters .range { margin-left: 0; width: 100%; justify-content: space-between; }
  .hide-sm { display: none; }
  .grid3 { grid-template-columns: 1fr 1fr; }
  .grid3 > :first-child { grid-column: 1 / -1; }
}

/* Stampa / PDF dei report */
@media print {
  body { background: #fff; }
  .topbar, .sidebar, .filters .range button, .summary .actions, .no-print { display: none !important; }
  .main { margin: 0; padding: 0; max-width: none; }
  .card { border-color: #ddd; break-inside: avoid; }
  .report-grid { grid-template-columns: 1fr 260px; }
}
