/* Stile del gestionale Contabilità: nessuna dipendenza esterna. */
:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --text: #1c2430;
  --muted: #667085;
  --border: #e3e6eb;
  --accent: #2f5bd3;
  --accent-soft: #e8eefc;
  --pos: #137a4b;
  --neg: #c0362c;
  --warn: #9a6a00;
  --warn-soft: #fff5d9;
  --sidebar: #17202e;
  --sidebar-text: #c8d0dc;
  --radius: 8px;
  font-size: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; line-height: 1.45; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }

/* layout */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 220px; flex-shrink: 0; background: var(--sidebar); color: var(--sidebar-text); padding: 1rem .75rem; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar a { color: var(--sidebar-text); padding: .4rem .6rem; border-radius: 6px; }
.sidebar a:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.sidebar a.active { background: var(--accent); color: #fff; }
.sidebar .brand { font-weight: 700; font-size: 1.15rem; color: #fff; margin-bottom: .75rem; }
.sidebar .nav-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: #7d8898; margin: .9rem .6rem .25rem; }
.sidebar .logout { margin-top: auto; padding-top: 1rem; }
.sidebar .logout .link { color: #7d8898; }
.content { flex: 1; min-width: 0; padding: 1.5rem 2rem 3rem; }
@media (max-width: 800px) {
  .layout { flex-direction: column; }
  .sidebar { width: auto; height: auto; position: static; flex-direction: row; flex-wrap: wrap; }
  .sidebar .nav-title { display: none; }
  .sidebar .logout { margin-top: 0; padding-top: 0; }
  .content { padding: 1rem; }
}

/* elementi */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1.25rem; }
.row { display: flex; gap: 1.25rem; flex-wrap: wrap; align-items: flex-start; }
.row > .card { flex: 1 1 320px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.right, td.num, th.num { text-align: right; }
.nowrap { white-space: nowrap; }
.error, .errorlist { color: var(--neg); }
.errorlist { margin: .25rem 0; padding-left: 1rem; font-size: .85rem; }

.btn, button { font: inherit; cursor: pointer; border: 1px solid var(--border); background: var(--panel); color: var(--text); padding: .4rem .85rem; border-radius: 6px; display: inline-block; }
.btn:hover, button:hover { text-decoration: none; border-color: #c5cad3; }
.btn.primary, button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger, button.danger { color: var(--neg); }
.btn.small, button.small { padding: .2rem .55rem; font-size: .85rem; }
button.link { border: 0; background: none; padding: 0; color: var(--accent); }

input, select, textarea { font: inherit; padding: .35rem .5rem; border: 1px solid var(--border); border-radius: 6px; background: #fff; color: var(--text); max-width: 100%; }
input[type=checkbox] { width: auto; }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .6rem; }
label input, label select, label textarea { display: block; margin-top: .2rem; width: 100%; color: var(--text); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 1rem; }
.form-grid .full { grid-column: 1 / -1; }
.helptext { display: block; font-size: .78rem; color: var(--muted); }
form p { margin: 0 0 .75rem; }
form p label { margin-bottom: .15rem; }
form p input:not([type=checkbox]), form p select, form p textarea { width: 100%; }

.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; margin-bottom: 1rem; }
.filters label { margin: 0; }
.filters input, .filters select { width: auto; }

/* tabelle */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--panel); }
th, td { padding: .4rem .6rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; background: #fafbfc; }
tbody tr:hover { background: #fafbfd; }
tfoot td { font-weight: 700; background: #fafbfc; }
td.num, th.num { white-space: nowrap; font-variant-numeric: tabular-nums; }

/* P&L e cashflow */
table.report { font-size: .88rem; }
table.report th:first-child, table.report td:first-child { position: sticky; left: 0; background: inherit; min-width: 240px; }
table.report thead th { background: #fafbfc; }
table.report tr { background: var(--panel); }
table.report tr.section td { font-weight: 700; background: #eef1f6; }
table.report tr.category td { font-weight: 600; }
table.report tr.line td:first-child { padding-left: 1.6rem; color: #3b4556; }
table.report tr.total td { font-weight: 700; background: var(--accent-soft); }
table.report tr.total.strong td { background: #d6e1fb; }
table.report tr.pct td { font-size: .78rem; color: var(--muted); border-bottom-width: 2px; }
table.report tr.unclassified td { color: var(--warn); }
table.report tr.balance td { font-weight: 700; background: #eef1f6; }
table.report .col-forecast { background: #fbf9f2; font-style: italic; }
table.report .col-current { background: #f2f7ff; }
table.report .col-total { background: #f4f5f7; font-weight: 600; }
table.report a.drill { color: inherit; }
table.report a.drill:hover { color: var(--accent); }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.kpi { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; }
.kpi .label { font-size: .8rem; color: var(--muted); }
.kpi .value { font-size: 1.35rem; font-weight: 700; margin-top: .15rem; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: .78rem; color: var(--muted); margin-top: .15rem; }
.chart-box { position: relative; height: 300px; }

/* badge e messaggi */
.badge { display: inline-block; font-size: .75rem; padding: .1rem .5rem; border-radius: 999px; background: #eef0f3; color: #3b4556; white-space: nowrap; }
.badge.st-paid { background: #dff3e8; color: var(--pos); }
.badge.st-partial { background: var(--warn-soft); color: var(--warn); }
.badge.st-overdue { background: #fde4e1; color: var(--neg); }
.badge.st-open { background: var(--accent-soft); color: var(--accent); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.messages { margin-bottom: 1rem; }
.msg { padding: .6rem .9rem; border-radius: 6px; margin-bottom: .5rem; background: var(--accent-soft); border: 1px solid #c9d7f8; }
.msg.success { background: #e3f5ec; border-color: #b8e2cb; }
.msg.warning { background: var(--warn-soft); border-color: #f0dca0; }
.msg.error { background: #fde8e6; border-color: #f4c2bc; }
.notice { padding: .6rem .9rem; border-radius: 6px; background: var(--warn-soft); border: 1px solid #f0dca0; margin-bottom: 1rem; }

.pagination { display: flex; gap: .5rem; align-items: center; justify-content: center; margin: 1rem 0; }
dl.details { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0; }
dl.details dt { color: var(--muted); }
dl.details dd { margin: 0; }
details summary { cursor: pointer; }
.inline-form { display: inline; }

/* login */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; }
.login-card { width: 100%; max-width: 360px; }
.login-card h1 { text-align: center; }
.login-card button { width: 100%; margin-top: .5rem; }
