/* WhatsApp Session Management UI - design system */
:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --border: #e8eaee;
  --border-strong: #dcdfe5;
  --fg: #12161c;
  --muted: #6b7280;
  --muted-2: #9aa1ac;
  --green: #16a34a;
  --green-soft: #e8f7ee;
  --amber: #d97706;
  --amber-soft: #fdf3e3;
  --red: #dc2626;
  --red-soft: #fdecec;
  --slate: #475569;
  --slate-soft: #f1f3f6;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.04);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }

/* Layout */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar-inner {
  max-width: 1140px; margin: 0 auto; padding: 14px 20px;
  display: flex; align-items: center; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--green-soft); color: var(--green);
  display: grid; place-items: center;
}
.topnav { margin-left: auto; display: flex; gap: 4px; }
.topnav a {
  padding: 7px 12px; border-radius: 9px; color: var(--muted); font-weight: 550;
}
.topnav a:hover { background: var(--slate-soft); color: var(--fg); }
.topnav a.active { background: var(--slate-soft); color: var(--fg); }

.page { max-width: 1140px; margin: 0 auto; padding: 28px 20px 64px; }
.page-head { margin-bottom: 22px; display: flex; align-items: flex-start; gap: 12px; }
.page-head h1 { font-size: 22px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-head { padding: 18px 20px; border-bottom: 1px solid var(--border); }
.card-head h2 { font-size: 15.5px; }
.card-head p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.card-body { padding: 20px; }
.card-foot { padding: 16px 20px; border-top: 1px solid var(--border); }

/* Info rows */
.rows { display: grid; gap: 2px; }
.row {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 11px 0; border-bottom: 1px dashed var(--border);
}
.row:last-child { border-bottom: 0; }
.row .k { color: var(--muted); }
.row .v { font-weight: 600; text-align: right; }

/* Badge */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 650; border: 1px solid transparent;
  white-space: nowrap;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-green { background: var(--green-soft); color: var(--green); border-color: #cdeedb; }
.badge-amber { background: var(--amber-soft); color: var(--amber); border-color: #f6e3c2; }
.badge-red { background: var(--red-soft); color: var(--red); border-color: #f7d4d4; }
.badge-slate { background: var(--slate-soft); color: var(--slate); border-color: var(--border-strong); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 15px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--fg);
  font: inherit; font-weight: 600; cursor: pointer;
  transition: background .12s ease, border-color .12s ease, opacity .12s ease;
}
.btn:hover { background: #f4f5f7; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-primary:hover { background: #12904015; background: #128f40; }
.btn-danger { background: #fff; border-color: #f0c9c9; color: var(--red); }
.btn-danger:hover { background: var(--red-soft); }
.btn-danger-solid { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger-solid:hover { background: #c11f1f; }
.btn-block { width: 100%; }
.btn-icon { padding: 8px; width: 36px; height: 36px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* Forms */
.field { margin-bottom: 18px; }
.label { display: block; font-weight: 600; margin-bottom: 6px; }
.hint { color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.input, .select {
  width: 100%; padding: 10px 12px; font: inherit; color: var(--fg);
  background: #fff; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  outline: none;
}
.input:focus, .select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(22,163,74,.12); }
.input-group { display: grid; grid-template-columns: 150px 1fr; gap: 10px; }
@media (max-width: 560px) { .input-group { grid-template-columns: 1fr; } }
.check {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  margin-bottom: 12px;
}
.check input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--green); }
.check .t { font-weight: 600; }
.check .d { color: var(--muted); font-size: 12.5px; }
.error-text { color: var(--red); font-size: 12.5px; margin-top: 6px; }

/* Activity */
.activity { display: grid; gap: 10px; }
.activity-item {
  display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: start;
  padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.activity-icon {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
}
.ic-green { background: var(--green-soft); color: var(--green); }
.ic-amber { background: var(--amber-soft); color: var(--amber); }
.ic-red { background: var(--red-soft); color: var(--red); }
.ic-slate { background: var(--slate-soft); color: var(--slate); }
.activity-title { font-weight: 650; }
.activity-desc { color: var(--muted); font-size: 13px; }
.activity-time { color: var(--muted-2); font-size: 12px; margin-top: 6px; }
@media (max-width: 520px) {
  .activity-item { grid-template-columns: 34px 1fr; }
  .activity-item .badge { grid-column: 2; justify-self: start; }
}

/* Empty state */
.empty { text-align: center; padding: 34px 16px; }
.empty-icon {
  width: 52px; height: 52px; border-radius: 16px; margin: 0 auto 14px;
  background: var(--slate-soft); color: var(--muted); display: grid; place-items: center;
}
.empty h3 { font-size: 15px; }
.empty p { color: var(--muted); margin: 6px 0 18px; }

/* QR */
.qr-wrap { text-align: center; padding: 8px 0 4px; }
.qr-box {
  width: 264px; height: 264px; margin: 0 auto; padding: 12px;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  display: grid; place-items: center;
}
.qr-box canvas, .qr-box img { width: 100% !important; height: 100% !important; display: block; }
.steps { color: var(--muted); margin: 18px auto 0; max-width: 380px; }
.steps b { color: var(--fg); }
.status-line {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 16px;
  color: var(--muted); font-weight: 550;
}
.success-state { text-align: center; padding: 26px 10px; }
.success-icon {
  width: 66px; height: 66px; border-radius: 50%; margin: 0 auto 16px;
  background: var(--green-soft); color: var(--green); display: grid; place-items: center;
}

/* Spinner + skeleton */
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(0,0,0,.12); border-top-color: var(--green);
  animation: spin .7s linear infinite; display: inline-block;
}
.spinner-lg { width: 30px; height: 30px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }
.skel { background: #eef0f3; border-radius: 8px; height: 14px; animation: pulse 1.2s ease-in-out infinite; }
.skel.lg { height: 22px; }
.skel.block { height: 64px; border-radius: 10px; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .55 } }
.skel-stack { display: grid; gap: 12px; }

/* Toasts */
.toasts {
  position: fixed; top: 18px; right: 18px; z-index: 100;
  display: grid; gap: 10px; width: min(340px, calc(100vw - 36px));
}
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--slate);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
  padding: 12px 14px; display: grid; grid-template-columns: 20px 1fr 18px; gap: 10px;
}
.toast.success { border-left-color: var(--green); }
.toast.error { border-left-color: var(--red); }
.toast.info { border-left-color: var(--slate); }
.toast .tt { font-weight: 650; }
.toast .td { color: var(--muted); font-size: 12.5px; }
.toast .tx { background: none; border: 0; color: var(--muted-2); cursor: pointer; font-size: 15px; line-height: 1; }

/* Dialog */
.overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .38);
  display: grid; place-items: center; padding: 20px; z-index: 90;
}
.dialog {
  background: #fff; border-radius: var(--radius); width: min(420px, 100%);
  box-shadow: 0 24px 60px rgba(16,24,40,.18); padding: 22px;
}
.dialog h3 { font-size: 16px; }
.dialog p { color: var(--muted); margin: 8px 0 20px; }
.dialog .btn-row { justify-content: flex-end; }
.hidden { display: none !important; }
.text-muted { color: var(--muted); }
.mt-16 { margin-top: 16px; }

/* Auth page + vendor chip */
.auth-body { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.auth-shell { width: min(420px, 100%); }
.auth-card { padding: 28px; }
.auth-head { text-align: center; margin-bottom: 22px; }
.auth-head h1 { font-size: 20px; margin-top: 14px; }
.auth-head p { color: var(--muted); margin: 6px 0 0; }
.brand-mark-lg { width: 44px; height: 44px; border-radius: 13px; margin: 0 auto; }
.auth-foot { font-size: 12.5px; text-align: center; margin: 18px 0 0; }
.vendor-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px; border: 1px solid var(--border); border-radius: 999px;
  font-weight: 600; max-width: 200px;
}
.vendor-avatar {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: var(--green-soft); color: var(--green); font-size: 12px; font-weight: 700;
}
.vendor-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: 14px; }
@media (max-width: 560px) { .vendor-name { display: none; } }
