/* Reweke Tickets — design system (shared with the Trade Portal) (brand: Deep Teal #1A7A7A, Mint #4ECDC4, White, Slate #F4F6F9) */
@font-face { font-family: "Inter"; src: url("/fonts/inter-latin-wght-normal.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Plus Jakarta Sans"; src: url("/fonts/plus-jakarta-sans-latin-wght-normal.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }

:root {
  --brand: #1A7A7A; --brand-700: #136262; --brand-100: #D5EEEE; --brand-50: #EDF7F7; --mint: #4ECDC4;
  --bg: #FFFFFF; --soft: #F4F6F9; --line: #E4E9EF; --line-strong: #CFD7E0;
  --text: #0E1B2C; --muted: #5D6B7C; --faint: #8794A3;
  --danger: #C0362C; --danger-50: #FDEDEB; --warn: #B45309; --warn-50: #FEF3E2; --ok: #1E7B4B; --ok-50: #E6F5EC; --info: #2456C7; --info-50: #E8EFFD;
  --radius: 12px; --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06); --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  --sidebar: 248px; --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; --font-head: "Plus Jakarta Sans", var(--font);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { font-family: var(--font-head); font-weight: 650; letter-spacing: -.01em; margin: 0; color: var(--text); }
h1 { font-size: 24px; } h2 { font-size: 18px; } h3 { font-size: 15px; }
a { color: var(--brand); text-decoration: none; } a:hover { text-decoration: underline; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 12.5px; } .strong { font-weight: 600; }
.hidden { display: none !important; } .nowrap { white-space: nowrap; } .right { text-align: right; } .grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; } .row.between { justify-content: space-between; } .row.end { justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: 12px; } .gap-lg { gap: 20px; }
.mt { margin-top: 16px; } .mb { margin-bottom: 16px; } .mono { font-variant-numeric: tabular-nums; }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 20px 14px 14px; border-right: 1px solid var(--line); background: var(--bg); z-index: 30; }
.sidebar .logo { display: block; padding: 4px 8px 22px; } .sidebar .logo img { width: 150px; height: auto; display: block; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; color: var(--muted); font-weight: 500; text-decoration: none; position: relative; }
.nav a:hover { background: var(--soft); color: var(--text); }
.nav a.active { background: var(--brand-50); color: var(--brand); font-weight: 600; }
.nav a.active::before { content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--mint); }
.nav .label { margin: 16px 12px 6px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
.sidebar .foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
.usercard { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-100); color: var(--brand-700); display: grid; place-items: center; font-weight: 700; flex: none; }
.usercard .who { line-height: 1.25; min-width: 0; } .usercard .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.foot .links { display: flex; gap: 6px; margin-top: 6px; } .foot .ver { margin: 8px 8px 0; font-size: 11.5px; color: var(--faint); }
.main { min-width: 0; }
.topbar { display: none; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 20; }
.topbar img { height: 26px; }
.content { max-width: 1320px; margin: 0 auto; padding: 28px 32px 90px; }
.scrim { display: none; }

