:root {
  --paper: #F4EFE6; --paper-2: #EBE4D7; --card: #FBF8F2; --ink: #1F2A24; --ink-2: #4A5650; --muted: #7C857F;
  --line: #DDD4C4; --accent: #E8613C; --accent-ink: #fff; --sage: #5E8C6A; --sage-bg: #E3ECDF;
  --amber: #C98A1B; --amber-bg: #F6E9CC; --red: #B9412F; --red-bg: #F5DDD6; --blue: #3E6C8E; --blue-bg: #DDE8F0;
  --radius: 14px; --shadow: 0 1px 0 rgba(31,42,36,.04), 0 8px 24px -12px rgba(31,42,36,.18);
  --display: 'Fraunces', Georgia, serif; --body: 'Instrument Sans', 'Segoe UI', sans-serif; --mono: 'JetBrains Mono', ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
#app { min-height: 100vh; }
body { background: var(--paper); color: var(--ink); font: 15px/1.5 var(--body); -webkit-font-smoothing: antialiased;
  background-image: radial-gradient(circle at 1px 1px, rgba(31,42,36,.06) 1px, transparent 0); background-size: 22px 22px; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: .86em; }
h1, h2, h3 { font-family: var(--display); font-weight: 650; letter-spacing: -.01em; margin: 0; }
h1 { font-size: 30px; } h2 { font-size: 20px; } h3 { font-size: 16px; }

/* Marca */
.brand { font-family: var(--display); font-weight: 650; font-size: 20px; display: flex; align-items: center; gap: 10px; }
.brand em { font-style: normal; color: var(--accent); }
.brand .wm { white-space: nowrap; }
.brand .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(232,97,60,.18); animation: pulse 2.4s infinite; }
.brand.big { font-size: 34px; }
@keyframes pulse { 50% { box-shadow: 0 0 0 9px rgba(232,97,60,0); } }

