*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue:    #2563eb;
  --blue-d:  #1d4ed8;
  --blue-l:  #eff6ff;
  --blue-m:  #bfdbfe;
  --sky:     #e0f2fe;
  --sky-b:   #0ea5e9;
  --green:   #16a34a;
  --green-l: #f0fdf4;
  --green-b: #bbf7d0;
  --red:     #dc2626;
  --red-l:   #fef2f2;
  --red-b:   #fecaca;
  --amber:   #d97706;
  --amber-l: #fffbeb;
  --white:   #ffffff;
  --gray-0:  #f8fafc;
  --gray-1:  #f1f5f9;
  --gray-b:  #e2e8f0;
  --gray-t:  #64748b;
  --gray-d:  #1e293b;
  --radius:  10px;
  --page-bg: #f0f9ff;
}

body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--page-bg);
  color: var(--gray-d);
  font-size: 14px;
  line-height: 1.6;
}

/* ── Nav ── */
.nav {
  background: var(--white);
  border-bottom: 1px solid var(--gray-b);
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.nav-icon {
  width: 36px; height: 36px; background: var(--blue);
  border-radius: 9px; display: flex; align-items: center;
  justify-content: center; color: #fff; font-size: 19px;
}
.nav-name { font-size: 15px; font-weight: 700; color: var(--gray-d); }
.nav-right { display: flex; align-items: center; gap: 12px; }
.nav-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--blue-l); color: var(--blue-d);
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.nav-username { font-size: 13px; font-weight: 500; color: var(--gray-d); }
.nav-plan {
  background: var(--blue-l); color: var(--blue-d);
  font-size: 11px; font-weight: 600;
  padding: 3px 10px; border-radius: 20px;
  border: 1px solid var(--blue-m);
}
.nav-signout {
  font-size: 13px; color: var(--gray-t);
  background: none; border: 1px solid var(--gray-b);
  padding: 5px 12px; border-radius: 7px;
  cursor: pointer; text-decoration: none;
  transition: background .15s;
}
.nav-signout:hover { background: var(--gray-0); }

/* ── Page wrapper ── */
.page { max-width: 960px; margin: 0 auto; padding: 28px 20px; }

/* ── Alerts ── */
.alert {
  border-radius: 10px; padding: 12px 16px;
  font-size: 13px; margin-bottom: 18px;
  display: flex; align-items: center; gap: 8px;
}
.alert-success { background: var(--green-l); border: 1px solid var(--green-b); color: var(--green); }
.alert-error   { background: var(--red-l);   border: 1px solid var(--red-b);   color: var(--red); }
.alert-info    { background: var(--blue-l);  border: 1px solid var(--blue-m);  color: var(--blue-d); }

