:root {
  /* --- Exelogy brand palette ---
     Derived from the real Exelogy logo design system (brand-kit/ at the
     project root has the source files). --bg matches the brand's own dark
     navy (#150F26); --panel/--panel-2/--border are lightness steps up from
     it so panels stay legible without leaving the brand's hue. --accent is
     Exelogy's royal purple (button fills, paired with white text);
     --brand-lilac is the lighter purple the brand itself uses for text/marks
     on dark backgrounds (links, the wordmark's accent letters, focus rings).
     All contrast pairs below are WCAG AA checked. */
  --bg: #150f26;
  --panel: #1e1536;
  --panel-2: #271c47;
  --border: #3d2c6f;
  --text: #ede9f6;
  --text-dim: #a99bc9;
  --accent: #6c2bd9;
  --accent-dim: #3b2166;
  --danger: #e5484d;
  --success: #2fbf71;
  --radius: 10px;

  --brand-navy: #150f26;
  --brand-accent: #6c2bd9;
  --brand-accent-2: #c0a6ff;

  --nav-height: 62px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* {
  box-sizing: border-box;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  color-scheme: dark; /* native controls (file picker, scrollbars) follow the dark theme */
  -webkit-tap-highlight-color: transparent;
}

button {
  font-family: inherit;
}

.icon {
  width: 1em;
  height: 1em;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px;
  padding-top: calc(20px + var(--safe-top));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-lockup {
  height: 22px;
  width: auto;
  display: block;
}

.brand-product {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--text-dim);
  padding-left: 12px;
  border-left: 1px solid var(--border);
  white-space: nowrap;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-dim);
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-dim);
}

.user-menu .user-name {
  color: var(--text);
  font-weight: 600;
}

.install-btn {
  display: none; /* shown via JS only when the browser offers an install prompt */
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.dot-offline {
  background: var(--danger);
}

.dot-online {
  background: var(--success);
}

.layout {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  grid-template-rows: auto auto;
  gap: 16px;
}

.dialer {
  grid-row: span 2;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.panel h2 {
  font-size: 15px;
  margin: 0 0 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

input[type="tel"],
input[type="text"],
input[type="email"],
input[type="password"],
input[type="file"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 15px;
  margin-bottom: 8px;
}

.hint {
  font-size: 12px;
  color: var(--text-dim);
  margin: 4px 0 14px;
}

.empty-hint {
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
  padding: 24px 8px;
  margin: 0;
}

/* ---------- Dial pad (number display + keypad + call button) ---------- */

.number-display-row {
  position: relative;
  margin-bottom: 6px;
}

.number-display {
  width: 100%;
  padding: 14px 44px 14px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 26px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-align: center;
  margin-bottom: 0;
}

.number-display::placeholder {
  font-size: 15px;
  color: var(--text-dim);
}

.backspace-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
}

.backspace-btn:hover,
.backspace-btn:active {
  color: var(--text);
  background: var(--panel);
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 18px 0 22px;
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
}

.key {
  aspect-ratio: 1 / 1;
  width: 100%;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 120ms ease, transform 80ms ease;
}

.key:active {
  transform: scale(0.94);
  background: var(--accent-dim);
}

.key-digit {
  font-size: 22px;
  font-weight: 600;
}

.key-letters {
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  margin-top: 2px;
}

.key-symbol .key-digit {
  font-size: 24px;
}

.call-fab {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin: 0 auto;
  border-radius: 50%;
  border: none;
  background: var(--success);
  color: white;
  font-size: 26px;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(47, 191, 113, 0.35);
  transition: transform 80ms ease, box-shadow 120ms ease;
}

.call-fab:active {
  transform: scale(0.95);
  box-shadow: 0 4px 12px rgba(47, 191, 113, 0.3);
}

/* ---------- In-call screen ---------- */

.call-banner {
  background: var(--panel-2);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius);
  padding: 28px 16px 22px;
  margin-bottom: 16px;
  text-align: center;
}

.call-avatar {
  width: 72px;
  height: 72px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--brand-accent-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 700;
  text-transform: uppercase;
}

.call-target {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 6px;
}

.call-timer {
  font-size: 28px;
  font-variant-numeric: tabular-nums;
  /* Solid --accent (royal purple) reads too low-contrast as text on dark
     panels — brand-accent-2 (lilac) is what Exelogy's own brand kit uses
     for on-dark text/accents, and it's the better contrast match here. */
  color: var(--brand-accent-2);
  margin-bottom: 22px;
}

.call-controls {
  display: flex;
  gap: 22px;
  justify-content: center;
}

.call-round-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border: none;
  background: none;
  color: var(--text);
  cursor: pointer;
  font-size: 11px;
}

