/* ============================================================
   TH3G Dashboard — Stylesheet
   Stile: AGICAP / SaaS moderno, palette azzurra
   ============================================================ */

:root {
  /* Backgrounds & surfaces — bianco puro (allineato al logo) */
  --bg:              #ffffff;
  --surface:         #ffffff;
  --panel-bg:        #f8fafc;   /* pannelli dashboard: bianco leggermente scuro */
  --surface-2:       #f1f5f9;
  --surface-hover:   #eef2f7;

  /* Borders */
  --border:          #e5e9ef;
  --border-strong:   #cbd2dc;

  /* Text — slate */
  --text:            #0f172a;
  --text-soft:       #334155;
  --text-muted:      #64748b;
  --text-subtle:     #94a3b8;

  /* Accent — AGICAP blue */
  --accent:          #2563eb;
  --accent-hover:    #1d4ed8;
  --accent-light:    #3b82f6;
  --accent-soft:     rgba(37, 99, 235, 0.10);
  --accent-softer:   rgba(37, 99, 235, 0.05);

  /* Semantici */
  --success:         #10b981;
  --danger:          #dc2626;
  --warning:         #f59e0b;

  /* Sidebar — deep navy */
  --sidebar-bg:      #0f172a;
  --sidebar-fg:      #e2e8f0;
  --sidebar-muted:   rgba(226, 232, 240, 0.5);
  --sidebar-hover:   rgba(255, 255, 255, 0.04);
  --sidebar-active:  rgba(59, 130, 246, 0.15);
  --sidebar-border:  rgba(255, 255, 255, 0.08);

  /* Shadows */
  --shadow-sm:  0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md:  0 1px 3px rgba(15, 23, 42, 0.06), 0 4px 12px rgba(15, 23, 42, 0.04);
  --shadow-lg:  0 4px 16px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.04);

  /* Radii */
  --r-sm:  6px;
  --r-md:  8px;
  --r-lg:  12px;
  --r-xl:  16px;

  /* Font */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 400;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv02", "cv11", "ss01";
  letter-spacing: -0.005em;
  line-height: 1.5;
}

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

img { max-width: 100%; display: block; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.015em; color: var(--text); }

/* ============================================================
   LOGIN
   ============================================================ */
.page-login {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  position: relative;
}

.login-wrap {
  width: 100%;
  max-width: 400px;
  position: relative;
  z-index: 1;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 2.5rem 2.25rem;
  box-shadow: var(--shadow-md);
}

.login-title {
  font-size: 1.375rem;
  font-weight: 600;
  margin: 0 0 0.25rem;
}
.login-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0 0 2rem;
}

.field { display: block; margin-bottom: 1.25rem; }

.field-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-soft);
  margin-bottom: 0.4rem;
}

.field input {
  width: 100%;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  padding: 0.625rem 0.875rem;
  font-size: 0.9375rem;
  outline: none;
  border-radius: var(--r-md);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field-error {
  min-height: 1.2em;
  margin: -0.6rem 0 0.8rem;
  color: var(--danger);
  font-size: 0.8125rem;
}

.btn-primary {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.7rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--r-md);
  transition: background 0.15s, transform 0.05s;
  margin-top: 0.25rem;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }

/* Logo login — formato orizzontale, firma in basso a destra */
.login-signature {
  position: fixed;
  right: 1.75rem;
  bottom: 1.25rem;
  width: 180px;
  height: auto;
  opacity: 0.9;
  pointer-events: none;
  user-select: none;
}

@media (max-width: 640px) {
  .login-card { padding: 2rem 1.5rem; }
  .login-signature { width: 130px; right: 1rem; bottom: 1rem; }
}

/* ============================================================
   DASHBOARD LAYOUT
   ============================================================ */

