/* ============= MERC DF · APP STYLES ============= */
/* Identidade compartilhada com a landing — herda tokens, adiciona padrões de plataforma */

:root {
  --bg: #0a0a0a;
  --bg-2: #111111;
  --bg-3: #1a1a1a;
  --bg-card: rgba(255,255,255,0.02);
  --bg-elev: #161616;
  --border: rgba(255,255,255,0.08);
  --border-2: rgba(255,255,255,0.16);
  --text: #f5f5f5;
  --text-2: #cccccc;
  --text-3: #888888;
  --text-m: #555555;

  --bg-light: #FFFFFF;
  --bg-warm: #FAF7EC;
  --bg-cream: #FBF9F4;
  --border-light: #E2E2EA;
  --text-light: #0A0A1F;
  --text-light-2: #2D2D3F;
  --text-light-3: #6E6E83;

  --gold: #c8a020;
  --gold-2: #a88420;
  --gold-dim: #7a5f17;
  --gold-light-bg: #d8c280;
  --neon: #e1fe05;
  --neon-dark: #b8d004;
  --neon-soft: rgba(225,254,5,0.12);
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --cyan: #06b6d4;
  --purple: #a855f7;

  --serif: 'Playfair Display', Georgia, serif;
  --sans: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --logo: 'Kiona', 'Outfit', 'Montserrat', sans-serif;
  --mono: 'JetBrains Mono', 'SFMono-Regular', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
::selection { background: var(--neon); color: var(--bg); }
*:focus { outline: none; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--neon); outline-offset: 3px; border-radius: 4px;
}

/* ============= APP SHELL (sidebar + main) ============= */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand {
  padding: 0 24px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-brand .logo-merc {
  font-family: var(--logo);
  font-size: 22px;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 1px;
}
.sidebar-brand .logo-divider {
  width: 1px;
  height: 18px;
  background: var(--border-2);
}
.sidebar-brand .logo-product {
  font-family: var(--logo);
  font-size: 12px;
  font-weight: 500;
  color: var(--gold);
  letter-spacing: 3px;
  text-transform: uppercase;
}

.sidebar-section {
  padding: 20px 16px 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-3);
  text-transform: uppercase;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  font-size: 13px;
  color: var(--text-2);
  transition: all .15s;
  border-left: 3px solid transparent;
}
.sidebar-link:hover {
  background: rgba(255,255,255,0.02);
  color: var(--text);
}
.sidebar-link.active {
  border-left-color: var(--neon);
  color: var(--neon);
  background: var(--neon-soft);
}
.sidebar-link .icon {
  font-family: var(--mono);
  font-size: 12px;
  width: 18px;
  text-align: center;
  color: var(--gold);
}
.sidebar-link.active .icon { color: var(--neon); }

.sidebar-user {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-2);
}
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-2), var(--neon));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 700;
  color: var(--bg);
  font-size: 14px;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 12px; color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 10px; color: var(--text-3); letter-spacing: 1px; text-transform: uppercase; }

/* MAIN */
.main {
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(10,10,10,0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 18px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.main-title { font-family: var(--serif); font-size: 22px; font-weight: 700; letter-spacing: -0.3px; }
.main-title .crumb { color: var(--text-3); font-weight: 400; }
.main-title em { font-style: italic; color: var(--neon); }
.main-actions { display: flex; gap: 12px; align-items: center; }

.main-body { padding: 32px; max-width: 1400px; width: 100%; margin: 0 auto; }

/* ============= BUTTONS ============= */
.btn {
  padding: 12px 20px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all .15s;
  font-family: var(--sans);
  text-decoration: none;
}
.btn-primary { background: var(--neon); color: var(--bg); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(225,254,5,0.3); }
.btn-secondary { background: transparent; color: var(--text); border: 1px solid var(--border-2); }
.btn-secondary:hover { border-color: var(--neon); color: var(--neon); }
.btn-gold { background: var(--gold); color: var(--bg); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { color: var(--neon); }
.btn-sm { padding: 8px 14px; font-size: 11px; }
.btn-lg { padding: 16px 28px; font-size: 14px; }
.btn-block { width: 100%; justify-content: center; }

/* ============= CARDS ============= */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
}
.card.elev { background: var(--bg-elev); }
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-family: var(--serif); font-size: 20px; font-weight: 700; letter-spacing: -0.3px; }
.card-title em { color: var(--neon); font-style: italic; }
.card-eyebrow { font-size: 10px; font-weight: 700; letter-spacing: 2px; color: var(--gold); text-transform: uppercase; margin-bottom: 6px; }

/* ============= STATS / KPI ============= */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}
.kpi {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  position: relative;
  overflow: hidden;
}
.kpi::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--gold-2), var(--neon));
}
.kpi-label { font-size: 11px; color: var(--text-3); letter-spacing: 2px; text-transform: uppercase; font-weight: 600; margin-bottom: 12px; }
.kpi-value { font-family: var(--serif); font-size: 36px; font-weight: 700; line-height: 1; letter-spacing: -1px; color: var(--text); font-style: italic; }
.kpi-value .small { font-size: 14px; color: var(--text-3); font-family: var(--sans); font-style: normal; }
.kpi-delta { font-size: 11px; margin-top: 8px; font-family: var(--mono); }
.kpi-delta.up { color: var(--green); }
.kpi-delta.down { color: var(--red); }

