/* Mailing Automation - shared styles */
:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-soft: #eef2ff;
  --accent: #f59e0b;
  --success: #059669;
  --success-soft: #ecfdf5;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --info-soft: #eff6ff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --bg: #f6f7fb;
  --card: #ffffff;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(17, 24, 39, .06), 0 1px 2px rgba(17, 24, 39, .04);
  --shadow-lg: 0 20px 40px rgba(17, 24, 39, .12);
  --sidebar: 248px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.55;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; }
p { margin: 0 0 1em; }
img { max-width: 100%; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }
code { background: #f3f4f6; padding: 1px 6px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.right { text-align: right; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--primary); color: #fff; padding: 10px 16px; z-index: 1000; }
.skip-link:focus { left: 0; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 8px; border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none !important;
  background: var(--primary); color: #fff; transition: background .15s, box-shadow .15s, transform .05s;
}
.btn:hover { background: var(--primary-dark); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn.secondary:hover { background: #f9fafb; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #b91c1c; }
.btn.success { background: var(--success); }
.btn.ghost { background: transparent; color: var(--primary); }
.btn.ghost:hover { background: var(--primary-soft); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.lg { padding: 13px 26px; font-size: 16px; border-radius: 10px; }
.btn.accent { background: var(--accent); color: #111827; }
.btn.accent:hover { background: #d97706; color: #fff; }
.btn.white { background: #fff; color: var(--primary); }
.btn.white:hover { background: var(--primary-soft); }
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }

/* Forms */
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 5px; color: #374151; }
.field { margin-bottom: 16px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.field .error-text { font-size: 12px; color: var(--danger); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=tel], input[type=search], input[type=url], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid #d1d5db; border-radius: 8px;
  font: inherit; font-size: 14px; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, .15); }
input.invalid, select.invalid, textarea.invalid { border-color: var(--danger); }
textarea { min-height: 110px; resize: vertical; }
textarea.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; min-height: 280px; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); vertical-align: middle; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 18px; }
@media (max-width: 720px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.otp-input { font-size: 26px !important; letter-spacing: 10px; text-align: center; font-family: ui-monospace, monospace; }

/* Cards & layout */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.card + .card { margin-top: 18px; }
.card h2 { font-size: 18px; }
.card-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-header h2 { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat .label { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.stat .sub { font-size: 12px; color: var(--muted); }
.progress { height: 8px; background: #e5e7eb; border-radius: 99px; overflow: hidden; margin-top: 8px; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: 99px; }
.progress.warn > span { background: var(--warning); }
.progress.danger > span { background: var(--danger); }

/* Alerts */
.alert { padding: 12px 16px; border-radius: 8px; border: 1px solid; margin-bottom: 16px; font-size: 14px; }
.alert.info { background: var(--info-soft); border-color: #bfdbfe; color: #1e3a8a; }
.alert.success { background: var(--success-soft); border-color: #a7f3d0; color: #065f46; }
.alert.warning { background: var(--warning-soft); border-color: #fde68a; color: #92400e; }
.alert.danger { background: var(--danger-soft); border-color: #fecaca; color: #991b1b; }
.alert strong { font-weight: 700; }
.tip-banner {
  display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  background: linear-gradient(90deg, #eef2ff, #f5f3ff); border: 1px solid #c7d2fe; color: #3730a3;
  padding: 11px 16px; border-radius: 10px; margin-bottom: 18px; font-size: 14px;
}
.tip-banner .icon { font-size: 20px; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { background: #f9fafb; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafafa; }
td.actions { white-space: nowrap; text-align: right; }
.empty { padding: 36px; text-align: center; color: var(--muted); }

/* Badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; background: #f3f4f6; color: #374151; }
.badge.green { background: #d1fae5; color: #065f46; }
.badge.red { background: #fee2e2; color: #991b1b; }
.badge.amber { background: #fef3c7; color: #92400e; }
.badge.blue { background: #dbeafe; color: #1e40af; }
.badge.indigo { background: #e0e7ff; color: #3730a3; }
.badge.gray { background: #f3f4f6; color: #4b5563; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { background: none; border: 0; padding: 10px 14px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(17, 24, 39, .5); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 200; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 560px; box-shadow: var(--shadow-lg); }
.modal.wide { max-width: 860px; }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-body { padding: 22px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.close-x { background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }

/* Toasts */
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 300; max-width: 380px; }
.toast { background: #111827; color: #fff; padding: 12px 16px; border-radius: 8px; box-shadow: var(--shadow-lg); font-size: 14px; animation: slidein .2s ease-out; }
.toast.success { background: #065f46; }
.toast.error { background: #991b1b; }
@keyframes slidein { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

.spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid #c7d2fe; border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { padding: 40px; text-align: center; color: var(--muted); }

/* ---------------------------------------------------------------------------
   App shell
--------------------------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar); background: #111827; color: #d1d5db; position: fixed; top: 0; bottom: 0; left: 0;
  display: flex; flex-direction: column; z-index: 50; transition: transform .2s;
}
.sidebar .brand { padding: 20px 20px 16px; color: #fff; font-weight: 800; font-size: 17px; display: flex; align-items: center; gap: 10px; }
.brand .logo-mark { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, #6366f1, #a855f7); display: grid; place-items: center; font-size: 16px; }
.sidebar nav { flex: 1; overflow-y: auto; padding: 4px 10px 16px; }
.sidebar .nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #6b7280; padding: 14px 10px 6px; font-weight: 700; }
.sidebar a.nav-link { display: flex; gap: 10px; align-items: center; color: #d1d5db; padding: 8px 10px; border-radius: 7px; font-size: 14px; text-decoration: none; }
.sidebar a.nav-link:hover { background: #1f2937; color: #fff; }
.sidebar a.nav-link.active { background: var(--primary); color: #fff; }
.sidebar .nav-icon { width: 18px; text-align: center; }
.sidebar .powered { padding: 14px 20px; font-size: 12px; color: #9ca3af; border-top: 1px solid #1f2937; }
.sidebar .powered a { color: #c7d2fe; }
.main { margin-left: var(--sidebar); flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { background: #fff; border-bottom: 1px solid var(--border); padding: 12px 26px; display: flex; align-items: center; justify-content: space-between; gap: 12px; position: sticky; top: 0; z-index: 40; }
.topbar h1 { font-size: 19px; margin: 0; }
.topbar .user-chip { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 700; }
.content { padding: 24px 26px 40px; max-width: 1280px; width: 100%; }
.menu-toggle { display: none; background: none; border: 0; font-size: 22px; cursor: pointer; }
.app-footer { margin-top: auto; padding: 16px 26px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); background: #fff; }
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .menu-toggle { display: block; }
  .content { padding: 18px 14px 36px; }
  .topbar { padding: 12px 14px; }
}

/* ---------------------------------------------------------------------------
   Public site
--------------------------------------------------------------------------- */
.site-header { background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 60; border-bottom: 1px solid var(--border); }
.site-header .inner { max-width: 1180px; margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.site-header .brand { font-weight: 800; font-size: 18px; color: var(--text); display: flex; align-items: center; gap: 10px; text-decoration: none; }
.site-header nav { display: flex; gap: 22px; align-items: center; }
.site-header nav a.link { color: #374151; font-weight: 500; font-size: 14px; }
@media (max-width: 820px) { .site-header nav a.link { display: none; } }
.container { max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.section { padding: 76px 0; }
.section.alt { background: #fff; }
.section-title { text-align: center; max-width: 720px; margin: 0 auto 44px; }
.section-title h2 { font-size: 34px; }
.eyebrow { display: inline-block; font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--primary); margin-bottom: 10px; }

.hero { background: radial-gradient(1200px 600px at 10% -10%, #c7d2fe 0%, transparent 60%), radial-gradient(900px 500px at 110% 10%, #f5d0fe 0%, transparent 55%), #f8faff; padding: 84px 0 70px; overflow: hidden; }
.hero .inner { display: grid; grid-template-columns: 1.1fr .9fr; gap: 48px; align-items: center; }
.hero h1 { font-size: 50px; letter-spacing: -.02em; margin-bottom: 18px; }
.hero h1 span { background: linear-gradient(90deg, #4f46e5, #a21caf); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p.lead { font-size: 19px; color: #374151; max-width: 560px; }
.trial-pill { display: inline-flex; gap: 8px; align-items: center; background: #fff; border: 1px solid #fde68a; color: #92400e; padding: 6px 14px; border-radius: 99px; font-weight: 700; font-size: 14px; margin-bottom: 18px; box-shadow: var(--shadow); }
.hero .cta-row { display: flex; gap: 12px; flex-wrap: wrap; margin: 26px 0 14px; }
.hero-card { background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg); padding: 22px; border: 1px solid var(--border); }
.hero-card .queue-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.hero-card .queue-row:last-child { border-bottom: 0; }
@media (max-width: 900px) { .hero .inner { grid-template-columns: 1fr; } .hero h1 { font-size: 36px; } }

.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.feature { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 24px; box-shadow: var(--shadow); }
.feature .icon { width: 44px; height: 44px; border-radius: 10px; background: var(--primary-soft); display: grid; place-items: center; font-size: 22px; margin-bottom: 14px; }
.feature h3 { font-size: 17px; }
.feature p { color: #4b5563; font-size: 14px; margin: 0; }
@media (max-width: 900px) { .features { grid-template-columns: 1fr; } }

.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; counter-reset: step; }
.step { position: relative; padding: 22px; background: #fff; border-radius: 14px; border: 1px solid var(--border); }
.step::before { counter-increment: step; content: counter(step); position: absolute; top: -14px; left: 22px; width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700; }
.step h3 { font-size: 16px; margin-top: 8px; }
.step p { font-size: 14px; color: #4b5563; margin: 0; }
@media (max-width: 900px) { .steps { grid-template-columns: 1fr 1fr; } }

.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; }
.plan { background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 26px; display: flex; flex-direction: column; box-shadow: var(--shadow); position: relative; }
.plan.featured { border: 2px solid var(--primary); }
.plan .price { font-size: 38px; font-weight: 800; margin: 8px 0 2px; }
.plan .price small { font-size: 15px; color: var(--muted); font-weight: 500; }
.plan ul { list-style: none; padding: 0; margin: 18px 0 22px; flex: 1; }
.plan li { padding: 6px 0 6px 26px; position: relative; font-size: 14px; }
.plan li::before { content: '✓'; position: absolute; left: 0; color: var(--success); font-weight: 800; }
.plan.selectable { cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.plan.selectable:hover { border-color: var(--primary); }
.plan.selected { border: 2px solid var(--primary); box-shadow: 0 0 0 4px rgba(79, 70, 229, .12); }

.callout { background: linear-gradient(135deg, #4f46e5, #7c3aed); color: #fff; border-radius: 18px; padding: 40px; display: flex; justify-content: space-between; gap: 24px; align-items: center; flex-wrap: wrap; }
.callout h2 { color: #fff; font-size: 28px; }
.callout p { color: #e0e7ff; margin: 0; max-width: 640px; }

.tpe { background: #0f172a; color: #cbd5e1; }
.tpe .section-title h2 { color: #fff; }
.tpe .section-title p { color: #94a3b8; }
.tpe .eyebrow { color: #a5b4fc; }
.tpe-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.tpe-card { background: #111c33; border: 1px solid #1e293b; border-radius: 14px; padding: 22px; transition: transform .15s, border-color .15s; }
.tpe-card:hover { transform: translateY(-2px); border-color: #4f46e5; }
.tpe-card h3 { color: #fff; font-size: 17px; }
.tpe-card p { font-size: 14px; margin: 0 0 12px; }
.tpe-card a { color: #a5b4fc; font-weight: 600; font-size: 14px; }
@media (max-width: 900px) { .tpe-grid { grid-template-columns: 1fr; } }

.site-footer { background: #0b1222; color: #94a3b8; padding: 30px 0; font-size: 14px; }
.site-footer .inner { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: center; }
.site-footer a { color: #c7d2fe; }

.faq details { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 14px 18px; margin-bottom: 10px; }
.faq summary { font-weight: 600; cursor: pointer; }
.faq details p { margin: 10px 0 0; color: #4b5563; }

/* Auth pages */
.auth-wrap { min-height: calc(100vh - 140px); display: flex; align-items: flex-start; justify-content: center; padding: 48px 16px; }
.auth-card { width: 100%; max-width: 440px; }
.auth-card.wide { max-width: 860px; }
.auth-card h1 { font-size: 24px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; margin: 18px 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.oauth-buttons { display: grid; gap: 8px; }
.oauth-buttons .btn { background: #fff; color: var(--text); border-color: var(--border); }
.oauth-buttons .btn:hover { background: #f9fafb; }

.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.template-card { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.template-card iframe { width: 100%; height: 190px; border: 0; pointer-events: none; background: #fff; }
.template-card .meta { padding: 12px; border-top: 1px solid var(--border); flex: 1; display: flex; flex-direction: column; gap: 6px; }
.template-card .meta h4 { margin: 0; font-size: 14px; }
.preview-frame { width: 100%; min-height: 420px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.sender-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sender-chip { background: var(--primary-soft); color: #3730a3; border-radius: 99px; padding: 3px 10px; font-size: 13px; font-family: ui-monospace, monospace; }
.sender-chip.own { background: #d1fae5; color: #065f46; }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 8px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }
@media (max-width: 600px) { .kv { grid-template-columns: 1fr; } }
.qr-box { display: inline-block; padding: 10px; background: #fff; border: 1px solid var(--border); border-radius: 8px; }
.pagination { display: flex; gap: 6px; justify-content: flex-end; align-items: center; margin-top: 12px; }
.grid-2 > .card, .grid-3 > .card { margin-top: 0; }
.card + .grid-2, .grid-2 + .card, .grid-2 + .grid-2, .stats + .grid-2 { margin-top: 18px; }
