/* Compatibilita desktop condivisa: Windows 10/11 e macOS, Chrome/Edge/Safari/Firefox. */
:root {
  color-scheme: dark;
  --platform-font: -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --platform-mono: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --platform-scrollbar: #315f98;
  --platform-scrollbar-track: rgba(5, 13, 24, .72);
}

html {
  min-width: 0;
  min-height: 100%;
  font-family: var(--platform-font);
  font-synthesis: none;
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scrollbar-color: var(--platform-scrollbar) var(--platform-scrollbar-track);
  scrollbar-width: thin;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--platform-font);
}

button, input, select, textarea, optgroup {
  min-width: 0;
  max-width: 100%;
  font: inherit;
  letter-spacing: inherit;
}

button, [role="button"], a.button, a.btn {
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button:not(:disabled), [role="button"]:not([aria-disabled="true"]),
input[type="date"]:not(:disabled), input[type="datetime-local"]:not(:disabled) { cursor: pointer; }

button:disabled, input:disabled, select:disabled, textarea:disabled {
  cursor: not-allowed;
  opacity: .62;
}

:where(button, a, input, select, textarea, [tabindex]):focus-visible {
  outline: 3px solid rgba(111, 169, 232, .82);
  outline-offset: 2px;
}

input, select, textarea {
  background-clip: padding-box;
  border-radius: max(0px, var(--input-radius, 8px));
}

input[type="date"], input[type="datetime-local"], input[type="month"], input[type="time"] {
  min-height: 42px;
  padding-inline-end: 10px;
}

input::-webkit-calendar-picker-indicator {
  display: block;
  width: 18px;
  height: 18px;
  opacity: .9;
  cursor: pointer;
  filter: invert(.85) sepia(.15) saturate(.5);
}

input[type="number"] { font-variant-numeric: tabular-nums; }

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

th, td { min-width: 0; }

thead th,
tbody td,
tfoot th,
tfoot td {
  box-sizing: border-box;
  vertical-align: middle;
}

:where(td.numeric, th.numeric, td.num, th.num, td.number, th.number) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

:where(td.actions, th.actions, td.action, th.action, td.colActions, th.colActions) {
  text-align: right;
}

:where(td:last-child .row-actions, td:last-child .rowActions) {
  flex-wrap: nowrap;
  justify-content: flex-end;
}

.table-wrap, .tableWrap, .table-scroll,
[class*="table-container"], [class*="table-wrapper"] {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}

dialog {
  max-width: min(1100px, calc(100vw - 32px));
  max-height: min(920px, calc(100vh - 32px));
  max-height: min(920px, calc(100dvh - 32px));
}

dialog::backdrop {
  background: rgba(1, 7, 15, .76);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}

img, svg, canvas, video { max-width: 100%; }

/* Scrollbar coerenti e sempre individuabili su Windows e nei browser Chromium. */
*::-webkit-scrollbar { width: 12px; height: 12px; }
*::-webkit-scrollbar-track { background: var(--platform-scrollbar-track); }
*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #4d83bd, #244d7c);
  border: 3px solid var(--platform-scrollbar-track);
  border-radius: 999px;
}
*::-webkit-scrollbar-thumb:hover { background: linear-gradient(180deg, #68a0dc, #315f98); }

/* Safari/macOS: evita tagli e trasparenze non supportate. */
@supports (-webkit-touch-callout: none) {
  body { -webkit-text-size-adjust: 100%; }
  input[type="checkbox"], input[type="radio"] { -webkit-appearance: auto; appearance: auto; }
  select { -webkit-appearance: menulist; appearance: auto; }
  input[type="date"], input[type="datetime-local"], input[type="month"], input[type="time"] {
    -webkit-appearance: auto;
    appearance: auto;
  }
  .sidebar, .topbar, .portal-tabs, dialog::backdrop {
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
  }
}

/* Portatili Windows/Mac e finestre affiancate: mantiene il desktop leggibile. */
@media (min-width: 901px) and (max-width: 1440px) {
  :where(.main, main, .workspace) { min-width: 0; }
  :where(.topbar-actions, .top-actions, .header-actions, .cloud-actions, .actions) {
    flex-wrap: wrap;
  }
  :where(.filters, .filters-bar, .filter-panel, .form-grid) > * { min-width: 0; }
}

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

@media print {
  :root { color-scheme: light; }
  html, body { min-height: auto; font-family: Arial, Helvetica, sans-serif; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  dialog:not([open]) { display: none !important; }
}
