:root {
  --green: #94c11f; --green-hover: #88c920; --green-dark: #5f7c13; --green-deep: #02702e;
  --blue: #0090d7; --blue-hover: #0099db; --ink: #4a4949; --grey-light: #ebebeb; --grey: #a1a1a1;
  --green-tint: #eaf1d9; --red: #b91f34; --white: #ffffff; --off-white: #fcfcfc;
  /* Brand blue darkened for text: #0090d7 on white is 3.5:1, below WCAG AA (4.5:1) for normal text.
     #0090d7 stays for focus rings and borders, where 3:1 is enough. */
  --blue-text: #0072ab; --blue-text-hover: #005b88;
  --notice-h: 2.2rem;  /* height of the sticky AI notice when it fits on one line */
}
html { scroll-padding-top: calc(var(--notice-h) + .5rem); }  /* anchors land below the sticky notice */
@font-face { font-family: "Roboto"; font-weight: 400; src: url("/static/fonts/Roboto-400.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Roboto"; font-weight: 500; src: url("/static/fonts/Roboto-500.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Roboto"; font-weight: 700; src: url("/static/fonts/Roboto-700.ttf") format("truetype"); font-display: swap; }

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: "Roboto", Arial, sans-serif; color: var(--ink); background: var(--off-white); line-height: 1.5; }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.2; overflow-wrap: break-word; }
h1, h2 { color: var(--green-deep); }
a { color: var(--blue-text); }
a:hover { color: var(--blue-text-hover); }
img { max-width: 100%; height: auto; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem 1.5rem; background: var(--white); border-bottom: 3px solid var(--green); }
.brand { display: inline-flex; flex: 0 0 auto; }
.menu { display: flex; gap: 1rem; flex-wrap: wrap; }
/* The AI notice stays visible while the page scrolls (signed promise "avviso sempre visibile"). */
.ai-notice { position: sticky; top: 0; z-index: 40; padding: .4rem 1.5rem; background: var(--green-tint); border-bottom: 1px solid var(--green); font-size: .88rem; line-height: 1.35; }
.ai-notice a { margin-left: .6rem; font-weight: 500; white-space: nowrap; }
.container { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }

.btn { display: inline-block; padding: .55rem 1.4rem; border: 2px solid transparent; border-radius: 30px; font: inherit; font-weight: 500; text-decoration: none; cursor: pointer; background: var(--white); color: var(--ink); }
.btn-primary { background: var(--green-dark); border-color: var(--green-dark); color: var(--white); }
.btn-primary:hover { background: var(--green-deep); border-color: var(--green-deep); color: var(--white); }
.btn-secondary { border-color: var(--blue-text); color: var(--blue-text); background: var(--white); }
.btn-secondary:hover { border-color: var(--blue-text-hover); color: var(--blue-text-hover); }

.card { background: var(--white); border: 1px solid var(--grey-light); border-radius: 12px; padding: 1.25rem 1.5rem; margin-bottom: 1rem; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .5rem .75rem; text-align: left; border-bottom: 1px solid var(--grey-light); }
.alert-error { padding: .75rem 1rem; border: 1px solid var(--red); border-radius: 8px; color: var(--red); background: var(--white); }
.badge { display: inline-block; padding: .1rem .6rem; border-radius: 30px; background: var(--grey-light); font-size: .8rem; }

.userbox { display: flex; align-items: center; gap: .75rem; }
.username { color: var(--ink); font-weight: 500; text-decoration: none; }
.username:hover { color: var(--blue-text); }
.inline-form { display: inline; margin: 0; }
.btn-small { padding: .3rem 1rem; font-size: .9rem; }

.auth-card { max-width: 460px; margin: 2rem auto; }
.form { display: flex; flex-direction: column; gap: 1rem; margin: 1rem 0; }
.field { display: flex; flex-direction: column; gap: .3rem; }
.field label { font-weight: 500; }
.field input { padding: .55rem .75rem; border: 1px solid var(--grey); border-radius: 8px; font: inherit; color: var(--ink); background: var(--white); }
.field input:focus { border-color: var(--blue); }
.form .btn { align-self: flex-start; }
.hint { margin: 0; color: var(--ink); font-size: .9rem; }
.auth-card .hint + .hint { margin-top: .5rem; }
input[type=checkbox], input[type=radio] { accent-color: var(--green-dark); }
.notice { padding: .75rem 1rem; border: 1px solid var(--green); border-radius: 8px; background: var(--green-tint); }
.alert-warning { margin-bottom: 1rem; padding: .75rem 1rem; border: 1px solid var(--red); border-left-width: 6px; border-radius: 8px; background: var(--white); }
.alert-warning p { margin: 0 0 .6rem; }

:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.skip-link { position: absolute; left: -9999px; top: .5rem; z-index: 100; padding: .5rem 1rem; border-radius: 30px; background: var(--white); color: var(--blue-text); font-weight: 500; }
.skip-link:focus { left: 1rem; }
main:focus { outline: none; }

.menu a { color: var(--ink); font-weight: 500; text-decoration: none; padding: .25rem .1rem; border-bottom: 3px solid transparent; }
.menu a:hover { color: var(--blue-text); }
.menu a.active { color: var(--green-dark); border-bottom-color: var(--green); }

.subnav { display: flex; gap: .25rem 1.25rem; flex-wrap: wrap; margin-bottom: 1rem; }
.subnav a { color: var(--ink); text-decoration: none; padding: .25rem 0; border-bottom: 3px solid transparent; }
.subnav a.active { color: var(--green-dark); border-bottom-color: var(--green); font-weight: 500; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.form-card { max-width: 640px; }
.field select { padding: .55rem .75rem; border: 1px solid var(--grey); border-radius: 8px; font: inherit; color: var(--ink); background: var(--white); }
.filters { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; margin-bottom: .75rem; }
.btn-danger { border-color: var(--red); color: var(--red); background: var(--white); }
.btn-danger:hover { background: var(--red); color: var(--white); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.badge-off { background: var(--red); color: var(--white); }
.mono { font-family: "DejaVu Sans Mono", monospace; font-size: .8rem; word-break: break-word; }
.pager { display: flex; gap: 1.5rem; margin-top: 1rem; }

/* --- shared helpers --- */
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.js .no-js { display: none; }
.flash { margin-bottom: 1rem; }
.empty { margin: .5rem 0; }
.num, .nowrap { white-space: nowrap; }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: flex; }

/* --- documents: tree on the left, content on the right --- */
.docs { display: grid; grid-template-columns: minmax(200px, 260px) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.docs-side { position: sticky; top: calc(var(--notice-h) + 1rem); padding: 1rem; }
.side-title { font-size: 1rem; color: var(--green-deep); }
.tree ul { list-style: none; margin: 0; padding-left: .9rem; }
.tree > ul { padding-left: 0; }
.tree a { display: block; padding: .3rem .6rem; border-radius: 8px; color: var(--ink); text-decoration: none; overflow-wrap: anywhere; }
.tree a:hover { background: var(--grey-light); color: var(--ink); }
.tree a.active { background: var(--green-tint); color: var(--green-deep); font-weight: 500; }
.tree-root { font-weight: 500; }
.tree-empty { padding: .3rem .6rem; }
.tree .tree-trash { margin-top: .75rem; border-top: 1px solid var(--grey-light); border-radius: 0; padding-top: .6rem; }
.docs-main { min-width: 0; }
.docs-toolbar { display: flex; flex-direction: column; gap: .75rem; }
.toolbar-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.toolbar-head h1 { margin: 0; color: var(--green-deep); }

.breadcrumbs { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-bottom: .75rem; font-size: .95rem; }
.breadcrumbs a { text-decoration: none; }
.breadcrumbs .sep { color: var(--grey); }
.breadcrumbs [aria-current] { font-weight: 500; overflow-wrap: anywhere; }

.upload-form { display: flex; flex-direction: column; gap: .5rem; }
.dropzone { position: relative; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .75rem; padding: 1.25rem; border: 2px dashed var(--grey); border-radius: 12px; background: var(--off-white); cursor: pointer; text-align: center; }
.dropzone:hover, .dropzone.dragover { border-color: var(--green); background: var(--green-tint); }
.dropzone:focus-within { border-color: var(--blue); outline: 3px solid var(--blue); outline-offset: 2px; }
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.upload-busy { align-items: center; gap: .75rem; }
.upload-progress { flex: 1; height: .8rem; accent-color: var(--green-dark); }
.upload-results { list-style: none; margin: 0 0 1rem; padding: 0; }
.upload-results li { padding: .45rem .75rem; border-radius: 8px; margin-bottom: .3rem; overflow-wrap: anywhere; }
.upload-results .ok { background: var(--green-tint); }
.upload-results .ko { border: 1px solid var(--red); color: var(--red); background: var(--white); }

.docs-table td { vertical-align: top; }
.name-cell { overflow-wrap: anywhere; min-width: 14rem; }
.name-cell a { font-weight: 500; }
.kind { display: inline-block; margin-left: .35rem; font-size: .75rem; font-weight: 500; letter-spacing: .03em; }
.row-folder .kind { margin-left: 0; }
.folder-link::before { content: ""; display: inline-block; width: .95em; height: .7em; margin-right: .45em; border-radius: 2px; background: var(--green); vertical-align: -.05em; }
.container-wide { max-width: 1400px; }
.actions-cell { width: 1%; white-space: nowrap; }
.row-actions { display: flex; flex-wrap: nowrap; gap: .4rem; justify-content: flex-end; align-items: flex-start; }
.row-actions details, .new-folder { position: relative; }
.row-actions details > summary, .new-folder > summary { list-style: none; }
.row-actions details > summary::-webkit-details-marker, .new-folder > summary::-webkit-details-marker { display: none; }
.row-actions details[open] > summary, .new-folder[open] > summary { background: var(--green-tint); }
.pop { display: flex; flex-direction: column; gap: .5rem; padding: .75rem; background: var(--white); border: 1px solid var(--grey); border-radius: 12px; text-align: left; white-space: normal; }
.row-actions .pop, .new-folder .pop { position: absolute; right: 0; top: calc(100% + .4rem); z-index: 10; width: min(340px, 85vw); box-shadow: 0 6px 18px rgba(0, 0, 0, .12); }
.pop label { font-weight: 500; }
.pop input, .pop select { width: 100%; min-width: 0; padding: .45rem .6rem; border: 1px solid var(--grey); border-radius: 8px; font: inherit; color: var(--ink); background: var(--white); }
.pop .btn { align-self: flex-start; }
.row-actions .btn-small { padding: .3rem .8rem; }

.status-cell { min-width: 9rem; max-width: 18rem; }
.status-msg { display: block; margin: .25rem 0; font-size: .85rem; }
.status-cell .inline-form { display: inline-block; margin-top: .25rem; }
.badge-queued { background: var(--grey-light); color: var(--ink); }
.badge-working { background: var(--white); border: 1px solid var(--blue); color: var(--ink); }
.badge-ready { background: var(--green-tint); color: var(--green-deep); }
.badge-error { background: var(--red); color: var(--white); }
.badge-warning { background: var(--white); border: 1px solid var(--red); color: var(--red); }
.status-line { border-collapse: collapse; margin: .25rem 0 1rem; }
.status-line td { padding: 0; }

.doc-title { overflow-wrap: anywhere; color: var(--green-deep); }
.pdf-frame { display: block; width: 100%; height: 80vh; min-height: 420px; border: 1px solid var(--grey-light); border-radius: 8px; }
.chunk { padding: .75rem .5rem; border-bottom: 1px solid var(--grey-light); }
.chunk.highlight { background: var(--green-tint); }
.chunk-label { margin: 0 0 .25rem; font-size: .85rem; font-weight: 500; }
.chunk-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

@media (max-width: 800px) {
  .docs { grid-template-columns: 1fr; }
  .docs-side { position: static; }
  .col-optional { display: none; }
  .table-wrap { overflow-x: auto; }  /* not on wide screens: the inline rename/move panels must not be clipped */
  .actions-cell { width: auto; white-space: normal; }
  .row-actions { flex-wrap: wrap; justify-content: flex-start; }
  .row-actions details[open] { flex-basis: 100%; min-width: 0; order: 10; }
  .new-folder .pop { right: auto; left: 0; }
  .row-actions .pop { position: static; width: auto; margin-top: .5rem; box-shadow: none; }
  /* rows become stacked cards: name, status, actions */
  .docs-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  .docs-table, .docs-table tbody, .docs-table tr, .docs-table td { display: block; width: auto; }
  .docs-table tr { padding: .6rem 0; border-bottom: 1px solid var(--grey-light); }
  .docs-table td { padding: .2rem 0; border-bottom: 0; }
  .docs-table td.col-optional { display: none; }
  .name-cell { min-width: 0; }
  .status-cell { min-width: 0; max-width: none; }
}
.section-title { margin-top: 1.5rem; font-size: 1.2rem; }

/* --- chat: conversations on the left, thread and question box on the right --- */
.chat { display: grid; grid-template-columns: minmax(200px, 270px) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.chat-side { position: sticky; top: calc(var(--notice-h) + 1rem); padding: 1rem; }
.chat-new { margin-bottom: 1rem; }
.chat-new .btn { width: 100%; }
.conv-list ul { list-style: none; margin: 0; padding: 0; max-height: 65vh; overflow-y: auto; }
.conv-list a { display: block; padding: .45rem .6rem; border-radius: 8px; color: var(--ink); text-decoration: none; }
.conv-list a:hover { background: var(--grey-light); color: var(--ink); }
.conv-list a.active { background: var(--green-tint); color: var(--green-deep); }
.conv-title { display: block; font-weight: 500; overflow-wrap: anywhere; }
.conv-date { display: block; font-size: .8rem; }
.conv-empty { padding: .3rem .6rem; }
.chat-main { min-width: 0; }
.fake-banner { margin: 0 0 1rem; padding: .6rem 1rem; border: 1px solid var(--blue); border-left-width: 6px; border-radius: 8px; background: var(--white); font-weight: 500; }
.chat-head { padding-bottom: 1rem; }
.chat-head-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.chat-title { margin: 0; color: var(--green-deep); font-size: 1.4rem; overflow-wrap: anywhere; }
.chat-actions { display: flex; gap: .5rem; align-items: flex-start; flex-wrap: wrap; }
.chat-settings { position: relative; }
.chat-settings > summary { list-style: none; }
.chat-settings > summary::-webkit-details-marker { display: none; }
.chat-settings[open] > summary { background: var(--green-tint); }
.settings-pop { position: absolute; right: 0; top: calc(100% + .4rem); z-index: 10; width: min(520px, 90vw); max-height: 75vh; overflow-y: auto; gap: .75rem; box-shadow: 0 6px 18px rgba(0, 0, 0, .12); }
.chat-meta { margin: .6rem 0 0; font-size: .95rem; overflow-wrap: anywhere; }
.chat-start p { margin: 0 0 .75rem; }
.chat-start .form { max-width: 640px; }

.scope { display: flex; flex-direction: column; gap: .6rem; margin: 0; padding: .75rem 1rem; border: 1px solid var(--grey-light); border-radius: 8px; }
.scope legend { padding: 0 .3rem; font-weight: 500; }
.scope-modes { display: flex; flex-direction: column; gap: .3rem; }
.scope-modes label { display: flex; align-items: center; gap: .45rem; font-weight: 400; }
.scope-modes input[type=radio], .pop .scope-modes input[type=radio] { width: auto; margin: 0; padding: 0; accent-color: var(--green-dark); }
.scope select[multiple], .field select { width: 100%; }

/* The page scrolls (no inner scroll box): the thread fills the screen and the question box stays at the bottom. */
.chat-thread { display: flex; flex-direction: column; min-height: calc(100vh - var(--notice-h) - 15rem); }
.messages { display: flex; flex: 1 0 auto; flex-direction: column; gap: .9rem; min-height: 120px; padding: .25rem .25rem .5rem; }
.msg { max-width: 52rem; padding: .75rem 1rem; border-radius: 12px; }
.msg-user { align-self: flex-end; background: var(--green-tint); }
.msg-assistant { align-self: flex-start; background: var(--off-white); border: 1px solid var(--grey-light); }
.msg-failed { border-color: var(--red); }
.msg-who { margin: 0 0 .25rem; font-size: .8rem; font-weight: 500; color: var(--green-dark); }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-text .cite { font-weight: 500; text-decoration: none; padding: 0 .1em; }
.msg-text .cite:hover { text-decoration: underline; }
.msg-status { margin: .25rem 0 0; font-style: italic; }
.msg-sources { margin-top: .6rem; padding-top: .5rem; border-top: 1px solid var(--grey-light); }
.msg-sources-title { margin: 0 0 .2rem; font-size: .85rem; font-weight: 500; }
.sources { list-style: none; margin: 0; padding: 0; font-size: .9rem; }
.sources li { overflow-wrap: anywhere; }
.msg-usage { margin: .5rem 0 0; font-size: .8rem; }
.msg-error-text { margin: .5rem 0 0; color: var(--red); font-weight: 500; }

.ask-form { position: sticky; bottom: 0; z-index: 5; display: flex; flex-direction: column; gap: .5rem; margin: 1rem -1.5rem -1.25rem; padding: .75rem 1.5rem 1rem; border-top: 1px solid var(--grey-light); border-radius: 0 0 12px 12px; background: var(--white); box-shadow: 0 -6px 14px rgba(0, 0, 0, .06); }
.ask-form textarea { width: 100%; min-height: 5rem; padding: .6rem .75rem; border: 1px solid var(--grey); border-radius: 8px; font: inherit; color: var(--ink); background: var(--white); resize: vertical; }
.ask-form textarea:focus { border-color: var(--blue); }
.ask-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.ask-error { margin: 0; }

@media (max-width: 900px) {
  .chat { grid-template-columns: 1fr; }
  .chat-side { position: static; }
  .conv-list ul { max-height: 30vh; }
  .settings-pop { position: static; width: auto; margin-top: .5rem; box-shadow: none; }
  .chat-settings[open] { flex-basis: 100%; }
  .chat-thread { min-height: 0; }
}

/* --- tasks (Elaborazioni): kinds, status, results, invoice table --- */
.page-title { margin: 0 0 .5rem; color: var(--green-deep); font-size: 1.5rem; overflow-wrap: anywhere; }
.scroll-x { overflow-x: auto; }
/* containing block for .sr-only labels inside scrolled tables: they must not widen the page */
.scroll-x, .table-wrap { position: relative; }
.kind-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1rem; margin-top: 1rem; }
.kind-card { display: flex; flex-direction: column; gap: .5rem; padding: 1rem; border: 1px solid var(--grey-light); border-radius: 12px; background: var(--off-white); }
.kind-card h2 { margin: 0; font-size: 1.1rem; color: var(--green-deep); }
.kind-card p { margin: 0; }
.kind-card .btn { align-self: flex-start; margin-top: auto; }
.task-meta { margin: .3rem 0; overflow-wrap: anywhere; }
.task-instructions { margin: .5rem 0; }
.task-instructions summary { cursor: pointer; font-weight: 500; }
.pre-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.task-body { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--grey-light); }
.task-status { margin: 0 0 .75rem; }
.downloads { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .75rem; }
.downloads-label { font-weight: 500; }
.task-warnings { margin: 1rem 0; padding: .75rem 1rem; border: 1px solid var(--red); border-radius: 8px; background: var(--white); }
.task-warnings .section-title { margin-top: 0; color: var(--red); font-size: 1rem; }
.task-warnings ul { margin: 0; padding-left: 1.2rem; }
.task-warnings li { overflow-wrap: anywhere; }
.result-section { margin-top: 1.25rem; overflow-wrap: anywhere; }
.result-doc { color: var(--green-deep); font-size: 1.2rem; }
.result-section + .result-section { padding-top: 1rem; border-top: 1px solid var(--grey-light); }
.result-heading { margin-top: 1rem; color: var(--green-deep); font-size: 1.05rem; }
h4.result-heading, h5.result-heading, h6.result-heading { font-size: .98rem; }
.result-list { margin: .25rem 0 .75rem; padding-left: 1.4rem; }
.result-table { margin: .5rem 0 1rem; }
.invoice-table th, .invoice-table td { font-size: .9rem; vertical-align: top; }
.invoice-table td { white-space: nowrap; }
.invoice-table td:last-child { white-space: normal; min-width: 14rem; }
.invoice-table tbody th { font-weight: 500; overflow-wrap: anywhere; min-width: 9rem; }
.row-warning th { border-left: 4px solid var(--red); }
.row-warning-detail td { color: var(--red); font-size: .85rem; white-space: normal; }
.invoice-table .amount { text-align: right; }
.card > .section-title:first-child { margin-top: 0; }
.tasks-table td { vertical-align: top; }
.tasks-table .badge { white-space: nowrap; }
.retention-note { margin-top: .75rem; }
.field textarea { width: 100%; padding: .55rem .75rem; border: 1px solid var(--grey); border-radius: 8px; font: inherit; color: var(--ink); background: var(--white); resize: vertical; }
.field textarea:focus, .field select:focus { border-color: var(--blue); }

/* --- consumi e modelli --- */
.usage-summary { display: flex; flex-wrap: wrap; gap: 1.5rem; margin: 1rem 0; }
.usage-summary dt { color: var(--ink); font-size: .9rem; }
.usage-summary dd { margin: 0; font-size: 1.5rem; font-weight: 500; color: var(--green-deep); }
.usage-bar, .usage-bar-small { width: 100%; height: 1rem; accent-color: var(--green-dark); }
.usage-bar-small { width: 6rem; height: .7rem; }
.table .num { text-align: right; white-space: nowrap; }
.table tfoot th, .table tfoot td { font-weight: 700; }
.month-nav { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem; }
.month-nav strong { min-width: 9rem; text-align: center; }
.status-list { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; margin: .5rem 0 0; }
.status-list dt { font-weight: 500; }
.status-list dd { margin: 0; }
.model-card { max-width: 760px; }
.model-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem 1rem; }
.model-head h2 { margin: 0; font-size: 1.1rem; }
.model-meta { margin: .25rem 0 0; color: var(--ink); font-size: .9rem; overflow-wrap: anywhere; }
.model-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 1rem; }
.field-check { flex-direction: row; align-items: center; gap: .5rem; }
.field-check input { width: auto; }

