:root {
  --bg: #f4efe8;
  --paper: rgba(255, 251, 245, 0.94);
  --ink: #17212b;
  --muted: #61707d;
  --line: #d8cfbf;
  --accent: #1f5c74;
  --accent-strong: #153f50;
  --accent-soft: #dcecf3;
  --danger: #a64f43;
  --success: #3d7052;
  --warn: #b68d4a;
  --shadow: 0 18px 40px rgba(23, 33, 43, 0.1);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(31, 92, 116, 0.12), transparent 24%),
    radial-gradient(circle at top right, rgba(194, 111, 69, 0.14), transparent 22%),
    linear-gradient(180deg, #f9f6f1 0%, #efe7da 100%);
}

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

.waha-shell {
  width: min(1640px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 14px 0 18px;
  display: grid;
  gap: 12px;
}

.channels-dashboard,
.provider-detail-stack {
  display: grid;
  gap: 12px;
}

.waha-topbar,
.panel,
.provider-card,
.service-item,
.session-card,
.qr-card {
  border: 1px solid rgba(216, 207, 191, 0.84);
  background: rgba(255, 253, 248, 0.92);
  box-shadow: var(--shadow);
}

.waha-topbar,
.panel,
.provider-card {
  border-radius: 20px;
  padding: 16px;
}

.waha-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.waha-kicker,
.panel-kicker {
  margin: 0 0 6px;
  color: var(--accent);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 11px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(30px, 3vw, 40px);
  line-height: 0.98;
}

h2 {
  font-size: 24px;
  line-height: 1.04;
}

.waha-lead {
  margin-top: 8px;
  max-width: 760px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.waha-topbar-actions,
.provider-card-footer,
.provider-detail-actions,
.service-actions,
.form-actions,
.session-actions,
.session-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.waha-layout {
  display: grid;
  grid-template-columns: minmax(340px, 420px) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.provider-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.provider-card {
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.provider-card:hover {
  transform: translateY(-2px);
  border-color: rgba(31, 92, 116, 0.42);
}

.provider-card.selected {
  border-color: rgba(31, 92, 116, 0.62);
  box-shadow: 0 22px 44px rgba(21, 63, 80, 0.14);
}

.provider-card-top,
.provider-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.provider-card-kicker {
  margin: 0 0 6px;
  color: var(--accent);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 11px;
}

.provider-card-title {
  margin: 0;
  font-size: 24px;
  line-height: 1.04;
}

.provider-card-copy,
.provider-placeholder-copy,
.provider-empty-copy {
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.provider-card-footer {
  margin-top: 18px;
  align-items: center;
  justify-content: space-between;
}

.provider-card-meta,
.provider-card-link {
  font-size: 13px;
}

.provider-card-meta {
  color: var(--muted);
}

.provider-card-link {
  color: var(--accent-strong);
  font-weight: 700;
}

.provider-detail-stack {
  min-width: 0;
}

.provider-detail-empty,
.provider-placeholder-panel {
  min-height: 220px;
}

.provider-placeholder-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}

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

.waha-column {
  display: grid;
  gap: 12px;
}

.waha-column.wide {
  min-width: 0;
}

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

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

.provider-detail[hidden] {
  display: none;
}

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

.service-item {
  border-radius: 16px;
  padding: 10px 12px;
}

.service-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.service-item strong {
  display: block;
  margin-top: 4px;
  font-size: 16px;
  line-height: 1.2;
}

.settings-form {
  display: grid;
  gap: 10px;
}

.meta-settings-form {
  gap: 12px;
}

.meta-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 12px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
}

.field textarea {
  min-height: 112px;
  resize: vertical;
}

.field input[readonly] {
  background: rgba(220, 236, 243, 0.5);
  color: var(--accent-strong);
}

.meta-account-card {
  display: grid;
  gap: 12px;
}

.meta-issue-list {
  display: grid;
  gap: 8px;
}

.meta-issue {
  border-radius: 14px;
  border: 1px solid rgba(182, 141, 74, 0.24);
  background: rgba(182, 141, 74, 0.12);
  padding: 10px 12px;
  display: grid;
  gap: 4px;
}

.meta-issue.error {
  border-color: rgba(166, 79, 67, 0.24);
  background: rgba(166, 79, 67, 0.1);
}

.meta-issue strong {
  font-size: 13px;
  line-height: 1.2;
}

.meta-issue span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.panel-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.ghost-button,
.primary-button {
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  transition: transform 0.16s ease, opacity 0.16s ease;
  font-size: 13px;
}

.ghost-button {
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
}

.ghost-button.danger {
  color: var(--danger);
}

.primary-button {
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  font-weight: 700;
}

.ghost-button:hover,
.primary-button:hover {
  transform: translateY(-1px);
}

.ghost-button:disabled,
.primary-button:disabled {
  opacity: 0.7;
  cursor: wait;
  transform: none;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(23, 33, 43, 0.06);
  color: var(--ink);
}

.status-pill.working {
  background: rgba(61, 112, 82, 0.15);
  color: var(--success);
}

.status-pill.warning {
  background: rgba(182, 141, 74, 0.18);
  color: #72531b;
}

.status-pill.error {
  background: rgba(166, 79, 67, 0.15);
  color: var(--danger);
}

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

.session-card {
  border-radius: 18px;
  padding: 14px;
}

.session-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.session-title {
  font-size: 22px;
  line-height: 1.06;
}

.session-subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.session-meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.connection-state {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(216, 207, 191, 0.72);
  background: rgba(255, 255, 255, 0.72);
  display: grid;
  gap: 4px;
}

.connection-state strong {
  font-size: 14px;
  line-height: 1.2;
}

.connection-state span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.connection-state.connected {
  background: rgba(61, 112, 82, 0.12);
  border-color: rgba(61, 112, 82, 0.24);
}

.connection-state.waiting {
  background: rgba(182, 141, 74, 0.12);
  border-color: rgba(182, 141, 74, 0.28);
}

.session-meta-card {
  border-radius: 14px;
  border: 1px solid rgba(216, 207, 191, 0.72);
  background: rgba(255, 255, 255, 0.76);
  padding: 10px 12px;
}

.session-meta-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.session-meta-card strong {
  display: block;
  margin-top: 3px;
  font-size: 15px;
  line-height: 1.25;
  word-break: break-word;
}

.qr-card {
  margin-top: 12px;
  border-radius: 16px;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.viewer-inline-card {
  margin-top: 12px;
  padding: 12px;
  border-radius: 18px;
  border: 1px solid rgba(216, 207, 191, 0.8);
  background: rgba(255, 255, 255, 0.78);
  display: grid;
  gap: 12px;
}

.viewer-inline-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.viewer-preview-image {
  width: 100%;
  border: 1px solid rgba(216, 207, 191, 0.9);
  border-radius: 18px;
  background: #111;
  object-fit: contain;
}

.qr-image {
  width: min(280px, 100%);
  aspect-ratio: 1;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: white;
  object-fit: contain;
  padding: 10px;
}

.session-hint,
.empty-state {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.empty-state {
  padding: 18px;
  border-radius: 18px;
  border: 1px dashed rgba(31, 92, 116, 0.24);
  background: rgba(255, 255, 255, 0.56);
}

@media (max-width: 1120px) {
  .provider-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .waha-layout {
    grid-template-columns: 1fr;
  }

  .provider-placeholder-list,
  .service-grid,
  .session-meta-grid,
  .meta-form-grid {
    grid-template-columns: 1fr;
  }
}

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

  .provider-card-footer,
  .provider-detail-actions,
  .provider-detail-head,
  .viewer-inline-head,
  .waha-topbar {
    flex-direction: column;
    align-items: stretch;
  }

}
