* { box-sizing: border-box; }
html { color-scheme: light; }

:root {
  --accent: #4f46e5;
  --accent-dark: #3730a3;
  --ink: #1c2733;
  --muted: #64748b;
  --border: #e2e8f0;
  --bg: #f1f4f9;
  --surface: #ffffff;
  --radius: 10px;
}

body {
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

header {
  background: linear-gradient(135deg, #1c2733 0%, #101820 100%);
  color: #fff;
  padding: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.header-inner { max-width: 1000px; margin: 0 auto; padding: 20px 24px; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-icon {
  font-size: 26px; width: 44px; height: 44px; display: flex; align-items: center;
  justify-content: center; background: rgba(255,255,255,0.08); border-radius: 10px;
}
header h1 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: 0.2px; }
.tagline { margin: 2px 0 0; font-size: 12px; color: #9aa5b1; letter-spacing: 0.5px; text-transform: uppercase; }

main { max-width: 1000px; margin: 28px auto 60px; padding: 0 16px; }

.tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background-color: #ffffff !important;
  color: #33404d !important;
  border: 1px solid var(--border);
  padding: 10px 18px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.tab-btn:hover { background-color: #f8fafc !important; }
.tab-btn.active {
  background-color: var(--accent) !important;
  color: #ffffff !important;
  border-color: var(--accent);
  box-shadow: 0 2px 6px rgba(79,70,229,0.35);
}
.tab-icon { font-size: 15px; }

.tab-panel {
  display: none;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(16,24,40,0.04);
}
.tab-panel.active { display: block; }

h2 { margin: 0 0 4px; font-size: 17px; font-weight: 600; }
.hint { color: var(--muted); font-size: 13px; margin: 0 0 22px; line-height: 1.5; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 22px; }
.form-grid label {
  display: flex; flex-direction: column; font-size: 12.5px; gap: 6px;
  color: #475569; font-weight: 600; letter-spacing: 0.1px;
}
.form-grid input {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 7px;
  font-size: 14px; color: var(--ink); background: #fff; font-weight: 400;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-grid input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
}
.actions { grid-column: 1 / -1; display: flex; gap: 10px; margin-top: 8px; }

.input-with-icons { position: relative; display: flex; }
.input-with-icons input { width: 100%; padding-right: 70px; }
.icon-btn {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: none !important; border: none; cursor: pointer;
  padding: 5px; line-height: 0; border-radius: 5px;
  color: var(--muted); opacity: 0.7; display: flex; align-items: center;
}
.icon-btn:hover { opacity: 1; background: #eef1f6 !important; color: var(--accent); }
.icon-btn svg { width: 17px; height: 17px; }
#toggle-token, #toggle-webhook-token, #toggle-app-secret { right: 34px; }
#copy-token, #copy-webhook-token, #copy-app-secret { right: 6px; }
.icon-btn:active { transform: translateY(-50%); }
#toggle-token.showing .icon-eye, #toggle-app-secret.showing .icon-eye { display: none !important; }
#toggle-token.showing .icon-eye-off, #toggle-app-secret.showing .icon-eye-off { display: inline-block !important; }
/* Webhook token icon meaning is flipped on purpose vs. Access Token above: it shows the
   *current* state (crossed-eye while masked, open eye once revealed) rather than the
   *action* the click performs - matches what was asked for this field specifically. */
#toggle-webhook-token.showing .icon-eye { display: inline-block !important; }
#toggle-webhook-token.showing .icon-eye-off { display: none !important; }
#copy-token.copied, #copy-webhook-token.copied { color: #16a34a; opacity: 1; }

button {
  background: var(--accent); color: #fff; border: none; padding: 10px 18px;
  border-radius: 7px; cursor: pointer; font-size: 14px; font-weight: 500;
  font-family: inherit; transition: background-color 0.15s ease, transform 0.05s ease;
}
button:hover { background: var(--accent-dark); }
button:active { transform: translateY(1px); }
button#test-tally, button#test-whatsapp { background: #475569; }
button#test-tally:hover, button#test-whatsapp:hover { background: #334155; }
.btn-secondary { background: #64748b !important; color: #fff; }
.btn-secondary:hover { background: #475569 !important; }

.logo-upload-box { display: flex; gap: 8px; align-items: center; }
.logo-upload-box input[type="file"] { flex: 1; padding: 6px; border: 1px dashed var(--border); border-radius: 7px; background: #fff; font-size: 13px; }
.hint-text { font-size: 12px; color: var(--muted); margin-top: 4px; display: block; font-weight: normal; }

.status-msg { margin-top: 14px; font-size: 13px; min-height: 18px; color: var(--muted); }

.test-send {
  display: flex; gap: 10px; margin-top: 26px; padding-top: 22px;
  border-top: 1px solid var(--border);
}
.test-send input {
  flex: 1; padding: 10px 12px; border: 1px solid var(--border); border-radius: 7px; font-size: 14px;
}
.test-send input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,70,229,0.12); }

.log-controls { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.log-controls input, .log-controls select {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 7px; font-size: 14px; font-family: inherit;
}
.log-controls #search-input { flex: 1; min-width: 200px; }
.log-controls input[type="date"] { width: auto; }
.log-controls input:focus, .log-controls select:focus { outline: none; border-color: var(--accent); }

.log-pagination { display: flex; gap: 10px; align-items: center; margin-top: 14px; }
.log-pagination select { padding: 7px 10px; border: 1px solid var(--border); border-radius: 7px; font-size: 13.5px; font-family: inherit; }
.log-pagination button { padding: 7px 14px; border: 1px solid var(--border); border-radius: 7px; background: #fff; font-size: 13.5px; font-family: inherit; cursor: pointer; }
.log-pagination button:disabled { opacity: 0.5; cursor: not-allowed; }
.log-pagination #page-info { font-size: 13.5px; color: var(--text-muted, #6b7280); }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid #eef1f5; }
th {
  color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase;
  letter-spacing: 0.4px; border-bottom: 2px solid var(--border);
}
tbody tr:hover { background: #fafbfd; }

.badge { padding: 3px 10px; border-radius: 12px; font-size: 11.5px; font-weight: 600; letter-spacing: 0.2px; }
.badge-Sent { background: #dcfce7; color: #166534; }
.badge-Pending { background: #fef9c3; color: #854d0e; }
.badge-Failed { background: #fee2e2; color: #991b1b; }
.badge-PendingApproval { background: #e0e7ff; color: #3730a3; }
.badge-Declined { background: #f1f5f9; color: #475569; }

.retry-btn, .approve-btn, .decline-btn { padding: 6px 12px; font-size: 12.5px; }
.approve-btn { background: #166534; }
.decline-btn { background: #64748b; }

.empty-state { text-align: center; color: var(--muted); padding: 32px 8px !important; font-size: 13.5px; }
.status-failed { color: #b91c1c; font-size: 12px; }

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .tabs { flex-wrap: wrap; }
}

/* --- Shared: buttons, links --- */
a.btn, button.btn-link {
  display: inline-block; background: var(--accent); color: #fff; border: none;
  padding: 10px 18px; border-radius: 7px; font-size: 14px; font-weight: 500;
  text-decoration: none; cursor: pointer; font-family: inherit;
}
a.btn:hover, button.btn-link:hover { background: var(--accent-dark); }
.btn-secondary { background: #475569 !important; }
.btn-secondary:hover { background: #334155 !important; }
.btn-lg { padding: 13px 26px; font-size: 15px; }

/* --- Header account area (dashboard / admin pages) --- */
.header-inner { display: flex; align-items: center; justify-content: space-between; }
.topbar-account { display: flex; align-items: center; gap: 14px; }
.account-email { font-size: 12.5px; color: #cbd5e1; }
#logout-btn, .logout-btn { background: #475569; padding: 8px 14px; font-size: 13px; }
#logout-btn:hover, .logout-btn:hover { background: #334155; }

.status-pill { padding: 3px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; }
.status-pill.trialing { background: #e0e7ff; color: #3730a3; }
.status-pill.pending_payment { background: #fef9c3; color: #854d0e; }
.status-pill.active { background: #dcfce7; color: #166534; }
.status-pill.expired, .status-pill.suspended { background: #fee2e2; color: #991b1b; }

/* --- Marketing / landing page --- */
.hero { text-align: center; padding: 64px 16px 44px; }
.hero h1 { font-size: 34px; margin: 0 0 14px; letter-spacing: -0.5px; }
.hero p { color: var(--muted); font-size: 16px; max-width: 560px; margin: 0 auto 28px; line-height: 1.6; }
.hero .cta-row { display: flex; gap: 12px; justify-content: center; }

.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; max-width: 1000px; margin: 0 auto 60px; padding: 0 16px; }
.feature-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.feature-card .icon { font-size: 26px; margin-bottom: 10px; }
.feature-card h3 { margin: 0 0 8px; font-size: 15px; }
.feature-card p { margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.5; }

.section-title { text-align: center; max-width: 1000px; margin: 0 auto; padding: 0 16px; }
.section-title h2 { font-size: 24px; margin-bottom: 6px; }
.section-title p { color: var(--muted); margin: 0 0 32px; }

/* --- Pricing --- */
.pricing-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; max-width: 1000px; margin: 0 auto; padding: 0 16px 60px; }
.plan-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; display: flex; flex-direction: column; }
.plan-card.featured { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(79,70,229,0.15); }
.plan-card h3 { margin: 0 0 4px; font-size: 18px; }
.plan-price { font-size: 32px; font-weight: 700; margin: 12px 0 18px; }
.plan-price span { font-size: 13px; font-weight: 500; color: var(--muted); }
.plan-card ul { list-style: none; padding: 0; margin: 0 0 24px; flex: 1; }
.plan-card li { padding: 7px 0; font-size: 13.5px; color: #334155; border-bottom: 1px solid #f1f4f9; }
.plan-card li::before { content: "✓ "; color: #16a34a; font-weight: 700; }

/* --- Auth pages (signup / login / forgot / reset / verify) --- */
.auth-wrap { max-width: 420px; margin: 60px auto; padding: 0 16px; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; box-shadow: 0 1px 2px rgba(16,24,40,0.04); }
.auth-card h2 { margin: 0 0 6px; }
.auth-card .hint { margin: 0 0 24px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; font-size: 12.5px; font-weight: 600; color: #475569; }
.field input { padding: 10px 12px; border: 1px solid var(--border); border-radius: 7px; font-size: 14px; font-family: inherit; color: var(--ink); }
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,70,229,0.12); }
.password-wrap { position: relative; display: flex; }
.password-wrap input { flex: 1; padding-right: 40px; }
.password-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); display: flex; align-items: center; border: none; background: none; cursor: pointer; padding: 6px 8px; color: #64748b; }
.password-toggle:hover { color: var(--ink); background: none; }
.password-toggle:active { transform: translateY(-50%); }
.auth-card button[type="submit"] { width: 100%; margin-top: 8px; }
.auth-links { margin-top: 18px; font-size: 13px; color: var(--muted); text-align: center; }
.auth-links a { color: var(--accent); text-decoration: none; font-weight: 600; }

/* --- Onboarding wizard --- */
.wizard-steps { display: flex; gap: 8px; margin-bottom: 24px; }
.wizard-step { flex: 1; text-align: center; padding: 10px 6px; border-radius: 8px; font-size: 12.5px; font-weight: 600; background: #eef1f6; color: var(--muted); }
.wizard-step.active { background: var(--accent); color: #fff; }
.wizard-step.done { background: #dcfce7; color: #166534; }
.wizard-panel { display: none; }
.wizard-panel.active { display: block; }

@media (max-width: 800px) {
  .features, .pricing-grid { grid-template-columns: 1fr; }
}