/* ============= TABLE ============= */
.table-wrap { background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  background: var(--bg-3);
  text-align: left;
  padding: 14px 16px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-3);
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}
.table td {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-2);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: rgba(255,255,255,0.02); cursor: pointer; }
.table .col-name { font-family: var(--serif); font-size: 14px; color: var(--text); font-weight: 600; }
.table .col-mono { font-family: var(--mono); font-size: 12px; color: var(--text-2); }
.table .col-num { font-family: var(--mono); font-size: 13px; text-align: right; color: var(--text); }

/* ============= BADGE / STATUS ============= */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  border: 1px solid;
}
.badge.processing { color: var(--cyan); border-color: rgba(6,182,212,0.3); background: rgba(6,182,212,0.08); }
.badge.review { color: var(--amber); border-color: rgba(245,158,11,0.3); background: rgba(245,158,11,0.08); }
.badge.delivered { color: var(--green); border-color: rgba(34,197,94,0.3); background: rgba(34,197,94,0.08); }
.badge.failed { color: var(--red); border-color: rgba(239,68,68,0.3); background: rgba(239,68,68,0.08); }
.badge.queued { color: var(--text-3); border-color: var(--border-2); }
.badge.dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ============= FORMS ============= */
.field { margin-bottom: 20px; }
.field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: var(--text-2);
  text-transform: uppercase;
  margin-bottom: 8px;
}
.field label .opt { color: var(--text-m); font-weight: 400; text-transform: lowercase; letter-spacing: 0; }
.field input, .field select, .field textarea {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  padding: 13px 16px;
  border-radius: 6px;
  transition: border-color .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--neon);
  outline: none;
}
.field-hint { font-size: 11px; color: var(--text-3); margin-top: 6px; line-height: 1.5; }

.field-group { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 768px) { .field-group { grid-template-columns: 1fr; } }

/* ============= UPLOAD ZONE ============= */
.upload-zone {
  border: 2px dashed var(--border-2);
  border-radius: 12px;
  padding: 48px 32px;
  text-align: center;
  background: var(--bg-2);
  cursor: pointer;
  transition: all .2s;
}
.upload-zone:hover {
  border-color: var(--neon);
  background: rgba(225,254,5,0.02);
}
.upload-zone .icon {
  font-family: var(--serif);
  font-size: 48px;
  color: var(--gold);
  font-style: italic;
  margin-bottom: 12px;
}
.upload-zone h4 {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}
.upload-zone p {
  font-size: 13px;
  color: var(--text-3);
}
.upload-zone .accepted {
  margin-top: 16px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--text-m);
}

/* ============= PIPELINE STEPS (timeline) ============= */
.timeline { position: relative; padding-left: 40px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 14px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, var(--neon) 0%, var(--gold-2) 100%);
  opacity: 0.3;
}
.timeline-step {
  position: relative;
  padding: 20px 24px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 16px;
}
.timeline-step::before {
  content: '';
  position: absolute;
  left: -32px;
  top: 24px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--gold-2);
}
.timeline-step.done::before { background: var(--green); border-color: var(--green); }
.timeline-step.active::before { background: var(--neon); border-color: var(--neon); box-shadow: 0 0 0 4px var(--neon-soft); }
.timeline-step.failed::before { background: var(--red); border-color: var(--red); }

