:root {
  --ink: #10231f; --muted: #60736d; --line: #e3e7e3; --bg: #f5f6f3; --card: #fff;
  --brand: #0f4c45; --mint: #e3f4ec;
  --emer: #b42318; --emer-bg: #fdecea; --urg: #d9480f; --urg-bg: #fff0e6;
  --pri: #b7791f; --pri-bg: #fdf6e3; --nor: #2f855a; --nor-bg: #e8f5ee; --und: #718096; --und-bg: #eef1f4;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 14px; display: flex; flex-direction: column; -webkit-font-smoothing: antialiased; }
button { font: inherit; cursor: pointer; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; margin: 0 0 10px; }
h2 small { font-weight: 500; letter-spacing: 0; text-transform: none; }

.bar { display: flex; align-items: center; gap: 18px; padding: 12px 20px; background: #fff; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand .mark { width: 30px; height: 30px; border-radius: 9px; background: var(--brand); position: relative; }
.brand .mark::after { content: ""; position: absolute; inset: 9px; border-radius: 50%; border: 2px solid #9fe0c4; }
.brand strong { display: block; font-size: 15px; }
.brand span { font-size: 12px; color: var(--muted); }
.live { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--nor); background: var(--nor-bg); padding: 5px 10px; border-radius: 99px; font-weight: 600; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: #2fae74; box-shadow: 0 0 0 0 rgba(47, 174, 116, .6); animation: ring 1.6s infinite; }
@keyframes ring { 70% { box-shadow: 0 0 0 7px rgba(47, 174, 116, 0); } 100% { box-shadow: 0 0 0 0 rgba(47, 174, 116, 0); } }
.bar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.engine { font-size: 12px; color: var(--muted); }
.btn-ghost { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 11px; font-size: 12.5px; color: var(--muted); }
.btn-ghost:hover { color: var(--ink); border-color: #c9d0cb; }

.alarm { margin: 12px 20px 0; padding: 12px 16px; border-radius: 12px; background: var(--emer); color: #fff; display: flex; align-items: center; gap: 14px; animation: flash 1.4s ease-in-out 3; }
.alarm strong { font-size: 14.5px; }
.alarm span { opacity: .9; }
.alarm button { margin-left: auto; background: #fff; color: var(--emer); border: 0; border-radius: 8px; padding: 7px 12px; font-weight: 600; font-size: 13px; white-space: nowrap; }
@keyframes flash { 50% { background: #e0412f; } }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; padding: 14px 20px 0; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.kpi span { font-size: 12px; color: var(--muted); }
.kpi strong { display: block; font-size: 24px; margin-top: 2px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

.grid { flex: 1; min-height: 0; display: grid; grid-template-columns: 320px minmax(0, 1fr) 280px; gap: 14px; padding: 14px 20px 20px; }
.inbox, .agenda { min-height: 0; overflow-y: auto; }
.detail { min-height: 0; overflow-y: auto; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
@media (max-width: 1180px) {
  .grid { grid-template-columns: 290px minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .inbox { grid-column: 1; grid-row: 1; max-height: 46vh; }
  .agenda { grid-column: 1; grid-row: 2; }
  .detail { grid-column: 2; grid-row: 1 / span 2; }
  .kpi strong { font-size: 21px; }
}
@media (max-width: 760px) {
  .grid { grid-template-columns: 1fr; grid-template-rows: none; }
  .inbox, .agenda, .detail { grid-column: auto; grid-row: auto; max-height: none; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .bar .live { display: none; }
}

/* Bandeja */
.list { display: flex; flex-direction: column; gap: 8px; }
.card { position: relative; text-align: left; width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px 10px 16px; overflow: hidden; transition: box-shadow .15s, border-color .15s; }
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--c, var(--und)); }
.card:hover { border-color: #c9d0cb; }
.card.sel { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.card.new { animation: arrive 1.2s ease-out; }
@keyframes arrive { 0% { transform: translateX(-12px); opacity: 0; background: var(--mint); } 40% { transform: none; opacity: 1; } 100% { background: #fff; } }
.card .row { display: flex; align-items: center; gap: 8px; }
.card .name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .ago { margin-left: auto; font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.card .mot { margin: 3px 0 7px; font-size: 13px; color: #33473f; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .tags { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 3px 8px; border-radius: 99px; background: var(--bgc, var(--und-bg)); color: var(--c, var(--und)); white-space: nowrap; }
.pill.soft { background: #f0f2ef; color: var(--muted); font-weight: 500; }
.pill svg { width: 12px; height: 12px; fill: currentColor; }
.lv-emergencia { --c: var(--emer); --bgc: var(--emer-bg); }
.lv-urgente { --c: var(--urg); --bgc: var(--urg-bg); }
.lv-prioritario { --c: var(--pri); --bgc: var(--pri-bg); }
.lv-normal { --c: var(--nor); --bgc: var(--nor-bg); }
.lv-sin_determinar { --c: var(--und); --bgc: var(--und-bg); }
.none { color: var(--muted); font-size: 13px; padding: 18px 4px; line-height: 1.5; }

/* Ficha */
.empty { height: 100%; display: grid; place-items: center; text-align: center; color: var(--muted); padding: 40px; }
.empty p { max-width: 300px; line-height: 1.5; }
.fx { padding: 20px 22px 26px; }
.fx-head { display: flex; align-items: flex-start; gap: 14px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.fx-head h1 { margin: 6px 0 2px; font-size: 21px; letter-spacing: -.01em; }
.fx-head .sub { color: var(--muted); font-size: 13px; }
.fx-head .call { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; background: var(--brand); color: #fff; border-radius: 9px; padding: 8px 12px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.fx-head .call svg { width: 14px; height: 14px; fill: currentColor; }
.block { margin-top: 16px; }
.block h3 { margin: 0 0 7px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.summary { background: #f7faf8; border: 1px solid #dfece5; border-radius: 12px; padding: 12px 14px; font-size: 15px; line-height: 1.5; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.fact { border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; }
.fact span { display: block; font-size: 11.5px; color: var(--muted); }
.fact strong { display: block; font-size: 14px; margin-top: 2px; }
.fact.hot strong { color: var(--urg); }
.painbar { height: 5px; border-radius: 3px; background: #edf0ed; margin-top: 6px; overflow: hidden; }
.painbar i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, #2fae74, #e0a422 55%, #d9480f); }
.quote { margin: 0; padding: 10px 14px; border-left: 3px solid var(--brand); background: #fafbf9; border-radius: 0 10px 10px 0; font-size: 14px; line-height: 1.5; color: #33473f; }
.quote small { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; }
.outcome { display: flex; align-items: center; gap: 12px; border-radius: 12px; padding: 12px 14px; }
.outcome.ok { background: var(--nor-bg); color: #1f5f40; }
.outcome.bad { background: var(--emer-bg); color: var(--emer); }
.outcome.wait { background: #f0f2ef; color: var(--muted); }
.outcome svg { width: 22px; height: 22px; fill: currentColor; flex: none; }
.outcome strong { display: block; font-size: 15px; }
.outcome span { font-size: 12.5px; opacity: .85; }
.outcome button { margin-left: auto; border: 0; border-radius: 8px; background: var(--emer); color: #fff; padding: 7px 11px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.convo { display: flex; flex-direction: column; gap: 5px; background: #f6f4ef; border-radius: 12px; padding: 12px; max-height: 360px; overflow-y: auto; }
.convo .m { max-width: 82%; padding: 7px 10px; border-radius: 10px; font-size: 13px; line-height: 1.4; background: #fff; align-self: flex-start; }
.convo .m.p { align-self: flex-end; background: #d8f0e2; }
.convo .m em { display: block; font-style: normal; font-size: 11px; color: var(--muted); margin-bottom: 2px; }

/* Agenda */
.day { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; }
.day h4 { margin: 0 0 8px; font-size: 13.5px; }
.slot { display: grid; grid-template-columns: 42px 1fr; gap: 8px; align-items: baseline; padding: 5px 6px; border-radius: 7px; font-size: 12.5px; }
.slot + .slot { border-top: 1px dashed #edf0ed; }
.slot time { font-variant-numeric: tabular-nums; color: var(--muted); }
.slot .who { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot .who small { color: var(--muted); }
.slot.free .who { color: #9aa7a2; }
.slot.urgfree .who { color: var(--urg); font-weight: 500; }
.slot.bot { background: var(--mint); }
.slot.bot .who b { color: var(--brand); }
.slot.past { opacity: .45; }
.slot.flash { animation: arrive 1.4s ease-out; }
.tag { display: inline-block; font-size: 10.5px; font-weight: 600; padding: 1px 6px; border-radius: 99px; background: var(--brand); color: #fff; margin-left: 4px; vertical-align: 1px; }

/* PIN */
.pin { position: fixed; inset: 0; background: rgba(16, 35, 31, .5); display: grid; place-items: center; z-index: 10; }
.pin form { background: #fff; border-radius: 16px; padding: 24px; width: 300px; display: flex; flex-direction: column; gap: 10px; }
.pin h3 { margin: 0; } .pin p { margin: 0; color: var(--muted); }
.pin input { border: 1px solid var(--line); border-radius: 9px; padding: 10px; font: inherit; font-size: 16px; }
.pin button { border: 0; border-radius: 9px; background: var(--brand); color: #fff; padding: 10px; font-weight: 600; }
.pin small { color: var(--emer); min-height: 1em; }

body.embed .bar { padding: 10px 16px; }
body.embed .kpis, body.embed .grid { padding-left: 14px; padding-right: 14px; }