/* --- small screens: top bar on two rows, tighter gutters --- */
@media (max-width: 800px) {
  .topbar { flex-wrap: wrap; gap: .4rem 1rem; padding: .6rem 1rem; }
  .brand img { width: 110px; }
  .userbox { margin-left: auto; min-width: 0; gap: .5rem; }
  .username { max-width: 36vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .menu { order: 3; flex: 1 0 100%; gap: .1rem 1.1rem; }
  .menu a { padding: .35rem 0; }
  /* Same text, smaller: on a phone the notice takes two or three short lines. */
  .ai-notice { padding: .3rem 1rem; font-size: .78rem; line-height: 1.3; }
}
@media (max-width: 600px) {
  .container { padding: 1rem; }
  .card { padding: 1rem; }
  .table th, .table td { padding: .45rem .5rem; }
  /* A compact question box: on a phone it stays below a fifth of the screen. */
  .ask-form { gap: .4rem; margin: 1rem -1rem -1rem; padding: .5rem 1rem .6rem; }
  .ask-form textarea { height: 3.4rem; min-height: 3.4rem; }
  .ask-bar { flex-wrap: nowrap; gap: .6rem; }
  .ask-bar .hint { font-size: .78rem; }
}

/* --- regole d'uso, preview notes --- */
.rules { max-width: 900px; }
.rules p, .rules li { overflow-wrap: anywhere; }
.rules-box { margin: 1rem 0; padding: .9rem 1.1rem; border: 1px solid var(--green); border-left-width: 6px; border-radius: 8px; background: var(--green-tint); }
.rules-box-title { display: block; margin-bottom: .3rem; font-weight: 700; color: var(--green-deep); }
.rules-box p { margin: 0; }
.rules-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1rem; margin: .5rem 0 1rem; }
.rules-col { padding: .75rem 1rem; border: 1px solid var(--grey-light); border-radius: 8px; }
.rules-col h3 { margin: 0 0 .4rem; font-size: 1rem; color: var(--green-deep); }
.rules-col ul { margin: 0; padding-left: 1.2rem; }
.rules-col p { margin: 0; }
.rules-col-warn { border-color: var(--red); }
.rules-col-warn h3 { color: var(--red); }
.ocr-note { margin: .25rem 0 1rem; }
