.shell { min-height: 100vh; }
.side { display: none; }
.main { padding: calc(14px + env(safe-area-inset-top)) 16px calc(96px + env(safe-area-inset-bottom)); max-width: 1180px; margin: 0 auto; }
.top { display: flex; align-items: flex-end; gap: 12px; margin: 6px 0 22px; }
.top > div:first-child { flex: 1; min-width: 0; }
.top h1 { margin: 2px 0 0; font-size: 32px; line-height: 1.1; }
.eyebrow { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.top-actions { display: flex; gap: 8px; }
@media (max-width: 959px) {
  .top { flex-wrap: wrap; align-items: center; }
  .top > div:first-child { order: 1; }
  .top-avatar { order: 2; }
  .top-actions { order: 3; width: 100%; }
  .top-actions:empty { display: none; }
  .top-actions .seg { width: 100%; }
  .top-actions .seg button { flex: 1; }
}
.view { animation: fadeUp .4s var(--ease) both; }

/* barra inferior (mòbil) */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr); padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  background: var(--glass); backdrop-filter: saturate(1.8) blur(20px); -webkit-backdrop-filter: saturate(1.8) blur(20px); border-top: 1px solid var(--line); }
.tabbar a { display: grid; justify-items: center; gap: 3px; padding: 6px 0; text-decoration: none; font-size: 10.5px; font-weight: 600; color: var(--ink-3); border-radius: 12px; transition: color .2s; }
.tabbar a.on { color: var(--ink); }
.tabbar a.on svg { stroke-width: 2.2; }

/* escriptori: barra lateral */
@media (min-width: 960px) {
  .shell { display: grid; grid-template-columns: 248px 1fr; }
  .side { display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 22px 14px; border-right: 1px solid var(--line); background: var(--glass); backdrop-filter: blur(20px); }
  .brand { display: flex; align-items: center; gap: 12px; padding: 4px 10px 26px; }
  .brand img { width: 40px; height: 40px; border-radius: 50%; }
  .brand b { display: block; font-family: var(--serif); font-weight: 500; font-size: 18px; letter-spacing: -.01em; }
  .brand span { font-size: 12px; color: var(--ink-3); }
  .nav { display: grid; gap: 2px; }
  .nav a, .side-link { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; text-decoration: none; color: var(--ink-2); font-weight: 500; transition: background .15s, color .15s; }
  .nav a:hover, .side-link:hover { background: var(--bg-soft); color: var(--ink); }
  .nav a.on { background: var(--bg-elev); color: var(--ink); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--line); }
  .nav a.on svg { color: var(--gold); }
  .side-foot { margin-top: auto; display: grid; gap: 2px; border-top: 1px solid var(--line); padding-top: 12px; }
  .side-link.on { color: var(--ink); background: var(--bg-soft); }
  .tabbar, .top-avatar { display: none; }
  .main { padding: 34px 40px 60px; width: 100%; }
  .top h1 { font-size: 38px; }
}

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 14px; }
@media (min-width: 760px) { .kpis { grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; } }
.kpi { padding: 16px 18px 18px; }
.kpi .k-l { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.kpi .k-v { font-family: var(--serif); font-weight: 500; font-size: 34px; letter-spacing: -.02em; line-height: 1.15; margin: 6px 0 6px; }
.kpi .k-d { font-size: 12.5px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; padding: 2px 7px; border-radius: 99px; font-size: 12px; }
.delta.up { color: var(--ok); background: var(--ok-soft); }
.delta.down { color: var(--bad); background: var(--bad-soft); }
.delta.flat { color: var(--ink-3); background: var(--bg-soft); }

.grid-2 { display: grid; gap: 14px; }
@media (min-width: 760px) { .grid-2 { grid-template-columns: 1fr 1fr; gap: 18px; } .span-2 { grid-column: span 2; } }

/* gràfics */
.chart { position: relative; height: 220px; }
.chart.short { height: 170px; }
.chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart .grid line { stroke: var(--line); }
.chart .axis text { fill: var(--ink-3); font-size: 11px; font-family: var(--sans); }
.chart .bar { fill: var(--gold); transition: opacity .15s; }
.chart .bar.dim { opacity: .35; }
.chart .hit { fill: transparent; cursor: default; }
.tip { position: fixed; z-index: 70; pointer-events: none; background: var(--ink); color: var(--bg); padding: 8px 11px; border-radius: 10px; font-size: 12.5px; line-height: 1.35;
  box-shadow: var(--shadow-lg); opacity: 0; transform: translate(-50%, calc(-100% - 10px)); transition: opacity .12s; white-space: nowrap; }
.tip.on { opacity: 1; }
.tip b { font-weight: 600; }
.meter { margin: 6px 0 16px; }
.meter:last-child { margin-bottom: 0; }
.meter-h { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 8px; }
.meter-t { height: 8px; border-radius: 99px; background: var(--bg-soft); overflow: hidden; }
.meter-t i { display: block; height: 100%; border-radius: 99px; background: var(--brand); transition: width .8s var(--ease); }

/* clients */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--bg-soft); }
.seg button { border: 0; background: none; height: 34px; padding: 0 12px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; transition: background .2s, color .2s; }
.seg button[aria-pressed=true] { background: var(--bg-elev); color: var(--ink); box-shadow: var(--shadow-sm); }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-3); padding: 14px 16px 10px; white-space: nowrap; }
.table td { padding: 12px 16px; border-top: 1px solid var(--line); vertical-align: middle; }
.table tbody tr { cursor: pointer; transition: background .12s; }
.table tbody tr:hover { background: var(--bg-soft); }
.table .who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.mini-stamps { display: flex; gap: 3px; }
.mini-stamps i { width: 8px; height: 8px; border-radius: 50%; background: var(--line-2); }
.mini-stamps i.on { background: var(--gold); }
.table-foot { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px 14px; border-top: 1px solid var(--line); }
@media (max-width: 700px) { .hide-sm { display: none; } .table td, .table th { padding-left: 12px; padding-right: 12px; } }

