@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Instrument+Sans:wght@400;500;600;700&display=swap");

:root {
  color-scheme: dark;
  --background: #101416;
  --surface: #181e21;
  --control: #222b2e;
  --border: #303b3f;
  --text: #edf4f1;
  --muted: #a8b8b4;
  --accent: #7ce3ae;
  font-family: "DM Sans", system-ui, sans-serif;
  color: var(--text);
  background: var(--background);
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input { font: inherit; }
button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 10px 15px;
  background: var(--accent);
  color: #10241a;
  font-weight: 700;
  cursor: pointer;
  transition: filter .18s, transform .18s, background-color .18s;
}
button:hover { filter: brightness(1.1); }
button:active { transform: scale(.97); }
button:disabled { opacity: .55; cursor: wait; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
svg { display: inline-block; width: 22px; height: 22px; vertical-align: middle; flex: none; }
.secondary { background: var(--control); color: var(--text); }
.outline { background: transparent; color: var(--muted); border-color: var(--border); }
.hidden { display: none !important; }
.muted, .note { color: var(--muted); }
h1, h2 { font-family: "Instrument Sans", system-ui, sans-serif; margin: 0; line-height: 1.15; }
p { line-height: 1.5; }
h1 { font-size: clamp(1.85rem, 4vw, 2.65rem); letter-spacing: -.045em; }
h2 { font-size: 1.18rem; letter-spacing: -.025em; }

.layout { width: min(100%, 1240px); margin-inline: auto; padding: 0 34px 48px; }
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 76px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 40px;
}
.logo { display: flex; align-items: center; gap: 10px; font-family: "Instrument Sans", sans-serif; font-weight: 700; font-size: 1.15rem; }
.logo-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: #244136; color: var(--accent); }
.green { color: var(--accent); }
.card { min-width: 0; padding: 24px; border-radius: 20px; border: 1px solid var(--border); background: var(--surface); }
.card h2 { display: flex; align-items: center; gap: 9px; margin-bottom: 18px; }
.card h2 svg { color: var(--accent); width: 19px; height: 19px; }
.login-card { max-width: 440px; margin: clamp(20px, 9vh, 90px) auto 0; padding: clamp(22px, 5vw, 34px); }
.login-card h1 { font-size: 2rem; }
.login-card .form { margin-top: 24px; }
.form { display: grid; gap: 16px; }
label { display: grid; gap: 7px; min-width: 0; font-size: .875rem; font-weight: 600; }
input { width: 100%; min-width: 0; min-height: 44px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--background); color: var(--text); }
input::placeholder { color: #91a19d; }
input[type="file"] { font-size: .78rem; padding: 7px; }
input::file-selector-button { font: inherit; color: var(--text); background: var(--control); border: 0; border-radius: 7px; padding: 7px 9px; margin-right: 7px; cursor: pointer; }
.error { color: #ffacb6; overflow-wrap: anywhere; font-size: .875rem; }
.error:empty { display: none; }
.note { font-size: .84rem; margin: 0; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 24px 0; border: 1px solid var(--border); border-radius: 17px; background: var(--surface); }
.stat { display: grid; gap: 5px; padding: 18px 22px; }
.stat + .stat { border-inline-start: 1px solid var(--border); }
.stat strong { display: flex; align-items: center; min-height: 32px; font: 600 1.55rem "Instrument Sans", sans-serif; }
.stat strong svg { color: var(--accent); }
.stat span { color: var(--muted); font-size: .81rem; }
.dashboard-grid { display: grid; grid-template-columns: minmax(280px, .85fr) minmax(0, 1.5fr); align-items: start; gap: 20px; }
.table-wrap { overflow-x: auto; margin-top: 14px; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th, td { text-align: left; padding: 11px 7px; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
th { color: var(--muted); font-size: .78rem; font-weight: 600; }
td:first-child { font-weight: 700; min-width: 76px; }
td button { min-height: 36px; margin: 2px; padding: 6px 9px; font-size: .78rem; }
.actions { min-width: 82px; }
.status-pill { display: inline-block; border-radius: 999px; padding: 4px 8px; background: #223b31; color: #a3ebc1; white-space: nowrap; font-size: .75rem; }
.status-pill.expired { background: #3c2c30; color: #ffc0c8; }
.link-result { margin-top: 16px; padding: 14px; border-radius: 12px; border: 1px solid #426352; background: #1e3329; overflow-wrap: anywhere; }
.link-result p { font-size: .85rem; }

.call-page { min-height: 100dvh; display: grid; place-items: center; background: #101614; color: #fff; font-family: system-ui, sans-serif; }
.phone { width: min(100%, 480px); height: min(880px, 100dvh); position: relative; isolation: isolate; overflow: hidden; background: #0b141a; }
.incoming, .end-screen {
  height: 100%;
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: max(18px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  background: #0b141a;
}
.incoming-top { width: 100%; margin-block: auto; padding-block: clamp(12px, 4dvh, 36px); }
.avatar { position: relative; overflow: hidden; display: grid; place-items: center; width: clamp(72px, 18dvh, 136px); aspect-ratio: 1; border-radius: 50%; margin: 0 auto clamp(12px, 2.5dvh, 22px); background: #233b37; color: #a8d5c3; }
.incoming .avatar svg { width: 43%; height: 43%; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.call-name, .video-top h1 { overflow-wrap: anywhere; }
.call-name { font: 650 clamp(1.55rem, 6vw, 2.1rem)/1.15 system-ui, sans-serif; letter-spacing: -.035em; }
.incoming-label { margin: 7px 0 0; color: #c8d1d5; font-size: .9rem; }
.call-actions { display: flex; justify-content: center; gap: clamp(70px, 25vw, 110px); }
.call-action { display: grid; justify-items: center; gap: 9px; background: transparent; color: white; border: 0; padding: 0; font-weight: 600; font-size: .875rem; }
.round { width: 50px; height: 50px; min-height: 0; border: 0; border-radius: 50%; display: grid; place-items: center; padding: 0; background: #3b4142; color: #fff; }
.round svg { width: 24px; height: 24px; }
.call-action .round { width: 64px; height: 64px; }
.call-action .round svg { width: 28px; height: 28px; }
.answer { background: #25d366; color: #062513; }
.danger { background: #e92743; color: #fff; }

.video-screen { position: absolute; inset: 0; background: #101416; animation: appear .24s ease-out; }
#remote-video { width: 100%; height: 100%; display: block; object-fit: cover; }
.video-top { position: absolute; inset: 0 0 auto; display: grid; justify-items: center; gap: 5px; padding: max(16px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 26px max(14px, env(safe-area-inset-left)); text-align: center; background: linear-gradient(#000d, #0008 70%, transparent); pointer-events: none; }
.video-top h1 { margin-top: 5px; font: 650 1.09rem/1.2 system-ui, sans-serif; letter-spacing: 0; }
.video-top #elapsed { margin: 0; font-size: .82rem; font-variant-numeric: tabular-nums; }
.video-bottom { position: absolute; bottom: max(18px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); display: flex; justify-content: space-evenly; width: min(calc(100% - 28px), 350px); gap: 8px; padding: 11px 12px; border-radius: 38px; background: #182126f2; }
.audio-off { color: #d4dcda; background: #313739; }
#camera-button[aria-pressed="true"] { background: #d9f4e5; color: #153126; }
.self-camera { position: absolute; right: max(14px, env(safe-area-inset-right)); bottom: calc(max(18px, env(safe-area-inset-bottom)) + 84px); width: clamp(76px, 26%, 126px); height: clamp(72px, 23dvh, 168px); overflow: hidden; border: 1px solid #ffffff6b; border-radius: 15px; background: #16211d; box-shadow: 0 6px 26px #0007; animation: appear .2s ease-out; }
.self-camera video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.self-camera span { position: absolute; inset: auto 0 0; padding: 6px 3px; background: #101917dc; text-align: center; font-size: .65rem; }
.playback { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); white-space: nowrap; }
.playback:active { transform: translate(-50%, -50%) scale(.97); }
.end-content { margin: auto; width: min(100%, 330px); padding-block: 16px; }
.end-icon { display: grid; place-items: center; width: 58px; height: 58px; border-radius: 50%; background: #344c42; margin: 0 auto 16px; }
.end-content h1 { font-size: 1.65rem; }
.end-content p { color: #ccd9d2; }
#toast { position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translate(-50%, 8px); opacity: 0; pointer-events: none; width: max-content; max-width: min(90%, 440px); border: 1px solid var(--border); border-radius: 12px; padding: 11px 15px; background: #263630; color: #fff; font-size: .85rem; z-index: 2; transition: opacity .2s, transform .2s; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.call-page ~ #toast { bottom: 100px; }
body:has(.video-screen) #toast { bottom: calc(max(18px, env(safe-area-inset-bottom)) + 80px); }
@keyframes appear { from { opacity: 0; } to { opacity: 1; } }

@media (min-width: 601px) and (min-height: 600px) {
  .phone { height: min(880px, calc(100dvh - 40px)); border-radius: 26px; box-shadow: 0 20px 60px #0006; }
}
@media (max-width: 820px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .layout { padding-inline: 16px; }
  .header { min-height: 64px; margin-bottom: 28px; }
  .card { padding: 17px; }
  .stat { padding: 13px 9px; }
  .phone { width: 100%; height: 100dvh; }
}
@media (max-width: 360px) {
  .video-bottom .round { width: 45px; height: 45px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.whatsapp-return {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin-top: 20px;
  padding: 10px 16px;
  border-radius: 11px;
  background: #25d366;
  color: #082514;
  font-size: .9rem;
  font-weight: 700;
  text-decoration: none;
  transition: filter .18s, transform .18s;
}
.whatsapp-return:hover { filter: brightness(1.08); }
.whatsapp-return:active { transform: scale(.97); }

/* Public call themes */
.call-action { position: relative; text-decoration: none; }
.swipe-hint { display: none; }

[data-call-theme="android"] .incoming {
  position: relative;
  isolation: isolate;
  background: #0b141a;
}
[data-call-theme="android"] .incoming::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: url("./call-wallpaper.png") top center / 400px auto repeat;
  opacity: .07;
  pointer-events: none;
}
[data-call-theme="android"] .incoming-top {
  margin: 0;
  padding: clamp(16px, 9dvh, 86px) 0 0;
}
[data-call-theme="android"] .incoming-label { margin: 6px 0 0; font-size: .8rem; }
[data-call-theme="android"] .incoming-top { display: flex; flex-direction: column; align-items: center; }
[data-call-theme="android"] .call-name { font-size: clamp(1.45rem, 6vw, 1.85rem); font-weight: 600; letter-spacing: -.02em; }
[data-call-theme="android"] .avatar { width: clamp(72px, 19dvh, 144px); background: #d5ece2; color: #23634d; }
[data-call-theme="android"] .avatar svg { width: 39%; height: 39%; fill: currentColor; }
[data-call-theme="android"] .incoming-bottom { width: 100%; margin-top: auto; padding-top: clamp(38px, 9dvh, 80px); }
[data-call-theme="android"] .call-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
[data-call-theme="android"] .call-action { font-size: .77rem; font-weight: 500; }
[data-call-theme="android"] .call-action .round { width: 53px; height: 53px; }
[data-call-theme="android"] .call-action .round svg { width: 25px; height: 25px; }
[data-call-theme="android"] .answer { background: #19a45b; color: #fff; }
[data-call-theme="android"] .danger { background: #ef1747; }
[data-call-theme="android"] .message-action .round { background: #202c33; }
[data-call-theme="android"] .message-action { place-self: stretch; align-content: center; cursor: pointer; }
[data-call-theme="android"] .message-action:hover .round { background: #30414b; }
[data-call-theme="android"] #answer { touch-action: none; user-select: none; cursor: grab; }
[data-call-theme="android"] #answer::before { content: ""; position: absolute; inset: -36px 0 0; }
[data-call-theme="android"] #answer .answer { transform: translateY(var(--answer-offset, 0px)); transition: transform .18s ease; }
[data-call-theme="android"] #answer.dragging { transform: none; cursor: grabbing; }
[data-call-theme="android"] #answer.dragging .answer { transition: none; }
[data-call-theme="android"] #answer.dragging .swipe-hint { visibility: hidden; }
[data-call-theme="android"] .swipe-hint { display: grid; place-items: center; position: absolute; inset: -32px 0 auto; color: #adbbbf; pointer-events: none; animation: swipe-hint 1.8s ease-out infinite; }
[data-call-theme="android"] .call-options { order: -2; }
[data-call-theme="android"] #camera-button { order: -1; }
[data-call-theme="android"] .video-bottom {
  width: min(calc(100% - 32px), 300px);
  gap: 6px;
  padding: 11px;
  border-radius: 15px;
  background: #222d34;
}
[data-call-theme="android"] .video-bottom .round {
  width: clamp(36px, 11.6vw, 46px);
  height: clamp(36px, 11.6vw, 46px);
  background: #3b4a54;
}
[data-call-theme="android"] .video-bottom .round svg { width: 22px; height: 22px; }
[data-call-theme="android"] .video-bottom .audio-off { color: #e2e9ed; }
[data-call-theme="android"] .video-bottom #camera-button[aria-pressed="true"] { background: #eef3f5; color: #222d34; }
[data-call-theme="android"] .video-bottom #hang-button { background: #f15c6d; color: #171e22; }
.call-options summary { cursor: pointer; list-style: none; }
.call-options summary::-webkit-details-marker { display: none; }
.call-options-panel {
  position: absolute;
  left: 0;
  bottom: calc(100% + 9px);
  z-index: 1;
  padding: 6px;
  border-radius: 13px;
  background: #222d34;
}
.call-options-panel button { white-space: nowrap; }
.call-options-panel button[aria-pressed="true"] { background: #43545f; }
#remote-video.video-contain { object-fit: contain; }

[data-call-theme="android"] .self-camera { border-radius: 12px; }

[data-call-theme="ios"] .incoming { background: linear-gradient(160deg, #303e43, #171e23 55%, #101418); }
[data-call-theme="ios"] .incoming-top { margin-top: clamp(12px, 10dvh, 96px); }
[data-call-theme="ios"] .incoming-bottom { width: 100%; }
[data-call-theme="ios"] .incoming-label { font-size: .85rem; }
[data-call-theme="ios"] .call-name { font-weight: 500; }
[data-call-theme="ios"] .avatar { width: clamp(72px, 18dvh, 132px); background: #516169; color: #f2f5f6; }
[data-call-theme="ios"] .message-action { display: none; }
[data-call-theme="ios"] .call-actions { gap: clamp(44px, 24vw, 110px); }
[data-call-theme="ios"] .answer { background: #30d158; color: #102917; }
[data-call-theme="ios"] .danger { background: #ff453a; }
[data-call-theme="ios"] .video-bottom { border-radius: 23px; background: #242629ed; }
[data-call-theme="ios"] .self-camera { border-radius: 18px; }

@keyframes swipe-hint {
  0%, 100% { opacity: .4; transform: translateY(2px); }
  50% { opacity: .9; transform: translateY(-3px); }
}
