* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f6f7f9; color: #21252b;
}
a { color: #1f5fb0; text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: #7a8591; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  background: #1c3352; color: #fff; padding: 10px 22px;
}
.topbar .brand a { color: #fff; font-weight: 600; font-size: 15px; }
.topbar nav a { color: #d8e3f0; margin-left: 14px; }
.topbar nav a:hover { color: #fff; }
.topbar .sep { color: #425b7a; margin: 0 8px; }
.topbar .user { color: #9db7d4; font-size: 13px; }

main { max-width: 1240px; margin: 0 auto; padding: 20px; }
footer { text-align: center; color: #8a94a0; padding: 20px; }

.flashes { margin-bottom: 12px; }
.flash { padding: 9px 14px; border-radius: 4px; margin-bottom: 6px; }
.flash-error { background: #fce8e6; color: #9a2f2f; border: 1px solid #f1b8b5; }
.flash-ok { background: #e8f6ea; color: #2a6b3a; border: 1px solid #b8dfc2; }

.btn, .btn-small {
  display: inline-block; padding: 7px 14px; border-radius: 4px;
  border: 1px solid #c4cad3; background: #fff; cursor: pointer;
  font-size: 13px; color: #2c3542; text-decoration: none;
}
.btn:hover, .btn-small:hover { background: #eef1f5; text-decoration: none; }
.btn-small { padding: 4px 9px; font-size: 12px; }
.btn-primary { background: #1f5fb0; border-color: #1f5fb0; color: #fff; }
.btn-primary:hover { background: #184a8c; }
.btn-primary[disabled] { background: #b5c2d2; border-color: #b5c2d2; cursor: not-allowed; }

.card {
  background: #fff; padding: 22px; border: 1px solid #e1e5ea;
  border-radius: 6px; box-shadow: 0 1px 2px rgba(0,0,0,.03);
}

/* LOGIN */
.login-wrap { display: flex; justify-content: center; margin-top: 60px; }
.login-card { width: 340px; }
.login-card h1 { margin: 0 0 4px; font-size: 19px; }
.login-card label { display: block; margin: 12px 0 4px; font-weight: 500; }
.login-card input { width: 100%; padding: 8px; border: 1px solid #c4cad3; border-radius: 4px; font: inherit; }
.login-card button { width: 100%; margin-top: 14px; padding: 9px; }

/* SUMMARY BAR */
.summary-bar { display: flex; gap: 14px; margin-bottom: 14px; }
.summary-bar .stat {
  background: #fff; border: 1px solid #e1e5ea; border-radius: 6px;
  padding: 12px 18px; flex: 1; text-align: center;
}
.stat-label { display: block; font-size: 12px; color: #7a8591; text-transform: uppercase; letter-spacing: .3px; }
.stat-value { display: block; font-size: 22px; font-weight: 600; margin-top: 3px; }
.stat-value.ok { color: #2a6b3a; }
.stat-value.ko { color: #9a2f2f; }
.stat-value.pending { color: #a16e00; }

/* FILTER BAR */
.filter-bar { margin-bottom: 10px; display: flex; gap: 6px; }
.filter {
  padding: 6px 12px; border: 1px solid #c4cad3; border-radius: 15px;
  background: #fff; font-size: 12px; color: #4a5563;
}
.filter.active { background: #1f5fb0; color: #fff; border-color: #1f5fb0; }

/* LISTA EMAIL */
.email-list {
  width: 100%; border-collapse: collapse; background: #fff;
  border: 1px solid #e1e5ea; border-radius: 6px; overflow: hidden;
}
.email-list th, .email-list td {
  padding: 8px 10px; border-bottom: 1px solid #eef1f5;
  text-align: left; vertical-align: top;
}
.email-list th { background: #f0f3f7; font-size: 12px; font-weight: 600; color: #5a6577; }
.email-list tbody tr:hover { background: #f9fafc; }
.email-list .small { font-size: 12px; color: #5a6577; white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.email-list .rag { font-size: 12px; color: #5a6577; max-width: 380px; }
.email-list .empty { text-align: center; color: #9aa3b0; padding: 24px; }

.cat { font-size: 12px; font-weight: 500; color: #2c3542; }
.geri { background: #ffe8cc; color: #a35b00; padding: 1px 5px; border-radius: 3px; font-size: 10px; }
.conf { display: inline-block; padding: 2px 7px; border-radius: 3px; font-weight: 600; font-size: 12px; color: #fff; }
.conf-hi { background: #2a6b3a; }
.conf-md { background: #c68900; }
.conf-lo { background: #9a2f2f; }

.badge { padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.badge.ok { background: #d2ecd7; color: #2a6b3a; }
.badge.ko { background: #fce8e6; color: #9a2f2f; }
.badge.todo { background: #e1e5ea; color: #7a8591; }

.pagination { display: flex; align-items: center; gap: 12px; margin: 14px 0; justify-content: center; }

/* EMAIL DETAIL */
.back { font-size: 13px; }
.email-card { background: #fff; border: 1px solid #e1e5ea; border-radius: 6px; padding: 22px; margin-bottom: 16px; }
.email-header { display: flex; justify-content: space-between; padding-bottom: 12px; border-bottom: 1px solid #eef1f5; margin-bottom: 12px; gap: 20px; }
.email-meta div { margin-bottom: 4px; font-size: 13px; }
.email-meta code { font-size: 12px; background: #f0f3f7; padding: 1px 4px; border-radius: 3px; }
.email-cat { text-align: right; }
.cat-big { font-size: 16px; font-weight: 600; color: #1c3352; margin-bottom: 4px; }
.conf-big { display: inline-block; padding: 3px 10px; border-radius: 4px; font-weight: 600; font-size: 13px; color: #fff; }
.geri-big { margin-top: 6px; display: inline-block; background: #ffe8cc; color: #a35b00; padding: 3px 8px; border-radius: 3px; font-size: 12px; font-weight: 600; }

.email-card h2 { margin: 18px 0 8px; font-size: 15px; color: #1c3352; }
.oggetto { font-size: 14px; font-weight: 500; padding: 8px 10px; background: #f6f7f9; border-radius: 4px; }
.corpo {
  font: 13px/1.5 Consolas, "Courier New", monospace;
  white-space: pre-wrap; word-wrap: break-word;
  max-height: 360px; overflow-y: auto;
  background: #fafbfc; border: 1px solid #e1e5ea; border-radius: 4px;
  padding: 10px 12px; margin: 0;
}
.rag-box {
  padding: 10px 12px; background: #eef4fb; border-left: 3px solid #1f5fb0;
  border-radius: 0 4px 4px 0; font-size: 13.5px; line-height: 1.55;
}
.alt-box {
  padding: 10px 12px; background: #fff7e6; border-left: 3px solid #c68900;
  border-radius: 0 4px 4px 0; font-size: 13px; line-height: 1.55;
}
.technical { margin-top: 14px; color: #7a8591; }

.prev-feedback {
  background: #f9fafc; border: 1px dashed #c4cad3; padding: 10px 14px;
  border-radius: 4px; margin-bottom: 14px;
}

/* FEEDBACK FORM */
.feedback-form {
  background: #fff; border: 1px solid #e1e5ea; border-radius: 6px;
  padding: 22px; margin-bottom: 18px;
}
.feedback-form h2 { margin: 0 0 12px; font-size: 15px; color: #1c3352; }
.feedback-form label { display: block; margin: 12px 0 4px; font-weight: 500; font-size: 13px; }
.feedback-form textarea, .feedback-form select {
  width: 100%; padding: 8px; border: 1px solid #c4cad3; border-radius: 4px; font: inherit;
}
.feedback-form .req { color: #9a2f2f; }
.feedback-form .hidden { display: none; }

.choice-row { display: flex; gap: 14px; margin: 10px 0 14px; }
.choice {
  flex: 1; padding: 16px; border: 2px solid #c4cad3; border-radius: 6px;
  cursor: pointer; text-align: center; font-weight: 600; font-size: 14px;
  background: #fff; color: #2c3542;
}
.choice input { margin-right: 8px; }
.choice-ok:has(input:checked) { border-color: #2a6b3a; background: #e8f6ea; color: #2a6b3a; }
.choice-ko:has(input:checked) { border-color: #9a2f2f; background: #fce8e6; color: #9a2f2f; }

/* STATS */
.simple-tbl {
  width: 100%; border-collapse: collapse; background: #fff;
  border: 1px solid #e1e5ea; border-radius: 6px; margin-bottom: 18px;
}
.simple-tbl th, .simple-tbl td {
  padding: 8px 10px; border-bottom: 1px solid #eef1f5; text-align: left;
}
.simple-tbl th { background: #f0f3f7; font-size: 12px; }
.simple-tbl td.ok { color: #2a6b3a; font-weight: 600; }
.simple-tbl td.ko { color: #9a2f2f; font-weight: 600; }
