:root {
  --bg: #FAFAF7;
  --surface: #FFFFFF;
  --text: #0A0A0A;
  --text-muted: #71717A;
  --text-faint: #A1A1AA;
  --border: #E7E5E4;
  --border-strong: #D4D4D8;
  --accent: #18181B;
  --accent-action: #C2410C;
  --accent-action-hover: #9A3412;
  --success: #15803D;

  --c-source:   #B45309;
  --c-medium:   #1D4ED8;
  --c-campaign: #7E22CE;
  --c-content:  #047857;
  --c-term:     #BE185D;

  --cat-paid:       #B45309;
  --cat-organic:    #047857;
  --cat-email:      #1D4ED8;
  --cat-whatsapp:   #15803D;
  --cat-other:      #525252;
  --cat-influencer: #BE185D;
  --cat-affiliate:  #7E22CE;
  --cat-offline:    #9A3412;
  --cat-referral:   #1E3A8A;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow:    0 4px 16px rgba(0,0,0,0.06);

  --font-sans: "Hanken Grotesk", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--bg); }
body {
  font-family: var(--font-sans);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: inherit; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select { font-family: inherit; color: inherit; font-size: inherit; }

/* HEADER */
header.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 24px 32px;
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 20px;
}
.logo-box {
  width: 64px; height: 64px;
  border-radius: var(--radius);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 20px; letter-spacing: -0.02em; color: var(--accent);
}
.logo-box svg { width: 100%; height: 100%; display: block; }
.header-text { flex: 1; min-width: 0; }
.header-text h1 {
  font-size: 22px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1;
}
.header-text p { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.header-badge {
  font-family: var(--font-mono);
  font-size: 11px; color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 4px 10px; border-radius: 100px;
  background: var(--bg);
  text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap;
}
.header-actions { display: flex; align-items: center; gap: 12px; }
.link-back {
  font-size: 13px; font-weight: 600; color: var(--text-muted);
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  text-decoration: none; transition: border-color .15s, color .15s;
}
.link-back:hover { border-color: var(--border-strong); color: var(--text); }

/* MAIN */
main {
  flex: 1;
  max-width: 1100px; width: 100%;
  margin: 0 auto;
  padding: 40px 32px;
}
.step { margin-bottom: 40px; }
.step-header { display: flex; align-items: baseline; gap: 12px; margin-bottom: 16px; }
.step-num {
  font-family: var(--font-mono);
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.1em;
  background: var(--surface); border: 1px solid var(--border);
  padding: 3px 10px; border-radius: 100px;
}
.step-title { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.step-helper {
  font-size: 13px; color: var(--text-muted);
  margin-top: 2px; margin-left: 60px; margin-bottom: 16px;
}

/* INPUT — URL base */
.url-input-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 18px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.url-input-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,0,0,0.04); }
.url-input-wrap input {
  width: 100%; border: none; outline: none;
  font-family: var(--font-mono); font-size: 14px; background: transparent;
}

/* CATEGORIAS */
.categories { display: flex; flex-direction: column; gap: 28px; }
.category h3 {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--text-muted); margin-bottom: 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.card {
  position: relative; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; text-align: left; cursor: pointer;
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
  display: flex; align-items: center; gap: 12px;
}
.card::before {
  content: ""; position: absolute; left: 0; top: 12px; bottom: 12px;
  width: 3px; background: var(--cat-color); border-radius: 0 2px 2px 0; opacity: 0.7;
}
.card:hover { transform: translateY(-1px); border-color: var(--cat-color); box-shadow: var(--shadow-sm); }
.card.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(0,0,0,0.06); background: #FAFAFA; }
.card.active::before { opacity: 1; }
.card-icon {
  width: 32px; height: 32px; flex-shrink: 0; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.04); color: var(--cat-color); font-size: 14px; font-weight: 700;
}
.card-text { flex: 1; min-width: 0; }
.card-label { font-size: 13.5px; font-weight: 600; color: var(--text); line-height: 1.25; }

/* FORM */
.form-section, .output-section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 28px; margin-bottom: 24px;
}
.scenario-tag {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 100px; font-size: 12px; font-weight: 600; margin-bottom: 18px;
}
.scenario-tag .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--cat-color); }
.toggle-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px; margin-bottom: 20px;
}
.toggle-switch {
  position: relative; width: 38px; height: 22px;
  background: var(--border-strong); border-radius: 100px;
  cursor: pointer; transition: background 0.15s; flex-shrink: 0;
}
.toggle-switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; background: white; border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2); transition: transform 0.15s;
}
.toggle-switch.on { background: var(--accent); }
.toggle-switch.on::after { transform: translateX(16px); }
.toggle-label { font-size: 14px; font-weight: 500; }
.toggle-label small { display: block; font-size: 12px; color: var(--text-muted); font-weight: 400; margin-top: 1px; }

