/* Codex AI CRM — marca: naranja #e8540a / negro #060606. Móvil primero. */
:root {
  --bg: #060606; --panel: #0e0e0e; --panel-2: #141414; --line: rgba(255,255,255,.1); --line-2: rgba(255,255,255,.18);
  --text: #f4f4f4; --muted: rgba(255,255,255,.58); --faint: rgba(255,255,255,.36);
  --orange: #e8540a; --orange-2: #ff7a33;
  --ok: #3ecf8e; --warn: #f5b63d; --bad: #ff5d5d; --info: #6ea8ff;
  --font-display: 'Libre Caslon Condensed', Georgia, serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, monospace;
  --pad: clamp(16px, 3.5vw, 32px);
  --side: 248px;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 var(--font-body); min-height: 100dvh; overflow-x: hidden; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
a { color: inherit; }
h1, h2, h3 { font-weight: 500; letter-spacing: -.02em; line-height: 1.15; text-wrap: balance; }
.muted { color: var(--muted); } .faint { color: var(--faint); }
.tag { font-family: var(--font-mono); font-size: 11px; letter-spacing: .04em; color: var(--faint); }
.mono { font-family: var(--font-mono); }
.num { font-variant-numeric: tabular-nums; }
.italic { font-family: var(--font-display); font-style: italic; font-weight: 400; letter-spacing: 0; }

/* ── Marca ── */
.logo { display: flex; align-items: center; gap: 10px; font-family: var(--font-mono); font-size: 15px; letter-spacing: .1em; }
.logo svg { width: 22px; height: 22px; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; fill: none; }

/* ── Botones y campos ── */
.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--line-2); font-size: 14px; font-weight: 500; white-space: nowrap; transition: background .2s, border-color .2s, color .2s; }
.btn:hover { border-color: #fff; }
.btn.primary { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn.primary:hover { background: var(--orange-2); border-color: var(--orange-2); }
.btn.solid { background: #fff; color: #000; border-color: #fff; }
.btn.danger { color: var(--bad); border-color: rgba(255,93,93,.4); }
.btn.danger:hover { background: rgba(255,93,93,.12); border-color: var(--bad); }
.btn.sm { min-height: 36px; padding: 0 14px; font-size: 13px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.linkbtn { color: var(--muted); font-size: 13px; text-align: left; padding: 6px 0; }
.linkbtn:hover { color: var(--orange-2); }
.iconbtn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line-2); display: grid; place-items: center; }
.iconbtn:hover { border-color: #fff; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > span { font-family: var(--font-mono); font-size: 11px; color: var(--muted); letter-spacing: .03em; }
.field input, .field select, .field textarea { width: 100%; min-height: 46px; padding: 11px 14px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); outline: none; font-size: 16px; }
.field textarea { min-height: 92px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--orange); }
.field .hint { font-family: var(--font-body); font-size: 12px; color: var(--faint); }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 15px; }
.check input { width: 20px; height: 20px; accent-color: var(--orange); }
.error { color: var(--bad); font-size: 13px; }

/* ── Entrada ── */
.login { min-height: 100dvh; display: grid; place-items: center; padding: var(--pad); background: radial-gradient(60% 50% at 80% 0%, rgba(232,84,10,.28), transparent 70%), var(--bg); }
.login-card { width: min(400px, 100%); display: grid; gap: 16px; padding: 28px; border: 1px solid var(--line); border-radius: 24px; background: rgba(14,14,14,.85); }
.login-card h1 { font-size: 30px; margin-top: 12px; }

