/* dos-magazzino — "Memphis da magazzino" (see DESIGN.md).
   Requires tokens.css + fonts/fonts.css loaded first. Calm data surfaces;
   Memphis energy only at the edges (header cluster, login, /me hero, email).
   DataTables markup is untouched: its dt-* / dtcc-* classes are only skinned. */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--border-ui) var(--canvas); }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  caret-color: var(--primary);
}

a { color: var(--primary); text-decoration: none; text-underline-offset: 3px; }
a:hover { color: var(--primary-ink); text-decoration: underline; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

h1, h2, h3 { font-family: var(--font-display); color: var(--ink); text-wrap: balance; }
h2 { margin: var(--space-6) 0 var(--space-3); font-size: 22px; font-weight: 800; letter-spacing: -.01em; }
h3 { margin: var(--space-5) 0 var(--space-2); font-size: 18px; font-weight: 700; }
code, kbd, samp { font-family: var(--font-mono); }

.muted { color: var(--muted); font-size: .92em; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Top bar: wordmark + Memphis cluster + nav (one 64px row) ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--space-6);
  min-height: 64px;
  padding: 0 var(--space-6);
  background: var(--surface);
  border-bottom: 2px solid var(--ink);
}
.brand {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  color: var(--ink);
  text-decoration: none;
  flex: 0 0 auto;
}
.brand:hover { color: var(--ink); text-decoration: none; }
.brand-word { font-family: var(--font-display); font-size: 20px; font-weight: 800; letter-spacing: .02em; line-height: 1; }
.brand-word span { font-weight: 400; }
.brand-line { display: block; width: 36px; height: 3px; margin-top: 5px; background: var(--brand); }
.memphis-cluster { flex: 0 0 auto; display: block; }
.memphis-cluster .shape { transform-box: fill-box; transform-origin: center; animation: pop-in var(--base) var(--ease) both; }
.memphis-cluster .shape:nth-child(2) { animation-delay: 60ms; }
.memphis-cluster .shape:nth-child(3) { animation-delay: 120ms; }

.tabs {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-left: auto;
  overflow-x: auto;
  scrollbar-width: none;
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 7px 12px;
  border: 2px solid transparent;
  border-radius: var(--radius-chip);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.tab:hover { background: var(--tint-grey); color: var(--ink); text-decoration: none; }
.tab.is-active { background: var(--yellow); border-color: var(--ink); }
.tab .ui-icon { width: 18px; height: 18px; }

/* ---------- Page head: title + subtitle (actions follow in .section-toolbar) ---------- */

.page-head { padding: var(--space-6) 0 var(--space-4); }
.site-title { margin: 0; font-size: 28px; font-weight: 800; line-height: 1.15; letter-spacing: -.01em; overflow-wrap: anywhere; }
.site-sub { margin: var(--space-1) 0 0; color: var(--muted); font-size: 15px; }

/* ---------- Main / cards ---------- */

.app-main { max-width: min(1280px, 100%); margin: 0 auto; padding: var(--space-2) var(--space-6) var(--space-6); }
.app-main--wide { max-width: 100%; }
.app-main--mid { max-width: min(960px, 100%); }

.app-main > section {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  padding: var(--space-5);
  margin-bottom: var(--space-6);
}
.app-main > section > h1 { margin: 0 0 var(--space-4); font-size: 22px; font-weight: 800; }
.app-main > section > h2:first-child { margin-top: 0; }
.app-main > section:first-of-type { margin-top: 0; }

/* ---------- Section toolbar (page actions + sub-navigation) ---------- */

.section-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin: 0 0 var(--space-4); }
.section-toolbar form { margin: 0; }
.section-toolbar .btn[aria-current], .section-toolbar .btn.is-active { background: var(--yellow); }

/* ---------- Buttons ---------- */
/* DataTables / ColumnControl render their own <button>s: excluded here. */

