/* CondoTap - identità visiva DISBIT */
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(/brand/inter-latin-var.woff2) format("woff2");
}
:root {
  --night: #1d1830;          /* DISBIT: inchiostro notte */
  --night-2: #2a2342;
  --paper: #f5f2ec;          /* DISBIT: carta */
  --orange: #f0913f;         /* DISBIT: arancio (su fondo scuro) */
  --bg: #faf8f4;
  --card: #ffffff;
  --ink: #1d1830;
  --muted: #6b6680;
  --line: #e6e1d8;
  --brand: #b85c10;          /* azioni: arancio DISBIT leggibile su chiaro */
  --brand-ink: #ffffff;
  --brand-soft: #fbeadb;
  --teal: #137a66;
  --teal-soft: #e3f1ed;
  --ok: #2f7d32;
  --ok-soft: #e5f2e3;
  --warn: #a8520b;
  --warn-soft: #fbeadb;
  --err: #c43c3b;
  --err-soft: #fbe5e4;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(29, 24, 48, .04), 0 4px 16px rgba(29, 24, 48, .05);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
body { background: var(--bg); }

/* marchio CondoTap */
.ct-brand { display: inline-flex; align-items: center; gap: .55rem; text-decoration: none; color: inherit; min-width: 0; }
.ct-brand img { width: 30px; height: 30px; flex: none; border-radius: 8px; }
.ct-word { font-weight: 800; letter-spacing: .06em; font-size: 1.05rem; line-height: 1; white-space: nowrap; }
.ct-word b { color: var(--orange); font-weight: 800; }
.ct-studio { display: block; font-size: .72rem; font-weight: 500; letter-spacing: 0; opacity: .75; margin-top: .2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ct-brand.big img { width: 56px; height: 56px; border-radius: 14px; }
.ct-brand.big .ct-word { font-size: 1.7rem; }
.powered { display: flex; align-items: center; gap: .4rem; font-size: .72rem; color: var(--muted); letter-spacing: .02em; }
.powered img { height: 12px; width: auto; display: block; }
.sidebar .powered { padding: 1rem 1.1rem .5rem; margin-top: auto; }
.auth .powered { justify-content: center; color: #b3adc4; margin-top: 1.1rem; }
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; font-size: 15px; line-height: 1.45; }
a { color: var(--brand); }
h1 { font-size: 1.35rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 1.25rem 0 .6rem; }
h3 { font-size: 1rem; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* layout */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: .75rem;
  background: var(--night); color: var(--paper);
  padding: .6rem 1rem; padding-top: max(.6rem, env(safe-area-inset-top)); box-shadow: 0 1px 0 rgba(255,255,255,.04);
}
.topbar .brand { font-weight: 700; letter-spacing: .2px; min-width: 0; flex: 0 1 auto; overflow: hidden; }
.ct-brand > span { min-width: 0; overflow: hidden; }
.topbar .who { white-space: nowrap; max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 960px) { .topbar .who { display: none; } }
.topbar .spacer { flex: 1; }
.topbar select { background: rgba(255,255,255,.1); color: #fff; border: 1px solid rgba(255,255,255,.25); border-radius: 8px; padding: .3rem .5rem; max-width: 50vw; }
.topbar select option { color: var(--ink); }
.cond-pick { display: flex; align-items: center; gap: .5rem; margin: 0 0 0 .75rem; color: #fff; font-size: .8rem; }
.cond-pick span { opacity: .85; white-space: nowrap; }
.topbar .cond-pick select { background: #fff; color: var(--ink); border-color: #fff; font-weight: 600; min-width: 220px; cursor: pointer; }
@media (max-width: 600px) {
  .topbar { gap: .5rem; padding: .55rem .75rem; }
  .topbar .brand { white-space: nowrap; overflow: hidden; min-width: 0; flex: 1; }
  .topbar .ct-brand img { width: 26px; height: 26px; }
  .topbar .ct-word { font-size: .95rem; }
  .topbar .spacer, .topbar .who, .topbar .cond-name { display: none; }
  .content .grid { grid-template-columns: 1fr 1fr; gap: .6rem; }
  .content .card.kpi { padding: .75rem; margin-bottom: 0; }
  .content .kpi .value { font-size: 1.1rem; }
  .content .kpi .label { font-size: .72rem; }
  h1 { font-size: 1.2rem; }
}
@media (max-width: 800px) { .cond-pick span { display: none; } .topbar .cond-pick select { min-width: 0; } }
.topbar button.link { color: #fff; }
.layout { display: flex; min-height: calc(100vh - 52px); }
.sidebar { width: 220px; flex: none; background: var(--card); border-right: 1px solid var(--line); padding: .75rem 0; display: flex; flex-direction: column; }
.sidebar a { display: block; padding: .55rem 1.1rem; color: var(--ink); text-decoration: none; border-left: 3px solid transparent; }
.sidebar a:hover { background: var(--bg); }
.sidebar a.active { border-left-color: var(--brand); background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.content { flex: 1; min-width: 0; padding: 1.25rem; max-width: 1100px; margin: 0 auto; }
.tabs-mobile { display: none; }
#menu-btn { display: none; background: none; border: 0; color: #fff; font-size: 1.4rem; cursor: pointer; }

@media (max-width: 800px) {
  .sidebar { position: fixed; top: 52px; left: 0; bottom: 0; z-index: 30; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  #menu-btn { display: block; }
  .content { padding: .85rem; }
}

/* card, griglie */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; margin-bottom: .9rem; }
.card.flat { box-shadow: none; border: 1px solid var(--line); }
.grid { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.kpi .label { color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .4px; }
.kpi .value { font-size: 1.45rem; font-weight: 700; margin-top: .15rem; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: .6rem; }

/* form */
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .2rem; }
input, select, textarea {
  width: 100%; font: inherit; color: inherit; background: #fff;
  border: 1px solid #ddd6ca; border-radius: 8px; padding: .5rem .65rem;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
input[type=checkbox] { width: auto; }
textarea { min-height: 90px; resize: vertical; }
.field { margin-bottom: .75rem; }
.fields { display: grid; gap: 0 .9rem; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.check { display: flex; align-items: center; gap: .45rem; color: var(--ink); font-size: .95rem; }

button, .btn {
  font: inherit; cursor: pointer; border-radius: 8px; padding: .5rem .95rem;
  border: 1px solid var(--brand); background: var(--brand); color: #fff; font-weight: 600;
  display: inline-flex; align-items: center; gap: .35rem; text-decoration: none;
}
button.secondary, .btn.secondary { background: #fff; color: var(--brand); }
button.danger { background: #fff; color: var(--err); border-color: #e6b8b2; }
button.link { background: none; border: 0; color: var(--brand); padding: .2rem .3rem; font-weight: 500; }
button.small { padding: .25rem .6rem; font-size: .85rem; }
button:disabled { opacity: .55; cursor: default; }

/* tabelle */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); font-weight: 600; background: #faf8f4; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; }
tfoot td { font-weight: 700; background: #faf8f4; }

/* badge e banner */
.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: .12rem .5rem; border-radius: 999px; background: var(--line); color: var(--ink); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err-soft); color: var(--err); }
.badge.info { background: var(--teal-soft); color: var(--teal); }
.banner { border-radius: var(--radius); padding: .8rem 1rem; margin-bottom: .9rem; border: 1px solid; }
.banner.ok { background: var(--ok-soft); border-color: #b9e4cd; color: #145c3b; }
.banner.err { background: var(--err-soft); border-color: #f1c4bd; color: #8e2a1f; }
.banner.warn { background: var(--warn-soft); border-color: #f0d9ad; color: #7a5212; }
.banner.info { background: var(--teal-soft); border-color: #bfdcd3; color: #0e5546; }
.banner b { display: block; margin-bottom: .1rem; }

/* rate (vista condomino) */
.rata { border-left: 4px solid var(--line); }
.rata.pagata { border-left-color: var(--ok); }
.rata.scaduta { border-left-color: var(--err); }
.rata.parziale, .rata.da_pagare { border-left-color: var(--warn); }
.rata-head { display: flex; justify-content: space-between; gap: .75rem; align-items: flex-start; }
.rata-amounts { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin-top: .6rem; }
.rata-amounts div span { display: block; font-size: .75rem; color: var(--muted); }
.rata-amounts div b { font-size: 1rem; }
details summary { cursor: pointer; color: var(--brand); font-size: .88rem; margin-top: .5rem; }
@media (max-width: 520px) { .rata-amounts { grid-template-columns: repeat(2, 1fr); } }

.seg { display: inline-flex; background: #efebe3; border-radius: 9px; padding: 3px; margin-bottom: .9rem; }
.seg button { background: none; border: 0; color: var(--muted); padding: .4rem 1rem; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: flex; gap: .9rem; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.timeline .date { width: 92px; flex: none; font-weight: 600; }

.folder { margin-bottom: .6rem; }
.folder > summary { font-weight: 600; color: var(--ink); font-size: 1rem; padding: .35rem 0; }
.doc { display: flex; justify-content: space-between; gap: .75rem; padding: .45rem 0 .45rem 1.2rem; border-bottom: 1px dashed var(--line); }

/* login */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; color: var(--paper);
  background: radial-gradient(120% 80% at 85% 0%, #3a2a3f 0%, rgba(29,24,48,0) 55%), linear-gradient(170deg, #1d1830 0%, #0e0c17 100%); }
.auth { width: 100%; max-width: 380px; }
.auth-head { text-align: center; margin-bottom: 1.2rem; }
.auth-head .ct-brand { justify-content: center; }
.auth-head p { margin: .6rem 0 0; color: #b3adc4; font-size: .9rem; }
.auth .card { color: var(--ink); }
.auth h1 { margin-bottom: .2rem; }
.auth .card { padding: 1.6rem; }

/* modal e toast */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 23, 32, .45); display: grid; place-items: center; z-index: 50; padding: 1rem; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; padding: 1.25rem; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal.wide { max-width: 920px; }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }
#toast { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: .4rem; }
.toast { background: var(--night); color: #fff; padding: .6rem 1rem; border-radius: 8px; box-shadow: var(--shadow); max-width: 90vw; }
.toast.err { background: var(--err); }
.secret { font-family: ui-monospace, Consolas, monospace; font-size: 1.05rem; background: #f4f1ea; padding: .3rem .55rem; border-radius: 6px; user-select: all; }
.empty { text-align: center; color: var(--muted); padding: 1.5rem 1rem; }
