/* AdZep Intelligence Hub - styles v0.2 */
:root {
  --bg:        #0d1117;
  --bg-soft:   #161b22;
  --bg-card:   #1c2128;
  --bg-input:  #0d1117;
  --border:    #30363d;
  --border-2:  #444c56;
  --text:      #e6edf3;
  --text-soft: #c9d1d9;
  --text-muted:#7d8590;
  --accent:    #58a6ff;
  --accent-2:  #1f6feb;
  --green:     #3fb950;
  --amber:     #d29922;
  --red:       #f85149;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: rgba(110,118,129,.4); padding: 1px 5px; border-radius: 3px; font-size: .9em; }
.dim { color: var(--text-muted); }
.hidden { display: none !important; }

/* Topbar */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 24px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 14px; font-size: 16px; }
.logo { font-size: 22px; }
.name strong { color: var(--accent); margin-left: 4px; }
.health-mini { font-size: 12px; color: var(--text-muted); margin-left: 16px; padding-left: 16px; border-left: 1px solid var(--border); }

.actions { display: flex; gap: 10px; align-items: center; }
.pub-select {
  background: var(--bg-card); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 10px; font-size: 13px;
}
.btn {
  padding: 7px 14px; border-radius: 6px;
  border: 1px solid var(--border); cursor: pointer;
  font-size: 13px; font-weight: 500;
  background: var(--bg-card); color: var(--text);
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--bg-soft); border-color: var(--border-2); }
.btn-primary { background: var(--accent-2); color: white; border-color: var(--accent-2); }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); }
.btn-danger { background: transparent; color: var(--red); border-color: var(--red); }
.btn-danger:hover { background: rgba(248,81,73,.1); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* Tabs */
.tabs {
  display: flex; padding: 0 24px;
  background: var(--bg-soft); border-bottom: 1px solid var(--border);
}
.tab {
  padding: 12px 20px; color: var(--text-muted);
  border-bottom: 2px solid transparent; font-weight: 500;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

/* Subtabs (dentro da Base) */
.subtabs {
  display: flex; gap: 0; padding: 0 4px;
  border-bottom: 1px solid var(--border); margin-bottom: 16px;
}
.subtab { padding: 8px 16px; color: var(--text-muted); border-bottom: 2px solid transparent; font-size: 13px; }
.subtab:hover { color: var(--text); text-decoration: none; }
.subtab.active { color: var(--text); border-bottom-color: var(--accent); }

.tab-panel, .subtab-panel { display: none; }
.tab-panel.active, .subtab-panel.active { display: block; }

/* Content */
.content { flex: 1; padding: 24px; max-width: 1400px; width: 100%; margin: 0 auto; }
.placeholder {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px;
  padding: 32px; max-width: 800px; margin: 40px auto;
}
.placeholder h1 { margin: 0 0 8px 0; font-size: 22px; }
.placeholder h1 small { color: var(--text-muted); font-weight: 400; font-size: 14px; margin-left: 8px; }
.placeholder p { color: var(--text-soft); }

/* Cards */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px; padding: 20px; margin-bottom: 16px;
}
.card h2 { margin: 0; font-size: 16px; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 12px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
table.data th, table.data td {
  text-align: left; padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data th {
  font-weight: 500; color: var(--text-muted);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
  background: var(--bg-soft);
}
table.data tr:hover td { background: rgba(88,166,255,.04); }
table.data .actions-cell { text-align: right; white-space: nowrap; }
table.data .actions-cell .btn { margin-left: 4px; }

.pill {
  display: inline-block;
  padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 500;
  background: var(--bg-soft); border: 1px solid var(--border);
}
.pill-usd { color: var(--green); border-color: var(--green); }
.pill-brl { color: var(--amber); border-color: var(--amber); }
.pill-360 { color: var(--accent); border-color: var(--accent); }
.pill-smb { color: var(--text-muted); }

.pill-status-draft   { color: var(--text-muted); }
.pill-status-active  { color: var(--green); border-color: var(--green); }
.pill-status-paused  { color: var(--amber); border-color: var(--amber); }
.pill-status-expired { color: var(--red); border-color: var(--red); }

textarea { resize: vertical; min-height: 60px; }

.action-tag {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11px; padding: 1px 6px; border-radius: 3px;
  background: rgba(88,166,255,.1); color: var(--accent);
}
.action-tag.delete { background: rgba(248,81,73,.1); color: var(--red); }
.action-tag.update { background: rgba(210,153,34,.1); color: var(--amber); }
.action-tag.create { background: rgba(63,185,80,.1); color: var(--green); }

/* Badge */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: 12px; font-weight: 500;
}
.badge-pending { background: var(--bg-soft); color: var(--text-muted); border: 1px solid var(--border); }
.badge-ok      { background: rgba(63,185,80,.15); color: var(--green); border: 1px solid var(--green); }
.badge-fail    { background: rgba(248,81,73,.15); color: var(--red); border: 1px solid var(--red); }

/* Modal */
.modal-root { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.65); }
.modal {
  position: relative; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px; width: min(640px, 92vw); max-height: 90vh;
  display: flex; flex-direction: column;
}
.modal-header { padding: 14px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { margin: 0; font-size: 16px; }
.modal-close { background: transparent; border: none; color: var(--text-muted); font-size: 22px; cursor: pointer; line-height: 1; padding: 0; width: 28px; height: 28px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* Forms */
.form-row { margin-bottom: 14px; }
.form-row.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row label {
  display: block; font-size: 12px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .03em; margin-bottom: 4px;
}
.form-row label .req { color: var(--red); margin-left: 2px; }
.form-row input, .form-row select, .form-row textarea {
  width: 100%; background: var(--bg-input); color: var(--text);
  border: 1px solid var(--border); border-radius: 5px;
  padding: 7px 10px; font-size: 13px; font-family: inherit;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  outline: none; border-color: var(--accent);
}
.form-row .hint { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.form-error { background: rgba(248,81,73,.08); border: 1px solid var(--red); color: var(--red); padding: 10px 12px; border-radius: 5px; font-size: 12px; margin-bottom: 12px; }
.form-error ul { margin: 4px 0 0 0; padding-left: 20px; }

/* Footer */
.footer {
  display: flex; justify-content: space-between;
  padding: 12px 24px; border-top: 1px solid var(--border);
  color: var(--text-muted); font-size: 12px;
}

/* Audit log */
.event-row .diff { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11px; color: var(--text-muted); }
.event-row .ts { white-space: nowrap; color: var(--text-muted); font-size: 12px; }


/* ─── Rule builder (form visual sem JSON) ─── */
.rb-section {
  padding: 18px 0 22px;
  border-bottom: 1px solid var(--border);
}
.rb-section:last-child { border-bottom: none; padding-bottom: 4px; }

.rb-title {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 14px 0; font-size: 14px; font-weight: 600;
  color: var(--text);
}
.rb-title-soft { color: var(--text-muted); font-weight: 500; font-size: 13px; }
.rb-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent-2); color: white;
  font-size: 11px; font-weight: 700;
}
.rb-optional {
  font-size: 11px; padding: 1px 8px;
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text-muted);
  font-weight: 400; margin-left: 6px;
}
.rb-hint {
  font-size: 12px; color: var(--text-soft);
  background: rgba(88,166,255,.06); border-left: 2px solid var(--accent);
  padding: 10px 12px; border-radius: 3px; margin-top: 10px;
}
.rb-hint-soft {
  font-size: 12px; color: var(--text-muted); margin-top: 6px;
}
.rb-label-soft {
  display: block; font-size: 12px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .03em; margin-bottom: 4px;
}

.rb-input {
  width: 100%; background: var(--bg-input); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 10px 12px; font-size: 14px; font-family: inherit;
}
.rb-input:focus { outline: none; border-color: var(--accent); }
.rb-input-lg { font-size: 17px; padding: 12px 14px; font-weight: 500; }

/* Picker (publishers + templates) */
.picker-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.picker-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border: 2px solid var(--border);
  border-radius: 8px; background: var(--bg-soft);
  cursor: pointer; transition: all .15s;
}
.picker-card:hover { border-color: var(--border-2); background: var(--bg-card); }
.picker-card.selected {
  border-color: var(--accent);
  background: rgba(88,166,255,.08);
  box-shadow: 0 0 0 1px var(--accent) inset;
}
.picker-icon { font-size: 26px; line-height: 1; }
.picker-body { flex: 1; min-width: 0; }
.picker-body strong { display: block; font-size: 14px; }
.picker-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.tpl-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

