:root {
  --bg: #0b0816;
  --bg2: #150f28;
  --panel: rgba(32, 24, 58, .62);
  --panel-solid: #1c1533;
  --line: rgba(232, 192, 96, .18);
  --gold: #e8c060;
  --gold2: #f7dc8f;
  --gold3: #b8862b;
  --maroon: #7c1d2e;
  --ruby: #e0475f;
  --emerald: #2fbf8f;
  --saffron: #f39c3d;
  --sapphire: #5a8dee;
  --amethyst: #a56bf0;
  --text: #f1eadb;
  --muted: #a99fbc;
  --radius: 18px;
  --shadow: 0 20px 50px rgba(0, 0, 0, .45);
  --ease: cubic-bezier(.2, .8, .2, 1);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: Inter, system-ui, sans-serif; color: var(--text); font-size: 14.5px;
  background: radial-gradient(1200px 800px at 80% -10%, #2a1650 0%, transparent 60%),
              radial-gradient(900px 700px at -10% 110%, #3a0f22 0%, transparent 55%), var(--bg);
  background-attachment: fixed; overflow-x: hidden;
}
#dust { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.screen { position: relative; z-index: 1; }
.hidden { display: none !important; }
h1, h2, h3, .cinzel { font-family: Cinzel, serif; letter-spacing: .04em; }
a { color: var(--gold); }
.muted { color: var(--muted); }

/* ---------------- VAULT ---------------- */
#vault { min-height: 100vh; display: grid; grid-template-columns: 1.1fr .9fr; align-items: center; gap: 40px; padding: 40px 6vw; perspective: 1600px; }
.vault-stage { position: relative; display: grid; place-items: center; }
.vault-glow { position: absolute; width: 560px; height: 560px; border-radius: 50%; background: radial-gradient(circle, rgba(232,192,96,.28), transparent 65%); filter: blur(20px); animation: pulse 4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.08); opacity: .7; } }
.vault-frame {
  position: relative; width: min(440px, 78vw); aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #4a3a1a, #1a1206 70%);
  box-shadow: 0 0 0 10px #2a1d0b, 0 0 0 14px #6b4f1d, 0 0 0 18px #2a1d0b, 0 40px 90px rgba(0,0,0,.8), inset 0 0 60px #000;
  perspective: 1400px; animation: rise 1.2s var(--ease) both;
}
@keyframes rise { from { transform: translateY(40px) scale(.9); opacity: 0; } }
.vault-light { position: absolute; inset: 6%; border-radius: 50%; background: radial-gradient(circle, #fff8dc 0%, #f7dc8f 30%, #e8a43a 60%, transparent 75%); opacity: 0; transition: opacity .8s; }
.vault-door {
  position: absolute; inset: 4%; border-radius: 50%; transform-origin: 0% 50%; transform-style: preserve-3d;
  background: conic-gradient(from 0deg, #b8862b, #f7dc8f, #9a6a1c, #e8c060, #8a5d18, #f7dc8f, #b8862b);
  box-shadow: inset 0 0 0 12px rgba(0,0,0,.25), inset 0 0 50px rgba(0,0,0,.6), 0 10px 30px rgba(0,0,0,.6);
  transition: transform 1.6s cubic-bezier(.6,0,.2,1), filter .6s;
}
.door-ring { position: absolute; inset: 11%; border-radius: 50%; border: 3px solid rgba(60,35,5,.55); box-shadow: inset 0 0 0 8px rgba(255,240,190,.15), 0 0 0 6px rgba(60,35,5,.25); }
.bolts i { position: absolute; left: 50%; top: 50%; width: 18%; height: 7%; margin: -3.5% 0 0 -9%;
  background: linear-gradient(#d7d7d7, #7a7a7a 60%, #c8c8c8); border-radius: 6px; box-shadow: 0 2px 6px rgba(0,0,0,.6);
  transition: transform .9s var(--ease); }
.bolts i:nth-child(n) { --r: calc(var(--i) * 45deg); transform: rotate(var(--r)) translateX(245%); }
.bolts i:nth-child(1){--i:0}.bolts i:nth-child(2){--i:1}.bolts i:nth-child(3){--i:2}.bolts i:nth-child(4){--i:3}
.bolts i:nth-child(5){--i:4}.bolts i:nth-child(6){--i:5}.bolts i:nth-child(7){--i:6}.bolts i:nth-child(8){--i:7}
.unlocking .bolts i { transform: rotate(var(--r)) translateX(150%); }
.dial { position: absolute; inset: 27%; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff1c4, #c99a3b 45%, #6b4a12);
  box-shadow: 0 8px 22px rgba(0,0,0,.6), inset 0 0 0 5px rgba(80,50,10,.5); transition: transform .5s var(--ease); }
.dial-ticks { position: absolute; inset: 0; width: 100%; height: 100%; }
.dial-ticks line { stroke: #4a3108; stroke-width: 2; }
.dial-ticks text { fill: #4a3108; font: 700 11px Cinzel, serif; text-anchor: middle; }
.dial-hub { position: absolute; inset: 30%; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #7c1d2e, #3a0a14); display: grid; place-items: center; box-shadow: inset 0 0 12px #000, 0 0 0 4px #b8862b; }
.crown { fill: var(--gold); width: 60%; filter: drop-shadow(0 0 6px rgba(247,220,143,.6)); }
.handle { position: absolute; right: 7%; top: 50%; width: 15%; height: 15%; margin-top: -7.5%; transition: transform 1s var(--ease); }
.handle span { position: absolute; left: 50%; top: 50%; width: 100%; height: 12%; margin: -6% 0 0 -50%; background: linear-gradient(#eee, #888); border-radius: 6px; }
.handle span:nth-child(2) { transform: rotate(60deg); } .handle span:nth-child(3) { transform: rotate(-60deg); }
.unlocking .handle { transform: rotate(180deg); }
.vault-door.shake { animation: shake .5s; filter: drop-shadow(0 0 25px rgba(224,71,95,.9)); }
@keyframes shake { 20%,60% { transform: translateX(-12px); } 40%,80% { transform: translateX(12px); } }
.opening .vault-door { transform: rotateY(-108deg); }
.opening .vault-light { opacity: 1; }
.opening .vault-glow { animation: none; transform: scale(3); opacity: 1; transition: transform 1.6s, opacity 1.6s; }

.vault-form { background: var(--panel); border: 1px solid var(--line); border-radius: 24px; padding: 38px 34px; backdrop-filter: blur(14px); box-shadow: var(--shadow); max-width: 430px; width: 100%; animation: rise 1.2s .25s var(--ease) both; }
.vf-title { font-family: 'Cinzel Decorative', serif; font-size: 40px; background: linear-gradient(90deg, var(--gold3), var(--gold2), var(--gold3)); background-size: 200%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shimmer 4s linear infinite; }
@keyframes shimmer { to { background-position: 200% 0; } }
.vf-sub { color: var(--muted); margin: 4px 0 26px; }
.vf-sub b { color: var(--gold2); font-weight: 600; }
.vf-err { color: var(--ruby); min-height: 20px; margin-top: 12px; text-align: center; }
.vault-out { animation: fadeOut 1s 1.5s forwards; }
.vault-out .vault-form { animation: dropAway .8s forwards; }
@keyframes dropAway { to { transform: translateY(60px); opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }

/* ---------------- SPLASH ---------------- */
#splash { position: fixed; inset: 0; display: grid; place-items: center; z-index: 50; background: radial-gradient(circle, #3a2408 0%, #0b0816 70%); overflow: hidden; }
.rays { position: absolute; width: 220vmax; height: 220vmax; background: repeating-conic-gradient(rgba(247,220,143,.10) 0 6deg, transparent 6deg 18deg); animation: spin 30s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.splash-inner { position: relative; text-align: center; }
.big-crown { width: 120px; animation: crownDrop 1s var(--ease) both; }
@keyframes crownDrop { from { transform: translateY(-120px) rotate(-20deg); opacity: 0; } }
.splash-title { font-family: 'Cinzel Decorative', serif; font-size: clamp(34px, 7vw, 80px); margin: 10px 0; color: var(--gold2); text-shadow: 0 0 30px rgba(247,220,143,.6); }
.splash-title span { display: inline-block; opacity: 0; animation: letterIn .7s var(--ease) forwards; }
@keyframes letterIn { from { opacity: 0; transform: translateY(40px) scale(1.6); filter: blur(8px); } to { opacity: 1; transform: none; filter: none; } }
.splash-tag { font-family: Cinzel, serif; color: var(--muted); letter-spacing: .3em; text-transform: uppercase; opacity: 0; animation: fadeIn 1s 1.4s forwards; }
.splash-welcome { margin-top: 26px; font-family: 'Great Vibes', cursive; font-size: 34px; color: var(--gold); opacity: 0; animation: fadeIn 1s 1.9s forwards; }
@keyframes fadeIn { to { opacity: 1; } }
#splash.leave { animation: splashLeave .9s var(--ease) forwards; }
@keyframes splashLeave { to { opacity: 0; transform: scale(1.15); filter: blur(10px); } }

/* ---------------- APP SHELL ---------------- */
#app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; animation: fadeIn .8s both; opacity: 0; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 22px 14px; background: linear-gradient(180deg, rgba(28,20,52,.92), rgba(18,12,34,.95)); border-right: 1px solid var(--line); display: flex; flex-direction: column; z-index: 20; }
.brand { display: flex; gap: 12px; align-items: center; padding: 4px 10px 22px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.brand .crown { width: 40px; }
.brand-name { font-family: Cinzel, serif; font-weight: 700; color: var(--gold2); font-size: 16px; }
.brand-sub { font-size: 11px; letter-spacing: .25em; text-transform: uppercase; color: var(--muted); }
nav { flex: 1; overflow-y: auto; }
nav a { display: flex; gap: 12px; align-items: center; padding: 11px 14px; margin: 3px 0; border-radius: 12px; color: var(--text); text-decoration: none; position: relative; transition: background .3s, transform .3s var(--ease); }
nav a .ico { width: 22px; text-align: center; font-size: 17px; }
nav a:hover { background: rgba(232,192,96,.08); transform: translateX(4px); }
nav a.active { background: linear-gradient(90deg, rgba(232,192,96,.22), rgba(232,192,96,.03)); color: var(--gold2); }
nav a.active::before { content: ''; position: absolute; left: 0; top: 18%; bottom: 18%; width: 3px; border-radius: 3px; background: var(--gold); box-shadow: 0 0 12px var(--gold); }
.me { border-top: 1px solid var(--line); padding-top: 14px; display: flex; align-items: center; gap: 10px; }
.me .av { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, var(--maroon), #3a0a14); color: var(--gold2); font-family: Cinzel; font-weight: 700; border: 1px solid var(--gold3); }
.me .who { flex: 1; min-width: 0; }
.me .who b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 14px; padding: 16px 28px; background: rgba(11,8,22,.7); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.topbar h2 { margin: 0; font-size: 22px; flex: 1; color: var(--gold2); }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.menu { display: none; }
.view { padding: 26px 28px 60px; }
.view > * { animation: viewIn .55s var(--ease) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(16px); } }

/* ---------------- UI PRIMITIVES ---------------- */
.btn { --c: rgba(255,255,255,.08); border: 1px solid var(--line); background: var(--c); color: var(--text); padding: 9px 16px; border-radius: 11px; cursor: pointer; font: 600 13.5px Inter; display: inline-flex; gap: 8px; align-items: center; transition: transform .2s var(--ease), box-shadow .3s, background .3s; position: relative; overflow: hidden; white-space: nowrap; }
.btn:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,.35); }
.btn:active { transform: scale(.97); }
.btn.gold { background: linear-gradient(135deg, var(--gold2), var(--gold) 45%, var(--gold3)); color: #2a1a03; border-color: transparent; }
.btn.gold::after { content: ''; position: absolute; inset: 0; background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.55) 50%, transparent 70%); transform: translateX(-100%); transition: transform .8s; }
.btn.gold:hover::after { transform: translateX(100%); }
.btn.big { width: 100%; justify-content: center; padding: 14px; font-size: 15px; margin-top: 10px; font-family: Cinzel; letter-spacing: .08em; }
.btn.ruby { background: rgba(224,71,95,.15); border-color: rgba(224,71,95,.4); color: #ffb3c0; }
.btn.green { background: rgba(47,191,143,.15); border-color: rgba(47,191,143,.4); color: #9ff0d4; }
.btn.wa { background: #1fa855; border-color: #1fa855; color: #fff; }
.btn.sm { padding: 6px 11px; font-size: 12.5px; border-radius: 9px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.icon-btn { background: none; border: 1px solid var(--line); color: var(--text); width: 38px; height: 38px; border-radius: 10px; cursor: pointer; font-size: 18px; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; letter-spacing: .03em; }
input, select, textarea { width: 100%; background: rgba(10,6,22,.6); border: 1px solid rgba(232,192,96,.22); color: var(--text); border-radius: 10px; padding: 10px 12px; font: 14px Inter; transition: border .2s, box-shadow .2s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(232,192,96,.18); }
input[type=checkbox] { width: auto; }
select option { background: var(--panel-solid); }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0,1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; backdrop-filter: blur(10px); box-shadow: var(--shadow); position: relative; }
.card h3 { margin: 0 0 14px; font-size: 16px; color: var(--gold2); display: flex; align-items: center; gap: 10px; }
.card h3 .grow { flex: 1; }
.stagger > * { animation: popIn .6s var(--ease) both; }
.stagger > *:nth-child(1){animation-delay:.03s}.stagger > *:nth-child(2){animation-delay:.09s}.stagger > *:nth-child(3){animation-delay:.15s}
.stagger > *:nth-child(4){animation-delay:.21s}.stagger > *:nth-child(5){animation-delay:.27s}.stagger > *:nth-child(6){animation-delay:.33s}
.stagger > *:nth-child(7){animation-delay:.39s}.stagger > *:nth-child(8){animation-delay:.45s}.stagger > *:nth-child(n+9){animation-delay:.5s}
@keyframes popIn { from { opacity: 0; transform: translateY(22px) scale(.97); } }
.section-gap { margin-top: 22px; }

/* stats */
.stat { overflow: hidden; }
.stat .lbl { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .12em; }
.stat .val { font-family: Cinzel; font-size: 28px; font-weight: 700; margin-top: 6px; color: var(--gold2); }
.stat .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.stat .orb { position: absolute; right: -24px; top: -24px; width: 100px; height: 100px; border-radius: 50%; opacity: .25; filter: blur(6px); }
.stat .emoji { position: absolute; right: 16px; top: 14px; font-size: 26px; }

/* palace cards */
.palaces { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
.palace { cursor: pointer; overflow: hidden; padding: 0; transition: transform .45s var(--ease), box-shadow .45s; transform-style: preserve-3d; }
.palace:hover { transform: translateY(-6px) rotateX(3deg); box-shadow: 0 30px 60px rgba(0,0,0,.55), 0 0 0 1px rgba(232,192,96,.45); }
.palace .top { height: 120px; position: relative; overflow: hidden; }
.palace .top svg.arch { position: absolute; inset: 0; width: 100%; height: 100%; }
.palace .badge { position: absolute; top: 12px; right: 12px; }
.palace .floor { position: absolute; top: 12px; left: 12px; font-size: 11px; letter-spacing: .15em; text-transform: uppercase; background: rgba(0,0,0,.35); padding: 4px 9px; border-radius: 20px; }
.palace .body { padding: 16px 18px 18px; }
.palace .pname { font-family: Cinzel; font-size: 17px; font-weight: 700; color: var(--gold2); }
.palace .dyn { font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.palace .tenant { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.palace .chips { display: flex; gap: 6px; flex-wrap: wrap; }
.avatar { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; border: 2px solid var(--gold3); background: linear-gradient(135deg, var(--maroon), #2c0812); display: grid; place-items: center; color: var(--gold2); font-family: Cinzel; font-weight: 700; flex: none; }
.avatar.xl { width: 120px; height: 120px; font-size: 40px; border-width: 3px; box-shadow: 0 0 0 6px rgba(232,192,96,.12), 0 20px 40px rgba(0,0,0,.5); }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 600; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.08); white-space: nowrap; }
.pill.paid { background: rgba(47,191,143,.16); color: #8ff0cc; border-color: rgba(47,191,143,.35); }
.pill.pending { background: rgba(224,71,95,.16); color: #ffb0bd; border-color: rgba(224,71,95,.35); }
.pill.partial { background: rgba(243,156,61,.16); color: #ffd09a; border-color: rgba(243,156,61,.35); }
.pill.vacant { background: rgba(165,107,240,.16); color: #d6b8ff; border-color: rgba(165,107,240,.35); }
.pill.owner { background: rgba(232,192,96,.18); color: var(--gold2); border-color: rgba(232,192,96,.4); }
.pill.off { opacity: .45; text-decoration: line-through; }
.pending .dot, .pill.pending::before { }
.pulse-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ruby); box-shadow: 0 0 0 0 rgba(224,71,95,.7); animation: ping 1.6s infinite; display: inline-block; }
@keyframes ping { 70% { box-shadow: 0 0 0 9px rgba(224,71,95,0); } 100% { box-shadow: 0 0 0 0 rgba(224,71,95,0); } }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; padding: 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 10px; border-bottom: 1px solid rgba(255,255,255,.05); vertical-align: middle; }
tr { transition: background .2s; }
tbody tr:hover { background: rgba(232,192,96,.05); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

/* tabs */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs button { background: none; border: 0; color: var(--muted); padding: 12px 16px; font: 600 14px Inter; cursor: pointer; position: relative; white-space: nowrap; }
.tabs button.on { color: var(--gold2); }
.tabs button.on::after { content: ''; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; background: var(--gold); box-shadow: 0 0 10px var(--gold); animation: grow .35s var(--ease); }
@keyframes grow { from { transform: scaleX(0); } }

/* hero (house detail) */
.hero { display: flex; gap: 26px; align-items: center; overflow: hidden; }
.hero .bgname { position: absolute; right: -10px; bottom: -30px; font-family: 'Cinzel Decorative'; font-size: 110px; opacity: .05; pointer-events: none; white-space: nowrap; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.kv div small { display: block; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 3px; }
.kv div b { font-weight: 600; }

/* toggle */
.toggle { position: relative; display: inline-block; width: 44px; height: 24px; flex: none; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle span { position: absolute; inset: 0; background: rgba(255,255,255,.12); border-radius: 24px; transition: .3s; cursor: pointer; }
.toggle span::before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #ddd; border-radius: 50%; transition: .35s var(--ease); }
.toggle input:checked + span { background: linear-gradient(90deg, var(--gold3), var(--gold)); }
.toggle input:checked + span::before { transform: translateX(20px); background: #fff; }
.tog-cell { display: flex; align-items: center; gap: 8px; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(5,3,12,.7); backdrop-filter: blur(6px); z-index: 100; display: grid; place-items: center; padding: 20px; animation: fadeIn .25s forwards; opacity: 0; }
.modal { background: linear-gradient(180deg, #221a3d, #170f2b); border: 1px solid var(--line); border-radius: 22px; width: min(720px, 100%); max-height: 92vh; overflow-y: auto; box-shadow: 0 40px 100px rgba(0,0,0,.7); animation: modalIn .45s var(--ease) both; }
.modal.wide { width: min(980px, 100%); }
@keyframes modalIn { from { transform: translateY(30px) scale(.95); opacity: 0; } }
.modal-head { display: flex; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: inherit; z-index: 2; }
.modal-head h3 { margin: 0; flex: 1; color: var(--gold2); }
.modal-body { padding: 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.modal-bg.closing { animation: fadeOut .2s forwards; }

/* toasts */
#toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast { background: #221a3d; border: 1px solid var(--line); border-left: 4px solid var(--gold); padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow); animation: toastIn .45s var(--ease); max-width: 360px; }
.toast.err { border-left-color: var(--ruby); } .toast.ok { border-left-color: var(--emerald); }
@keyframes toastIn { from { transform: translateX(120%); } }

/* empty */
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty .big { font-size: 46px; margin-bottom: 10px; animation: float 3s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-8px); } }

/* docs */
.docs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.doc { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: rgba(0,0,0,.2); transition: transform .3s var(--ease); }
.doc:hover { transform: translateY(-3px); }
.doc .thumb { height: 100px; display: grid; place-items: center; font-size: 36px; background: rgba(232,192,96,.06); }
.doc .thumb img { width: 100%; height: 100%; object-fit: cover; }
.doc .meta { padding: 8px 10px; font-size: 12px; }
.doc .meta b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drop { border: 2px dashed rgba(232,192,96,.35); border-radius: 14px; padding: 22px; text-align: center; color: var(--muted); transition: background .2s, border-color .2s; cursor: pointer; }
.drop.over { background: rgba(232,192,96,.08); border-color: var(--gold); }
.photo-pick { display: flex; gap: 16px; align-items: center; margin-bottom: 16px; }

/* monthly sheet */
.meter { display: flex; gap: 8px; align-items: center; }
.meter input { width: 100px; text-align: right; }
.calc { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--gold2); transition: transform .3s; display: inline-block; }
.calc.bump { animation: bump .4s; }
@keyframes bump { 40% { transform: scale(1.25); color: #fff; } }

/* analytics */
.range-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.seg { display: inline-flex; background: rgba(0,0,0,.3); border: 1px solid var(--line); border-radius: 12px; padding: 4px; position: relative; }
.seg button { position: relative; z-index: 1; background: none; border: 0; color: var(--muted); font: 600 13px Inter; padding: 8px 14px; cursor: pointer; border-radius: 9px; transition: color .3s; }
.seg button.on { color: #2a1a03; }
.seg .slider { position: absolute; top: 4px; bottom: 4px; border-radius: 9px; background: linear-gradient(135deg, var(--gold2), var(--gold3)); transition: left .45s var(--ease), width .45s var(--ease); box-shadow: 0 4px 14px rgba(232,192,96,.4); }
.custom-range { display: flex; gap: 8px; align-items: center; overflow: hidden; max-width: 0; opacity: 0; transition: max-width .5s var(--ease), opacity .4s; }
.custom-range.show { max-width: 460px; opacity: 1; }
.custom-range input { width: 150px; }
.chart-box { position: relative; height: 300px; }
.chart-box.tall { height: 360px; }
.kpi-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(135px,1fr)); gap: 14px; }
.legend-note { font-size: 12px; color: var(--muted); }

/* ---------------- RECEIPT ---------------- */
.receipt {
  --ink: #3b2408; color: var(--ink); background: #fbf3df;
  background-image: radial-gradient(circle at 20% 10%, rgba(255,255,255,.7), transparent 40%), radial-gradient(circle at 90% 90%, rgba(196,150,70,.18), transparent 45%);
  border-radius: 6px; padding: 34px 40px; position: relative; font-family: Inter; overflow: hidden;
  box-shadow: inset 0 0 0 10px #fbf3df, inset 0 0 0 12px #b8862b, inset 0 0 0 16px #fbf3df, inset 0 0 0 17px #b8862b;
}
.receipt .wm { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; opacity: .06; }
.receipt .wm svg { width: 70%; fill: #7c1d2e; }
.receipt .r-head { text-align: center; border-bottom: 2px double #b8862b; padding-bottom: 14px; margin-bottom: 18px; }
.receipt .r-head svg { width: 46px; fill: #b8862b; }
.receipt .r-bname { font-family: 'Cinzel Decorative'; font-size: 28px; color: #7c1d2e; }
.receipt .r-tag { font-family: Cinzel; font-size: 11px; letter-spacing: .35em; text-transform: uppercase; color: #8a6420; }
.receipt .r-addr { font-size: 12px; margin-top: 4px; }
.receipt .r-title { display: inline-block; margin-top: 12px; padding: 5px 22px; background: #7c1d2e; color: #f7dc8f; font-family: Cinzel; letter-spacing: .25em; font-size: 13px; border-radius: 3px; }
.receipt .r-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 30px; margin-bottom: 18px; font-size: 13.5px; }
.receipt .r-meta small { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: #8a6420; }
.receipt .r-meta b { font-size: 15px; }
.receipt table { margin: 6px 0 12px; }
.receipt th { color: #8a6420; border-bottom: 1.5px solid #b8862b; }
.receipt td { border-bottom: 1px dotted rgba(184,134,43,.5); color: var(--ink); }
.receipt tr.total td { border-top: 2px solid #b8862b; border-bottom: 2px double #b8862b; font-weight: 800; font-size: 17px; color: #7c1d2e; }
.receipt .words { font-style: italic; font-size: 13px; }
.receipt .r-foot { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 26px; gap: 20px; }
.receipt .sign { text-align: center; }
.receipt .sign .sig { font-family: 'Great Vibes'; font-size: 30px; color: #7c1d2e; }
.receipt .sign small { display: block; border-top: 1px solid #8a6420; padding-top: 4px; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; }
.receipt .note { font-size: 12px; max-width: 60%; }
.stamp { position: absolute; right: 50px; top: 150px; transform: rotate(-16deg); border: 4px double; border-radius: 10px; padding: 6px 16px; font-family: Cinzel; font-weight: 700; font-size: 26px; letter-spacing: .2em; opacity: .85; animation: stampIn .6s .2s cubic-bezier(.3,1.6,.5,1) both; }
.stamp.paid { color: #1d7a55; border-color: #1d7a55; }
.stamp.pending { color: #b0283f; border-color: #b0283f; }
.stamp.partial { color: #b8661b; border-color: #b8661b; }
@keyframes stampIn { from { transform: rotate(-16deg) scale(3); opacity: 0; } }

/* ---------------- RESPONSIVE ---------------- */
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 900px) {
  #vault { grid-template-columns: 1fr; justify-items: center; padding: 30px 16px; gap: 24px; }
  .vault-frame { width: min(300px, 70vw); }
  #app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; width: 260px; transform: translateX(-100%); transition: transform .4s var(--ease); }
  .sidebar.open { transform: none; box-shadow: 20px 0 60px rgba(0,0,0,.6); }
  .menu { display: inline-block; }
  .view { padding: 18px 16px 50px; }
  .topbar { padding: 12px 16px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .hero { flex-direction: column; text-align: center; }
  .receipt { padding: 24px 20px; } .receipt .r-meta { grid-template-columns: 1fr; } .stamp { right: 18px; top: 215px; font-size: 18px; }
}

/* ---------------- PRINT (receipt only) ---------------- */
@media print {
  body { background: #fff !important; }
  body > *:not(#modalRoot), #dust { display: none !important; }
  .modal-bg { position: static; background: none; backdrop-filter: none; padding: 0; animation: none; opacity: 1; display: block; }
  .modal { box-shadow: none; border: 0; max-height: none; background: #fff; width: 100%; animation: none; }
  .modal-head, .modal-foot { display: none !important; }
  .modal-body { padding: 0; }
  .receipt { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .stamp { animation: none; }
  .no-seal .stamp { display: none !important; }
}

/* =====================================================================
   MOBILE & TABLET (iPhone Safari / Android Chrome)
   ===================================================================== */
html { -webkit-text-size-adjust: 100%; }
body { -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; }
#vault, #app { min-height: 100vh; min-height: 100dvh; }
.sidebar { height: 100vh; height: 100dvh; }
.bottom-nav, .scrim { display: none; }
button, a, .palace, nav a { touch-action: manipulation; }
@media (hover: none) {
  .palace:hover { transform: none; }
  .palace:active { transform: scale(.98); }
  .btn:hover { transform: none; box-shadow: none; }
  .btn:active { transform: scale(.96); }
  nav a:hover { transform: none; }
}

/* Tablet: collapse the sidebar to an icon rail */
@media (min-width: 901px) and (max-width: 1180px) {
  #app { grid-template-columns: 78px 1fr; }
  .sidebar { padding: 18px 10px; }
  .brand > div, nav a .lbl, .me .who, .me .btn { display: none; }
  .brand { justify-content: center; padding: 4px 0 18px; }
  nav a { justify-content: center; padding: 13px 0; }
  nav a .ico { font-size: 20px; }
  .me { justify-content: center; }
  .palaces { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
}

@media (max-width: 900px) {
  /* inputs at 16px stop iOS Safari from zooming on focus */
  input, select, textarea { font-size: 16px; padding: 12px 13px; }
  .btn { padding: 11px 16px; min-height: 42px; }
  .btn.sm { min-height: 36px; padding: 8px 12px; }

  .topbar { padding: calc(10px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) 10px calc(16px + env(safe-area-inset-left)); }
  .topbar h2 { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .top-actions .btn .lbl { display: none; }
  .view { padding: 16px calc(16px + env(safe-area-inset-right)) calc(96px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left)); }
  .sidebar { padding-top: calc(22px + env(safe-area-inset-top)); padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 15; opacity: 0; pointer-events: none; transition: opacity .3s; }
  .scrim.show { opacity: 1; pointer-events: auto; }

  .bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 12;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: rgba(18,12,34,.92);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line); }
  .bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; color: var(--muted); text-decoration: none; font-size: 10.5px; border-radius: 12px; transition: color .3s; position: relative; }
  .bottom-nav a .ico { font-size: 20px; transition: transform .35s var(--ease); }
  .bottom-nav a.active { color: var(--gold2); }
  .bottom-nav a.active .ico { transform: translateY(-3px) scale(1.15); filter: drop-shadow(0 0 8px rgba(247,220,143,.7)); }
  .bottom-nav a.active::after { content: ''; position: absolute; top: 0; width: 26px; height: 3px; border-radius: 3px; background: var(--gold); }

  #toasts { left: 16px; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); }
  .toast { max-width: none; }

  /* Bottom-sheet modals */
  .modal-bg { place-items: end center; padding: 0; }
  .modal { width: 100%; max-height: 92dvh; border-radius: 22px 22px 0 0; animation: sheetIn .45s var(--ease) both; }
  .modal.wide { width: 100%; }
  .modal::before { content: ''; display: block; width: 44px; height: 5px; border-radius: 5px; background: rgba(255,255,255,.25); margin: 8px auto 0; }
  .modal-foot { padding-bottom: calc(16px + env(safe-area-inset-bottom)); position: sticky; bottom: 0; background: #170f2b; }
  .modal-foot .btn { flex: 1 1 42%; justify-content: center; }
  @keyframes sheetIn { from { transform: translateY(100%); } }

  /* Tables become stacked cards */
  table.resp thead { display: none; }
  table.resp, table.resp tbody, table.resp tr, table.resp td { display: block; width: 100%; }
  table.resp tr { border: 1px solid var(--line); border-radius: 14px; margin-bottom: 12px; padding: 8px 12px; background: rgba(0,0,0,.18); }
  table.resp td { display: flex; justify-content: space-between; align-items: center; gap: 12px; border: 0; padding: 7px 0; text-align: right; }
  table.resp td::before { content: attr(data-l); color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; text-align: left; flex: none; }
  table.resp td.num { text-align: right; }
  table.resp td.full { display: block; text-align: left; }
  table.resp td.full::before { display: block; margin-bottom: 4px; }
  table.resp .row-actions { justify-content: flex-start; width: 100%; }
  table.resp td:has(.row-actions)::before { display: none; }
  .meter input { width: 100%; }

  .range-bar { flex-direction: column; align-items: stretch; }
  .seg { width: 100%; }
  .seg button { flex: 1; padding: 9px 4px; }
  .custom-range.show { max-width: 100%; flex-wrap: wrap; }
  .custom-range input { flex: 1; width: auto; min-width: 130px; }
  .chart-box { height: 240px; } .chart-box.tall { height: 280px; }
  .stat .val { font-size: 22px; }
  .card { padding: 16px; border-radius: 16px; }
  .vf-title { font-size: 32px; }
  .vault-form { padding: 28px 22px; }
  .avatar.xl { width: 96px; height: 96px; font-size: 32px; }
  .receipt .r-bname { font-size: 22px; }
  .receipt .note { max-width: 100%; }
  .receipt .r-foot { flex-direction: column; align-items: stretch; }
}
@media (max-width: 420px) {
  .g4.stats { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
  .stat .emoji { display: none; }
  .palaces { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