:where(button:not(.dtcc-button):not(.dt-paging-button):not(.dtcc-search-clear):not([role="tab"])),
.btn,
.btn-primary,
.btn-secondary,
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 40px;
  padding: 8px 16px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  border: 2px solid var(--ink);
  border-radius: var(--radius-control);
  box-shadow: var(--shadow-hard);
  cursor: pointer;
  transition: transform var(--fast) var(--ease), box-shadow var(--fast) var(--ease), background var(--fast) var(--ease);
}
/* Primary: a bare <button> is the form's submit = the view's next step. */
:where(button:not(.dtcc-button):not(.dt-paging-button):not(.dtcc-search-clear):not(.btn):not(.btn-secondary):not(.btn-danger):not([role="tab"])),
.btn-primary { background: var(--primary); color: #fff; }
.btn, .btn-secondary { background: var(--surface); color: var(--ink); }
.btn-danger { background: var(--surface); color: var(--error); border-color: var(--error); box-shadow: 3px 3px 0 var(--error); }

:where(button:not(.dtcc-button):not(.dt-paging-button):not(.dtcc-search-clear):not([role="tab"])):hover,
.btn:hover, .btn-primary:hover, .btn-secondary:hover, .btn-danger:hover {
  transform: translate(-1px, -1px);
  box-shadow: var(--shadow-hard-hover);
  text-decoration: none;
}
.btn:hover, .btn-secondary:hover { background: var(--tint-grey); color: var(--ink); }
.btn-primary:hover { color: #fff; }
.btn-danger:hover { box-shadow: 4px 4px 0 var(--error); color: var(--error); }
:where(button:not(.dtcc-button):not(.dt-paging-button):not(.dtcc-search-clear):not([role="tab"])):active,
.btn:active, .btn-primary:active, .btn-secondary:active, .btn-danger:active {
  transform: translate(3px, 3px);
  box-shadow: 0 0 0 var(--ink);
}
button:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
button:focus-visible, .btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }

.ui-icon { width: 20px; height: 20px; display: inline-block; flex: 0 0 auto; vertical-align: middle; pointer-events: none; }
.icon-action { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); }

/* ---------- Status chips & badges (tint + text, never colour alone) ---------- */

.chip,
.badge-expiring, .badge-expired, .badge-active, .badge-guasto,
.state-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: var(--radius-chip);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.6;
  color: var(--ink);
  background: var(--tint-grey);
  white-space: nowrap;
  text-transform: none;
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--dot, var(--muted)); }
.chip--teal, .badge-active { background: var(--tint-teal); --dot: var(--ok); }
.chip--cobalt, .state-pill { background: var(--tint-cobalt); --dot: var(--primary); }
.chip--yellow, .badge-expiring { background: var(--tint-yellow); --dot: var(--warn); }
.chip--pink, .badge-expired, .badge-guasto { background: var(--tint-pink); color: var(--error); --dot: var(--error); }
.chip--grey { background: var(--tint-grey); --dot: var(--muted); }

/* ---------- Tables (plain + DataTables skin) ---------- */

table {
  width: 100%;
  margin: var(--space-2) 0 var(--space-4);
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-control);
  overflow: hidden;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
thead th {
  background: var(--canvas);
  color: var(--muted);
  font-family: var(--font-text);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
}
th, td { height: 40px; padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--hairline); }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--fast) var(--ease); }
tbody tr:hover { background: var(--canvas); }
.assets-table td.col-serial { white-space: nowrap; font-family: var(--font-mono); }

.dt-container { margin-top: var(--space-1); }
.dt-container .dt-layout-row {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: var(--space-3); margin: 0 0 var(--space-3);
}
.dt-container .dt-layout-table { overflow-x: auto; max-width: 100%; }
/* Search input is full width; DataTables' 3px left margin pushed it past the card. */
div.dt-container div.dt-search input { margin-left: 0; }
.dt-container .dt-search label,
.dt-container .dt-length label { display: inline-flex; align-items: center; gap: var(--space-2); font-size: 14px; color: var(--muted); margin: 0; }
.dt-container .dt-search input,
.dt-container .dt-length select {
  width: auto; padding: 7px 10px; border: 1px solid var(--border-ui); border-radius: var(--radius-control);
  background: var(--surface); color: var(--ink); font: inherit;
}
.dt-container .dt-search input { min-width: min(18rem, 100%); max-width: 100%; }
.dt-container .dt-search input:focus,
.dt-container .dt-length select:focus { outline: 2px solid var(--primary); outline-offset: 2px; border-color: var(--primary); }
table.dt thead th { cursor: pointer; white-space: nowrap; }
table.dt thead th.dt-orderable-none { cursor: default; }
.dt-container .dt-info { font-size: 13px; color: var(--muted); }
.dt-container .dt-paging { display: inline-flex; flex-wrap: wrap; gap: var(--space-1); }
.dt-container .dt-paging .dt-paging-button {
  min-width: 36px; min-height: 36px; padding: 4px 10px;
  border: 1px solid var(--border-ui) !important; border-radius: var(--radius-control);
  background: var(--surface) !important; color: var(--ink) !important; font: inherit; cursor: pointer;
}
.dt-container .dt-paging .dt-paging-button:hover:not(.disabled):not(.current) { background: var(--tint-grey) !important; }
.dt-container .dt-paging .dt-paging-button.current { background: var(--yellow) !important; border: 2px solid var(--ink) !important; font-weight: 700; }
.dt-container .dt-paging .dt-paging-button.disabled { opacity: .4; cursor: default; }
.dtcc-dropdown { border-radius: var(--radius-control) !important; border: 1px solid var(--border-ui) !important; box-shadow: var(--shadow-hard) !important; font-family: var(--font-text); }