.page-dashboard {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

/* ---- Sidebar ------------------------------------------------ */
.sidebar {
  width: 280px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  color: var(--sidebar-fg);
  transition: width .2s ease;
  position: relative;
  z-index: 20;
}

.sidebar-brand {
  padding: 1.25rem 1rem;
  background: #ffffff;
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* Bottone hamburger per collassare la sidebar */
.sidebar-toggle {
  flex-shrink: 0;
  width: 36px; height: 36px;
  border: 1px solid transparent;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
  border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s, border-color .12s;
}
.sidebar-toggle:hover {
  background: rgba(15, 23, 42, 0.05);
  color: var(--accent, #4f46e5);
  border-color: rgba(15, 23, 42, 0.08);
}
.sidebar-toggle svg { width: 20px; height: 20px; }

/* Button invisibile che rende il logo cliccabile (tasto Home) */
.sidebar-brand-btn {
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s ease, transform 0.1s ease;
  border-radius: 4px;
}
.sidebar-brand-btn:hover   { opacity: 0.85; }
.sidebar-brand-btn:active  { transform: scale(0.98); }
.sidebar-brand-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Logo sidebar — formato orizzontale, riempie in larghezza */
.sidebar-logo {
  width: 100%;
  max-width: 240px;
  max-height: 60px;
  height: auto;
  display: block;
  object-fit: contain;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0;
}

.nav-section-label {
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
  padding: 0 1.25rem;
  margin: 1rem 0 0.4rem;
}
.sidebar-nav > .nav-section-label:first-child { margin-top: 0.2rem; }

.nav-list { list-style: none; margin: 0; padding: 0 0.5rem; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0.55rem 0.75rem;
  font-size: 0.875rem;
  color: rgba(226, 232, 240, 0.82);
  cursor: pointer;
  border-radius: var(--r-md);
  transition: background 0.15s, color 0.15s;
  user-select: none;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
}
.nav-item:hover:not(.is-locked) {
  background: var(--sidebar-hover);
  color: #fff;
}
.nav-item.is-active {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 500;
}
.nav-item.is-locked { opacity: 0.38; cursor: not-allowed; }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nav-icon  { width: 20px; height: 20px; flex-shrink: 0; opacity: 0.9; }
.nav-item.is-active .nav-icon { opacity: 1; }
.ic-lock { width: 12px; height: 12px; opacity: 0.6; flex-shrink: 0; }

/* Badge rosso con counter (es. messaggi non letti) */
.nav-item { position: relative; }
.nav-badge {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: #dc2626;
  color: #fff;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 2px var(--sidebar-bg, #1f2937);
  flex-shrink: 0;
}
/* Sidebar stretta: il badge diventa un pallino rosso sopra l'icona */
html.sidebar-collapsed .nav-badge {
  position: absolute;
  top: 4px; right: 10px;
  min-width: 10px;
  width: 10px; height: 10px;
  padding: 0;
  font-size: 0;     /* nasconde il numero */
  border-radius: 50%;
  margin-left: 0;
}

/* ============================================================
   Sidebar COLLAPSED — solo icone, con hover-peek che espande
   ============================================================ */
html.sidebar-collapsed .sidebar { width: 72px; }

/* Con sidebar stretta il logo orizzontale non ha senso: lo nascondiamo
   e lasciamo solo il bottone hamburger centrato (come Gmail/Drive). */
html.sidebar-collapsed .sidebar-logo,
html.sidebar-collapsed .sidebar-brand-btn { display: none; }
html.sidebar-collapsed .sidebar-brand {
  padding: 1rem 0;
  justify-content: center;
}
html.sidebar-collapsed .nav-label,
html.sidebar-collapsed .nav-section-label,
html.sidebar-collapsed .ic-lock,
html.sidebar-collapsed .user-meta,
html.sidebar-collapsed .btn-logout { display: none; }
html.sidebar-collapsed .nav-list   { padding: 0 0.4rem; }
html.sidebar-collapsed .nav-item   {
  justify-content: center;
  padding: 0.6rem 0;
}
html.sidebar-collapsed .user-row   { justify-content: center; padding: 0.5rem 0; }
html.sidebar-collapsed .sidebar-footer { padding: 0.6rem; }

/* Mobile: sidebar diventa overlay laterale */
@media (max-width: 900px) {
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
  }
  html.sidebar-open .sidebar { transform: translateX(0); }
  html.sidebar-collapsed .sidebar { width: 280px; }  /* su mobile non ha senso "stretta" */
  html.sidebar-collapsed .sidebar .nav-label,
  html.sidebar-collapsed .sidebar .nav-section-label,
  html.sidebar-collapsed .sidebar .user-meta,
  html.sidebar-collapsed .sidebar .btn-logout { display: initial; }
  html.sidebar-collapsed .sidebar .nav-label,
  html.sidebar-collapsed .sidebar .nav-section-label { display: block; }
  html.sidebar-collapsed .sidebar .nav-item { justify-content: flex-start; padding: 0.55rem 0.75rem; }
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--sidebar-border);
}

.user-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.5rem;
  margin-bottom: 0.35rem;
  border-radius: var(--r-md);
}

