:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mvzap-bg: #f2f6fb;
  --mvzap-surface: #ffffff;
  --mvzap-border: #d9e4f2;
  --mvzap-text: #0f172a;
  --mvzap-muted: #516074;
  --mvzap-primary: #0b95b3;
  --mvzap-primary-strong: #087f9a;
  --mvzap-primary-soft: #d9f3f9;
  --mvzap-dark: #091b3a;
  --mvzap-dark-soft: #12325c;
  background: var(--mvzap-bg);
  color: var(--mvzap-text);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--mvzap-bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--mvzap-border);
  background: var(--mvzap-surface);
  color: var(--mvzap-text);
  border-radius: 6px;
  padding: 9px 12px;
  cursor: pointer;
  font-weight: 600;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

button:hover {
  border-color: var(--mvzap-primary);
  background: #f8fbfe;
}

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

button.primary:hover {
  background: var(--mvzap-primary-strong);
  border-color: var(--mvzap-primary-strong);
}

button.danger {
  color: #b42318;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 28px 32px;
  background: linear-gradient(90deg, var(--mvzap-dark), var(--mvzap-dark-soft));
  color: #fff;
}

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

.topbar-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid rgba(153, 232, 246, 0.35);
  background: rgba(14, 165, 199, 0.24);
  color: #ffffff;
  text-decoration: none;
  font-weight: 700;
}

.topbar-link:hover {
  background: rgba(14, 165, 199, 0.34);
}

.topbar h1 {
  margin: 4px 0 0;
  font-size: 28px;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  color: #9ee8f5;
  font-size: 12px;
  font-weight: 700;
}

.status-pill {
  min-width: 180px;
  text-align: center;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(14, 165, 199, 0.2);
  border: 1px solid rgba(153, 232, 246, 0.35);
}

.status-pill.is-ok {
  background: rgba(34, 197, 94, 0.18);
  border-color: rgba(134, 239, 172, 0.45);
}

.status-pill.is-warn {
  background: rgba(245, 158, 11, 0.22);
  border-color: rgba(253, 224, 71, 0.5);
}

.status-pill.is-error {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(252, 165, 165, 0.45);
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(360px, 1.05fr);
  gap: 18px;
  padding: 22px;
}

.auth-shell {
  min-height: calc(100vh - 102px);
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(340px, 0.8fr);
  gap: 22px;
  padding: 22px;
  align-items: center;
}

.auth-hero {
  padding: 22px;
  color: var(--mvzap-text);
}

.auth-hero h2 {
  margin: 0 0 10px;
  font-size: clamp(30px, 5vw, 40px);
  line-height: 1.08;
}

.auth-panel {
  max-width: 520px;
  width: 100%;
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.type-switch {
  display: inline-flex;
  gap: 8px;
}

.auth-form {
  display: grid;
  gap: 12px;
}

.error-text {
  color: #b42318;
}

.panel {
  background: var(--mvzap-surface);
  border: 1px solid var(--mvzap-border);
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 10px 26px rgba(10, 20, 46, 0.06);
}

.panel.wide {
  grid-column: 1 / -1;
}

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

.section-head h2 {
  margin: 0;
  font-size: 19px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.instance-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr 220px 160px;
  gap: 10px;
  align-items: end;
}

.connection-panel {
  margin-top: 14px;
  border-top: 1px solid var(--mvzap-border);
  padding-top: 14px;
}

#connection-qr {
  min-height: 110px;
}

#connection-qr-image {
  width: min(220px, 100%);
  border: 1px solid var(--mvzap-border);
  border-radius: 8px;
  background: #fff;
  padding: 6px;
}

.admin-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(140px, 1fr));
  gap: 8px 14px;
}

.admin-tabs {
  display: inline-flex;
  gap: 8px;
  margin-bottom: 12px;
}

[data-admin-pane] {
  display: grid;
  gap: 10px;
}

#admin-provision-form {
  grid-template-columns: repeat(3, minmax(180px, 1fr));
}

#admin-provision-form button[type='submit'] {
  align-self: end;
}

.admin-metrics p {
  margin: 0;
  color: var(--mvzap-muted);
}

.admin-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
}

#admin-quick-actions {
  margin-top: 10px;
  margin-bottom: 10px;
}

.admin-alerts {
  margin: 10px 0 14px;
  border: 1px solid var(--mvzap-border);
  border-radius: 8px;
  padding: 10px;
  background: #f8fbfe;
  color: var(--mvzap-text);
  display: grid;
  gap: 6px;
}

