/* ADIX Music AI — estilos */
:root {
  --bg: #f4f4f6;
  --card: #ffffff;
  --text: #16161a;
  --muted: #6b6b76;
  --line: #e4e4ea;
  --grid: #eeeef2;
  --primary: #d90f1e;
  --primary-2: #b00a17;
  --primary-soft: #fdecee;
  --accent: #f59e0b;
  --accent-soft: #fff4dc;
  --ok: #059669;
  --ok-soft: #e3f7ef;
  --bad: #dc2626;
  --bad-soft: #fde8e8;
  --info: #2563eb;
  --info-soft: #e7efff;
  --side: #0b0b0e;
  --side-text: #c9c9d1;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(10, 10, 14, .06), 0 4px 16px rgba(10, 10, 14, .05);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); }
body { font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
p { margin: 0 0 .6em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.ico { width: 20px; height: 20px; flex: none; }
.ico-xs { width: 14px; height: 14px; vertical-align: -2px; }
.ico-xl { width: 44px; height: 44px; color: var(--primary); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

/* ---------- Estructura ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 248px; flex: none; background: var(--side); color: var(--side-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 18px 12px; z-index: 30; }
.sidebar { background: radial-gradient(120% 60% at 50% 105%, rgba(217, 15, 30, .28), transparent 60%), var(--side); }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; padding: 2px 6px 18px; }
.brand-logo { width: 54px; height: 54px; border-radius: 50%; flex: none; box-shadow: 0 0 0 2px rgba(217, 15, 30, .65), 0 0 18px rgba(217, 15, 30, .35); }
.brand-txt { display: flex; flex-direction: column; line-height: 1.15; }
.brand-txt b { font-size: 17px; letter-spacing: .4px; text-transform: uppercase; }
.brand-txt small { font-size: 11.5px; color: #ff4d5a; letter-spacing: .6px; text-transform: uppercase; font-weight: 700; }
#nav { display: flex; flex-direction: column; gap: 2px; }
#nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--side-text); text-decoration: none; font-size: 14.5px; }
#nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
#nav a.active { background: var(--primary); color: #fff; box-shadow: 0 4px 14px rgba(217, 15, 30, .35); }
.side-foot { margin-top: auto; font-size: 12px; opacity: .75; padding: 10px; font-style: italic; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; padding: 14px 28px; background: rgba(244, 244, 246, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 21px; flex: 1; min-width: 0; }
.status-row { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.status { font-size: 12px; padding: 4px 10px; border-radius: 99px; text-decoration: none; font-weight: 600; white-space: nowrap; }
.status.ok { background: var(--ok-soft); color: var(--ok); }
.status.demo { background: var(--accent-soft); color: #b45309; }
.status.off { background: #ecebf2; color: var(--muted); }
.view { padding: 24px 28px 60px; max-width: 1320px; width: 100%; }
.nav-bg { display: none; }
.only-mobile { display: none; }

/* ---------- Tarjetas y rejillas ---------- */
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.kpis { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.stack > * + * { margin-top: 18px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); min-width: 0; }
.card-h { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-h h3 { font-size: 16px; }
.card-sub { color: var(--muted); font-size: 13px; margin: 3px 0 0; }
.card-a { display: flex; gap: 8px; flex-wrap: wrap; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.kpi-t { font-size: 12.5px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.kpi-v { font-size: 24px; font-weight: 700; margin: 4px 0 2px; letter-spacing: -.3px; overflow-wrap: anywhere; }
.kpi-s { font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.kpi-alerta { border-color: #f3c3c3; background: linear-gradient(0deg, #fff, #fff8f8); }
.kpi-ok { border-color: #bfe8d7; }
.delta { font-weight: 700; padding: 1px 6px; border-radius: 6px; font-size: 12px; }
.delta.up { background: var(--ok-soft); color: var(--ok); }
.delta.down { background: var(--bad-soft); color: var(--bad); }
.tag { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; text-transform: none; }
.tag-amber { background: var(--accent-soft); color: #b45309; }
.tag-violet { background: var(--primary-soft); color: var(--primary-2); }
.tag-green { background: var(--ok-soft); color: var(--ok); }
.tag-red { background: var(--bad-soft); color: var(--bad); }
.tag-gray { background: #ecebf2; color: var(--muted); }
.tip { color: var(--muted); cursor: help; display: inline-flex; }
.chart { position: relative; height: 290px; }
.chart.sm { height: 230px; }
.chart.lg { height: 340px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 700; margin: 6px 0 -4px; }

/* ---------- Encabezado de marca ---------- */
.hero { display: flex; align-items: center; gap: 22px; padding: 22px 26px; border-radius: var(--radius); color: #fff; overflow: hidden;
  background: radial-gradient(90% 140% at 100% 0%, rgba(37, 99, 235, .35), transparent 55%), radial-gradient(80% 140% at 0% 100%, rgba(217, 15, 30, .55), transparent 60%), #0b0b0e; box-shadow: var(--shadow); }
.hero img { width: 104px; height: 104px; border-radius: 50%; flex: none; box-shadow: 0 0 0 3px rgba(217, 15, 30, .7), 0 0 30px rgba(217, 15, 30, .4); }
.hero h2 { font-size: 24px; letter-spacing: .3px; }
.hero .lema { color: #ff4d5a; font-style: italic; font-weight: 700; margin: 2px 0 6px; }
.hero p { margin: 0; color: #d6d6de; }
.hero .servicios { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.hero .servicios span { font-size: 11.5px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; border: 1px solid rgba(255, 255, 255, .25); border-radius: 99px; padding: 3px 10px; }

/* ---------- Avisos ---------- */
.banner { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: 12px; font-size: 14px; }
.banner > .ico { margin-top: 1px; }
.banner p:last-child { margin: 0; }
.banner-warn { background: var(--accent-soft); color: #7c4a03; }
.banner-info { background: var(--info-soft); color: #1e3a8a; }
.banner-ok { background: var(--ok-soft); color: #065f46; }
.banner-error { background: var(--bad-soft); color: #7f1d1d; }
.empty { text-align: center; padding: 40px 20px; }
.empty h3 { margin: 10px 0 6px; font-size: 18px; }
.empty p { color: var(--muted); max-width: 520px; margin: 0 auto 16px; }
.empty-a { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.list { margin: 0; padding-left: 20px; }
.list li { margin: 4px 0; }
.insights { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.insights li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; background: #f9f9fb; border: 1px solid var(--line); }
.insights li .tag { flex: none; margin-top: 2px; }
.val { border-radius: 10px; padding: 8px 12px; margin-top: 8px; font-size: 13.5px; }
.val summary { cursor: pointer; font-weight: 600; }
.val ul { margin: 6px 0 2px; padding-left: 20px; }
.val-error { background: var(--bad-soft); }
.val-warn { background: var(--accent-soft); }
.val-info { background: var(--info-soft); }

/* ---------- Botones y formularios ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: #fff; color: var(--text); padding: 9px 14px; border-radius: 10px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #d6d6de; background: #fafafb; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-2); border-color: var(--primary-2); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #1c1830; }
.btn-danger { color: var(--bad); }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.icon-btn { border: 0; background: transparent; padding: 6px; border-radius: 8px; cursor: pointer; color: inherit; display: inline-flex; }
.icon-btn:hover { background: rgba(0, 0, 0, .06); }
label { font-size: 13px; font-weight: 600; color: var(--muted); display: flex; flex-direction: column; gap: 5px; }
input, select, textarea { font: inherit; font-size: 14px; color: var(--text); border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; background: #fff; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.form { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); align-items: end; }
.form .full { grid-column: 1 / -1; }
.filtros { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.filtros label { flex-direction: row; align-items: center; gap: 8px; }
.filtros select { width: auto; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.file-drop { border: 2px dashed #e3c3c6; border-radius: 12px; padding: 18px; text-align: center; background: #fffafa; cursor: pointer; }
.file-drop:hover { border-color: var(--primary); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid #f6c7cb; background: var(--primary-soft); color: var(--primary-2); border-radius: 99px; padding: 6px 12px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; text-align: left; }
.chip:hover { background: #fbdadd; }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #f7f7f9; }
.tbl td { padding: 8px 10px; border-bottom: 1px solid #efeff3; vertical-align: top; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl tr.neg td { background: #fff6f6; }
.tbl tr.parcial td { color: var(--muted); font-style: italic; }
.tbl tr.total td { font-weight: 700; background: #f7f7f9; }
.nowrap { white-space: nowrap; }
.pos { color: var(--ok); font-weight: 600; }
.negv { color: var(--bad); font-weight: 600; }

/* ---------- KPI detallados ---------- */
.kpi-list { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.kpi-d { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: #fff; display: flex; flex-direction: column; gap: 6px; }
.kpi-d h4 { font-size: 14px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.kpi-d .res { font-size: 20px; font-weight: 700; }
.kpi-d .formula { font-size: 12px; color: var(--muted); background: #f5f5f8; border-radius: 6px; padding: 4px 8px; }
.kpi-d .per { font-size: 12px; color: var(--muted); }
.kpi-d.alerta { border-color: #f3c3c3; }
.kpi-d.ok { border-color: #bfe8d7; }

/* ---------- Asistente ---------- */
.chat { display: flex; flex-direction: column; height: calc(100vh - 150px); min-height: 480px; }
.chat-log { flex: 1; overflow-y: auto; padding: 4px 2px 12px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 82%; padding: 12px 15px; border-radius: 14px; font-size: 14.5px; }
.msg p:last-child { margin-bottom: 0; }
.msg ul, .msg ol { margin: 4px 0 8px; padding-left: 20px; }
.msg h4 { font-size: 14.5px; margin: 8px 0 4px; }
.msg.user { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.msg.model { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; box-shadow: var(--shadow); }
.msg .meta { font-size: 11.5px; color: var(--muted); margin-top: 6px; }
.msg.user .meta { color: #ffd3d7; }
.msg.pensando { color: var(--muted); font-style: italic; }
.chat-form { display: flex; gap: 10px; margin-top: 10px; }
.chat-form textarea { resize: none; height: 52px; }
.dots::after { content: '…'; animation: dots 1.2s infinite steps(4); display: inline-block; width: 1.2em; overflow: hidden; vertical-align: bottom; }
@keyframes dots { 0% { width: 0; } 100% { width: 1.2em; } }

/* ---------- Modal, avisos y bloqueo ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(11, 11, 14, .6); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
.modal { background: #fff; border-radius: 16px; width: 100%; padding: 22px; position: relative; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal h2 { font-size: 19px; margin-bottom: 12px; padding-right: 30px; }
.modal-x { position: absolute; right: 12px; top: 12px; }
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 32px); }
.toast { background: var(--side); color: #fff; padding: 11px 16px; border-radius: 10px; font-size: 14px; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); transition: opacity .3s, transform .3s; max-width: 420px; }
.toast-ok { background: #065f46; }
.toast-error { background: #991b1b; }
.toast.out { opacity: 0; transform: translateY(8px); }
.lock { position: fixed; inset: 0; z-index: 300; background: var(--side); display: flex; align-items: center; justify-content: center; padding: 16px; }
.lock-box { background: #fff; border-radius: 18px; padding: 28px; width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; text-align: center; }
.lock { background: radial-gradient(80% 60% at 50% 100%, rgba(217, 15, 30, .35), transparent 70%), var(--side); }
.lock-box .lock-logo { width: 120px; height: 120px; border-radius: 50%; margin: 0 auto 4px; box-shadow: 0 0 0 3px rgba(217, 15, 30, .6), 0 0 26px rgba(217, 15, 30, .35); }
.lock-err { color: var(--bad); min-height: 1.2em; margin: 0; }

/* ---------- Impresión / PDF ---------- */
.cot-print, .print-head { display: none; }
.top-btn { padding: 6px 10px; }
@media print {
  @page { size: A4; margin: 12mm; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  /* Cotización: solo el documento */
  body.print-cot * { visibility: hidden; }
  body.print-cot .cot-print, body.print-cot .cot-print * { visibility: visible; }
  body.print-cot .cot-print { display: block; position: absolute; inset: 0; padding: 24px; font-size: 13px; }
  /* Pantalla actual */
  body.print-page { background: #fff; font-size: 12px; }
  body.print-page .sidebar, body.print-page .topbar, body.print-page .nav-bg, body.print-page #toasts, body.print-page .modal-bg,
  body.print-page .chips, body.print-page .chat-form, body.print-page .card-a, body.print-page button, body.print-page #lock { display: none !important; }
  body.print-page .app, body.print-page .main { display: block; }
  body.print-page .view { padding: 0; max-width: none; }
  body.print-page .print-head { display: block; font-size: 12px; color: #444; border-bottom: 1px solid #ccc; padding-bottom: 6px; margin-bottom: 12px; }
  body.print-page .card, body.print-page .kpi, body.print-page .kpi-d, body.print-page .insights li { box-shadow: none; break-inside: avoid; }
  body.print-page .chart { height: auto !important; }
  body.print-page canvas { max-width: 100% !important; height: auto !important; }
  body.print-page .chat { height: auto; }
  body.print-page .chat-log { overflow: visible; }
  body.print-page .table-wrap { overflow: visible; }
}
.cot-doc h2 { font-size: 20px; margin-bottom: 4px; }
.cot-head { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.cot-head img { width: 72px; height: 72px; border-radius: 50%; }
.cot-doc table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.cot-doc th, .cot-doc td { border-bottom: 1px solid #ddd; padding: 6px 8px; text-align: left; }
.cot-doc td.num, .cot-doc th.num { text-align: right; }

/* ---------- Adaptación a pantallas pequeñas ---------- */
@media (max-width: 1100px) {
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-2-1 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .25s; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .3); }
  body.nav-open .nav-bg { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 25; }
  .only-mobile { display: inline-flex; }
  .topbar { padding: 10px 16px; flex-wrap: wrap; gap: 8px; }
  .topbar h1 { font-size: 18px; }
  .hero { flex-direction: column; text-align: center; padding: 20px 16px; }
  .hero .servicios { justify-content: center; }
  .top-btn span { display: none; }
  .status-row { width: 100%; justify-content: flex-start; order: 3; }
  .view { padding: 16px 16px 48px; }
  .g2, .g3 { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-v { font-size: 20px; }
  .msg { max-width: 94%; }
  .chat { height: calc(100vh - 170px); }
  .card { padding: 16px; }
}