/* KVs (condicoes) */
.kvs-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.kv-row {
  display: flex; align-items: center; gap: 8px;
  padding: 10px; background: var(--bg-soft);
  border: 1px solid var(--border); border-radius: 6px;
}
.kv-row select, .kv-row input {
  background: var(--bg-input); color: var(--text);
  border: 1px solid var(--border); border-radius: 5px;
  padding: 7px 10px; font-size: 13px; flex: 1;
}
.kv-row .kv-dim { flex: 1.3; }
.kv-row .kv-eq { color: var(--text-muted); font-weight: 500; }
.kv-remove {
  width: 28px; height: 28px; padding: 0; line-height: 1;
  background: transparent; border: 1px solid var(--border);
  color: var(--text-muted); border-radius: 5px; cursor: pointer;
  font-size: 16px;
}
.kv-remove:hover { color: var(--red); border-color: var(--red); }
.btn-add {
  background: transparent; border: 1px dashed var(--border-2);
  color: var(--accent); padding: 9px 14px;
}
.btn-add:hover { background: rgba(88,166,255,.05); border-style: solid; border-color: var(--accent); }

/* Floor (com simbolo de moeda) */
.floor-input-wrap {
  display: flex; align-items: center; gap: 10px;
  max-width: 360px;
  padding: 8px 14px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 8px;
}
.floor-input-wrap:focus-within { border-color: var(--accent); }
.floor-symbol { font-size: 22px; font-weight: 600; color: var(--accent); }
.floor-input-wrap input {
  flex: 1; background: transparent; border: none; color: var(--text);
  font-size: 22px; font-weight: 500; padding: 4px 0;
}
.floor-input-wrap input:focus { outline: none; }
.floor-cur { font-size: 13px; }
.floor-cell { font-weight: 500; font-variant-numeric: tabular-nums; }