/* ---------- Forms ---------- */

label { display: block; margin: var(--space-4) 0 6px; font-weight: 600; font-size: 14px; color: var(--ink); }
input, select, textarea {
  width: 100%;
  min-height: 40px;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border-ui);
  border-radius: var(--radius-control);
  padding: 8px 12px;
  transition: border-color var(--fast) var(--ease);
}
textarea { min-height: 88px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 2px; border-color: var(--primary); }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; accent-color: var(--primary); }
[aria-invalid="true"] { border-color: var(--error); }
fieldset { border: 1px solid var(--hairline); border-radius: var(--radius-control); padding: var(--space-4); margin: var(--space-4) 0 0; }
legend {
  padding: 0 var(--space-2);
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
}

.asset-form, .movement-form { max-width: 720px; }
.movement-form > button[type="submit"], form > button[type="submit"] { margin-top: var(--space-5); }
.movement-form fieldset { background: var(--canvas); }
.movement-form fieldset > label {
  display: flex; align-items: center; gap: var(--space-3);
  margin: 0; padding: 6px 2px; font-weight: 500; cursor: pointer;
}
.movement-form fieldset input[type="checkbox"] { margin: 0; }

.accessory-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4); margin-top: var(--space-3);
  background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius-control);
}
.accessory-row > span { flex: 1 1 100%; font-weight: 600; font-size: 14px; }
.accessory-row input, .accessory-row select { flex: 1 1 9rem; width: auto; margin: 0; }

/* ---------- Flash / errors ---------- */

.flash, .auth-error, .form-error {
  display: flex; align-items: flex-start; gap: var(--space-2);
  margin: 0 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-control);
  background: var(--surface);
  font-weight: 600;
  animation: slide-in var(--base) var(--ease) both;
}
.flash::before, .auth-error::before, .form-error::before {
  content: ""; flex: 0 0 auto; width: 10px; height: 10px; margin-top: 6px; border-radius: 2px;
  background: var(--dot, var(--muted)); transform: rotate(45deg);
}
.flash-ok { background: var(--tint-teal); --dot: var(--ok); }
.flash-warn { background: var(--tint-yellow); --dot: var(--warn); }
.flash-error, .auth-error, .form-error { background: var(--tint-pink); color: var(--error); --dot: var(--error); }

/* ---------- Detail key/value lists ---------- */

.detail-dl, .movement-meta {
  display: grid;
  grid-template-columns: minmax(8rem, 12rem) 1fr;
  margin: var(--space-2) 0 var(--space-5);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-control);
  overflow: hidden;
}
.detail-dl dt, .movement-meta dt {
  padding: 10px 12px;
  background: var(--canvas);
  color: var(--muted);
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  border-bottom: 1px solid var(--hairline);
}
.detail-dl dd, .movement-meta dd { margin: 0; padding: 10px 12px; border-bottom: 1px solid var(--hairline); overflow-wrap: anywhere; }
.detail-dl dt:last-of-type, .detail-dl dd:last-of-type,
.movement-meta dt:last-of-type, .movement-meta dd:last-of-type { border-bottom: none; }
.movement-meta dd a, .detail-dl dd a { font-family: var(--font-mono); font-weight: 600; }
.asset-holder { margin: 0 0 var(--space-4); font-size: 16px; }

