:root {
  --paper: #f6f4ef;
  --surface: #ffffff;
  --ink: #1b2533;
  --ink-2: #4a5566;
  --ink-3: #7b8594;
  --line: #e3dfd6;
  --line-2: #ece9e2;
  --navy: #1d3557;
  --accent: #0f6b5c;
  --accent-soft: #e3f1ee;
  --warn: #9a5b00;
  --warn-soft: #fbf1df;
  --danger: #a12d2d;
  --danger-soft: #f8e6e6;
  --radius: 10px;
  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--ink); font: 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-family: var(--serif); font-size: 26px; letter-spacing: -0.01em; }
h2 { font-size: 16px; }
.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }

/* Layout */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }

.shell > * { min-width: 0; }
.side { background: var(--navy); color: #e8edf3; padding: 22px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { font-family: var(--serif); font-size: 19px; color: #fff; padding: 0 10px 18px; line-height: 1.2; }
.brand small { display: block; font-family: var(--sans); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #9fb0c6; margin-top: 4px; }
.nav { display: block; padding: 8px 10px; border-radius: 8px; color: #dfe6ee; text-decoration: none; }
.nav:hover { background: rgba(255,255,255,.07); }
.nav.on { background: rgba(255,255,255,.13); color: #fff; font-weight: 600; }
.nav-h { margin: 14px 10px 4px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #9fb0c6; font-weight: 600; }
.nav-sep { height: 10px; }
.side { overflow-y: auto; }
.side .nav { padding: 6px 10px; }
.nav.soon { color: #7f92aa; cursor: default; }
.nav.soon:hover { background: none; }
.nav.soon em { font-style: normal; font-size: 11px; margin-left: 6px; }
.side-foot { margin-top: auto; padding: 10px; font-size: 12px; color: #9fb0c6; }
.side-foot button { background: none; border: 0; color: #dfe6ee; padding: 0; cursor: pointer; text-decoration: underline; margin-top: 4px; }
.main { padding: 28px 36px 60px; max-width: 1180px; width: 100%; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.head p { margin: 4px 0 0; color: var(--ink-2); }

/* Controls */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 7px 14px; cursor: pointer; font-weight: 500; text-decoration: none; color: var(--ink); }
.btn:hover { border-color: #cfc9bd; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #0c5a4d; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.link { border: 0; background: none; padding: 0; color: var(--accent); }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=search], select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--surface); }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid #9cc9bf; outline-offset: 1px; border-color: var(--accent); }
textarea { resize: vertical; min-height: 84px; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.grid .wide { grid-column: 1 / -1; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Cards and tables */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.card + .card { margin-top: 14px; }
.stats { display: flex; gap: 22px; color: var(--ink-2); font-size: 13px; }
.stats b { color: var(--ink); font-size: 15px; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar input[type=search] { max-width: 340px; }
.tabs { display: inline-flex; background: var(--line-2); border-radius: 9px; padding: 3px; gap: 2px; }
.tabs button { border: 0; background: none; padding: 5px 12px; border-radius: 7px; cursor: pointer; color: var(--ink-2); }
.tabs button.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
table.list { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.list th { text-align: left; font-size: 11.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #faf9f6; }
table.list td { padding: 10px 12px; overflow-wrap: anywhere; border-bottom: 1px solid var(--line-2); vertical-align: top; }
table.list tr:last-child td { border-bottom: 0; }
table.list tbody tr { cursor: pointer; }
table.list tbody tr:hover td { background: #fbfaf7; }
.code { font-variant-numeric: tabular-nums; color: var(--ink-2); white-space: nowrap; }
.name { font-weight: 600; }
.badge { display: inline-block; font-size: 11.5px; padding: 2px 8px; border-radius: 99px; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.badge.ok { background: var(--accent-soft); color: var(--accent); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.off { background: #eceff3; color: #5b6676; }
.empty { padding: 36px; text-align: center; color: var(--ink-3); }

/* Client page */
.back { display: inline-block; margin-bottom: 10px; text-decoration: none; font-size: 13px; }
.client-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 14px; }
.client-head .meta { margin-top: 6px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; color: var(--ink-2); }
.notice { border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; font-size: 13px; }
.notice.info { background: #eef3f9; color: #28456b; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.err { background: var(--danger-soft); color: var(--danger); }
.notice.ok { background: var(--accent-soft); color: var(--accent); }
.section-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.section-tabs button { border: 0; background: none; padding: 9px 14px; cursor: pointer; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.section-tabs button.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.formfoot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; align-items: center; }
.matter-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; margin-bottom: 12px; }
.matter-head h2 { font-family: var(--serif); font-size: 18px; font-weight: 600; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 12px 0; border-bottom: 1px solid var(--line-2); }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { font-size: 12px; color: var(--ink-3); }
.timeline .txt { white-space: pre-wrap; margin-top: 3px; }
.dups { margin: 10px 0 0; padding-left: 18px; }

/* Dialog */
.overlay { position: fixed; inset: 0; background: rgba(20,28,40,.35); display: grid; place-items: center; padding: 16px; z-index: 10; }
.dialog { background: var(--surface); border-radius: 12px; padding: 22px; width: 100%; max-width: 440px; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
.dialog h2 { margin-bottom: 8px; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, #1d3557 0%, #243f63 55%, #2b4a6f 100%); }
.login .card { width: 100%; max-width: 380px; padding: 28px; }
.login h1 { margin-bottom: 4px; }
.login form { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
.toast { position: fixed; bottom: 18px; right: 18px; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 13px; z-index: 20; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; }
  .brand { padding: 0 8px 0 4px; font-size: 16px; } .brand small { display: none; }
  .side-foot { margin: 0 0 0 auto; padding: 0; }
  .main { padding: 18px 16px 40px; }
  .grid { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
  .nav.soon { display: none; }
  .toast { left: 16px; right: 16px; }
}
.mt { margin-top: 12px; }
.row.end { justify-content: flex-end; margin-bottom: 12px; }

/* tappa 2 */
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin: 18px 0 8px; }
.label { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 600; margin: 14px 0 4px; }
dl.qa { display: grid; grid-template-columns: minmax(140px, 32%) 1fr; gap: 6px 14px; margin: 6px 0 0; }
dl.qa dt { color: var(--ink-2); font-size: 13px; }
dl.qa dd { margin: 0; white-space: pre-wrap; }
.txt { white-space: pre-wrap; }
.txt.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; background: #faf9f6; border: 1px solid var(--line-2); border-radius: 8px; padding: 12px; margin-top: 8px; }
ul.plain, ol.plain { margin: 6px 0 0; padding-left: 20px; }
ul.plain li, ol.plain li { margin: 4px 0; }
details.step > summary { cursor: pointer; font-weight: 600; font-size: 15px; }
details.step > summary em { font-style: normal; font-weight: 400; color: var(--ink-3); font-size: 12.5px; }
details.step[open] > summary { margin-bottom: 10px; }
.suggest { background: var(--accent-soft); border-radius: 8px; padding: 10px 14px; margin: 6px 0; }
.card.booking + .card.booking { margin-top: 10px; }
@media (max-width: 860px) { dl.qa { grid-template-columns: 1fr; } dl.qa dt { margin-top: 6px; } }
.hidden-file { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
label.btn { position: relative; }

/* percorso fase 1 */
.steps { display: flex; gap: 6px; flex-wrap: wrap; margin: 14px 0 12px; }
.steps button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 14px; cursor: pointer; color: var(--ink-2); font-weight: 500; }
.steps button.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.steps button.review { border-color: #e6c88f; color: var(--warn); }
.steps button.review.on { background: var(--warn); border-color: var(--warn); color: #fff; }
.card.pipe + .card.pipe { margin-top: 10px; }
.card.pipe h2 a { color: inherit; text-decoration: none; }
.card.pipe h2 a:hover { text-decoration: underline; }
.call-line { margin: 4px 0; }
.btn.small { font-size: 12.5px; padding: 5px 10px; }

/* dashboard */
.dash { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr); gap: 16px; align-items: start; }
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.cal-head h2 { font-family: var(--serif); font-size: 19px; text-transform: capitalize; min-width: 150px; text-align: center; }
.legend { margin-left: auto; display: flex; gap: 6px; }
.legend .ev { font-style: normal; }
.grid7 { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.grid7.wd div { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); padding: 4px 6px; }
.grid7.month { border-top: 1px solid var(--line-2); border-left: 1px solid var(--line-2); }
.cell { min-height: 92px; border-right: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); padding: 4px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cell.out { background: #fbfaf7; }
.cell.out .dn { color: #b9b4aa; }
.cell.today { background: #eef5f3; }
.cell.today .dn { background: var(--accent); color: #fff; border-radius: 99px; width: 22px; height: 22px; display: grid; place-items: center; }
.dn { font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.ev { display: block; font-size: 11.5px; line-height: 1.25; padding: 3px 6px; border-radius: 5px; text-decoration: none; overflow-wrap: anywhere; }
.ev b { font-weight: 600; display: block; }
.legend .ev b { display: inline; }
.ev.fit { background: var(--accent-soft); color: var(--accent); border-left: 3px solid var(--accent); }
.ev.strat { background: #fbf1df; color: #7a4d00; border-left: 3px solid #c08a2b; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 99px; margin-right: 6px; }
.dot.fit { background: var(--accent); } .dot.strat { background: #c08a2b; }
.upcoming { margin-top: 12px; }
.agenda .card + .card { margin-top: 14px; }
.agenda h2 { margin-bottom: 10px; }
.addtask { display: flex; flex-direction: column; gap: 8px; margin-bottom: 6px; }
.addtask .row input[type=date] { width: 150px; flex: none; }
.addtask .row input[type=search] { flex: 1; min-width: 120px; }
ul.tasks { list-style: none; margin: 4px 0 0; padding: 0; }
li.task { display: flex; gap: 10px; align-items: flex-start; padding: 7px 0; border-bottom: 1px solid var(--line-2); }
li.task:last-child { border-bottom: 0; }
li.task input[type=checkbox] { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--accent); }
li.task.done > div { color: var(--ink-3); text-decoration: line-through; }
.label.red { color: var(--danger); }
.tag { font-size: 11px; background: var(--line-2); color: var(--ink-2); border-radius: 5px; padding: 2px 6px; white-space: nowrap; margin-top: 2px; }
@media (max-width: 1100px) { .dash { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .grid7.wd, .grid7.month { display: none; }
  .cal-head h2 { min-width: 0; }
}

/* tappa 3 */
.ev.gcal { background: #eef0f3; color: #4a5566; border-left: 3px solid #9aa4b2; }
.codes { max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin: 8px 0; display: grid; gap: 4px; }
.code-opt { font-size: 13px; display: flex; gap: 6px; align-items: baseline; }
.prop-list { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.prop-item { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 10px 14px; cursor: pointer; min-width: 220px; }
.prop-item.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; overflow-wrap: anywhere; }
ul.docs { list-style: none; padding: 0; margin: 0; }
li.doc-row { display: grid; grid-template-columns: auto 1fr auto auto auto; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line-2); }
li.doc-row:last-child { border-bottom: 0; }
.group { border-left: 3px solid var(--line); padding-left: 12px; }
.group .sub { display: grid; gap: 8px; padding: 8px 0 12px; border-bottom: 1px dashed var(--line-2); }
@media (max-width: 860px) { li.doc-row { grid-template-columns: auto 1fr; } }

/* Fase 2 */
.sec-h { font-size: 18px; margin: 22px 0 8px; }
.q-rows { display: grid; gap: 8px; margin: 10px 0; }
.q-row { display: grid; grid-template-columns: 1fr 190px auto auto auto; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.q-row .qty, .row .qty, input.qty { width: 70px; }
.q-row.q-free { grid-template-columns: 1fr auto auto auto 130px auto; }
.q-row input.price { width: 100px; }
.q-row.q-inst { grid-template-columns: 60px 1fr auto auto auto; }
.err-text { color: #b42318; font-weight: 600; }
.q-out { margin-top: 12px; }
.q-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.q-table td { padding: 6px 8px; border-bottom: 1px solid var(--line-2); }
.q-table td.num { text-align: right; white-space: nowrap; }
.q-table tr.tot td { font-weight: 700; }
.q-table tr.rec td { color: var(--ink-2); font-style: italic; }
.ws { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.ws-row { display: grid; grid-template-columns: 1fr 200px 150px 1fr; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.ws-row.done { opacity: .6; }
.ws-row:has(> button), .ws-row:has(> a) { grid-template-columns: 1fr auto 130px 120px auto auto; }
@media (max-width: 800px) { .q-row, .ws-row, .ws-row:has(> button) { grid-template-columns: 1fr; } }

/* Mammouth checks */
.badge.err { background: #fde8e7; color: #b42318; }
table.chk td { vertical-align: top; padding: 8px 6px; }
table.chk { width: 100%; table-layout: auto; }
table.chk td { white-space: normal !important; overflow-wrap: anywhere; word-break: normal; }
table.chk td.nw { white-space: nowrap !important; width: 1%; }
pre.wrap { white-space: pre-wrap; background: #f6f4ef; padding: 10px; border-radius: 8px; }
