:root {
  --bg: #C45A18;
  --text: #fff8f1;
  --muted: rgba(255, 248, 241, 0.72);
  --orange: #ff4e16;
  --amber: #ff9a35;
  --panel: rgba(9, 4, 2, 0.88);
  --line: rgba(255, 248, 241, 0.14);
}

* {
  box-sizing: border-box;
}

body.system-page {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 80% 20%, rgba(255, 154, 53, 0.22), transparent 30rem),
    linear-gradient(160deg, #140603 0%, #4e1807 48%, var(--bg) 100%);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

.system-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

.system-topbar nav,
.call-actions,
menu {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.system-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-weight: 900;
  font-size: clamp(20px, 1.4vw, 28px);
}

.system-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--orange), var(--amber));
  color: #190702;
}

.auth-shell,
.call-shell {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.dashboard-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 60px;
}

.auth-card,
.call-card,
.system-panel,
.dialog-card {
  width: min(100%, 460px);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(145deg, rgba(17, 7, 3, 0.94), rgba(4, 2, 1, 0.9));
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.32);
}

.call-card {
  width: min(100%, 560px);
}

.system-panel {
  width: 100%;
}

.system-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 20px;
  margin: 20px 0;
}

.panel-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  margin-top: 8px;
  font-size: clamp(34px, 5vw, 64px);
  line-height: 0.98;
  letter-spacing: -0.07em;
}

h2 {
  font-size: 26px;
}

p {
  color: var(--muted);
  line-height: 1.65;
}

.system-kicker {
  color: var(--amber);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

label {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  color: rgba(255, 248, 241, 0.86);
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid rgba(255, 248, 241, 0.16);
  border-radius: 7px;
  background: rgba(255, 248, 241, 0.08);
  color: var(--text);
  padding: 0 13px;
  font: inherit;
}

textarea {
  min-height: 108px;
  padding-top: 12px;
  resize: vertical;
}

select option {
  color: #1a0702;
}

.system-button,
.system-ghost,
.system-danger {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 0 18px;
  color: var(--text);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.system-button {
  margin-top: 18px;
  background: linear-gradient(135deg, var(--orange), var(--amber));
  box-shadow: 0 14px 34px rgba(255, 78, 22, 0.25);
}

.system-button:hover {
  filter: brightness(1.08);
}

.system-button:disabled,
.system-ghost:disabled,
.system-danger:disabled {
  cursor: not-allowed;
  opacity: 0.72;
}

.system-ghost.is-selected {
  border-color: rgba(255, 154, 53, 0.9);
  background: rgba(255, 78, 22, 0.28);
  color: var(--text);
}

.system-ghost {
  background: rgba(255, 248, 241, 0.08);
  border-color: rgba(255, 248, 241, 0.18);
}

.system-danger {
  background: #c22b1d;
}

.system-link {
  color: var(--muted);
  font-weight: 800;
}

.system-status {
  min-height: 26px;
  margin-top: 14px;
}

.welcome-audio {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  margin-top: 18px;
  padding: 14px;
  border: 1px solid rgba(255, 248, 241, 0.12);
  border-radius: 8px;
  background: rgba(255, 248, 241, 0.06);
}

.welcome-audio p {
  font-size: 14px;
  line-height: 1.55;
}

.audio-toggle {
  min-width: 112px;
  min-height: 42px;
  margin: 0;
  white-space: nowrap;
}

.audio-toggle:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 3px;
}

.user-list,
.audit-list,
.inquiry-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.audit-list {
  max-height: clamp(350px, 42vh, 500px);
  overflow-y: auto;
  padding-right: 8px;
  scrollbar-color: rgba(255, 154, 53, 0.75) rgba(255, 248, 241, 0.08);
  scrollbar-width: thin;
}

.audit-list::-webkit-scrollbar {
  width: 8px;
}

.audit-list::-webkit-scrollbar-track {
  background: rgba(255, 248, 241, 0.08);
  border-radius: 999px;
}

.audit-list::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--orange), var(--amber));
  border-radius: 999px;
}

.user-card,
.audit-item,
.inquiry-card,
.totp-box {
  border: 1px solid rgba(255, 248, 241, 0.1);
  border-radius: 8px;
  padding: 16px;
  background: rgba(255, 248, 241, 0.06);
}

.user-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
}

.inquiry-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 16px;
}

.inquiry-card .system-button {
  margin-top: 0;
  white-space: nowrap;
}

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