/* Status pills clicaveis */
.status-toggle { display: inline-flex; gap: 0; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px; padding: 3px; }
.status-pill {
  background: transparent; border: none; cursor: pointer;
  padding: 7px 16px; font-size: 13px; color: var(--text-muted);
  border-radius: 5px; font-weight: 500; transition: all .15s;
}
.status-pill:hover { color: var(--text); }
.status-pill.active { background: var(--accent-2); color: white; }

/* Empty state */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-icon { font-size: 48px; margin-bottom: 8px; }
.empty-state h3 { margin: 0 0 4px 0; font-size: 18px; }
.empty-state p { margin: 0 0 18px 0; }

/* Tabela de regras */
.rules-table .tpl-mini { font-size: 18px; }
.rules-table .small { font-size: 11px; }
.dim.small { font-size: 11px; }

/* Modal maior pra acomodar o builder */
.modal-root .modal { width: min(820px, 94vw); }
.modal-body { padding: 4px 24px 18px; }


/* ─── Importar dados (drag-drop) ─── */
.dropzone {
  border: 2px dashed var(--border-2);
  border-radius: 12px;
  padding: 36px 20px;
  text-align: center;
  background: var(--bg-soft);
  transition: all .15s;
  cursor: pointer;
}
.dropzone:hover, .dropzone.drag-over {
  border-color: var(--accent);
  background: rgba(88,166,255,.05);
}
.dz-icon { font-size: 40px; margin-bottom: 6px; }
.dz-title { font-size: 16px; font-weight: 500; margin-bottom: 4px; }
.dz-sub { color: var(--text-muted); font-size: 13px; }