/* formularis */
.split { display: grid; gap: 18px; align-items: start; }
@media (min-width: 960px) { .split { grid-template-columns: minmax(0, 1.25fr) minmax(300px, .9fr); gap: 24px; } .preview-col { position: sticky; top: 34px; } }
.sec { font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); margin: 26px 0 14px; }
.sec:first-child { margin-top: 4px; }
.row-2 { display: grid; gap: 12px; }
@media (min-width: 560px) { .row-2 { grid-template-columns: 1fr 1fr; } }
.form-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--line); }
.banner { background: var(--gold-soft); color: var(--gold-ink); border-radius: var(--r); padding: 12px 16px; font-size: 14px; margin-bottom: 16px; }

/* vista prèvia de la targeta i de la notificació */
.preview-col .eyebrow { margin: 4px 0 12px; }
.wallet-card { border-radius: 22px; padding: 20px; color: #f4efe6; background: radial-gradient(130% 100% at 100% 0%, #44525e, #2f3b45 55%, #26313a); box-shadow: var(--shadow-lg); position: relative; overflow: hidden; }
.wallet-card::after { content: ""; position: absolute; width: 220px; height: 220px; right: -70px; bottom: -90px; border-radius: 50%; border: 1px solid rgba(210,170,108,.28); }
.wallet-card .stamp { box-shadow: inset 0 0 0 1.5px rgba(244,239,230,.28); }
.wallet-card .stamp.on { box-shadow: inset 0 -3px 0 rgba(0,0,0,.15); }
.wc-top { display: flex; align-items: center; gap: 10px; }
.wc-top img { width: 38px; height: 38px; border-radius: 50%; }
.wc-top span { display: block; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; opacity: .7; }
.wc-top b { font-family: var(--serif); font-weight: 500; font-size: 19px; }
.wc-lema { font-size: 13px; opacity: .75; margin: 14px 0 16px; }
.wc-foot { margin-top: 16px; font-size: 13px; opacity: .9; position: relative; z-index: 1; }
.notif { display: flex; gap: 12px; align-items: flex-start; margin-top: 16px; padding: 12px 14px; border-radius: 20px; background: var(--glass); backdrop-filter: blur(20px) saturate(1.6);
  box-shadow: var(--shadow), inset 0 0 0 1px var(--line); }
.notif img { width: 36px; height: 36px; border-radius: 9px; }
.notif-h { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.notif-h span { color: var(--ink-3); font-size: 12px; }
.notif p { margin: 2px 0 0; font-size: 14px; color: var(--ink-2); line-height: 1.35; overflow-wrap: anywhere; }
.phone { border-radius: 34px; padding: 26px 14px 30px; background: linear-gradient(160deg, #3b4752, #1f272e 60%, #2f3b45); box-shadow: var(--shadow-lg); }
.phone-time { text-align: center; color: #fff; font-size: 56px; font-weight: 300; letter-spacing: -.02em; margin-bottom: 18px; }
.phone .notif { background: rgba(250, 248, 244, .82); color: #1b2228; }
.phone .notif p { color: #4c5660; }

/* fitxa client */
.sheet h2 { font-family: var(--serif); font-weight: 500; font-size: 26px; letter-spacing: -.02em; margin: 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 14px; margin: 16px 0; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.pin-big { font-family: var(--serif); font-size: 52px; letter-spacing: .18em; text-align: center; margin: 18px 0 6px; font-variant-numeric: tabular-nums; }
