/* fix: l'attributo hidden deve sempre vincere su display:flex della modale */
[hidden] { display: none !important; }

:root {
  --bg: #0f1115;
  --bg-soft: #161a20;
  --panel: #1b1f27;
  --border: #262c36;
  --text: #e8eaed;
  --dim: #9aa3af;
  --faint: #5f6875;
  --accent: #dc4c3e;
  --accent-soft: rgba(220, 76, 62, 0.15);
  --green: #33b679;
  --blue: #4c9aff;
  --yellow: #e0a83d;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.app { max-width: 1080px; margin: 0 auto; padding: 0 16px 80px; }

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 0 14px;
  position: sticky; top: 0; background: var(--bg); z-index: 10;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.brand-name { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.topbar-right { display: flex; flex-direction: column; align-items: flex-end; }
.clock { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.date { font-size: 12px; color: var(--dim); }

/* Tabs */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab {
  background: none; border: none; color: var(--dim); font-size: 14px; font-weight: 600;
  padding: 10px 16px; cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: color .15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

/* Views */
.view { display: none; }
.view.active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.view-head { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.view-head h2 { font-size: 20px; font-weight: 700; }

/* Grid oggi */
.grid-today { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 720px) { .grid-today { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px;
}
.panel-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--faint); margin-bottom: 12px;
}
.weather-panel { grid-column: 1 / -1; }

/* Meteo */
.weather-now { display: flex; align-items: baseline; gap: 14px; margin-bottom: 14px; }
.w-temp { font-size: 44px; font-weight: 700; letter-spacing: -0.02em; }
.w-meta { color: var(--dim); font-size: 14px; }
.weather-week { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.w-day {
  flex: 1; min-width: 64px; text-align: center; padding: 10px 6px;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px;
}
.w-day .d { font-size: 11px; color: var(--dim); margin-bottom: 4px; }
.w-day .i { font-size: 20px; }
.w-day .t { font-size: 12px; margin-top: 4px; font-weight: 600; }
.w-day .p { font-size: 10px; color: var(--blue); margin-top: 2px; }

/* Liste generiche */
.list { display: flex; flex-direction: column; gap: 8px; }
.list .empty { color: var(--faint); font-size: 13px; padding: 8px 0; }
.list-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px;
  font-size: 13px; cursor: default;
}
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .sub { color: var(--dim); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .when { color: var(--dim); font-size: 12px; white-space: nowrap; }
.badge { padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge.cal { background: var(--accent-soft); color: var(--accent); }
.badge.unread { background: var(--blue); color: #fff; }
.badge.p1 { background: var(--accent); color: #fff; }
.badge.p2 { background: var(--yellow); color: #1a1a1a; }
.badge.p3 { background: var(--blue); color: #fff; }
.badge.p4 { background: var(--border); color: var(--dim); }

/* Email */
.mail-list { display: flex; flex-direction: column; gap: 6px; }
.mail-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  cursor: pointer; transition: border-color .15s;
}
.mail-row:hover { border-color: var(--accent); }
.mail-row.unread { border-left: 3px solid var(--blue); }
.mail-row .from { font-weight: 600; font-size: 13px; width: 180px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-row .subject { flex: 1; min-width: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-row .date { color: var(--dim); font-size: 12px; flex-shrink: 0; }
.mail-row .actions { display: flex; gap: 6px; }
@media (max-width: 720px) { .mail-row .from { width: 110px; } }

/* Todo */
.quick-add-row { display: flex; gap: 8px; }
.quick-add-row input { flex: 1; }
.todo-sections { display: flex; flex-direction: column; gap: 18px; }
.todo-group-title { font-size: 13px; font-weight: 700; color: var(--dim); margin-bottom: 8px; }
.todo-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; font-size: 13px;
}
.todo-item.done .title { text-decoration: line-through; color: var(--faint); }
.todo-item .check {
  width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--border);
  cursor: pointer; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: transparent; transition: all .15s;
}
.todo-item.done .check { background: var(--green); border-color: var(--green); color: #fff; }
.todo-item .grow { flex: 1; min-width: 0; }
.todo-item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.todo-item .sub { color: var(--dim); font-size: 12px; }

/* Calendario */
.cal-scope { display: flex; gap: 6px; margin-bottom: 12px; overflow-x: auto; padding-bottom: 4px; }
.chip {
  padding: 6px 12px; border-radius: 20px; background: var(--panel); border: 1px solid var(--border);
  color: var(--dim); font-size: 12px; cursor: pointer; white-space: nowrap;
}
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.cal-list { display: flex; flex-direction: column; gap: 8px; }
.cal-day-head { font-size: 13px; font-weight: 700; color: var(--dim); margin: 14px 0 8px; }
.cal-event {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; font-size: 13px;
}
.cal-event .time { color: var(--accent); font-size: 12px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cal-event .grow { flex: 1; min-width: 0; }
.cal-event .title { font-weight: 600; }
.cal-event .loc { color: var(--dim); font-size: 12px; }

/* Bottoni / input */
.btn {
  border: none; border-radius: 10px; padding: 9px 16px; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: opacity .15s;
}
.btn:hover { opacity: .85; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: var(--bg-soft); color: var(--text); border: 1px solid var(--border); }
.btn.mini { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
input[type="text"], textarea {
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); padding: 10px 12px; font-size: 13px; font-family: inherit;
  width: 100%; resize: vertical;
}
input[type="text"]:focus, textarea:focus { outline: none; border-color: var(--accent); }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal {
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  padding: 20px; width: 100%; max-width: 520px; display: flex; flex-direction: column; gap: 10px;
}
.modal h3 { font-size: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #fff; padding: 12px 20px; border-radius: 10px;
  font-size: 13px; font-weight: 600; z-index: 200; box-shadow: 0 4px 20px rgba(0,0,0,.4);
  animation: toastIn .25s ease;
}
.toast.error { background: #b32d2d; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

.loading { color: var(--faint); font-size: 13px; padding: 12px 0; }
