/* Sistema visual dels panells (personal i propietari). Clar per defecte, fosc segons el sistema. */
:root {
  --bg: #f6f3ee;
  --bg-elev: #ffffff;
  --bg-soft: #efeae2;
  --glass: rgba(250, 248, 244, .72);
  --ink: #1b2228;
  --ink-2: #4c5660;
  --ink-3: #8a929a;
  --line: rgba(27, 34, 40, .08);
  --line-2: rgba(27, 34, 40, .14);
  --brand: #2f3b45;
  --brand-ink: #f6f1e8;
  --gold: #b38a4d;
  --gold-soft: rgba(179, 138, 77, .14);
  --gold-ink: #7a5a28;
  --ok: #2d7a52;
  --ok-soft: rgba(45, 122, 82, .12);
  --bad: #b6452f;
  --bad-soft: rgba(182, 69, 47, .1);
  --shadow-sm: 0 1px 2px rgba(20, 26, 32, .05), 0 1px 1px rgba(20, 26, 32, .03);
  --shadow: 0 1px 2px rgba(20, 26, 32, .04), 0 8px 24px -8px rgba(20, 26, 32, .12);
  --shadow-lg: 0 24px 60px -20px rgba(20, 26, 32, .35);
  --r-sm: 10px; --r: 16px; --r-lg: 22px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121619; --bg-elev: #1a2025; --bg-soft: #20272d; --glass: rgba(22, 27, 31, .72);
    --ink: #eef0f1; --ink-2: #b4bbc1; --ink-3: #7c858d;
    --line: rgba(255, 255, 255, .07); --line-2: rgba(255, 255, 255, .13);
    --brand: #e9e3d8; --brand-ink: #182026;
    --gold: #d2aa6c; --gold-soft: rgba(210, 170, 108, .14); --gold-ink: #e3c38f;
    --ok: #5cc28c; --ok-soft: rgba(92, 194, 140, .13); --bad: #ef7a62; --bad-soft: rgba(239, 122, 98, .12);
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -8px rgba(0,0,0,.5); --shadow-lg: 0 24px 60px -20px rgba(0,0,0,.7);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 15px; -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01"; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
.num { font-variant-numeric: tabular-nums; }
.serif { font-family: var(--serif); font-weight: 500; letter-spacing: -.015em; }
.muted { color: var(--ink-3); }
.soft { color: var(--ink-2); }
[hidden] { display: none !important; }
::selection { background: var(--gold-soft); }

/* botons */
.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 18px; border-radius: 12px; border: 0; cursor: pointer;
  font-weight: 600; font-size: 15px; background: var(--brand); color: var(--brand-ink); transition: transform .15s var(--ease), opacity .2s, background .2s; white-space: nowrap; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2); }
.btn.soft { background: var(--bg-soft); color: var(--ink); }
.btn.gold { background: var(--gold); color: #fff; }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn.lg { height: 54px; font-size: 16px; border-radius: 16px; }
.icon-btn { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--bg-soft); display: grid; place-items: center; cursor: pointer; color: var(--ink-2); }
svg.i { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* camps */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field small { color: var(--ink-3); font-size: 12px; }
.input { width: 100%; height: 44px; padding: 0 14px; border-radius: 12px; border: 0; background: var(--bg-soft); box-shadow: inset 0 0 0 1px transparent; transition: box-shadow .2s, background .2s; font-size: 16px; }
textarea.input { height: auto; padding: 12px 14px; resize: vertical; min-height: 88px; line-height: 1.45; }
.input:focus { outline: none; background: var(--bg-elev); box-shadow: inset 0 0 0 1.5px var(--gold); }
.search { position: relative; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); width: 18px; height: 18px; }
.search .input { padding-left: 40px; }
.toggle { position: relative; width: 46px; height: 28px; flex: none; }
.toggle input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.toggle i { position: absolute; inset: 0; border-radius: 99px; background: var(--line-2); transition: background .2s; pointer-events: none; }
.toggle i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.2); transition: transform .25s var(--spring); }
.toggle input:checked + i { background: var(--ok); }
.toggle input:checked + i::after { transform: translateX(18px); }

