/* =============================================================================
   Protek Bug Tracker — tema "pannello macchina"
   Pensato per chi lo usa in officina, spesso da telefono o tablet, con poca
   confidenza col computer: testi grandi, bersagli da 44 px, niente comandi che
   appaiono solo al passaggio del mouse, stati mostrati come spie colorate.
   ========================================================================== */

:root {
  --bg: #111214;
  --bg-2: #17181c;
  --panel: #1b1c21;
  --panel-2: #23252b;
  --line: #34363d;
  --line-2: #464952;
  --red: #e3001b;
  --red-hover: #ff1f3a;
  --red-dark: #8f0012;
  --red-soft: rgba(227, 0, 27, 0.16);
  --text: #f5f5f6;
  --muted: #b3b5be;
  --ok: #35c56a;
  --ok-soft: rgba(53, 197, 106, 0.14);
  --warn: #f0b13a;
  --info: #55a8ff;
  --violet: #b892ff;
  --font: "Segoe UI", "Inter", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow: 0 14px 44px rgba(0, 0, 0, 0.6);
  --touch: 44px;
  --focus: 0 0 0 3px rgba(255, 255, 255, 0.85), 0 0 0 6px var(--red);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; line-height: 1.2; }
h2 { font-size: 24px; }
h3 { font-size: 17px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.mono { font-variant-numeric: tabular-nums; }
.grow { flex: 1; }
.danger-text { color: #ff7b8b; }

::selection { background: var(--red-dark); color: #fff; }

/* Focus sempre visibile: chi usa la tastiera deve sapere dove si trova. */
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-sm); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 5px; }

/* =============================================================================
   Controlli: tutti alti almeno 44 px
   ========================================================================== */

.btn {
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  min-height: var(--touch);
  padding: 0 18px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: #2b2d34; border-color: #575a64; }
.btn:active { background: #1e2025; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-hover); border-color: var(--red-hover); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #06210f; }
.btn-ok:hover { background: #4ad57c; border-color: #4ad57c; }
.btn-danger { background: transparent; border-color: var(--red-dark); color: #ff7b8b; }
.btn-danger:hover { background: var(--red-soft); border-color: var(--red); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--panel-2); color: var(--text); border-color: var(--line-2); }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn-icon { width: var(--touch); padding: 0; font-size: 22px; line-height: 1; }
.btn-menu { width: var(--touch); padding: 0; font-size: 22px; line-height: 1; color: var(--muted); }
.btn-add {
  width: 100%; margin-top: 10px; justify-content: flex-start;
  background: transparent; border: 1px dashed var(--line-2); color: var(--muted);
}
.btn-add:hover { color: var(--text); border-color: var(--text); background: var(--panel-2); }
.btn .ico { font-size: 18px; line-height: 1; }

input, select, textarea {
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  min-height: var(--touch);
  padding: 10px 12px;
  width: 100%;
  outline: none;
  transition: border-color 0.12s;
}
input:focus, select:focus, textarea:focus { border-color: #fff; box-shadow: var(--focus); }
textarea { min-height: 110px; resize: vertical; line-height: 1.45; }
select option { background: var(--panel); }
input[type="search"] { padding-left: 40px; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%23b3b5be' stroke-width='2.2'><circle cx='8' cy='8' r='5.5'/><path d='M12.5 12.5l4 4'/></svg>"); background-repeat: no-repeat; background-position: 12px center; }
input[type="file"] { padding: 8px; }
input[type="checkbox"] { width: 22px; height: 22px; min-height: 0; margin: 0; accent-color: var(--red); }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > span { font-size: 15px; font-weight: 600; color: var(--text); }
.field > span small { font-weight: 400; color: var(--muted); font-size: 14px; }
.field.inline { flex-direction: row; align-items: center; gap: 12px; margin: 0; }
.field.inline > span { white-space: nowrap; }
.field.inline select { width: auto; min-width: 220px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.form-error {
  color: #ff7b8b; font-size: 15px; margin: 6px 0 12px;
  padding: 10px 12px; border: 1px solid var(--red-dark); border-radius: var(--radius-sm); background: var(--red-soft);
}
.form-hint { color: var(--muted); font-size: 14px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 15px; color: var(--muted); cursor: pointer; min-height: var(--touch); }

/* =============================================================================
   Login
   ========================================================================== */

#view-login {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: linear-gradient(180deg, #16171b 0%, var(--bg) 60%);
}
.login-card {
  width: 100%; max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 6px solid var(--red);
  border-radius: 14px;
  padding: 34px 30px 28px;
  box-shadow: var(--shadow);
  text-align: center;
}
.login-logo { height: 48px; margin-bottom: 16px; }
.login-card h1 { font-size: 26px; margin-bottom: 6px; }
.login-card p { margin: 0 0 24px; font-size: 16px; }
.login-card .field { text-align: left; margin-bottom: 4px; }
.login-card input[type="password"], .login-card input[type="text"] { font-size: 20px; letter-spacing: 0.06em; min-height: 52px; }
.login-card .btn-primary { min-height: 52px; font-size: 18px; margin-top: 6px; }

/* =============================================================================
   Barra alta
   ========================================================================== */

.appbar {
  height: 60px;
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
  background: var(--panel);
  border-bottom: 2px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; min-height: var(--touch); }
.brand img { height: 30px; }
.brand-sub { font-size: 15px; color: var(--muted); border-left: 1px solid var(--line-2); padding-left: 12px; }
.appbar-center { flex: 1; text-align: center; color: var(--muted); font-size: 15px; }
.appbar-actions { display: flex; gap: 10px; margin-left: auto; align-items: center; }
.role-badge {
  display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600;
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--muted); background: var(--bg-2);
}
.role-badge.admin { color: var(--warn); border-color: #6b4d12; }
.role-badge .lamp { width: 10px; height: 10px; }
.lamp.admin { background: var(--warn); }
.lamp.user { background: var(--muted); }
body.role-user .admin-only { display: none !important; }

.view { padding: 24px 24px 48px; max-width: 1600px; margin: 0 auto; }

/* =============================================================================
   Programmi
   ========================================================================== */

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.programs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.program-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 6px solid var(--line-2);
  border-radius: var(--radius);
  padding: 20px;
  display: flex; gap: 16px; align-items: flex-start;
  cursor: pointer;
  min-height: 132px;
  transition: border-color 0.12s, background 0.12s;
}
.program-card:hover, .program-card:focus-visible { border-color: var(--red); background: var(--panel-2); }
.program-card.has-open { border-left-color: var(--red); }
.program-card.new {
  justify-content: center; align-items: center;
  border: 2px dashed var(--line-2); color: var(--muted); font-weight: 600; font-size: 17px;
}
.program-card.new:hover { color: var(--text); border-color: var(--text); }
.program-card .icon {
  width: 64px; height: 64px; flex: none;
  border-radius: 12px;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 26px; color: var(--red);
  overflow: hidden;
}
.program-card .icon img { width: 100%; height: 100%; object-fit: cover; }
.program-card .body { flex: 1; min-width: 0; padding-right: 40px; }
.program-card .name { font-weight: 700; font-size: 19px; margin-bottom: 4px; }
.program-card .desc { color: var(--muted); font-size: 15px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.program-card .meta { margin-top: 12px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.program-card .menu { position: absolute; top: 10px; right: 10px; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 14px; font-weight: 600;
  padding: 4px 10px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line-2); color: var(--muted);
}
.badge.red { background: var(--red-soft); border-color: var(--red-dark); color: #ff8a97; }

/* Spazio usato */
.storage {
  margin-top: 26px; padding: 16px 18px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.storage .row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.storage .row b { font-size: 17px; }
.storage .bar { height: 14px; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 7px; overflow: hidden; display: flex; }
.storage .bar i { display: block; height: 100%; background: var(--info); }
.storage .bar i:nth-child(2n) { filter: brightness(0.8); }
.storage.warn .bar i { background: var(--warn); }
.storage.full .bar i { background: var(--red); }
.storage .legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 10px; color: var(--muted); font-size: 15px; }
.storage .legend button { background: none; border: 0; color: var(--info); font: inherit; cursor: pointer; padding: 0; text-decoration: underline; }
.storage .hint { margin-top: 10px; color: var(--muted); font-size: 14px; }

.preview-box {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; margin: 6px 0 14px;
  font-size: 16px; min-height: 72px; display: flex; flex-direction: column; justify-content: center; gap: 4px;
}
.preview-box b { font-size: 20px; }
.preview-box.none { color: var(--muted); }

/* Menu a tendina */
.popmenu {
  position: fixed; z-index: 60;
  min-width: 220px;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 6px;
}
.popmenu button {
  display: flex; align-items: center; width: 100%; text-align: left; min-height: var(--touch);
  background: none; border: 0; color: var(--text);
  font: inherit; font-size: 16px; padding: 0 14px; border-radius: var(--radius-sm); cursor: pointer;
}
.popmenu button:hover { background: var(--panel); }
.popmenu button:disabled { opacity: 0.4; cursor: default; }
.popmenu button.danger { color: #ff7b8b; }
.popmenu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }

/* =============================================================================
   Programma
   ========================================================================== */

.program-head {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}
.program-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.program-title .back {
  color: var(--muted); font-size: 24px; width: var(--touch); height: var(--touch); flex: none;
  display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-sm);
}
.program-title .back:hover { color: var(--text); background: var(--panel-2); }
.program-icon {
  width: 48px; height: 48px; flex: none; border-radius: 10px;
  background: var(--bg-2); border: 1px solid var(--line-2);
  display: flex; align-items: center; justify-content: center;
  color: var(--red); font-weight: 800; font-size: 20px; overflow: hidden;
}
.program-icon img { width: 100%; height: 100%; object-fit: cover; }
.program-tabs { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 4px; }
.program-tabs .tab { min-height: 40px; display: inline-flex; align-items: center; padding: 0 22px; border-radius: 999px; color: var(--muted); font-weight: 600; font-size: 16px; }
.program-tabs .tab.active { background: var(--red); color: #fff; }
.program-actions { display: flex; gap: 10px; justify-content: flex-end; align-items: center; }
.program-actions input[type="search"] { max-width: 320px; }

.three-cols {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 260px;
  align-items: stretch;
}
/* Colonne senza sfondo: le separano solo due linee verticali a tutta altezza. */
.col { padding: 0 20px; min-height: 320px; }
.col-versions { padding-left: 0; border-right: 1px solid var(--line); }
.col-categories { padding-right: 0; border-left: 1px solid var(--line); }
.col-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 12px; }
.col-head h3 { font-size: 17px; }
.side-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.side-list li {
  display: flex; align-items: center; gap: 8px;
  min-height: var(--touch);
  padding: 6px 4px 6px 10px; border-radius: var(--radius-sm); cursor: pointer;
  border-left: 4px solid transparent;
  transition: background 0.12s;
}
.side-list li:hover { background: var(--panel-2); }
.side-list li.active { background: var(--panel-2); border-left-color: var(--red); }
.side-list li .label { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 16px; font-weight: 500; }
.side-list li.active .label { font-weight: 700; }
.side-list li .sub { display: block; font-size: 13px; color: var(--muted); font-weight: 400; }
.side-list li .count {
  min-width: 30px; height: 28px; padding: 0 9px;
  border-radius: 999px; font-size: 14px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-2); border: 1px solid var(--line-2); color: var(--muted);
}
.side-list li .count.hot { background: var(--red-soft); border-color: var(--red-dark); color: #ff8a97; }
.side-list li .count.zero { opacity: 0.4; }
.side-list .empty { color: var(--muted); font-size: 15px; padding: 10px; cursor: default; }

/* Tipo + stato */
.type-toggle { display: inline-flex; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 999px; padding: 4px; margin-bottom: 14px; }
.type-toggle button { font: inherit; font-size: 16px; font-weight: 600; color: var(--muted); background: none; border: 0; min-height: 40px; padding: 0 20px; border-radius: 999px; cursor: pointer; }
.type-toggle button.active { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }
.type-toggle button[data-type="improvement"].active { color: var(--violet); }

.status-tabs { display: flex; gap: 8px; flex-wrap: wrap; border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 14px; }
.status-tabs button {
  font: inherit; font-weight: 600; font-size: 16px;
  color: var(--muted); background: var(--bg-2); border: 1px solid var(--line);
  min-height: var(--touch); padding: 0 14px; border-radius: var(--radius-sm); cursor: pointer;
  display: inline-flex; align-items: center; gap: 10px;
}
.status-tabs button:hover { background: var(--panel-2); color: var(--text); }
.status-tabs button.active { color: var(--text); border-color: var(--text); background: var(--panel-2); }
.status-tabs button .n {
  font-size: 14px; font-weight: 700; color: var(--text);
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 999px; min-width: 26px; height: 24px;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 7px;
}
/* Spie di stato: quadrate, come le lampade di un pannello. */
.lamp { width: 12px; height: 12px; border-radius: 3px; display: inline-block; flex: none; }
.lamp.open { background: var(--red); box-shadow: 0 0 8px var(--red); }
.lamp.discuss { background: var(--warn); }
.lamp.testing { background: var(--info); }
.lamp.notfound { background: var(--muted); }
.lamp.solved { background: var(--ok); }
.lamp.improvement { background: var(--violet); }
.lamp.bug { background: var(--red); }

/* Lista segnalazioni */
.issues-list { display: flex; flex-direction: column; gap: 22px; }
/* Ogni segnalazione è una scheda a sé; la priorità è solo un'etichetta sopra il suo gruppo. */
.prio-group { display: flex; flex-direction: column; gap: 10px; }
.prio-head {
  display: flex; align-items: center; gap: 10px;
  min-height: 32px; padding: 0 12px; font-size: 15px; font-weight: 700;
  color: var(--text);
  border-left: 6px solid var(--line-2);
}
.prio-head .n { margin-left: auto; color: var(--muted); font-weight: 600; }
.prio-head.high { border-left-color: var(--red); }
.prio-head.medium { border-left-color: var(--warn); }
.prio-head.low { border-left-color: var(--line-2); }
.issue-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  gap: 14px; align-items: start;
  min-height: 64px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.issue-row:hover { background: var(--panel-2); border-color: var(--line-2); }
/* Con una segnalazione aperta le altre si attenuano, per non distrarre; tornano nitide sotto il mouse. */
.issues-list.expanded .issue-row:not(.active), .issues-list.expanded .prio-head { opacity: 0.38; transition: opacity 0.15s; }
.issues-list.expanded .issue-row:not(.active):hover, .issues-list.expanded .issue-row:not(.active):focus-visible { opacity: 1; }
.issue-row.active {
  background: var(--panel-2); border-color: var(--line-2);
  box-shadow: inset 4px 0 0 var(--red);
  border-bottom-color: transparent; border-bottom-left-radius: 0; border-bottom-right-radius: 0;
}
.issue-row:focus-visible { outline: 2px solid var(--red); outline-offset: -2px; }
.issue-row .num {
  font-size: 17px; font-weight: 700; color: var(--text);
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  min-height: 40px; display: inline-flex; align-items: center; justify-content: center; padding: 0 8px;
}
.issue-row .title { font-weight: 600; font-size: 17px; line-height: 1.3; white-space: normal; overflow-wrap: anywhere; padding-top: 8px; }
.issue-row .sub { font-size: 14px; color: var(--muted); display: flex; gap: 8px 12px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.issue-row .right { display: flex; gap: 12px; align-items: center; color: var(--muted); font-size: 14px; padding-top: 11px; white-space: nowrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 14px; padding: 3px 10px; border-radius: 999px;
  background: var(--bg-2); border: 1px solid var(--line-2); color: var(--muted); white-space: nowrap;
}
.chip.legacy { color: var(--violet); border-color: #4f3f73; }
.chip.type-improvement { color: var(--violet); border-color: #4f3f73; }
.chip.type-bug { color: #ff8a97; border-color: var(--red-dark); }
.chip.status-open { color: #ff8a97; border-color: var(--red-dark); }
.chip.status-discuss { color: var(--warn); border-color: #6b4d12; }
.chip.status-testing { color: var(--info); border-color: #1f4a75; }
.chip.status-notfound { color: var(--muted); }
.chip.status-solved { color: var(--ok); border-color: #1f5a33; }
.empty-state {
  text-align: center; color: var(--muted); padding: 40px 20px;
  border: 2px dashed var(--line-2); border-radius: var(--radius); font-size: 16px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.empty-state b { color: var(--text); font-size: 18px; }

.mobile-tabs { display: none; }

/* =============================================================================
   Dettaglio espanso sotto la riga della segnalazione
   ========================================================================== */

.issue-detail {
  margin-top: -10px;                 /* annulla il gap del gruppo: riga e dettaglio sono un'unica scheda */
  padding: 14px 20px 20px;
  background: var(--panel);
  border: 1px solid var(--line-2); border-top: 0;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: inset 4px 0 0 var(--red);
  animation: fade 0.12s ease;
}
.detail-top { display: flex; align-items: flex-start; gap: 10px; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; padding-top: 4px; }
.detail-close { flex: none; }
.issue-detail .when { color: var(--muted); font-size: 15px; margin: 10px 0 16px; }
.detail-actions {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px;
  margin: 24px 0 0; padding: 14px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius);
}
.detail-actions > * { min-width: 0; }
.detail-actions .btn { min-height: 52px; font-size: 16px; white-space: normal; }
.detail-actions .btn-danger { grid-column: 1 / -1; min-height: var(--touch); }
.detail-actions select { min-height: 52px; font-weight: 600; }
.issue-detail section { margin-bottom: 24px; }
.issue-detail section:last-child { margin-bottom: 0; }
.issue-detail section h3 { margin-bottom: 10px; display: flex; align-items: center; gap: 10px; }
.issue-detail section h3 .btn { margin-left: auto; }
.desc-box { white-space: pre-wrap; word-break: break-word; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; font-size: 16px; line-height: 1.5; }
.resolution-box { border: 1px solid #2a6b40; background: var(--ok-soft); border-radius: var(--radius-sm); padding: 14px; }
.resolution-box.notfound { border-color: var(--line-2); background: var(--bg-2); }
.resolution-box .who { font-size: 15px; color: var(--muted); margin-top: 10px; }
.note-list { display: flex; flex-direction: column; gap: 8px; }
.note {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px;
}
.note .txt { flex: 1; white-space: pre-wrap; word-break: break-word; font-size: 16px; }
.note .when { font-size: 13px; color: var(--muted); white-space: nowrap; margin: 0; padding-top: 4px; }
.note.resolution { border-left: 4px solid var(--ok); }
.att-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.att {
  position: relative; display: flex; flex-direction: column; gap: 6px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px;
}
.att img { width: 100%; height: 100px; object-fit: cover; border-radius: 6px; cursor: zoom-in; }
.att .file { height: 100px; display: flex; align-items: center; justify-content: center; font-size: 36px; }
.att .name { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att .size { font-size: 13px; color: var(--muted); }
.att .del { position: absolute; top: 6px; right: 6px; width: 36px; height: 36px; min-height: 0; padding: 0; font-size: 16px; background: rgba(17, 18, 20, 0.85); }
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--red); width: 0; transition: width 0.15s; }

/* =============================================================================
   Finestre di dialogo
   ========================================================================== */

.dialog-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, 0.65);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  animation: fade 0.1s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.dialog {
  width: 100%; max-width: 640px; max-height: calc(100vh - 32px); overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-top: 6px solid var(--red);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 24px 26px;
}
.dialog.narrow { max-width: 480px; }
.dialog.wide { max-width: 800px; }
.dialog h2 { font-size: 22px; margin-bottom: 6px; }
.dialog .lead { color: var(--muted); margin: 0 0 18px; font-size: 16px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.dialog-actions .btn { min-height: 48px; }
.dialog p { margin: 0 0 12px; font-size: 16px; }
.dialog ul.counts { margin: 6px 0 14px; padding-left: 22px; color: var(--muted); font-size: 16px; }

.notes-editor { display: flex; flex-direction: column; gap: 8px; }
.notes-editor .row { display: flex; gap: 8px; }
.notes-editor textarea { min-height: 52px; }
.dropzone {
  border: 2px dashed var(--line-2); border-radius: var(--radius-sm); padding: 18px; text-align: center;
  color: var(--muted); font-size: 15px; cursor: pointer; min-height: 72px;
  transition: border-color 0.12s, background 0.12s;
}
.dropzone b { color: var(--text); font-size: 16px; }
.dropzone:hover, .dropzone.over { border-color: var(--red); background: var(--red-soft); color: var(--text); }
.pending-files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.pending-files .chip { padding: 6px 6px 6px 12px; font-size: 15px; }
.pending-files .chip button { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 18px; width: 32px; height: 32px; padding: 0; }
.upload-log { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.upload-log .row { display: grid; grid-template-columns: 1fr 140px; gap: 12px; align-items: center; }

.segmented { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius-sm); overflow: hidden; width: 100%; }
.segmented button {
  flex: 1; font: inherit; font-size: 16px; font-weight: 600; background: var(--bg-2); color: var(--muted); border: 0;
  min-height: var(--touch); padding: 0 12px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.segmented button + button { border-left: 1px solid var(--line-2); }
.segmented button.active { background: var(--panel-2); color: var(--text); box-shadow: inset 0 -3px 0 var(--text); }
.segmented button.active[data-value="high"] { box-shadow: inset 0 -3px 0 var(--red); }
.segmented button.active[data-value="medium"] { box-shadow: inset 0 -3px 0 var(--warn); }
.segmented button.active[data-value="improvement"] { box-shadow: inset 0 -3px 0 var(--violet); color: var(--violet); }
.segmented button.active[data-value="bug"] { box-shadow: inset 0 -3px 0 var(--red); }

.icon-preview { width: 72px; height: 72px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--bg-2); object-fit: cover; }

/* =============================================================================
   Changelog
   ========================================================================== */

.changelog { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 24px 32px; }
.changelog-toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.changelog-body h2.ver { font-size: 24px; margin: 26px 0 12px; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.changelog-body h2.ver:first-child { margin-top: 0; }
.changelog-body h2.ver .date { font-size: 16px; color: var(--muted); font-weight: 500; }
.changelog-body h3.sec { margin: 16px 0 8px; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.changelog-body h3.sec.improvements { color: var(--violet); }
.changelog-body h3.sec.bugs { color: var(--ok); }
.changelog-body h4.cat { font-size: 16px; color: var(--muted); margin: 12px 0 6px; font-weight: 600; }
.changelog-body ul { margin: 0 0 8px; padding-left: 22px; }
.changelog-body li { margin-bottom: 8px; font-size: 16px; line-height: 1.5; }
.changelog-body li .n { font-weight: 700; }
.changelog-body li .from { color: var(--muted); font-size: 14px; }
.changelog-body li .who { color: var(--muted); font-size: 14px; }

/* =============================================================================
   Avvisi
   ========================================================================== */

.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 100;
  background: var(--panel-2); border: 1px solid var(--line-2); border-left: 6px solid var(--info);
  color: var(--text); padding: 14px 18px; border-radius: var(--radius-sm); box-shadow: var(--shadow);
  max-width: 460px; font-size: 16px;
  animation: slide 0.15s ease;
}
@keyframes slide { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.toast.ok { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--red); }

/* =============================================================================
   Schermi stretti
   ========================================================================== */

@media (max-width: 1200px) {
  .program-head { grid-template-columns: 1fr; }
  .program-tabs { justify-self: start; }
  .program-actions { justify-content: flex-start; flex-wrap: wrap; }
  .program-actions input[type="search"] { max-width: none; flex: 1; min-width: 200px; }
  .three-cols { grid-template-columns: 210px minmax(0, 1fr) 230px; }
}

@media (max-width: 900px) {
  .view { padding: 14px 12px 96px; }
  .appbar { padding: 0 12px; height: 56px; }
  .brand-sub { display: none; }
  .appbar-center { display: none; }
  .role-badge span.txt { display: none; }
  .program-actions { display: grid; grid-template-columns: 1fr auto; }
  .program-actions input[type="search"] { max-width: none; }
  .program-actions #programMenuBtn { grid-row: 1; grid-column: 2; }
  /* Il bottone principale sta fisso in basso, a portata di pollice. */
  .program-actions #newIssueBtn {
    position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 25;
    min-height: 56px; font-size: 18px; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
  }
  .mobile-tabs {
    display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line);
    border-radius: 999px; padding: 4px; margin-bottom: 14px;
  }
  .mobile-tabs button {
    flex: 1; font: inherit; font-size: 16px; font-weight: 600; color: var(--muted); background: none; border: 0;
    min-height: var(--touch); border-radius: 999px; cursor: pointer;
  }
  .mobile-tabs button.active { background: var(--red); color: #fff; }
  .three-cols { display: block; }
  .col, .col-versions, .col-categories { padding: 0; border: 0; min-height: 0; }
  .pane { display: none; }
  .pane.active { display: block; }
  .issue-row { grid-template-columns: 60px minmax(0, 1fr); }
  .issue-row .right { grid-column: 2; justify-content: flex-start; flex-wrap: wrap; padding-top: 0; white-space: normal; }
  .field-row, .field-row-3 { grid-template-columns: 1fr; }
  .issue-detail { padding: 14px 12px 18px; }
  .detail-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 10px; gap: 8px; }
  .dialog { padding: 20px 16px; }
  .dialog-actions .btn { flex: 1; }
  .program-title h2 { font-size: 20px; }
  .toast { left: 12px; right: 12px; bottom: 80px; max-width: none; }
}

/* =============================================================================
   Stampa: solo il changelog
   ========================================================================== */

@media print {
  body { background: #fff; color: #000; font-size: 12pt; }
  .appbar, .program-head, .mobile-tabs, #issuesLayout, .changelog-toolbar, .toast, .issue-detail, #dialogHost { display: none !important; }
  .view { padding: 0; max-width: none; }
  .changelog { border: 0; padding: 0; background: #fff; }
  .changelog-body h2.ver { color: #000; border-bottom: 1px solid #000; padding-bottom: 4px; }
  .changelog-body h2.ver .date, .changelog-body li .from, .changelog-body li .who, .changelog-body h4.cat { color: #444; }
  .changelog-body h3.sec, .changelog-body h3.sec.bugs, .changelog-body h3.sec.improvements { color: #000; }
  .lamp { display: none; }
  a { color: #000; }
}
