/* Polaris 4 — strato visivo condiviso.
   Caricato per ultimo in ogni template (dopo theme.css, topbar.css, CSS di pagina e <style> inline),
   uniforma titoli, bottoni, card, pannelli, tabelle e stati vuoti senza toccare struttura, id o data-*.
   Usa solo i token di theme.css. Le regole per pagina sono in fondo, raggruppate per body class. */

/* ── Titoli di pagina: firma a mano libera sotto l'H1 ───────────────────── */
body.workspace-light :is(.card-header .card-title,.card-header h1,.investor-head h1,.inv-head h1){position:relative;display:inline-block}
body.workspace-light :is(.card-header .card-title,.card-header h1,.investor-head h1,.inv-head h1)::after{
  content:'';position:absolute;left:-1px;right:-4px;bottom:-7px;height:7px;pointer-events:none;
  background:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 132 10' preserveAspectRatio='none'%3E%3Cpath d='M2 6 C 22 2, 40 9, 62 5 S 104 2, 130 6' fill='none' stroke='%23E8590C' stroke-width='2.4' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat center/100% 100%}

body.database-page .card-header .card-title{margin-bottom:9px}

/* ── Bottoni ─────────────────────────────────────────────────────────── */
.workspace-light :is(.btn-primary,.button-primary,button.primary,.investor-actions button.primary){background:var(--ink);border-color:var(--ink);color:#fff;font-weight:600;transition:background var(--dur) var(--ease-out),box-shadow var(--dur) var(--ease-out),transform var(--dur) var(--ease-out)}
.workspace-light :is(.btn-primary,.button-primary,button.primary):hover:not(:disabled){background:#1B2C45;box-shadow:0 4px 12px rgba(15,27,45,.16)}
.workspace-light :is(.btn-primary,.button-primary,button.primary):active:not(:disabled){transform:translateY(1px)}
.workspace-light :is(.btn-secondary,.view-btn,.add-menu>summary){transition:background var(--dur) var(--ease-out),border-color var(--dur) var(--ease-out)}
.workspace-light :is(.btn-secondary,.view-btn,.add-menu>summary):hover{background:var(--surface-3);border-color:var(--border-strong)}
.workspace-light :is(button,.btn-secondary,.btn-primary):disabled{cursor:not-allowed}
.workspace-light :is(.btn-secondary,.btn-primary,.add-menu>summary) img{width:16px;height:16px;object-fit:contain}

/* ── Card e pannelli ─────────────────────────────────────────────────── */
.workspace-light :where(.card,.metrics-card,.kpi-card,.panel,.web-card,.own-card,.system-card,.settings-standard-card,.settings-table-card,.distribution-card,.analysis-filter-card,.investor-card){transition:box-shadow var(--dur) var(--ease-out),border-color var(--dur) var(--ease-out)}
.workspace-light :where(.overline,.af-title,.rp-label){color:var(--text-4)}

/* ── Badge di stato coerenti in tutta l'app ──────────────────────────── */
.workspace-light .badge{font-weight:600;letter-spacing:.005em}
.workspace-light .badge.verde{background:var(--positive-soft);color:var(--positive-text)}
.workspace-light .badge.arancione{background:var(--accent-soft);color:var(--accent-text)}
.workspace-light .badge.rosso{background:var(--red-bg);color:var(--negative)}
.workspace-light .badge.grigio{background:var(--surface-2);color:var(--text-3)}
.workspace-light .badge-ori{background:var(--info-soft);color:#1D4ED8}

/* ── Tabelle a griglia (Database, Analisi, Impostazioni) ──────────────── */
.workspace-light :where(.tbl-row,.sector-tr:not(.head)){transition:background var(--dur) var(--ease-out)}
.workspace-light :where(.tbl-row.selected){background:#FFF7F1}

/* ── Stati vuoti e caricamento ───────────────────────────────────────── */
.workspace-light :where(.tbl-empty,.empty-state,.notification-empty,.loading){color:var(--text-3)}
.workspace-light .spinner{border-color:var(--border);border-top-color:var(--accent)}

/* ── Scrollbar sottili ovunque ───────────────────────────────────────── */
.workspace-light *{scrollbar-width:thin;scrollbar-color:#D9D3C8 transparent}

/* ═══ Regole per pagina ═════════════════════════════════════════════════ */

/* Note: area di lavoro a tutta altezza e campi dell'editor coerenti */
body.note-page{min-height:100vh}
body.note-page .note-workspace{min-height:calc(100vh - var(--topbar))}
body.note-page .note-participant-row input,body.note-page .note-task-editor-row input[type=text],body.note-page .note-task-editor-row input[type=date]{border:1px solid var(--border);background:var(--surface);color:var(--text)}
body.note-page .note-title-row h1{font-size:22px}
body.note-page .note-list-item{transition:background var(--dur) var(--ease-out)}
body.note-page .note-type-chip{border-radius:var(--radius-chip)}

/* Scheda società: intestazione e indicatori */
body.company-page .company-header h1{letter-spacing:-.025em}

/* Impostazioni: navigazione laterale più leggibile */
body.settings-page :is(.settings-nav-item,.settings-view-tabs button){transition:background var(--dur) var(--ease-out),color var(--dur) var(--ease-out)}

/* ═══ Pagine fuori dall'app (login, errore) ═════════════════════════════ */
.login-brand{display:flex;align-items:center;gap:10px}
.login-brand .polaris-logo-asset{width:26px;height:26px}
.login-brand .polaris-logo-ring{stroke:#FBF9F5}
.login-brand .polaris-logo-dot{fill:#E8590C;stroke:#0F1B2D;paint-order:stroke}
.login-page .intro h1{position:relative;display:inline-block}
.login-page .intro h1::after{content:'';position:absolute;left:-1px;right:-4px;bottom:-8px;height:8px;background:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 132 10' preserveAspectRatio='none'%3E%3Cpath d='M2 6 C 22 2, 40 9, 62 5 S 104 2, 130 6' fill='none' stroke='%23E8590C' stroke-width='2.4' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat center/100% 100%}
.login-page .intro p{margin-top:16px}
.login-page .login-note{position:relative;z-index:2;margin:18px 0 0;font:600 22px/1.15 'Caveat','Segoe Print',cursive;color:rgba(251,249,245,.78);transform:rotate(-2deg);transform-origin:left}
.login-page input:focus{border-color:#9DB5E8;box-shadow:0 0 0 3px rgba(37,99,235,.18)}
.login-page .submit:not(:disabled):hover{background:#1B2C45}

body.error-page{background:var(--bg);font-family:var(--font-sans);color:var(--text)}
body.error-page .card{border-color:var(--border);border-radius:16px;box-shadow:var(--shadow-pop)}
body.error-page .brand-mark{background:var(--surface-2);box-shadow:inset 0 0 0 1px var(--border)}
body.error-page .errore-logo{padding:12px}
body.error-page .polaris-logo-ring{stroke:var(--ink)}
body.error-page .polaris-logo-dot{fill:var(--accent);stroke:var(--surface-2);paint-order:stroke}
body.error-page h1{font-weight:650;letter-spacing:-.02em}
body.error-page .ref{font-family:var(--font-mono);border-radius:9px}
body.error-page .back{display:inline-flex;align-items:center;gap:8px;margin-top:18px;height:36px;padding:0 14px;border:1px solid var(--border);border-radius:var(--radius-control);background:var(--surface);color:var(--text);text-decoration:none;font-weight:500}
body.error-page .back:hover{background:var(--surface-3);border-color:var(--border-strong)}
body.error-page .back img{width:16px;height:16px}

/* ═══ Tratto a mano (Polaris 4) ═════════════════════════════════════════
   Kit condiviso: filtro SVG #pz-rough (definito nel macro della topbar),
   bordi irregolari, tratteggi e annotazioni in corsivo. Da usare con misura:
   grafici e scatole "di lavoro", mai testi lunghi o tabelle. */
.workspace-light .pz-rough{filter:url(#pz-rough)}
.workspace-light .pz-rough-strong{filter:url(#pz-rough-strong)}
.workspace-light .pz-sketch{border-radius:14px 7px 13px 6px/7px 13px 6px 14px!important}
.workspace-light .pz-hand{font-family:var(--font-hand);font-weight:600;font-size:18px;line-height:1.05;color:var(--accent-text);letter-spacing:0}
.workspace-light .pz-hand.ink{color:var(--text-2)}
.workspace-light .pz-hatch{background:var(--hatch-navy)}
.workspace-light .pz-hatch-accent{background:var(--hatch-accent)}
/* Freccia a mano per le annotazioni */
.workspace-light .pz-arrow{display:inline-block;width:34px;height:16px;vertical-align:middle;background:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 34 16'%3E%3Cpath d='M2 11 C 10 4, 20 3, 30 7 M24 2 L31 7 L25 12' fill='none' stroke='%23C2410C' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat center/contain}
.workspace-light .pz-arrow.down{transform:rotate(90deg)}
.workspace-light .pz-arrow.left{transform:scaleX(-1)}
@media (prefers-reduced-motion:reduce){.workspace-light .pz-rough,.workspace-light .pz-rough-strong{filter:none}}

/* ═══ Fondo a puntini dell'app ══════════════════════════════════════════
   La griglia di puntini che prima stava solo dietro la mappa Settori è il
   fondo di tutta l'app; i contenitori di pagina diventano trasparenti, i
   pannelli laterali e le card restano pieni. */
body.workspace-light{background-color:var(--bg);background-image:radial-gradient(#F0ECE4 1px,transparent 1.3px);background-size:18px 18px;background-attachment:fixed}
.workspace-light :is(.app,.main-col,.main-card,.note-workspace,.note-detail,main.inv,.settings-layout,.settings-content){background-color:transparent!important;background-image:none!important}
.workspace-light .tabs{background-color:transparent}
.workspace-light .company-page .tabs,body.company-page .tabs{background:var(--bg)}
.workspace-light :is(.sector-sunburst,.inv-deal){background-image:none!important}
.workspace-light .sector-sunburst{background-color:transparent!important}

/* ═══ Revisione finale: scala tipografica unica ═════════════════════════
   H1 di pagina 26/600 · titoli di sezione 20/600 · titoli di card 15/600 ·
   etichette mono 10.5 · testo minimo 11px. */
body.workspace-light :is(.inv-head h1,.investor-head h1){font-size:var(--display-size)!important;font-weight:600!important;letter-spacing:-.025em}
body.workspace-light .score-framework-head h2,body.workspace-light .score-criteria-header h2{font-size:20px!important;font-weight:600!important;letter-spacing:-.015em}
body.workspace-light .sector-map-head h2{font-size:20px!important;font-weight:600!important}
body.workspace-light .sector-table-card h2{font-size:15px!important;font-weight:600!important}
body.workspace-light .sector-map-controls label>span:first-child{font-size:10.5px!important;letter-spacing:.13em!important}
body.workspace-light .sector-screening{border:1px solid var(--border)!important;background:var(--surface)!important;color:var(--text)!important}
body.workspace-light .sector-screening:hover{border-color:var(--border-strong)!important;background:var(--surface-3)!important}
body.workspace-light .inv-tbl [role="columnheader"],body.workspace-light .inv-th{font-size:10.5px!important;letter-spacing:.1em}
body.workspace-light .note-list-type{font-size:10px!important}
body.workspace-light .score-framework-count,body.workspace-light .score-group-summary small{font-size:10.5px!important}
body.workspace-light .sector-detail h2{font-size:18px!important;font-weight:600!important}
body.workspace-light .note-empty h2{font-size:20px!important;font-weight:600!important}

/* Intestazione tabelle unica (modello: tabella del Database).
   Fondo carta, filo inferiore 1.5px, etichette mono 10.5 maiuscole,
   colonna ordinata in inchiostro con sottolineatura a mano, righe a tratteggio tenue. */
body.workspace-light{--th-bg:#FAF8F4;--th-line:#D9D3C7;--tr-line:#ECE7DE;--tr-hover:#FAF7F1}
body.workspace-light :is(.analysis-page thead th,.settings-page thead th,.ab-company-table thead th){height:36px!important;background:var(--th-bg)!important;border-bottom:1.5px solid var(--th-line)!important;box-shadow:none!important}
body.workspace-light :is(.inv-tr-head,.sector-tr.head,.fin-row-head,.score-detail-columns){min-height:36px;background:var(--th-bg)!important;border-bottom:1.5px solid var(--th-line)!important;box-shadow:none!important}
body.workspace-light :is(.analysis-page thead th,.settings-page thead th,.ab-company-table thead th,.inv-tr-head>*,.sector-tr.head>*,.sector-tr.head,.fin-row-head>*,.score-detail-columns>*){font-family:var(--font-mono)!important;font-size:10.5px!important;font-weight:500!important;letter-spacing:.1em!important;text-transform:uppercase!important;color:var(--text-4)!important;line-height:1.2!important}
body.workspace-light :is(.inv-tr-head>*,.tbl-head-cell)[aria-sort="ascending"],
body.workspace-light :is(.inv-tr-head>*,.tbl-head-cell)[aria-sort="descending"]{position:relative;color:var(--text)!important}
body.workspace-light :is(.analysis-page thead th,.inv-tr-head>*)[aria-sort="ascending"]::after,
body.workspace-light :is(.analysis-page thead th,.inv-tr-head>*)[aria-sort="descending"]::after{content:"";position:absolute;left:10px;width:min(64px,calc(100% - 20px));bottom:6px;height:4px;background:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 60 4' preserveAspectRatio='none'%3E%3Cpath d='M1 2.6 C 15 1.2, 30 3.2, 59 1.6' fill='none' stroke='%23E8590C' stroke-width='1.4' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat center/100% 100%}
@media(max-width:560px){
  body.workspace-light .inv-tr-head.inv-tr-head>div[aria-sort]{padding-bottom:8px}
  body.workspace-light .inv-tr-head.inv-tr-head>div[aria-sort]::after{left:0;bottom:0;width:min(64px,100%)}
}
body.workspace-light .analysis-page thead th.cell-num[aria-sort]::after,body.workspace-light .analysis-page thead th:nth-child(n+4)[aria-sort]::after{left:auto;right:10px}
body.workspace-light :is(.analysis-page tbody td,.settings-page tbody td,.ab-company-table tbody td){border-bottom:1px dashed var(--tr-line)!important}
body.workspace-light :is(.inv-tr:not(.inv-tr-head),.sector-tr:not(.head),.fin-row:not(.fin-row-head),.score-detail-row:not(.score-detail-columns)){border-top:0!important;border-bottom:1px dashed var(--tr-line)!important}
body.workspace-light :is(.fin-row,.score-detail-row):last-child{border-bottom:0!important}
body.workspace-light :is(.analysis-page tbody tr,.settings-page tbody tr):hover td,body.workspace-light :is(.inv-tr:not(.inv-tr-head),.sector-tr:not(.head)):hover{background:var(--tr-hover)}

/* Scala titoli: allineamento finale (H1 pagina 26 · sezione 20 · card 15) */
body.workspace-light .company-page h1,body.company-page.workspace-light h1,body.workspace-light .note-sidebar-head h1{font-size:26px!important;font-weight:600!important;letter-spacing:-.02em}
body.workspace-light.settings-page .settings-content h3:not(.st-hero-title),body.settings-page.workspace-light .st-card h3{font-size:15px!important}
body.workspace-light .inv-lane-head h2,body.workspace-light [data-inv-panel] h2{font-size:15px!important}
body.workspace-light.settings-page .st-hero-head h3,body.settings-page.workspace-light .st-hero-head h3{font-size:18px!important}

/* Focus in inchiostro (niente alone blu) */
body.workspace-light,body.login-page{--focus-ring:0 0 0 3px rgba(15,27,45,.10)}
body.workspace-light :where(input,select,textarea):focus{border-color:rgba(15,27,45,.45)}
.login-page input:focus{border-color:var(--ink)!important;box-shadow:0 0 0 3px rgba(15,27,45,.08)!important}
/* Settori: "Aggiungi" ATECO come bottone secondario */
body.workspace-light .sector-ateco-add button{background:var(--surface)!important;color:var(--ink)!important;border:1px solid var(--border)!important;border-radius:8px;font-weight:500}
body.workspace-light .sector-ateco-add button:hover{border-color:var(--ink)!important}
/* Pagina di errore: stesso fondo a puntini e tratto a mano */
body.error-page{background:#FBF9F5 radial-gradient(#F0ECE4 1px,transparent 1.3px) 0 0/18px 18px!important}
body.error-page .card{border-radius:16px 8px 15px 7px/8px 15px 7px 16px;box-shadow:3px 3px 0 var(--surface-2,#F3F0EA)}
body.error-page h1{font-family:'Inter Tight',sans-serif;font-weight:600;display:inline-block;padding-bottom:6px;background:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 6' preserveAspectRatio='none'%3E%3Cpath d='M2 4 C 30 1.5, 70 5.5, 118 2.5' fill='none' stroke='%23E8590C' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat bottom/100% 6px}
body.error-page .brand-mark{background:var(--surface-2,#F3F0EA);box-shadow:none}
/* Analisi e scheda società: lo stato "attivo" usa il navy Polaris invece del blu */
body.analysis-page,body.company-page{--info:var(--tone-navy);--info-soft:var(--tone-navy-tint)}
