:root{
  --bg: #0e0f12;
  --display-fg: #f3f4f6;
  --key-fn-bg: #2b2d33;
  --key-fn-fg: #f3f4f6;
  --key-num-bg: #1c1e23;
  --key-num-fg: #f3f4f6;
  --key-op-bg: #3be0a9;
  --key-op-fg: #0e0f12;
  --key-op-active-bg: #163228;
  --key-op-active-fg: #3be0a9;
  --divider: rgba(255,255,255,0.08);
  --panel-bg: #15171c;
  --panel-fg: #f3f4f6;
  --muted: #9196a1;
  --input-bg: #1c1e23;
  --danger: #e5534b;
  --accent: #3be0a9;
  color-scheme: dark;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
*{ box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
html,body{ height:100%; margin:0; }
body{ background:var(--bg); color:var(--panel-fg); font-family:var(--font); overflow:hidden; }

/* ---------- calculator ---------- */
#calc{ height:100%; display:flex; flex-direction:column; justify-content:flex-end; gap:14px; padding:16px; user-select:none; }
#display-wrap{ flex:1; display:flex; align-items:flex-end; justify-content:flex-end; padding:0 10px 8px; min-height:0; }
#display{ font-weight:300; font-size:clamp(40px,12vw,76px); color:var(--display-fg); line-height:1; max-width:100%; overflow:hidden; white-space:nowrap; direction:rtl; }
#keys{ display:grid; grid-template-columns:repeat(4,1fr); gap:10px; }
button.key{ border:none; border-radius:999px; font-size:clamp(20px,6vw,28px); padding:0; aspect-ratio:1/1; width:100%; display:flex; align-items:center; justify-content:center; cursor:pointer; }
button.key:active{ filter:brightness(0.85); }
.key.num{ background:var(--key-num-bg); color:var(--key-num-fg); }
.key.fn{ background:var(--key-fn-bg); color:var(--key-fn-fg); font-size:clamp(18px,5vw,24px); }
.key.op{ background:var(--key-op-bg); color:var(--key-op-fg); }
.key.op.active{ background:var(--key-op-active-bg); color:var(--key-op-active-fg); }
.key.zero{ aspect-ratio:auto; grid-column:span 2; justify-content:flex-start; padding-left:28px; border-radius:40px; }

/* ---------- generic sheet / modal ---------- */
.sheet{ position:fixed; inset:0; background:rgba(0,0,0,0.45); display:flex; align-items:flex-end; z-index:30; }
.sheet.hidden{ display:none !important; }
.sheet-card{ background:var(--panel-bg); width:100%; border-radius:18px 18px 0 0; padding:16px 18px 22px; max-height:85vh; overflow-y:auto; }
.sheet-card.tall{ max-height:90vh; }
.sheet-head{ display:flex; align-items:center; justify-content:space-between; font-weight:600; font-size:15px; padding:2px 2px 10px; }
.icon-btn{ background:none; border:none; color:var(--muted); font-size:18px; cursor:pointer; padding:6px 8px; }
.hint{ color:var(--muted); font-size:13px; line-height:1.4; }
.error{ color:var(--danger); font-size:13px; min-height:16px; }
input[type="text"],input[type="password"]{ width:100%; border:1px solid var(--divider); border-radius:10px; padding:10px 12px; font-size:14px; background:var(--input-bg); color:var(--panel-fg); font-family:var(--font); margin:6px 0; }
.pill-btn{ border:none; border-radius:999px; padding:10px 20px; font-size:14px; font-weight:600; background:var(--accent); color:#0e0f12; cursor:pointer; }
.pill-btn.secondary{ background:var(--key-fn-bg); color:var(--key-fn-fg); }
.ghost-btn{ border:1px solid var(--divider); background:none; color:var(--panel-fg); border-radius:999px; padding:8px 16px; font-size:13px; cursor:pointer; }
.ghost-btn.danger, .pill-btn.danger{ color:#fff; background:var(--danger); border-color:var(--danger); }

/* ---------- dashboard ---------- */
#dashboard{ position:fixed; inset:0; background:var(--bg); z-index:20; display:flex; flex-direction:column; }
#dashboard.hidden{ display:none !important; }
#dash-header{ display:flex; align-items:center; justify-content:space-between; padding:16px 18px; border-bottom:1px solid var(--divider); }
#dash-header h1{ font-size:18px; margin:0; }
#dash-tabs{ display:flex; gap:6px; padding:10px 14px; border-bottom:1px solid var(--divider); }
.tab{ background:none; border:none; color:var(--muted); font-size:14px; padding:8px 14px; border-radius:999px; cursor:pointer; }
.tab.active{ background:var(--key-fn-bg); color:var(--panel-fg); }
#dash-body{ flex:1; overflow-y:auto; padding:16px; }
.tab-pane{ display:none; }
.tab-pane.active{ display:block; }

.card{ background:var(--panel-bg); border:1px solid var(--divider); border-radius:14px; padding:14px 16px; margin-bottom:12px; }
.card-row{ display:flex; align-items:center; justify-content:space-between; gap:12px; }
.muted{ color:var(--muted); font-size:13px; margin-top:2px; }

.user-row{ background:var(--panel-bg); border:1px solid var(--divider); border-radius:14px; padding:12px 14px; margin-bottom:10px; }
.user-row .top{ display:flex; align-items:center; justify-content:space-between; gap:8px; }
.user-row .name{ font-weight:600; }
.badge{ font-size:11px; padding:3px 9px; border-radius:999px; font-weight:600; }
.badge.active{ background:#163228; color:var(--accent); }
.badge.pending{ background:#2b2d33; color:var(--muted); }
.badge.blocked{ background:#3a1f1f; color:var(--danger); }
.badge.recovering{ background:#2b2a16; color:#e0c93b; }
.user-row .actions{ display:flex; flex-wrap:wrap; align-items:center; gap:6px; margin-top:10px; }
.user-row .actions button{ font-size:12px; padding:6px 12px; }
.combo-toggle{ display:flex; align-items:center; gap:6px; font-size:12px; color:var(--panel-fg); padding:6px 10px; }
.combo-toggle input{ width:16px; height:16px; }

.link-row{ display:flex; gap:8px; align-items:center; }
#inviteQr{ display:block; margin:14px auto 0; background:#fff; border-radius:10px; padding:10px; }

#userDetailBody .thread-msg{ padding:8px 0; border-bottom:1px solid var(--divider); font-size:14px; }
#userDetailBody .thread-msg .who{ font-size:11px; color:var(--muted); display:block; margin-bottom:2px; }

@media (min-width:640px){
  body{ display:flex; align-items:center; justify-content:center; }
  #calc{ width:420px; height:780px; max-height:92vh; border-radius:28px; box-shadow:0 20px 60px rgba(0,0,0,0.4); }
  #dashboard{ width:720px; height:820px; max-height:92vh; left:50%; top:50%; inset:auto; transform:translate(-50%,-50%); border-radius:20px; box-shadow:0 20px 60px rgba(0,0,0,0.4); overflow:hidden; }
}