/* ---------- Schede: holdings summary, detail list, action rows ---------- */

.holdings-summary {
  margin: 0 0 var(--space-5); padding: var(--space-4);
  border: 1px solid var(--hairline); border-radius: var(--radius-control); background: var(--canvas);
}
.holdings-summary ul { list-style: none; margin: var(--space-1) 0 var(--space-2); padding: 0; }
.holdings-summary li {
  padding: var(--space-2) var(--space-3); margin-bottom: 6px; background: var(--surface);
  border: 1px solid var(--hairline); border-radius: var(--radius-control); font-size: 14px;
}
.holdings-label, .admin-card summary {
  margin: var(--space-3) 0 6px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
}
.scheda-detail > ul { list-style: none; margin: var(--space-2) 0 0; padding: 0; }
.scheda-detail > ul > li {
  display: flex; align-items: center; gap: var(--space-2); padding: 10px var(--space-3); margin-bottom: 6px;
  background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius-control); font-size: 14px;
}
.scheda-detail > ul > li a { font-family: var(--font-mono); font-weight: 600; }
.scheda-actions, .preview-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.scheda-actions { margin: 0 0 var(--space-2); }
.preview-actions { margin-top: var(--space-5); }
.scheda-actions form, .preview-actions form { margin: 0; }
#add-accessory-row { margin-top: var(--space-3); }

/* ---------- Filters (asset/accessory lists) ---------- */

.assets-filter { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-3); align-items: center; margin: 0 0 var(--space-5); }
.assets-filter input, .assets-filter select { width: 100%; min-width: 0; }
.assets-filter input[name="q"], .assets-filter input[name="person"] { grid-column: span 2; }
.assets-filter .filter-actions { display: flex; align-items: center; gap: var(--space-3); }
.assets-filter--inline { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.assets-filter--inline input[name="q"] { flex: 1 1 20rem; }

/* ---------- People ---------- */

.people-summary { margin: 0 0 var(--space-2); }
.people-filters { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: 0 0 var(--space-4); }
.people-filters .people-sync { display: contents; }
.miss, .flag-bad { color: var(--error); font-weight: 700; }
.flag-ok { color: var(--ok); font-weight: 700; }
.flag-none { color: var(--muted); font-weight: 700; }

/* ---------- Home launcher ---------- */

.launcher-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: var(--space-4); margin-top: var(--space-2); }
.launcher-grid .launcher-tile {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-4);
  min-height: 132px; padding: var(--space-5);
  background: var(--surface); color: var(--ink); border: 2px solid var(--ink); border-radius: var(--radius-card);
  font-family: var(--font-display); font-size: 17px; font-weight: 700; text-decoration: none;
  transition: transform var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.launcher-grid .launcher-tile:hover { transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--ink); color: var(--ink); text-decoration: none; }
.launcher-icon {
  display: flex; align-items: center; justify-content: center; width: 44px; height: 44px;
  background: var(--tint-cobalt); color: var(--ink); border-radius: var(--radius-control);
}
.launcher-icon .ui-icon { width: 24px; height: 24px; }
.launcher-auth { margin-top: var(--space-6); padding-top: var(--space-5); border-top: 1px solid var(--hairline); }
.launcher-auth form { margin: 0; }
.sketchpad-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); margin: var(--space-4) 0 var(--space-6); }

/* ---------- Licenses ---------- */

.license-nav { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-bottom: var(--space-5); }
.license-help, .license-editor { margin: var(--space-5) 0; padding: var(--space-5); border: 1px solid var(--hairline); border-radius: var(--radius-card); background: var(--surface); }
.license-help summary, .license-editor summary { cursor: pointer; font-weight: 700; font-family: var(--font-display); }
.license-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: var(--space-4); }
.license-form button { align-self: end; }
.license-revoke { display: flex; flex-wrap: wrap; align-items: end; gap: var(--space-4); margin: var(--space-4) 0; }
.license-table-wrap { overflow-x: auto; }

/* ---------- Administration ---------- */

