:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #2563eb;
  --dark: #0f172a;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --shadow: 0 10px 30px rgba(15, 23, 42, .08);
  --r: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  cursor: pointer;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 20% 20%, rgba(37, 99, 235, .15), transparent 35%), var(--bg);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 30px;
  box-shadow: var(--shadow);
}

.logo {
  width: 52px;
  height: 52px;
  border-radius: 18px;
  background: var(--primary);
  color: #ffffff;
  display: grid;
  place-items: center;
  font-weight: 900;
  margin-bottom: 18px;
}

.login-card h1 {
  margin: 0;
  font-size: 28px;
}

.login-card p {
  color: var(--muted);
  line-height: 1.5;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.field label {
  font-weight: 800;
}

.field small {
  color: var(--muted);
  line-height: 1.4;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 14px;
  background: #ffffff;
  outline: none;
  color: var(--text);
}

.field textarea {
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .1);
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 270px 1fr;
}

.side {
  background: var(--dark);
  color: #ffffff;
  padding: 24px;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 30px;
  color: #ffffff;
}

.brand:hover {
  text-decoration: none;
}

.brand .logo {
  width: 44px;
  height: 44px;
  margin: 0;
  border-radius: 15px;
}

.brand b {
  font-size: 18px;
}

.brand span {
  display: block;
  color: #94a3b8;
  font-size: 13px;
  margin-top: 2px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav a {
  width: 100%;
  text-align: left;
  background: transparent;
  color: #cbd5e1;
  padding: 12px 14px;
  border-radius: 14px;
  font-weight: 800;
}

.nav a.active,
.nav a:hover {
  background: rgba(255, 255, 255, .1);
  color: #ffffff;
  text-decoration: none;
}

.note {
  margin-top: auto;
  color: #94a3b8;
  font-size: 13px;
  line-height: 1.5;
  border-top: 1px solid rgba(255, 255, 255, .1);
  padding-top: 18px;
}

.main {
  padding: 28px;
  max-width: 1360px;
  width: 100%;
}

.top {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.top h1 {
  margin: 0;
  font-size: 30px;
}

.top p {
  margin: 8px 0 0;
  color: var(--muted);
}

.user {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 14px;
  color: var(--muted);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 4px;
  height: max-content;
}

.user form {
  margin: 0;
}

.user button {
  border: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 900;
  padding: 0;
}

.cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.card,
.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: 0 8px 24px rgba(15, 23, 42, .04);
  padding: 22px;
}

.stat-label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.stat {
  font-size: 34px;
  font-weight: 900;
  margin-top: 8px;
}

.green {
  color: var(--green);
}

.red {
  color: var(--red);
}

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

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 20px;
}

.grid-settings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.btn,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
  padding: 11px 16px;
  border-radius: 12px;
  font-weight: 900;
  gap: 8px;
}

.btn:hover,
button:hover {
  text-decoration: none;
}

.btn:disabled,
button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.btn.is-loading,
button.is-loading {
  position: relative;
  pointer-events: none;
}

.btn.is-loading::before,
button.is-loading::before {
  content: "";
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 999px;
  animation: spin .75s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.btn.primary,
button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.btn.ghost,
button.ghost {
  background: transparent;
}

.btn.red,
button.red {
  background: var(--red);
  border-color: var(--red);
  color: #ffffff;
}

.actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

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

.table th,
.table td {
  padding: 14px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
  vertical-align: top;
}

.table th {
  color: var(--muted);
}

.badge {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  background: #e5e7eb;
  color: #374151;
}

.badge.completed {
  background: #dcfce7;
  color: #166534;
}

.badge.failed {
  background: #fee2e2;
  color: #991b1b;
}

.badge.running,
.badge.queued {
  background: #dbeafe;
  color: #1d4ed8;
}

.badge.no_answer {
  background: #f3f4f6;
  color: #4b5563;
}

.form-card {
  max-width: 880px;
}

.form-section {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 18px;
  background: #f8fafc;
}

.form-section h2 {
  margin: 0;
  font-size: 20px;
}

.form-section p {
  color: var(--muted);
  line-height: 1.5;
  margin: 6px 0 16px;
}

.inline-fields {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.check {
  display: flex;
  gap: 12px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 18px;
  line-height: 1.4;
}

.check input {
  margin-top: 3px;
}

.agents {
  display: grid;
  gap: 16px;
}

.agent-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

.agent-card p,
.card p {
  color: var(--muted);
  line-height: 1.5;
}

.hint {
  background: #eff6ff;
  color: #1e40af;
  border-radius: 16px;
  padding: 14px 16px;
  line-height: 1.5;
}

.advanced {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: #f8fafc;
}

.advanced summary {
  cursor: pointer;
  font-weight: 900;
  color: var(--muted);
}

.advanced .field {
  margin: 14px 0 0;
}

.connection-status {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.connection-status div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
}

.connection-status span {
  color: var(--muted);
  font-weight: 800;
}

.provision-log {
  margin-top: 18px;
  max-height: 260px;
}

.warn {
  margin-top: 18px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  border-radius: 16px;
  padding: 14px 16px;
  line-height: 1.5;
}

.flash {
  margin-bottom: 18px;
  background: #ecfdf5;
  border: 1px solid #bbf7d0;
  color: #166534;
  border-radius: 16px;
  padding: 14px 16px;
}

.danger {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.summary {
  white-space: pre-wrap;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  line-height: 1.55;
  color: #334155;
  overflow: auto;
}

.split {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 18px;
}

.kv {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px 16px;
  font-size: 14px;
}

.kv div:nth-child(odd) {
  color: var(--muted);
  font-weight: 900;
}

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

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

pre {
  margin: 0;
}

@media (max-width: 950px) {
  .app {
    grid-template-columns: 1fr;
  }

  .side {
    gap: 18px;
  }

  .note {
    margin-top: 0;
  }

  .cards,
  .grid2,
  .grid-settings,
  .inline-fields,
  .split {
    grid-template-columns: 1fr;
  }

  .top,
  .agent-card {
    flex-direction: column;
  }

  .main {
    padding: 18px;
  }
}
