/* Reset + shell (sidebar, topbar, navigazione) — geometria e scala del mockup */
* { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 14px; }

body {
  font-family: 'IBM Plex Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

code, .mono { font-family: 'IBM Plex Mono', ui-monospace, 'Cascadia Mono', monospace; }

a { color: var(--accent); text-decoration: none; transition: color var(--t-fast) var(--ease); }
a:hover { color: var(--accent-strong); text-decoration: underline; }

::selection { background: var(--accent-soft); }

h1 { font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 13.5px; font-weight: 600; }
h3 { font-size: 12.5px; font-weight: 600; }

/* Focus visibile e coerente su tutta l'app (il mockup non lo descrive:
   è il minimo per non peggiorare l'accessibilità rispetto a oggi). */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* ---- Layout ---- */
.layout { display: flex; min-height: 100vh; align-items: stretch; }

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.content {
  flex: 1;
  padding: 22px 24px 40px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

/* ---- Sidebar: marchio ---- */
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 16px 16px 14px;
}
.brand-mark {
  width: 26px;
  height: 26px;
  flex: none;
  background: var(--accent);
  color: var(--on-accent);
  display: grid;
  place-items: center;
  font: 700 12px 'IBM Plex Mono', ui-monospace, monospace;
  border-radius: var(--radius-sm);
}
.brand .name { font-size: 13.5px; font-weight: 700; letter-spacing: .04em; line-height: 1.2; }
.brand .sub { font-size: 10.5px; color: var(--text3); line-height: 1.3; }

/* ---- Sidebar: navigazione ---- */
.nav { padding: 0 10px 8px; flex: 1; }
.nav-group { display: flex; flex-direction: column; gap: 1px; padding-bottom: 8px; }
.nav-group-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text3);
  padding: 8px 8px 5px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  border-radius: 6px;
  color: var(--text2);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  box-shadow: inset 0 0 0 1px transparent;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.nav-item:hover { background: var(--surface2); color: var(--text); text-decoration: none; }
.nav-item.active {
  background: var(--surface2);
  color: var(--text);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--border);
}
.nav-item svg { width: 15px; height: 15px; flex-shrink: 0; }
.nav-item .nav-badge {
  margin-left: auto;
  font: 600 10.5px 'IBM Plex Mono', ui-monospace, monospace;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 9px;
  padding: 1px 6px;
  text-align: center;
}

/* ---- Sidebar: utente in fondo (posizione del mockup) ---- */
.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.side-user { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.side-user .uname {
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-user .urole {
  font-size: 11px;
  color: var(--text3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.avatar {
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
}

/* ---- Topbar ---- */
.searchbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  color: var(--text2);
  background: var(--bg);
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.searchbox:hover { border-color: var(--border-strong); color: var(--text); }
.searchbox svg { width: 12px; height: 12px; }
.searchbox kbd {
  font: 500 10px 'IBM Plex Mono', ui-monospace, monospace;
  color: var(--text3);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0 4px;
}

.topbar-spacer { flex: 1; }

/* Bottone testuale della topbar (tema, maschera importi) — con etichetta,
   come nel mockup; sotto i 900px resta la sola icona. */
.tbtn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: 500 12px 'IBM Plex Sans', system-ui, sans-serif;
  color: var(--text2);
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 9px;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease);
}
.tbtn:hover { background: var(--surface2); color: var(--text); }
.tbtn-ico { display: inline-flex; flex: none; }
.tbtn.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-border); }
.tbtn svg { width: 13px; height: 13px; flex: none; }

.iconbtn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: none;
  color: var(--text2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease);
}
.iconbtn:hover { background: var(--surface2); color: var(--text); }
.iconbtn svg { width: 13px; height: 13px; }
.iconbtn.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-border); }

/* ---- Switcher società (topbar) ---- */
.company-switcher {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 6px 2px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  transition: border-color var(--t-fast) var(--ease);
}
.company-switcher:hover { border-color: var(--border-strong); }
.company-switcher .cs-ico { display: inline-flex; color: var(--text3); }
.company-switcher .cs-ico svg { width: 13px; height: 13px; }
.company-select {
  border: none;
  background: transparent;
  color: var(--text2);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  padding: 3px 2px;
  cursor: pointer;
  outline: none;
  max-width: 190px;
}
.company-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text2);
}
.company-chip .cs-ico { display: inline-flex; color: var(--text3); }
.company-chip .cs-ico svg { width: 13px; height: 13px; }

/* ---- Notifiche (campanella + pannello) ---- */
.notif-wrap { position: relative; display: inline-flex; }
.notif-btn { position: relative; }
.notif-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: var(--radius-pill);
  background: var(--neg);
  color: #fff;
  font: 600 10px/15px 'IBM Plex Mono', ui-monospace, monospace;
  text-align: center;
  box-shadow: 0 0 0 2px var(--surface);
}
.notif-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 340px;
  max-width: 90vw;
  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: 120;
}
.notif-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  font-size: 13.5px;
  font-weight: 600;
}
.notif-empty { padding: 28px 16px; text-align: center; color: var(--text3); font-size: 12.5px; }
.notif-item {
  display: block;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease);
}
.notif-item:hover { background: var(--row-hover); text-decoration: none; }
.notif-item.unread { background: var(--accent-soft); }
.notif-item.unread:hover { background: var(--accent-soft); filter: brightness(.98); }
.notif-item-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 600;
}
.notif-item-title .notif-ico { display: inline-flex; color: var(--warn); flex-shrink: 0; }
.notif-item-title .notif-ico svg { width: 14px; height: 14px; }
.notif-item-body { font-size: 12px; color: var(--text2); margin: 3px 0 0 21px; }
.notif-item-time { font-size: 11px; color: var(--text3); margin: 3px 0 0 21px; }

.linkbtn {
  background: none;
  border: none;
  color: var(--accent);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
  transition: color var(--t-fast) var(--ease);
}
.linkbtn:hover { color: var(--accent-strong); text-decoration: underline; }

/* ---- Intestazione pagina ---- */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.page-head .grow { flex: 1; }
.page-sub { color: var(--text3); font-size: 12.5px; margin-top: 3px; }

/* ---- Maschera importi ----
   Il mockup sfoca [data-amt]; in app la maschera continua a sostituire il
   testo (eur() → '•••••'), quindi la sfocatura vale per i grafici, che
   il testo non lo hanno. */
body[data-mask="1"] [data-amt] {
  filter: blur(7px);
  user-select: none;
  pointer-events: none;
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform var(--t-med) var(--ease);
  }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .topbar { padding: 10px 16px; }
  .content { padding: 16px 16px 32px; }
  .tbtn .tbtn-label { display: none; }
  .tbtn { padding: 5px 7px; }
}

@media (max-width: 720px) {
  .company-select { max-width: 120px; }
  .searchbox .searchbox-label, .searchbox kbd { display: none; }
}