/* ---------- Components ---------- */
.card { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 16px; }
.card > h3:first-child, .card-head { margin-bottom: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.crumb { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); margin-bottom: 8px; font-weight: 500; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 15px; border-radius: 9px; border: 1px solid var(--brand); background: var(--brand); color: #fff; font: 600 13.5px var(--font); cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .12s, box-shadow .12s; }
.btn:hover { background: var(--brand-700); text-decoration: none; }
.btn:focus-visible, .nav a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible { outline: 3px solid rgba(78, 205, 196, .55); outline-offset: 1px; }
.btn.secondary { background: var(--bg); color: var(--text); border-color: var(--line-strong); } .btn.secondary:hover { background: var(--soft); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); } .btn.ghost:hover { background: var(--soft); color: var(--text); }
.btn.danger { background: var(--danger); border-color: var(--danger); } .btn.danger:hover { background: #a02b22; }
.btn.warn { background: var(--warn); border-color: var(--warn); } .btn.warn:hover { background: #92400e; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; } .btn.icon { width: 34px; padding: 0; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.ico { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

input, select, textarea { font: 14px var(--font); color: var(--text); background: var(--bg); border: 1px solid var(--line-strong); border-radius: 8px; padding: 8px 10px; height: 38px; width: 100%; }
textarea { height: auto; min-height: 84px; resize: vertical; line-height: 1.45; }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--brand); padding: 0; }
input[type=file] { height: auto; padding: 6px; }
input[type=number] { text-align: right; }
input:disabled, select:disabled { background: var(--soft); color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--faint); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--soft); color: var(--muted); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.draft { background: var(--soft); color: var(--muted); } .badge.submitted { background: var(--info-50); color: var(--info); }
.badge.returned { background: var(--warn-50); color: var(--warn); } .badge.finalized { background: var(--ok-50); color: var(--ok); }
.badge.declined { background: var(--danger-50); color: var(--danger); }
.badge.accepted { background: var(--ok-50); color: var(--ok); }
.badge.ok { background: var(--ok-50); color: var(--ok); } .badge.off { background: var(--soft); color: var(--faint); } .badge.bad { background: var(--danger-50); color: var(--danger); }
.badge.plain::before { display: none; } .badge.role { background: var(--brand-50); color: var(--brand-700); }
.chip { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--soft); font-size: 11.5px; color: var(--muted); margin: 2px 4px 2px 0; }

