:root {
  color-scheme: light;
  --ink: #17211d;
  --muted: #66736d;
  --line: #dce5e0;
  --surface: #ffffff;
  --canvas: #f3f7f5;
  --brand: #007a5a;
  --brand-dark: #005f46;
  --brand-soft: #e4f5ef;
  --danger: #bd2c37;
  --danger-dark: #98212a;
  --warning: #9b6500;
  --shadow: 0 18px 50px rgba(28, 54, 44, 0.09);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--canvas);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.6;
}

[hidden] {
  display: none !important;
}

.page-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 40px 0 80px;
}

.auth-panel {
  width: min(440px, 100%);
  margin: 8vh auto 0;
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 12px;
  color: #fff;
  background: var(--brand);
  font-weight: 800;
  letter-spacing: -0.04em;
}

.eyebrow {
  margin: 18px 0 5px;
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(1.75rem, 4vw, 2.45rem);
  letter-spacing: -0.04em;
}

h2 {
  margin-bottom: 18px;
  font-size: 1.18rem;
}

.subtle,
.session-ref,
.privacy-note {
  color: var(--muted);
}

.form-stack {
  display: grid;
  gap: 16px;
  margin-top: 26px;
}

label {
  display: grid;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 650;
}

input,
select {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid #b9c7c0;
  border-radius: 10px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(0, 122, 90, 0.12);
}

.button {
  min-height: 42px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 700;
}

.button-primary {
  color: #fff;
  background: var(--brand);
}

.button-primary:hover {
  background: var(--brand-dark);
}

.button-secondary {
  border-color: #becbc5;
  color: var(--ink);
  background: #fff;
}

.button-secondary:hover {
  background: #edf3f0;
}

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

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

.button-small {
  min-height: 34px;
  padding: 6px 12px;
}

.button-large {
  min-height: 50px;
}

.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;
}

.invite-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.invite-controls select {
  width: min(220px, 100%);
  min-height: 42px;
}

.invite-status {
  min-height: 20px;
  margin: 8px 0 0;
  text-align: right;
}

.table-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.error-message {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 0.88rem;
}

.topbar,
.call-heading,
.status-row,
.agent-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.topbar {
  margin-bottom: 24px;
}

.topbar .eyebrow,
.call-heading .eyebrow {
  margin-top: 0;
}

.agent-actions {
  font-size: 0.9rem;
}

.status-row {
  margin-bottom: 14px;
}

.count-badge,
.connection-status {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}

.count-badge {
  gap: 4px;
  color: var(--brand-dark);
  background: var(--brand-soft);
}

.connection-status {
  color: #47534e;
  background: #e7eeea;
}

.connection-status[data-state="connected"] {
  color: var(--brand-dark);
  background: var(--brand-soft);
}

.connection-status[data-state="reconnecting"],
.connection-status[data-state="warning"],
.connection-status[data-state="waiting"] {
  color: var(--warning);
  background: #fff2d9;
}

.connection-status[data-state="error"] {
  color: var(--danger);
  background: #ffe7e9;
}

.card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 8px 28px rgba(28, 54, 44, 0.05);
}

.queue-card,
.call-card,
.customer-setup {
  padding: 24px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 0.76rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

td:last-child,
th:last-child {
  text-align: right;
}

.empty-state {
  margin: 20px 0 6px;
  color: var(--muted);
  text-align: center;
}

.call-card {
  margin-top: 22px;
  background: #f8fafc;
}

.call-heading {
  align-items: flex-start;
}

.customer-connection-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid #e7a12e;
  border-radius: 12px;
  color: #694008;
  background: #fff2d9;
  font-size: 0.9rem;
  font-weight: 700;
}

.customer-connection-banner[hidden] {
  display: none;
}

.customer-connection-banner .button {
  flex: 0 0 auto;
}

.session-ref {
  margin-bottom: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.74rem;
  word-break: break-all;
}

.media-grid,
.customer-media {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 14px;
  margin-top: 16px;
}

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

.media-card-screen {
  grid-column: 1 / -1;
}

.media-frame {
  position: relative;
  display: grid;
  min-height: 190px;
  place-items: center;
  overflow: hidden;
  border-radius: 14px;
  color: #b9c8c1;
  background: #15211d;
}

.media-card-large .media-frame {
  min-height: 330px;
}

.media-frame video {
  width: 100%;
  height: 100%;
  min-height: inherit;
  object-fit: cover;
}

.media-card > p {
  margin: 8px 2px 0;
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 650;
}

