/* HalloFrame Conti — identità «libro mastro»: carta avorio, inchiostro, ottone.
   Verde per le entrate, rosso mattone per le uscite, blu ardesia per i previsti.
   Lo shell arriva da hf-ui.css; qui solo il frame. */

:root {
  --hf-accent: #9a7425;
  --hf-paper: #f5f2ea;
  --hf-content-max: 1520px;
  --hf-sans: "IBM Plex Sans", Inter, ui-sans-serif, system-ui, sans-serif;

  --ct-ink: #15181f;
  --ct-text: #2a2d33;
  --ct-muted: #6c6a63;
  --ct-faint: #a09b8f;
  --ct-paper: #f5f2ea;
  --ct-paper-2: #ece6d8;
  --ct-card: #fffdf7;
  --ct-line: #e6dfcf;
  --ct-line-2: #d5cbb4;
  --ct-brass: #9a7425;
  --ct-brass-2: #b88d35;
  --ct-brass-soft: #f4ead2;
  --ct-in: #1f7a4d;
  --ct-in-soft: #e3f1e8;
  --ct-out: #b5452b;
  --ct-out-soft: #f8e6df;
  --ct-plan: #4f6488;
  --ct-plan-soft: #e7ecf4;
  --ct-serif: "IBM Plex Serif", Georgia, serif;
  --ct-mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --ct-radius: 12px;
  --ct-shadow: 0 1px 0 rgba(21, 24, 31, .04), 0 14px 34px -22px rgba(21, 24, 31, .35);
}