/* ── WA Banner ── */
.wa-banner {
  background: var(--white); border-radius: 12px;
  padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 20px;
}
.wa-banner.connected    { border: 1px solid var(--green-b); }
.wa-banner.disconnected { border: 1px solid #fed7aa; background: #fff7ed; }
.wa-banner.not_started  { border: 1px solid var(--blue-m); background: var(--blue-l); }
.wa-left { display: flex; align-items: center; gap: 12px; }
.wa-dot  { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.wa-dot.on  { background: var(--green); }
.wa-dot.off { background: #f97316; animation: blink 1.4s ease-in-out infinite; }
.wa-dot.idle { background: var(--blue); }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.3} }
.wa-text strong { font-size: 14px; font-weight: 600; display: block; color: var(--gray-d); }
.wa-text span   { font-size: 12px; color: var(--gray-t); }
.wa-btn {
  padding: 7px 16px; border-radius: 8px; font-size: 13px;
  font-weight: 500; cursor: pointer; text-decoration: none;
  border: none; transition: background .15s;
}
.wa-btn.primary { background: var(--blue); color: #fff; }
.wa-btn.primary:hover { background: var(--blue-d); }
.wa-btn.ghost   { background: var(--white); color: var(--gray-t); border: 1px solid var(--gray-b); }
.wa-btn.ghost:hover { background: var(--gray-0); }

/* ── Stats grid ── */
.stats { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; margin-bottom: 16px; }
.stat-card {
  background: var(--white); border: 1px solid var(--gray-b);
  border-radius: 12px; padding: 16px 18px;
}
.stat-label {
  font-size: 11px; color: var(--gray-t); font-weight: 600;
  letter-spacing: .4px; text-transform: uppercase; margin-bottom: 8px;
}
.stat-value { font-size: 30px; font-weight: 700; color: var(--gray-d); line-height: 1; }
.stat-sub   { font-size: 11px; color: var(--gray-t); margin-top: 5px; }
.stat-value.green { color: var(--green); }
.stat-value.red   { color: var(--red); }

/* ── Usage bar ── */
.usage-card {
  background: var(--white); border: 1px solid var(--gray-b);
  border-radius: 12px; padding: 16px 20px; margin-bottom: 24px;
}
.usage-row {
  display: flex; justify-content: space-between;
  font-size: 13px; margin-bottom: 10px;
}
.usage-row .label { font-weight: 500; color: var(--gray-d); }
.usage-row .value { color: var(--gray-t); }
.usage-track { background: var(--gray-b); border-radius: 4px; height: 7px; overflow: hidden; }
.usage-fill  { height: 100%; background: var(--blue); border-radius: 4px; transition: width .4s; }
.usage-fill.warning { background: var(--amber); }
.usage-fill.danger  { background: var(--red); }

/* ── Section header ── */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.section-title { font-size: 15px; font-weight: 600; color: var(--gray-d); }

/* ── Send panel ── */
.send-card {
  background: var(--white); border: 1px solid var(--gray-b);
  border-radius: 12px; padding: 20px; margin-bottom: 28px;
}
.send-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 11px; font-weight: 600; color: var(--gray-t); text-transform: uppercase; letter-spacing: .4px; }
input.field, textarea.field, select.field {
  border: 1px solid var(--gray-b); border-radius: 8px;
  padding: 9px 12px; font-size: 13px; color: var(--gray-d);
  background: var(--white); outline: none; font-family: inherit;
  transition: border-color .15s;
}
input.field:focus, textarea.field:focus, select.field:focus { border-color: var(--blue); }
textarea.field { resize: vertical; min-height: 90px; }
.char-count { font-size: 11px; color: var(--gray-t); text-align: right; margin-top: 4px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px; font-size: 13px;
  font-weight: 500; cursor: pointer; border: none;
  font-family: inherit; transition: background .15s; text-decoration: none;
}
.btn-primary   { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-d); }
.btn-send      { background: var(--blue); color: #fff; width: 100%; justify-content: center; font-weight: 600; padding: 10px; }
.btn-send:hover { background: var(--blue-d); }
.btn-ghost     { background: var(--white); color: var(--gray-t); border: 1px solid var(--gray-b); }
.btn-ghost:hover { background: var(--gray-0); }
.btn-danger    { background: var(--red-l); color: var(--red); border: 1px solid var(--red-b); }
.btn-danger:hover { background: #fee2e2; }

/* ── API Key cards ── */
.key-card {
  background: var(--white); border: 1px solid var(--gray-b);
  border-radius: 12px; padding: 16px 20px;
  display: flex; align-items: center; gap: 14px; margin-bottom: 10px;
}
.key-icon {
  width: 40px; height: 40px; border-radius: 9px;
  background: var(--blue-l); color: var(--blue);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.key-info { flex: 1; min-width: 0; }
.key-label { font-size: 13px; font-weight: 600; color: var(--gray-d); margin-bottom: 5px; }
.key-value {
  font-family: 'Courier New', monospace; font-size: 12px;
  color: var(--blue-d); background: var(--blue-l);
  border: 1px solid var(--blue-m); border-radius: 7px;
  padding: 6px 12px; cursor: pointer; user-select: all;
  word-break: break-all; display: block;
  transition: background .15s;
}
.key-value:hover { background: var(--blue-m); }
.key-meta { font-size: 11px; color: var(--gray-t); margin-top: 5px; }
.key-actions { display: flex; gap: 8px; flex-shrink: 0; }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 7px; }

/* ── Code snippet ── */
.code-tabs { display: flex; gap: 4px; margin-bottom: 10px; }
.code-tab {
  font-size: 12px; padding: 5px 14px; border-radius: 6px;
  border: 1px solid var(--gray-b); background: var(--white);
  cursor: pointer; color: var(--gray-t); transition: all .15s;
}
.code-tab.active { background: var(--blue-l); color: var(--blue-d); border-color: var(--blue-m); }
.code-box {
  background: #0f172a; border-radius: 10px; padding: 18px 20px;
  font-family: 'Courier New', monospace; font-size: 12px;
  color: #94a3b8; overflow-x: auto; line-height: 1.8;
}
.code-box .kw  { color: #38bdf8; }
.code-box .str { color: #a78bfa; }
.code-box .val { color: #34d399; }
.code-box .cm  { color: #475569; }

/* ── Auth pages ── */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center;
  justify-content: center; padding: 2rem 1rem;
  background: linear-gradient(135deg, #e0f2fe 0%, #f0f9ff 50%, #eff6ff 100%);
}
.auth-card {
  background: var(--white); border: 1px solid var(--gray-b);
  border-radius: 16px; padding: 2.5rem 2rem;
  width: 100%; box-shadow: 0 4px 24px rgba(37,99,235,.08);
}
.auth-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 2rem; }
.auth-logo-icon {
  width: 40px; height: 40px; background: var(--blue);
  border-radius: 10px; display: flex; align-items: center;
  justify-content: center; font-size: 22px;
}
.auth-logo-text .name { font-size: 16px; font-weight: 700; color: var(--gray-d); }
.auth-logo-text .sub  { font-size: 11px; color: var(--gray-t); }
.auth-card h1 { font-size: 22px; font-weight: 700; margin-bottom: 6px; color: var(--gray-d); }
.auth-card .subtitle { font-size: 13px; color: var(--gray-t); margin-bottom: 2rem; }
.auth-field { margin-bottom: 1rem; }
.auth-field label { display: block; font-size: 12px; font-weight: 600; color: var(--gray-t); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .4px; }
.field-error { color: var(--red); font-size: 11px; margin-top: 4px; display: block; }
.auth-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.btn-auth {
  width: 100%; background: var(--blue); color: #fff;
  border: none; border-radius: 9px; padding: 12px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  margin-top: .5rem; transition: background .15s;
}
.btn-auth:hover { background: var(--blue-d); }
.auth-footer { text-align: center; margin-top: 1.5rem; font-size: 13px; color: var(--gray-t); }
.auth-footer a { color: var(--blue); text-decoration: none; font-weight: 500; }
.divider { border: none; border-top: 1px solid var(--gray-b); margin: 1.5rem 0; }

/* ── QR page ── */
.qr-wrap {
  min-height: 100vh; display: flex; flex-direction: column;
  background: var(--page-bg);
}
.qr-page { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 20px; }
.qr-card {
  background: var(--white); border: 1px solid var(--gray-b);
  border-radius: 16px; padding: 2.5rem 2rem;
  width: 100%; max-width: 440px; text-align: center;
  box-shadow: 0 4px 24px rgba(37,99,235,.06);
}
.qr-card h1 { font-size: 20px; font-weight: 700; margin-bottom: 8px; color: var(--gray-d); }
.qr-card .subtitle { font-size: 13px; color: var(--gray-t); margin-bottom: 1.5rem; line-height: 1.6; }
.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 20px; padding: 5px 14px; font-size: 12px;
  font-weight: 600; margin-bottom: 1.5rem; border: 1px solid;
}
.pill-waiting { background: var(--amber-l); color: var(--amber); border-color: #fde68a; }
.pill-qr      { background: var(--blue-l);  color: var(--blue-d); border-color: var(--blue-m); }
.pill-ok      { background: var(--green-l); color: var(--green);  border-color: var(--green-b); }
.pill-err     { background: var(--red-l);   color: var(--red);    border-color: var(--red-b); }
.pill-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill-dot.pulse { animation: blink 1.4s ease-in-out infinite; }
.qr-img-box {
  background: var(--white); border: 3px solid var(--blue-m);
  border-radius: 14px; padding: 14px; display: inline-block; margin-bottom: 1.5rem;
}
.qr-img-box img { display: block; width: 220px; height: 220px; border-radius: 6px; }
.qr-placeholder {
  width: 220px; height: 220px; border-radius: 8px;
  background: var(--gray-1); border: 2px dashed var(--gray-b);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1.5rem; color: var(--gray-t); font-size: 13px;
}
.spinner {
  width: 36px; height: 36px; border: 3px solid var(--blue-m);
  border-top-color: var(--blue); border-radius: 50%;
  animation: spin .8s linear infinite; margin: 0 auto 1.5rem;
}
@keyframes spin { to { transform: rotate(360deg); } }
.qr-connected {
  background: var(--green-l); border: 1px solid var(--green-b);
  border-radius: 12px; padding: 20px; margin-bottom: 1.5rem;
}
.qr-phone { font-size: 24px; font-weight: 700; color: var(--green); margin-bottom: 4px; }
.qr-name  { font-size: 13px; color: var(--gray-t); }
.qr-steps {
  background: var(--gray-1); border-radius: 10px;
  padding: 16px; margin-bottom: 1.5rem; text-align: left;
}
.qr-step { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 10px; font-size: 13px; color: var(--gray-t); }
.qr-step:last-child { margin-bottom: 0; }
.step-num {
  width: 22px; height: 22px; border-radius: 50%; background: var(--blue);
  color: #fff; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px;
}
.qr-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ── Empty state ── */
.empty { background: var(--white); border: 1px solid var(--gray-b); border-radius: 12px; padding: 40px; text-align: center; }
.empty-icon { font-size: 36px; margin-bottom: 12px; }
.empty h3 { font-size: 15px; font-weight: 600; color: var(--gray-d); margin-bottom: 6px; }
.empty p  { font-size: 13px; color: var(--gray-t); }

/* ── Responsive ── */
@media(max-width:640px) {
  .stats    { grid-template-columns: 1fr 1fr; }
  .send-row { grid-template-columns: 1fr; }
  .auth-row2 { grid-template-columns: 1fr; }
  .nav      { padding: 0 16px; }
  .page     { padding: 20px 14px; }
  .key-card { flex-direction: column; align-items: flex-start; }
  .key-actions { width: 100%; }
}
</style>
