/* Dashboard shared styles - SKF Mockup */

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  background: #f5f6f8; color: #1f2937; font-size: 13px;
  -webkit-font-smoothing: antialiased;
  transition: background-color .2s ease;
}
body.sec-home     { background: #f0f9ff; }
body.sec-realtime { background: #fff7ed; }
body.sec-process  { background: #ecfdf5; }
body.sec-report   { background: #f5f3ff; }
body.sec-drill    { background: #fefce8; }
a { color: inherit; text-decoration: none; }

.wrap { max-width: 1360px; margin: 0 auto; padding: 16px 20px 40px; }

/* TOP brand bar */
.top {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 8px;
  padding: 12px 18px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}
.brand { display: flex; align-items: center; gap: 12px; font-size: 13px; letter-spacing: 1.2px; font-weight: 700; }
.brand .sep { color: #d1d5db; font-weight: 400; }
.brand .client { color: #00B0F0; }
.brand a:hover { color: #0080b8; }
.topright { display: flex; align-items: center; gap: 16px; font-size: 12px; color: #6b7280; }
.topright .live { display: inline-flex; align-items: center; gap: 6px; color: #16a34a; font-weight: 600; }
.topright .live .pulse { width: 8px; height: 8px; background: #16a34a; border-radius: 50%; }
.topright .dataset {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; background: rgba(0,176,240,0.08); color: #0080b8;
  border-radius: 999px; font-size: 11px; font-weight: 600;
  border: 1px solid rgba(0,176,240,0.2);
}
.topright .dataset .d { width: 5px; height: 5px; background: #00B0F0; border-radius: 50%; }

/* NAVBAR con dropdown */
.navbar {
  margin-top: 12px;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 8px;
  padding: 0 8px;
  display: flex; align-items: stretch;
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
  position: relative;
}
.nav-item {
  padding: 14px 16px; color: #6b7280;
  font-size: 13px; font-weight: 500;
  border-bottom: 2px solid transparent; transition: all .15s ease;
  display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer; user-select: none;
}
.nav-item:hover { color: #1f2937; }
.nav-item.active { color: #1f2937; font-weight: 600; border-bottom-color: #00B0F0; }
.nav-item .chev { font-size: 10px; color: #9ca3af; transition: transform .15s ease, color .15s ease; }

/* Section colors - palette tenue per orientamento utente */
.nav-group { position: relative; --sec-main: #00B0F0; --sec-dark: #0080B8; --sec-light: rgba(0, 176, 240, 0.08); }
.nav-group.sec-realtime { --sec-main: #FB923C; --sec-dark: #C2410C; --sec-light: rgba(251, 146, 60, 0.10); }
.nav-group.sec-process  { --sec-main: #34D399; --sec-dark: #047857; --sec-light: rgba(52, 211, 153, 0.10); }
.nav-group.sec-report   { --sec-main: #A78BFA; --sec-dark: #6D28D9; --sec-light: rgba(167, 139, 250, 0.10); }
.nav-group.sec-drill    { --sec-main: #FACC15; --sec-dark: #A16207; --sec-light: rgba(250, 204, 21, 0.14); }

.nav-group .nav-item { color: #6b7280; }
.nav-group .nav-item .chev { color: #9ca3af; }
.nav-group:hover .nav-item { color: var(--sec-dark); background: var(--sec-light); border-radius: 6px 6px 0 0; }
.nav-group:hover .nav-item .chev { color: var(--sec-main); transform: rotate(180deg); }
.nav-group .nav-item.active { color: var(--sec-dark); border-bottom-color: var(--sec-main); font-weight: 600; }
.nav-group .nav-item.active .chev { color: var(--sec-main); }

/* Nav-item diretti con colore di sezione (Causali, Analisi canali) */
.nav-item.sec-realtime { --sec-main: #FB923C; --sec-dark: #C2410C; --sec-light: rgba(251, 146, 60, 0.10); }
.nav-item.sec-drill    { --sec-main: #FACC15; --sec-dark: #A16207; --sec-light: rgba(250, 204, 21, 0.14); }
.nav-item.sec-realtime:hover, .nav-item.sec-drill:hover { color: var(--sec-dark); background: var(--sec-light); border-radius: 6px 6px 0 0; }
.nav-item.sec-realtime.active, .nav-item.sec-drill.active { color: var(--sec-dark); border-bottom-color: var(--sec-main); font-weight: 600; }
.dropdown {
  position: absolute; top: 100%; left: 0;
  min-width: 240px;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  padding: 6px; margin-top: 4px;
  opacity: 0; visibility: hidden; transform: translateY(-4px);
  transition: all .15s ease;
  z-index: 100;
}
.nav-group:hover .dropdown { opacity: 1; visibility: visible; transform: translateY(0); }
.drop-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; color: #1f2937; font-size: 13px;
  border-radius: 6px; transition: background .12s ease;
  cursor: pointer;
}
.drop-item:hover { background: var(--sec-light); color: var(--sec-dark); }
.drop-item.disabled { color: #cbd5e1; cursor: not-allowed; }
.drop-item.disabled:hover { background: transparent; color: #cbd5e1; }
.drop-item .badge {
  font-size: 9px; letter-spacing: 0.5px; font-weight: 700;
  padding: 2px 6px; background: #f1f5f9; color: #94a3b8;
  border-radius: 3px; text-transform: uppercase;
}
.drop-item.disabled .badge { background: #f8fafc; }
.drop-category {
  font-size: 10px; letter-spacing: 1px; font-weight: 700;
  color: #9ca3af; text-transform: uppercase;
  padding: 6px 12px 4px;
}
.navbar .spacer { flex: 1; }
.navbar .gear {
  padding: 14px 16px; color: #cbd5e1; cursor: not-allowed;
  border-left: 1px solid #f1f5f9; display: flex; align-items: center;
  font-size: 18px;
}

/* Page head */
.page-head { margin: 18px 4px 12px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.page-head .left .eyebrow { font-size: 11px; letter-spacing: 1.2px; color: #6b7280; font-weight: 700; margin-bottom: 4px; text-transform: uppercase; }
.page-head.sec-home .left .eyebrow     { color: #0080B8; }
.page-head.sec-realtime .left .eyebrow { color: #C2410C; }
.page-head.sec-process .left .eyebrow  { color: #047857; }
.page-head.sec-report .left .eyebrow   { color: #6D28D9; }
.page-head.sec-drill .left .eyebrow    { color: #A16207; }
.page-head .left h1 { font-size: 22px; font-weight: 600; color: #1f2937; letter-spacing: -0.3px; }
.page-head .filters { display: flex; gap: 8px; align-items: center; }
.page-head .filter {
  padding: 6px 12px; font-size: 12px; color: #475569;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 6px;
  display: flex; align-items: center; gap: 6px;
  cursor: pointer;
  position: relative;
  user-select: none;
  transition: border-color .15s ease;
}
.page-head .filter:hover { border-color: #00B0F0; }
.page-head .filter .k { color: #9ca3af; }
.page-head .filter .filter-chev { font-size: 9px; color: #9ca3af; margin-left: 2px; transition: transform .15s ease; }
.page-head .filter.open { border-color: #00B0F0; }
.page-head .filter.open .filter-chev { transform: rotate(180deg); color: #00B0F0; }

.filter-dropdown {
  position: absolute; top: calc(100% + 4px); right: 0;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.10), 0 2px 4px rgba(0,0,0,0.04);
  padding: 4px; min-width: 200px;
  display: none; z-index: 200;
}
.page-head .filter.open .filter-dropdown { display: block; }
.filter-opt {
  padding: 8px 12px; font-size: 12px; color: #1f2937; border-radius: 5px;
  cursor: pointer; transition: background .1s ease;
}
.filter-opt:hover { background: rgba(0, 176, 240, 0.08); color: #0080B8; }
.filter-opt.disabled { color: #cbd5e1; cursor: not-allowed; }
.filter-opt.disabled:hover { background: transparent; color: #cbd5e1; }
.filter-opt.selected { background: rgba(0, 176, 240, 0.10); color: #0080B8; font-weight: 600; }
.filter-opt.selected::after { content: ' ✓'; font-size: 11px; }

/* KPI cards */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.kpi {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 8px;
  padding: 16px 18px; position: relative;
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}
.kpi .lab { font-size: 11px; letter-spacing: 0.6px; text-transform: uppercase; color: #6b7280; font-weight: 600; margin-bottom: 8px; }
.kpi .val { font-size: 28px; font-weight: 600; color: #1f2937; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .val .unit { font-size: 14px; color: #9ca3af; font-weight: 500; margin-left: 2px; }
.kpi .delta { font-size: 11px; margin-top: 8px; font-weight: 500; display: inline-flex; align-items: center; gap: 4px; }
.kpi .delta.pos { color: #16a34a; }
.kpi .delta.neg { color: #dc2626; }
.kpi .delta.neu { color: #6b7280; }
.kpi .acc { position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 0 2px 2px 0; background: #00B0F0; }
.kpi.warn .acc { background: #f59e0b; }
.kpi.alert .acc { background: #ef4444; }
.kpi.neutral .acc { background: #9ca3af; }

/* Row + panel */
.row { display: grid; grid-template-columns: 1.35fr 1fr; gap: 12px; margin-top: 12px; }
.panel {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
  overflow: hidden;
}
.panel-head {
  padding: 12px 16px; border-bottom: 1px solid #f1f5f9;
  display: flex; align-items: center; justify-content: space-between;
}
.panel-head h3 { font-size: 13px; font-weight: 600; color: #1f2937; }
.panel-head .meta { font-size: 11px; color: #9ca3af; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 12px; }
thead th {
  text-align: left; padding: 10px 14px; font-size: 10px; letter-spacing: 0.6px;
  text-transform: uppercase; color: #6b7280; font-weight: 600;
  border-bottom: 1px solid #e5e7eb; background: #fafbfc;
}
thead th.num { text-align: right; }
thead th.cen { text-align: center; }
tbody td { padding: 11px 14px; border-bottom: 1px solid #f3f4f6; font-variant-numeric: tabular-nums; }
tbody td.label { font-variant-numeric: normal; font-weight: 500; color: #1f2937; }
tbody td.num { text-align: right; }
tbody td.cen { text-align: center; }
tbody tr.off td { color: #cbd5e1; background: #fafbfc; }
tbody tr.off td.label { color: #94a3b8; font-weight: 400; }
tbody tr.active { background: rgba(0, 176, 240, 0.04); }
tbody tr.active td.label { color: #0f172a; font-weight: 600; }
tbody tr:hover:not(.off) { background: rgba(0, 176, 240, 0.06); cursor: pointer; }
.ch-id { display: inline-block; min-width: 38px; font-weight: 700; }
.ch-type { color: #6b7280; font-size: 11px; margin-left: 8px; font-weight: 400; }
.sem { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; }
.sem.g { background: #16a34a; }
.sem.y { background: #f59e0b; }
.sem.r { background: #dc2626; }
.sem.off { background: #d1d5db; }

/* Drill */
.drill { padding: 14px 16px 16px; }
.drill-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.drill-stat { border: 1px solid #f1f5f9; background: #fafbfc; padding: 10px 12px; border-radius: 6px; }
.drill-stat .lab { font-size: 10px; letter-spacing: 0.6px; text-transform: uppercase; color: #6b7280; font-weight: 600; margin-bottom: 6px; }
.drill-stat .val { font-size: 20px; font-weight: 600; color: #1f2937; font-variant-numeric: tabular-nums; line-height: 1; }
.drill-stat .sub { font-size: 10px; color: #9ca3af; margin-top: 4px; font-weight: 500; }
.chart-wrap { margin-top: 12px; }
.chart-wrap .lab { font-size: 11px; color: #6b7280; margin-bottom: 6px; font-weight: 500; }
.chart-wrap svg { width: 100%; height: 96px; }
.mix { margin-top: 14px; }
.mix .lab { font-size: 11px; color: #6b7280; margin-bottom: 8px; font-weight: 500; }
.mix-row { display: grid; grid-template-columns: 90px 1fr 44px; gap: 10px; align-items: center; padding: 5px 0; font-size: 12px; }
.mix-row .name { color: #475569; }
.mix-row .bar { height: 8px; background: #f1f5f9; border-radius: 4px; overflow: hidden; }
.mix-row .fill { height: 100%; background: #00B0F0; border-radius: 4px; }
.mix-row .pct { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; color: #1f2937; }

/* AI fascia - sempre greyed con badge Fase 2 */
.ai {
  margin-top: 16px;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
  overflow: hidden;
  position: relative;
}
.ai-head {
  background: #6b7280; color: #fff;
  padding: 10px 16px; display: flex; align-items: center; gap: 10px;
  font-size: 12px; letter-spacing: 0.8px; font-weight: 600;
}
.ai-head .star { width: 22px; height: 22px; border-radius: 6px; background: #9ca3af; display: flex; align-items: center; justify-content: center; font-size: 11px; }
.ai-head .phase-badge {
  margin-left: auto;
  background: #f59e0b; color: #fff;
  padding: 3px 10px; border-radius: 4px;
  font-size: 10px; letter-spacing: 1px; font-weight: 700; text-transform: uppercase;
}
.ai-banner {
  background: #fffbeb; border-bottom: 1px solid #fcd34d;
  padding: 8px 16px; font-size: 11px; color: #92400e;
  display: flex; align-items: center; gap: 8px;
}
.ai-banner::before { content: 'ⓘ'; font-size: 13px; color: #b45309; }
.ai-body { padding: 14px 16px; opacity: 0.55; pointer-events: none; }
.ai-input { background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 6px; padding: 10px 14px; display: flex; align-items: center; gap: 10px; font-size: 13px; color: #9ca3af; margin-bottom: 12px; }
.ai-input .btn { margin-left: auto; background: #9ca3af; color: #fff; padding: 5px 12px; border-radius: 5px; font-size: 11px; font-weight: 600; letter-spacing: 0.5px; }
.ai-label { font-size: 10px; letter-spacing: 0.8px; text-transform: uppercase; color: #9ca3af; font-weight: 600; margin-bottom: 8px; }
.ai-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.ai-tile { background: #fafbfc; border: 1px solid #e5e7eb; border-radius: 6px; padding: 10px 12px; font-size: 12px; line-height: 1.5; color: #6b7280; cursor: not-allowed; }
.ai-tile .icn { display: inline-block; width: 22px; height: 22px; border-radius: 5px; background: #f1f5f9; color: #9ca3af; text-align: center; line-height: 22px; font-size: 11px; margin-bottom: 6px; }

/* BOZZA banner */
.draft-banner {
  margin-top: 12px;
  background: #fff8e1;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  padding: 10px 16px;
  display: flex; align-items: center; gap: 10px;
  font-size: 12px; color: #92400e;
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}
.draft-banner::before {
  content: 'BOZZA';
  display: inline-block;
  background: #f59e0b; color: #fff;
  padding: 3px 10px; border-radius: 4px;
  font-size: 10px; letter-spacing: 1px; font-weight: 700;
}
.draft-banner strong { color: #78350f; }

/* Placeholder pages */
.placeholder-view {
  margin-top: 16px;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 8px;
  padding: 80px 40px; text-align: center;
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}
.placeholder-view .badge {
  display: inline-block;
  padding: 4px 12px;
  background: #fff8e1; color: #b8860b;
  border-radius: 999px;
  font-size: 11px; letter-spacing: 1px; font-weight: 700; text-transform: uppercase;
  margin-bottom: 20px;
}
.placeholder-view h2 { font-size: 28px; font-weight: 600; color: #1f2937; margin-bottom: 12px; }
.placeholder-view p { font-size: 14px; color: #6b7280; max-width: 560px; margin: 0 auto 8px; line-height: 1.6; }

/* Responsive */
@media (max-width: 980px) {
  .row { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .ai-tiles { grid-template-columns: repeat(2, 1fr); }
}

/* Mobile (iPhone) - <= 480px */
@media (max-width: 480px) {
  .wrap { padding: 10px 12px 30px; }

  /* Top brand bar compatto */
  .top { padding: 10px 12px; flex-direction: column; align-items: stretch; gap: 8px; }
  .topright { font-size: 11px; gap: 8px; flex-wrap: wrap; justify-content: flex-start; }
  .topright .dataset { display: none; }

  /* Navbar scrollabile orizzontalmente */
  .navbar { overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 0 4px; flex-wrap: nowrap; }
  .navbar::-webkit-scrollbar { display: none; }
  .navbar { scrollbar-width: none; }
  .nav-item { padding: 11px 10px; font-size: 12px; white-space: nowrap; }
  .navbar .spacer { display: none; }
  .navbar .gear { padding: 11px 12px; border-left: 0; }

  /* Dropdown su mobile - tap toggle (CSS-only via :focus-within fallback) */
  .nav-group .dropdown { right: 0; left: auto; min-width: 200px; }

  /* Page head stack */
  .page-head { flex-direction: column; align-items: flex-start; gap: 10px; margin: 14px 4px 10px; }
  .page-head .left h1 { font-size: 18px; }
  .page-head .filters { width: 100%; flex-wrap: wrap; gap: 6px; }
  .page-head .filter { font-size: 11px; padding: 5px 10px; }
  .filter-dropdown { right: auto; left: 0; }

  /* KPI 2 colonne */
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .kpi { padding: 12px 14px; }
  .kpi .val { font-size: 20px; }
  .kpi .lab { font-size: 10px; margin-bottom: 6px; }
  .kpi .delta { font-size: 10px; margin-top: 6px; }

  /* Row 1 col */
  .row { grid-template-columns: 1fr; gap: 8px; }

  /* Panel padding ridotto */
  .panel-head { padding: 10px 12px; }
  .panel-head h3 { font-size: 12px; }
  .panel-head .meta { font-size: 10px; }

  /* Tabella orizzontalmente scroll */
  .panel table { font-size: 11px; min-width: 480px; }
  .panel > table, .panel > div:has(table) { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* AI tiles 1 col */
  .ai-tiles { grid-template-columns: 1fr; }
  .ai-head { padding: 8px 12px; font-size: 11px; }
  .ai-body { padding: 10px 12px; }

  /* Draft banner */
  .draft-banner { padding: 8px 12px; font-size: 11px; gap: 8px; }

  /* Configurazione e altri minor adjustments */
  body.sec-home, body.sec-realtime, body.sec-process, body.sec-report, body.sec-drill { padding-bottom: 30px; }
}
