:root {
  --ink: #12141a;
  --muted: #5c6370;
  --paper: #f4f1eb;
  --surface: #fffdf8;
  --accent: #0b6e4f;
  --accent-2: #0a5840;
  --line: rgba(18, 20, 26, 0.1);
  --danger: #9b1c1c;
  --ok: #0b6e4f;
  --warn: #9a6700;
  --shadow: 0 18px 50px rgba(18, 20, 26, 0.08);
  --radius: 18px;
  --font: "DM Sans", system-ui, sans-serif;
  --display: "Instrument Serif", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1100px 520px at 8% -8%, rgba(11,110,79,.16), transparent 55%),
    radial-gradient(900px 480px at 100% 0%, rgba(18,20,26,.07), transparent 45%),
    linear-gradient(165deg, #ebe7df 0%, var(--paper) 42%, #e5ebe7 100%);
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

.wrap { width: min(1120px, calc(100% - 2rem)); margin: 0 auto; }
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 1.1rem 0;
}
.logo {
  font-family: var(--display); font-size: 1.85rem; color: var(--ink);
  text-decoration: none; letter-spacing: -.02em;
}
.logo span { color: var(--accent); }
.nav { display: flex; gap: .35rem .9rem; flex-wrap: wrap; align-items: center; }
.nav a { color: var(--muted); text-decoration: none; font-size: .95rem; }
.nav a:hover { color: var(--ink); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .4rem; border: 0; border-radius: 999px; padding: .7rem 1.15rem;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); text-decoration: none; color: #fff; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { background: rgba(255,255,255,.55); text-decoration: none; color: var(--ink); }
.btn-danger { background: #fff; color: var(--danger); border: 1px solid rgba(155,28,28,.25); }
.btn-sm { padding: .45rem .85rem; font-size: .875rem; }

.hero {
  display: grid; grid-template-columns: 1.15fr .85fr; gap: 2rem;
  align-items: center; padding: 2.5rem 0 3.5rem;
}
.hero h1 {
  font-family: var(--display); font-weight: 400;
  font-size: clamp(2.6rem, 6vw, 4.4rem); line-height: .98;
  letter-spacing: -.02em; margin: 0 0 1rem;
}
.hero h1 em { font-style: italic; color: var(--accent); }
.lead { color: var(--muted); font-size: 1.12rem; max-width: 34rem; margin: 0 0 1.5rem; }
.cta-row { display: flex; flex-wrap: wrap; gap: .75rem; }

.shot {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 24px; box-shadow: var(--shadow); overflow: hidden;
  min-height: 280px; position: relative;
}
.shot-inner { padding: 1.1rem; }
.fake-ui-top { display: flex; gap: .4rem; margin-bottom: 1rem; }
.fake-ui-top i { width: 9px; height: 9px; border-radius: 50%; background: #d8d2c8; display: block; }
.fake-card {
  background: #f7f4ee; border-radius: 14px; padding: 1rem; margin-bottom: .75rem;
  border: 1px solid var(--line);
}
.fake-card strong { display: block; font-size: 1.35rem; margin-top: .2rem; }
.fake-row { display: flex; justify-content: space-between; color: var(--muted); font-size: .9rem; padding: .45rem 0; border-bottom: 1px dashed var(--line); }

.section { padding: 2.5rem 0 3rem; }
.section h2 {
  font-family: var(--display); font-size: clamp(1.9rem, 4vw, 2.7rem);
  margin: 0 0 .5rem; font-weight: 400;
}
.section .sub { color: var(--muted); margin: 0 0 1.75rem; max-width: 40rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.card {
  background: rgba(255,253,248,.78); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.25rem 1.2rem;
}
.card h3 { margin: 0 0 .4rem; font-size: 1.05rem; }
.card p { margin: 0; color: var(--muted); font-size: .95rem; }

.site-footer {
  border-top: 1px solid var(--line); padding: 1.5rem 0 2.5rem;
  color: var(--muted); font-size: .9rem;
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}

/* App shell */
.app-shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: rgba(18,20,26,.92); color: #f4f1eb; padding: 1.25rem 1rem;
  display: flex; flex-direction: column; gap: 1rem;
}
.sidebar .logo { color: #fff; font-size: 1.6rem; }
.sidebar .logo span { color: #7dceb4; }
.side-nav { display: flex; flex-direction: column; gap: .25rem; }
.side-nav a {
  color: rgba(244,241,235,.78); text-decoration: none;
  padding: .65rem .8rem; border-radius: 12px; font-size: .95rem;
}
.side-nav a:hover, .side-nav a.active { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.side-meta { margin-top: auto; font-size: .8rem; color: rgba(244,241,235,.55); }
.app-main { padding: 1.25rem 1.4rem 2.5rem; }
.app-top {
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap;
}
.app-top h1 { margin: 0; font-size: 1.45rem; }

.flash {
  border-radius: 14px; padding: .85rem 1rem; margin-bottom: 1rem;
  border: 1px solid var(--line); background: #fff;
}
.flash.ok { border-color: rgba(11,110,79,.25); background: #eef8f3; color: var(--ok); }
.flash.error { border-color: rgba(155,28,28,.25); background: #fdf2f2; color: var(--danger); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .85rem; margin-bottom: 1.25rem; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 1rem;
}
.stat .label { color: var(--muted); font-size: .82rem; }
.stat .value { font-size: 1.45rem; font-weight: 700; margin-top: .2rem; }

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 1.15rem 1.2rem; margin-bottom: 1rem;
  box-shadow: 0 10px 30px rgba(18,20,26,.04);
}
.panel h2 { margin: 0 0 1rem; font-size: 1.1rem; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .85rem 1rem; }
.form-grid .full { grid-column: 1 / -1; }
label { display: block; font-size: .82rem; color: var(--muted); margin-bottom: .3rem; }
input, select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 12px;
  padding: .7rem .8rem; font: inherit; background: #fff;
}
textarea { min-height: 90px; resize: vertical; }
.actions { display: flex; gap: .65rem; flex-wrap: wrap; margin-top: 1rem; }

table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { text-align: left; padding: .7rem .4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
tr.row-link { cursor: pointer; }
tr.row-link:hover { background: rgba(11,110,79,.06); }
tr.row-link a { color: var(--accent); font-weight: 600; }

.receipt-head {
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px dashed var(--line);
}
.receipt-brand { font-family: var(--display); font-size: 1.45rem; line-height: 1.15; }
.receipt-num { font-weight: 700; font-size: 1.05rem; }
.receipt-meta { color: var(--muted); font-size: .9rem; }
.receipt-right { text-align: right; }
.kv {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: .75rem; margin: 0 0 1.25rem;
}
.kv > div {
  background: #f7f4ee; border: 1px solid var(--line); border-radius: 12px; padding: .7rem .85rem;
}
.kv dt { margin: 0; color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; }
.kv dd { margin: .2rem 0 0; font-weight: 700; font-size: 1.05rem; }
.badge {
  display: inline-block; padding: .15rem .55rem; border-radius: 999px;
  font-size: .75rem; font-weight: 600;
}
.badge.bozza { background: #fff4d6; color: var(--warn); }
.badge.inviato { background: #e7f6ef; color: var(--ok); }
.badge.errore { background: #fde8e8; color: var(--danger); }

.auth-box {
  width: min(420px, calc(100% - 2rem)); margin: 4rem auto;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 22px; padding: 1.6rem; box-shadow: var(--shadow);
}
.auth-box h1 { font-family: var(--display); font-weight: 400; margin: 0 0 .35rem; }
.auth-box .muted { color: var(--muted); margin: 0 0 1.2rem; }
.stack { display: grid; gap: .85rem; }

@media (max-width: 900px) {
  .hero, .grid-3, .stats, .form-grid, .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 5; }
  .side-nav { flex-direction: row; flex-wrap: wrap; }
}
