:root {
  color-scheme: light;
  --bg: #f2efe8;
  --paper: #fffaf2;
  --line: #d8cdbb;
  --ink: #1d1a17;
  --muted: #6c6256;
  --accent: #a9481f;
  --accent-strong: #7f3312;
  --danger: #b42318;
  --ok: #18794e;
  --warn: #b54708;
  --shadow: 0 20px 60px rgba(61, 39, 17, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(169, 72, 31, 0.12), transparent 30%),
    linear-gradient(180deg, #f7f3eb 0%, var(--bg) 100%);
  color: var(--ink);
}

body.modal-open {
  overflow: hidden;
}

.shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 40px 20px 56px;
}

.hidden {
  display: none !important;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
  align-items: end;
}

.hero-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 12px;
  color: var(--accent-strong);
  margin: 0 0 10px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(34px, 4vw, 56px);
  line-height: 1;
  max-width: 700px;
  margin-bottom: 12px;
}

.lede,
.meta,
.notes {
  color: var(--muted);
}

.status-card,
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.status-card {
  min-width: 240px;
  padding: 20px;
}

.hero-cta {
  min-height: 54px;
  font-size: 16px;
  font-weight: 700;
}

.notice {
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid rgba(181, 71, 8, 0.25);
  background: rgba(181, 71, 8, 0.08);
  margin-bottom: 18px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.card {
  padding: 20px;
}

.highlight-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.compact-lede {
  margin-bottom: 16px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

.actions,
.row {
  display: flex;
  gap: 10px;
}

.actions {
  margin-bottom: 18px;
  flex-wrap: wrap;
}

button,
input {
  border-radius: 14px;
  border: 1px solid var(--line);
  font: inherit;
}

button {
  background: var(--accent);
  color: white;
  padding: 12px 16px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
  background: var(--accent-strong);
}

button.ghost {
  background: transparent;
  color: var(--ink);
}

button.light-ghost {
  color: white;
  border-color: rgba(255, 255, 255, 0.14);
}

button.danger {
  background: var(--danger);
}

button.disabled-action,
button:disabled {
  cursor: not-allowed;
  transform: none;
  background: #c8b9a4;
  color: #5c5247;
}

input {
  width: 100%;
  padding: 12px 14px;
  background: white;
}

.field {
  display: block;
}

.field span,
.pairing-output span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 14px;
}

.pairing-output {
  margin-top: 16px;
}

.pairing-output strong {
  font-size: 24px;
  letter-spacing: 0.08em;
}

.qr-card {
  min-height: 340px;
}

.qr-wrapper {
  border: 1px dashed var(--line);
  border-radius: 20px;
  min-height: 250px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.55);
}

.qr-wrapper img {
  width: min(100%, 320px);
  height: auto;
}

.qr-wrapper.empty {
  color: var(--muted);
}

.pill {
  display: inline-flex;
  padding: 8px 12px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
  font-weight: 700;
}

.pill-open {
  background: rgba(24, 121, 78, 0.14);
  color: var(--ok);
}

.pill-connecting,
.pill-reconnecting {
  background: rgba(181, 71, 8, 0.14);
  color: var(--warn);
}

.pill-close,
.pill-idle {
  background: rgba(108, 98, 86, 0.12);
  color: var(--muted);
}

.json-block,
.events {
  background: #1f1f1f;
  color: #f5f5f5;
  border-radius: 18px;
  padding: 16px;
}

.json-block {
  white-space: pre-wrap;
  min-height: 180px;
}

.json-block.compact {
  min-height: 120px;
}

.events {
  max-height: 420px;
  overflow: auto;
  display: grid;
  gap: 10px;
}

.event {
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
}

.event header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 13px;
}

.event pre {
  margin: 0;
  white-space: pre-wrap;
  color: #d8d8d8;
}

.notes {
  padding-left: 18px;
}

.tiny {
  color: var(--muted);
  font-size: 13px;
}

.capabilities {
  display: grid;
  gap: 10px;
}

.cap-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(216, 205, 187, 0.8);
}

.cap-row strong.yes {
  color: var(--ok);
}

.cap-row strong.no {
  color: var(--danger);
}

.storage-summary,
.storage-grid {
  display: grid;
  gap: 12px;
}

.storage-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.storage-item {
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(216, 205, 187, 0.8);
  background: rgba(255, 255, 255, 0.6);
}

.storage-item span {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}

.storage-item strong {
  display: block;
  font-size: 18px;
}

.floating-webphone {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  border-radius: 999px;
  padding: 14px 20px;
  box-shadow: 0 18px 40px rgba(61, 39, 17, 0.25);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(12, 9, 7, 0.6);
  backdrop-filter: blur(6px);
}