.admin-alerts.empty {
  color: var(--mvzap-muted);
}

.admin-alert-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  border: 1px solid #e8eef8;
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
}

.admin-alert-item strong {
  color: #1d2f47;
}

.toolbar-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.ops-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(110px, 1fr));
  gap: 10px;
}

.ops-card {
  border: 1px solid var(--mvzap-border);
  border-radius: 8px;
  padding: 10px;
  background: #fbfdff;
}

.ops-card p {
  margin: 0 0 6px;
}

.ops-card strong {
  font-size: 22px;
  color: var(--mvzap-dark);
}

.ops-foot {
  margin-top: 10px;
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.ops-foot p {
  margin: 0;
}

.ops-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

#admin-line-status {
  margin-top: 8px;
  min-height: 110px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--mvzap-muted);
}

input,
select {
  width: 100%;
  border: 1px solid var(--mvzap-border);
  border-radius: 6px;
  padding: 10px;
  color: var(--mvzap-text);
  background: #fbfdff;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--mvzap-primary);
  box-shadow: 0 0 0 3px var(--mvzap-primary-soft);
}

.password-field {
  display: grid;
  align-items: center;
}

.password-field input {
  grid-area: 1 / 1;
  height: 38px;
  padding: 8px 40px 8px 10px;
}

.password-toggle {
  grid-area: 1 / 1;
  justify-self: end;
  margin-right: 6px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #2e435f;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.password-toggle:hover {
  background: var(--mvzap-primary-soft);
  border-color: transparent;
}

.check {
  grid-template-columns: 18px 1fr;
  align-items: center;
  gap: 8px;
}

.check input {
  width: 16px;
  height: 16px;
}

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

.empty {
  color: var(--mvzap-muted);
  padding: 14px 0;
}

.line-card {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid var(--mvzap-border);
  border-radius: 8px;
  padding: 14px;
}

.line-card h3 {
  margin: 0 0 6px;
}

.line-card p {
  margin: 3px 0;
}

.line-card.is-blocked {
  border-color: #f5b7ae;
  background: #fff8f7;
}

.line-card.is-no-instance {
  border-color: #f2de8a;
  background: #fffdf6;
}

.muted {
  color: var(--mvzap-muted);
}

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

.call-actions {
  min-width: 340px;
}

.call-actions button {
  margin: 2px;
  padding: 7px 9px;
}

.call-actions button[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

.action-status {
  display: inline-block;
  min-width: 120px;
  color: var(--mvzap-primary-strong);
  font-weight: 700;
}

.table-wrap {
  margin-top: 12px;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

tbody tr:hover {
  background: #f8fbfe;
}

th {
  color: var(--mvzap-muted);
  font-size: 12px;
  text-transform: uppercase;
}

.call-status-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 10px;
  border: 1px solid var(--mvzap-border);
  background: #eef4fc;
  color: #27425f;
  font-size: 12px;
  font-weight: 700;
}

.call-status-badge.status-active,
.call-status-badge.status-answered {
  background: #e7f8ef;
  border-color: #b7ebc7;
  color: #1e7a42;
}

.call-status-badge.status-ringing,
.call-status-badge.status-incoming-ring,
.call-status-badge.status-calling,
.call-status-badge.status-dialing {
  background: #e8f2ff;
  border-color: #c8defd;
  color: #1f5da8;
}

.call-status-badge.status-failed,
.call-status-badge.status-failed-no-ring {
  background: #fdeeee;
  border-color: #f8c9c9;
  color: #b42318;
}

.call-status-badge.status-ended,
.call-status-badge.status-rejected,
.call-status-badge.status-not-answered {
  background: #f3f4f7;
  border-color: #d9dee9;
  color: #4e5d73;
}

textarea {
  width: 100%;
  min-height: 220px;
  border: 1px solid var(--mvzap-border);
  border-radius: 8px;
  padding: 12px;
  resize: vertical;
  background: #fbfdff;
  color: var(--mvzap-text);
}

@media (max-width: 860px) {
  .auth-shell,
  .layout,
  .form-grid,
  .instance-grid,
  .ops-grid,
  .toolbar-grid,
  .admin-metrics {
    grid-template-columns: 1fr;
  }

  .topbar,
  .line-card {
    flex-direction: column;
  }
}
