:root {
  --bg: #f7f6f2;
  --fg: #1f2328;
  --muted: #6b7280;
  --brand: #1e3a5f;
  --accent: #b45309;
  --card: #ffffff;
  --line: #e5e7eb;
  --notice: #fff7ed;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
  line-height: 1.55;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.5rem;
  background: var(--brand);
  color: #fff;
}

.brand {
  color: #fff;
  text-decoration: none;
  font-size: 1.35rem;
  letter-spacing: 0.02em;
}

.brand .ia { color: #fbbf24; font-weight: bold; }

.nav a {
  color: #e5e7eb;
  text-decoration: none;
  margin-left: 1.2rem;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.95rem;
}

.nav a:hover { color: #fff; text-decoration: underline; }

.content {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1rem 3rem;
}

.hero h1 { font-size: 2rem; margin: 0 0 0.6rem; color: var(--brand); }
.lead { font-size: 1.1rem; }
.stats { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
.muted { color: var(--muted); font-size: 0.95rem; }

.notice {
  margin-top: 2rem;
  padding: 1rem 1.2rem;
  background: var(--notice);
  border: 1px solid #fdba74;
  border-radius: 8px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.95rem;
}
.notice h2 { margin: 0 0 0.5rem; font-size: 1rem; color: var(--accent); }

.footer {
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem 1rem 2rem;
  border-top: 1px solid var(--line);
  font-size: 0.9rem;
  color: var(--muted);
}

@media (max-width: 600px) {
  .topbar { flex-direction: column; gap: 0.5rem; }
  .nav a { margin: 0 0.6rem; }
  .hero h1 { font-size: 1.5rem; }
}

/* ----- W1: form, card, tabelle ----- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.4rem 1.6rem;
  margin-bottom: 1.5rem;
}
.card.narrow { max-width: 480px; margin-left: auto; margin-right: auto; }
.card h1 { margin-top: 0; font-size: 1.5rem; color: var(--brand); }
.card h2 { font-size: 1.1rem; color: var(--brand); margin: 1.2rem 0 0.4rem; }

.form { display: flex; flex-direction: column; gap: 0.9rem; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
.form label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.95rem; }
.form label.check { flex-direction: row; align-items: center; gap: 0.6rem; }
.form input[type="text"], .form input[type="email"], .form input[type="password"],
.form textarea, .form select {
  font: inherit; padding: 0.55rem 0.7rem; border: 1px solid #cbd5e1; border-radius: 6px; background: #fff;
}
.form input:focus, .form textarea:focus, .form select:focus { outline: 2px solid var(--brand); outline-offset: 1px; }

.btn {
  display: inline-block; font: inherit; font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--brand); color: #fff; border: 0; border-radius: 6px; padding: 0.6rem 1.1rem; cursor: pointer;
  align-self: flex-start;
}
.btn:hover { background: #16304f; }
.btn.small { padding: 0.3rem 0.6rem; font-size: 0.85rem; }
.btn.secondary { background: #64748b; }
.btn.danger { background: #b91c1c; }

.linklike { background: none; border: 0; color: #e5e7eb; cursor: pointer; font: inherit; font-family: system-ui, sans-serif; font-size: 0.95rem; padding: 0; }
.linklike:hover { color: #fff; text-decoration: underline; }
.nav form.inline { display: inline; margin-left: 1.2rem; }

.ok { color: #166534; background: #f0fdf4; border: 1px solid #bbf7d0; padding: 0.6rem 0.8rem; border-radius: 6px; }
.error { color: #991b1b; background: #fef2f2; border: 1px solid #fecaca; padding: 0.6rem 0.8rem 0.6rem 1.6rem; border-radius: 6px; margin: 0 0 0.8rem; }
p.error { padding-left: 0.8rem; }

.table { width: 100%; border-collapse: collapse; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 0.92rem; }
.table th, .table td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; }
.table .actions form { display: flex; gap: 0.3rem; flex-wrap: wrap; }
code { font-family: Consolas, "Courier New", monospace; background: #f1f5f9; padding: 0.1rem 0.35rem; border-radius: 4px; }

/* ----- W2: ricerca, catalogo, conversazione ----- */
.searchbar { display: flex; gap: 0.6rem; margin-bottom: 0.6rem; }
.searchbar input[type="search"] { flex: 1; font: inherit; padding: 0.6rem 0.8rem; border: 1px solid #cbd5e1; border-radius: 6px; }
.results { list-style: none; padding: 0; margin: 0; }
.result { padding: 0.8rem 0; border-bottom: 1px solid var(--line); }
.result-title { font-weight: bold; }
.result-meta { margin: 0.3rem 0 0 1.7rem; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tag { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 0.78rem; background: #eef2f7; color: #334155; padding: 0.1rem 0.5rem; border-radius: 999px; }
.tag.score { background: #ecfdf5; color: #065f46; }
.excerpt { margin: 0.5rem 0 0 1.7rem; white-space: pre-wrap; font-family: Georgia, serif; font-size: 0.9rem; color: #374151; background: #fafaf7; border-left: 3px solid #d6d3c4; padding: 0.5rem 0.8rem; max-height: 9rem; overflow: auto; }
ul.plain { list-style: none; padding: 0; margin: 0.4rem 0; }
ul.plain li { padding: 0.2rem 0; }
.folder summary { cursor: pointer; font-weight: bold; padding: 0.4rem 0; }
.folder ul.plain { margin-left: 1.2rem; }
label.check { display: flex; align-items: flex-start; gap: 0.5rem; cursor: pointer; }
label.check input { margin-top: 0.35rem; }
.sticky-actions { position: sticky; bottom: 0; box-shadow: 0 -4px 12px rgba(0,0,0,0.06); }
.sticky-actions label { display: flex; flex-direction: column; gap: 0.3rem; font-family: system-ui, sans-serif; font-size: 0.95rem; margin-bottom: 0.8rem; }
.sticky-actions input[type="text"] { font: inherit; padding: 0.5rem 0.7rem; border: 1px solid #cbd5e1; border-radius: 6px; }
.warn { color: #92400e; background: #fffbeb; border: 1px solid #fde68a; padding: 0.5rem 0.8rem; border-radius: 6px; font-family: system-ui, sans-serif; font-size: 0.92rem; }
.chat .msg { padding: 0.8rem 0; border-bottom: 1px solid var(--line); }
.chat .msg.user .who { color: var(--accent); }
.chat .who { font-family: system-ui, sans-serif; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--brand); margin-bottom: 0.3rem; }
.chat .text { white-space: pre-wrap; }
.extracts summary { cursor: pointer; font-family: system-ui, sans-serif; font-size: 0.85rem; color: var(--muted); }
.extracts pre { white-space: pre-wrap; font-size: 0.85rem; background: #fafaf7; padding: 0.6rem; border-radius: 6px; max-height: 20rem; overflow: auto; }

/* ----- W3: domanda, streaming, voti ----- */
.form textarea { font: inherit; padding: 0.55rem 0.7rem; border: 1px solid #cbd5e1; border-radius: 6px; resize: vertical; }
.streaming { font-style: italic; margin-top: 0.4rem; }
.feedback { margin-top: 0.6rem; display: flex; gap: 0.5rem; align-items: flex-start; flex-wrap: wrap; font-family: system-ui, sans-serif; font-size: 0.9rem; }
.inline-form { display: inline-flex; flex-direction: column; gap: 0.4rem; }
.imprecisa-box { display: flex; flex-direction: column; gap: 0.4rem; padding: 0.5rem 0.7rem; background: #fafaf7; border: 1px solid var(--line); border-radius: 6px; }
.imprecisa-box[hidden] { display: none; }
.rich { white-space: normal; }
.rich h3, .rich h4, .rich h5 { font-size: 1.05rem; color: var(--brand); margin: 0.9rem 0 0.3rem; }
.rich p { margin: 0.4rem 0; }
.rich ul, .rich ol { margin: 0.3rem 0 0.6rem 1.4rem; }
.rich blockquote { margin: 0.5rem 0; padding: 0.3rem 0.8rem; border-left: 3px solid #d6d3c4; color: #374151; }

/* ----- W5: suggerimenti e admin feedback ----- */
.item { padding: 0.8rem 0; border-bottom: 1px solid var(--line); }
.item-head { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; font-family: system-ui, sans-serif; font-size: 0.88rem; color: var(--muted); margin-bottom: 0.3rem; }
.unread { background: #fffdf5; }
.unread .item-head span::before, tr.unread td:first-child::before { content: "\25CF "; color: var(--accent); }
.small-link { font-family: system-ui, sans-serif; font-size: 0.85rem; align-self: center; }

/* ----- W6: consumi ----- */
.meter { height: 10px; background: #e5e7eb; border-radius: 999px; overflow: hidden; margin: 0.4rem 0 0.8rem; }
.meter-fill { height: 100%; background: #16a34a; }
.meter-fill.warn { background: #b45309; }

/* link al file originale (PDF/DOCX) accanto a risultati, catalogo e documenti della conversazione */
.doc-link { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 0.8rem; margin-left: 0.4rem; white-space: nowrap; }

.footer .credits { margin-top: 0.6rem; border-top: 1px solid #e2e8f0; padding-top: 0.6rem; }
