:root {
  --orange: #F26B1D;
  --orange-600: #DB5A10;
  --orange-50: #FFF4EC;
  --orange-100: #FFE6D4;
  --ink: #1F2328;
  --gray-700: #3F454D;
  --gray-500: #6B7280;
  --gray-400: #9AA1AB;
  --gray-300: #D6DAE0;
  --gray-200: #E7EAEE;
  --gray-100: #F3F4F6;
  --gray-50: #F8F9FA;
  --white: #FFFFFF;
  --ok: #1E9E62;
  --warn: #D98A00;
  --err: #D23C3C;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 4px 16px rgba(16,24,40,.06);
  --sidebar: 248px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--ink); background: var(--gray-50); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 15px; color: var(--ink); }
.hidden { display: none !important; }
[hidden] { display: none !important; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar); background: var(--white); border-right: 1px solid var(--gray-200);
  display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; z-index: 40; padding: 20px 14px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 22px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px; background: var(--orange); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 20px; letter-spacing: -.5px;
}
.brand-mark.lg { width: 64px; height: 64px; border-radius: 18px; font-size: 32px; margin: 0 auto 14px; }
.brand-name { font-weight: 700; font-size: 16px; }
.brand-sub { font-size: 12px; color: var(--gray-500); }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; border: 0; background: transparent; color: var(--gray-700);
  padding: 11px 12px; border-radius: 12px; font-size: 14.5px; font-weight: 500; text-align: left;
}
.nav-item:hover { background: var(--gray-100); }
.nav-item.active { background: var(--orange-50); color: var(--orange-600); font-weight: 600; }
.nav-item svg { color: currentColor; }
.sidebar-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }
.credit { font-size: 12px; color: var(--gray-400); text-align: center; }
.main { flex: 1; margin-left: var(--sidebar); min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; background: rgba(248,249,250,.92); backdrop-filter: blur(8px);
  display: flex; align-items: center; gap: 12px; padding: 14px 28px; border-bottom: 1px solid var(--gray-200);
}
.topbar-title { font-weight: 700; font-size: 18px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.content { padding: 24px 28px 48px; max-width: 1080px; width: 100%; }
.view { display: none; }
.view.active { display: block; }
.scrim { display: none; }
.icon-btn.only-mobile { display: none; }

/* ---------- Componentes ---------- */
.card { background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { font-size: 17px; margin: 0; font-weight: 700; }
.muted { color: var(--gray-500); margin: -4px 0 16px; font-size: 14px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 12px;
  padding: 11px 16px; font-size: 14.5px; font-weight: 600; border: 1px solid transparent; transition: .15s; white-space: nowrap;
}
.btn svg { width: 18px; height: 18px; }
.btn-sm { padding: 8px 12px; font-size: 13.5px; }
.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--orange-600); }
.btn-ghost { background: var(--white); color: var(--gray-700); border-color: var(--gray-300); }
.btn-ghost:hover:not(:disabled) { border-color: var(--orange); color: var(--orange-600); }
.btn-danger { background: #fff; color: var(--err); border-color: #F1C4C4; }
.btn-danger:hover { background: #FDF1F1; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-install { background: var(--ink); color: #fff; width: 100%; }
.btn-install:hover { background: #000; }
.icon-btn { border: 0; background: transparent; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; color: var(--gray-700); }
.icon-btn:hover { background: var(--gray-100); }
.icon-btn.on { color: var(--orange); }
.icon-btn.on svg { fill: var(--orange); }
.link-btn { border: 0; background: none; color: var(--gray-500); text-decoration: underline; font-size: 14px; margin-top: 18px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.label { font-size: 13px; font-weight: 600; color: var(--gray-700); }
.hint { font-size: 12.5px; color: var(--gray-500); min-height: 0; }
input[type=text], input[type=url], input[type=search], select, textarea {
  width: 100%; border: 1px solid var(--gray-300); border-radius: var(--radius-sm); padding: 11px 12px; background: #fff; outline: none; transition: .15s;
}
textarea { resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus { border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-100); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--gray-700); cursor: pointer; }
.check input { accent-color: var(--orange); width: 16px; height: 16px; }
.mt { margin-top: 16px; }
.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

/* Etapas */
.steps { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--gray-500); background: #fff; border: 1px solid var(--gray-200); padding: 7px 12px 7px 8px; border-radius: 999px; font-weight: 500; }
.step span { width: 22px; height: 22px; border-radius: 50%; background: var(--gray-200); color: var(--gray-700); display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.step.active { color: var(--orange-600); border-color: var(--orange-100); background: var(--orange-50); }
.step.active span { background: var(--orange); color: #fff; }
.step.done span { background: var(--ink); color: #fff; }

/* Tipos */
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.type-card {
  display: flex; gap: 12px; align-items: flex-start; text-align: left; background: #fff; border: 1.5px solid var(--gray-200);
  border-radius: 14px; padding: 14px; transition: .15s; color: var(--ink);
}
.type-card:hover { border-color: var(--orange); }
.type-card.active { border-color: var(--orange); background: var(--orange-50); box-shadow: 0 0 0 3px var(--orange-100); }
.type-card .ti { width: 38px; height: 38px; border-radius: 10px; background: var(--orange-50); color: var(--orange); display: grid; place-items: center; }
.type-card.active .ti { background: var(--orange); color: #fff; }
.type-card b { display: block; font-size: 14.5px; margin-bottom: 2px; }
.type-card small { color: var(--gray-500); font-size: 12.5px; line-height: 1.4; display: block; }
.chip-type { font-size: 12.5px; font-weight: 600; background: var(--gray-100); color: var(--gray-700); padding: 5px 10px; border-radius: 999px; }
.chip-type.on { background: var(--orange-50); color: var(--orange-600); }

.textarea-wrap { position: relative; }
.textarea-wrap textarea { padding-bottom: 54px; }
.mic-btn {
  position: absolute; right: 10px; bottom: 10px; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--gray-300);
  background: #fff; border-radius: 999px; padding: 7px 14px; font-size: 13.5px; font-weight: 600; color: var(--gray-700);
}
.mic-btn svg { width: 17px; height: 17px; }
.mic-btn:hover { border-color: var(--orange); color: var(--orange-600); }
.mic-btn.rec { background: var(--orange); border-color: var(--orange); color: #fff; animation: pulse 1.4s infinite; }
@keyframes pulse { 0%{box-shadow:0 0 0 0 rgba(242,107,29,.45)} 70%{box-shadow:0 0 0 10px rgba(242,107,29,0)} 100%{box-shadow:0 0 0 0 rgba(242,107,29,0)} }

.type-options { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.type-options .full { grid-column: 1 / -1; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1.5px solid var(--gray-300); background: #fff; color: var(--gray-700); padding: 7px 13px; border-radius: 999px; font-size: 13.5px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip:hover { border-color: var(--orange); }
.chip.on { border-color: var(--orange); background: var(--orange-50); color: var(--orange-600); font-weight: 600; }
.chip.on::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--orange); }
.chips-empty { font-size: 13px; color: var(--gray-500); }
.seg { display: inline-flex; background: var(--gray-100); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { border: 0; background: transparent; padding: 8px 16px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--gray-700); }
.seg button.active { background: #fff; color: var(--orange-600); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.notice { display: flex; gap: 10px; align-items: flex-start; background: var(--gray-50); border: 1px dashed var(--gray-300); border-radius: 12px; padding: 10px 12px; margin-top: 12px; font-size: 13px; color: var(--gray-700); }
.notice svg { color: var(--orange); width: 18px; height: 18px; margin-top: 1px; }

#outPrompt { font-size: 14px; min-height: 280px; background: var(--gray-50); }
.send-bar { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; align-items: center; }
.send-sep { flex: 1; }
.btn-ai { background: #fff; border: 1.5px solid var(--gray-300); color: var(--ink); }
.btn-ai:hover { border-color: var(--orange); color: var(--orange-600); }
.btn-ai.preferred { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn-ai.preferred:hover { background: var(--orange-600); color: #fff; }
.saved-tag { font-size: 12.5px; color: var(--gray-500); }

/* Pílula da base */
.db-pill { display: inline-flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--gray-200); border-radius: 999px; padding: 6px 12px; font-size: 13px; color: var(--gray-700); max-width: 340px; }
.db-pill span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.db-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gray-400); flex-shrink: 0; }
.db-pill.ok .dot { background: var(--ok); }
.db-pill.dirty .dot { background: var(--warn); }
.db-pill.err .dot { background: var(--err); }

/* Histórico */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.kpi { background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi small { color: var(--gray-500); font-size: 12.5px; font-weight: 500; }
.kpi b { display: block; font-size: 26px; font-weight: 800; letter-spacing: -.5px; margin-top: 2px; }
.kpi .bar { height: 6px; background: var(--gray-100); border-radius: 99px; margin-top: 8px; overflow: hidden; }
.kpi .bar i { display: block; height: 100%; background: var(--orange); border-radius: 99px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar select { width: auto; min-width: 150px; padding: 9px 10px; font-size: 14px; }
.search { position: relative; flex: 1; min-width: 200px; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--gray-400); width: 18px; height: 18px; }
.search input { padding-left: 36px; padding-top: 9px; padding-bottom: 9px; }
.list { display: flex; flex-direction: column; gap: 10px; }
.item { border: 1px solid var(--gray-200); border-radius: 14px; padding: 14px 16px; display: flex; gap: 14px; align-items: flex-start; background: #fff; }
.item:hover { border-color: var(--gray-300); }
.item-main { flex: 1; min-width: 0; }
.item-title { font-weight: 600; font-size: 15px; }
.item-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.tag { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--gray-100); color: var(--gray-700); }
.tag.o { background: var(--orange-50); color: var(--orange-600); }
.tag.s-ok { background: #E8F6EF; color: var(--ok); }
.item-preview { color: var(--gray-500); font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item-actions { display: flex; gap: 2px; flex-shrink: 0; }
.empty { text-align: center; color: var(--gray-500); padding: 34px 10px; font-size: 14px; }
.empty svg { width: 34px; height: 34px; color: var(--gray-300); display: block; margin: 0 auto 8px; }

.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.pcard { border: 1px solid var(--gray-200); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.pcard-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.pcard h3 { margin: 0; font-size: 15.5px; }
.pcard p { margin: 0; color: var(--gray-500); font-size: 13.5px; }
.pcard a { color: var(--orange-600); font-size: 13px; text-decoration: none; display: inline-flex; gap: 6px; align-items: center; word-break: break-all; }
.pcard a svg { width: 15px; height: 15px; }
.pcard .off { opacity: .55; }

/* Base */
.base-status { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 18px; }
.base-status div { background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: 12px; padding: 12px 14px; }
.base-status small { color: var(--gray-500); font-size: 12px; display: block; }
.base-status b { font-size: 14.5px; word-break: break-all; }
.base-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12.5px; color: var(--gray-500); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--gray-200); }
.tbl td { padding: 10px; border-bottom: 1px solid var(--gray-100); vertical-align: top; }

.prose { font-size: 14.5px; }
.prose h2 { margin-top: 0; }
.prose h3 { font-size: 15.5px; margin: 22px 0 6px; }
.prose li { margin-bottom: 6px; }
kbd { background: var(--gray-100); border: 1px solid var(--gray-300); border-radius: 5px; padding: 0 5px; font-size: 12px; font-family: inherit; }

/* Overlays */
.overlay { position: fixed; inset: 0; z-index: 100; background: var(--gray-50); display: flex; align-items: center; justify-content: center; padding: 20px; overflow-y: auto; }
.start { max-width: 760px; width: 100%; text-align: center; }
.start-head h1 { margin: 0 0 6px; font-size: 28px; letter-spacing: -.5px; }
.start-head p { margin: 0 0 28px; color: var(--gray-500); }
.start-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.start-card { background: #fff; border: 1.5px solid var(--gray-200); border-radius: 18px; padding: 24px 18px; display: flex; flex-direction: column; align-items: center; gap: 6px; box-shadow: var(--shadow); transition: .15s; color: var(--ink); }
.start-card:hover { border-color: var(--orange); transform: translateY(-2px); }
.start-card svg { width: 30px; height: 30px; color: var(--orange); margin-bottom: 6px; }
.start-card b { font-size: 15.5px; }
.start-card span { color: var(--gray-500); font-size: 13px; word-break: break-all; }
#sReconectar { border-color: var(--orange); background: var(--orange-50); }
.start-foot { margin-top: 18px; font-size: 13px; color: var(--gray-500); }
.start .credit { margin-top: 24px; }

.modal-overlay { background: rgba(17,24,39,.45); z-index: 120; }
.modal { background: #fff; border-radius: 18px; width: 100%; max-width: 620px; max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px 6px; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-body { padding: 10px 22px; overflow-y: auto; }
.modal-body pre { white-space: pre-wrap; background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: 12px; padding: 12px; font-family: inherit; font-size: 13.5px; max-height: 50vh; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px 20px; flex-wrap: wrap; }

.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 40px); }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.18); display: flex; gap: 10px; align-items: center; max-width: 420px; animation: tin .2s ease-out; }
.toast svg { width: 18px; height: 18px; }
.toast.ok svg { color: #6EE7B7; }
.toast.err { background: var(--err); }
.toast.warn svg { color: #FCD34D; }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }

/* ---------- Responsivo ---------- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.15); }
  .sidebar.open { transform: none; }
  .scrim.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 35; }
  .main { margin-left: 0; }
  .icon-btn.only-mobile { display: grid; }
  .topbar { padding: 10px 14px; }
  .content { padding: 16px 14px 40px; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .db-pill { max-width: 150px; }
}
@media (max-width: 640px) {
  .grid-2, .type-options { grid-template-columns: 1fr; }
  .type-grid { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .topbar-title { font-size: 16px; }
  #btnSave span { display: none; }
  .db-pill { display: none; }
  .send-bar .btn { flex: 1 1 100%; }
  .send-sep { display: none; }
  .step { font-size: 0; padding: 4px; }
  .step span { font-size: 12px; }
  .steps { gap: 6px; }
  .toolbar select { flex: 1; }
  .item { flex-direction: column; }
  .item-actions { align-self: flex-end; }
}

/* Marca usa o ícone do app */
.brand-mark { background: url(../icons/icon-192.png) center / cover no-repeat; color: transparent; }
