/* KiQMail — design system (KiQ Apps palette: indigo #5e5ce6, blue #0a84ff, navy #10243b) */
:root {
  --indigo: #5e5ce6;
  --indigo-dark: #4a48c4;
  --blue: #0a84ff;
  --navy: #10243b;
  --ink: #1c2b3a;
  --muted: #64748b;
  --line: #e3e8ef;
  --bg: #f7f9fc;
  --card: #ffffff;
  --tint: #eef0fd;
  --ok: #0f9d6e;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(16, 36, 59, 0.08);
}
* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  font-size: 16px; line-height: 1.6; color: var(--ink); background: var(--bg);
}
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 24px; }
h1, h2, h3 { color: var(--navy); line-height: 1.2; margin: 0 0 12px; }
h1 { font-size: 44px; letter-spacing: -0.6px; }
h2 { font-size: 30px; letter-spacing: -0.3px; }
h3 { font-size: 18px; }
p { margin: 0 0 14px; }
a { color: var(--indigo); }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.eyebrow { text-transform: uppercase; letter-spacing: 1.4px; font-size: 12px; font-weight: 700; color: var(--indigo); margin-bottom: 10px; }

/* header / footer */
.site-header { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--navy); font-weight: 800; font-size: 20px; letter-spacing: -0.3px; }
.brand .mark { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, var(--indigo), var(--blue)); display: grid; place-items: center; color: #fff; font-size: 15px; font-weight: 900; }
.nav { display: flex; gap: 6px; align-items: center; }
.nav a { text-decoration: none; color: var(--ink); padding: 8px 12px; border-radius: 8px; font-weight: 600; font-size: 15px; }
.nav a:hover, .nav a.active { background: var(--tint); color: var(--indigo); }
.site-footer { border-top: 1px solid var(--line); padding: 28px 0 40px; margin-top: 80px; color: var(--muted); font-size: 14px; }
.site-footer .wrap { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 11px 18px; border-radius: 10px; border: 1px solid transparent; font-weight: 700; font-size: 15px; cursor: pointer; text-decoration: none; transition: .15s; font-family: inherit; }
.btn-primary { background: var(--indigo); color: #fff; }
.btn-primary:hover { background: var(--indigo-dark); }
.btn-ghost { background: #fff; color: var(--navy); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--indigo); color: var(--indigo); }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; }

/* hero */
.hero { padding: 72px 0 48px; display: grid; grid-template-columns: 1.05fr 1fr; gap: 48px; align-items: center; }
.hero p.lead { font-size: 19px; color: var(--muted); max-width: 520px; }
.hero .actions { display: flex; gap: 12px; margin-top: 22px; flex-wrap: wrap; }
.phone { background: #fff; border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); overflow: hidden; }
.phone-bar { padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.phone-bar .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.phone-body { padding: 0; background: #f2f4f7; }

/* sections */
section.block { padding: 56px 0; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: 0 1px 2px rgba(16,36,59,.04); }
.card .icon { width: 40px; height: 40px; border-radius: 10px; background: var(--tint); color: var(--indigo); display: grid; place-items: center; font-weight: 900; margin-bottom: 14px; }
.steps { counter-reset: s; }
.steps .card { position: relative; padding-top: 26px; }
.steps .card::before { counter-increment: s; content: counter(s); position: absolute; top: -14px; left: 20px; width: 28px; height: 28px; border-radius: 50%; background: var(--indigo); color: #fff; font-weight: 800; font-size: 14px; display: grid; place-items: center; }

/* pricing */
.price { font-size: 38px; font-weight: 800; color: var(--navy); letter-spacing: -1px; }
.price span { font-size: 15px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.card.featured { border-color: var(--indigo); box-shadow: 0 0 0 3px var(--tint); }
.list { list-style: none; padding: 0; margin: 14px 0 0; }
.list li { padding: 6px 0 6px 26px; position: relative; }
.list li::before { content: '✓'; position: absolute; left: 0; color: var(--ok); font-weight: 800; }

/* workbench (emails + footnote pages) */
.workbench { display: grid; grid-template-columns: 380px 1fr; gap: 24px; padding: 32px 0 20px; align-items: start; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; position: sticky; top: 84px; max-height: calc(100vh - 110px); overflow: auto; }
.panel h3 { margin-bottom: 6px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; font-weight: 700; color: var(--navy); margin-bottom: 4px; }
.field input[type=text], .field input[type=email], .field input[type=url], .field input[type=password], .field textarea, .field select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 14px; color: var(--ink); background: #fff;
}
.field textarea { min-height: 84px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--indigo); box-shadow: 0 0 0 3px var(--tint); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.swatch.active { box-shadow: 0 0 0 2px var(--indigo); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit; color: var(--ink); }
.chip.active { background: var(--indigo); color: #fff; border-color: var(--indigo); }
.divider { height: 1px; background: var(--line); margin: 16px 0; }

.stage { min-width: 0; }
.stage-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.stage-bar .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.viewer { background: #e9edf2; border: 1px solid var(--line); border-radius: var(--radius); padding: 28px 16px; display: flex; justify-content: center; min-height: 500px; }
.viewer.mobile iframe { width: 390px; }
.viewer iframe { width: 100%; max-width: 680px; height: 760px; border: 0; background: #fff; border-radius: 10px; box-shadow: var(--shadow); transition: width .2s; }
.viewer.footnote-view { background: #fff; padding: 0; display: block; }
.viewer.footnote-view .mail { padding: 22px 26px; font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif; }
.mail-head { border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 16px; font-size: 14px; color: var(--muted); }
.mail-head b { color: var(--navy); }
.mail-body { font-size: 15px; color: #333; margin-bottom: 26px; }
.code { background: #0f1b2a; color: #d8e1ee; border-radius: 10px; padding: 16px; font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; word-break: break-all; max-height: 360px; overflow: auto; margin-top: 14px; }
.hidden { display: none !important; }

/* gallery */
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.tile { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer; transition: .15s; text-align: left; padding: 0; font-family: inherit; }
.tile:hover { border-color: var(--indigo); transform: translateY(-2px); box-shadow: var(--shadow); }
.tile.active { border-color: var(--indigo); box-shadow: 0 0 0 3px var(--tint); }
.tile .thumb { height: 150px; background: #f2f4f7; overflow: hidden; position: relative; }
.tile .thumb iframe { width: 600px; height: 750px; border: 0; transform: scale(.5); transform-origin: 0 0; pointer-events: none; position: absolute; left: 50%; margin-left: -150px; }
.tile .meta { padding: 12px 14px; }
.tile .meta b { display: block; color: var(--navy); }
.tile .meta span { font-size: 13px; color: var(--muted); }

/* toast */
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px); background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 10px; font-weight: 600; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 50; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 900px) {
  .hero, .grid-3, .grid-2, .workbench, .gallery { grid-template-columns: 1fr; }
  h1 { font-size: 34px; }
  .panel { position: static; max-height: none; }
  .nav a { padding: 8px; font-size: 14px; }
}

/* ---- platform additions ---- */
:root { --warn: #b7791f; --err: #c0392b; }
.flash { padding: 12px 16px; border-radius: 10px; font-size: 14px; margin-bottom: 10px; border: 1px solid var(--line); background: #fff; }
.flash.ok { border-color: #bfe8d8; background: #eefaf5; color: #0b6b4c; }
.flash.error { border-color: #f3c6c0; background: #fdf1ef; color: #8e2b20; }
.flash.dev { border-color: #f1dfb0; background: #fdf8ea; color: #7a5a12; word-break: break-all; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--tint); color: var(--indigo); }
.badge.ok { background: #eefaf5; color: #0b6b4c; }
.badge.warn { background: #fdf1ef; color: #8e2b20; }
.auth-wrap { max-width: 440px; margin: 56px auto; }
.auth-wrap .card { padding: 30px; }
.status-row { margin-top: 12px; }
.fn-thumb { background: #f2f4f7; border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-top: 10px; overflow-x: auto; }
.snippet { width: 100%; margin-top: 12px; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; color: #d8e1ee; background: #0f1b2a; border: 0; border-radius: 10px; padding: 12px; resize: vertical; }
.label-input { font: inherit; font-size: 26px; font-weight: 800; color: var(--navy); border: 1px solid transparent; border-radius: 8px; padding: 2px 8px; background: transparent; width: 100%; max-width: 420px; letter-spacing: -0.3px; }
.label-input:hover, .label-input:focus { border-color: var(--line); background: #fff; outline: none; }
.table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.table td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
code { background: var(--tint); padding: 1px 6px; border-radius: 5px; font-size: 90%; }
.site-footer a { color: var(--muted); }

/* ---- designer v2 ---- */
.panel details { border-top: 1px solid var(--line); padding: 10px 0 4px; }
.panel details:first-of-type { border-top: 0; padding-top: 0; }
.panel summary { cursor: pointer; font-weight: 800; color: var(--navy); font-size: 15px; padding: 6px 0 10px; list-style: none; display: flex; justify-content: space-between; }
.panel summary::after { content: '▾'; color: var(--muted); }
.panel details:not([open]) summary::after { content: '▸'; }
.layout-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 6px; }
.layout-tile { border: 2px solid var(--line); border-radius: 10px; background: #fff; padding: 6px; cursor: pointer; text-align: left; font-family: inherit; }
.layout-tile img { display: block; width: 100%; height: 56px; object-fit: contain; object-position: left top; background: #f7f9fc; border-radius: 6px; }
.layout-tile span { display: block; font-size: 12px; font-weight: 700; color: var(--navy); margin-top: 5px; }
.layout-tile.active { border-color: var(--indigo); box-shadow: 0 0 0 3px var(--tint); }
.img-row { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }
.img-row input[type=file] { font-size: 12px; max-width: 200px; }
.field input[type=color] { width: 28px; height: 28px; border: 1px solid var(--line); border-radius: 50%; padding: 0; background: none; cursor: pointer; vertical-align: middle; }
.swatches input[type=color] { margin-left: 4px; }
.field input[type=range] { width: 100%; }
.field output { font-weight: 400; color: var(--muted); }
.field input[type=url] { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 14px; }

/* ---- admin ---- */
.admin-nav { display: flex; gap: 4px; flex-wrap: wrap; padding: 22px 0 18px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.admin-nav a { text-decoration: none; color: var(--ink); padding: 8px 14px; border-radius: 8px; font-weight: 700; font-size: 14px; }
.admin-nav a.active, .admin-nav a:hover { background: var(--navy); color: #fff; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.kpi span { display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.kpi b { display: block; font-size: 28px; color: var(--navy); letter-spacing: -0.5px; margin: 4px 0 2px; }
.kpi small { color: var(--muted); font-size: 12px; }
.kpi.accent { background: var(--navy); border-color: var(--navy); }
.kpi.accent span, .kpi.accent small { color: #b9c4d6; } .kpi.accent b { color: #fff; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding: 10px 0 22px; position: relative; }
.bar { flex: 1; background: var(--indigo); border-radius: 4px 4px 0 0; min-height: 3px; position: relative; opacity: .9; }
.bar i { position: absolute; bottom: -20px; left: 0; right: 0; text-align: center; font-size: 11px; color: var(--muted); font-style: normal; }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.filters input, .filters select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 14px; background: #fff; }
.table th { text-align: left; padding: 8px 12px; font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); border-bottom: 1px solid var(--line); background: #fafbfd; }
.impersonate-bar { background: #fdf8ea; border-bottom: 1px solid #f1dfb0; color: #7a5a12; padding: 8px 24px; font-size: 14px; text-align: center; }
@media (max-width: 900px) { .layout-grid { grid-template-columns: repeat(3, 1fr); } }