/* targetes i llistes */
.card { background: var(--bg-elev); border-radius: var(--r-lg); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--line); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 0; }
.card-h h3 { margin: 0; font-size: 15px; font-weight: 600; }
.card-b { padding: 16px 20px 20px; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
.row-btn { width: 100%; display: flex; align-items: center; gap: 12px; background: none; border: 0; text-align: left; cursor: pointer; padding: 0; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; flex: none; font-weight: 600; font-size: 14px; background: var(--gold-soft); color: var(--gold-ink); }
.pill { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--bg-soft); color: var(--ink-2); white-space: nowrap; }
.pill.gold { background: var(--gold-soft); color: var(--gold-ink); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.grow { flex: 1; min-width: 0; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { text-align: center; color: var(--ink-3); padding: 28px 12px; font-size: 14px; }

/* segells */
.stamps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.stamp { aspect-ratio: 1; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--line-2); display: grid; place-items: center; position: relative; }
.stamp.on { background: radial-gradient(circle at 35% 30%, #e3c48f, var(--gold) 70%); box-shadow: inset 0 -3px 0 rgba(0,0,0,.12), 0 2px 6px -2px rgba(122, 90, 40, .5); }
.stamp.on::before { content: "🥐"; font-size: clamp(14px, 4.5vw, 22px); }
.stamp.new { animation: stampIn .55s var(--spring) both; }
@keyframes stampIn { 0% { transform: scale(.2) rotate(-25deg); opacity: 0; } 100% { transform: none; opacity: 1; } }

/* full inferior (bottom sheet) i diàlegs */
.scrim { position: fixed; inset: 0; background: rgba(10, 14, 18, .38); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity .3s var(--ease); z-index: 40; }
.scrim.on { opacity: 1; pointer-events: auto; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; background: var(--bg-elev); border-radius: 26px 26px 0 0; box-shadow: var(--shadow-lg);
  transform: translateY(105%); transition: transform .42s var(--ease), visibility 0s .42s; visibility: hidden; max-height: 92vh; overflow: auto; padding: 8px 20px calc(24px + env(safe-area-inset-bottom)); }
.sheet.on { transform: none; visibility: visible; transition: transform .42s var(--ease), visibility 0s; }
.sheet .grab { width: 38px; height: 5px; border-radius: 99px; background: var(--line-2); margin: 4px auto 14px; }
@media (min-width: 760px) {
  .sheet { left: 50%; right: auto; bottom: auto; top: 50%; width: 460px; border-radius: 26px; transform: translate(-50%, -46%) scale(.96); opacity: 0; pointer-events: none;
    transition: transform .32s var(--ease), opacity .25s; padding-bottom: 24px; }
  .sheet.on { transform: translate(-50%, -50%); opacity: 1; pointer-events: auto; }
  .sheet .grab { display: none; }
}

/* avís flotant */
.toast { position: fixed; left: 50%; top: calc(14px + env(safe-area-inset-top)); z-index: 60; transform: translate(-50%, -140%); display: flex; align-items: center; gap: 10px;
  background: var(--ink); color: var(--bg); padding: 12px 18px 12px 14px; border-radius: 99px; font-weight: 600; font-size: 14px; box-shadow: var(--shadow-lg); transition: transform .45s var(--spring); max-width: calc(100vw - 32px); }
.toast.on { transform: translate(-50%, 0); }
.toast .dot { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--ok); color: #fff; flex: none; }
.toast.bad .dot { background: var(--bad); }

/* entrada */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; background:
  radial-gradient(900px 500px at 85% -10%, var(--gold-soft), transparent 60%), radial-gradient(700px 500px at -10% 110%, rgba(47,59,69,.08), transparent 60%), var(--bg); }
.auth-box { width: 100%; max-width: 380px; text-align: center; }
.auth-box .logo { width: 72px; height: 72px; border-radius: 50%; box-shadow: var(--shadow); }
.auth-box h1 { font-family: var(--serif); font-weight: 500; font-size: 30px; letter-spacing: -.02em; margin: 18px 0 4px; }
.fade-up { animation: fadeUp .5s var(--ease) both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.skeleton { background: linear-gradient(90deg, var(--bg-soft), var(--line), var(--bg-soft)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 8px; }
@keyframes sk { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* selector d'idioma */
.lang { display: inline-flex; gap: 2px; padding: 3px; border-radius: 99px; background: var(--bg-soft); }
.lang button { border: 0; background: none; height: 28px; min-width: 34px; padding: 0 8px; border-radius: 99px; font-size: 11.5px; font-weight: 700; letter-spacing: .04em; color: var(--ink-3); cursor: pointer; transition: background .2s, color .2s; }
.lang button[aria-pressed=true] { background: var(--bg-elev); color: var(--ink); box-shadow: var(--shadow-sm); }
.lang-top { position: absolute; top: calc(14px + env(safe-area-inset-top)); right: 16px; }

.auth-box { position: relative; }
