/* =========================================================================
   aziendain.cloud — design system app (linguaggio shadcn/ui, CSS puro)
   ========================================================================= */

@font-face {
  font-family: "Geist";
  src: url("../fonts/geist-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Geist";
  src: url("../fonts/geist-latin-ext-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Geist Mono";
  src: url("../fonts/geist-mono-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --radius: 0.625rem;
  --background: #ffffff;
  --foreground: #09090b;
  --card: #ffffff;
  --card-foreground: #09090b;
  --popover: #ffffff;
  --muted: #f4f4f5;
  --muted-foreground: #71717a;
  --subtle: #fafafa;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --input: #e4e4e7;
  --ring: #2f5bea;
  --primary: #18181b;
  --primary-hover: #27272a;
  --primary-foreground: #fafafa;
  --secondary: #f4f4f5;
  --secondary-hover: #e9e9ec;
  --accent: #f4f4f5;
  --brand: #2f5bea;
  --brand-soft: #eef2fe;
  --brand-ink: #1e3fb8;
  --destructive: #dc2626;
  --destructive-hover: #b91c1c;
  --sidebar: #fafafa;
  --sidebar-border: #e4e4e7;

  --ok: #15803d;      --ok-bg: #f0fdf4;     --ok-border: #bbf7d0;     --ok-dot: #16a34a;
  --warn: #a16207;    --warn-bg: #fefce8;   --warn-border: #fde68a;   --warn-dot: #eab308;
  --serious: #c2410c; --serious-bg: #fff7ed; --serious-border: #fed7aa; --serious-dot: #f97316;
  --danger: #b91c1c;  --danger-bg: #fef2f2; --danger-border: #fecaca; --danger-dot: #dc2626;
  --info: #1e3fb8;    --info-bg: #eef2fe;   --info-border: #c7d4fb;   --info-dot: #2f5bea;

  --shadow-xs: 0 1px 2px 0 rgb(9 9 11 / 0.05);
  --shadow-sm: 0 1px 3px 0 rgb(9 9 11 / 0.08), 0 1px 2px -1px rgb(9 9 11 / 0.06);
  --shadow-md: 0 4px 6px -1px rgb(9 9 11 / 0.08), 0 2px 4px -2px rgb(9 9 11 / 0.05);
  --shadow-lg: 0 12px 24px -6px rgb(9 9 11 / 0.14), 0 4px 8px -4px rgb(9 9 11 / 0.06);

  --sidebar-w: 256px;
  --header-h: 56px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

/* --- Reset ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--foreground);
  background: var(--background);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01" on;
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
table { border-collapse: collapse; }
::selection { background: #dbe4fd; color: var(--foreground); }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

* { scrollbar-width: thin; scrollbar-color: #d4d4d8 transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #d4d4d8; border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background-color: #a1a1aa; }

.icon { width: 16px; height: 16px; flex-shrink: 0; }
.icon-sm { width: 14px; height: 14px; flex-shrink: 0; }
.icon-lg { width: 20px; height: 20px; flex-shrink: 0; }
.tabular, .num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-size: 12.5px; letter-spacing: -0.01em; }
.muted { color: var(--muted-foreground); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap { white-space: nowrap; }

/* --- Layout app ------------------------------------------------------------ */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100dvh; }

.sidebar {
  position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--sidebar);
  border-right: 1px solid var(--sidebar-border);
  z-index: 40;
}
.sidebar-head { padding: 12px; }
.tenant-card {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px; border-radius: 8px; border: 0; background: transparent; text-align: left; cursor: default;
}
.tenant-logo {
  width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--primary); color: var(--primary-foreground);
  font-weight: 600; font-size: 13px; letter-spacing: -0.02em;
}
.tenant-name { font-weight: 600; font-size: 13.5px; line-height: 1.25; letter-spacing: -0.01em; }
.tenant-sub { font-size: 12px; color: var(--muted-foreground); line-height: 1.3; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 4px 12px 12px; }
.nav-group + .nav-group { margin-top: 16px; }
.nav-label { padding: 0 8px 6px; font-size: 12px; font-weight: 500; color: var(--muted-foreground); }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  height: 32px; padding: 0 8px; border-radius: 6px;
  color: #3f3f46; font-weight: 450;
  transition: background-color .15s var(--ease-out), color .15s var(--ease-out);
}
.nav-item .icon { color: #71717a; }
.nav-item:hover { background: #f0f0f2; color: var(--foreground); }
.nav-item[aria-current="page"] { background: #ececef; color: var(--foreground); font-weight: 550; }
.nav-item[aria-current="page"] .icon { color: var(--foreground); }
.nav-count {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px;
  display: inline-grid; place-items: center; border-radius: 99px;
  font-size: 11.5px; font-weight: 550; font-variant-numeric: tabular-nums;
  background: #e4e4e7; color: #3f3f46;
}
.nav-count.is-alert { background: var(--danger-bg); color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger-border); }

.sidebar-foot { padding: 12px; border-top: 1px solid var(--sidebar-border); }
.user-btn {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 6px 8px; border-radius: 8px; border: 0; background: transparent; cursor: pointer; text-align: left;
}
.user-btn:hover { background: #f0f0f2; }
.user-name { font-size: 13px; font-weight: 550; line-height: 1.25; }
.user-role { font-size: 12px; color: var(--muted-foreground); line-height: 1.3; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--header-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 24px;
  background: rgb(255 255 255 / 0.86);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar .menu-toggle { display: none; }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--muted-foreground); min-width: 0; }
.crumbs a:hover { color: var(--foreground); }
.crumbs .current { color: var(--foreground); font-weight: 500; }
.crumbs .icon-sm { color: #a1a1aa; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.search-trigger {
  display: inline-flex; align-items: center; gap: 8px;
  height: 34px; width: 260px; padding: 0 8px 0 10px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--subtle); color: var(--muted-foreground);
  font-size: 13px; cursor: pointer;
  transition: border-color .15s, background-color .15s;
}
.search-trigger:hover { border-color: var(--border-strong); background: #fff; }
.search-trigger span:not(.kbd) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.search-trigger .kbd { margin-left: auto; white-space: nowrap; flex-shrink: 0; }

.content { padding: 24px; width: 100%; max-width: 1480px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-title { font-size: 24px; line-height: 1.2; font-weight: 600; letter-spacing: -0.025em; }
.page-desc { color: var(--muted-foreground); margin-top: 4px; max-width: 70ch; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* --- Griglie ---------------------------------------------------------------- */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-dash { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 8px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wrap { flex-wrap: wrap; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.ml-auto { margin-left: auto; }

/* --- Card ------------------------------------------------------------------- */
.card {
  background: var(--card); color: var(--card-foreground);
  border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-xs);
}
.card-header { padding: 18px 20px 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-title { font-size: 15px; font-weight: 600; letter-spacing: -0.015em; line-height: 1.3; }
.card-desc { font-size: 13px; color: var(--muted-foreground); margin-top: 2px; }
.card-content { padding: 16px 20px 20px; }
.card-content.flush { padding: 12px 0 4px; }
.card-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.card-link { font-size: 13px; font-weight: 500; color: var(--muted-foreground); display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.card-link:hover { color: var(--foreground); }

/* --- Bottoni ------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px;
  border-radius: 8px; border: 1px solid transparent;
  font-size: 13.5px; font-weight: 500; line-height: 1; white-space: nowrap;
  cursor: pointer; user-select: none;
  transition: background-color .15s var(--ease-out), border-color .15s var(--ease-out), color .15s, box-shadow .15s, transform .1s;
}
.btn:active { transform: translateY(0.5px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.btn-primary { background: var(--primary); color: var(--primary-foreground); box-shadow: var(--shadow-xs); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: #fff; border-color: var(--border); box-shadow: var(--shadow-xs); }
.btn-outline:hover { background: var(--accent); }
.btn-secondary { background: var(--secondary); }
.btn-secondary:hover { background: var(--secondary-hover); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--accent); }
.btn-destructive { background: var(--destructive); color: #fff; }
.btn-destructive:hover { background: var(--destructive-hover); }
.btn-link { background: transparent; padding: 0; height: auto; color: var(--brand-ink); text-decoration: underline; text-underline-offset: 3px; }
.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; border-radius: 7px; gap: 6px; }
.btn-xs { height: 26px; padding: 0 8px; font-size: 12.5px; border-radius: 6px; gap: 4px; }
.btn-lg { height: 40px; padding: 0 18px; }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn-block { width: 100%; }
.btn .icon { width: 16px; height: 16px; }
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--primary-foreground) transparent var(--primary-foreground) transparent;
  animation: spin .7s linear infinite;
}
.btn-outline.is-loading::after { border-color: var(--foreground) transparent var(--foreground) transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn-dot { position: relative; }
.icon-btn-dot .dot {
  position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger-dot); box-shadow: 0 0 0 2px #fff;
}

/* --- Badge e stati ---------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px; border-radius: 6px;
  font-size: 12px; font-weight: 500; line-height: 1; white-space: nowrap;
  border: 1px solid var(--border); background: #fff; color: #3f3f46;
}
.badge .icon, .badge .icon-sm { width: 13px; height: 13px; }
.badge-solid { background: var(--primary); color: var(--primary-foreground); border-color: var(--primary); }
.badge-muted { background: var(--muted); border-color: transparent; color: #3f3f46; }
.badge-ok      { background: var(--ok-bg);      border-color: var(--ok-border);      color: var(--ok); }
.badge-expiring{ background: var(--warn-bg);    border-color: var(--warn-border);    color: var(--warn); }
.badge-missing { background: var(--serious-bg); border-color: var(--serious-border); color: var(--serious); }
.badge-expired { background: var(--danger-bg);  border-color: var(--danger-border);  color: var(--danger); }
.badge-info    { background: var(--info-bg);    border-color: var(--info-border);    color: var(--info); }
.badge-na      { background: var(--muted); border-color: transparent; color: var(--muted-foreground); }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; background: #a1a1aa; }
.dot-ok { background: var(--ok-dot); } .dot-expiring { background: var(--warn-dot); }
.dot-missing { background: var(--serious-dot); } .dot-expired { background: var(--danger-dot); }
.dot-info { background: var(--info-dot); }

.days { font-variant-numeric: tabular-nums; font-weight: 550; white-space: nowrap; }
.days-expired { color: var(--danger); } .days-expiring { color: var(--warn); } .days-ok { color: var(--muted-foreground); font-weight: 450; }

/* --- Form --------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field + .field { margin-top: 14px; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field-row + .field, .field + .field-row, .field-row + .field-row { margin-top: 14px; }
.field-row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.label { font-size: 13px; font-weight: 500; line-height: 1.2; }
.hint { font-size: 12.5px; color: var(--muted-foreground); }
.input, .select, .textarea {
  width: 100%; height: 36px; padding: 0 12px;
  border: 1px solid var(--input); border-radius: 8px;
  background: #fff; box-shadow: var(--shadow-xs);
  font-size: 13.5px;
  transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 88px; padding: 9px 12px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: #71717a; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgb(47 91 234 / 0.18); }
.input[aria-invalid="true"] { border-color: var(--destructive); box-shadow: 0 0 0 3px rgb(220 38 38 / 0.12); }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px;
}
.input-sm, .select-sm { height: 32px; font-size: 13px; }
.input-icon { position: relative; }
.input-icon > .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted-foreground); pointer-events: none; }
.input-icon > .input { padding-left: 34px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.form-error { font-size: 12.5px; color: var(--destructive); }

/* --- Toolbar filtri ------------------------------------------------------ */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .input-icon { width: 280px; }
.toolbar .grow { flex: 1; }

/* Segmented / tabs */
.tabs { display: inline-flex; align-items: center; gap: 2px; padding: 3px; background: var(--muted); border-radius: 9px; }
.tab {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 12px; border-radius: 7px; border: 0; background: transparent;
  font-size: 13px; font-weight: 500; color: #52525b; cursor: pointer; white-space: nowrap;
  transition: background-color .15s, color .15s, box-shadow .15s;
}
.tab:hover { color: var(--foreground); }
.tab[aria-selected="true"], .tab.is-active { background: #fff; color: var(--foreground); box-shadow: var(--shadow-sm); }
.tab .count { font-size: 11.5px; color: var(--muted-foreground); font-variant-numeric: tabular-nums; }

.underline-tabs { display: flex; gap: 20px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.underline-tab {
  display: inline-flex; align-items: center; gap: 6px; padding: 10px 0; margin-bottom: -1px;
  font-size: 13.5px; font-weight: 500; color: var(--muted-foreground);
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.underline-tab:hover { color: var(--foreground); }
.underline-tab[aria-current="page"] { color: var(--foreground); border-bottom-color: var(--foreground); }

/* --- Tabelle -------------------------------------------------------------- */
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: #fff; box-shadow: var(--shadow-xs); }
.table { width: 100%; font-size: 13.5px; }
.table th {
  height: 40px; padding: 0 14px; text-align: left; white-space: nowrap;
  font-size: 12.5px; font-weight: 500; color: var(--muted-foreground);
  border-bottom: 1px solid var(--border); background: var(--subtle);
}
.table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color .12s; }
.table tbody tr:hover { background: #fafafa; }
.table tr[data-href] { cursor: pointer; }
.table .t-right { text-align: right; }
.table .t-strong { font-weight: 550; }
.table-plain { width: 100%; font-size: 13.5px; }
.table-plain td, .table-plain th { padding: 9px 20px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table-plain th { font-size: 12.5px; color: var(--muted-foreground); font-weight: 500; }
.table-plain tr:last-child td { border-bottom: 0; }
.table-foot { display: flex; align-items: center; justify-content: space-between; padding: 10px 2px 0; font-size: 13px; color: var(--muted-foreground); }

.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.person-name { font-weight: 550; line-height: 1.25; }
.person-sub { font-size: 12.5px; color: var(--muted-foreground); line-height: 1.3; }

/* --- Avatar ----------------------------------------------------------- */
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600; letter-spacing: -0.01em;
  background: #ececef; color: #3f3f46;
}
.avatar-sm { width: 24px; height: 24px; font-size: 10.5px; }
.avatar-lg { width: 56px; height: 56px; font-size: 18px; }
.avatar-brand { background: var(--brand-soft); color: var(--brand-ink); }
.avatar-dark { background: var(--primary); color: #fff; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { box-shadow: 0 0 0 2px #fff; }
.avatar-stack .avatar + .avatar { margin-left: -6px; }

/* --- Kbd, separatore, alert ---------------------------------------------- */
.kbd {
  display: inline-flex; align-items: center; gap: 2px; height: 20px; padding: 0 5px;
  border: 1px solid var(--border); border-radius: 4px; background: #fff;
  font-family: var(--font-sans); font-size: 11px; font-weight: 500; color: var(--muted-foreground);
}
.sep { height: 1px; background: var(--border); border: 0; margin: 12px 0; }
.alert {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border); background: #fff; font-size: 13.5px;
}
.alert .icon { margin-top: 2px; }
.alert-title { font-weight: 600; }
.alert-danger { background: var(--danger-bg); border-color: var(--danger-border); color: #7f1d1d; }
.alert-danger .icon { color: var(--danger); }
.alert-warn { background: var(--warn-bg); border-color: var(--warn-border); color: #713f12; }
.alert-warn .icon { color: var(--warn); }
.alert-info { background: var(--info-bg); border-color: var(--info-border); color: #172554; }
.alert-info .icon { color: var(--brand); }
.alert-ok { background: var(--ok-bg); border-color: var(--ok-border); color: #14532d; }
.alert-ok .icon { color: var(--ok); }

/* --- KPI ---------------------------------------------------------------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.kpi { padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; transition: border-color .15s, box-shadow .15s; }
a.kpi:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.kpi-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 500; color: #52525b; }
.kpi-label .icon { color: #a1a1aa; }
.kpi-value { font-size: 28px; line-height: 1; font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: 15px; font-weight: 500; color: var(--muted-foreground); letter-spacing: -0.01em; margin-left: 2px; }
.kpi-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted-foreground); }

/* Meter (conformita') */
.meter { height: 8px; border-radius: 99px; background: var(--ok-bg); box-shadow: inset 0 0 0 1px var(--ok-border); overflow: hidden; display: flex; gap: 2px; }
.meter > span { display: block; height: 100%; border-radius: 99px; }
.meter .m-ok { background: var(--ok-dot); }
.meter .m-expiring { background: var(--warn-dot); }
.meter .m-missing { background: var(--serious-dot); }
.meter .m-expired { background: var(--danger-dot); }
.meter-lg { height: 10px; }

.site-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; align-items: center; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.site-row:last-child { border-bottom: 0; }
.site-row:hover { background: #fafafa; }
.site-row .meter { grid-column: 1 / -1; }
.site-row-pct { font-weight: 600; font-variant-numeric: tabular-nums; font-size: 15px; letter-spacing: -0.02em; }

/* Timeline scadenze */
.tl { list-style: none; padding: 0; }
.tl-item { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 10px 20px; border-bottom: 1px solid var(--border); transition: background-color .12s; }
.tl-item:last-child { border-bottom: 0; }
.tl-item:hover { background: #fafafa; }
.tl-date {
  width: 56px; height: 48px; border-radius: 8px; border: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.05;
  background: #fff;
}
.tl-date b { font-size: 17px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.tl-date span { font-size: 11px; text-transform: uppercase; color: var(--muted-foreground); font-weight: 500; letter-spacing: .04em; }
.tl-date.is-expired { border-color: var(--danger-border); background: var(--danger-bg); }
.tl-date.is-expired b, .tl-date.is-expired span { color: var(--danger); }
.tl-title { font-weight: 550; line-height: 1.3; }
.tl-sub { font-size: 12.5px; color: var(--muted-foreground); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.tl-sub .sep-dot::before { content: "·"; color: #a1a1aa; }
.tl-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }

.kind { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: #52525b; }
.kind .icon-sm { color: #a1a1aa; }

/* Lista compatta */
.list { list-style: none; padding: 0; }
.list-item { display: flex; align-items: flex-start; gap: 12px; padding: 10px 20px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
a.list-item:hover, .list-item.is-link:hover { background: #fafafa; }
.list-title { font-weight: 500; line-height: 1.35; }
.list-sub { font-size: 12.5px; color: var(--muted-foreground); margin-top: 1px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.check-circle {
  width: 18px; height: 18px; margin-top: 1px; flex-shrink: 0; border-radius: 50%;
  border: 1.5px solid #a1a1aa; background: #fff; cursor: pointer; display: grid; place-items: center; padding: 0;
  transition: border-color .15s, background-color .15s;
}
.check-circle:hover { border-color: var(--foreground); }
.check-circle .icon { width: 12px; height: 12px; color: #fff; opacity: 0; }
.check-circle.is-done { background: var(--ok-dot); border-color: var(--ok-dot); }
.check-circle.is-done .icon { opacity: 1; }
.is-done-text { text-decoration: line-through; color: var(--muted-foreground); }

.prio { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 500; }
.prio-alta { color: var(--danger); } .prio-media { color: #52525b; } .prio-bassa { color: var(--muted-foreground); }

/* --- Empty state ----------------------------------------------------------- */
.empty { text-align: center; padding: 40px 24px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.empty-icon { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; background: var(--muted); color: #52525b; margin-bottom: 6px; }
.empty-title { font-weight: 600; }
.empty-text { color: var(--muted-foreground); max-width: 46ch; }

/* --- Matrice formazione ---------------------------------------------------- */
.matrix-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 12px; background: #fff; max-height: calc(100dvh - 260px); }
.matrix { border-collapse: separate; border-spacing: 0; font-size: 13px; }
.matrix th, .matrix td { border-bottom: 1px solid var(--border); }
.matrix thead th {
  position: sticky; top: 0; z-index: 2; background: var(--subtle);
  height: 124px; vertical-align: bottom; padding: 8px 4px; min-width: 44px; max-width: 44px;
}
.matrix thead th .rot { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; font-size: 12px; font-weight: 500; color: #52525b; margin: 0 auto; }
.matrix thead th.mx-person { left: 0; z-index: 3; min-width: 240px; max-width: 240px; text-align: left; padding: 8px 14px; font-size: 12.5px; color: var(--muted-foreground); font-weight: 500; }
.matrix tbody th { position: sticky; left: 0; z-index: 1; background: #fff; text-align: left; padding: 8px 14px; font-weight: 400; border-right: 1px solid var(--border); }
.matrix thead th.mx-person { border-right: 1px solid var(--border); }
.matrix td { text-align: center; padding: 4px; }
.matrix tbody tr:hover th, .matrix tbody tr:hover td { background: #fafafa; }
.mx-group th { background: var(--muted) !important; font-size: 12px; font-weight: 600; color: #3f3f46; padding: 6px 14px !important; position: sticky; left: 0; }
.mx-cell {
  width: 30px; height: 26px; border-radius: 6px; margin: 0 auto;
  display: grid; place-items: center; border: 1px solid transparent;
}
.mx-cell .icon { width: 14px; height: 14px; }
.mx-ok { background: var(--ok-bg); border-color: var(--ok-border); color: var(--ok); }
.mx-expiring { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn); }
.mx-missing { background: #fff; border: 1.5px dashed var(--serious-dot); color: var(--serious); }
.mx-expired { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger); }
.mx-planned { box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px var(--brand); }
.mx-na { color: #d4d4d8; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: #52525b; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend .mx-cell { width: 22px; height: 18px; margin: 0; }
.legend .mx-cell .icon { width: 11px; height: 11px; }

/* --- Dettaglio lavoratore ----------------------------------------------- */
.profile { display: flex; align-items: center; gap: 16px; }
.profile-name { font-size: 22px; font-weight: 600; letter-spacing: -0.025em; line-height: 1.2; }
.dl { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 10px 16px; font-size: 13.5px; }
.dl dt { color: var(--muted-foreground); }
.dl dd { margin: 0; font-weight: 450; min-width: 0; overflow-wrap: anywhere; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }

.course-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.course-row:last-child { border-bottom: 0; }
.course-name { font-weight: 550; }
.course-meta { font-size: 12.5px; color: var(--muted-foreground); margin-top: 2px; }

/* --- Kanban --------------------------------------------------------------- */
.board { display: grid; grid-template-columns: repeat(3, minmax(260px, 1fr)); gap: 16px; align-items: start; }
.board-6 { grid-template-columns: repeat(6, minmax(172px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.board-6 .column-head { flex-wrap: wrap; row-gap: 2px; }
.board-6 .column-head .sum { margin-left: 0; width: 100%; }
.k-card form button { opacity: 0; transition: opacity .15s; }
.k-card:hover form button, .k-card:focus-within form button { opacity: 1; }
@media (hover: none) { .k-card form button { opacity: 1; } }
.column { background: var(--subtle); border: 1px solid var(--border); border-radius: 12px; display: flex; flex-direction: column; min-height: 200px; }
.column-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px 8px; font-weight: 600; font-size: 13.5px; }
.column-head .count { color: var(--muted-foreground); font-weight: 500; font-variant-numeric: tabular-nums; }
.column-head .sum { margin-left: auto; font-size: 12.5px; color: var(--muted-foreground); font-weight: 500; font-variant-numeric: tabular-nums; }
.column-body { padding: 4px 10px 12px; display: flex; flex-direction: column; gap: 8px; flex: 1; min-height: 80px; border-radius: 0 0 12px 12px; transition: background-color .15s; }
.column-body.is-over { background: var(--brand-soft); }
.k-card {
  background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 12px;
  box-shadow: var(--shadow-xs); cursor: grab; display: flex; flex-direction: column; gap: 8px;
  transition: box-shadow .15s, border-color .15s, opacity .15s;
}
.k-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.k-card.is-dragging { opacity: .45; }
.k-card:active { cursor: grabbing; }
.k-title { font-weight: 550; line-height: 1.35; }
.k-desc { font-size: 12.5px; color: var(--muted-foreground); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.k-foot { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted-foreground); }
.k-value { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--foreground); font-size: 14px; letter-spacing: -0.01em; }

/* --- Ticket / chat ------------------------------------------------------- */
.thread { display: flex; flex-direction: column; gap: 18px; }
.msg { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 12px; }
.msg-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.msg-author { font-weight: 600; font-size: 13.5px; }
.msg-time { font-size: 12px; color: var(--muted-foreground); }
.msg-body { padding: 12px 14px; border-radius: 0 10px 10px 10px; background: var(--subtle); border: 1px solid var(--border); white-space: pre-line; line-height: 1.6; max-width: 72ch; }
.msg.is-provider .msg-body { background: var(--brand-soft); border-color: var(--info-border); }
.msg-system { text-align: center; font-size: 12.5px; color: var(--muted-foreground); display: flex; align-items: center; gap: 10px; }
.msg-system::before, .msg-system::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.composer { border: 1px solid var(--border); border-radius: 12px; background: #fff; box-shadow: var(--shadow-xs); overflow: hidden; }
.composer:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgb(47 91 234 / 0.15); }
.composer textarea { border: 0; width: 100%; min-height: 96px; padding: 12px 14px; resize: vertical; outline: none; line-height: 1.55; }
.composer-bar { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-top: 1px solid var(--border); background: var(--subtle); }

.status-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; }
.st-aperto .dot { background: var(--info-dot); }
.st-in_lavorazione .dot { background: var(--warn-dot); }
.st-in_attesa .dot { background: #a855f7; }
.st-risolto .dot { background: var(--ok-dot); }
.st-chiuso .dot { background: #a1a1aa; }

/* --- Popover / dropdown ----------------------------------------------------- */
.dropdown { position: relative; }
.menu {
  position: absolute; z-index: 60; min-width: 220px; padding: 4px;
  background: var(--popover); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(-4px) scale(.98); transform-origin: top right; pointer-events: none;
  transition: opacity .14s var(--ease-out), transform .14s var(--ease-out);
}
.menu.is-open { opacity: 1; transform: none; pointer-events: auto; }
.menu-right { right: 0; top: calc(100% + 6px); }
.menu-up { bottom: calc(100% + 6px); left: 0; right: 0; transform-origin: bottom left; }
.menu-label { padding: 6px 8px; font-size: 12px; font-weight: 500; color: var(--muted-foreground); }
.menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 7px 8px; border-radius: 6px; border: 0; background: transparent; text-align: left;
  font-size: 13.5px; cursor: pointer;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--accent); outline: none; }
.menu-item .icon { color: #71717a; }
.menu-item.is-danger { color: var(--destructive); }
.menu-item.is-danger .icon { color: var(--destructive); }
.menu-sep { height: 1px; background: var(--border); margin: 4px -4px; }

.notif-menu { width: 360px; max-height: 460px; overflow: auto; padding: 0; }
.notif-head { padding: 12px 14px; border-bottom: 1px solid var(--border); font-weight: 600; display: flex; align-items: center; justify-content: space-between; }
.notif-item { display: flex; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
.notif-item:hover { background: #fafafa; }
.notif-item:last-child { border-bottom: 0; }

/* --- Dialog / sheet -------------------------------------------------------- */
dialog { border: 0; padding: 0; background: transparent; color: inherit; max-width: none; max-height: none; }
dialog::backdrop { background: rgb(9 9 11 / 0.45); backdrop-filter: blur(2px); }
.dialog {
  width: min(520px, calc(100vw - 32px)); margin: auto;
  background: #fff; border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg);
}
dialog[open].dialog { animation: dialog-in .18s var(--ease-out); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(6px) scale(.98); } }
.dialog-wide { width: min(680px, calc(100vw - 32px)); }
.dialog-head { padding: 20px 22px 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.dialog-title { font-size: 17px; font-weight: 600; letter-spacing: -0.02em; }
.dialog-desc { font-size: 13.5px; color: var(--muted-foreground); margin-top: 4px; }
.dialog-body { padding: 18px 22px; max-height: calc(100dvh - 220px); overflow-y: auto; }
.dialog-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; background: var(--subtle); border-radius: 0 0 14px 14px; }

.sheet {
  position: fixed; inset: 0 0 0 auto; height: 100dvh; max-height: 100dvh; width: min(480px, 100vw); margin: 0 0 0 auto;
  background: #fff; border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
  flex-direction: column;
}
dialog.sheet[open] { display: flex; }
dialog:not([open]) { display: none; }
dialog[open].sheet { animation: sheet-in .22s var(--ease-out); }
@keyframes sheet-in { from { transform: translateX(24px); opacity: 0; } }
.sheet .dialog-body { flex: 1; max-height: none; }
.sheet .dialog-foot { border-radius: 0; }

/* --- Command palette ---------------------------------------------------- */
.command { width: min(620px, calc(100vw - 32px)); margin: 12vh auto auto; background: #fff; border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden; }
dialog[open].command { animation: dialog-in .16s var(--ease-out); }
.command-input { display: flex; align-items: center; gap: 10px; padding: 0 14px; border-bottom: 1px solid var(--border); }
.command-input .icon { color: var(--muted-foreground); }
.command-input input { flex: 1; height: 50px; border: 0; outline: none; font-size: 15px; background: transparent; }
.command-list { max-height: 380px; overflow-y: auto; padding: 6px; }
.command-group { padding: 8px 8px 4px; font-size: 12px; font-weight: 500; color: var(--muted-foreground); }
.command-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; font-size: 13.5px; cursor: pointer; }
.command-item .icon { color: #71717a; }
.command-item .sub { margin-left: auto; font-size: 12.5px; color: var(--muted-foreground); }
.command-item.is-active { background: var(--accent); }
.command-empty { padding: 28px; text-align: center; color: var(--muted-foreground); }
.command-foot { display: flex; gap: 14px; padding: 8px 14px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted-foreground); background: var(--subtle); }

/* --- Toast ----------------------------------------------------------------- */
.toaster { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 10px;
  min-width: 300px; max-width: 420px; padding: 12px 14px;
  background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg);
  font-size: 13.5px; animation: toast-in .24s var(--ease-out);
}
.toast .icon { margin-top: 2px; }
.toast-success .icon { color: var(--ok); }
.toast-error .icon { color: var(--destructive); }
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }

/* --- Skeleton --------------------------------------------------------------- */
.skeleton { background: linear-gradient(90deg, #f4f4f5 25%, #ececef 37%, #f4f4f5 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 6px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* --- Login ---------------------------------------------------------------- */
.auth { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth-panel { display: flex; flex-direction: column; justify-content: space-between; padding: 40px; background: #0b0b0d; color: #fafafa; position: relative; overflow: hidden; }
.auth-form-wrap { display: grid; place-items: center; padding: 40px 24px; }
.auth-form { width: 100%; max-width: 380px; }
.auth-title { font-size: 26px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.2; }
.wordmark { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; letter-spacing: -0.02em; }
.wordmark .mark { width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center; background: #fafafa; color: #0b0b0d; }
.wordmark .mark svg { width: 16px; height: 16px; }
.wordmark .tld { color: #a1a1aa; font-weight: 500; }
.auth-quote { font-size: 22px; line-height: 1.35; letter-spacing: -0.02em; font-weight: 500; max-width: 30ch; }
.demo-box { margin-top: 22px; padding: 14px; border: 1px dashed var(--border-strong); border-radius: 10px; background: var(--subtle); }
.demo-users { display: grid; gap: 6px; margin-top: 10px; }
.demo-user { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; cursor: pointer; text-align: left; width: 100%; transition: border-color .15s, box-shadow .15s; }
.demo-user:hover { border-color: var(--border-strong); box-shadow: var(--shadow-xs); }

/* Mini preview nel pannello login */
.auth-preview { display: grid; gap: 10px; max-width: 440px; }
.auth-preview .ap-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 10px; background: #18181b; border: 1px solid #27272a; }
.auth-preview .ap-row b { font-weight: 550; font-size: 13.5px; }
.auth-preview .ap-row span { font-size: 12.5px; color: #a1a1aa; }
.auth-preview .ap-badge { margin-left: auto; font-size: 12px; padding: 3px 8px; border-radius: 6px; font-weight: 500; white-space: nowrap; }

/* --- Pagine errore -------------------------------------------------------- */
.error-page { min-height: 100dvh; display: grid; place-items: center; padding: 24px; text-align: center; }

/* --- Responsive --------------------------------------------------------- */
@media (max-width: 1280px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .grid-dash { grid-template-columns: minmax(0, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .board { grid-template-columns: repeat(3, minmax(240px, 1fr)); overflow-x: auto; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; width: 280px; transform: translateX(-100%); transition: transform .22s var(--ease-out); box-shadow: var(--shadow-lg); }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open::after { content: ""; position: fixed; inset: 0; background: rgb(9 9 11 / .4); z-index: 35; }
  .topbar { padding: 0 14px; }
  .topbar .menu-toggle { display: inline-flex; }
  .search-trigger { width: 36px; padding: 0; justify-content: center; }
  .search-trigger span, .search-trigger .kbd { display: none; }
  .content { padding: 18px 14px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-panel { display: none; }
  .toolbar .input-icon { width: 100%; }
  .field-row, .field-row-3 { grid-template-columns: minmax(0, 1fr); }
  .dl { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
  .dl dt { margin-top: 8px; }
  .crumbs .crumb-parent { display: none; }
  .hide-mobile { display: none !important; }
}
@media (max-width: 560px) {
  .kpis { grid-template-columns: minmax(0, 1fr); }
  .tl-item { grid-template-columns: 48px minmax(0, 1fr); }
  .tl-right { grid-column: 2; align-items: flex-start; flex-direction: row; }
  .tl-date { width: 48px; }
  .page-title { font-size: 21px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
