:root {
  --bg: #f4f6f9; --panel: #ffffff; --ink: #1d2733; --muted: #5d6b7a; --line: #dde3ea; --line2: #eef1f5;
  --brand: #1f5c8b; --brand-2: #164569; --brand-soft: #e7f0f7;
  --ok: #1e7f4f; --ok-soft: #e3f4ea; --warn: #a76100; --warn-soft: #fdf1dc; --bad: #b42323; --bad-soft: #fbe5e5;
  --info-soft: #eef3fb; --todo: #fff2a8;
  --radius: 8px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px; color: var(--ink); background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--brand); }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 10px; }
h3 { font-size: 15px; margin: 0 0 8px; }
p { line-height: 1.5; }
.boot { padding: 40px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.hidden { display: none !important; }

/* layout */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.side { background: #0f2a40; color: #cfdbe6; padding: 14px 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 18px 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand svg { flex: none; }
.brand b { color: #fff; font-size: 16px; display: block; }
.brand span { font-size: 11px; color: #9fb4c7; }
.nav { padding: 8px 0; }
.nav .grp { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #7f98ad; padding: 14px 18px 4px; }
.nav a { display: flex; align-items: center; gap: 8px; color: #d9e4ee; text-decoration: none; padding: 7px 18px; font-size: 13.5px; border-left: 3px solid transparent; }
.nav a:hover { background: rgba(255,255,255,.06); }
.nav a.active { background: rgba(255,255,255,.1); border-left-color: #6fb3e6; color: #fff; }
.nav a .cnt { margin-left: auto; font-size: 11px; background: rgba(255,255,255,.12); padding: 1px 7px; border-radius: 10px; }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 24px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar .org { font-weight: 600; }
.topbar .sp { flex: 1; }
.topbar .user { font-size: 13px; color: var(--muted); }
.content { padding: 22px 24px 60px; max-width: 1400px; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head .t { flex: 1; min-width: 260px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.menu-btn { display: none; }

/* cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.card.tight { padding: 0; overflow: hidden; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.kpi { padding: 14px 16px; }
.kpi .v { font-size: 28px; font-weight: 700; color: var(--brand-2); }
.kpi .l { color: var(--muted); font-size: 12.5px; }
.help { background: var(--info-soft); border: 1px solid #d3e0f2; border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; line-height: 1.5; }
.help b:first-child { color: var(--brand-2); }
.help ul { margin: 6px 0 0; padding-left: 20px; }
.next-step { border-left: 4px solid var(--brand); }
.next-step .ph { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* buttons & forms */
button, .btn { font: inherit; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 7px 13px; border-radius: 6px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; line-height: 1.2; }
button:hover, .btn:hover { border-color: #b8c4d1; background: #f8fafc; }
button.primary, .btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.primary:hover { background: var(--brand-2); }
button.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
button.danger { color: var(--bad); border-color: #e7b9b9; }
button.danger:hover { background: var(--bad-soft); }
button.link { border: none; background: none; color: var(--brand); padding: 2px 4px; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.sm, .btn.sm { padding: 4px 9px; font-size: 12.5px; }
input, select, textarea { font: inherit; color: var(--ink); border: 1px solid #c9d2dc; border-radius: 6px; padding: 7px 9px; background: #fff; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc6e8; border-color: var(--brand); }
textarea { resize: vertical; min-height: 70px; line-height: 1.45; }
label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 4px; color: #33414f; }
label.f .hint { font-weight: 400; color: var(--muted); font-size: 12px; margin-top: 3px; display: block; }
.req-star { color: var(--bad); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar input[type=search], .toolbar select { width: auto; min-width: 180px; }
.chk { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.chk input { width: auto; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 14px; background: var(--line2); border: 1px solid var(--line); font-size: 12px; }
.chip input { width: auto; margin: 0; }

/* badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11.5px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.b-ok { background: var(--ok-soft); color: var(--ok); }
.b-warn { background: var(--warn-soft); color: var(--warn); }
.b-bad { background: var(--bad-soft); color: var(--bad); }
.b-info { background: var(--brand-soft); color: var(--brand-2); }
.b-mute { background: var(--line2); color: var(--muted); }

/* tables */
.tblwrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; background: #f7f9fb; border-bottom: 1px solid var(--line); padding: 8px 10px; white-space: nowrap; position: sticky; top: 0; }
table.t td { border-bottom: 1px solid var(--line2); padding: 8px 10px; vertical-align: top; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: #f5f9fd; }
table.t td.wrap { max-width: 380px; }
.empty { padding: 30px; text-align: center; color: var(--muted); }

/* progress */
.bar { height: 8px; background: var(--line2); border-radius: 6px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 6px; }
.bar.ok > i { background: var(--ok); }
.stack { display: flex; height: 10px; border-radius: 6px; overflow: hidden; background: var(--line2); }
.stack i { display: block; height: 100%; }
.s-att { background: #2e9a63; } .s-par { background: #e0a23a; } .s-non { background: #d55454; } .s-na { background: #9aa8b6; } .s-nv { background: #dfe5eb; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; background: var(--c); }
.amb-row { display: grid; grid-template-columns: minmax(0, 1fr) 160px 46px; gap: 12px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line2); font-size: 13px; }
.amb-row:last-child { border-bottom: 0; }

/* guida */
.phase { margin-bottom: 14px; }
.phase-h { display: flex; align-items: center; gap: 12px; cursor: pointer; padding: 14px 16px; }
.phase-h h2 { margin: 0; flex: 1; }
.phase-h .bar { width: 160px; }
.phase-b { padding: 0 16px 14px; }
.phase-intro { color: var(--muted); margin: 0 0 12px; line-height: 1.5; }
.step { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; display: grid; grid-template-columns: 30px 1fr; gap: 10px; }
.step.done { background: #f6fbf8; border-color: #cfe9da; }
.step .ico { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #b9c6d3; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: var(--muted); }
.step.done .ico { background: var(--ok); border-color: var(--ok); color: #fff; }
.step.current { border-color: var(--brand); box-shadow: 0 0 0 2px #cfe2f2; }
.step h3 { margin: 2px 0 6px; }
.step .why { margin: 0 0 6px; line-height: 1.5; }
.step ul { margin: 4px 0 8px; padding-left: 20px; line-height: 1.5; }
.step .meta { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }

/* requisiti */
.req { border-bottom: 1px solid var(--line2); padding: 10px 14px; display: grid; grid-template-columns: 96px 1fr auto; gap: 12px; cursor: pointer; }
.req:hover { background: #f7fafd; }
.req .id { font-weight: 700; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; color: var(--brand-2); }
.req .txt { line-height: 1.45; }
.req .own { font-size: 12px; color: var(--muted); margin-top: 3px; }
.amb-title { background: #f7f9fb; padding: 10px 14px; font-weight: 600; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: center; }
.amb-title .bar { width: 120px; margin-left: auto; }
.cover { display: flex; flex-direction: column; gap: 4px; }
.cover a { text-decoration: none; }
.reqtext { white-space: pre-wrap; background: #f7f9fb; border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; line-height: 1.5; }
.state-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-bottom: 12px; }
.state-opts label { border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; cursor: pointer; font-size: 12.5px; display: block; }
.state-opts label b { display: block; font-size: 13px; margin-bottom: 2px; }
.state-opts input { display: none; }
.state-opts input:checked + div { outline: 2px solid var(--brand); outline-offset: 7px; border-radius: 2px; }

/* documenti */
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.doc-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; }
.doc-card:hover { border-color: #a9c3da; box-shadow: var(--shadow); }
.doc-card .code { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: var(--brand-2); font-weight: 700; }
.doc-card .title { font-weight: 600; line-height: 1.35; }
.doc-card .foot { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: auto; font-size: 12px; color: var(--muted); }
.editor { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 0; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; overflow: hidden; height: calc(100vh - 250px); min-height: 480px; }
.editor textarea { border: 0; border-right: 1px solid var(--line); border-radius: 0; height: 100%; resize: none; font-family: ui-monospace, Consolas, "Courier New", monospace; font-size: 13px; padding: 14px; line-height: 1.55; }
.editor textarea:focus { outline: none; }
.editor .pv { overflow-y: auto; padding: 18px 24px; }
.editor.preview-only { grid-template-columns: 1fr; }
.editor.preview-only textarea { display: none; }
.docview { line-height: 1.55; font-size: 14px; }
.docview h1 { font-size: 19px; color: var(--brand); border-bottom: 1px solid #c6d6e4; padding-bottom: 4px; margin: 22px 0 10px; }
.docview h2 { font-size: 16px; color: var(--brand); margin: 18px 0 8px; }
.docview h3 { font-size: 14.5px; margin: 14px 0 6px; }
.docview table.md { border-collapse: collapse; width: 100%; font-size: 12.5px; margin: 8px 0 14px; }
.docview table.md th { background: var(--brand); color: #fff; text-align: left; padding: 6px 8px; }
.docview table.md td { border: 1px solid #c9d6e2; padding: 5px 8px; vertical-align: top; }
.docview blockquote { margin: 10px 0; padding: 8px 12px; background: #eef3f8; border-left: 4px solid var(--brand); }
.docview mark.todo { background: var(--todo); padding: 0 3px; border-radius: 3px; }
.docview .special { color: var(--muted); font-style: italic; }
.doc-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.doc-tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 8px 12px; color: var(--muted); }
.doc-tabs button.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.statusline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; font-size: 13px; }
.mdhelp { font-size: 12px; color: var(--muted); }
.mdhelp code { background: var(--line2); padding: 1px 4px; border-radius: 3px; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15,30,45,.45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50; overflow-y: auto; }
.modal { background: #fff; border-radius: 10px; width: 100%; max-width: 760px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.wide { max-width: 1050px; }
.modal-h { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-h h2 { margin: 0; flex: 1; font-size: 16px; }
.modal-b { padding: 16px 18px; max-height: calc(100vh - 210px); overflow-y: auto; }
.modal-f { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--line); background: #fafbfc; border-radius: 0 0 10px 10px; flex-wrap: wrap; }
.modal-f .sp { flex: 1; }
.x { border: 0; background: none; font-size: 22px; line-height: 1; color: var(--muted); padding: 2px 6px; }

/* toast */
#toast-root { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: #10283c; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); max-width: 420px; font-size: 13px; }
.toast.err { background: var(--bad); }
.toast.ok { background: var(--ok); }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(135deg, #0f2a40, #1f5c8b); }
.login { background: #fff; border-radius: 12px; padding: 28px; width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login h1 { display: flex; gap: 10px; align-items: center; }
.login .err { color: var(--bad); min-height: 20px; margin: 6px 0; font-size: 13px; }
.temp-pw { font-family: ui-monospace, Consolas, monospace; font-size: 20px; background: var(--todo); padding: 8px 12px; border-radius: 6px; display: inline-block; letter-spacing: .05em; user-select: all; }

.files { list-style: none; padding: 0; margin: 0; }
.files li { display: flex; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line2); font-size: 13px; }
.files li .n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.dropzone { border: 2px dashed #c3cfdb; border-radius: 8px; padding: 14px; text-align: center; color: var(--muted); margin-top: 8px; }
.dropzone.over { border-color: var(--brand); background: var(--brand-soft); }
dl.gloss dt { font-weight: 700; margin-top: 12px; color: var(--brand-2); }
dl.gloss dd { margin: 3px 0 0; line-height: 1.5; }

@media (max-width: 1000px) {
  .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .g3, .g2 { grid-template-columns: 1fr; }
  .editor { grid-template-columns: 1fr; height: auto; }
  .editor textarea { height: 60vh; border-right: 0; border-bottom: 1px solid var(--line); }
}
@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: -260px; width: 250px; z-index: 40; transition: left .2s; }
  .side.open { left: 0; }
  .menu-btn { display: inline-flex; }
  .content { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .req { grid-template-columns: 1fr; }
  .amb-row { grid-template-columns: 1fr 90px 40px; }
}
@media print {
  .side, .topbar, .page-head .actions, .toolbar { display: none !important; }
  .shell { display: block; }
}
.az-switch { padding: 10px 18px 12px; border-bottom: 1px solid rgba(255,255,255,.08); }
.az-switch label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: #9fb4c7; margin-bottom: 4px; }
.az-switch select { width: 100%; background: #16384f; color: #fff; border: 1px solid rgba(255,255,255,.15); border-radius: 6px; padding: 6px 8px; font-size: 13px; }
