/* Snoda Invoice — monocromo, registro, niente card. */
:root {
  --ink: #000;
  --graphite: #3a3a3a;
  --ash: #8c8c8c;
  --mist: #e6e6e6;
  --fog: #f5f5f5;
  --paper: #fff;
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --rail: 208px;
  --gutter: 16px;
}
* { box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font); line-height: 1.45; font-feature-settings: "tnum" 1, "ss01" 1; }
a { color: inherit; }
a.plain { text-decoration: none; }
a.plain:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 500; letter-spacing: -0.01em; }
h1 { font-size: 1.75rem; line-height: 1.15; }
h2 { font-size: 1.2rem; margin-bottom: 12px; }
p { margin: 0 0 1em; max-width: 64ch; }
.muted { color: var(--ash); }
.small { font-size: 0.875rem; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
abbr { text-decoration: none; border-bottom: 1px dotted var(--ash); cursor: help; }

/* ---- shell ---- */
.shell { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: 100vh; }
.rail { border-right: 1px solid var(--mist); padding: 24px 20px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 28px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 1rem; letter-spacing: -0.01em; text-decoration: none; line-height: 1.2; }
.brand small { display: block; font-weight: 400; color: var(--ash); font-size: 0.78rem; margin-top: 2px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 7px; background: var(--ink); color: var(--paper); font-size: 0.8rem; font-weight: 600; letter-spacing: 0; flex: none; }
.brand.big { font-size: 1.05rem; margin-bottom: 28px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { text-decoration: none; padding: 7px 10px; color: var(--graphite); border-radius: 6px; display: flex; align-items: center; justify-content: space-between; }
.nav a:hover { background: var(--fog); }
.nav a[aria-current="page"] { color: var(--paper); background: var(--ink); font-weight: 500; }
.nav a .badge { min-width: 1.6em; text-align: center; background: var(--ink); color: var(--paper); border-radius: 999px; font-size: 0.72rem; padding: 1px 7px; }
.nav a[aria-current="page"] .badge { background: var(--paper); color: var(--ink); }
.rail-foot { margin-top: auto; font-size: 0.85rem; color: var(--ash); display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.rail-foot button { background: none; border: 0; padding: 0; color: var(--graphite); text-decoration: underline; cursor: pointer; }
.main { padding: 32px 40px 80px; max-width: 1180px; width: 100%; min-width: 0; }
.table-wrap { overflow-x: auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head p { margin: 6px 0 0; color: var(--graphite); }
.head-actions { display: flex; gap: 10px; align-items: center; }
.head-actions select { border: 1px solid var(--mist); border-radius: 6px; padding: 8px 10px; background: var(--paper); }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 40px; }

/* ---- buttons / forms ---- */
.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--ink); background: var(--ink); color: var(--paper); padding: 8px 14px; border-radius: 6px; cursor: pointer; text-decoration: none; line-height: 1.2; white-space: nowrap; }
.btn:hover { background: var(--graphite); border-color: var(--graphite); }
.btn.secondary { background: var(--paper); color: var(--ink); }
.btn.secondary:hover { background: var(--fog); border-color: var(--ink); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--graphite); padding-left: 6px; padding-right: 6px; text-decoration: underline; text-underline-offset: 3px; }
.btn.quiet:hover { background: var(--fog); color: var(--ink); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 0.875rem; color: var(--graphite); }
.field input, .field select, .field textarea { border: 1px solid #bdbdbd; border-radius: 6px; padding: 9px 10px; background: var(--paper); width: 100%; }
.field input:hover, .field select:hover { border-color: var(--graphite); }
.field .hint { font-size: 0.8rem; color: var(--ash); }
.form-card h2 { margin: 8px 0 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 20px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.notice { border-left: 2px solid var(--ink); padding: 8px 12px; margin: 16px 0; background: var(--fog); max-width: 70ch; border-radius: 0 6px 6px 0; }
.dropzone { display: block; border: 1px dashed #bdbdbd; border-radius: 8px; padding: 22px; text-align: center; color: var(--graphite); cursor: pointer; max-width: 440px; }
.dropzone:hover, .dropzone.over { border-color: var(--ink); background: var(--fog); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }

/* ---- stats row ---- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 24px; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--mist); padding: 18px 0; margin-bottom: 32px; }
.stat { text-decoration: none; }
.stat b { display: block; font-size: 1.75rem; font-weight: 500; line-height: 1.1; }
.stat span { color: var(--graphite); font-size: 0.9rem; }
a.stat:hover b { text-decoration: underline; text-underline-offset: 4px; }

/* ---- filters / summary ---- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filters select, .filters input { border: 1px solid var(--mist); border-radius: 6px; padding: 8px 10px; background: var(--paper); max-width: 240px; }
.filters select:hover, .filters input:hover { border-color: var(--graphite); }
.filters input[type="search"] { min-width: 220px; }
.summary { display: flex; gap: 28px; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--mist); margin-bottom: 4px; color: var(--graphite); font-size: 0.9rem; }
.summary b { color: var(--ink); font-weight: 500; font-size: 1.05rem; }

/* ---- ledger ---- */
.ledger { width: 100%; border-collapse: collapse; }
.ledger th { text-align: left; font-weight: 500; color: var(--graphite); font-size: 0.82rem; padding: 10px 8px 8px 0; border-bottom: 1px solid var(--mist); position: sticky; top: 0; background: var(--paper); z-index: 1; }
.ledger th.num { text-align: right; }
.ledger td { padding: 10px 8px 10px 0; border-bottom: 1px solid var(--mist); vertical-align: top; }
.ledger tr:hover td { background: #fafafa; }
.ledger .sub { display: block; color: var(--ash); font-size: 0.78rem; margin-top: 1px; }
.ledger .act { white-space: nowrap; text-align: right; }
.ledger .act button { margin-left: 6px; }
.ledger.compact td { padding: 8px 8px 8px 0; }
.chip { display: inline-block; border: 1px solid var(--mist); border-radius: 999px; padding: 2px 9px; font-size: 0.78rem; color: var(--graphite); white-space: nowrap; background: var(--paper); }
.catsel { appearance: none; -webkit-appearance: none; border: 1px solid var(--mist); border-radius: 999px; padding: 3px 24px 3px 9px; font-size: 0.78rem; color: var(--graphite); background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238c8c8c' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 9px center; cursor: pointer; max-width: 210px; }
.catsel:hover { border-color: var(--ink); color: var(--ink); }
.month { margin: 36px 0 10px; display: flex; align-items: baseline; gap: 14px; }
.month h2 { font-size: 1.4rem; margin: 0; }
.month .due { color: var(--graphite); }
.month .due b { font-weight: 500; color: var(--ink); }
.status { font-size: 0.8rem; color: var(--graphite); white-space: nowrap; }
.status::before { content: "○ "; }
.status.ok::before { content: "● "; }
.empty { padding: 40px 0; color: var(--graphite); max-width: 56ch; }

/* ---- spese ---- */
.bars { list-style: none; margin: 0; padding: 0; }
.bars li { margin: 0 0 10px; }
.bars a { display: grid; grid-template-columns: 180px 1fr 110px; align-items: center; gap: 12px; }
.bar-label { font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { display: block; height: 14px; background: var(--fog); border-radius: 2px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--ink); }
.bar-val { font-size: 0.9rem; }
.bar-val small { color: var(--ash); margin-left: 6px; font-size: 0.78rem; }
.chart { width: 100%; height: auto; display: block; margin-bottom: 6px; }
.legend { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin: 0 4px 0 8px; vertical-align: middle; }
.legend.black { background: var(--ink); }
.legend.grey { background: #d9d9d9; }

/* ---- dialog / toast / skeleton ---- */
dialog { border: 1px solid var(--ink); border-radius: 8px; padding: 24px; max-width: 640px; width: calc(100% - 32px); }
dialog::backdrop { background: rgba(0,0,0,0.35); }
dialog h2 { margin-bottom: 12px; }
pre.xml { font-family: var(--mono); font-size: 0.75rem; line-height: 1.4; background: var(--fog); padding: 12px; overflow: auto; max-height: 50vh; border-radius: 6px; }
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: min(420px, calc(100% - 40px)); }
.toast { background: var(--ink); color: var(--paper); padding: 10px 14px; border-radius: 6px; font-size: 0.9rem; opacity: 0; transform: translateY(6px); transition: opacity 160ms ease, transform 160ms ease; }
.toast.show { opacity: 1; transform: none; }
.toast.error { background: var(--paper); color: var(--ink); border: 1px solid var(--ink); }
.skeleton .sk-line { height: 14px; background: var(--fog); border-radius: 4px; margin: 14px 0; width: 100%; }
.skeleton .sk-line.w40 { width: 40%; height: 26px; }
.skeleton .sk-line.w70 { width: 70%; }
.skeleton .sk-block { height: 72px; background: var(--fog); border-radius: 4px; margin: 24px 0; }
@media (prefers-reduced-motion: no-preference) { .skeleton > * { animation: pulse 1.2s ease-in-out infinite; } }
@keyframes pulse { 50% { opacity: 0.55; } }

/* ---- login ---- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px var(--gutter); }
.login-card { width: 100%; max-width: 420px; }
.login h1 { font-size: 1.5rem; margin-bottom: 8px; }
.login .lede { color: var(--graphite); margin-bottom: 28px; }

/* ---- mobile ---- */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--mist); padding: 14px var(--gutter); flex-direction: row; align-items: center; flex-wrap: wrap; gap: 10px 16px; }
  .nav { flex-direction: row; gap: 4px; flex-wrap: wrap; }
  .nav a { padding: 5px 9px; }
  .rail-foot { margin-top: 0; width: 100%; flex-direction: row; gap: 12px; }
  .main { padding: 20px var(--gutter) 60px; }
  .grid-2, .grid-3, .two-col { grid-template-columns: 1fr; }
  .two-col { gap: 28px; }
  .filters input[type="search"] { min-width: 0; width: 100%; max-width: none; }
  .ledger thead { display: none; }
  .ledger tr { display: grid; grid-template-columns: 1fr auto; padding: 10px 0; border-bottom: 1px solid var(--mist); gap: 2px 10px; }
  .ledger td { border: 0; padding: 2px 0; }
  .ledger td.num { grid-column: 2; text-align: right; }
  .ledger td.act { grid-column: 1 / -1; text-align: left; }
  .ledger td.act button { margin: 6px 8px 0 0; }
  .bars a { grid-template-columns: 110px 1fr 90px; }
  h1 { font-size: 1.5rem; }
}