/* Login */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 440px) 1fr; }
.login-card { background: var(--card); padding: 56px 44px; display: flex; flex-direction: column; justify-content: center; gap: 12px; border-right: 1px solid var(--line); }
.login-card form { display: grid; gap: 14px; margin-top: 18px; }
.login-art { position: relative; overflow: hidden; background: var(--ink); }
.login-art::before { content: ''; position: absolute; inset: 0; background: radial-gradient(600px 400px at 70% 30%, rgba(232,97,60,.35), transparent 60%), radial-gradient(500px 500px at 20% 90%, rgba(94,140,106,.35), transparent 60%); }
.login-art .bubble { position: absolute; max-width: 320px; padding: 12px 16px; border-radius: 18px 18px 18px 4px; background: #fff; color: var(--ink); box-shadow: 0 20px 40px -20px rgba(0,0,0,.5); opacity: 0; animation: rise .7s forwards; }
.login-art .bubble.me { background: #DCF5C9; border-radius: 18px 18px 4px 18px; }
.b1 { top: 22%; left: 14%; animation-delay: .2s !important; } .b2 { top: 36%; left: 30%; animation-delay: 1s !important; }
.b3 { top: 55%; left: 18%; animation-delay: 1.8s !important; } .b4 { top: 66%; left: 36%; animation-delay: 2.5s !important; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@media (max-width: 760px) { .login { grid-template-columns: 1fr; } .login-art { display: none; } }

/* Formularios */
label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
input, select, textarea { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(31,42,36,.08); }
.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 8px 16px; font-weight: 600; cursor: pointer; transition: transform .1s, background .15s; white-space: nowrap; }
.btn:hover { background: #fff; } .btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #d4552f; }
.btn.dark { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 12px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.error { color: var(--red); min-height: 1.2em; margin: 0; font-size: 14px; }

/* Layout */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100%; }
.nav { background: var(--ink); color: var(--paper); padding: 22px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.nav .brand { color: var(--paper); padding: 0 10px 18px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; text-decoration: none; color: #C9CFC9; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.on { background: var(--paper); color: var(--ink); }
.nav a .badge { margin-left: auto; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 7px; }
.nav .mobile-only { display: none; }
.nav .foot { margin-top: auto; font-size: 12px; color: #8E978F; padding: 10px; display: grid; gap: 6px; }
.nav .foot button { justify-self: start; color: #C9CFC9; border-color: #3A473F; background: transparent; }
.main { padding: 28px 34px 60px; min-width: 0; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.head p { margin: 4px 0 0; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .nav { position: sticky; top: 0; z-index: 5; height: auto; flex-direction: row; align-items: center; gap: 2px; padding: 10px 12px; overflow-x: auto; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav .brand { padding: 0 12px 0 4px; font-size: 17px; flex: none; }
  .nav a { flex: none; padding: 7px 11px; font-size: 14px; }
  .nav .foot { display: none; }
  .nav .mobile-only { display: flex; }
  .main { padding: 20px 16px; }
  h1 { font-size: 25px; }
}

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.pad { padding: 18px 20px; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
.kpi { padding: 16px 18px; position: relative; overflow: hidden; animation: rise .5s both; }
.kpi:nth-child(2) { animation-delay: .05s } .kpi:nth-child(3) { animation-delay: .1s } .kpi:nth-child(4) { animation-delay: .15s } .kpi:nth-child(5) { animation-delay: .2s } .kpi:nth-child(6) { animation-delay: .25s }
.kpi .v { font-family: var(--display); font-size: 32px; font-weight: 650; line-height: 1.1; margin-top: 6px; }
.kpi .l { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.kpi .s { font-size: 13px; color: var(--ink-2); }
.kpi.hot { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.kpi.hot .l, .kpi.hot .s { color: #B9C1BA; }
.grid2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 14px; align-items: start; }
@media (max-width: 1000px) { .grid2 { grid-template-columns: 1fr; } }
.integr { display: grid; gap: 10px; }
.integr div { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.integr div:last-child { border: 0; }

/* Chips de estado */
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--paper-2); color: var(--ink-2); white-space: nowrap; }
.chip::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.ok { background: var(--sage-bg); color: var(--sage); } .chip.warn { background: var(--amber-bg); color: var(--amber); }
.chip.bad { background: var(--red-bg); color: var(--red); } .chip.info { background: var(--blue-bg); color: var(--blue); }

/* Tablas */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); font-weight: 600; }
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tr.day td { background: var(--paper-2); font-family: var(--display); font-weight: 650; padding: 8px 12px; }
.table input.price { width: 112px; padding: 6px 8px; font-family: var(--mono); font-size: 13px; text-align: right; }
.table input.price.changed { border-color: var(--accent); background: #FFF3EE; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs button { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 6px 14px; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--ink-2); }
.tabs button.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.scroll-x { overflow-x: auto; }

/* Conversaciones */
.inbox { display: grid; grid-template-columns: 320px 1fr 300px; gap: 14px; height: calc(100vh - 140px); min-height: 520px; }
.inbox > * { min-height: 0; }
.list { overflow-y: auto; }
.list .item { padding: 12px 16px; border-bottom: 1px solid var(--line); cursor: pointer; display: grid; gap: 2px; }
.list .item:hover { background: #fff; } .list .item.on { background: var(--paper-2); }
.list .item .top .mono { white-space: nowrap; font-size: 11px; }
.list .item .top { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
.list .item .prev { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread { display: flex; flex-direction: column; overflow: hidden; }
.thread .msgs { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 8px;
  background: #EFE7DA; background-image: radial-gradient(circle at 1px 1px, rgba(31,42,36,.07) 1px, transparent 0); background-size: 18px 18px; }
.msg { max-width: 76%; padding: 8px 12px 6px; border-radius: 12px; background: #fff; box-shadow: 0 1px 1px rgba(0,0,0,.06); white-space: pre-wrap; word-wrap: break-word; animation: rise .25s both; }
.msg .t { display: block; text-align: right; font-size: 11px; color: var(--muted); margin-top: 2px; }
.msg.out { align-self: flex-end; background: #DCF5C9; }
.msg.staff { align-self: flex-end; background: #DDE8F0; }
.msg.staff .who { font-size: 11px; font-weight: 700; color: var(--blue); display: block; }
.msg img { max-width: 220px; border-radius: 8px; display: block; margin-bottom: 4px; }
.msg.sys { align-self: center; background: var(--paper-2); font-size: 12px; color: var(--ink-2); }
.composer { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); background: var(--card); }
.composer textarea { flex: 1; resize: none; height: 44px; }
.side { overflow-y: auto; display: grid; gap: 12px; align-content: start; }
.side .card { padding: 14px 16px; }
.side dl { margin: 8px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: 13px; }
.side dt { color: var(--muted); }
@media (max-width: 1200px) { .inbox { grid-template-columns: 280px 1fr; } .inbox .side { display: none; } }
@media (max-width: 800px) { .inbox { grid-template-columns: 1fr; height: auto; } }

/* Simulador */
.sim { display: grid; grid-template-columns: minmax(340px, 420px) 1fr; gap: 18px; align-items: start; }
.phone { background: var(--ink); border-radius: 36px; padding: 12px; box-shadow: 0 30px 60px -30px rgba(31,42,36,.6); }
.phone .screen { border-radius: 26px; overflow: hidden; display: flex; flex-direction: column; height: 640px; background: #EFE7DA; }
.phone .bar { background: #075E54; color: #fff; padding: 14px 16px; display: flex; gap: 10px; align-items: center; }
.phone .bar .av { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; font-weight: 700; }
.phone .bar small { display: block; opacity: .8; font-size: 12px; }
.phone .msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 6px; background-image: radial-gradient(circle at 1px 1px, rgba(31,42,36,.07) 1px, transparent 0); background-size: 18px 18px; }
.phone .msg { max-width: 85%; font-size: 14px; }
.phone .msg.cust { align-self: flex-end; background: #DCF5C9; }
.phone .msg.bot { align-self: flex-start; background: #fff; }
.phone .composer { background: #F0F0F0; border: 0; }
.typing { align-self: flex-start; background: #fff; border-radius: 12px; padding: 10px 14px; display: flex; gap: 4px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s } .typing i:nth-child(3) { animation-delay: .4s }
@keyframes blink { 50% { opacity: .2; } }
.trace { display: grid; gap: 10px; max-height: 664px; overflow-y: auto; }
.trace .step { border-left: 3px solid var(--accent); padding: 10px 14px; background: var(--card); border-radius: 0 10px 10px 0; animation: rise .3s both; }
.trace .step.guard { border-color: var(--amber); }
.trace .step b { font-family: var(--mono); font-size: 13px; }
.trace pre { margin: 6px 0 0; font: 12px/1.45 var(--mono); white-space: pre-wrap; word-break: break-word; color: var(--ink-2); max-height: 220px; overflow: auto; }
.sim-ctrl { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
@media (max-width: 900px) { .sim { grid-template-columns: 1fr; } }

.json { width: 100%; min-height: 60vh; font: 12.5px/1.5 var(--mono); }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 999px; box-shadow: var(--shadow); animation: rise .3s both; z-index: 9; }
.empty { padding: 40px; text-align: center; color: var(--muted); }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; }
.switch input { appearance: none; width: 44px; height: 24px; border-radius: 999px; background: var(--line); position: relative; border: 0; padding: 0; cursor: pointer; transition: background .2s; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked { background: var(--sage); } .switch input:checked::after { transform: translateX(20px); }

/* Ventana modal */
.modal-bg { position: fixed; inset: 0; background: rgba(31,42,36,.45); display: grid; place-items: center; z-index: 20; padding: 16px; animation: fade .15s both; }
.modal { width: min(460px, 100%); padding: 22px 24px; display: grid; gap: 12px; box-shadow: 0 30px 60px -20px rgba(31,42,36,.5); animation: rise .2s both; }
.modal p { margin: 0; }
.quick.end { justify-content: flex-end; }
@keyframes fade { from { opacity: 0; } }
/* Formularios de políticas */
.form { display: grid; gap: 14px; }
.form textarea { resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.composer .clip { padding: 8px 12px; cursor: pointer; font-size: 18px; }
label input, label textarea, label select { font-weight: 400; color: var(--ink); }
.modal .proof img { width: 100%; max-height: 46vh; object-fit: contain; border-radius: 10px; background: var(--paper-2); display: block; }

/* Laboratorio */
.lab { display: grid; gap: 10px; }
.lab-item summary { list-style: none; cursor: pointer; padding: 14px 18px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.lab-item summary::-webkit-details-marker { display: none; }
.lab-item.bad { border-left: 4px solid var(--red); } .lab-item.ok { border-left: 4px solid var(--sage); }
.lab-why { flex: 1 1 320px; color: var(--ink-2); font-size: 13px; }
.lab-body { display: grid; grid-template-columns: 280px 1fr; gap: 18px; padding: 0 18px 18px; }
.lab-chat { display: flex; flex-direction: column; gap: 6px; background: #EFE7DA; border-radius: 12px; padding: 12px; max-height: 520px; overflow: auto; }
.score { display: grid; grid-template-columns: 78px 1fr 28px; gap: 8px; align-items: center; font-size: 13px; margin-bottom: 6px; }
.score i { height: 8px; border-radius: 99px; background: linear-gradient(90deg, var(--accent) var(--w), var(--paper-2) var(--w)); }
@media (max-width: 900px) { .lab-body { grid-template-columns: 1fr; } }

/* Fotos en el chat */
.msg.media { padding: 4px 4px 6px; max-width: 320px; }
.gal { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 4px; }
.gal img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; margin: 0; }
.msg.media .cap { display: block; font-size: 13px; padding: 4px 6px 0; color: var(--ink-2); }
/* Galería del catálogo */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.media-card { padding: 14px 16px; display: grid; gap: 10px; }
.mc-head { display: flex; justify-content: space-between; gap: 8px; }
.mc-thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; min-height: 40px; }
.mc-thumbs figure { margin: 0; position: relative; }
.mc-thumbs img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 8px; display: block; }
.mc-thumbs figcaption { position: absolute; left: 6px; bottom: 6px; background: var(--ink); color: var(--paper); font-size: 10.5px; padding: 1px 7px; border-radius: 99px; }
.mc-thumbs .vid { display: grid; place-items: center; background: var(--paper-2); border-radius: 8px; aspect-ratio: 4/3; font-size: 13px; }
.mc-del, .mc-act { position: absolute; top: 4px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: rgba(31,42,36,.75); color: #fff; cursor: pointer; font-size: 14px; line-height: 1; opacity: 0; transition: opacity .15s; }
.mc-del { right: 4px; } .mc-act { left: 4px; }
.mc-thumbs figure:hover .mc-del, .mc-thumbs figure:hover .mc-act { opacity: 1; }
@media (hover: none) { .mc-del, .mc-act { opacity: 1; } }