.files-list { margin-top: 16px; display: flex; flex-direction: column; gap: 6px; }
.file-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
}
.file-icon { font-size: 20px; }
.file-body { flex: 1; min-width: 0; }
.file-body strong { display: block; }
.file-status { font-size: 12px; }

.summary-header {
  font-size: 14px; font-weight: 500; color: var(--green);
  margin: 18px 0 10px 0;
}
.summary-card {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 10px;
}
.summary-card h4 { margin: 0 0 10px 0; font-size: 14px; }
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}
.kpi-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi-val { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; }


/* ─── Briefing (Quick Wins) ─── */
.briefing-root { padding: 4px 0; }
.briefing-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 16px; gap: 16px; flex-wrap: wrap; }
.briefing-meta h1 { margin: 0; font-size: 22px; }
.briefing-meta .small { font-size: 12px; }
.briefing-summary {
  background: var(--bg-card);
  border-left: 3px solid var(--accent);
  padding: 14px 18px;
  border-radius: 0 8px 8px 0;
  font-size: 14px;
  margin-bottom: 18px;
  color: var(--text-soft);
}
.briefing-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 14px;
}
.briefing-card { padding: 18px; }
.briefing-card-title {
  margin: 0 0 14px 0;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.briefing-card-icon { font-size: 20px; }

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
}
.kpi-block {
  padding: 10px 12px;
  background: var(--bg-soft);
  border-radius: 6px;
  border: 1px solid var(--border);
}
.kpi-delta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.briefing-list {
  list-style: none; padding: 0; margin: 0;
}
.briefing-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.briefing-list li:last-child { border-bottom: none; }

.severity-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 8px; vertical-align: middle;
}
.sev-info { background: var(--accent); }
.sev-warn { background: var(--amber); }
.sev-crit { background: var(--red); }

.pill-verdict-ganhou  { color: var(--green); border-color: var(--green); }
.pill-verdict-perdeu  { color: var(--red); border-color: var(--red); }
.pill-verdict-neutro  { color: var(--text-muted); }
.pill-verdict-cedo    { color: var(--amber); border-color: var(--amber); }


/* ─── Briefing v0.2 (oportunidades com floor + data quality) ─── */
.data-quality-banner {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 14px;
  border-left: 3px solid;
}
.data-quality-banner.sev-warn { background: rgba(210,153,34,0.08); border-color: var(--amber); color: var(--amber); }
.data-quality-banner.sev-crit { background: rgba(248,81,73,0.08); border-color: var(--red); color: var(--red); }

.card-summary {
  font-size: 13px; color: var(--text-soft);
  padding: 8px 10px; background: rgba(88,166,255,0.05);
  border-left: 2px solid var(--accent); border-radius: 0 4px 4px 0;
  margin-bottom: 12px;
}

/* Oportunidades com floor sugerido */
.opp-item {
  padding: 14px !important;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border) !important;
}
.opp-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  margin-bottom: 6px;
}
.opp-head strong { font-size: 14px; flex: 1; }
.opp-floor {
  text-align: right; padding: 4px 10px;
  background: rgba(63,185,80,0.1); border: 1px solid var(--green);
  border-radius: 6px; line-height: 1.2;
}
.opp-floor-label { display: block; font-size: 9px; text-transform: uppercase; color: var(--green); letter-spacing: .04em; }
.opp-floor-val { display: block; font-size: 16px; font-weight: 600; color: var(--green); font-variant-numeric: tabular-nums; }
.opp-thesis { color: var(--text-soft); margin-top: 6px; }
.opp-kvs { font-size: 12px; margin-top: 6px; }
.opp-kvs code { font-size: 11px; }
.opp-rationale { margin-top: 4px; font-style: italic; }
.opp-upside { font-size: 12px; color: var(--green); margin-top: 4px; }