.modal-dialog {
  position: relative;
  z-index: 1;
  width: min(1080px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
}

.softphone {
  background: linear-gradient(180deg, #151312 0%, #26211e 100%);
  color: white;
  border-radius: 28px;
  padding: 24px;
  box-shadow: 0 30px 70px rgba(15, 10, 6, 0.24);
}

.modal-top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.softphone-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 18px;
}

.softphone-body {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 18px;
}

.dialer,
.call-card {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 22px;
  padding: 18px;
}

.dialer-screen {
  margin-bottom: 16px;
}

.dialer-screen input {
  background: rgba(255, 255, 255, 0.92);
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.key {
  min-height: 64px;
  font-size: 24px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.06);
}

.call-panel {
  display: grid;
  gap: 18px;
}

.micro-events {
  display: grid;
  gap: 10px;
}

.micro-event {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  color: #efeae3;
}

.error {
  color: var(--danger);
  margin-top: 14px;
  min-height: 20px;
}

.softphone-message {
  min-height: 22px;
  margin-top: 10px;
  font-size: 14px;
}

.softphone-message.info {
  color: #f2c98f;
}

.softphone-message.success {
  color: #8ed8b2;
}

.softphone-message.error {
  color: #ff9c8f;
}

.call-timer {
  margin-top: 12px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #8ed8b2;
  font-variant-numeric: tabular-nums;
}

/* Notificação de chamada recebida */
.incoming-call {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 1200;
  max-width: calc(100vw - 48px);
}

.incoming-call.hidden {
  display: none;
}

.incoming-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  width: 380px;
  max-width: 100%;
  border-radius: 18px;
  background: linear-gradient(150deg, #14321f, #0f2540);
  border: 1px solid rgba(142, 216, 178, 0.35);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  color: #f3f7f5;
  animation: incoming-pop 0.25s ease, incoming-glow 1.6s ease-in-out infinite;
}

@keyframes incoming-pop {
  from {
    transform: translateY(-12px);
    opacity: 0;
  }
}

@keyframes incoming-glow {
  0%,
  100% {
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45), 0 0 0 0 rgba(142, 216, 178, 0.25);
  }
  50% {
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45), 0 0 0 8px rgba(142, 216, 178, 0);
  }
}

.incoming-avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 50%;
  background: rgba(142, 216, 178, 0.18);
  color: #8ed8b2;
  overflow: hidden;
  animation: incoming-ring 1.2s ease-in-out infinite;
}

.incoming-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.incoming-photo.hidden,
.wc-photo.hidden {
  display: none;
}

@keyframes incoming-ring {
  0%,
  100% {
    transform: rotate(0);
  }
  20% {
    transform: rotate(-12deg);
  }
  40% {
    transform: rotate(12deg);
  }
  60% {
    transform: rotate(-8deg);
  }
  80% {
    transform: rotate(8deg);
  }
}

.incoming-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.incoming-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8ed8b2;
}

.incoming-name {
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.incoming-sub {
  font-size: 13px;
  color: rgba(243, 247, 245, 0.7);
}

.incoming-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 0 0 auto;
}

.incoming-btn {
  border: none;
  border-radius: 10px;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  transition: filter 0.15s ease, transform 0.05s ease;
}

.incoming-btn:hover {
  filter: brightness(1.08);
}

.incoming-btn:active {
  transform: scale(0.97);
}

.incoming-btn.answer {
  background: #1fae5a;
}

.incoming-btn.decline {
  background: #e0524a;
}

@media (max-width: 520px) {
  .incoming-call {
    top: 12px;
    right: 12px;
    left: 12px;
  }

  .incoming-card {
    width: 100%;
  }
}

/* Card de chamada dentro do webphone */
.webphone-call {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  margin-bottom: 16px;
  border-radius: 16px;
  background: linear-gradient(150deg, rgba(20, 50, 31, 0.65), rgba(15, 37, 64, 0.65));
  border: 1px solid rgba(142, 216, 178, 0.28);
}

.webphone-call.hidden {
  display: none;
}

.wc-avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  flex: 0 0 56px;
  border-radius: 50%;
  background: rgba(142, 216, 178, 0.18);
  color: #8ed8b2;
  overflow: hidden;
}

.wc-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.wc-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.wc-state {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #8ed8b2;
}

.wc-name {
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wc-number {
  font-size: 13px;
  color: rgba(243, 247, 245, 0.7);
}

.wc-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 0 0 auto;
}

.wc-actions .ghost {
  padding: 8px 16px;
}

.wc-actions .hidden {
  display: none;
}

.call-history {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-empty {
  color: var(--muted);
  margin: 0;
}

.history-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
}

.history-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.history-dir {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
}

.history-dir.in {
  background: rgba(24, 121, 78, 0.12);
  color: var(--ok);
}

.history-dir.out {
  background: rgba(169, 72, 31, 0.12);
  color: var(--accent);
}

.history-status {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
}

.history-status.ok {
  color: var(--ok);
  border-color: rgba(24, 121, 78, 0.4);
}

.history-status.bad {
  color: var(--danger);
  border-color: rgba(180, 35, 24, 0.4);
}

.history-status.warn {
  color: var(--warn);
  border-color: rgba(181, 71, 7, 0.4);
}

.history-status.live {
  color: var(--accent-strong);
  border-color: rgba(127, 51, 18, 0.4);
}

.history-when {
  color: var(--muted);
  font-size: 13px;
}

.history-duration {
  margin-left: auto;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}

.history-line.route {
  font-size: 13px;
  color: var(--ink);
}

.history-route b {
  color: var(--muted);
  font-weight: 600;
}

.history-arrow {
  color: var(--muted);
}

.history-line.media {
  gap: 12px;
}

.history-audio {
  flex: 1;
  min-width: 200px;
  height: 36px;
}

.history-download {
  color: var(--accent-strong);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.history-download:hover {
  text-decoration: underline;
}

.history-norec {
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
}

@media (max-width: 860px) {
  .history-duration {
    margin-left: 0;
  }

  .hero,
  .grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .hero {
    align-items: start;
  }

  .status-card {
    min-width: 0;
  }

  .row {
    flex-direction: column;
  }

  .storage-grid,
  .softphone-body {
    grid-template-columns: 1fr;
  }

  .floating-webphone {
    right: 16px;
    bottom: 16px;
  }

  .modal {
    padding: 12px;
  }
}
