:root {
  --bg: #f4f5f9; --card: #fff; --text: #1f2430; --muted: #6b7280; --line: #e6e8ef;
  --brand: #3b2a8a; --brand-soft: #ece9fb;
  --ok: #1d7a46; --ok-soft: #d8f3e3; --warn: #9a6400; --warn-soft: #fff3d6;
  --bad: #b42318; --bad-soft: #fde2df; --info: #2d5bd7; --info-soft: #e3ebff;
  --star: #f5b301;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--brand); }
.topbar { display: flex; align-items: center; gap: 20px; padding: 0 24px; height: 56px; background: var(--brand); color: #fff; }
.topbar a { color: #fff; text-decoration: none; opacity: .85; }
.topbar a:hover, .topbar a.active { opacity: 1; }
.topbar .brand { font-weight: 700; font-size: 16px; opacity: 1; margin-right: 12px; }
.topbar .spacer { flex: 1; }
.topbar .pill { background: #fff; color: var(--brand); border-radius: 999px; padding: 0 8px; font-size: 12px; font-weight: 700; margin-left: 4px; }
.topbar form { margin: 0; }
.topbar button.link { background: none; border: 0; color: #fff; opacity: .85; cursor: pointer; font: inherit; padding: 0; }
main { max-width: 1400px; margin: 0 auto; padding: 24px; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 18px; margin: 28px 0 12px; display: flex; align-items: center; gap: 10px; }
h3 { font-size: 15px; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }

.btn { display: inline-block; background: var(--brand); color: #fff; border: 0; border-radius: 8px; padding: 7px 14px; font: inherit; cursor: pointer; text-decoration: none; }
.btn.secondary { background: var(--brand-soft); color: var(--brand); }
.btn.small { padding: 4px 10px; font-size: 12px; }

.messages { list-style: none; padding: 0; margin: 0 0 16px; }
.messages li { padding: 8px 12px; border-radius: 8px; margin-bottom: 6px; background: var(--ok-soft); color: var(--ok); }
.messages li.error { background: var(--bad-soft); color: var(--bad); }

.sync-progress { background: var(--info-soft); border-radius: 10px; padding: 10px 14px; margin: 12px 0 4px; }
.sync-progress .sync-text { font-size: 13px; color: var(--info); margin-bottom: 6px; }
.sync-progress .bar { height: 8px; background: #fff; border-radius: 999px; overflow: hidden; }
.sync-progress .fill { height: 100%; width: 0; background: var(--info); border-radius: 999px; transition: width .4s; }
.sync-progress.done { background: var(--ok-soft); }
.sync-progress.done .sync-text { color: var(--ok); }
.sync-progress.done .fill { background: var(--ok); width: 100% !important; }

.quality-banner { background: var(--warn-soft); border: 1px solid #f3d27a; border-radius: 10px; padding: 12px 16px; margin: 16px 0 4px; }
.quality-banner ul { margin: 8px 0 10px; padding-left: 20px; }
.quality-banner li { margin: 3px 0; }
.quality-banner summary { cursor: pointer; }
.quality-banner[open] summary { margin-bottom: 6px; }

/* resumen superior */
.totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 16px 0 8px; }
.tile { background: var(--card); border-radius: 10px; padding: 12px 14px; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
a.tile { text-decoration: none; color: inherit; transition: box-shadow .15s, transform .15s; }
a.tile:hover { box-shadow: 0 3px 10px rgba(0,0,0,.12); transform: translateY(-1px); }
.tile .n { font-size: 26px; font-weight: 700; }
/* casilla con desglose: mismo formato que las demás (número grande arriba, etiqueta debajo) + línea pequeña */
.tile-split a { color: inherit; text-decoration: none; }
.tile-split a.main { display: block; }
.tile-split .subs { margin-top: 2px; font-size: 12px; color: var(--muted); }
.tile-split .subs a:hover, .tile-split a.main:hover .l { text-decoration: underline; }
.tile-split .subs b { color: var(--text); font-weight: 600; }
.tile .l { color: var(--muted); font-size: 12px; }
.tile.alert { background: var(--bad-soft); }
.tile.alert .n { color: var(--bad); }
.tile.attn { background: var(--warn-soft); }
.tile.attn .n { color: var(--warn); }

/* tarjetas de site */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 16px; }
.card { background: var(--card); border-radius: 12px; padding: 18px 20px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 12px; }
.card-status { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.card-status .row { flex-wrap: nowrap; gap: 6px; }
.card-head .title { font-size: 17px; font-weight: 700; text-decoration: none; color: var(--text); }
.badge { display: inline-block; border-radius: 6px; padding: 2px 8px; font-size: 12px; font-weight: 600; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.muted { background: var(--line); color: var(--muted); }
.badge.new { background: var(--brand); color: #fff; }
tr.unread td { font-weight: 600; }
tr.unread td .muted { font-weight: 400; }
.stars { color: var(--star); letter-spacing: 1px; }
.stars .off { color: #d5d7de; }
.stars .half { background: linear-gradient(90deg, var(--star) 50%, #d5d7de 50%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.grade { font-weight: 700; margin-right: 4px; }

.sections { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.section { background: #f8f8fc; border-radius: 8px; padding: 10px 12px; }
.section h4 { margin: 0 0 6px; font-size: 13px; }
.kv { display: flex; justify-content: space-between; padding: 2px 0; font-size: 13px; }
.kv b { font-variant-numeric: tabular-nums; }
a.kv { color: inherit; text-decoration: none; border-radius: 4px; }
a.kv:hover { background: var(--brand-soft); }
.section h4 a { color: inherit; text-decoration: none; }
.section h4 a:hover { color: var(--brand); text-decoration: underline; }
.kv b.hot { color: var(--bad); }
.kv b.warm { color: var(--warn); }

.kpis { display: flex; gap: 14px; flex-wrap: wrap; margin: 10px 0; font-size: 13px; color: var(--muted); }
.kpis b { color: var(--text); }

table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
.table-card { background: var(--card); border-radius: 12px; padding: 4px 0; box-shadow: 0 1px 3px rgba(0,0,0,.06); overflow-x: auto; }
.rules td.v { text-align: right; }

.level-critical { border-left: 3px solid var(--bad); }
.level-warning { border-left: 3px solid var(--star); }
.level-info { border-left: 3px solid var(--info); }

.footer-note { margin-top: 10px; font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
.error-box { background: var(--bad-soft); color: var(--bad); border-radius: 8px; padding: 8px 10px; font-size: 12px; margin-top: 8px; white-space: pre-wrap; }

a.ext { text-decoration: none; color: var(--muted); font-size: 12px; }
a.ext:hover { color: var(--brand); }
td.links { white-space: nowrap; }
td.links .btn { margin: 1px 0; }

.chat { display: flex; flex-direction: column; gap: 10px; max-width: 900px; }
.msg { background: var(--card); border-radius: 10px; padding: 10px 14px; box-shadow: 0 1px 2px rgba(0,0,0,.06); max-width: 80%; }
.msg-tienda { align-self: flex-end; background: var(--brand-soft); }
.msg-operador { border-left: 3px solid var(--bad); }
.msg-cliente { border-left: 3px solid var(--star); }
.msg-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.msg-body { white-space: normal; overflow-wrap: anywhere; }
.msg-body p, .msg-body div { margin: 0 0 4px; }
.msg-body blockquote { margin: 6px 0; padding-left: 10px; border-left: 3px solid var(--line); color: var(--muted); }
.msg-body table { width: auto; background: transparent; }
.msg-body td, .msg-body th { border: 0; padding: 2px 6px; font-size: inherit; }
select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: var(--card); }

.sim-banner { background: var(--warn-soft); border: 1px dashed #d9a400; color: #6b4a00; border-radius: 8px; padding: 8px 12px; margin-bottom: 10px; font-size: 13px; }
.reply-form textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px; font: inherit; resize: vertical; }
.reply-form label { display: inline-flex; gap: 4px; align-items: center; }
.reply-preview { border: 2px solid var(--brand-soft); }
pre.raw { white-space: pre-wrap; overflow-wrap: anywhere; background: #f6f6fa; border-radius: 6px; padding: 8px; font-size: 12px; }
.messages li.warning { background: var(--warn-soft); color: var(--warn); }

.nav-search input { width: 220px; padding: 6px 10px; border-radius: 8px; border: 0; font: inherit; font-size: 13px; }
.search-input { flex: 1; min-width: 260px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.form-card { max-width: 820px; }
.form-card .field { margin-bottom: 14px; }
.form-card label { display: block; font-weight: 600; margin-bottom: 4px; }
.form-card input[type=text], .form-card select, .form-card textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
code { background: #f1f1f6; border-radius: 4px; padding: 0 4px; font-size: 12px; }

.login { max-width: 360px; margin: 80px auto; background: var(--card); padding: 28px; border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.login input { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; margin: 4px 0 12px; }
.login .btn { width: 100%; padding: 10px; }

@media (max-width: 640px) {
  main { padding: 16px; }
  .grid { grid-template-columns: 1fr; }
  .sections { grid-template-columns: 1fr; }
  .topbar { gap: 12px; padding: 0 16px; overflow-x: auto; }
}
.sync-stamp { font-size: 11px; font-weight: 300; color: var(--muted); letter-spacing: .1px; }

/* color por marketplace (Configuración → Marketplaces → color) */
.mp-card { border-top: 6px solid var(--mp, var(--line)); }
.mp-heading { display: flex; align-items: center; gap: 10px; }
.mp-toggle { border: 1px solid var(--line); background: var(--card); border-radius: 6px; width: 28px; height: 28px;
  font-size: 14px; line-height: 1; cursor: pointer; color: var(--muted); padding: 0; }
.mp-toggle:hover { color: var(--brand); border-color: var(--brand); }
.mp-group.collapsed .mp-body { display: none; }
.mp-collapsed-note { display: none; }
.mp-group.collapsed .mp-collapsed-note { display: inline; }
.mp-dot { width: 14px; height: 14px; border-radius: 4px; background: var(--mp, var(--line)); flex-shrink: 0; }

/* Buzón de entrada (icono tipo Gmail en lugar del número) */
.tile-inbox .inbox-icon { width: 34px; height: 26px; display: block; margin: 5px 0 6px; }
.tile-inbox .subs { margin-top: 2px; font-size: 12px; color: var(--muted); }
.tile-inbox .subs b { color: var(--text); font-weight: 600; }
.alert-prefs { margin: 10px 0; }
.alert-kinds { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.alert-kinds label { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; }

/* casillas arrastrables */
.totals [data-tile] { cursor: grab; }
.totals [data-tile].dragging { opacity: .45; outline: 2px dashed var(--brand); }
.tiles-hint { margin: -2px 0 6px; font-size: 11px; }
.tile-inbox .inbox-icon { color: var(--brand); }
.tile-inbox.attn .inbox-icon { color: var(--warn); }

/* buscador de plantillas */
.tpl-search { position: relative; flex: 1; min-width: 240px; max-width: 420px; }
.tpl-search input { width: 100%; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.tpl-results { position: absolute; z-index: 10; left: 0; right: 0; top: 100%; margin: 2px 0 0; padding: 4px 0; list-style: none;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 4px 14px rgba(0,0,0,.1); max-height: 260px; overflow: auto; }
.tpl-results li { padding: 6px 10px; cursor: pointer; font-size: 13px; }
.tpl-results li:hover, .tpl-results li.active { background: var(--brand-soft); }
.ratings-link { text-decoration: underline; text-underline-offset: 2px; } .ratings-link:hover { color: var(--brand); }

.tpl-vars { margin: 0 0 12px; }
.var-chip { font: 12px ui-monospace, monospace; background: var(--bg, #f4f5f8); border: 1px solid #d5d7de; border-radius: 6px; padding: 2px 6px; margin: 4px 4px 0 0; cursor: pointer; }
.var-chip:hover { border-color: #888; }
.not-available { border: 1px dashed var(--line); border-radius: 8px; padding: 8px 10px; color: var(--muted); }
.not-available b { color: var(--warn); }
.not-available .btn { margin-top: 6px; }
.mp-icon { width: 16px; height: 16px; vertical-align: -3px; margin-right: 5px; border-radius: 3px; }
.title .mp-icon, h1 .mp-icon { width: 20px; height: 20px; vertical-align: -4px; }
.resolve-box { margin-bottom: 16px; }
.resolve-box h3 { margin-top: 0; }
.resolve-box code { font-size: 13px; }
.tile .n .of { font-size: .55em; font-weight: 600; color: var(--muted); margin-left: 2px; }
.rules-table { width: 100%; border-collapse: collapse; } .rules-table th, .rules-table td { text-align: left; padding: 6px 8px; border-top: 1px solid var(--line); vertical-align: top; }