.admin-subnav { display: flex; flex-wrap: wrap; gap: var(--space-4); margin: 0 0 var(--space-6); }
.admin-card { border: 1px solid var(--hairline); border-radius: var(--radius-card); padding: var(--space-5); margin-bottom: var(--space-6); background: var(--surface); }
.admin-card details { padding: var(--space-3) 0; border-top: 1px solid var(--hairline); }
.admin-card summary { cursor: pointer; margin: 0; color: var(--ink); }
.admin-card > h3:first-child { margin-top: 0; }
.admin-card > .detail-dl:last-child, .admin-card > .admin-table:last-child { margin-bottom: 0; }
.account-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.person-index { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-5); margin: 0 0 var(--space-5); border-bottom: 1px solid var(--hairline); }
.person-index a:not(.btn) { padding: var(--space-3) 0; color: var(--muted); font-weight: 600; text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.person-index a:not(.btn):hover, .person-index a:not(.btn):focus-visible { color: var(--ink); border-bottom-color: var(--primary); }
.person-index-action { margin-left: auto; margin-bottom: var(--space-2); }
.site-title .chip { font-size: 13px; vertical-align: middle; position: relative; top: -3px; }
.person-account-title { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin: var(--space-6) 0 var(--space-2); }
.admin-card h4 { margin: var(--space-5) 0 var(--space-2); }
.admin-form fieldset { border: 0; padding: var(--space-3) 0; background: none; }

/* ---------- Login ---------- */

.auth-login { position: relative; max-width: 440px; margin: var(--space-6) auto; overflow: hidden; }
.auth-login form > button[type="submit"], .auth-login .btn-primary { width: 100%; min-height: 48px; font-size: 16px; }
.auth-privacy { margin: var(--space-5) 0 0; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- Footer ---------- */

.site-footer {
  max-width: min(1280px, 100%); margin: 0 auto; padding: var(--space-5) var(--space-6) var(--space-6);
  color: var(--muted); font-size: 13px; border-top: 1px solid var(--hairline);
}

/* ---------- Motion ---------- */

@keyframes slide-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes pop-in { from { opacity: 0; transform: scale(.4) rotate(-30deg); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition: opacity var(--fast) linear !important; }
  button:hover, .btn:hover, .btn-primary:hover, .btn-secondary:hover, .btn-danger:hover,
  button:active, .btn:active, .btn-primary:active, .launcher-grid .launcher-tile:hover { transform: none !important; }
}

/* ---------- Small screens ---------- */

@media (max-width: 1024px) {
  .topbar { gap: var(--space-4); padding: 0 var(--space-4); }
}

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: var(--space-2) var(--space-3); padding: var(--space-3) var(--space-4) 0; min-height: 0; }
  .tabs { order: 3; flex: 1 0 100%; margin: 0 calc(-1 * var(--space-4)); padding: var(--space-2) var(--space-4) var(--space-3); }
  .tab { min-height: 44px; }
  .page-head { padding: var(--space-5) 0 var(--space-3); }
  .site-title { font-size: 24px; }
  .app-main { padding: var(--space-2) var(--space-4) var(--space-5); }
  .app-main > section { padding: var(--space-4); }
  .section-toolbar > .btn, .section-toolbar > a.btn-primary { flex: 1 1 100%; min-height: 44px; }
  .assets-filter { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .assets-filter input[name="q"], .assets-filter input[name="person"], .assets-filter .filter-actions { grid-column: span 2; }
  .detail-dl, .movement-meta { grid-template-columns: minmax(6rem, 40%) minmax(0, 1fr); }
  /* plain tables scroll inside themselves; DataTables already wraps in .dt-layout-table */
  table:not(.dt) { display: block; overflow-x: auto; white-space: nowrap; }
  .site-footer { padding: var(--space-4); }
}

/* ---------- Memphis decoration (edges only) ---------- */

.memphis-confetti { display: block; width: 220px; max-width: 60%; height: auto; }
.memphis-confetti--small { width: 140px; margin: 0 auto var(--space-3); }
.empty-state { padding: var(--space-6) var(--space-4); text-align: center; color: var(--muted); }
.empty-state p { margin: 0 0 var(--space-4); font-size: 16px; }
.auth-login .memphis-confetti { position: absolute; right: -24px; top: -12px; width: 160px; opacity: .9; pointer-events: none; }
.auth-login h2 { margin: 0 0 var(--space-4); font-size: 24px; }
.auth-google { margin: var(--space-5) 0 0; }
.auth-google .btn-primary { width: 100%; min-height: 48px; font-size: 16px; }
.auth-login form > button[type="submit"].btn { width: 100%; }
body:has(.auth-login) .page-head { text-align: center; }
.section-toolbar .toolbar-back { margin-left: auto; font-weight: 600; }
/* ColumnControl draws its own order button: hide DataTables' native arrow to avoid a double indicator. */
table.dt thead th:has(.dtcc) .dt-column-order { display: none; }
table.dt thead th .dtcc-button { min-height: 0; }

/* ---------- Licenses: triage action bar ---------- */
.triage-action { position: sticky; top: 72px; z-index: 5; background: var(--surface); margin: 0 0 var(--space-4); }
.triage-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: var(--space-3); }
.triage-grid label { margin: 0; }
.section-toolbar .btn .chip { margin-left: var(--space-1); }

