/* Layout ispirato a QuickBooks Online (barra laterale + barra superiore), con i colori ITA. */
:root {
  --ink: #1f2933; --muted: #6b7684; --line: #e1e5ea; --bg: #f4f5f8; --card: #fff;
  --brand: #12355b; --brand-2: #1d4f86; --accent: #1f7a5a; --warn: #b4531a; --bad: #b42318; --side: #0f2742;
  font-family: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif; color: var(--ink); background: var(--bg); font-size: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
#shell { display: flex; min-height: 100vh; }
#mainwrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* Barra laterale come QBO: rail di icone scura + pannello chiaro a gruppi */
#side { display: flex; flex-shrink: 0; position: sticky; top: 0; height: 100vh; z-index: 6; }
#side .rail { width: 68px; background: var(--side); display: flex; flex-direction: column; align-items: center; padding: 10px 0; gap: 4px; }
#side .rail .logo .mark { display: inline-block; background: #fff; color: var(--side); padding: 3px 6px; border-radius: 5px; font-weight: 800; font-size: 13px; margin-bottom: 10px; }
#side .ri { width: 60px; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 0; color: #c6d2df; font-size: 10.5px; background: none; border: none; border-radius: 8px; font-weight: 500; }
#side .ri svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#side .ri:hover { background: rgba(255,255,255,.08); text-decoration: none; color: #fff; }
#side .ri.on { background: rgba(255,255,255,.14); color: #fff; }
#side .panel { width: 228px; background: #fff; border-right: 1px solid var(--line); overflow-y: auto; padding-bottom: 30px; }
#side .ptitle { padding: 16px 16px 12px; font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .03em; color: var(--ink); border-bottom: 1px solid var(--line); }
#side .ptitle small { display: block; text-transform: none; letter-spacing: 0; color: var(--muted); font-weight: 400; font-size: 12px; margin-top: 2px; }
#side .grp { border-bottom: 1px solid #f0f2f5; }
#side .gh { width: 100%; display: flex; align-items: center; gap: 10px; padding: 11px 16px; background: none; border: none; color: var(--ink); font-weight: 600; font-size: 13.5px; text-align: left; border-radius: 0; }
#side .gh i { width: 18px; height: 18px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
#side .gh b { margin-left: auto; color: var(--muted); transition: transform .15s; font-weight: 400; }
#side .grp.open .gh b { transform: rotate(90deg); }
#side .gi { display: none; padding-bottom: 6px; }
#side .grp.open .gi { display: block; }
#side a.item { display: flex; justify-content: space-between; align-items: center; margin: 1px 8px; padding: 7px 10px 7px 36px; color: #39424e; border-radius: 6px; font-size: 13.5px; }
#side a.item:hover { background: #f1f4f7; text-decoration: none; }
#side a.item.on { background: #e8eef5; color: var(--ink); font-weight: 600; }
#side a.item.off { color: #a3adb9; pointer-events: none; }
#side .badge { background: var(--accent); color: #fff; border-radius: 99px; padding: 0 7px; font-size: 11px; font-weight: 700; }
#side .soon, #createdd .soon { font-size: 10px; border: 1px solid #c9d1da; border-radius: 4px; padding: 0 4px; color: #8a96a3; }
#createdd { position: fixed; top: 64px; left: 76px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,.16); padding: 18px 22px; display: flex; gap: 48px; z-index: 30; }
#createdd[hidden] { display: none; }
#createdd h4 { margin: 0 0 10px; font-size: 14px; }
#createdd a { display: block; padding: 6px 0; color: #39424e; }
#createdd a.off { color: #a3adb9; pointer-events: none; }
.coswitch { font-weight: 600; border: none; background: transparent; font-size: 15px; padding-left: 0; }
.iconbtn { background: none; border: none; color: var(--ink); padding: 6px; border-radius: 50%; }
.iconbtn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.iconbtn:hover { background: var(--bg); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--brand-2); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.menu .dd.right { left: auto; right: 0; }
.ddh { padding: 6px 16px; font-size: 11px; text-transform: uppercase; color: var(--muted); letter-spacing: .05em; }

/* Barra superiore */
#top { height: 56px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 20px; gap: 12px; position: sticky; top: 0; z-index: 5; }
#top .left, #top .right { display: flex; align-items: center; gap: 12px; }
.newbtn { border-radius: 99px; padding: 7px 18px; font-weight: 600; }
.menu { position: relative; }
.menu .dd { position: absolute; top: 40px; left: 0; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 6px 0; min-width: 220px; z-index: 10; }
.menu .dd a { display: block; padding: 8px 16px; color: var(--ink); }
.menu .dd a:hover { background: var(--bg); text-decoration: none; }
.lang button { padding: 4px 8px; font-size: 12px; }
.lang button.on { background: var(--brand); color: #fff; }

main { padding: 24px 28px 60px; max-width: 1280px; width: 100%; }
.pad { padding: 24px; }
h1 { font-size: 22px; margin: 0 0 4px; font-weight: 600; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 600; }
.muted { color: var(--muted); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; margin-bottom: 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; margin-top: 16px; }
.grid .card { margin: 0; }
.row { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
label.inline { flex-direction: row; align-items: center; gap: 6px; }
input, select, textarea { font: inherit; padding: 7px 9px; border: 1px solid #c9d1da; border-radius: 6px; background: #fff; color: var(--ink); min-width: 0; }
input:focus, select:focus { outline: 2px solid #9cc3ee; border-color: var(--brand-2); }
button { font: inherit; cursor: pointer; border-radius: 6px; border: 1px solid var(--accent); background: var(--accent); color: #fff; padding: 7px 14px; font-weight: 500; }
button.secondary { background: #fff; color: var(--ink); border-color: #c9d1da; }
button.danger { background: #fff; color: var(--bad); border-color: #f0c7c2; }
button.link { background: none; border: none; padding: 0; color: var(--brand-2); }
button.small { padding: 4px 10px; font-size: 13px; }
button:disabled { opacity: .5; cursor: default; }

table { width: 100%; border-collapse: collapse; background: var(--card); }
.tablecard { background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #fafbfc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.total td { font-weight: 700; border-top: 2px solid var(--ink); }
tr.sec th { background: none; color: var(--ink); font-size: 13px; text-transform: none; letter-spacing: 0; padding-top: 16px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 8px 0 16px; }
.tabs a { padding: 10px 16px; color: var(--muted); border-bottom: 3px solid transparent; font-weight: 500; }
.tabs a.on { color: var(--ink); border-color: var(--accent); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; background: #eef1f5; color: var(--ink); }
.pill.ok { background: #e3f4ec; color: var(--accent); }
.pill.warn { background: #fdf0e6; color: var(--warn); }
.pill.bad { background: #fde8e6; color: var(--bad); }

/* Banking: schede dei conti come in QBO */
.bankcards { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 4px; }
.bankcard { min-width: 240px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; cursor: pointer; }
.bankcard.on { border: 2px solid var(--accent); padding: 13px 15px; }
.bankcard .bal { font-size: 18px; font-weight: 600; margin-top: 6px; }
.bankcard .lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.bankcard .review { margin-top: 8px; font-size: 12px; color: var(--warn); font-weight: 600; }

.kpi { font-size: 26px; font-weight: 600; margin: 4px 0; }
.bar { height: 10px; border-radius: 5px; background: #e8ecf1; overflow: hidden; margin: 6px 0 2px; }
.bar > span { display: block; height: 100%; }
.in { color: var(--accent); }
.note { background: #fffbe6; border: 1px solid #f1e3a6; border-radius: 6px; padding: 4px 8px; font-size: 12px; }

#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 50; }
#toast.show { opacity: 1; }
#toast.err { background: var(--bad); }
.auth { max-width: 400px; margin: 70px auto; }
.auth .brandline { text-align: center; margin-bottom: 18px; font-weight: 600; font-size: 18px; color: var(--brand); }
.auth form { display: flex; flex-direction: column; gap: 12px; }
.secret { font-family: ui-monospace, monospace; background: #f1f3f6; padding: 10px; border-radius: 6px; word-break: break-all; }
.lines td input, .lines td select { width: 100%; }
.empty { padding: 34px; text-align: center; color: var(--muted); }
.reportlist a { display: block; padding: 12px 4px; border-bottom: 1px solid var(--line); font-weight: 500; }
.reporthead { text-align: center; margin-bottom: 12px; }
.reporthead h2 { margin: 0; }

@media (max-width: 820px) {
  #side { position: fixed; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
  #createdd { left: 8px; right: 8px; flex-direction: column; gap: 12px; }
  #side.open { transform: none; }
  #burger { display: inline-block !important; }
  main { padding: 16px; }
}
@media print {
  #side, #top, .noprint { display: none !important; }
  main { padding: 0; }
  .card, .tablecard { border: none; }
}
td.nw { white-space: nowrap; }

/* Moduli a schermo intero (Invoice, Receive payment) come QBO */
.fullform { position: fixed; inset: 0; background: var(--bg); z-index: 40; display: flex; flex-direction: column; }
.fullform .fh { height: 56px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 20px; }
.fullform .fh h1 { font-size: 20px; margin: 0; }
.fullform .fb { flex: 1; overflow-y: auto; padding: 22px; }
.fullform .sheet { max-width: 1120px; margin: 0 auto; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.fullform .sheet .band { background: #f6f8fa; padding: 20px 24px; border-bottom: 1px solid var(--line); border-radius: 10px 10px 0 0; }
.fullform .sheet .sec { padding: 20px 24px; }
.fullform .ff { height: 60px; background: #fff; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 20px; gap: 12px; }
.fullform .ff .mid { display: flex; gap: 22px; }
.bigamt { text-align: right; } .bigamt .l { font-size: 11px; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; } .bigamt .v { font-size: 30px; font-weight: 700; }
.ilines th { background: #fff; } .ilines td { padding: 4px 6px; } .ilines input, .ilines select { width: 100%; border-color: transparent; background: transparent; }
.ilines tr:hover input, .ilines tr:hover select, .ilines input:focus, .ilines select:focus { border-color: #c9d1da; background: #fff; }
.totals { width: 340px; margin-left: auto; } .totals div { display: flex; justify-content: space-between; padding: 6px 0; } .totals .grand { font-size: 18px; font-weight: 700; border-top: 1px solid var(--line); padding-top: 10px; }
/* Money bar delle fatture */
.moneybar { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 18px 22px; margin-bottom: 16px; }
.moneybar .hd { font-size: 13px; color: var(--muted); } .moneybar .hd b { color: var(--ink); }
.moneybar .nums { display: flex; justify-content: space-between; margin-top: 8px; } .moneybar .nums .v { font-size: 20px; font-weight: 600; } .moneybar .nums .r { text-align: right; }
.moneybar .track { display: flex; height: 18px; border-radius: 3px; overflow: hidden; margin-top: 8px; background: #e2e6eb; }
.st-ov { color: var(--warn); font-weight: 600; } .st-paid { color: var(--accent); font-weight: 600; }
.matchbadge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; } .matchbadge b { background: #e3f4ec; color: var(--accent); border-radius: 4px; padding: 1px 6px; font-size: 11px; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100%); background: #fff; box-shadow: -8px 0 30px rgba(0,0,0,.15); z-index: 45; display: flex; flex-direction: column; }
.drawer .dh { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.drawer .db { flex: 1; overflow-y: auto; padding: 18px 22px; display: flex; flex-direction: column; gap: 12px; }
.drawer .df { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
@media print { .fullform { position: static; } .fullform .fh, .fullform .ff { display: none; } }
.menu .dd { display: flex; flex-direction: column; }
.menu .dd[hidden], [hidden] { display: none !important; }