.audio-container {
  display: none;
}

.co-agent-video-grid {
  display: grid;
  min-height: 10rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  align-items: stretch;
}

.co-agent-video-tile {
  position: relative;
  min-height: 8rem;
  overflow: hidden;
  border-radius: 0.75rem;
  background: #0b2942;
  color: #fff;
}

.co-agent-video-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.co-agent-video-label {
  position: absolute;
  right: 0.5rem;
  bottom: 0.5rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: rgb(0 0 0 / 65%);
  font-size: 0.75rem;
}

.co-agent-camera-placeholder {
  display: grid;
  height: 100%;
  min-height: 8rem;
  place-items: center;
  padding: 1rem;
  text-align: center;
}

.call-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
  padding: 10px 12px;
  border-radius: 14px;
  color: #fff;
  background: #101b31;
  box-shadow: 0 10px 24px rgba(16, 27, 49, 0.16);
}

.call-controls-label {
  margin-right: 4px;
  color: #c8d3e4;
  font-size: 0.78rem;
  font-weight: 700;
}

.call-controls .button-secondary {
  border-color: rgba(255, 255, 255, 0.22);
  color: #fff;
  background: rgba(255, 255, 255, 0.09);
}

.call-controls .button-secondary:hover {
  background: rgba(255, 255, 255, 0.16);
}

#agent-end {
  margin-left: auto;
}

.screen-device-stage {
  display: grid;
  min-height: 540px;
  padding: 32px;
  place-items: center;
  overflow: hidden;
  border: 1px solid #d8e1e8;
  border-radius: 18px;
  background:
    radial-gradient(circle at top, rgba(0, 122, 90, 0.09), transparent 42%),
    #edf2f6;
}

.screen-device-frame {
  --screen-aspect-ratio: 9 / 16;
  --screen-target-width: 430px;
  position: relative;
  width: min(100%, var(--screen-target-width));
  aspect-ratio: var(--screen-aspect-ratio);
  overflow: hidden;
  border-radius: 28px;
  background: #0b1110;
  box-shadow:
    0 0 0 8px #14201c,
    0 22px 48px rgba(23, 33, 29, 0.24);
  transition:
    width 180ms ease,
    aspect-ratio 180ms ease;
}

.screen-content {
  display: grid;
  width: 100%;
  height: 100%;
  min-height: 0;
  place-items: center;
  overflow: hidden;
  border-radius: inherit;
  color: #b9c8c1;
  background: #070c0a;
}

.screen-content video {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
  background: #070c0a;
  cursor: crosshair;
}

.screen-resolution-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  color: #fff;
  background: rgba(9, 16, 13, 0.78);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  font-weight: 700;
  pointer-events: none;
}

.customer-page {
  background:
    linear-gradient(180deg, rgba(0, 122, 90, 0.08), transparent 240px),
    var(--canvas);
}

.customer-shell {
  width: min(820px, calc(100% - 32px));
  margin: 0 auto;
  padding: max(28px, env(safe-area-inset-top)) 0 40px;
}

.customer-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.customer-header .eyebrow {
  margin: 0 0 3px;
}

.customer-header h1 {
  margin: 0;
  font-size: 1.6rem;
}

.customer-setup {
  max-width: 560px;
  margin: 0 auto;
}

.customer-call-heading {
  margin-bottom: 18px;
}

.customer-media {
  margin-top: 0;
}

.customer-agent-frame {
  min-height: 390px;
}

.local-preview .media-frame {
  min-height: 230px;
}

.privacy-note {
  margin: 22px auto 0;
  font-size: 0.78rem;
  text-align: center;
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100% - 24px, 680px);
    padding-top: 20px;
  }

  .auth-panel {
    margin-top: 4vh;
    padding: 24px;
  }

  .topbar,
  .call-heading,
  .customer-connection-banner,
  .status-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .agent-actions {
    width: 100%;
  }

  .media-grid,
  .customer-media {
    grid-template-columns: 1fr;
  }

  .media-card-screen {
    grid-column: auto;
  }

  .media-card-large .media-frame,
  .customer-agent-frame {
    min-height: 280px;
  }

  .local-preview .media-frame {
    min-height: 180px;
  }

  .call-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .call-controls-label {
    grid-column: 1 / -1;
  }

  #agent-end {
    margin-left: 0;
  }

  .screen-device-stage {
    min-height: 420px;
    padding: 24px 16px;
  }

  .customer-controls .button-danger {
    grid-column: 1 / -1;
  }
}