/* ---------- Licenses: service page (mini-CRM) ---------- */
.svc-flags { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: calc(-1 * var(--space-2)) 0 var(--space-3); }
.svc-tabs { display: flex; gap: var(--space-1); border-bottom: 2px solid var(--ink); margin: 0 0 var(--space-5); overflow-x: auto; }
.svc-tabs [role="tab"] {
  padding: 10px 14px; font-family: var(--font-display); font-weight: 700; font-size: 14px; color: var(--ink);
  border: 2px solid transparent; border-bottom: 0; border-radius: var(--radius-control) var(--radius-control) 0 0; white-space: nowrap;
}
.svc-tabs [role="tab"]:hover { background: var(--tint-grey); text-decoration: none; }
.svc-tabs [role="tab"][aria-selected="true"] { background: var(--yellow); border-color: var(--ink); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: var(--space-6); }
.grid2 h2 { margin-top: 0; }
.seatbar { display: flex; height: 10px; width: 100%; max-width: 280px; background: var(--tint-teal); border: 1px solid var(--ink); border-radius: var(--radius-chip); overflow: hidden; }
.seatbar .used { background: var(--primary); } .seatbar .releasing { background: var(--yellow); }
.seatnums { display: block; margin-top: var(--space-1); font-size: 13px; color: var(--muted); }
.legend { display: flex; gap: var(--space-4); font-size: 13px; color: var(--muted); margin: 0 0 var(--space-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border: 1px solid var(--ink); border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.lg-used { background: var(--primary); } .lg-rel { background: var(--yellow); } .lg-free { background: var(--tint-teal); }
.num { text-align: right; white-space: nowrap; }
.actions { text-align: right; white-space: nowrap; }
.btn-sm { min-height: 32px !important; padding: 4px 10px !important; font-size: 13px !important; box-shadow: 2px 2px 0 var(--ink) !important; }
.btn-danger.btn-sm { box-shadow: 2px 2px 0 var(--error) !important; }
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.inline-form input, .inline-form select { width: auto; min-width: 0; }
.inline-form input[name="unit_cost"] { width: 7rem; } .inline-form .currency { width: 4.5rem; }
.inline-form input[name="reason"] { width: 10rem; }
.svc-edit { margin: var(--space-5) 0 0; padding: var(--space-4); border: 1px solid var(--hairline); border-radius: var(--radius-card); }
.svc-edit summary { cursor: pointer; font-family: var(--font-display); font-weight: 700; }
label.check { display: flex; align-items: center; gap: var(--space-2); font-weight: 500; }
.assign-box { margin: 0 0 var(--space-6); padding: var(--space-4); background: var(--canvas); border: 1px solid var(--hairline); border-radius: var(--radius-card); }
.assign-box h2 { margin-top: 0; }
.basket-choice label { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin: var(--space-2) 0; font-weight: 500; }
.basket-choice label.is-full { color: var(--muted); }
.simulate { max-width: 760px; margin: 0 0 var(--space-4); padding: var(--space-4); border: 1px solid var(--hairline); border-radius: var(--radius-card); background: var(--canvas); }
.simulate > label { margin-top: 0; }
.org, .org ul { list-style: none; margin: 0; padding-left: 22px; border-left: 1px solid var(--border-ui); }
.org { padding-left: 0; border-left: 0; }
.org li { margin: 4px 0; }
.org summary { list-style: none; cursor: pointer; }
.org summary::-webkit-details-marker { display: none; }
.org-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 6px 10px; border-radius: var(--radius-control); }
.org summary .org-head::before { content: "▸"; font-size: 12px; color: var(--muted); transition: transform var(--fast) var(--ease); }
.org details[open] > summary .org-head::before { transform: rotate(90deg); }
.org-head.leaf { padding-left: 26px; }
.org summary:hover .org-head { background: var(--tint-grey); }
.node-name { font-family: var(--font-display); font-weight: 700; }
.node-sub { flex-basis: 100%; font-size: 12px; color: var(--muted); }
.org li.on-path > details > summary .org-head, .org li.on-path > .org-head { background: var(--tint-cobalt); }
.org li.charged > details > summary .org-head, .org li.charged > .org-head { background: var(--yellow); outline: 2px solid var(--ink); }
.org li.can-scale > details > summary .org-head, .org li.can-scale > .org-head { background: var(--tint-teal); }

/* ---------- Licenses: cost report ---------- */
.cost-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: var(--space-4); margin: 0 0 var(--space-5); }
.cost-summary > div { padding: var(--space-4); border: 1px solid var(--hairline); border-radius: var(--radius-card); background: var(--canvas); }
.cost-label { display: block; margin-bottom: var(--space-1); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.cost-summary strong { font-family: var(--font-display); font-size: 22px; }
.cost-table td, .cost-table th[scope="row"] { vertical-align: top; }
.cost-table tbody th[scope="row"], .cost-table tfoot th { text-align: left; font-weight: 700; }
.cost-table .it-row { background: var(--canvas); }
.cost-table tfoot td, .cost-table tfoot th { border-top: 2px solid var(--ink); }
.toolbar-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }

.inline-form .seats-input { width: 7rem; }

/* ---------- Licenses home: service cards ---------- */
.svc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: var(--space-4); }
.svc-card {
  display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-5);
  color: var(--ink); background: var(--surface); border: 2px solid var(--ink); border-radius: var(--radius-card);
  text-decoration: none; transition: transform var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.svc-card:hover { color: var(--ink); text-decoration: none; transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--ink); }
.svc-card-name { font-family: var(--font-display); font-size: 20px; font-weight: 800; }
.svc-card-cost { font-family: var(--font-display); font-weight: 700; }
.svc-card-types { display: flex; flex-direction: column; font-size: 14px; color: var(--muted); }
.svc-card-flags { display: flex; flex-wrap: wrap; gap: var(--space-1); margin-top: auto; }
@media (prefers-reduced-motion: reduce) { .svc-card:hover { transform: none; } }

/* ---------- Licenses: order queue ---------- */
.order-list { display: grid; gap: var(--space-4); }
.order-card { padding: var(--space-4); border: 1px solid var(--hairline); border-radius: var(--radius-card); background: var(--surface); }
.order-card header { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); }
.order-card h2 { margin: 0; font-size: 18px; }
.order-note { margin: var(--space-2) 0 0; font-style: italic; color: var(--muted); }
.order-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: var(--space-4); align-items: start; margin-top: var(--space-3); }
.order-actions fieldset { margin: 0 0 var(--space-3); }
.order-actions .inline-form input { flex: 1 1 14rem; width: auto; }

/* ---------- Service icons (brand SVG or monogram) ---------- */
.svc-icon { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  width: 32px; height: 32px; margin-right: var(--space-2); border: 2px solid var(--ink); border-radius: var(--radius-control);
  background: var(--surface); font-family: var(--font-display); font-weight: 800; font-size: 16px; color: var(--ink); vertical-align: middle; }
