/* Rosen · agente de texto — one stylesheet, a handful of components. */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e5ea;
  --text: #1c2430;
  --muted: #5f6b7a;
  --accent: #0f7b6c;
  --accent-ink: #ffffff;
  --accent-soft: #e3f3f0;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #b54708;
  --warn-soft: #fef3e2;
  --green: #12a150;
  --yellow: #e0a100;
  --red: #d92d20;
  --bubble-in: #ffffff;
  --bubble-ai: #e3f3f0;
  --bubble-user: #e8eefc;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151a; --surface: #181d24; --surface-2: #1f252e; --border: #2b323d;
    --text: #e6e9ee; --muted: #9aa5b4; --accent: #2bb39f; --accent-ink: #0b1512;
    --accent-soft: #15302b; --danger: #f97066; --danger-soft: #3a1714; --warn: #fdb022;
    --warn-soft: #33250c; --bubble-in: #1f252e; --bubble-ai: #15302b; --bubble-user: #1d2740;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.4rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 1rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grow { flex: 1; }
.two-col { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 800px) { .two-col { grid-template-columns: 1fr; } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Top bar */
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: .6rem 1rem; display: flex; align-items: center; gap: 1rem;
  position: sticky; top: 0; z-index: 10; flex-wrap: wrap;
}
.brand { font-weight: 700; color: var(--text); }
.topbar nav { display: flex; gap: .25rem; flex-wrap: wrap; }
.topbar nav a { padding: .35rem .65rem; border-radius: 8px; color: var(--muted); }
.topbar nav a.on, .topbar nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.topbar .user { margin-left: auto; display: flex; gap: .5rem; align-items: center; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.wrap.wide { max-width: 1400px; }

/* Cards & tables */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem 1.2rem; box-shadow: var(--shadow);
}
.card.pad-0 { padding: 0; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .65rem .8rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
.table-scroll { overflow-x: auto; }

/* Status dot & badges */
.dot { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; vertical-align: middle; }
.dot.verde { background: var(--green); }
.dot.amarillo { background: var(--yellow); }
.dot.rojo { background: var(--red); }
.badge {
  display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .78rem;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap;
}
.badge.ia { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge.pendiente { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.humano { background: var(--bubble-user); color: var(--text); border-color: transparent; }
.badge.error { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

/* Buttons & forms */
.btn {
  display: inline-flex; align-items: center; gap: .35rem; padding: .5rem .9rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; cursor: pointer; text-decoration: none; line-height: 1.2; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.small { padding: .3rem .6rem; font-size: .85rem; }
.btn.link { border: 0; background: none; color: var(--accent); padding: 0; }
form.inline { display: inline; }
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .25rem; }
label.check { display: flex; gap: .5rem; align-items: center; font-weight: 400; }
.field { margin-bottom: .9rem; }
.field .hint { font-size: .82rem; color: var(--muted); margin-top: .2rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=time],
input[type=date], input[type=search], input[type=tel], select, textarea {
  width: 100%; padding: .5rem .65rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit;
}
textarea { min-height: 5rem; resize: vertical; }
/* Inline forms: inputs sit next to their button instead of taking a full line. */
.row > input:not([type=checkbox]):not([type=radio]), .row > select { width: auto; flex: 0 1 260px; min-width: 0; }
form.row { flex-wrap: nowrap; }
@media (max-width: 640px) { form.row { flex-wrap: wrap; } }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.fields-2 { display: grid; gap: 0 1rem; grid-template-columns: 1fr 1fr; }
@media (max-width: 640px) { .fields-2 { grid-template-columns: 1fr; } }

/* Flash */
.flash { padding: .65rem .9rem; border-radius: 8px; margin-bottom: 1rem; word-break: break-word; }
.flash.ok { background: var(--accent-soft); color: var(--text); }
.flash.error { background: var(--danger-soft); color: var(--danger); }
.saved { color: var(--accent); font-size: .85rem; }
.warning-box { background: var(--warn-soft); border-radius: 8px; padding: .75rem .9rem; color: var(--text); }

/* Workspace header + tabs */
.ws-head { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: .75rem; }
.ws-head .grow { min-width: 200px; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; overflow-x: auto; }
.tabs a {
  padding: .55rem .9rem; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs a.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--text); }

/* Stats */
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; }
.stat .k { font-size: .8rem; color: var(--muted); }
.stat .v { font-size: 1.4rem; font-weight: 700; margin-top: .15rem; }
.bar { height: .5rem; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: .4rem; }
.bar > span { display: block; height: 100%; background: var(--accent); }
.bar.warn > span { background: var(--yellow); }
.bar.over > span { background: var(--red); }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { padding: .5rem 0; border-bottom: 1px solid var(--border); display: flex; gap: .75rem; }
.feed li:last-child { border-bottom: 0; }
.feed time { color: var(--muted); font-size: .85rem; min-width: 5.5rem; }

/* Inbox */
.inbox {
  display: grid; grid-template-columns: 340px 1fr; height: calc(100vh - 200px); min-height: 480px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.inbox > * { min-width: 0; }
.inbox .list { border-right: 1px solid var(--border); overflow-y: auto; }
.inbox .chips { display: flex; gap: .3rem; padding: .6rem; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.chip { padding: .2rem .65rem; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); font-size: .85rem; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip:hover { text-decoration: none; }
.conv-item { display: block; padding: .7rem .85rem; border-bottom: 1px solid var(--border); color: var(--text); }
.conv-item:hover { background: var(--surface-2); text-decoration: none; }
.conv-item.on { background: var(--accent-soft); }
.conv-item .name { font-weight: 600; }
.conv-item .preview { color: var(--muted); font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail { display: flex; flex-direction: column; min-width: 0; }
.detail-head { padding: .7rem 1rem; border-bottom: 1px solid var(--border); display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.thread { flex: 1; overflow-y: auto; padding: 1rem; background: var(--bg); display: flex; flex-direction: column; gap: .4rem; }
.bubble { max-width: 75%; padding: .5rem .75rem; border-radius: 12px; word-wrap: break-word; box-shadow: var(--shadow); }
.bubble .body { white-space: pre-wrap; }
.bubble.in { background: var(--bubble-in); align-self: flex-start; border: 1px solid var(--border); }
.bubble.ai { background: var(--bubble-ai); align-self: flex-end; }
.bubble.user { background: var(--bubble-user); align-self: flex-end; }
.bubble .meta { font-size: .75rem; color: var(--muted); margin-top: .2rem; }
.bubble.failed { border: 1px solid var(--danger); }
.composer { border-top: 1px solid var(--border); padding: .6rem; display: flex; gap: .5rem; }
.composer textarea { min-height: 2.6rem; height: 2.6rem; }
.empty { padding: 2rem; text-align: center; color: var(--muted); }
@media (max-width: 800px) {
  .inbox { grid-template-columns: 1fr; height: auto; }
  .inbox .list { max-height: 40vh; border-right: 0; border-bottom: 1px solid var(--border); }
  .inbox.has-conv .list { display: none; }
  .thread { min-height: 50vh; }
}
.back-link { display: none; }
@media (max-width: 800px) { .back-link { display: inline; } }

/* Agente sections */
.repeat-row { display: grid; gap: .5rem; grid-template-columns: 1fr auto; align-items: start; padding: .6rem 0; border-bottom: 1px dashed var(--border); }
.repeat-row .ops { display: flex; flex-direction: column; gap: .25rem; }
.svc-row { display: grid; gap: .5rem; grid-template-columns: 2fr 1fr 1fr auto; align-items: center; margin-bottom: .4rem; }
@media (max-width: 640px) { .svc-row { grid-template-columns: 1fr 1fr; } }
.hours-grid { display: grid; grid-template-columns: 7rem minmax(0, 9.5rem) minmax(0, 9.5rem) auto auto; gap: .4rem .75rem; align-items: center; justify-content: start; }
.hours-grid[hidden] { display: none; }
.hours-row { display: contents; }
.hours-grid input[type=time]:disabled { opacity: .4; }
@media (max-width: 520px) {
  .hours-grid { grid-template-columns: 5.5rem 1fr 1fr; }
  .hours-grid .allday { grid-column: 2; }
  .hours-grid .closed { grid-column: 3; }
}
pre.prompt { white-space: pre-wrap; background: var(--surface-2); padding: 1rem; border-radius: 8px; font-size: .85rem; max-height: 60vh; overflow: auto; }
details > summary { cursor: pointer; font-weight: 600; }

/* Team cards */
.member { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; background: var(--surface); }
.member.inactive { opacity: .7; }
.checks { display: flex; flex-wrap: wrap; gap: .4rem 1rem; }

/* Wizard */
.progress { display: flex; gap: .5rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.progress .step { flex: 1; min-width: 110px; padding: .5rem .6rem; border-radius: 8px; background: var(--surface-2); color: var(--muted); font-size: .88rem; }
.progress .step.done { background: var(--accent-soft); color: var(--accent); }
.progress .step.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.type-pick { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.type-pick label { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; cursor: pointer; font-weight: 600; display: flex; gap: .5rem; align-items: center; background: var(--surface); }
.type-pick input:checked + span { color: var(--accent); }

.qr { background: #fff; padding: .5rem; border-radius: 8px; width: 260px; max-width: 100%; }
.login { max-width: 380px; margin: 8vh auto; }
