/* Guard4AI — grafica comune ai tre livelli (utente, costruttore, staff), dallo stile di docs/ui-mockup/Sistema.
   Nessuna risorsa esterna: Inter e JetBrains Mono se installati, altrimenti i font di sistema. */

:root {
  --accent: #2445C9;            /* sostituito dal colore del tenant (white-label) nel template */
  --accent-hover: #1A339A;
  --bg: #F4F6F9;
  --surface: #FFFFFF;
  --border: #E3E7EE;
  --divider: #EEF1F5;
  --control: #D5DBE4;
  --ink: #111827;
  --ink-2: #374151;
  --muted: #5B6474;
  --side: #0F172A;
  --side-active: #1E293B;
  --side-ink: #CBD5E1;
  --side-muted: #94A3B8;
  --ok-bg: #E6F4EC; --ok-ink: #146C3A; --ok-dot: #1E8E4E;
  --warn-bg: #FFF4DE; --warn-ink: #8A5300; --warn-dot: #D18A00; --warn-border: #F0D29A;
  --crit-bg: #FDECEA; --crit-ink: #A8201A; --crit-border: #F1B9B3;
  --neutral-bg: #EEF1F5; --neutral-ink: #374151; --neutral-dot: #9AA3B2;
  /* nomi usati dalle pagine esistenti */
  --line: var(--border); --card: var(--surface);
  --green: var(--ok-dot); --yellow: var(--warn-dot); --red: var(--crit-ink);
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.5 var(--font); color: var(--ink); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
h2 { margin: 0 0 12px; font-size: 18px; font-weight: 600; }
h3 { margin: 0; font-size: 16px; font-weight: 600; }
p { margin: 0 0 10px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------------------------------------------------------- struttura */
.g4-shell { min-height: 100vh; display: flex; flex-wrap: wrap; align-items: stretch; }
.g4-side { flex: 1 1 240px; max-width: 260px; background: var(--side); color: var(--side-ink); padding: 20px 16px;
           display: flex; flex-direction: column; gap: 4px; }
.g4-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 20px; color: #fff; }
.g4-brand img { max-height: 32px; max-width: 140px; }
.g4-brand .name { font-size: 17px; font-weight: 700; color: #fff; }
.g4-brand .sub { font-size: 12px; color: var(--side-muted); }
.g4-side .section { margin: 18px 8px 6px; font-size: 11px; font-weight: 600; letter-spacing: .06em; color: var(--side-muted);
                    text-transform: uppercase; }
.g4-side .section:first-of-type { margin-top: 8px; }
.g4-side a.item { padding: 10px 12px; border-radius: 8px; color: var(--side-ink); font-size: 14px; }
.g4-side a.item:hover { background: var(--side-active); color: #fff; text-decoration: none; }
.g4-side a.item.active { background: var(--side-active); color: #fff; font-weight: 600; }
.g4-side .spacer { flex: 1 1 auto; min-height: 24px; }
.g4-user { display: flex; align-items: center; gap: 10px; padding: 12px 8px 0; border-top: 1px solid var(--side-active); }
.g4-user .avatar { width: 34px; height: 34px; border-radius: 999px; background: var(--side-active); color: #fff; flex: 0 0 auto;
                   display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; }
.g4-user .who { min-width: 0; flex: 1 1 auto; }
.g4-user .who b { display: block; color: #fff; font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
.g4-user .who span { display: block; font-size: 12px; color: var(--side-muted); white-space: nowrap; overflow: hidden;
                     text-overflow: ellipsis; }
.g4-user button { background: none; border: 1px solid var(--side-active); color: var(--side-ink); padding: 6px 10px;
                  white-space: nowrap; flex: 0 0 auto; }
.g4-user button:hover { background: var(--side-active); color: #fff; }
.g4-lang { display: flex; gap: 6px; padding: 10px 8px 0; }
.g4-lang button { background: none; border: 0; color: var(--side-muted); padding: 2px 4px; font-size: 12px; }
.g4-lang button[aria-current="true"] { color: #fff; font-weight: 600; text-decoration: underline; }

.g4-main { flex: 999 1 640px; min-width: 0; display: flex; flex-direction: column; }
.g4-top { background: var(--surface); border-bottom: 1px solid var(--border); padding: 12px 32px; display: flex; gap: 12px;
          align-items: center; flex-wrap: wrap; min-height: 58px; }
.g4-top .grow { flex: 1 1 auto; }
.g4-content { padding: 28px 32px 56px; display: flex; flex-direction: column; gap: 24px; max-width: 1400px; width: 100%; }
.g4-content > h1 + p.muted, .page-sub { margin: -18px 0 0; color: var(--muted); font-size: 14px; }
.g4-public { max-width: 1120px; margin: 0 auto; padding: 32px 24px 64px; }
.g4-public-brand { text-align: center; margin-top: 24px; }
.g4-public-brand img { max-height: 64px; max-width: 256px; }
.g4-public-brand .name { font-size: 20px; font-weight: 600; }

@media (max-width: 900px) {
  .g4-side { max-width: none; flex-basis: 100%; padding: 12px 16px; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .g4-brand { padding: 0 8px 0 0; }
  .g4-side .section, .g4-side .spacer { display: none; }
  .g4-user { border-top: 0; padding: 0; margin-left: auto; }
  .g4-lang { padding: 0; }
  .g4-top, .g4-content { padding-left: 16px; padding-right: 16px; }
}

/* ---------------------------------------------------------------- componenti */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 20px 24px; overflow-x: auto; }
.card.warn { background: var(--warn-bg); border-color: var(--warn-border); color: #5C3800; }
.card.crit { background: var(--crit-bg); border-color: var(--crit-border); }
.grid { display: grid; gap: 24px; }
.two { grid-template-columns: 2fr 1fr; }
.three { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
@media (max-width: 900px) { .two { grid-template-columns: 1fr; } }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px 20px; }
.kpi .l { margin: 0; font-size: 13px; color: var(--muted); }
.kpi .n { margin: 6px 0 0; font-size: 28px; font-weight: 700; }
.kpi .n small { font-size: 16px; font-weight: 500; color: var(--muted); }
.kpi .s { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.bar { margin-top: 10px; height: 6px; border-radius: 999px; background: var(--divider); overflow: hidden; }
.bar > span { display: block; height: 6px; border-radius: 999px; background: var(--accent); }
.bar > span.warn { background: var(--warn-dot); } .bar > span.crit { background: var(--crit-ink); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 8px; border-bottom: 1px solid var(--divider); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; letter-spacing: .02em; text-transform: uppercase;
     border-bottom-color: var(--border); padding-top: 10px; padding-bottom: 10px; }
tr:last-child td { border-bottom: 0; }

.pill, .sev { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap;
              background: var(--neutral-bg); color: var(--neutral-ink); border: 0; }
.pill.ok { background: var(--ok-bg); color: var(--ok-ink); }
.pill.warn, .sev-medium { background: var(--warn-bg); color: var(--warn-ink); }
.pill.crit, .sev-high, .sev-critical { background: var(--crit-bg); color: var(--crit-ink); }
.sev-low, .sev-info { background: var(--neutral-bg); color: var(--neutral-ink); }
.chip { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); padding: 8px 12px;
        border-radius: 999px; background: var(--neutral-bg); }
.chip.warn { color: var(--warn-ink); background: var(--warn-bg); font-weight: 600; }
.chip.crit { color: var(--crit-ink); background: var(--crit-bg); font-weight: 600; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 999px; margin-right: 6px; vertical-align: middle;
       background: var(--neutral-dot); }
.dot.green { background: var(--ok-dot); } .dot.yellow { background: var(--warn-dot); } .dot.red { background: var(--crit-ink); }
.dot.grey { background: var(--neutral-dot); }

.muted { color: var(--muted); }
.bad { color: var(--crit-ink); }
.mono { font-family: var(--mono); font-size: 13px; word-break: break-all; }
pre { white-space: pre-wrap; word-break: break-all; margin: 0; font-family: var(--mono); font-size: 13px; background: var(--bg);
      padding: 10px 12px; border-radius: 8px; }
dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; }
dt { color: var(--muted); }
dd { margin: 0; }

button, .btn { font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
               padding: 10px 14px; border-radius: 10px; background: var(--surface); color: var(--ink); border: 1px solid var(--control); }
button:hover, .btn:hover { border-color: var(--muted); text-decoration: none; color: var(--ink); }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover, .btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
button.danger, .btn.danger { color: var(--crit-ink); border-color: var(--crit-border); }
form.inline { display: inline; }
input, select, textarea { font: inherit; font-size: 14px; padding: 8px 10px; border: 1px solid var(--control); border-radius: 8px;
                          background: var(--surface); color: var(--ink); max-width: 100%; }
label { color: var(--ink-2); }

.msg { padding: 12px 16px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); }
.msg.warning, .msg.error { background: var(--warn-bg); border-color: var(--warn-border); color: #5C3800; }
.msg.success { background: var(--ok-bg); border-color: #BFE3CD; color: var(--ok-ink); }
.banner { padding: 10px 32px; font-weight: 600; font-size: 13px; background: var(--warn-bg); color: var(--warn-ink);
          border-bottom: 1px solid var(--warn-border); }
.banner a { color: inherit; text-decoration: underline; }

.story { margin: 0 0 12px; padding-left: 20px; line-height: 1.8; }
.vcount { display: flex; gap: 14px; flex-wrap: wrap; margin: 8px 0; }
.vcount b { font-size: 20px; margin-right: 3px; }
.vtable { table-layout: fixed; }
.vtable td.mono { overflow-wrap: anywhere; }
.vtable td:nth-child(2) { overflow-wrap: normal; word-break: keep-all; }

.auth-card { max-width: 420px; margin: 64px auto; }
.auth-card h1 { font-size: 24px; margin-bottom: 12px; }
.auth-card input:not([type=hidden]) { width: 100%; }

@media print {
  .g4-side, .g4-top, .banner, .noprint, form { display: none !important; }
  body, .g4-content { background: #fff; padding: 0; }
  .card { border-color: #ccc; }
}

/* ---------------------------------------------------------------- livello utente (U5) */
.site-card { display: flex; flex-direction: column; gap: 10px; color: var(--ink); }
.site-card:hover { text-decoration: none; border-color: var(--control); color: var(--ink); }
.site-card.status-check { border: 2px solid #E0B867; padding: 19px 23px; }
.site-card.status-action { border: 2px solid var(--crit-border); padding: 19px 23px; }
.site-card .status { margin: 0; font-size: 13px; font-weight: 600; }
.site-card.status-ok .status { color: var(--ok-ink); }
.site-card.status-check .status { color: var(--warn-ink); }
.site-card.status-action .status { color: var(--crit-ink); }
.site-card h3 { font-size: 18px; }
.site-card .last { margin: 0; padding-top: 12px; border-top: 1px solid var(--divider); font-size: 14px; color: var(--ink-2); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--divider); }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { flex: 0 0 92px; font-size: 13px; color: var(--muted); padding-top: 2px; }
.timeline .mark { flex: 0 0 auto; padding-top: 4px; }
.timeline .mark .dot { width: 10px; height: 10px; margin: 0; }
.timeline .what { flex: 1 1 auto; min-width: 0; }
.timeline .what p { margin: 0; font-size: 15px; line-height: 1.5; }
.timeline .what p.where { font-size: 13px; font-weight: 600; color: var(--muted); }
.timeline .what p.chips { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.timeline .pill { font-size: 13px; font-weight: 500; padding: 4px 10px; }
.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.periods { border: 0; padding: 0; margin: 0 0 12px; display: flex; flex-direction: column; gap: 8px; }
.periods legend { color: var(--ink-2); margin-bottom: 6px; padding: 0; }
.reply { border-left: 3px solid var(--accent); padding: 4px 0 4px 12px; margin: 8px 0; }
.report-link { margin-top: 6px !important; font-size: 13px !important; }