.call-round-btn .icon {
  width: 52px;
  height: 52px;
  padding: 15px;
  border-radius: 50%;
  background: var(--panel);
  border: 1px solid var(--border);
  box-sizing: border-box;
}

.call-round-btn[aria-pressed="true"] .icon {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.call-round-btn-danger .icon {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}

/* ---------- Buttons (generic) ---------- */

.btn {
  border: none;
  border-radius: 8px;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-secondary {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
}

.icon-btn-call {
  background: var(--success);
  color: white;
}

.icon-btn-danger {
  background: transparent;
  color: var(--text-dim);
}

.icon-btn-danger:hover,
.icon-btn-danger:active {
  color: var(--danger);
  background: rgba(229, 72, 77, 0.12);
}

.inline-form {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
}

.inline-form input {
  margin-bottom: 0;
}

/* ---------- Contacts list ---------- */

.contact-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  max-height: 260px;
  overflow-y: auto;
}

.contact-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
}

.contact-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--brand-accent-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  flex-shrink: 0;
}

.contact-info {
  flex: 1;
  min-width: 0;
}

.contact-list .contact-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contact-list .contact-phone {
  color: var(--text-dim);
  font-size: 13px;
}

.contact-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* ---------- Call history / Recents ---------- */

.history-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  max-height: 340px;
  overflow-y: auto;
}

.history-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
}

.history-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--panel-2);
  color: var(--text-dim);
}

.history-icon.is-success {
  color: var(--success);
}

.history-icon.is-missed {
  color: var(--danger);
}

.history-info {
  flex: 1;
  min-width: 0;
}

.history-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-name.is-missed {
  color: #ff9a9d;
}

.history-meta {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: capitalize;
}

.history-right {
  text-align: right;
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-dim);
}

.history-time {
  white-space: nowrap;
}

.history-duration {
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.history {
  max-height: 400px;
  overflow-y: auto;
}

/* ---------- Bottom tab bar (mobile "phone app" nav) ---------- */

.bottom-nav {
  display: none;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 0 4px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 11px;
  cursor: pointer;
}

.nav-btn .icon {
  width: 22px;
  height: 22px;
}

.nav-btn.is-active {
  color: var(--brand-accent-2);
}

/* ================================================================
   Mobile layout — stacked panels behind a bottom tab bar, like a
   native phone dialer app.
   ================================================================ */

@media (max-width: 860px) {
  .app {
    padding: 14px 14px 0;
  }

  .topbar {
    margin-bottom: 14px;
  }

  .brand-product {
    display: none;
  }

  .status-label {
    display: none;
  }

  .install-btn {
    padding: 8px 12px;
    font-size: 12px;
  }

  .user-menu .user-name {
    display: none;
  }

  .btn-logout {
    padding: 8px 10px;
    font-size: 12px;
  }

  .layout {
    display: block;
  }

  .panel {
    display: none;
    border: none;
    background: transparent;
    padding: 4px 0 24px;
  }

  .panel.is-active {
    display: block;
  }

  .panel h2 {
    display: none;
  }

  .keypad {
    max-width: 340px;
  }

  .contact-list,
  .history-list {
    max-height: none;
  }

  .history {
    max-height: none;
  }

  .bottom-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    background: var(--panel);
    border-top: 1px solid var(--border);
    padding-bottom: var(--safe-bottom);
  }

  /* Keep content from being hidden behind the fixed bottom nav. */
  .app {
    padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 14px);
  }
}

@media (min-width: 861px) {
  .bottom-nav {
    display: none !important;
  }
}

/* ---------- Auth pages (login / signup) ---------- */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(circle at 20% 10%, rgba(79, 124, 255, 0.12), transparent 40%),
    var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px 28px;
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
  text-align: center;
}

.auth-brand .brand-lockup {
  height: 40px;
  width: auto;
}

.auth-brand .tagline {
  color: var(--text-dim);
  font-size: 13px;
  margin: 0;
}

.auth-card h2 {
  font-size: 16px;
  margin: 0 0 18px;
  text-align: center;
  color: var(--text-dim);
  font-weight: 500;
}

.auth-card form {
  display: flex;
  flex-direction: column;
}

.auth-card .btn-primary {
  width: 100%;
  padding: 12px 0;
  margin-top: 6px;
}

.auth-error {
  background: rgba(229, 72, 77, 0.12);
  border: 1px solid rgba(229, 72, 77, 0.4);
  color: #ff9a9d;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 14px;
}

.auth-switch {
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 18px;
}

.auth-switch a {
  color: var(--brand-accent-2);
  text-decoration: none;
  font-weight: 600;
}

.auth-switch a:hover {
  text-decoration: underline;
}
