:root {
  --bg: #090c10;
  --surface: #121821;
  --surface-2: #1a222e;
  --border: #263142;
  --text: #eef3f8;
  --muted: #8a9bb0;
  --accent: #00d084;
  --accent-dark: #00a86b;
  --danger: #ff4757;
  --warn: #ffa502;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh; overscroll-behavior: none;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

.container { max-width: 480px; margin: 0 auto; padding: 20px 16px 40px; }
.app-shell {
  max-width: 480px; margin: 0 auto; min-height: 100dvh;
  display: flex; flex-direction: column; padding-bottom: 72px;
}

.brand-header { text-align: center; margin-bottom: 18px; }
.brand-row { display: inline-flex; align-items: center; gap: 10px; }
.brand-header h1 { margin: 0; font-size: 1.9rem; letter-spacing: 3px; }
.subtitle { margin: 6px 0 0; color: var(--muted); font-size: 0.9rem; }

.led { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.led-green { background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.led-amber { background: var(--warn); box-shadow: 0 0 10px var(--warn); }
.led-red { background: var(--danger); box-shadow: 0 0 10px var(--danger); }

.badge {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--accent);
  font-size: 0.72rem; font-weight: 700; padding: 3px 8px; border-radius: 99px; letter-spacing: 1px;
}

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; margin-bottom: 14px;
}
.card-subtle { background: transparent; border-style: dashed; }
.card h2, .card h3 { margin-top: 0; }

.banner {
  border-radius: 10px; padding: 11px 14px; font-size: 0.86rem; line-height: 1.4; margin-bottom: 12px;
}
.banner-info { background: #132235; border: 1px solid #24456b; color: #c7e0ff; }
.banner-accent { background: #0c2b21; border: 1px solid #155c42; color: #b9ffe3; }
.banner-warn { background: #2c200d; border: 1px solid #6b4913; color: #ffe0a3; }

.plans-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.plan-card {
  background: var(--surface-2); border: 2px solid var(--border); border-radius: 12px;
  padding: 12px; text-align: left; cursor: pointer; color: var(--text); transition: 0.15s;
}
.plan-card.selected { border-color: var(--accent); background: #0e241d; }
.plan-card.disabled { opacity: 0.42; cursor: not-allowed; }
.plan-title { font-weight: 700; font-size: 1rem; }
.plan-price { color: var(--accent); font-weight: 700; font-size: 0.92rem; margin-top: 4px; }
.plan-note { color: var(--muted); font-size: 0.75rem; margin-top: 2px; }

.field-group { margin-bottom: 12px; }
.field-group label { display: block; font-size: 0.82rem; color: var(--muted); margin-bottom: 5px; }
input[type="text"], input[type="password"], .mono-input {
  width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 11px 12px; font-size: 1rem; outline: none;
}
input:focus { border-color: var(--accent); }
.mono-input { font-family: monospace; font-size: 0.85rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; width: 100%;
  border: none; border-radius: 12px; padding: 12px 16px; font-weight: 700; font-size: 0.95rem;
  cursor: pointer; text-decoration: none; transition: transform 0.08s, opacity 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-lg { padding: 15px 18px; font-size: 1.05rem; }
.btn-sm { padding: 8px 12px; font-size: 0.82rem; width: auto; }
.btn-primary { background: var(--accent); color: #05140d; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-call { background: var(--accent); color: #04190f; letter-spacing: 1px; margin-top: 10px; }
.btn-link { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 0.9rem; padding: 0; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.stack-actions { display: flex; flex-direction: column; gap: 8px; }
.file-label { cursor: pointer; }

.cred-box { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.cred-label { font-size: 0.72rem; color: var(--muted); letter-spacing: 1px; display: block; }
.cred-number { font-size: 1.7rem; font-weight: 800; letter-spacing: 2px; color: var(--accent); margin-top: 4px; }
.cred-token { display: block; word-break: break-all; font-size: 0.85rem; margin: 6px 0 10px; color: #fff; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.my-number { font-size: 1.08rem; font-weight: 800; letter-spacing: 1px; }
.my-meta { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.pill { font-size: 0.72rem; color: var(--muted); }
.pill-btn {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--accent);
  font-size: 0.72rem; font-weight: 700; padding: 4px 9px; border-radius: 6px; cursor: pointer;
}
.pill-btn.recording { background: var(--danger); color: #fff; border-color: var(--danger); }
.topbar-right { display: flex; gap: 6px; }
.icon-pill {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 7px 10px; font-size: 0.76rem; font-weight: 700; cursor: pointer;
}
.icon-pill.active { background: var(--danger); border-color: var(--danger); color: #fff; }
.icon-pill-accent { border-color: #195f44; color: var(--accent); }

.tab-panel { padding: 14px 16px; flex: 1; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.panel-head h2 { margin: 0; }

.dial-display-wrap {
  position: relative;
  display: flex; align-items: center; background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px; padding: 8px 10px; margin-bottom: 14px;
}
.dial-input {
  border: none !important; background: transparent !important; font-size: 1.65rem !important;
  font-weight: 700; letter-spacing: 2px; text-align: center; padding: 6px 48px !important;
}
#dial-clear { position: absolute; right: 10px; }
#btn-toggle-abc { position: absolute; left: 10px; }

.dial-mini-btn {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
  border-radius: 8px; padding: 8px 10px; font-weight: 700; cursor: pointer;
}

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 10px; }
.key {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: 14px; padding: 13px 6px; font-size: 1.45rem; font-weight: 700;
  cursor: pointer; display: flex; flex-direction: column; align-items: center; line-height: 1.1;
}
.key span { font-size: 0.62rem; color: var(--muted); letter-spacing: 1px; margin-top: 2px; }
.key:active { background: var(--surface-2); border-color: var(--accent); }
.key-fn { font-size: 0.85rem; justify-content: center; color: var(--muted); }

.list-stack { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.list-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px; display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.list-title { font-weight: 700; font-size: 0.98rem; }
.list-sub { color: var(--muted); font-size: 0.8rem; margin-top: 2px; }
.list-actions { display: flex; gap: 6px; }

.kv-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; font-size: 0.92rem; }

.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; background: var(--surface); border-top: 1px solid var(--border);
  display: grid; grid-template-columns: repeat(4, 1fr); z-index: 15;
}
.nav-btn {
  background: none; border: none; color: var(--muted); padding: 15px 6px;
  font-size: 0.76rem; font-weight: 700; letter-spacing: 0.6px; cursor: pointer;
}
.nav-btn.active { color: var(--accent); border-top: 2px solid var(--accent); }
.nav-badge {
  display: inline-block; background: var(--danger); color: #fff;
  font-size: 0.68rem; font-weight: 800; padding: 1px 6px; border-radius: 99px;
  margin-left: 4px; vertical-align: middle;
}
.missed-label { color: var(--danger); font-weight: 700; }

.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.8); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50;
}
.modal-card {
  position: relative; width: 100%; max-width: 390px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 18px; padding: 22px 18px;
}
.ln-card { text-align: center; }
.modal-close {
  position: absolute; top: 12px; right: 14px; background: var(--surface-2);
  border: 1px solid var(--border); color: var(--text); width: 34px; height: 34px;
  border-radius: 50%; font-size: 1.3rem; line-height: 1; cursor: pointer;
}
.ln-amount { font-size: 1.35rem; font-weight: 800; color: var(--accent); margin: 4px 0 12px; }
.qr-box {
  background: #ffffff; padding: 12px; border-radius: 12px; display: inline-flex;
  justify-content: center; align-items: center; margin: 6px auto 16px; min-width: 210px; min-height: 210px;
}
.qr-box svg { width: 200px; height: 200px; display: block; }
.ln-status { margin-top: 12px; font-size: 0.85rem; color: var(--muted); }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 0.88rem; cursor: pointer; }

.call-overlay {
  position: fixed; inset: 0; background: radial-gradient(circle at top, #13212c, #07090d);
  z-index: 80; display: flex; flex-direction: column; justify-content: space-between;
  padding: 28px 20px 28px; text-align: center;
}
.call-badge { font-size: 0.78rem; letter-spacing: 1.5px; color: var(--accent); font-weight: 700; }
.call-top h2 { margin: 10px 0 4px; font-size: 1.8rem; }
.call-sub { color: var(--muted); font-size: 1rem; letter-spacing: 1px; }
.call-timer { margin-top: 10px; font-family: monospace; font-size: 1.25rem; color: var(--text); }
.call-debug { margin-top: 6px; font-family: monospace; font-size: 0.72rem; color: var(--muted); }

.incoming-actions { display: flex; justify-content: space-around; padding-bottom: 24px; }
.btn-circle {
  width: 112px; height: 112px; border-radius: 50%; border: none; font-weight: 800;
  font-size: 0.95rem; color: #fff; cursor: pointer; box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.btn-circle-green { background: var(--accent); color: #05190f; }
.btn-circle-red { background: var(--danger); }

.video-stage {
  position: relative; width: 100%; max-width: 520px; height: 42dvh; max-height: 460px;
  margin: 10px auto; border-radius: 16px; overflow: hidden; background: #000; border: 1px solid var(--border);
}
#remote-video { width: 100%; height: 100%; object-fit: cover; }
#local-video {
  position: absolute; bottom: 10px; right: 10px; width: 96px; height: 132px;
  object-fit: cover; border-radius: 10px; border: 2px solid var(--accent); background: #111;
}

.call-controls {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px;
  max-width: 440px; width: 100%; margin: 0 auto 12px;
}
.ctrl-btn {
  position: relative; flex: 1 1 72px; max-width: 100px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 12px; padding: 13px 4px; font-size: 0.74rem; font-weight: 700; cursor: pointer;
}
.ctrl-btn.active { background: var(--accent); color: #04190f; border-color: var(--accent); }
.call-hangup { max-width: 420px; margin: 0 auto; }

.chat-dot {
  position: absolute; top: 6px; right: 6px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--danger);
}

/* EPHEMERAL CHAT DRAWER & RESCUE MODAL */
.chat-drawer {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 14px;
  width: calc(100% - 24px); max-width: 440px; max-height: 76dvh;
  background: rgba(18, 24, 33, 0.97); border: 1px solid var(--accent);
  border-radius: 16px; padding: 12px; z-index: 95;
  display: flex; flex-direction: column; text-align: left;
  box-shadow: 0 12px 40px rgba(0,0,0,0.75);
}
.chat-rescue-card { max-width: 440px; max-height: 82dvh; display: flex; flex-direction: column; text-align: left; }
.chat-head { display: flex; justify-content: space-between; align-items: center; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.chat-ttl-pill { font-size: 0.74rem; color: var(--warn); margin-top: 2px; }
.chat-messages {
  flex: 1; min-height: 140px; max-height: 44dvh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px; padding: 10px 2px;
}
.chat-bubble {
  max-width: 86%; padding: 9px 11px; border-radius: 12px; font-size: 0.9rem;
  background: var(--surface-2); border: 1px solid var(--border); align-self: flex-start;
  word-break: break-word;
}
.chat-bubble.me { align-self: flex-end; background: #0d2b21; border-color: #165e44; }
.chat-meta { display: flex; justify-content: space-between; gap: 10px; font-size: 0.68rem; color: var(--muted); margin-top: 4px; }
.chat-media-img { max-width: 100%; max-height: 200px; border-radius: 8px; display: block; margin-top: 4px; }
.chat-attach-bar { display: flex; gap: 6px; flex-wrap: wrap; padding: 6px 0; }
.chat-input-row { display: flex; gap: 6px; align-items: center; }
.chat-input-row input { padding: 9px 10px; font-size: 0.92rem; }
.sketch-box { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 8px; margin: 6px 0; text-align: center; }
#sketch-canvas { background: #10161e; border: 1px dashed var(--border); border-radius: 8px; touch-action: none; max-width: 100%; }

.ear-lock-shield {
  position: fixed; inset: 0; background: rgba(0,0,0,0.94); z-index: 99;
  display: flex; align-items: center; justify-content: center;
}
.ear-lock-msg { text-align: center; color: #6c7a89; display: flex; flex-direction: column; gap: 8px; }

.toast {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--accent); color: var(--text);
  padding: 10px 16px; border-radius: 10px; font-size: 0.88rem; font-weight: 600; z-index: 120;
}
.banner a,
.banner a:link,
.banner a:visited,
.banner a:hover,
.banner a:active {
  color: #00d084 !important;
  font-weight: 700;
  text-decoration: underline;
}
.cam-flip-btn {
  position: absolute; top: 10px; right: 10px; z-index: 20;
  transform: translateZ(0);
  background: rgba(9, 12, 16, 0.88); border: 1px solid var(--accent); color: var(--text);
  border-radius: 99px; padding: 7px 12px; font-size: 0.72rem; font-weight: 800;
  letter-spacing: 0.6px; cursor: pointer;
}
.cam-flip-btn:active { background: var(--accent); color: #05140d; }