/* CAMPOS DA UTM */
.fields { display: flex; flex-direction: column; gap: 14px; }
.field { display: grid; grid-template-columns: 130px 1fr; gap: 14px; align-items: start; }
.field-label { font-family: var(--font-mono); font-size: 13px; font-weight: 600; color: var(--text); padding-top: 11px; }
.field-input-wrap {
  position: relative; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 14px; transition: border-color 0.15s, box-shadow 0.15s;
}
.field-input-wrap:focus-within:not(.readonly) {
  border-color: var(--field-color, var(--accent)); background: var(--surface); box-shadow: 0 0 0 3px rgba(0,0,0,0.03);
}
.field-input-wrap.readonly { background: #F4F4F5; border-style: dashed; }
.field-input-wrap input, .field-input-wrap select {
  width: 100%; border: none; outline: none; background: transparent;
  font-family: var(--font-mono); font-size: 13.5px; color: var(--field-color, var(--text)); font-weight: 500;
}
.field-input-wrap input::placeholder { color: var(--text-faint); font-weight: 400; }
.field-meta { margin-top: 6px; font-size: 11.5px; color: var(--text-muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 100px; font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em; background: rgba(0,0,0,0.05); color: var(--text-muted);
}
.badge.macro    { background: rgba(126, 34, 206, 0.08); color: #6B21A8; }
.badge.fixed    { background: rgba(0,0,0,0.05); color: var(--text-muted); }
.badge.tool     { background: rgba(29, 78, 216, 0.08); color: #1E40AF; }
.badge.manual   { background: rgba(180, 83, 9, 0.08); color: #92400E; }
.badge.unused   { background: transparent; color: var(--text-faint); border: 1px dashed var(--border-strong); }
.field.unused .field-input-wrap {
  background: transparent; border: 1px dashed var(--border);
  color: var(--text-faint); font-style: italic; padding: 10px 14px;
}
.field.unused .field-input-wrap::before {
  content: "(não aplicável neste cenário)";
  font-family: var(--font-sans); font-size: 13px; color: var(--text-faint);
}

/* OUTPUT */
.output-title { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.output-subtitle { font-size: 13px; color: var(--text-muted); margin-bottom: 18px; }
.url-breakdown {
  background: #0A0A0A; border-radius: var(--radius);
  padding: 22px 24px; margin-bottom: 18px; overflow-x: auto;
}
.url-breakdown .line { font-family: var(--font-mono); font-size: 13.5px; line-height: 1.85; white-space: nowrap; color: #A1A1AA; }
.url-breakdown .base-url { color: #FAFAFA; }
.url-breakdown .key-source   { color: #FCD34D; }
.url-breakdown .key-medium   { color: #93C5FD; }
.url-breakdown .key-campaign { color: #D8B4FE; }
.url-breakdown .key-content  { color: #6EE7B7; }
.url-breakdown .key-term     { color: #F9A8D4; }
.url-breakdown .val { color: #FAFAFA; }
.url-breakdown .punct { color: #71717A; }
.url-final {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; font-family: var(--font-mono); font-size: 13px;
  word-break: break-all; line-height: 1.5; margin-bottom: 14px;
}
.url-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-primary, .btn-secondary {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 600;
  transition: transform 0.1s, background 0.15s, border-color 0.15s;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: #27272A; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary.copied { background: var(--success); }
.btn-secondary { background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.btn-secondary:hover { border-color: var(--border-strong); }

/* QR */
.qr-section { margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--border); }
.qr-title { font-size: 14px; font-weight: 700; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.qr-subtitle { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; }
.qr-wrap { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.qr-canvas { background: white; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); }
.qr-canvas svg { display: block; width: 200px; height: 200px; }
.qr-actions { display: flex; flex-direction: column; gap: 8px; }
.empty-state {
  text-align: center; padding: 40px 20px; color: var(--text-muted); font-size: 14px;
  background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius-lg);
}

/* ===== SHELL / HOME (novo) ===== */
.userbar {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--text-muted);
}
.userbar .who { font-weight: 600; color: var(--text); }
.pill {
  font-family: var(--font-mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em;
  padding: 3px 9px; border-radius: 100px; border: 1px solid var(--border); background: var(--bg); color: var(--text-muted);
}
.pill.admin { background: rgba(126,34,206,0.08); color: #6B21A8; border-color: transparent; }

.carteira { margin-bottom: 36px; }
.carteira-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.carteira-head h2 { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.carteira-head .count { font-size: 12px; color: var(--text-muted); }

.account-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.account-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px; text-align: left; cursor: pointer; text-decoration: none;
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.account-card:hover { transform: translateY(-2px); border-color: var(--border-strong); box-shadow: var(--shadow); }
.account-mark {
  width: 48px; height: 48px; flex-shrink: 0; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff; font-weight: 800; font-size: 16px; letter-spacing: -0.02em;
}
.account-info h3 { font-size: 15px; font-weight: 700; line-height: 1.2; }
.account-info p { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.state-box {
  max-width: 520px; margin: 60px auto; text-align: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 40px 32px;
}
.state-box h2 { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.state-box p { font-size: 14px; color: var(--text-muted); }
.state-box code { font-family: var(--font-mono); font-size: 12px; background: var(--bg); padding: 2px 6px; border-radius: 4px; }

/* FOOTER */
footer {
  margin-top: auto; padding: 28px 32px;
  background: var(--surface); border-top: 1px solid var(--border);
  text-align: center; font-size: 13px; color: var(--text-muted);
}
footer a { color: var(--text); font-weight: 600; text-decoration: none; border-bottom: 1px solid var(--border-strong); transition: border-color 0.15s; }
footer a:hover { border-color: var(--accent); }

/* responsivo */
@media (max-width: 720px) {
  main { padding: 24px 16px; }
  header.app-header { padding: 16px; }
  .form-section, .output-section { padding: 18px; }
  .field { grid-template-columns: 1fr; gap: 6px; }
  .field-label { padding-top: 0; }
  .step-helper { margin-left: 0; }
  .header-text h1 { font-size: 18px; }
  .header-badge { display: none; }
  .card-grid { grid-template-columns: 1fr; }
}