/* ── Estructura ── */
.app { display: grid; grid-template-columns: 1fr; min-height: 100dvh; }
.side { display: none; }
.main { min-width: 0; padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: max(12px, env(safe-area-inset-top)) var(--pad) 12px; background: rgba(6,6,6,.88); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.top h1 { font-size: clamp(22px, 4vw, 30px); }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
main { padding: var(--pad); max-width: 1280px; margin-inline: auto; display: grid; gap: 24px; outline: none; }

.tabbar { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, 1fr); background: rgba(10,10,10,.96); backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabbar a { display: grid; justify-items: center; gap: 3px; padding: 9px 2px 8px; font-size: 11px; color: var(--muted); text-decoration: none; min-height: 56px; }
.tabbar a svg, .nav a svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.on { color: var(--orange-2); }

@media (min-width: 900px) {
  .app { grid-template-columns: var(--side) 1fr; }
  .side { display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100dvh; padding: 28px 20px; border-right: 1px solid var(--line); }
  .side-tag { margin: 2px 0 22px 32px; }
  .nav { display: grid; gap: 4px; }
  .nav a { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 12px; color: var(--muted); text-decoration: none; font-weight: 500; }
  .nav a:hover { background: var(--panel-2); color: #fff; }
  .nav a.on { background: rgba(232,84,10,.14); color: var(--orange-2); }
  .side-foot { margin-top: auto; display: grid; gap: 2px; padding: 0 14px; }
  .main { padding-bottom: 40px; }
  .tabbar { display: none; }
}

/* ── Componentes ── */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: clamp(16px, 2.6vw, 24px); min-width: 0; }
.card h2 { font-size: 17px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 900px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 16px; display: grid; gap: 6px; min-width: 0; }
.tile .big { font-family: var(--font-display); font-style: italic; font-size: clamp(28px, 6vw, 40px); line-height: 1; overflow-wrap: anywhere; }
.tile.hot { border-color: rgba(232,84,10,.55); background: linear-gradient(160deg, rgba(232,84,10,.16), var(--panel)); }
.tile.bad .big { color: var(--bad); }
.delta { font-family: var(--font-mono); font-size: 11px; }
.delta.up { color: var(--ok); } .delta.down { color: var(--bad); }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-family: var(--font-mono); font-size: 11px; border: 1px solid var(--line-2); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-activo, .b-pagado { color: var(--ok); border-color: rgba(62,207,142,.4); }
.b-aviso, .b-pendiente { color: var(--warn); border-color: rgba(245,182,61,.4); }
.b-vencido { color: var(--orange-2); border-color: rgba(255,122,51,.5); }
.b-suspendido, .b-baja { color: var(--bad); border-color: rgba(255,93,93,.45); }
.b-pausado { color: var(--muted); }
.b-prospecto { color: var(--info); border-color: rgba(110,168,255,.4); }

.list { display: grid; }
.row { display: grid; gap: 4px 12px; padding: 14px 0; border-top: 1px solid var(--line); align-items: center; min-width: 0; }
.row:first-child { border-top: 0; padding-top: 0; }
.row .title { font-weight: 500; overflow-wrap: anywhere; }
.row .sub { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.row .right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
a.row { text-decoration: none; color: inherit; }
a.row:hover .title { color: var(--orange-2); }
.split { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.stack { display: grid; gap: 12px; }
.empty { padding: 26px 8px; text-align: center; color: var(--muted); font-size: 14px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 8px 14px; min-height: 38px; border-radius: 999px; border: 1px solid var(--line-2); font-size: 13px; color: var(--muted); }
.chip.on { background: #fff; color: #000; border-color: #fff; }
.search { width: 100%; max-width: 420px; min-height: 44px; padding: 10px 16px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); outline: none; font-size: 16px; }
.search:focus { border-color: var(--orange); }
.kvs { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.kv { display: grid; gap: 4px; }
.kv dt { font-family: var(--font-mono); font-size: 11px; color: var(--faint); }
.kv dd { overflow-wrap: anywhere; }
.alert { border: 1px solid rgba(245,182,61,.45); background: rgba(245,182,61,.08); color: #ffd98a; border-radius: 14px; padding: 12px 14px; font-size: 14px; }
.alert.bad { border-color: rgba(255,93,93,.5); background: rgba(255,93,93,.08); color: #ffb0b0; }
.note { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; color: var(--muted); }

/* Ficha del cliente */
.client-head { display: grid; gap: 14px; }
.client-head h2 { font-size: clamp(24px, 5vw, 36px); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.svc { border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: grid; gap: 12px; background: var(--panel-2); }
.switch { display: flex; gap: 6px; flex-wrap: wrap; }
.switch button { padding: 6px 12px; min-height: 34px; border-radius: 999px; border: 1px solid var(--line-2); font-size: 12px; font-family: var(--font-mono); color: var(--muted); }
.switch button:hover { border-color: #fff; color: #fff; }
.switch button.on { background: #fff; color: #000; border-color: #fff; }
.logline { font-size: 12px; color: var(--muted); font-family: var(--font-mono); }

/* Gráfico de barras */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 150px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; min-width: 0; }
.bar .col { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.bar i { display: block; width: 100%; min-height: 3px; border-radius: 8px 8px 3px 3px; background: linear-gradient(180deg, var(--orange-2), var(--orange)); }
.bar small { font-family: var(--font-mono); font-size: 10px; color: var(--faint); }
.bar b { font-family: var(--font-mono); font-size: 10px; font-weight: 400; color: var(--muted); }

/* Calendario */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .dow { font-family: var(--font-mono); font-size: 10px; color: var(--faint); text-align: center; padding: 4px 0; }
.cal button { aspect-ratio: 1; min-height: 44px; border-radius: 12px; background: var(--panel-2); border: 1px solid transparent; display: grid; align-content: center; justify-items: center; gap: 2px; font-size: 13px; position: relative; }
.cal button.out { opacity: .25; pointer-events: none; }
.cal button.today { border-color: var(--line-2); }
.cal button.sel { border-color: var(--orange); background: rgba(232,84,10,.14); }
.cal button .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--warn); }
.cal button .dot.late { background: var(--bad); } .cal button .dot.paid { background: var(--ok); }
.cal button small { font-family: var(--font-mono); font-size: 9px; color: var(--muted); }
.cal-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.cal-nav h2 { text-transform: capitalize; }

/* Ventana de formulario */
dialog { border: 1px solid var(--line-2); border-radius: 24px; background: var(--panel); color: var(--text); width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; margin: auto; overflow: hidden; }
dialog::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(3px); }
dialog form { display: grid; max-height: calc(100dvh - 24px); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 6px; }
.dlg-head h2 { font-size: 20px; }
.dlg-body { display: grid; gap: 14px; padding: 12px 20px; overflow-y: auto; }
.dlg-foot { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; padding: 14px 20px calc(18px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.two { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
@media (max-width: 480px) { .two { grid-template-columns: 1fr; } .dlg-foot .btn { flex: 1; } }

#toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: #fff; color: #000; padding: 11px 18px; border-radius: 999px; font-size: 14px; font-weight: 500; opacity: 0; pointer-events: none; transition: .25s; z-index: 100; max-width: calc(100vw - 32px); text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.err { background: var(--bad); color: #fff; }
@media (min-width: 900px) { #toast { bottom: 28px; } }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