.svc-icon img { width: 18px; height: 18px; }
.svc-icon--lg { width: 44px; height: 44px; font-size: 22px; }
.svc-icon--lg img { width: 26px; height: 26px; }
.svc-icon--yellow { background: var(--yellow); } .svc-icon--teal { background: var(--teal); }
.svc-icon--pink { background: var(--pink); } .svc-icon--cobalt { background: var(--tint-cobalt); }
.svc-icon--zeroheight { background: var(--brand-zeroheight); color: #fff; text-transform: none; }
.svc-card-name { display: inline-flex; align-items: center; }

/* ---------- Assets: ABM devices to register ---------- */
.app-main > section.abm-pending { border: 2px solid var(--ink); background: var(--tint-yellow); }
.abm-pending h2 { margin-top: 0; }
.abm-pending table { background: var(--surface); }

/* Row actions on dense license tables: one "Gestisci" disclosure instead of
   inline forms per column, so the table keeps a sane width. */
.row-actions summary { list-style: none; display: inline-flex; cursor: pointer; white-space: nowrap; }
.row-actions summary::-webkit-details-marker { display: none; }
.row-actions-panel { display: grid; gap: var(--space-2); width: 13rem; margin-top: var(--space-2); }
.row-actions-panel .inline-form { flex-wrap: wrap; }
#holders-table td { overflow-wrap: anywhere; }
.row-actions-panel .inline-form select, .row-actions-panel .inline-form input[name="reason"] { flex: 1; width: auto; min-width: 0; }
.dt-export { display: flex; gap: var(--space-2); justify-content: flex-end; margin: 0 0 var(--space-2); }

/* ---------- Anagrafica: connected Google apps ---------- */
.apps-head { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.apps-head h2 { margin: 0; }
.apps-head .btn { margin-left: auto; }
.help-inline { position: relative; }
.help-inline summary {
  display: grid; place-items: center; width: 24px; height: 24px; list-style: none; cursor: pointer;
  border: 1px solid var(--border-ui); border-radius: 50%; font-size: 13px; font-weight: 700; color: var(--muted);
}
.help-inline summary::-webkit-details-marker { display: none; }
.help-inline[open] summary { border-color: var(--ink); color: var(--ink); }
.help-inline p {
  position: absolute; z-index: 20; top: 32px; left: 0; width: min(420px, 80vw); margin: 0; padding: 12px 14px;
  border: 2px solid var(--ink); border-radius: var(--radius-card); background: var(--surface); box-shadow: var(--shadow-hard);
  font-size: 14px; line-height: 1.45;
}
.scope-table td code { font-family: var(--font-mono); font-size: 13px; color: var(--muted); }
.scope-level { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--tint-grey); }
.scope-level--lettura { background: var(--tint-yellow); }
.scope-level--modifica { background: var(--tint-pink); }
.scope-level--completo { background: var(--error); color: var(--surface); }
.apps-search { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; margin: var(--space-3) 0; }
.apps-search label { font-weight: 600; }
.apps-search > input, .apps-search .autocomplete { flex: 1; min-width: 220px; max-width: 420px; }
.apps-search .btn { margin: 0; }
/* Inline autocomplete list (static/js/autocomplete.js), same pattern as dos-rda's profile search. */
.autocomplete { position: relative; flex: 1; min-width: 220px; max-width: 420px; }
.autocomplete input { width: 100%; }
.autocomplete-list {
  position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; right: 0; max-height: 320px; overflow: auto;
  margin: 0; padding: 0; list-style: none;
  border: 1px solid var(--border-ui); border-radius: var(--radius-control); background: var(--surface); box-shadow: var(--shadow-hard);
}
.autocomplete-choice {
  display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  padding: 8px 12px; border-bottom: 1px solid var(--hairline); cursor: pointer;
}
.autocomplete-choice:last-child { border-bottom: 0; }
.autocomplete-choice:hover, .autocomplete-choice[aria-selected="true"] { background: var(--tint-cobalt); }
.autocomplete-initials {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary); color: var(--surface); font-size: 12px; font-weight: 700;
}
.autocomplete-copy { display: grid; gap: 2px; min-width: 0; }
.autocomplete-copy strong, .autocomplete-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.autocomplete-copy strong { font-size: 14px; }
.autocomplete-copy small { color: var(--muted); font-size: 12px; }
.autocomplete-action { color: var(--primary-ink); font-size: 12px; font-weight: 700; }
.autocomplete-help { padding: 10px 12px; color: var(--muted); font-size: 13px; }
/* Anagrafica → Sicurezza */
.security-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--space-2); margin: var(--space-3) 0; }
.security-stat {
  display: grid; gap: 4px; padding: 14px 16px; text-decoration: none; color: var(--ink);
  border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface);
}
.security-stat strong { font-family: var(--font-display); font-size: 28px; line-height: 1; }
.security-stat span { font-size: 13px; color: var(--muted); }
.security-stat:hover { border-color: var(--ink); }
.security-stat--warn { background: var(--tint-yellow); border-color: var(--ink); }
.security-stat--alert { background: var(--tint-pink); border: 2px solid var(--error); }
.security-stat--alert strong { color: var(--error); }
.text-error { color: var(--error); }
