:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #475569;
  --border: #e2e8f0;
  --accent: #1d4ed8;
  --accent-hover: #1e40af;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}
.container { max-width: 1180px; margin: 0 auto; padding: 0 24px; }
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 24px; height: 68px; }
.brand { font-weight: 800; font-size: 18px; color: var(--text); text-decoration: none; white-space: nowrap; }
.nav-links { display: flex; gap: 24px; flex-wrap: wrap; }
.nav-links a { color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500; }
.nav-links a:hover { color: var(--text); }
.btn-primary, .btn-submit {
  display: inline-block; padding: 11px 20px; border-radius: 8px;
  background: var(--accent); color: #fff; font-weight: 600; font-size: 14px;
  text-decoration: none; border: none; cursor: pointer;
}
.btn-submit { width: 100%; margin-top: 12px; padding: 13px 20px; }
.btn-primary:hover, .btn-submit:hover { background: var(--accent-hover); }
.btn-outline {
  display: inline-block; padding: 9px 16px; border-radius: 8px;
  border: 1px solid var(--border); color: var(--text); text-decoration: none; font-size: 14px; font-weight: 600;
}
.btn-danger-sm { padding: 5px 10px; border: 1px solid #fecaca; background: #fef2f2; color: #b91c1c; border-radius: 6px; cursor: pointer; font-size: 12px; }
.hero-grid { display: grid; grid-template-columns: 1.2fr 0.9fr; gap: 48px; align-items: center; padding: 64px 24px; }
.kicker { font-size: 13px; color: var(--muted); margin: 0 0 12px; }
h1 { font-size: clamp(2rem, 3.6vw, 3.25rem); line-height: 1.12; letter-spacing: -0.02em; margin: 0 0 18px; }
.lead { font-size: 17px; color: var(--muted); margin: 0 0 28px; max-width: 560px; }
.metric-strip { display: flex; gap: 36px; border-top: 1px solid var(--border); padding-top: 24px; }
.metric-strip strong { display: block; font-size: 24px; }
.metric-strip span { font-size: 13px; color: var(--muted); }
.signup-card, .panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 28px;
}
.signup-card h2 { margin: 0 0 6px; font-size: 22px; }
.sub { margin: 0 0 20px; color: var(--muted); font-size: 14px; }
label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 6px; }
input, select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid #cbd5e1; border-radius: 8px;
  font-size: 14px; font-family: inherit; background: #fff;
}
.privacy-note { font-size: 12px; color: var(--muted); margin-top: 14px; }
.alert-error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; padding: 14px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.suite-section { padding: 48px 24px 72px; border-top: 1px solid var(--border); }
.tool-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 24px; }
.tool-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 22px; }
.tool-card h3 { margin: 0 0 8px; font-size: 17px; }
.tool-card p { margin: 0; font-size: 14px; color: var(--muted); }
.site-footer { border-top: 1px solid var(--border); padding: 28px 0; font-size: 13px; color: var(--muted); }
.footer-inner { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.admin-main { padding: 32px 24px 64px; }
.admin-body { background: #f1f5f9; }
.em-login-badge {
  display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: #1d4ed8; background: #eff6ff; padding: 4px 10px; border-radius: 6px; margin-bottom: 10px;
}
.em-shell { display: flex; min-height: 100vh; }
.em-sidebar {
  width: 248px; flex-shrink: 0; background: #0f172a; color: #cbd5e1;
  display: flex; flex-direction: column; border-right: 1px solid #1e293b;
}
.em-sidebar-brand { padding: 22px 20px; border-bottom: 1px solid #1e293b; }
.em-brand-title { font-size: 17px; font-weight: 800; color: #fff; }
.em-brand-sub { font-size: 12px; color: #94a3b8; margin-top: 2px; }
.em-nav { padding: 14px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.em-nav a {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-radius: 8px; color: #cbd5e1; text-decoration: none;
  font-size: 14px; font-weight: 500; transition: background 0.15s, color 0.15s;
}
.em-nav a:hover { background: #1e293b; color: #fff; }
.em-nav a.active { background: #2563eb; color: #fff; font-weight: 600; }
.em-count {
  font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px;
  background: rgba(255,255,255,0.14); color: #fff;
}
.em-count-warn { background: #dc2626; }
.em-sidebar-footer { padding: 16px; border-top: 1px solid #1e293b; }
.em-user-pill { font-size: 12px; color: #94a3b8; margin-bottom: 10px; }
.em-user-pill strong { color: #fff; }
.btn-sm-full { width: 100%; text-align: center; padding: 8px 12px; font-size: 13px; color: #e2e8f0; border-color: #334155; }
.em-workspace { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.em-topbar {
  height: 64px; background: #fff; border-bottom: 1px solid var(--border);
  padding: 0 28px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.em-topbar-title { font-size: 18px; font-weight: 700; color: var(--text); }
.em-topbar-actions { display: flex; align-items: center; gap: 10px; }
.em-content { padding: 26px 28px 60px; max-width: 1320px; width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-xs-primary { padding: 5px 10px; border-radius: 6px; border: none; background: #2563eb; color: #fff; font-size: 12px; font-weight: 600; cursor: pointer; }
.btn-xs-outline { padding: 5px 10px; border-radius: 6px; border: 1px solid #cbd5e1; background: #fff; color: #334155; font-size: 12px; font-weight: 600; cursor: pointer; }
.btn-active-pill { background: #eff6ff; border-color: #2563eb; color: #1d4ed8; }
.btn-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; }
.kpi-card span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); }
.kpi-card strong { display: block; font-size: 30px; line-height: 1.2; margin: 4px 0; color: #0f172a; }
.kpi-card small { font-size: 12px; color: #64748b; }
.em-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; align-items: start; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.panel-head h3 { margin: 0 0 4px; font-size: 16px; }
.panel-head .sub { margin: 0; }
.seq-list { display: flex; flex-direction: column; gap: 10px; }
.seq-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; }
.seq-badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 6px; background: #fef3c7; color: #92400e; white-space: nowrap; }
.seq-welcome { background: #dbeafe; color: #1e40af; }
.seq-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.seq-card { background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; padding: 14px; }
.seq-card h4 { margin: 8px 0 4px; font-size: 14px; }
.muted-xs { font-size: 12px; color: #64748b; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { text-align: left; padding: 10px 12px; background: #f8fafc; color: #475569; font-size: 12px; font-weight: 700; border-bottom: 1px solid var(--border); }
.data-table td { text-align: left; padding: 11px 12px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.actions-cell { white-space: nowrap; }
.actions-cell form { margin-right: 4px; }
.status-pill { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; text-transform: capitalize; }
.pill-green { background: #dcfce7; color: #166534; }
.pill-red { background: #fee2e2; color: #991b1b; }
.pill-blue { background: #dbeafe; color: #1e40af; }
.pill-gray { background: #e2e8f0; color: #475569; }
.inline-add-form { display: grid; grid-template-columns: 1fr 1.2fr auto auto; gap: 10px; align-items: center; }
.search-bar { display: flex; gap: 10px; align-items: center; width: 100%; max-width: 620px; }
.search-bar input { flex: 1; }
.search-bar select { width: 190px; }
.checkbox-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; white-space: nowrap; cursor: pointer; }
.checkbox-inline input { width: auto; }
.checkbox-row { display: flex; align-items: center; gap: 8px; padding: 6px 4px; margin: 0; font-weight: 400; font-size: 13px; border-bottom: 1px solid #f1f5f9; cursor: pointer; }
.checkbox-row input { width: auto; }
.tpl-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.tpl-studio { display: grid; grid-template-columns: 310px 1fr; gap: 20px; align-items: start; }
.tpl-list-card, .tpl-editor-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.tpl-list-head { padding: 14px 16px; font-size: 13px; font-weight: 700; background: #f8fafc; border-bottom: 1px solid var(--border); }
.tpl-list-item { display: block; padding: 13px 16px; border-bottom: 1px solid #f1f5f9; text-decoration: none; color: inherit; transition: background 0.12s; }
.tpl-list-item:hover { background: #f8fafc; }
.tpl-list-item.selected { background: #eff6ff; border-left: 3px solid #2563eb; padding-left: 13px; }
.tpl-item-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.tpl-role-tag { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; padding: 2px 7px; border-radius: 4px; }
.tag-blue { background: #dbeafe; color: #1e40af; }
.tag-gold { background: #fef3c7; color: #92400e; }
.tag-gray { background: #f1f5f9; color: #475569; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-green { background: #16a34a; }
.dot-gray { background: #94a3b8; }
.tpl-item-name { font-size: 14px; font-weight: 700; color: #0f172a; }
.tpl-item-subj { font-size: 12px; color: #64748b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.tpl-editor-card { padding: 22px; }
.tpl-editor-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.seg-tabs { display: inline-flex; background: #f1f5f9; padding: 3px; border-radius: 8px; gap: 2px; }
.seg-btn { border: none; background: transparent; padding: 7px 14px; border-radius: 6px; font-size: 13px; font-weight: 600; color: #475569; cursor: pointer; }
.seg-btn.active { background: #fff; color: #0f172a; box-shadow: 0 1px 2px rgba(0,0,0,0.08); }
.preview-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 14px; font-size: 13px; flex-wrap: wrap; }
.preview-stage { display: flex; justify-content: center; background: #e2e8f0; padding: 14px; border-radius: 10px; }
.form-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.merge-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 14px 0 4px; font-size: 12px; color: #475569; }
.chip { padding: 4px 8px; border-radius: 5px; border: 1px solid #cbd5e1; background: #f8fafc; font-family: monospace; font-size: 11px; cursor: pointer; color: #0f172a; }
.chip:hover { background: #e2e8f0; }
.code-area { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 12px; line-height: 1.5; }
.code-box { background: #0f172a; color: #e2e8f0; padding: 12px 14px; border-radius: 8px; font-size: 12px; overflow-x: auto; }
.editor-actions-bar { display: flex; align-items: center; gap: 10px; margin-top: 16px; }
.editor-secondary-actions { display: flex; align-items: center; gap: 10px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.mono-sm { font-family: monospace; font-size: 11px; max-width: 340px; word-break: break-all; }
.template-form { margin-bottom: 28px; }
@media (max-width: 1024px) {
  .em-shell { flex-direction: column; }
  .em-sidebar { width: 100%; }
  .em-nav { flex-direction: row; overflow-x: auto; }
  .tpl-studio, .em-grid-2, .seq-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .inline-add-form { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .hero-grid, .tool-grid, .kpi-grid, .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .nav-links { display: none; }
}