.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 600;
  flex-shrink: 0;
}

.user-meta { min-width: 0; flex: 1; }
.user-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: #fff;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-role {
  font-size: 0.7rem;
  color: var(--sidebar-muted);
  margin-top: 0.1rem;
}

.btn-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  text-decoration: none;
  padding: 0.55rem;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(226, 232, 240, 0.85);
  font-size: 0.8125rem;
  border-radius: var(--r-md);
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
  border: none;
  width: 100%;
  font-family: inherit;
}
.btn-logout:hover {
  background: rgba(220, 38, 38, 0.18);
  color: #fff;
}

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

.topbar {
  padding: 1.15rem 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
/* Clock spinto all'estrema destra; brand + greeting restano raggruppati a sinistra */
.topbar-right { margin-left: auto; }

/* Brand nella topbar — appare SOLO quando la sidebar e` chiusa */
.topbar-brand {
  display: none;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  align-items: center;
  border-radius: 6px;
  transition: opacity 0.15s, transform 0.08s;
}
.topbar-brand:hover  { opacity: 0.85; }
.topbar-brand:active { transform: scale(0.97); }
.topbar-brand img {
  height: 40px; width: auto; display: block;
}
html.sidebar-collapsed .topbar-brand { display: inline-flex; }

.crumb {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.1rem;
}
.greeting {
  margin: 0;
  font-weight: 600;
  font-size: 1.125rem;
}
.greeting em { font-style: normal; color: var(--accent); }

.clock { text-align: right; }

/* Impostazioni è ora un modulo a sé (/settings) embeddato via iframe */
.clock-date {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: capitalize;
}
.clock-time {
  display: block;
  margin-top: 0.1rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

/* ---- Viste ------------------------------------------------- */
.view {
  display: none;
  padding: 2rem 2.5rem 3.5rem;
  overflow-y: auto;
  flex: 1;
}
/* Su schermi larghi centriamo il contenuto con un max-width per evitare
   che la griglia di widget si stiri a tutto lo schermo (disarmonica). */
.view > * { max-width: 1600px; margin-left: auto; margin-right: auto; width: 100%; }
@media (max-width: 1100px) {
  .view { padding: 1.5rem 1.25rem; }
}
.view.is-active { display: flex; flex-direction: column; }

/* Stat strip — "Eventi oggi" (ora cliccabile) */
.stat-strip {
  margin-top: 0.25rem;
  margin-bottom: 1.5rem;
  flex-shrink: 0;
}

.stat {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  padding: 1rem 1.25rem;
  min-width: 220px;
  max-width: 260px;
  border-radius: var(--r-lg);
  position: relative;
  box-shadow: var(--shadow-sm);
  display: block;
  text-align: left;
  font-family: inherit;
  color: inherit;
}

.stat-clickable {
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.stat-clickable:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.stat-clickable:active { transform: translateY(0); }
.stat-clickable:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.stat-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}
.stat-arrow {
  opacity: 0;
  transition: opacity 0.15s, transform 0.15s;
  color: var(--accent);
  font-size: 0.85rem;
}
.stat-clickable:hover .stat-arrow {
  opacity: 1;
  transform: translateX(2px);
}

.stat-value {
  font-size: 1.875rem;
  font-weight: 600;
  margin-top: 0.25rem;
  color: var(--text);
  line-height: 1.2;
}
.stat-accent {
  position: absolute;
  top: 1.1rem;
  right: 1.1rem;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

/* ---- Stat variant: Agenda (icona + data + sub) ---- */
.stat-agenda {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 280px;
  max-width: 340px;
  padding: 1.1rem 1.25rem;
}
.stat-agenda .stat-icon {
  width: 42px; height: 42px;
  padding: 9px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  flex-shrink: 0;
}
.stat-agenda .stat-body    { flex: 1; min-width: 0; }
.stat-agenda .stat-value   {
  font-size: 1.1rem; font-weight: 600;
  margin-top: 0.15rem;
  text-transform: capitalize;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stat-agenda .stat-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}
/* Su stat-agenda il pallino in alto a destra non serve */
.stat-agenda .stat-accent { display: none; }

/* Griglia 2x2 — tutti e 4 i widget con la STESSA altezza.
   grid-template-rows: 1fr 1fr forza la simmetria tra le due righe.
   Un min-height sulla griglia garantisce un'altezza ragionevole
   anche su schermi piccoli. */
.grid-2x2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 1.25rem;
  min-height: 1040px;
  margin-bottom: 2.5rem;   /* respiro sotto l'ultimo widget (workaround al
                              collasso del padding-bottom nel flex scroll) */
}

@media (max-width: 1100px) {
  .grid-2x2 {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(4, minmax(380px, 1fr));
    min-height: auto;
  }
}

/* ---- Panel ------------------------------------------------ */
.panel {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  box-shadow: var(--shadow-sm);
}

.panel-full {
  flex: 1;
  min-height: 0;
}

.panel-head {
  padding: 1rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.panel-eyebrow {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}
.panel-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0.2rem 0 0;
}
.panel-meta {
  font-size: 0.8125rem;
  color: var(--text-soft);
}
.panel-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.8125rem;
  text-decoration: none;
  color: var(--accent);
  font-weight: 500;
  padding: 0.35rem 0.65rem;
  border-radius: var(--r-sm);
  transition: background 0.15s;
}
.panel-link:hover { background: var(--accent-soft); }

/* ---- News ticker (Sole 24 Ore / Fisco e Tasse) ----------- */
.news-ticker {
  flex: 1 1 auto;
  position: relative;
  padding: 0.75rem 0.9rem 0.4rem;
  min-height: 220px;
  overflow: hidden;
  display: flex;
}
.news-ticker-loading,
.news-ticker-error {
  color: var(--text-subtle);
  font-size: 0.85rem;
  text-align: center;
}
.news-ticker-error .news-ticker-retry {
  display: inline-block;
  margin-left: 8px;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  font: inherit; font-size: 12px;
  color: var(--accent);
  cursor: pointer;
}
.news-ticker-retry:hover { background: var(--accent-soft); }

/* Layout full-cover: la foto prende tutto il ticker, titolo sovraimposto
   in basso su gradient scuro (stile card Reuters/Bloomberg). */
.news-ticker-item {
  position: relative;
  display: block;
  width: 100%; height: 100%;
  text-decoration: none;
  color: #fff;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(0,0,0,0.04);
  transition: opacity .2s ease, transform .2s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.news-ticker-item::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(
    180deg,
    rgba(0,0,0,0) 30%,
    rgba(0,0,0,0.55) 65%,
    rgba(0,0,0,0.92) 100%
  );
  pointer-events: none;
}

.news-ticker-thumb {
  width: 100%; height: 100%;
  display: block;
  object-fit: cover;
  background: rgba(0,0,0,0.04);
}
.news-ticker-thumb-empty {
  display: grid; place-items: center;
  font-size: 48px;
  color: rgba(255,255,255,0.85);
  background: linear-gradient(135deg, #8b5a3c 0%, #a14300 100%);
  width: 100%; height: 100%;
}

.news-ticker-body {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 1rem 1.1rem;
  z-index: 2;
}
.news-ticker-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff !important;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 0.35rem;
  text-shadow: 0 2px 6px rgba(0,0,0,0.7), 0 1px 2px rgba(0,0,0,0.9);
}
.news-ticker-meta {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.95) !important;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  text-shadow: 0 1px 3px rgba(0,0,0,0.7);
}

