:root {
  --rose: #c54259;
  --rose-dark: #a8344a;
  --rose-soft: #f9e6e9;
  --nude: #f4decf;
  --cream: #fff8f3;
  --brown: #73604f;
  --ink: #33373d;
  --muted: #8a7f76;
  --line: #eadfd6;
  --white: #ffffff;
  --green: #2f8f5b;
  --green-soft: #e3f3ea;
  --amber: #b7791f;
  --amber-soft: #fbf0dc;
  --bubble-in: #ffffff;
  --bubble-out: #fbe9e3;
  --bubble-human: #e9eef8;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(115, 96, 79, .06), 0 6px 24px rgba(115, 96, 79, .08);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14px/1.45 Inter, system-ui, sans-serif;
  color: var(--ink);
  background: var(--cream);
}
h1, h2, h3 { font-family: "Cormorant Garamond", Georgia, serif; font-weight: 600; color: var(--brown); margin: 0 0 .4em; }
h2 { font-size: 28px; }
h3 { font-size: 21px; }
h4 { margin: 14px 0 6px; font-size: 13px; color: var(--brown); text-transform: uppercase; letter-spacing: .06em; }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--white);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--rose-soft); border-color: var(--rose); }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
label > input, label > select, label > textarea { margin-top: 4px; color: var(--ink); font-size: 14px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--rose); min-height: 1.2em; }
.row { display: flex; gap: 10px; align-items: center; }
.row > label { flex: 1; }
.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 16px; }