.timeline-step-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.timeline-step-num {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--gold);
  letter-spacing: 2px;
  font-weight: 700;
}
.timeline-step-title {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin-bottom: 6px;
}
.timeline-step-desc { font-size: 13px; color: var(--text-2); line-height: 1.6; }
.timeline-step-meta {
  margin-top: 12px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 1px;
}
.timeline-step-meta span { display: inline-flex; align-items: center; gap: 4px; }

/* ============= AGENT CARD ============= */
.agent-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-top: 32px;
}
.agent-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  position: relative;
  overflow: hidden;
}
.agent-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--gold-2), var(--neon));
}
.agent-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
}
.agent-num {
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 700;
  font-style: italic;
  color: var(--neon);
  line-height: 1;
  letter-spacing: -1px;
}
.agent-model-badge {
  font-family: var(--mono);
  font-size: 10px;
  padding: 4px 8px;
  border-radius: 4px;
  background: var(--bg-3);
  color: var(--text-2);
  letter-spacing: 0.5px;
  border: 1px solid var(--border);
}
.agent-model-badge.deterministic { color: var(--green); border-color: rgba(34,197,94,0.3); }
.agent-model-badge.sonnet { color: var(--cyan); border-color: rgba(6,182,212,0.3); }
.agent-model-badge.opus { color: var(--purple); border-color: rgba(168,85,247,0.3); }
.agent-model-badge.gpt { color: var(--amber); border-color: rgba(245,158,11,0.3); }

.agent-name { font-family: var(--serif); font-size: 20px; font-weight: 700; letter-spacing: -0.3px; margin-bottom: 6px; }
.agent-purpose { font-size: 13px; color: var(--text-2); line-height: 1.6; margin-bottom: 16px; }
.agent-io {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.agent-io-block { font-size: 11px; }
.agent-io-block .lbl { color: var(--text-3); letter-spacing: 1.5px; text-transform: uppercase; font-weight: 700; margin-bottom: 4px; }
.agent-io-block .val { font-family: var(--mono); color: var(--text-2); font-size: 11px; }

.agent-webhook {
  margin-top: 12px;
  padding: 8px 12px;
  background: var(--bg-3);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--neon);
  letter-spacing: 0.5px;
  word-break: break-all;
}

/* ============= LOGIN / AUTH ============= */
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.auth-side {
  background: linear-gradient(135deg, var(--bg-2) 0%, var(--bg) 100%);
  padding: 64px 64px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-right: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.auth-side::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--gold-2), var(--neon));
}
.auth-form-area {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 64px 64px;
  background: var(--bg);
}
.auth-card {
  max-width: 440px;
  width: 100%;
  margin: 0 auto;
}
.auth-card h1 {
  font-family: var(--serif);
  font-size: 38px;
  font-weight: 700;
  letter-spacing: -1px;
  margin-bottom: 12px;
  line-height: 1.1;
}
.auth-card h1 em { color: var(--neon); font-style: italic; }
.auth-card .lead { font-size: 15px; color: var(--text-2); margin-bottom: 32px; line-height: 1.6; }

@media (max-width: 880px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .auth-form-area { padding: 32px 24px; min-height: 100vh; justify-content: center; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .agent-grid { grid-template-columns: 1fr; }
}

/* ============= UTILITY ============= */
.gold { color: var(--gold); }
.neon { color: var(--neon); }
.mono { font-family: var(--mono); }
.serif { font-family: var(--serif); }
.italic { font-style: italic; }
.center { text-align: center; }
.mt-0 { margin-top: 0; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }
.mb-0 { margin-bottom: 0; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text-3 { color: var(--text-3); }
.text-2 { color: var(--text-2); }
.hairline { height: 1px; background: var(--border); margin: 24px 0; border: 0; }
.hairline-gold { height: 2px; background: linear-gradient(90deg, var(--gold-2), var(--neon)); margin: 24px 0; border: 0; }