/* Crossfade fra notizia "in uscita" e "in entrata" */
.news-ticker-item.is-leaving {
  opacity: 0;
  transform: translateY(-4px);
}
.news-ticker-item.is-entering {
  opacity: 0;
  transform: translateY(6px);
}

/* Dots indicatori posizione */
.news-ticker-dots {
  display: flex; justify-content: center;
  gap: 6px;
  padding: 8px 0 14px;
  flex-shrink: 0;
}
.news-dot {
  width: 6px; height: 6px; border-radius: 50%;
  padding: 0; border: none;
  background: var(--border-strong, #cfd4dc);
  cursor: pointer;
  transition: background .15s, transform .15s;
}
.news-dot:hover   { background: var(--text-subtle); }
.news-dot.active {
  background: var(--accent, #4f46e5);
  transform: scale(1.3);
}

/* Vista fullscreen: GRID di card (un articolo per card), non un ticker
   a rotazione. Ogni card ha foto + titolo + meta. */
.panel-full .news-ticker.is-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.1rem;
  align-items: stretch;
  padding: 1.4rem 1.75rem;
  min-height: 0;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
}
.news-card {
  display: flex; flex-direction: column;
  text-decoration: none;
  color: inherit;
  background: #fff;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  overflow: hidden;
  transition: transform .15s ease, box-shadow .15s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.news-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.08);
}
.news-card-thumb {
  width: 100%; height: 160px;
  object-fit: cover;
  background: rgba(0,0,0,0.04);
  display: block;
}
.news-card-thumb-empty {
  display: grid; place-items: center;
  font-size: 40px;
  color: var(--text-subtle);
  background: linear-gradient(135deg, #f5f7fa 0%, #e5e9ef 100%);
}
.news-card-body {
  padding: 0.85rem 1rem 1rem;
  display: flex; flex-direction: column; gap: 0.4rem;
  flex: 1;
}
.news-card-title {
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--text, #1a2332);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.news-card-meta {
  font-size: 0.72rem;
  color: var(--text-subtle, #6b7685);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-top: auto;
}

/* La card del tema Sole ha un accento arancio sulla border-top */
.news-widget[data-news-source="sole24"] .news-card {
  border-top: 3px solid #c44d00;
}

/* Logo editoriale della fonte in sostituzione del title testuale */
.panel-logo {
  display: block;
  height: 30px;
  width: auto;
  max-width: 170px;
  margin-top: 0.1rem;
}
.panel-full .panel-logo { height: 44px; max-width: 240px; }

/* ---- Tema Sole 24 Ore: rosa salmone tipico dei quotidiani finanziari ---- */
.news-widget[data-news-source="sole24"] {
  background: #f7e5d0;
  border-color: #ecd3b4;
}
.news-widget[data-news-source="sole24"] .panel-head {
  background: linear-gradient(180deg, #fcefdd 0%, #f7e5d0 100%);
  border-bottom-color: #ecd3b4;
}
.news-widget[data-news-source="sole24"] .panel-eyebrow {
  color: #8b5a3c;
  font-weight: 600;
}
.news-widget[data-news-source="sole24"] .panel-title { color: #2b1a0d; }
/* NB: news-ticker-title e news-ticker-meta restano bianchi (testo sovraimposto
   alla foto, vedi `.news-ticker-item` + gradient scuro). */
.news-widget[data-news-source="sole24"] .panel-link        { color: #a14300; }
.news-widget[data-news-source="sole24"] .panel-link:hover  { background: rgba(161, 67, 0, 0.1); }
.news-widget[data-news-source="sole24"] .news-ticker-item:hover {
  background: rgba(161, 67, 0, 0.06);
}
.news-widget[data-news-source="sole24"] .news-dot          { background: rgba(139, 90, 60, 0.35); }
.news-widget[data-news-source="sole24"] .news-dot:hover    { background: rgba(139, 90, 60, 0.6); }
.news-widget[data-news-source="sole24"] .news-dot.active   { background: #a14300; }

/* ---- Todo widget ------------------------------------------ */
.todo-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--border);
  align-items: center;
  flex-shrink: 0;
}
.todo-form .todo-input {
  flex: 1;
  border: 1px solid var(--border-strong);
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  background: var(--surface);
  outline: none;
  border-radius: var(--r-md);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.todo-form .todo-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.todo-form .todo-tag-input {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  padding: 0.45rem 0.6rem;
  font-size: 0.8125rem;
  outline: none;
  border-radius: var(--r-md);
  cursor: pointer;
  color: var(--text-soft);
}
.todo-form button[type="submit"] {
  width: 36px; height: 36px;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  transition: background 0.15s;
  border-radius: var(--r-md);
  font-weight: 400;
}
.todo-form button[type="submit"]:hover { background: var(--accent-hover); }

.todo-list {
  list-style: none;
  margin: 0;
  padding: 0.5rem;
  overflow-y: auto;
  flex: 1;
}
.todo-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.7rem 0.9rem;
  border-radius: var(--r-md);
  transition: background 0.15s;
}
.todo-item:hover { background: var(--surface-hover); }

.todo-check {
  appearance: none;
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 1px;
  position: relative;
  transition: background 0.15s, border-color 0.15s;
  border-radius: 5px;
}
.todo-check:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.todo-check:checked::after {
  content: "";
  position: absolute;
  left: 4px; top: 0px;
  width: 5px; height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.todo-body { flex: 1; min-width: 0; }
.todo-text {
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--text);
  word-wrap: break-word;
}
.todo-item.is-done .todo-text {
  text-decoration: line-through;
  color: var(--text-subtle);
}
.todo-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.35rem;
}
.todo-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.todo-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

/* Pill scadenza con color-coding secondo quanto manca */
.todo-due {
  display: inline-flex; align-items: center;
  font-size: 0.7rem; font-weight: 600;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  border: 1px solid transparent;
}
.todo-due-overdue { color: #b91c1c; background: rgba(220,38,38,0.1);  border-color: rgba(220,38,38,0.25); }
.todo-due-today   { color: #b45309; background: rgba(245,158,11,0.12); border-color: rgba(245,158,11,0.3); }
.todo-due-soon    { color: #9a4d02; background: rgba(251,191,36,0.12); border-color: rgba(251,191,36,0.3); }
.todo-due-future  { color: var(--text-muted); background: var(--surface-2); border-color: var(--border); }
.todo-item.is-done .todo-due { opacity: .55; }

/* Input date nel form create */
.todo-form .todo-due-input {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  padding: 0.42rem 0.55rem;
  font-size: 0.8125rem;
  font-family: inherit;
  color: var(--text-soft);
  outline: none;
  border-radius: var(--r-md);
  cursor: pointer;
  min-width: 0;
  max-width: 140px;
}
.todo-form .todo-due-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Edit in-place: textarea inline al posto del testo */
.todo-edit-input {
  width: 100%;
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--r-sm);
  padding: 0.25rem 0.45rem;
  outline: none;
  resize: none;
  overflow-y: auto;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.todo-delete {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-subtle);
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, background 0.15s;
  padding: 0.25rem 0.4rem;
  font-size: 0.85rem;
  border-radius: var(--r-sm);
}
.todo-item:hover .todo-delete { opacity: 1; }
.todo-delete:hover { color: var(--danger); background: rgba(220, 38, 38, 0.08); }

.todo-empty {
  padding: 2.5rem 1rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ---- Iframe hosts ----------------------------------------- */
.iframe-host {
  flex: 1;
  min-height: 0;
  position: relative;
  background: var(--surface-2);
  overflow: hidden;
}
.iframe-host iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* ---- News fallback ---------------------------------------- */
.news-fallback {
  position: absolute;
  inset: 0;
  background: var(--panel-bg);
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.nf-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.75rem;
  flex-shrink: 0;
}
.nf-head-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}
.nf-head-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8125rem;
  text-decoration: none;
  background: var(--accent);
  color: #fff;
  padding: 0.45rem 0.85rem;
  border-radius: var(--r-md);
  font-weight: 500;
  transition: background 0.15s;
}
.nf-head-btn:hover { background: var(--accent-hover); }

.nf-list {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  flex: 1;
  overflow-y: auto;
  margin-bottom: 0.75rem;
}

.nf-item {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  padding: 0.75rem 0.5rem;
  border-radius: var(--r-md);
  transition: background 0.15s;
}
.nf-item:hover { background: var(--surface-hover); }
.nf-cat {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 0.25rem;
  letter-spacing: 0.02em;
}
.nf-title {
  font-size: 0.9375rem;
  line-height: 1.4;
  color: var(--text);
  font-weight: 500;
}
.nf-item:hover .nf-title { color: var(--accent-hover); }

.nf-note {
  padding: 0.85rem 1rem;
  background: var(--surface-2);
  font-size: 0.8125rem;
  color: var(--text-soft);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  line-height: 1.55;
  flex-shrink: 0;
}
.nf-note a { color: var(--accent); text-decoration: none; font-weight: 500; }
.nf-note a:hover { text-decoration: underline; }

/* ---- Placeholder (coming soon) ---------------------------- */
.panel-placeholder {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4rem 2rem;
  flex: 1;
  min-height: 60vh;
}
.placeholder-icon {
  width: 56px; height: 56px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.25rem;
  font-size: 1.5rem;
  font-weight: 600;
}
.placeholder-title {
  font-weight: 600;
  font-size: 1.375rem;
  margin: 0;
}
.placeholder-msg {
  margin: 0.5rem 0 1.5rem;
  color: var(--text-muted);
  max-width: 420px;
  font-size: 0.9375rem;
  line-height: 1.55;
}
.placeholder-tag {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
}

/* ---- Scrollbar -------------------------------------------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 10px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-subtle); background-clip: padding-box; }

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  background-clip: padding-box;
}

