:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface2: #21262d;
  --border: #30363d;
  --text: #f0f6fc;
  --muted: #8b949e;
  --accent: #238636;
  --accent-hover: #2ea043;
  --danger: #da3633;
  --brand: #1e3a5f;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: radial-gradient(ellipse at top, #1a2744 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100dvh;
}

.app-frame {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 12px 24px;
}
#app {
  width: 100%;
  max-width: 420px;
  min-height: calc(100dvh - 48px);
}
@media (min-width: 768px) {
  .app-frame { padding-top: 32px; }
  #app {
    max-width: 440px;
    min-height: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
    overflow: hidden;
  }
  .screen { min-height: 680px; }
}

.install-bar {
  width: 100%;
  max-width: 520px;
  margin: 12px auto 0;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--brand);
  border-radius: 12px;
  font-size: 0.85rem;
}
.install-bar span { flex: 1; }
.btn-install {
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn-dismiss {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.2rem;
  cursor: pointer;
  line-height: 1;
}

.screen { padding: 24px 20px; min-height: 100dvh; }
@media (min-width: 768px) {
  .screen { min-height: 680px; padding: 28px 24px; }
}

.brand { text-align: center; padding: 32px 0 28px; }
.brand-icon {
  display: block;
  margin: 0 auto 16px;
  border-radius: 18px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.brand h1 { font-size: 1.55rem; font-weight: 700; }
.muted { color: var(--muted); font-size: 0.9rem; margin-top: 4px; }
.device-hint {
  margin-top: 12px;
  font-size: 0.8rem;
  color: #58a6ff;
}
.login-foot { text-align: center; margin-top: 20px; font-size: 0.78rem; line-height: 1.5; }

.login-form label { display: block; margin-bottom: 16px; }
.login-form span { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; }
.login-form input[type="text"],
.login-form input[type="password"],
.login-form input:not([type="checkbox"]) {
  width: 100%;
  padding: 14px 16px;
  font-size: 1.05rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface2);
  color: var(--text);
}
.checkbox-row {
  display: flex !important;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px !important;
  font-size: 0.88rem;
  color: var(--muted);
}
.checkbox-row input { width: auto; accent-color: var(--accent); }

.btn-primary {
  width: 100%;
  padding: 14px;
  margin-top: 8px;
  font-size: 1.05rem;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { background: var(--accent-hover); }
.error-msg { color: #f85149; text-align: center; margin-top: 12px; font-size: 0.9rem; min-height: 1.2em; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
  gap: 8px;
}
.topbar strong { display: block; font-size: 1.1rem; }
.topbar-actions { display: flex; gap: 8px; flex-shrink: 0; }
.status { font-size: 0.8rem; display: block; margin-top: 2px; }
.status.on { color: #3fb950; }
.status.off { color: var(--muted); }
.btn-text {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 4px 0;
}
.btn-text:hover { color: var(--text); }

.display {
  text-align: center;
  font-size: 2rem;
  font-weight: 300;
  letter-spacing: 2px;
  padding: 16px 0;
  min-height: 60px;
  word-break: break-all;
}
@media (min-width: 768px) {
  .display { font-size: 2.2rem; padding: 20px 0; }
}
.pc-hint {
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.keypad button {
  padding: 14px 8px;
  min-height: 58px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, transform 0.05s;
}
.keypad button:hover { background: var(--border); }
.keypad button:active { transform: scale(0.97); background: var(--border); }
.key-main { font-size: 1.45rem; line-height: 1.1; }
.key-sub { font-size: 0.55rem; color: var(--muted); letter-spacing: 1px; margin-top: 2px; }

.actions { display: flex; gap: 12px; margin-bottom: 20px; }
.btn-call, .btn-hangup {
  flex: 1;
  padding: 16px;
  font-size: 1.1rem;
  font-weight: 600;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.05s;
}
.btn-call { background: var(--accent); color: #fff; }
.btn-call:hover:not(:disabled) { background: var(--accent-hover); }
.btn-call:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-hangup { background: var(--danger); color: #fff; }
.btn-hangup:disabled { opacity: 0.35; cursor: not-allowed; }

.tabs { display: flex; gap: 8px; border-top: 1px solid var(--border); padding-top: 12px; }
.tab {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.tab.active { background: var(--surface2); color: var(--text); font-weight: 600; }

.call-log { list-style: none; margin-top: 12px; max-height: 280px; overflow-y: auto; }
.call-log li {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.call-log li span { color: var(--muted); font-size: 0.8rem; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
  backdrop-filter: blur(6px);
}
.overlay-card {
  text-align: center;
  width: 100%;
  max-width: 340px;
}
.overlay-label { color: var(--muted); font-size: 1rem; margin-bottom: 8px; }
.overlay-number { font-size: 2.2rem; font-weight: 700; margin-bottom: 28px; }
.overlay-actions { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.big { width: 100%; max-width: 280px; padding: 18px !important; }

@media (display-mode: standalone) {
  .install-bar { display: none !important; }
  #btn-install-inline { display: none !important; }
}

.platform-chips {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 12px 0 4px;
}
.chip {
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}
.chip.active {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(35, 134, 54, 0.15);
}
.client-device {
  font-size: 0.75rem;
  color: var(--muted);
  margin-left: 6px;
}

.gateway-body { background: radial-gradient(ellipse at top, #3d1f1f 0%, var(--bg) 55%); }
.gateway-app { max-width: 420px; width: 100%; }
.gateway-top { border-bottom-color: #5c2a2a; }
.gateway-panel { padding: 16px; }
.gateway-pending {
  margin: 20px 0;
  padding: 20px;
  background: var(--surface2);
  border-radius: 16px;
  text-align: center;
}
.btn-gateway { background: #8b3a3a; }
.btn-gateway:hover { background: #a04444; }
.gw-log { margin-top: 16px; max-height: 40vh; overflow-y: auto; }
.sms-panel { padding: 12px 0; display: flex; flex-direction: column; gap: 10px; }
.sms-panel textarea {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  resize: vertical;
}
.sms-to input {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
}
.sms-log { max-height: 36vh; }
.err { color: var(--danger); font-size: 0.8rem; }
.platform-chip {
  display: inline-block;
  font-size: 0.8rem;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(139, 58, 58, 0.25);
  margin-bottom: 12px;
}
