:root {
  --paper: #f5f2ec;
  --panel: #fffdf9;
  --ink: #20201d;
  --muted: #706f68;
  --line: #dedbd2;
  --accent: #a47c42;
  --accent-soft: #eee3d2;
  --danger: #a34f43;
  --success: #3e7056;
  --shadow: 0 18px 50px rgba(41, 37, 28, 0.07);
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 90% 0%, rgba(196, 165, 116, 0.12), transparent 30rem),
    var(--paper);
  font: 15px/1.5 var(--sans);
}
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); }
[hidden] { display: none !important; }

.shell {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  padding: 28px 0 80px;
}
.login-card {
  width: min(440px, 100%);
  margin: 12vh auto 0;
  padding: 42px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.login-card h1,
.topbar h1 {
  margin: 0;
  font: 500 clamp(2.4rem, 7vw, 4.4rem)/0.95 var(--serif);
  letter-spacing: -0.04em;
}
.login-card .muted { margin: 14px 0 28px; }
.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}
.muted { color: var(--muted); }
.small-copy { font-size: 12px; }

.topbar,
.section-heading,
.hero,
.material,
.funnel-step {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.topbar {
  align-items: flex-end;
  padding: 10px 0 38px;
}
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 17px;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}
.button:hover { transform: translateY(-1px); }
.button.primary { color: #fff; background: var(--ink); }
.button.secondary { color: #fff; background: var(--accent); }
.button.ghost { color: var(--ink); background: transparent; border-color: var(--line); }
.button.danger { color: var(--danger); background: transparent; border-color: rgba(163, 79, 67, 0.3); }
.button.small { min-height: 32px; padding: 0 11px; font-size: 12px; }

.panel {
  margin-bottom: 18px;
  padding: 26px;
  background: rgba(255, 253, 249, 0.9);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.hero {
  min-height: 150px;
  background: var(--ink);
  color: #fffdf9;
}
.hero .eyebrow,
.hero .muted { color: #d4c8b8; }
.hero h2 {
  margin: 0;
  font: 500 clamp(2rem, 5vw, 3.3rem)/1 var(--serif);
  letter-spacing: -0.03em;
}
.live-note {
  max-width: 240px;
  margin: 0;
  color: #e9dfd1;
  font-size: 13px;
  text-align: right;
}
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 18px;
}
.metric { margin-bottom: 0; }
.metric-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.metric strong {
  display: block;
  margin-top: 8px;
  font: 500 2.5rem/1 var(--serif);
}
.section-heading { align-items: flex-start; margin-bottom: 22px; }
.section-heading h2 {
  margin: 0;
  font: 500 1.8rem/1.1 var(--serif);
  letter-spacing: -0.025em;
}
.funnel { display: grid; gap: 13px; }
.funnel-step { gap: 14px; }
.step-label { width: 145px; font-size: 13px; }
.step-track {
  flex: 1;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--accent-soft);
}
.step-bar {
  display: block;
  height: 100%;
  min-width: 3px;
  border-radius: inherit;
  background: var(--accent);
}
.funnel-step strong { width: 92px; text-align: right; font-size: 13px; }

.table-wrap {
  overflow-x: auto;
  margin: 0 -6px;
}
table.leads {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.leads th,
table.leads td {
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  white-space: nowrap;
}
table.leads th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
table.leads td:nth-child(2),
table.leads td:nth-child(3) {
  white-space: normal;
  overflow-wrap: anywhere;
}
table.leads tr.is-vip td:nth-child(5) {
  color: var(--accent);
  font-weight: 700;
}

.form-message {
  min-height: 1.4em;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.form-message.error { color: var(--danger); }
.form-message.success { color: var(--success); }

.workspace-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.workspace-grid > .panel { min-width: 0; }
.editor-form { display: grid; gap: 15px; }
.editor-form label,
.login-card label,
.upload-box label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
input, textarea, select {
  width: 100%;
  padding: 11px 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(164, 124, 66, 0.12);
}
input[type="color"] { height: 42px; padding: 4px; }
textarea { resize: vertical; min-height: 74px; }
.two-col,
.color-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.color-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.editor-block {
  display: grid;
  gap: 14px;
  padding-top: 6px;
}
.editor-block + .editor-block {
  margin-top: 6px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.email-grid {
  display: grid;
  gap: 16px;
}
.email-day {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.email-day h3 {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.form-message {
  min-height: 1.4em;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.form-message.error { color: var(--danger); }
.form-message.success { color: var(--success); }

.preview-panel { display: flex; flex-direction: column; }
.preview-panel iframe {
  width: 100%;
  min-height: 530px;
  border: 1px solid var(--line);
  background: #0c0b0a;
}
.upload-box {
  display: grid;
  gap: 8px;
  margin-top: 20px;
  padding: 15px;
  border: 1px dashed var(--line);
  border-radius: 8px;
}
.upload-box .button { justify-self: start; }
.materials {
  display: grid;
  gap: 10px;
  margin-top: 20px;
}
.material {
  align-items: flex-start;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.material > div:first-child { min-width: 0; }
.material strong { display: block; overflow-wrap: anywhere; }
.material p { margin: 4px 0; overflow-wrap: anywhere; }
.material-actions { display: flex; gap: 6px; flex-shrink: 0; }
details { margin-top: 8px; }
summary { cursor: pointer; color: var(--accent); font-size: 12px; }
pre {
  max-height: 180px;
  overflow: auto;
  padding: 10px;
  white-space: pre-wrap;
  color: var(--ink);
  background: var(--paper);
  border-radius: 6px;
  font: 12px/1.5 var(--sans);
}

.email-grid {
  display: grid;
  gap: 18px;
}
.email-day {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.email-day h3 { margin-bottom: 4px; }

@media (max-width: 760px) {
  .shell { width: min(100% - 24px, 600px); padding-top: 16px; }
  .login-card { margin-top: 8vh; padding: 28px 22px; }
  .topbar { align-items: flex-start; flex-direction: column; padding-bottom: 24px; }
  .top-actions { width: 100%; }
  .top-actions .button { flex: 1; }
  .panel { padding: 20px 16px; }
  .hero { align-items: flex-start; flex-direction: column; }
  .live-note { max-width: none; text-align: left; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .metric { padding: 16px 12px; }
  .metric strong { font-size: 2rem; }
  .workspace-grid { grid-template-columns: 1fr; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .section-heading .button { align-self: stretch; }
  .step-label { width: 115px; }
}

@media (max-width: 470px) {
  .two-col, .color-row { grid-template-columns: 1fr; }
  .funnel-step { gap: 8px; }
  .step-label { width: 100px; font-size: 12px; }
  .material { flex-direction: column; }
  .material-actions { width: 100%; }
  .material-actions .button { flex: 1; }
}

.tool-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.tool-info {
  position: absolute;
  top: -7px;
  right: -7px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  min-height: 18px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
  font-style: italic;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(41, 37, 28, 0.12);
}
.tool-info:hover {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  transform: none;
}
.tool-popover {
  position: fixed;
  z-index: 80;
  width: min(320px, calc(100vw - 32px));
  padding: 14px 16px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.tool-popover h3 {
  margin: 0 0 12px;
  font: 500 1.15rem/1.15 var(--serif);
}
.tool-login-fields {
  display: grid;
  gap: 10px;
  margin: 0;
}
.tool-login-fields dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.tool-login-fields dd {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 0;
  font-size: 13px;
  overflow-wrap: anywhere;
}
.tool-login-fields a { color: var(--ink); }
.tool-copy {
  flex-shrink: 0;
  min-height: 26px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.tool-copy:hover { color: var(--ink); border-color: var(--accent); }

@media (max-width: 760px) {
  .top-actions .tool-btn { flex: 1; }
  .top-actions .tool-btn .button { width: 100%; }
}