.section-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.compact-action {
  min-height: 38px;
  padding: 0 14px;
  font-size: 14px;
}

.compact-dialog {
  width: min(100%, 430px);
}

.totp-dialog-card {
  width: min(100%, 520px);
  max-height: calc(100dvh - 24px);
  overflow: auto;
}

.totp-qr-frame {
  display: grid;
  place-items: center;
  width: min(100%, 312px);
  margin: 22px auto 4px;
  padding: 18px;
  border: 1px solid rgba(255, 248, 241, 0.14);
  border-radius: 8px;
  background: #fff8f1;
}

.totp-qr-frame img {
  display: block;
  width: min(100%, 260px);
  height: auto;
}

.copy-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.copy-row .system-ghost {
  min-height: 46px;
}

.recovery-panel {
  display: grid;
  gap: 10px;
  margin-top: 18px;
  padding: 16px;
  border: 1px solid rgba(255, 248, 241, 0.12);
  border-radius: 8px;
  background: rgba(255, 248, 241, 0.06);
}

.recovery-panel h3 {
  margin: 0;
  color: var(--text);
  font-size: 18px;
}

.recovery-panel ul {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.recovery-panel code {
  display: block;
  padding: 8px 10px;
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  font: 800 14px/1.3 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  overflow-wrap: anywhere;
}

.inquiry-meta,
.user-meta {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.inquiry-reason {
  color: rgba(255, 196, 156, 0.86);
  font-size: 14px;
}

.visitor-form {
  margin-top: 18px;
}

.visitor-form .call-actions {
  margin-top: 4px;
}

.caller-details {
  display: grid;
  gap: 8px;
  margin-top: 18px;
  padding: 16px;
  border: 1px solid rgba(255, 248, 241, 0.12);
  border-radius: 8px;
  background: rgba(255, 248, 241, 0.06);
}

.caller-name {
  font-size: 20px;
}

.caller-meta {
  color: var(--amber);
  font-weight: 800;
}

.caller-message {
  color: var(--text);
}

.receiver-readiness {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid rgba(255, 248, 241, 0.12);
  border-radius: 8px;
  background: rgba(255, 248, 241, 0.06);
}

.readiness-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #ffca7a;
  box-shadow: 0 0 0 5px rgba(255, 202, 122, 0.12);
}

.receiver-readiness[data-state="live"] .readiness-dot {
  background: #36d779;
  box-shadow: 0 0 0 5px rgba(54, 215, 121, 0.14);
}

.receiver-readiness[data-state="blocked"] .readiness-dot {
  background: #ff4e36;
  box-shadow: 0 0 0 5px rgba(255, 78, 54, 0.14);
}

.receiver-readiness strong {
  display: block;
  color: var(--text);
}

.receiver-readiness p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.incoming-alert {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  margin-top: 16px;
  padding: 16px;
  border: 1px solid rgba(255, 248, 241, 0.12);
  border-radius: 8px;
  background: rgba(255, 248, 241, 0.06);
}

.incoming-alert.is-ringing {
  border-color: rgba(255, 154, 53, 0.5);
  background: rgba(255, 78, 22, 0.12);
  box-shadow: 0 0 28px rgba(255, 78, 22, 0.14);
}

.incoming-alert strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
}

.incoming-alert-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 10px;
}

.incoming-alert-actions .system-button,
.incoming-alert-actions .system-ghost {
  margin-top: 0;
  white-space: nowrap;
}

dialog {
  border: 0;
  background: transparent;
  max-width: min(100vw - 24px, 560px);
  max-height: calc(100dvh - 24px);
  overflow: auto;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.68);
}

@media (max-width: 760px) {
  .system-grid,
  .panel-head,
  .user-card,
  .inquiry-card,
  .incoming-alert {
    grid-template-columns: 1fr;
  }

  .user-actions {
    justify-content: start;
  }

  .incoming-alert-actions {
    justify-content: start;
  }

  .section-toolbar {
    align-items: start;
    flex-direction: column;
  }

  .copy-row,
  .recovery-panel ul {
    grid-template-columns: 1fr;
  }

  .welcome-audio {
    grid-template-columns: 1fr;
  }

  .audio-toggle {
    width: fit-content;
  }

  .totp-qr-frame {
    width: min(100%, 264px);
    padding: 12px;
  }

  .totp-qr-frame img {
    width: min(100%, 220px);
  }
}