.notice { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; display: flex; gap: 10px; align-items: flex-start; }
.notice.info { background: var(--info-50); color: #1c419a; } .notice.warn { background: var(--warn-50); color: #7c3a06; } .notice.err { background: var(--danger-50); color: #8f2820; } .notice.ok { background: var(--ok-50); color: #155c39; }
.notice b { display: block; }

/* tables */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--bg); white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--soft); }
th.num, td.num { text-align: right; } td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
/* Il kit è la riga di prezzo che conta: più prominente (sfondo, bordo colorato, cifre più grandi). */
tr.kit-head td { background: var(--brand-50); font-weight: 600; color: var(--brand-700); border-bottom: 1px solid var(--brand-100); border-top: 2px solid var(--brand-100); }
tr.kit-head:first-child td { border-top-color: transparent; }
tr.kit-head td.num { color: var(--brand-700); font-size: 14px; }
tr.kit-head td.strong.num { font-size: 15px; font-weight: 700; }
tr.kit-head.plain td { font-weight: 600; color: var(--muted); background: var(--soft); font-size: 12.5px; }
tr.kit-head .badge.role.plain { background: var(--brand); color: #fff; font-weight: 700; }
/* I componenti di un kit restano sempre inseriti con il proprio prezzo (bill of materials), ma sono
   visivamente secondari: il totale che conta è quello del kit, non la somma di queste righe. */
tr.kit-member td:not(.num) { color: var(--muted); }
tr.kit-member td.num.faint { font-style: italic; }

/* KPI / totals */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.kpi { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; background: var(--bg); }
.kpi .k { font-size: 12.5px; color: var(--muted); font-weight: 500; } .kpi .v { font-family: var(--font-head); font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; } .kpi .s { font-size: 12px; color: var(--faint); }
.kpi.brand { background: var(--brand); border-color: var(--brand); } .kpi.brand .k, .kpi.brand .v, .kpi.brand .s { color: #fff; } .kpi.brand .s { opacity: .8; }
.kpi.soft { background: var(--brand-50); border-color: var(--brand-100); }

.timeline { list-style: none; margin: 0; padding: 0 0 0 4px; }
.timeline li { position: relative; padding: 0 0 16px 22px; border-left: 2px solid var(--line); margin-left: 6px; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--bg); border: 3px solid var(--mint); }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline .when { color: var(--faint); font-size: 12px; } .timeline ul.changes { margin: 6px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
.bubble { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--bg); }
.bubble.reweke { background: var(--warn-50); border-color: #f5d9a8; } .bubble.trade { background: var(--brand-50); border-color: var(--brand-100); }
.bubble .who { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.bubble p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

.actionbar { position: sticky; bottom: 0; margin: 20px -32px -90px; padding: 12px 32px; background: rgba(255, 255, 255, .96); backdrop-filter: blur(6px); border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; align-items: center; flex-wrap: wrap; z-index: 10; }
.actionbar .msg { margin-right: auto; color: var(--muted); font-size: 13px; }

dialog { border: 0; border-radius: 16px; padding: 0; width: min(520px, 94vw); box-shadow: var(--shadow-lg); color: var(--text); }
dialog::backdrop { background: rgba(8, 16, 28, .5); }
dialog form, dialog .dlg { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
dialog h2 { margin-bottom: 2px; }
.toasts { position: fixed; right: 16px; top: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--text); color: #fff; padding: 11px 14px; border-radius: 10px; box-shadow: var(--shadow-lg); font-weight: 500; animation: pop .18s ease-out; }
.toast.ok { background: var(--ok); } .toast.err { background: var(--danger); }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }
.loading { display: grid; place-items: center; padding: 60px; color: var(--muted); }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--brand-100); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; align-items: end; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 14px; }
.perm-grid > div { border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
details.more summary { cursor: pointer; color: var(--brand); font-size: 12.5px; }
.secret-note { font-size: 12px; color: var(--faint); }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 46%) 1fr; }
.auth-hero { background: linear-gradient(155deg, #1A7A7A 0%, #0f5252 70%); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-hero img { width: 210px; }
.auth-hero h1 { color: #fff; font-size: 34px; line-height: 1.15; max-width: 440px; } .auth-hero p { color: #cdeeea; max-width: 420px; font-size: 15px; }
.auth-hero ul { list-style: none; padding: 0; margin: 22px 0 0; display: grid; gap: 10px; color: #e4f6f4; } .auth-hero li::before { content: "✓"; color: var(--mint); font-weight: 800; margin-right: 10px; }
.auth-form { display: grid; place-items: center; padding: 32px; }
.auth-form .box { width: min(400px, 100%); display: flex; flex-direction: column; gap: 16px; }
.auth-form .mobile-logo { display: none; width: 160px; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 280px; transform: translateX(-102%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  .nav-open .sidebar { transform: none; }
  .nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(8, 16, 28, .45); z-index: 25; }
  .topbar { display: flex; }
  .content { padding: 20px 16px 90px; }
  .actionbar { margin: 20px -16px -90px; padding: 10px 16px; }
  .auth { grid-template-columns: 1fr; } .auth-hero { display: none; } .auth-form .mobile-logo { display: block; }
}
@media (max-width: 860px) {
  .rtable thead { display: none; }
  .rtable, .rtable tbody, .rtable tr, .rtable td { display: block; width: 100%; }
  .rtable tr { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; margin-bottom: 10px; background: var(--bg); box-shadow: var(--shadow); }
  .rtable tr.kit-head { background: var(--brand-50); }
  .rtable td { display: flex; justify-content: space-between; align-items: center; gap: 14px; border: 0; padding: 6px 0; text-align: right; }
  .rtable td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; text-align: left; flex: 0 0 38%; }
  .rtable td.nolabel::before { display: none; } .rtable td.nolabel { justify-content: flex-start; }
  .rtable td > input, .rtable td > select { max-width: 60%; } .rtable td.num { white-space: normal; }
  .rtable tr.kit-head td { justify-content: space-between; }
  .items input, .items select { max-width: 62%; min-width: 0; } .items .w-code, .items .w-desc, .items .w-num { min-width: 0; }
  .tablewrap { overflow-x: visible; }
  h1 { font-size: 21px; } .kpi .v { font-size: 19px; }
  .stepper .step-line { width: 14px; }
}
@media print { .sidebar, .topbar, .actionbar, .btn { display: none !important; } .shell { display: block; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* delta highlight (history) */
.delta-up { color: var(--danger); font-weight: 600; }
.delta-down { color: var(--ok); font-weight: 600; }
.w-num { width: 110px; }
.hidden { display: none !important; }

/* inline controls inside flex rows keep their natural width (kit header, exchange-rate row) */
.row > input, .row > select { width: auto; flex: 0 1 auto; }
.row > input.w-desc { width: 260px; max-width: 100%; }
.row > input.w-num { width: 96px; }
@media (max-width: 860px) { .toasts { left: 16px; right: 16px; top: 12px; max-width: none; } }

/* clients: removed-from-CRM rows */
tr.row-inactive td { opacity: .55; }
tr.row-inactive .badge.bad { opacity: 1; }

/* ======================= Reweke Tickets ======================= */
/* header: always visible, carries the notification bell */
.topbar { display: flex; justify-content: flex-end; }
.topbar .menu-btn, .topbar .top-logo { display: none; }
.bell-wrap { position: relative; }
#bell { position: relative; }
.bell-count { position: absolute; top: 0; right: 0; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.popover { position: absolute; right: 0; top: 42px; width: min(380px, calc(100vw - 24px)); background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 40; overflow: hidden; }
.pop-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.pop-foot { padding: 10px 14px; border-top: 1px solid var(--line); text-align: center; }
.pop-list { max-height: 360px; overflow-y: auto; }
.pad { padding: 16px; }
.notif { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none; }
.notif:hover { background: var(--soft); text-decoration: none; }
.notif .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; flex: none; background: transparent; }
.notif.unread { background: var(--brand-50); } .notif.unread .dot { background: var(--brand); }
.card.pop-list { padding: 0; max-height: none; }

/* status and priority badges */
.badge.st-open { background: var(--info-50); color: var(--info); } .badge.st-in_progress { background: var(--brand-50); color: var(--brand-700); }
.badge.st-on_hold { background: var(--warn-50); color: var(--warn); } .badge.st-resolved { background: var(--ok-50); color: var(--ok); }
.badge.st-cancelled { background: var(--soft); color: var(--faint); }
.badge.prio::before { display: none; }
.badge.prio-low { background: var(--soft); color: var(--muted); } .badge.prio-normal { background: var(--info-50); color: var(--info); }
.badge.prio-high { background: var(--warn-50); color: var(--warn); } .badge.prio-urgent { background: var(--danger-50); color: var(--danger); }
.chip { display: inline-flex; align-items: center; gap: 4px; } .chip .ico { width: 13px; height: 13px; }
.chip.warn { background: var(--warn-50); color: var(--warn); }
.chip.vis-internal { background: var(--warn-50); color: var(--warn); } .chip.vis-public { background: var(--ok-50); color: var(--ok); }

/* KPI cards that link to filtered lists */
a.kpi.link { color: inherit; text-decoration: none; transition: border-color .12s, box-shadow .12s; }
a.kpi.link:hover { border-color: var(--brand); box-shadow: var(--shadow); }
.kpi.warn .v { color: var(--danger); } .kpi.soft { background: var(--brand-50); border-color: var(--brand-100); }

/* filters */
.filters .wide { grid-column: span 2; }
.check, .radio { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.check input, .radio input { flex: none; }
.overdue { color: var(--danger); font-weight: 600; }
.or { display: flex; align-items: center; gap: 10px; color: var(--faint); font-size: 12.5px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ticket detail */
.ticket-head { display: flex; gap: 16px; margin-bottom: 20px; }
.ticket-head h1 { margin: 6px 0 8px; overflow-wrap: anywhere; }
.sub { gap: 16px; } .owner { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; } .owner.none { color: var(--warn); font-weight: 600; }
.ticket-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.ticket-main > .card + .card, .ticket-side > .card + .card { margin-top: 16px; }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
.facts { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; margin: 0; }
.facts dt { color: var(--muted); font-size: 12.5px; font-weight: 600; } .facts dd { margin: 0; overflow-wrap: anywhere; }
ul.plain { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.files { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.file { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); text-decoration: none; min-width: 0; }
.file span:first-of-type { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; } .file:hover { background: var(--soft); border-color: var(--line-strong); }
.entry-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.entry .when { color: var(--faint); font-size: 12px; margin-left: auto; }
.entry .bubble { margin-top: 8px; } .bubble.internal { background: var(--warn-50); border-color: #f5d9a8; }
.timeline .entry ul.changes { margin: 6px 0 0; }
fieldset.vis { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px 10px; display: flex; flex-wrap: wrap; gap: 8px 22px; }
fieldset.vis legend { font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 0 6px; }

/* autocomplete picker */
.picker { position: relative; }
.picked { display: flex; align-items: center; justify-content: space-between; gap: 8px; border: 1px solid var(--line-strong); border-radius: 8px; padding: 0 4px 0 12px; min-height: 38px; background: var(--brand-50); font-weight: 600; }
.ac-list { position: absolute; z-index: 30; left: 0; right: 0; top: 42px; margin: 0; padding: 4px; list-style: none; background: var(--bg); border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: var(--shadow-lg); max-height: 280px; overflow-y: auto; }
.ac-list li { padding: 8px 10px; border-radius: 7px; cursor: pointer; display: flex; flex-direction: column; }
.ac-list li.on, .ac-list li:hover { background: var(--brand-50); } .ac-list li.none { cursor: default; }
.link-row { display: grid; grid-template-columns: 150px 1fr 1fr 1.4fr 34px; gap: 8px; align-items: center; }

@media (max-width: 1000px) {
  .topbar .menu-btn, .topbar .top-logo { display: inline-flex; } .topbar .top-logo { display: block; }
  .ticket-grid { grid-template-columns: 1fr; }
  .link-row { grid-template-columns: 1fr 1fr; } .link-row select { grid-column: span 2; }
  .filters .wide { grid-column: auto; }
  .popover { position: fixed; left: 12px; right: 12px; top: 56px; width: auto; }
}
.kpi.link .k { color: var(--muted); }
.timeline ul.changes { list-style: disc; }
.timeline ul.changes li { border: 0; padding: 0; margin: 0; }
.timeline ul.changes li::before { display: none; }
details.filterbox > summary { cursor: pointer; font-weight: 600; color: var(--brand); list-style: none; }
details.filterbox > summary::-webkit-details-marker { display: none; }
@media (min-width: 861px) { details.filterbox > summary { display: none; } }

/* Selettore lingua e testo solo per screen reader */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.lang-pick select { font: inherit; font-size: 13px; padding: 5px 8px; border: 1px solid var(--line, #d7dde5); border-radius: 8px; background: transparent; color: inherit; cursor: pointer; }

/* ---------- Budget & Forecast ---------- */
.nav a .ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 9px 14px; font: 600 13.5px var(--font); color: var(--muted); cursor: pointer; }
.tabs button.on { color: var(--brand); border-bottom-color: var(--mint); }
.grid-table td, .grid-table th { padding: 6px 8px; white-space: nowrap; }
.grid-table td.lbl, .grid-table th.lbl { position: sticky; left: 0; background: var(--bg); z-index: 1; min-width: 210px; white-space: normal; }
.grid-table input { height: 30px; width: 74px; padding: 3px 6px; font-size: 13px; }
.grid-table input.pct { width: 60px; }
.grid-table tr.total td { font-weight: 700; background: var(--soft); border-top: 2px solid var(--line-strong); }
.grid-table tr.sub td { color: var(--muted); }
.grid-table tr.ebitda td { font-weight: 700; background: var(--brand-50); }
.neg { color: var(--danger); } .pos { color: var(--ok); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.pill.a { background: var(--brand-50); color: var(--brand-700); } .pill.m { background: var(--soft); color: var(--muted); }
.bar { height: 10px; border-radius: 6px; background: var(--soft); overflow: hidden; min-width: 120px; }
.bar > i { display: block; height: 100%; background: var(--brand); } .bar > i.warn { background: #E0A100; } .bar > i.bad { background: var(--danger); }
.stackbar { display: flex; height: 22px; border-radius: 6px; overflow: hidden; background: var(--soft); }
.stackbar > i { display: block; height: 100%; } .c1 { background: #1A7A7A; } .c2 { background: #4ECDC4; } .c3 { background: #B6E6E2; } .c4 { background: #CFD7E0; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin: 8px 0; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; } .three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 1000px) { .two, .three { grid-template-columns: 1fr; } }
.stepline { display: flex; flex-direction: column; gap: 10px; }
.stepline .it { display: grid; grid-template-columns: 28px 1fr auto; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.stepline .it .n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--soft); font-weight: 700; font-size: 12px; color: var(--muted); }
.stepline .it.done .n { background: var(--brand); color: #fff; } .stepline .it.run .n { background: var(--mint); color: #063; }
.stepline .it.late { border-color: #F1C9A0; background: #FFFAF3; }
.alert-row { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--line); }
.alert-row:last-child { border-bottom: 0; }
svg.chart { width: 100%; height: 260px; display: block; }
svg.chart text { font: 11px var(--font); fill: #5D6B7C; } svg.chart .grid { stroke: #E4E9EF; stroke-width: 1; }
.note-box { border: 1px dashed var(--line-strong); border-radius: 10px; padding: 10px 12px; background: #FBFCFD; color: var(--muted); font-size: 12.5px; }
.calc { font-variant-numeric: tabular-nums; background: var(--soft); border-radius: 8px; padding: 10px 12px; }
.kbd { font-family: ui-monospace, Consolas, monospace; font-size: 12px; background: var(--soft); padding: 1px 6px; border-radius: 5px; }
.locked-banner { background: var(--ok-50); color: #14532d; border: 1px solid #BFE5CF; border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.sidebar .nav a { font-size: 13.5px; }
.two > .card + .card, .three > .card + .card { margin-top: 0; }
td input.pct { width: 84px; } td.mono { white-space: nowrap; }

.mybrand { display: flex !important; align-items: center; gap: 8px; } .mybrand b { font-family: var(--font-head); font-size: 22px; color: var(--brand-700); } .mybrand img { width: 130px !important; }
.modname { margin: -14px 8px 14px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
tr[data-sel] { cursor: pointer; } tr[data-sel]:hover { background: var(--soft); }

.tabs a.tabs-a { padding: 9px 14px; font: 600 13.5px var(--font); color: var(--muted); border-bottom: 2px solid transparent; text-decoration: none; }
.tabs a.tabs-a:hover { color: var(--text); } .tabs a.tabs-a.on { color: var(--brand); border-bottom-color: var(--mint); }
.field input.narrow, input.narrow { max-width: 140px; }
.kpi-v { font: 650 22px var(--font-head); margin: 2px 0; }
.dlg.wide { width: min(960px, 94vw); }

/* ---------- Topbar unica a tutta larghezza (logo una sola volta, in alto a sinistra) ---------- */
.shell { grid-template-rows: 60px 1fr; }
.shell > .topbar { grid-column: 1 / -1; grid-row: 1; display: flex; align-items: center; gap: 14px; height: 60px; padding: 0 24px; position: sticky; top: 0; z-index: 40; border-bottom: 1px solid var(--line); background: var(--bg); justify-content: flex-start; }
.topbar .top-brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: inherit; }
.topbar .top-brand b { font-family: var(--font-head); font-size: 22px; font-weight: 700; color: var(--brand-700); }
.topbar .top-brand img { height: 28px; width: auto; display: block; }
.topbar .top-mod { padding-left: 14px; border-left: 1px solid var(--line-strong); font: 600 12px var(--font); letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
.topbar .menu-btn { display: none; }
.shell > .sidebar { grid-row: 2; top: 60px; height: calc(100vh - 60px); padding-top: 16px; }
.shell > .main { grid-row: 2; grid-column: 2; }
@media (max-width: 1000px) {
  .shell > .main { grid-column: 1; }
  .shell > .topbar { padding: 0 12px; }
  .topbar .menu-btn { display: inline-flex; }
  .shell > .sidebar { position: fixed; top: 60px; bottom: 0; height: auto; }
  .topbar .top-mod { display: none; }
}

/* ---------- Selettore lingua nella topbar ---------- */
.lang-top { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); margin-right: 6px; }
.lang-top .ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.lang-top .lang-text { font-size: 13px; font-weight: 500; }
.lang-top .lang-pick select { height: 34px; padding: 0 28px 0 10px; border: 1px solid var(--line-strong); border-radius: 999px; background-color: var(--bg); color: var(--text); font: 600 13px var(--font); cursor: pointer; }
.lang-top .lang-pick select:hover { border-color: var(--brand); }
@media (max-width: 700px) { .lang-top .lang-text { display: none; } }
.lang-top .lang-pick select { min-width: 110px; }
@media (max-width: 700px) {
  .lang-top { margin-right: 0; gap: 4px; } .lang-top .lang-pick select { min-width: 0; width: 92px; padding: 0 22px 0 8px; font-size: 12.5px; }
  .topbar .top-brand b { font-size: 18px; } .topbar .top-brand img { height: 22px; }
  .shell > .topbar { gap: 8px; } .topbar .top-brand { min-width: 0; flex: 0 1 auto; }
}
@media (max-width: 700px) { .lang-top .lang-pick select { width: 106px; } }

td.center, th.center { text-align: center; }
.month-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px 14px; margin-top: 8px; } .month-grid .field { margin: 0; } .month-grid input { width: 100%; }
@media (max-width: 1000px) { .month-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 520px) { .month-grid { grid-template-columns: repeat(2, 1fr); } }

.sidebar .foot .ver { white-space: nowrap; }
#panel, #formBox { scroll-margin-top: 84px; }

/* Expense Budget: tabelle compatte (nessuno scroll orizzontale), barra versioni, azioni */
.grid-table.compact { font-size: 12px; width: 100%; }
.grid-table.compact td, .grid-table.compact th { padding: 4px 4px; }
.grid-table.compact th { font-size: 11px; }
.grid-table.compact input, .grid-table.compact select { height: 28px; font-size: 12px; padding: 2px 4px; max-width: 100%; }
.grid-table.compact input.n { width: 74px; text-align: right; }
.grid-table.compact input.pct { width: 52px; text-align: right; }
.grid-table.compact input.nm { width: 100%; min-width: 130px; }
.grid-table.compact input.mo { width: 52px; padding: 2px 3px; text-align: right; }
.grid-table.compact select.s-cat { max-width: 120px; } .grid-table.compact select.s-bu { max-width: 88px; } .grid-table.compact select.s-m { width: 58px; } .grid-table.compact select.s-t { width: 66px; } .grid-table.compact select.s-p { max-width: 100px; }
.grid-table.compact td.lbl, .grid-table.compact th.lbl { min-width: 140px; }
.grid-table td.num, .grid-table th.num { text-align: right; }
.inl { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.inl select, .inl input { height: 36px; }
.ver-bar .row { gap: 14px; align-items: center; }
.cc-sel { max-width: 320px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 10px; }
.tabs button.on, .tabs a.tabs-a.on { color: var(--brand); border-bottom-color: var(--mint); }
.stepline.h { display: flex; gap: 10px; flex-wrap: wrap; }
.stepline.h .it { flex: 1 1 180px; }
.mon { width: 34px; }
.amt { width: 90px; text-align: right; }

/* Library */
.pdf { width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.tile-link { display: flex; flex-direction: column; gap: 4px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; color: var(--text); text-decoration: none; }
.tile-link:hover { border-color: var(--brand); }
.tile-link .ico { width: 20px; height: 20px; color: var(--brand); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.crumb { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; font-size: 13px; margin-bottom: 6px; }

.crumbs { margin-top: 10px; font-size: 0.95em; }
.crumbs a { text-decoration: none; }