.btn {
  border: 1px solid var(--line); background: var(--white); padding: 8px 14px; border-radius: 10px; cursor: pointer;
  white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:hover { border-color: var(--rose); }
.btn.primary { background: var(--rose); border-color: var(--rose); color: #fff; }
.btn.primary:hover { background: var(--rose-dark); }
.btn.ghost { background: transparent; }
.btn.success { background: var(--green); border-color: var(--green); color: #fff; }
.btn.warn { background: var(--amber-soft); border-color: #ecd3a6; color: #7a5212; }
.btn.round { border-radius: 50%; width: 40px; height: 40px; padding: 0; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link { background: none; border: 0; color: var(--muted); cursor: pointer; text-decoration: underline; }

.brand-mark {
  width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(135deg, var(--rose), #d97a8a);
  color: #fff; display: grid; place-items: center; font-family: "Cormorant Garamond", serif; font-weight: 600; font-size: 17px; flex: none;
}
.brand-mark.big { width: 72px; height: 72px; font-size: 30px; margin: 0 auto 14px; }
.brand-mark.sm { width: 34px; height: 34px; font-size: 14px; }

/* Login */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; background: radial-gradient(circle at 30% 20%, var(--nude), var(--cream) 60%); }
.login-card { background: var(--white); padding: 36px 32px; border-radius: 20px; box-shadow: var(--shadow); width: 100%; max-width: 360px; text-align: center; display: flex; flex-direction: column; gap: 12px; }
.login-card .brand-mark { margin: 0 auto; width: 56px; height: 56px; font-size: 22px; }
.login-card h1 { font-size: 30px; margin: 4px 0 0; }

/* Layout */
.app { display: grid; grid-template-columns: 236px 1fr; height: 100vh; }
.sidebar { background: var(--white); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 18px 12px; }
.brand { display: flex; gap: 10px; align-items: center; padding: 0 8px 18px; }
.brand strong { display: block; font-family: "Cormorant Garamond", serif; font-size: 18px; color: var(--brown); line-height: 1.1; }
.brand span { font-size: 12px; color: var(--muted); }
nav { display: flex; flex-direction: column; gap: 2px; }
nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; cursor: pointer; color: var(--ink); }
nav a span { width: 20px; text-align: center; }
nav a:hover { background: var(--cream); }
nav a.active { background: var(--rose-soft); color: var(--rose-dark); font-weight: 600; }
.badge { margin-left: auto; background: var(--rose); color: #fff; border-radius: 99px; font-size: 11px; padding: 1px 7px; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 8px; }
.mode { font-size: 12px; padding: 8px 10px; border-radius: 10px; background: var(--amber-soft); color: #7a5212; }
.mode.live { background: var(--green-soft); color: var(--green); }

main { overflow: hidden; height: 100vh; }
.view { height: 100%; overflow: auto; padding: 24px 28px; }
.view-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.view-head p { margin: 0; max-width: 640px; }
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.two-cols.wide-left { grid-template-columns: 1.4fr 1fr; }

/* Conversations */
.view-chat { display: grid; grid-template-columns: 320px 1fr 300px; padding: 0; overflow: hidden; }
.conv-list { border-right: 1px solid var(--line); background: var(--white); display: flex; flex-direction: column; min-height: 0; }
.conv-tools { padding: 14px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--white); border-radius: 99px; padding: 4px 10px; font-size: 12px; cursor: pointer; }
.chip.active { background: var(--rose); color: #fff; border-color: var(--rose); }
#convItems { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; }
.conv { display: flex; gap: 10px; padding: 12px 14px; border-bottom: 1px solid #f5ede7; cursor: pointer; }
.conv:hover { background: var(--cream); }
.conv.active { background: var(--rose-soft); }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--nude); color: var(--brown); display: grid; place-items: center; font-weight: 600; flex: none; }
.conv-main { flex: 1; min-width: 0; }
.conv-top { display: flex; justify-content: space-between; gap: 6px; }
.conv-top strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-time { font-size: 11px; color: var(--muted); flex: none; }
.conv-prev { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-tags { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.tag { font-size: 10.5px; padding: 1px 7px; border-radius: 99px; background: var(--cream); border: 1px solid var(--line); color: var(--brown); }
.tag.paused { background: var(--amber-soft); border-color: #ecd3a6; color: #7a5212; }
.tag.attention { background: var(--rose); color: #fff; border-color: var(--rose); }
.tag.sim { background: #eef0f7; color: #4b5578; }
.unread-dot { background: var(--rose); color: #fff; border-radius: 99px; font-size: 11px; padding: 0 6px; margin-left: 6px; }

.chat { display: flex; flex-direction: column; min-height: 0; background: var(--cream) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80'%3E%3Ccircle cx='40' cy='40' r='1.2' fill='%23eadfd6'/%3E%3C/svg%3E"); }
.empty-state { margin: auto; text-align: center; padding: 20px; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 12px 18px; background: var(--white); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.chat-head .who { flex: 1; min-width: 140px; }
.chat-head .who strong { display: block; }
.chat-head .who span { font-size: 12px; color: var(--muted); }
.agent-toggle { display: flex; align-items: center; gap: 8px; }
.status-pill { font-size: 12px; padding: 5px 10px; border-radius: 99px; }
.status-pill.on { background: var(--green-soft); color: var(--green); }
.status-pill.off { background: var(--amber-soft); color: #7a5212; }
.alert { margin: 10px 18px 0; padding: 10px 12px; border-radius: 10px; background: var(--rose-soft); color: var(--rose-dark); font-size: 13px; display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.messages { flex: 1; overflow: auto; padding: 18px; display: flex; flex-direction: column; gap: 6px; }
.day-sep { align-self: center; font-size: 11px; color: var(--muted); background: var(--white); padding: 3px 10px; border-radius: 99px; margin: 8px 0; border: 1px solid var(--line); }
.msg { max-width: 72%; padding: 8px 11px 6px; border-radius: 12px; box-shadow: 0 1px 1px rgba(0,0,0,.04); white-space: pre-wrap; word-wrap: break-word; }
.msg.in { align-self: flex-start; background: var(--bubble-in); border-top-left-radius: 4px; }
.msg.out { align-self: flex-end; background: var(--bubble-out); border-top-right-radius: 4px; }
.msg.human { background: var(--bubble-human); }
.msg .meta { display: flex; gap: 6px; justify-content: flex-end; font-size: 10.5px; color: var(--muted); margin-top: 3px; }
.msg .who-label { font-size: 10.5px; font-weight: 600; color: var(--rose-dark); margin-bottom: 2px; }
.msg.human .who-label { color: #3d5aa8; }
.msg img { max-width: 260px; border-radius: 8px; display: block; margin-bottom: 4px; }
.msg audio { max-width: 260px; display: block; margin-bottom: 4px; }
.msg .failed { color: var(--rose); }
.event { align-self: center; font-size: 12px; color: var(--brown); background: var(--nude); padding: 4px 12px; border-radius: 99px; max-width: 90%; text-align: center; }
.composer { padding: 12px 18px; background: var(--white); border-top: 1px solid var(--line); }
.composer form { display: flex; gap: 10px; align-items: flex-end; }
.composer textarea { resize: none; min-height: 42px; max-height: 140px; }
.composer .hint { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.window-closed { background: var(--amber-soft); border: 1px solid #ecd3a6; border-radius: 10px; padding: 12px; font-size: 13px; color: #7a5212; display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }

.crm-card { border-left: 1px solid var(--line); background: var(--white); overflow: auto; padding: 18px; }
.crm-card h3 { margin-bottom: 2px; }
.crm-card .appt { background: var(--cream); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin-bottom: 6px; font-size: 13px; }

/* Funnel */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi b { display: block; font-size: 26px; font-family: "Cormorant Garamond", serif; color: var(--brown); line-height: 1.1; }
.kpi span { font-size: 12px; color: var(--muted); }
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 12px; min-height: 420px; }
.column { background: #fbf3ee; border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 0; }
.column.drop { outline: 2px dashed var(--rose); }
.column-head { padding: 12px 12px 8px; display: flex; justify-content: space-between; align-items: baseline; }
.column-head strong { font-size: 13px; }
.column-head span { font-size: 12px; color: var(--muted); }
.column-body { padding: 0 10px 10px; display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.deal { background: var(--white); border: 1px solid var(--line); border-radius: 10px; padding: 10px; cursor: grab; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.deal strong { display: block; font-size: 13px; }
.deal small { color: var(--muted); display: block; }

/* Agenda */
.agenda-days { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.day { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; min-height: 140px; }
.day.today { border-color: var(--rose); box-shadow: 0 0 0 2px var(--rose-soft); }
.day.closed { background: #fbf6f2; }
.day h4 { margin: 0 0 8px; }
.event-card { border-left: 3px solid var(--rose); background: var(--cream); border-radius: 8px; padding: 7px 9px; margin-bottom: 6px; font-size: 13px; }
.event-card.cancelado { border-color: var(--muted); opacity: .55; text-decoration: line-through; }
.event-card.google { border-color: #4b74c9; }
.event-card .time { font-weight: 600; color: var(--rose-dark); }
.event-card .acts { display: flex; gap: 8px; margin-top: 4px; }
.slots { display: flex; flex-wrap: wrap; gap: 6px; max-height: 230px; overflow: auto; }
.slot { border: 1px solid var(--line); border-radius: 8px; padding: 4px 9px; background: var(--white); cursor: pointer; font-size: 13px; }
.slot.sel { background: var(--rose); color: #fff; border-color: var(--rose); }

/* Table */
.table-wrap { overflow: auto; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #f5ede7; vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 500; background: #fdf9f6; position: sticky; top: 0; }
tr:hover td { background: var(--cream); cursor: pointer; }

/* Templates */
.tpl-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.tpl { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.tpl-head { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.tpl p { margin: 6px 0 0; white-space: pre-wrap; font-size: 13px; color: var(--ink); }
.st { font-size: 11px; padding: 2px 8px; border-radius: 99px; background: var(--cream); border: 1px solid var(--line); }
.st.APPROVED { background: var(--green-soft); color: var(--green); border-color: #bfe3cd; }
.st.PENDING { background: var(--amber-soft); color: #7a5212; }
.st.REJECTED { background: var(--rose-soft); color: var(--rose-dark); }

/* Simulator */
.sim-wrap { display: grid; grid-template-columns: minmax(300px, 400px) 1fr; gap: 20px; align-items: start; }
.phone { background: #efe7df; border-radius: 26px; border: 8px solid #2c2a29; height: min(680px, calc(100vh - 170px)); display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow); }
.phone-head { background: var(--brown); color: #fff; display: flex; gap: 10px; align-items: center; padding: 10px 12px; }
.phone-head span { display: block; font-size: 11px; opacity: .8; }
.phone-body { flex: 1; overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 5px; }
.phone-body .msg { max-width: 85%; font-size: 13.5px; }
.phone-body .msg.in { align-self: flex-end; background: #dcf3d0; border-radius: 12px 4px 12px 12px; }
.phone-body .msg.out { align-self: flex-start; background: #fff; border-radius: 4px 12px 12px 12px; }
.phone-input { display: flex; gap: 8px; padding: 8px; background: #efe7df; }
.phone-input input { border-radius: 99px; }
.tips { padding-left: 18px; margin: 0 0 10px; }
.tips li { cursor: pointer; padding: 4px 0; color: var(--rose-dark); }
.tips li:hover { text-decoration: underline; }

/* Settings */
.kb { min-height: 60vh; font: 13px/1.5 ui-monospace, Consolas, monospace; resize: vertical; }
.hours { display: grid; grid-template-columns: 54px 1fr 1fr 70px; gap: 6px 8px; align-items: center; font-size: 13px; }
.hours input[type=time] { padding: 6px 8px; }
.integrations { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.integrations li { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; }
.on-off { font-size: 12px; font-weight: 600; }
.on-off.on { color: var(--green); }
.on-off.off { color: var(--muted); }

/* Modal & toast */
.modal { position: fixed; inset: 0; background: rgba(51, 55, 61, .35); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal-card { background: var(--white); border-radius: 18px; padding: 22px; width: 100%; max-width: 480px; max-height: 90vh; overflow: auto; box-shadow: var(--shadow); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 30; max-width: calc(100% - 32px); }
.toast.err { background: var(--rose-dark); }

/* Responsive */
@media (max-width: 1180px) {
  .view-chat { grid-template-columns: 280px 1fr; }
  .crm-card { display: none; }
  .view-chat.show-crm .crm-card { display: block; position: fixed; right: 0; top: 0; bottom: 0; width: min(340px, 100%); z-index: 10; box-shadow: var(--shadow); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; height: 100dvh; }
  .sidebar { flex-direction: row; align-items: center; padding: 8px 10px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); gap: 8px; }
  .brand > div:last-child, .sidebar-foot { display: none; }
  .brand { padding: 0; }
  nav { flex-direction: row; }
  nav a { padding: 8px 10px; white-space: nowrap; font-size: 13px; }
  main { height: auto; min-height: 0; }
  .view { padding: 16px; }
  .view-chat { grid-template-columns: 1fr; }
  .view-chat .chat { display: none; }
  .view-chat.open .conv-list { display: none; }
  .view-chat.open .chat { display: flex; }
  .two-cols, .two-cols.wide-left, .sim-wrap { grid-template-columns: 1fr; }
  .msg { max-width: 88%; }
}