body { background: var(--ct-paper); color: var(--ct-text); font-family: var(--hf-sans); }
.num, .ct-num { font-family: var(--ct-mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.in { color: var(--ct-in); } .out { color: var(--ct-out); } .plan { color: var(--ct-plan); }

/* ---------------------------------------------------------------- shell */
.sidebar { background: #fbf9f3; border-right: 1px solid var(--ct-line); }
.sidebar-brand .ct-mark { border-radius: 11px; flex-shrink: 0; }
.brand-text small { font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--ct-muted); }
.brand-text strong { font-family: var(--ct-serif); font-size: 22px; font-weight: 600; color: var(--ct-ink); }
.ct-side-new { margin: 10px 4px 12px; min-height: 42px; justify-content: center; gap: 8px; border-radius: 10px; display: inline-flex; align-items: center; font-weight: 600; font-size: 13px; }
.ct-side-new [data-icon] { width: 16px; height: 16px; }
.sidebar-nav a.active { background: var(--ct-brass-soft); color: #6d5115; }
.ct-nav-count { margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 99px; background: var(--ct-out-soft); color: var(--ct-out); font: 600 11px/1.6 var(--ct-mono); text-align: center; }
.ct-session { display: flex; align-items: center; gap: 10px; padding: 4px 6px 12px; min-width: 0; }
.ct-session strong { display: block; font-size: 12.5px; color: var(--ct-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px; }
.ct-session small { font-size: 11px; color: var(--ct-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; max-width: 170px; }
.ct-avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; background: var(--ct-ink); color: #f5f2ea; font: 600 13px var(--ct-serif); }
.topbar { background: color-mix(in srgb, var(--ct-paper) 90%, transparent); border-bottom: 1px solid var(--ct-line); }
.ct-crumb { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 12.5px; color: var(--ct-muted); }
.ct-crumb .page-title { font-size: 13.5px; font-weight: 600; color: var(--ct-ink); }
.ct-live { display: inline-flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--ct-muted); padding: 0 4px; }
.ct-live i { width: 7px; height: 7px; border-radius: 50%; background: var(--ct-faint); }
.ct-live[data-state="on"] i { background: #2f9e62; box-shadow: 0 0 0 3px rgba(47, 158, 98, .16); }
.ct-live[data-state="retry"] i { background: var(--ct-brass-2); }
.ct-content { padding-top: clamp(18px, 2.4vw, 28px); }
.ct-loading { display: flex; align-items: center; gap: 12px; padding: 40px 4px; color: var(--ct-muted); font-size: 13.5px; }
.ct-loading span { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--ct-line-2); border-top-color: var(--ct-ink); animation: ct-spin .8s linear infinite; }
@keyframes ct-spin { to { transform: rotate(360deg); } }

.primary { background: var(--ct-ink); border-color: var(--ct-ink); border-radius: 9px; display: inline-flex; align-items: center; gap: 8px; color: #fff; }
.primary:hover { background: #262a33; }
.primary.brass { background: var(--ct-brass); border-color: var(--ct-brass); }
.primary.brass:hover { background: #87661f; }
.ghost { background: var(--ct-card); border-color: var(--ct-line-2); border-radius: 9px; display: inline-flex; align-items: center; gap: 8px; }
.ghost:hover { background: #fff; border-color: var(--ct-faint); }
.primary [data-icon], .ghost [data-icon], .danger [data-icon] { width: 15px; height: 15px; }
.danger { border-radius: 9px; }
.ct-link { background: none; border: 0; padding: 0; color: #6d5115; font-weight: 600; font-size: 12.5px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(154, 116, 37, .35); }

/* ---------------------------------------------------------------- testate */
.ct-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 18px; flex-wrap: wrap; }
.ct-head h2 { font: 600 clamp(28px, 3vw, 38px)/1.04 var(--ct-serif); letter-spacing: -.02em; color: var(--ct-ink); }
.ct-eyebrow { font: 600 10.5px var(--hf-sans); letter-spacing: .16em; text-transform: uppercase; color: var(--ct-muted); margin-bottom: 6px; }
.ct-sub { margin-top: 8px; font-size: 13px; color: var(--ct-muted); display: flex; gap: 14px; flex-wrap: wrap; }
.ct-sub b { color: var(--ct-ink); font-weight: 600; }
.ct-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------------------------------------------------------------- cruscotto */
.ct-hero { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.4fr); gap: 0; background: var(--ct-ink); color: #f1ede3; border-radius: 16px; overflow: hidden; margin-bottom: 16px; box-shadow: 0 30px 60px -40px rgba(21, 24, 31, .7); }
.ct-hero-main { padding: 22px 26px; position: relative; background: repeating-linear-gradient(0deg, transparent 0 27px, rgba(255, 255, 255, .045) 27px 28px); }
.ct-hero-main small { font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: rgba(241, 237, 227, .6); }
.ct-hero-main strong { display: block; margin-top: 8px; font: 500 clamp(32px, 4vw, 46px)/1 var(--ct-mono); letter-spacing: -.03em; color: #fff; }
.ct-hero-main strong.neg { color: #f2a48f; }
.ct-hero-main p { margin-top: 10px; font-size: 12.5px; color: rgba(241, 237, 227, .7); }
.ct-hero-accounts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); border-left: 1px solid rgba(255, 255, 255, .08); }
.ct-hero-accounts div { padding: 18px 20px; border-bottom: 1px solid rgba(255, 255, 255, .07); border-right: 1px solid rgba(255, 255, 255, .07); min-width: 0; }
.ct-hero-accounts span { display: block; font-size: 12px; color: rgba(241, 237, 227, .65); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ct-hero-accounts b { display: block; margin-top: 4px; font: 500 17px var(--ct-mono); color: #fff; }
.ct-kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.ct-kpi { background: var(--ct-card); border: 1px solid var(--ct-line); border-radius: var(--ct-radius); padding: 14px 16px; min-width: 0; }
.ct-kpi small { display: block; font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--ct-muted); }
.ct-kpi strong { display: block; margin-top: 6px; font: 500 21px/1.1 var(--ct-mono); color: var(--ct-ink); letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ct-kpi span { display: block; margin-top: 5px; font-size: 11.5px; color: var(--ct-muted); }
.ct-kpi.in strong { color: var(--ct-in); } .ct-kpi.out strong { color: var(--ct-out); }
.ct-kpi.alert { border-color: color-mix(in srgb, var(--ct-out) 35%, white); background: linear-gradient(180deg, #fff, #fdf3ef); }
.ct-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; }
.ct-card { background: var(--ct-card); border: 1px solid var(--ct-line); border-radius: var(--ct-radius); padding: 18px 20px; min-width: 0; box-shadow: var(--ct-shadow); }
.ct-card > header { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.ct-card > header h3 { font: 600 17px var(--ct-serif); color: var(--ct-ink); }
.ct-card > header small { font-size: 12px; color: var(--ct-muted); }
.ct-legend { display: flex; gap: 14px; font-size: 11.5px; color: var(--ct-muted); }
.ct-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.ct-chart { width: 100%; height: auto; display: block; overflow: visible; }
.ct-chart text { font: 500 12.5px var(--ct-mono); fill: var(--ct-muted); }
.ct-chart .grid { stroke: var(--ct-line); stroke-width: 1; }
.ct-chart .zero { stroke: var(--ct-line-2); }
.ct-chart .bar-in { fill: var(--ct-in); } .ct-chart .bar-out { fill: var(--ct-out); opacity: .85; }
.ct-chart .net { fill: var(--ct-ink); }
.ct-chart .line { fill: none; stroke: var(--ct-ink); stroke-width: 2; stroke-linejoin: round; }
.ct-chart .area { fill: url(#ct-area); }
.ct-chart .low { fill: var(--ct-out); } .ct-chart .low-label { fill: var(--ct-out); font-weight: 600; }
.ct-chart .neg-zone { fill: rgba(181, 69, 43, .06); }
.ct-bars { display: grid; gap: 10px; }
.ct-bars div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; font-size: 12.5px; }
.ct-bars span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ct-bars b { font: 500 12.5px var(--ct-mono); }
.ct-bars i { grid-column: 1 / -1; height: 7px; border-radius: 99px; background: var(--ct-paper-2); overflow: hidden; display: block; }
.ct-bars i::after { content: ""; display: block; height: 100%; width: var(--w); background: linear-gradient(90deg, var(--ct-brass-2), var(--ct-out)); border-radius: 99px; }

/* ---------------------------------------------------------------- elenchi */
.ct-toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.ct-search { position: relative; flex: 1 1 280px; min-width: 200px; }
.ct-search [data-icon] { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--ct-muted); pointer-events: none; }
.ct-search input { width: 100%; min-height: 42px; padding: 0 14px 0 40px; border-radius: 10px; border: 1px solid var(--ct-line-2); background: var(--ct-card); font-size: 14px; }
.ct-search input:focus, .ct-toolbar select:focus, .ct-toolbar input:focus { outline: none; border-color: var(--ct-ink); box-shadow: 0 0 0 3px rgba(21, 24, 31, .08); }
.ct-toolbar select, .ct-toolbar input[type="date"] { min-height: 42px; padding: 6px 30px 6px 11px; font-size: 12.5px; border-radius: 10px; border: 1px solid var(--ct-line-2); background-color: var(--ct-card); max-width: 220px; }
.ct-toolbar input[type="date"] { padding-right: 10px; }
.ct-seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--ct-paper-2); gap: 2px; }
.ct-seg button { all: unset; cursor: pointer; padding: 7px 12px; border-radius: 8px; font-size: 12.5px; font-weight: 500; color: var(--ct-text); white-space: nowrap; }
.ct-seg button[aria-pressed="true"] { background: var(--ct-card); color: var(--ct-ink); font-weight: 600; box-shadow: 0 1px 2px rgba(21, 24, 31, .12); }
.ct-seg button:focus-visible { outline: 2px solid var(--ct-ink); }
.ct-totals { display: flex; gap: 0; margin-bottom: 12px; background: var(--ct-card); border: 1px solid var(--ct-line); border-radius: var(--ct-radius); overflow: hidden; }
.ct-totals div { flex: 1; padding: 11px 16px; border-right: 1px solid var(--ct-line); min-width: 0; }
.ct-totals div:last-child { border-right: 0; }
.ct-totals small { display: block; font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--ct-muted); }
.ct-totals b { display: block; margin-top: 3px; font: 500 16px var(--ct-mono); }
.ct-ledger { background: var(--ct-card); border: 1px solid var(--ct-line); border-radius: var(--ct-radius); overflow: clip; }
.ct-ledger table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ct-ledger th { text-align: left; font: 600 10.5px var(--hf-sans); letter-spacing: .12em; text-transform: uppercase; color: var(--ct-muted); padding: 10px 14px; background: #faf7ef; border-bottom: 1px solid var(--ct-line); white-space: nowrap; }
.ct-ledger td { padding: 11px 14px; border-bottom: 1px solid var(--ct-line); vertical-align: middle; }
.ct-ledger tr:last-child td { border-bottom: 0; }
.ct-ledger tbody tr { cursor: pointer; }
.ct-ledger tbody tr:hover td { background: #fffaf0; }
.ct-ledger tbody tr:focus-visible { outline: 2px solid var(--ct-ink); outline-offset: -2px; }
.ct-ledger .r { text-align: right; }
.ct-ledger .date { font: 500 12px var(--ct-mono); color: var(--ct-muted); white-space: nowrap; }
.ct-ledger .what strong { display: block; color: var(--ct-ink); font-weight: 600; max-width: 420px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ct-ledger .what small { display: block; font-size: 12px; color: var(--ct-muted); max-width: 420px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ct-ledger .amount { font: 500 14px var(--ct-mono); text-align: right; white-space: nowrap; }
.ct-ledger .amount.in::before { content: "+ "; } .ct-ledger .amount.out::before { content: "− "; }
.ct-ledger tr.planned td { background: repeating-linear-gradient(135deg, transparent 0 10px, rgba(79, 100, 136, .035) 10px 20px); }
.ct-ledger tr.planned .amount { opacity: .85; }
.ct-more { display: flex; justify-content: center; padding: 12px; border-top: 1px solid var(--ct-line); }
.ct-pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 6px; font-size: 10.5px; font-weight: 600; letter-spacing: .02em; white-space: nowrap; background: var(--ct-paper-2); color: var(--ct-text); }
.ct-pill.plan { background: var(--ct-plan-soft); color: var(--ct-plan); }
.ct-pill.late { background: var(--ct-out-soft); color: var(--ct-out); }
.ct-pill.ok { background: var(--ct-in-soft); color: var(--ct-in); }
.ct-pill.part { background: var(--ct-brass-soft); color: #6d5115; }
.ct-cat { font-size: 11.5px; color: var(--ct-muted); }
.ct-empty { background: var(--ct-card); border: 1px solid var(--ct-line); border-radius: var(--ct-radius); padding: clamp(26px, 5vw, 52px); text-align: left; }
.ct-empty h3 { font: 600 clamp(22px, 2.4vw, 28px)/1.15 var(--ct-serif); color: var(--ct-ink); }
.ct-empty p { margin-top: 10px; color: var(--ct-muted); max-width: 58ch; font-size: 14px; }
.ct-steps { list-style: none; margin: 20px 0 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; counter-reset: s; }
.ct-steps li { counter-increment: s; border: 1px solid var(--ct-line); border-radius: 11px; padding: 14px; background: #fff; display: grid; gap: 6px; align-content: start; }
.ct-steps li::before { content: counter(s); width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--ct-brass-soft); color: #6d5115; font: 600 12px var(--ct-mono); }
.ct-steps strong { font-size: 13.5px; color: var(--ct-ink); }
.ct-steps span { font-size: 12.5px; color: var(--ct-muted); }
.ct-steps button { justify-self: start; margin-top: 4px; }
.ct-none { padding: 26px 18px; text-align: center; color: var(--ct-muted); font-size: 13.5px; }
.ct-none strong { display: block; font: 600 16px var(--ct-serif); color: var(--ct-ink); margin-bottom: 4px; }

/* scadenze */
.ct-due-group { margin-bottom: 16px; }
.ct-due-group h3 { font: 600 15px var(--ct-serif); color: var(--ct-ink); margin: 0 0 8px; display: flex; gap: 10px; align-items: baseline; }
.ct-due-group h3 small { font: 500 12px var(--ct-mono); color: var(--ct-muted); }
.ct-due-group.late h3 { color: var(--ct-out); }
.ct-due { display: grid; grid-template-columns: 88px minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 11px 14px; background: var(--ct-card); border: 1px solid var(--ct-line); border-bottom: 0; }
.ct-due:first-of-type { border-radius: var(--ct-radius) var(--ct-radius) 0 0; }
.ct-due:last-child { border-bottom: 1px solid var(--ct-line); border-radius: 0 0 var(--ct-radius) var(--ct-radius); }
.ct-due:only-of-type { border-radius: var(--ct-radius); }
.ct-due .date { font: 500 12px var(--ct-mono); color: var(--ct-muted); }
.ct-due .what { min-width: 0; cursor: pointer; }
.ct-due .what strong { display: block; color: var(--ct-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13.5px; }
.ct-due .what small { display: block; font-size: 12px; color: var(--ct-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ct-due .amount { font: 500 14px var(--ct-mono); }

/* ---------------------------------------------------------------- drawer e modali */
.ct-drawer { padding: 0; border: 0; margin: 0 0 0 auto; width: min(760px, 100vw); max-width: 100vw; height: 100dvh; max-height: 100dvh; background: var(--ct-paper); color: var(--ct-text); box-shadow: -30px 0 80px -30px rgba(21, 24, 31, .5); }
.ct-drawer[open] { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; animation: ct-slide .24s cubic-bezier(.2, .8, .2, 1); }
.ct-drawer::backdrop { background: rgba(21, 24, 31, .38); backdrop-filter: blur(2px); }
@keyframes ct-slide { from { transform: translateX(36px); opacity: .5; } to { transform: none; opacity: 1; } }
.ct-dr-head { display: flex; align-items: center; gap: 12px; padding: 14px 20px; background: var(--ct-card); border-bottom: 1px solid var(--ct-line); }
.ct-dr-head .t { flex: 1; min-width: 0; }
.ct-dr-head small { display: block; font: 500 11px var(--ct-mono); color: var(--ct-muted); }
.ct-dr-head h2 { font: 600 20px/1.2 var(--ct-serif); color: var(--ct-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ct-dr-body { overflow: auto; padding: 18px 22px 40px; }
.ct-dr-foot { display: flex; align-items: center; gap: 10px; padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); background: var(--ct-card); border-top: 1px solid var(--ct-line); }
.ct-dr-foot .state { flex: 1; font-size: 12.5px; color: var(--ct-muted); min-width: 0; }
.ct-dr-foot .state.err { color: var(--ct-out); font-weight: 600; }
.ct-section { padding: 4px 0 18px; margin-bottom: 16px; border-bottom: 1px solid var(--ct-line); }
.ct-section:last-child { border-bottom: 0; margin-bottom: 0; }
.ct-section > h3 { font: 600 16px var(--ct-serif); color: var(--ct-ink); margin-bottom: 12px; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.ct-form { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px 14px; }
.ct-form > .c1 { grid-column: span 1; } .ct-form > .c2 { grid-column: span 2; } .ct-form > .c3 { grid-column: span 3; } .ct-form > .c4 { grid-column: span 4; } .ct-form > .c6 { grid-column: 1 / -1; }
.ct-drawer .field, .ct-modal .field { gap: 6px; }
.ct-drawer .field > span, .ct-modal .field > span { font-size: 11.5px; font-weight: 600; color: var(--ct-text); }
.ct-drawer .field input, .ct-drawer .field select, .ct-drawer .field textarea, .ct-modal .field input, .ct-modal .field select { background: #fff; border-color: var(--ct-line-2); border-radius: 9px; min-height: 40px; }
.ct-drawer .field input:focus, .ct-drawer .field select:focus, .ct-drawer .field textarea:focus, .ct-modal .field input:focus, .ct-modal .field select:focus { border-color: var(--ct-ink); box-shadow: 0 0 0 3px rgba(21, 24, 31, .09); outline: none; }
.ct-drawer .field textarea { min-height: 80px; resize: vertical; }
.field input.money { font: 500 15px var(--ct-mono); text-align: right; }
.field input.money.big { font-size: 26px; min-height: 58px; letter-spacing: -.02em; }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--ct-out) !important; background: #fffaf8 !important; }
.ct-err, .field .ct-err { font-size: 11.5px; font-weight: 600; color: var(--ct-out); order: 5; text-transform: none; letter-spacing: 0; }
.ct-kind { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding: 4px; background: var(--ct-paper-2); border-radius: 12px; margin-bottom: 14px; }
.ct-kind label { position: relative; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px; border-radius: 9px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--ct-text); }
.ct-kind input { position: absolute; opacity: 0; pointer-events: none; }
.ct-kind label:has(input:checked) { background: var(--ct-card); box-shadow: 0 1px 3px rgba(21, 24, 31, .14); }
.ct-kind label.k-in:has(input:checked) { color: var(--ct-in); } .ct-kind label.k-out:has(input:checked) { color: var(--ct-out); } .ct-kind label.k-tr:has(input:checked) { color: var(--ct-plan); }
.ct-kind label:has(input:focus-visible) { outline: 2px solid var(--ct-ink); }
.ct-kind [data-icon] { width: 16px; height: 16px; }
.ct-switch { display: inline-flex; align-items: center; gap: 10px; font-size: 13px; cursor: pointer; }
.ct-switch input { width: 36px; height: 20px; appearance: none; border-radius: 99px; background: var(--ct-line-2); position: relative; cursor: pointer; margin: 0; flex-shrink: 0; }
.ct-switch input::after { content: ""; position: absolute; left: 3px; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
.ct-switch input:checked { background: var(--ct-ink); }
.ct-switch input:checked::after { transform: translateX(16px); }
.ct-switch input:focus-visible { outline: 2px solid var(--ct-ink); outline-offset: 2px; }
.ct-hint { font-size: 12px; color: var(--ct-muted); }
.ct-calc { display: flex; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 10px; background: #fff; border: 1px dashed var(--ct-line-2); font-size: 12.5px; color: var(--ct-muted); }
.ct-calc b { font: 600 14px var(--ct-mono); color: var(--ct-ink); }
.ct-rows { display: grid; gap: 8px; }
.ct-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 8px; align-items: end; }
.ct-x { all: unset; cursor: pointer; width: 36px; height: 40px; display: grid; place-items: center; border-radius: 8px; color: var(--ct-out); }
.ct-x:hover { background: var(--ct-out-soft); }
.ct-x [data-icon] { width: 15px; height: 15px; }
.ct-kv { display: grid; grid-template-columns: minmax(120px, 36%) minmax(0, 1fr); gap: 7px 14px; font-size: 13px; }
.ct-kv dt { color: var(--ct-muted); } .ct-kv dd { margin: 0; color: var(--ct-ink); overflow-wrap: anywhere; }
.ct-files { display: grid; gap: 6px; }
.ct-file { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--ct-line); background: #fff; font-size: 13px; }
.ct-file a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; color: var(--ct-ink); }
.ct-file small { color: var(--ct-muted); font: 500 11px var(--ct-mono); }
.ct-upload { display: inline-flex; position: relative; }
.ct-upload input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.ct-history { display: grid; gap: 10px; }
.ct-history div { font-size: 12.5px; padding-left: 14px; border-left: 2px solid var(--ct-line-2); }
.ct-history b { color: var(--ct-ink); }
.ct-history small { display: block; color: var(--ct-muted); font-size: 11.5px; }
.ct-history s { color: var(--ct-faint); }
.ct-pay { display: grid; grid-template-columns: 90px minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px dashed var(--ct-line); font-size: 13px; }
.ct-pay:last-child { border-bottom: 0; }
.ct-pay .date { font: 500 12px var(--ct-mono); color: var(--ct-muted); }
.ct-pay .amount { font: 500 13.5px var(--ct-mono); }

.ct-modal { border: 0; padding: 0; border-radius: 16px; width: min(560px, calc(100vw - 24px)); max-height: min(88dvh, 820px); background: var(--ct-card); color: var(--ct-text); box-shadow: 0 40px 100px -30px rgba(21, 24, 31, .55); }
.ct-modal.wide { width: min(980px, calc(100vw - 24px)); }
.ct-modal[open] { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; animation: ct-pop .2s ease-out; }
.ct-modal::backdrop { background: rgba(21, 24, 31, .4); }
@keyframes ct-pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.ct-modal header { padding: 20px 22px 10px; }
.ct-modal header h2 { font: 600 20px/1.2 var(--ct-serif); color: var(--ct-ink); }
.ct-modal header p { margin-top: 6px; font-size: 13px; color: var(--ct-muted); }
.ct-modal .body { padding: 6px 22px 18px; overflow: auto; }
.ct-modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--ct-line); background: #faf7ef; flex-wrap: wrap; }

/* ---------------------------------------------------------------- import */
.ct-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.ct-drop { display: grid; place-items: center; text-align: center; gap: 6px; padding: 28px 16px; border: 1.5px dashed var(--ct-line-2); border-radius: 12px; background: #fff; cursor: pointer; position: relative; transition: border-color .15s, background .15s; }
.ct-drop:hover, .ct-drop.over { border-color: var(--ct-ink); background: #fffdf8; }
.ct-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.ct-drop [data-icon] { width: 26px; height: 26px; color: var(--ct-brass); }
.ct-drop strong { font: 600 15px var(--ct-serif); color: var(--ct-ink); }
.ct-drop span { font-size: 12.5px; color: var(--ct-muted); }
.ct-map { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px 12px; margin: 14px 0; }
.ct-sample { overflow: auto; border: 1px solid var(--ct-line); border-radius: 10px; }
.ct-sample table { border-collapse: collapse; font-size: 12px; min-width: 100%; }
.ct-sample th, .ct-sample td { padding: 7px 10px; border-bottom: 1px solid var(--ct-line); white-space: nowrap; max-width: 240px; overflow: hidden; text-overflow: ellipsis; text-align: left; }
.ct-sample th { background: #faf7ef; font-weight: 600; }
.ct-lines { border: 1px solid var(--ct-line); border-radius: 12px; overflow: auto; max-height: 60vh; background: #fff; }
.ct-lines table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.ct-lines th { position: sticky; top: 0; z-index: 1; background: #faf7ef; text-align: left; padding: 9px 10px; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--ct-muted); border-bottom: 1px solid var(--ct-line); }
.ct-lines td { padding: 8px 10px; border-bottom: 1px solid var(--ct-line); vertical-align: middle; }
.ct-lines td.amount { font: 500 13px var(--ct-mono); text-align: right; white-space: nowrap; }
.ct-lines tr.off td { opacity: .45; }
.ct-lines select { font-size: 12px; padding: 5px 26px 5px 8px; border-radius: 8px; border: 1px solid var(--ct-line-2); max-width: 230px; background-color: #fff; }
.ct-match { display: inline-flex; flex-direction: column; font-size: 12px; }
.ct-match b { color: var(--ct-in); font-weight: 600; }
.ct-result { text-align: center; padding: 30px 16px; }
.ct-result strong { display: block; font: 600 26px var(--ct-serif); color: var(--ct-ink); }
.ct-result p { color: var(--ct-muted); margin: 8px 0 16px; }

/* ---------------------------------------------------------------- report e iva */
.ct-pivot { overflow: auto; background: var(--ct-card); border: 1px solid var(--ct-line); border-radius: var(--ct-radius); }
.ct-pivot table { border-collapse: separate; border-spacing: 0; font-size: 12.5px; min-width: 100%; }
.ct-pivot th, .ct-pivot td { padding: 8px 10px; border-bottom: 1px solid var(--ct-line); white-space: nowrap; text-align: right; font-family: var(--ct-mono); font-variant-numeric: tabular-nums; }
.ct-pivot th:first-child, .ct-pivot td:first-child { position: sticky; left: 0; z-index: 1; text-align: left; font-family: var(--hf-sans); background: var(--ct-card); min-width: 220px; max-width: 280px; overflow: hidden; text-overflow: ellipsis; border-right: 1px solid var(--ct-line); }
.ct-pivot thead th { background: #faf7ef; font: 600 10.5px var(--hf-sans); letter-spacing: .1em; text-transform: uppercase; color: var(--ct-muted); position: sticky; top: 0; z-index: 2; }
.ct-pivot thead th:first-child { z-index: 3; background: #faf7ef; }
.ct-pivot tr.group td { font-weight: 600; background: #fdfaf2; }
.ct-pivot tr.group td:first-child { background: #fdfaf2; }
.ct-pivot tr.child td:first-child { padding-left: 26px; color: var(--ct-muted); }
.ct-pivot tr.total td { font-weight: 600; border-top: 2px solid var(--ct-ink); }
.ct-pivot tr.margin td { font-weight: 700; background: var(--ct-paper-2); }
.ct-pivot tr.margin td:first-child { background: var(--ct-paper-2); }
.ct-pivot .zero { color: var(--ct-faint); }
.ct-vat { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.ct-vat.monthly { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.ct-vat article { background: var(--ct-card); border: 1px solid var(--ct-line); border-radius: var(--ct-radius); padding: 14px 16px; display: grid; gap: 8px; }
.ct-vat article.now { border-color: var(--ct-brass); box-shadow: inset 0 0 0 1px var(--ct-brass); }
.ct-vat h3 { font: 600 14px var(--ct-serif); color: var(--ct-ink); display: flex; justify-content: space-between; gap: 6px; }
.ct-vat dl { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: 12px; margin: 0; }
.ct-vat dt { color: var(--ct-muted); } .ct-vat dd { margin: 0; font-family: var(--ct-mono); text-align: right; }
.ct-vat .pay { border-top: 1px solid var(--ct-line); padding-top: 8px; display: flex; justify-content: space-between; align-items: baseline; }
.ct-vat .pay b { font: 600 17px var(--ct-mono); }
.ct-note { margin-top: 14px; font-size: 12.5px; color: var(--ct-muted); max-width: 90ch; }

/* ricorrenze e beni */
.ct-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.ct-rec { background: var(--ct-card); border: 1px solid var(--ct-line); border-radius: var(--ct-radius); padding: 14px 16px; display: grid; gap: 6px; cursor: pointer; position: relative; overflow: hidden; }
.ct-rec::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--ct-out); }
.ct-rec.in::before { background: var(--ct-in); }
.ct-rec.off { opacity: .55; }
.ct-rec:hover { border-color: var(--ct-line-2); box-shadow: var(--ct-shadow); }
.ct-rec:focus-visible { outline: 2px solid var(--ct-ink); }
.ct-rec strong { font-size: 14px; color: var(--ct-ink); }
.ct-rec b { font: 500 19px var(--ct-mono); }
.ct-rec small { font-size: 12px; color: var(--ct-muted); }
.ct-progress { height: 6px; border-radius: 99px; background: var(--ct-paper-2); overflow: hidden; }
.ct-progress span { display: block; height: 100%; background: var(--ct-brass-2); }

/* impostazioni */
.ct-settings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.ct-list { display: grid; gap: 0; border: 1px solid var(--ct-line); border-radius: 11px; overflow: hidden; background: #fff; }
.ct-list > div { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--ct-line); font-size: 13px; }
.ct-list > div:last-child { border-bottom: 0; }
.ct-list > div > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ct-list > div.sub { padding-left: 30px; color: var(--ct-muted); }
.ct-list > div.off span { opacity: .5; text-decoration: line-through; }
.ct-list small { font: 500 11.5px var(--ct-mono); color: var(--ct-muted); }
.ct-tabs { display: flex; gap: 4px; margin-bottom: 10px; }

/* attività */
.ct-events { background: var(--ct-card); border: 1px solid var(--ct-line); border-radius: var(--ct-radius); overflow: hidden; }
.ct-event { display: grid; grid-template-columns: 120px minmax(0, 1fr) auto; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--ct-line); font-size: 13px; align-items: start; }
.ct-event:last-child { border-bottom: 0; }
.ct-event time { font: 500 11.5px var(--ct-mono); color: var(--ct-muted); }
.ct-event small { display: block; color: var(--ct-muted); font-size: 12px; }

/* accesso */
.ct-login { min-height: 100vh; background: var(--ct-paper); display: grid; place-items: center; padding: 24px 16px; }
.ct-login-shell { width: min(960px, 100%); display: grid; grid-template-columns: 1fr 1fr; background: var(--ct-card); border: 1px solid var(--ct-line); border-radius: 20px; overflow: hidden; box-shadow: 0 40px 90px -50px rgba(21, 24, 31, .5); }
.ct-login-ledger { padding: 34px 36px; background: var(--ct-ink); color: #f1ede3; display: grid; align-content: space-between; gap: 30px; background-image: repeating-linear-gradient(0deg, transparent 0 31px, rgba(255, 255, 255, .05) 31px 32px); }
.ct-login-brand { display: inline-flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.ct-login-brand small { display: block; font-size: 10px; letter-spacing: .18em; text-transform: uppercase; opacity: .7; }
.ct-login-brand strong { display: block; font: 600 24px var(--ct-serif); }
.ct-login-ledger .ct-login-brand img { box-shadow: 0 0 0 1px rgba(255, 255, 255, .2); border-radius: 11px; }
.ct-login-motto { font: 500 clamp(21px, 2.4vw, 28px)/1.25 var(--ct-serif); max-width: 19ch; }
.ct-login-book { border: 1px solid rgba(255, 255, 255, .14); border-radius: 12px; padding: 12px 14px; display: grid; gap: 10px; }
.ct-book-head { display: grid; grid-template-columns: 1fr 1fr; font: 500 10.5px var(--ct-mono); letter-spacing: .14em; text-transform: uppercase; color: rgba(241, 237, 227, .55); padding-left: 14px; }
.ct-book-row { display: grid; grid-template-columns: 8px 1fr 1fr; gap: 10px; align-items: center; }
.ct-book-row i { width: 6px; height: 6px; border-radius: 50%; background: rgba(255, 255, 255, .25); }
.ct-book-row b { height: 7px; border-radius: 99px; width: 70%; }
.ct-book-row b.out { background: #d4775f; } .ct-book-row b.in { background: #4fae7f; }
.ct-book-row b.w1 { width: 45%; } .ct-book-row b.w2 { width: 85%; } .ct-book-row b.w3 { width: 55%; }
.ct-book-total { border-top: 1px solid rgba(255, 255, 255, .18); padding-top: 10px; display: flex; justify-content: flex-end; }
.ct-book-total span { width: 40%; height: 9px; border-radius: 99px; background: var(--ct-brass-2); }
.ct-login-card { padding: 40px 40px 30px; display: grid; align-content: center; gap: 16px; }
.ct-login-card .compact { display: none; color: var(--ct-ink); }
.ct-login-card h1 { font: 600 30px/1.1 var(--ct-serif); color: var(--ct-ink); }
.ct-login-form { display: grid; gap: 14px; }
.ct-login-form .field > span { font-size: 12px; font-weight: 600; }
.ct-login-form input { min-height: 46px; border-radius: 10px; background: #fff; border: 1px solid var(--ct-line-2); width: 100%; padding: 0 14px; font-size: 15px; }
.ct-login-form input:focus { outline: none; border-color: var(--ct-ink); box-shadow: 0 0 0 4px rgba(21, 24, 31, .09); }
.ct-login-form .primary { min-height: 48px; justify-content: center; font-size: 14px; border-radius: 10px; width: 100%; margin-top: 4px; }
.ct-login-foot { font-size: 11.5px; color: var(--ct-faint); }

/* ---------------------------------------------------------------- responsive */
@media (min-width: 721px) { .ct-hide-lg { display: none !important; } }
@media (max-width: 1240px) {
  .ct-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ct-vat.monthly { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .ct-grid { grid-template-columns: 1fr; }
  .ct-hero { grid-template-columns: 1fr; }
  .ct-hero-accounts { border-left: 0; border-top: 1px solid rgba(255, 255, 255, .08); }
  .ct-settings { grid-template-columns: 1fr; }
  .ct-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ct-vat { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 960px) { .ct-live span { display: none; } }
@media (max-width: 720px) {
  .ct-content { padding-left: 12px; padding-right: 12px; }
  .ct-hide-sm { display: none; }
  .ct-head { margin-bottom: 14px; }
  .ct-head .ct-actions .ghost span:not([data-icon]) { display: none; }
  .ct-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .ct-kpi strong { font-size: 18px; }
  .ct-hero-main { padding: 18px; }
  .ct-hero-accounts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ct-hero-accounts div { padding: 12px 14px; }
  .ct-card { padding: 16px 14px; }
  .ct-toolbar select, .ct-toolbar input[type="date"] { flex: 1 1 calc(50% - 8px); max-width: none; }
  .ct-seg { width: 100%; } .ct-seg button { flex: 1; text-align: center; }
  .ct-totals { flex-wrap: wrap; } .ct-totals div { flex: 1 1 33%; }
  /* registro a schede su telefono */
  .ct-ledger thead { display: none; }
  .ct-ledger table, .ct-ledger tbody, .ct-ledger tr, .ct-ledger td { display: block; width: 100%; }
  .ct-ledger tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 11px 14px; border-bottom: 1px solid var(--ct-line); }
  .ct-ledger td { padding: 0; border: 0; }
  .ct-ledger td.what { grid-column: 1; grid-row: 1; }
  .ct-ledger td.amount { grid-column: 2; grid-row: 1; }
  .ct-ledger td.date { grid-column: 1; grid-row: 2; }
  .ct-ledger td.meta { grid-column: 2; grid-row: 2; text-align: right; }
  .ct-ledger td.opt { display: none; }
  .ct-ledger .what strong, .ct-ledger .what small { max-width: none; }
  .ct-due { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; }
  .ct-due .date { grid-column: 1; grid-row: 2; }
  .ct-due .what { grid-column: 1; grid-row: 1; }
  .ct-due .amount { grid-column: 2; grid-row: 1; text-align: right; }
  .ct-due .act { grid-column: 2; grid-row: 2; justify-self: end; }
  .ct-steps { grid-template-columns: 1fr; }
  .ct-two { grid-template-columns: 1fr; }
  .ct-vat, .ct-vat.monthly { grid-template-columns: 1fr; }
  .ct-event { grid-template-columns: 1fr; gap: 2px; }
  .ct-drawer { width: 100vw; box-shadow: none; }
  .ct-dr-head { padding: 10px 12px; }
  .ct-dr-head h2 { font-size: 18px; }
  .ct-dr-body { padding: 14px 14px 40px; }
  .ct-dr-foot { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
  .ct-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ct-form > .c1, .ct-form > .c2 { grid-column: span 1; }
  .ct-form > .c3, .ct-form > .c4, .ct-form > .c6 { grid-column: 1 / -1; }
  .ct-pay { grid-template-columns: 1fr auto; }
  .ct-pay .date { grid-row: 2; } .ct-pay .act { grid-column: 2; grid-row: 2; justify-self: end; }
  .ct-modal { width: 100vw; max-width: 100vw; max-height: 92dvh; margin: auto 0 0; border-radius: 18px 18px 0 0; }
  .ct-modal footer { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .ct-modal footer > * { flex: 1 1 auto; justify-content: center; }
  .ct-login-shell { grid-template-columns: 1fr; }
  .ct-login-ledger { display: none; }
  .ct-login-card { padding: 30px 22px 24px; }
  .ct-login-card .compact { display: inline-flex; }
}
@media (max-width: 480px) {
  .ct-head h2 { font-size: 27px; }
  .ct-hero-main strong { font-size: 32px; }
  .ct-kv { grid-template-columns: 1fr; gap: 2px; }
  .ct-kv dd { margin-bottom: 8px; }
  .ct-login { padding: 12px; place-items: start center; }
}
@media (prefers-reduced-motion: reduce) { .ct-drawer[open], .ct-modal[open] { animation: none; } }
