/* inGnius CRM · móvil primero, tema claro y oscuro */
:root {
  --bg: #f3f6f5; --surface: #ffffff; --line: #d9e1de; --fg: #14201c; --muted: #5a6a64;
  --accent: #1f6f5c; --accent-fg: #ffffff; --accent-soft: #e2f0eb;
  --warn: #9a5b00; --warn-soft: #fbf0dd; --bad: #a3312a; --bad-soft: #fbe6e3;
  --radius: 10px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1614; --surface: #17211e; --line: #2a3833; --fg: #e7eeeb; --muted: #94a69f;
    --accent: #5cc4a6; --accent-fg: #0f1614; --accent-soft: #1b3029;
    --warn: #f0b866; --warn-soft: #33281a; --bad: #f08a80; --bad-soft: #3a1f1c;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.5 var(--font); }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0; text-wrap: balance; }
h1 { font-size: 26px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
p { margin: 0; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* Cabecera y navegación */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px;
  background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; text-decoration: none; color: var(--fg); }
.brand span { color: var(--accent); }
.nav { display: flex; gap: 4px; }
.nav a { text-decoration: none; color: var(--muted); padding: 8px 12px; border-radius: 8px; font-weight: 600; font-size: 15px; }
.nav a.active { color: var(--accent); background: var(--accent-soft); }
.logout button { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; padding: 8px; }
@media (max-width: 760px) {
  .nav { position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--line);
    justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px)); z-index: 10; }
  .nav a { font-size: 13px; padding: 8px 6px; }
  .top { flex-wrap: wrap; }
  .top-search { order: 3; flex: 1 0 100%; }
  body { padding-bottom: 72px; }
}

.wrap { max-width: 980px; margin: 0 auto; padding: 20px 16px 40px; display: flex; flex-direction: column; gap: 16px; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 760px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.panel > h2 { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }

/* Avisos */
.flash { padding: 10px 14px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.flash.error { background: var(--bad-soft); color: var(--bad); }

/* Etiquetas */
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.pill.lost { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.plain { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.overdue { color: var(--bad); font-weight: 600; }

/* Listas de contactos */
.items { display: flex; flex-direction: column; }
.item { display: flex; flex-direction: column; gap: 6px; padding: 12px 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; padding-top: 0; }
.item .title { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.item .title a { font-weight: 600; text-decoration: none; color: var(--fg); }
.item .meta { font-size: 14px; color: var(--muted); }
.empty { color: var(--muted); padding: 8px 0; }

/* Formularios */
label { font-size: 14px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
input, select, textarea { font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; width: 100%; min-width: 0; }
textarea { min-height: 80px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.fields .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .fields { grid-template-columns: minmax(0, 1fr); } }
.field-error { color: var(--bad); font-size: 13px; font-weight: 600; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: 600 15px var(--font); border-radius: 8px; padding: 9px 14px;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-fg); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn.small { padding: 6px 10px; font-size: 14px; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.quick select { width: auto; padding: 6px 8px; font-size: 14px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.inline-form label { flex: 1 1 140px; }
details > summary { cursor: pointer; color: var(--accent); font-weight: 600; }
details[open] > summary { margin-bottom: 10px; }

/* Números */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 2px; }
.stat strong { font-size: 26px; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.stat span { font-size: 13px; color: var(--muted); }
progress, meter { width: 100%; height: 10px; accent-color: var(--accent); }
.tablebox { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-top: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border-top: 0; }
td.r, th.r { text-align: right; }

/* Historial */
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.timeline li { border-left: 3px solid var(--line); padding-left: 10px; }
.timeline .when { font-size: 13px; color: var(--muted); }

.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.chips a { text-decoration: none; white-space: nowrap; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); font-size: 14px; background: var(--surface); }
.chips a.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); font-weight: 600; }

.auth { max-width: 420px; margin: 8vh auto 0; }
.token { font-family: var(--mono); word-break: break-all; background: var(--bg); border: 1px dashed var(--accent); padding: 10px; border-radius: 8px; }
code { font-family: var(--mono); font-size: 14px; }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }

/* ---- Versión 2 ---- */
.brand { display: inline-flex; align-items: center; gap: 6px; }
.brand-logo { height: 26px; width: auto; max-width: 140px; display: block; }
.top-search { flex: 0 1 220px; min-width: 0; }
.top-search input { padding: 6px 10px; font-size: 14px; background: var(--bg); }
.services-line { flex-wrap: wrap; gap: 6px; }
.service-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.service-card .kind { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
.service-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; align-items: start; }
.top-actions { display: flex; align-items: center; gap: 4px; }
.top-actions a { text-decoration: none; color: var(--muted); font-weight: 600; font-size: 15px; padding: 8px 10px; border-radius: 8px; }
.top-actions a.active { color: var(--accent); background: var(--accent-soft); }
.timerbar { background: var(--accent-soft); border-bottom: 1px solid var(--line); }
.timerbar-inner { max-width: 980px; margin: 0 auto; padding: 8px 16px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 14px; }
.timer-label { flex: 1 1 160px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--bad); flex: none; }
@media (prefers-reduced-motion: no-preference) { .dot { animation: pulse 1.6s ease-in-out infinite; } }
@keyframes pulse { 50% { opacity: .3; } }
.big-timer { font-size: 36px; font-family: var(--mono); margin: 0; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--bad); cursor: pointer; text-decoration: underline; }
.check { flex-direction: row; align-items: center; gap: 8px; color: var(--fg); }
.check input { width: auto; }
.check-group { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 0; display: flex; flex-wrap: wrap; gap: 8px 18px; }
.check-group legend { padding: 0 4px; font-size: 14px; color: var(--muted); }
input.narrow { max-width: 90px; }
input[type="color"].color-input { width: 56px; height: 40px; padding: 2px; }
.code-input { font-family: var(--mono); font-size: 22px; letter-spacing: .2em; text-align: center; }
.row select.narrow-select { width: auto; max-width: 100%; flex: 0 1 auto; padding: 6px 8px; font-size: 14px; }
.note-box { background: var(--accent-soft); border-radius: 8px; padding: 10px 12px; margin: 0; }
.warn-text { color: var(--warn); }
p.error { color: var(--bad); background: var(--bad-soft); padding: 10px 12px; border-radius: 8px; margin: 0; }
textarea.mono { font-family: var(--mono); font-size: 13px; white-space: pre; }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; }
.qr { width: 220px; max-width: 100%; aspect-ratio: 1; background: #fff; border-radius: 8px; padding: 6px; margin: 8px 0; }
.qr svg { width: 100%; height: 100%; display: block; }
.secret { display: inline-block; font-size: 16px; letter-spacing: .08em; word-break: break-all; }
.codes { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.codes code { display: block; padding: 8px; text-align: center; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; font-size: 16px; }
.narrow.wrap, .wrap.narrow { max-width: 760px; }
.public-brand { display: flex; justify-content: center; padding: 12px 0 4px; }
.public-logo { height: 40px; width: auto; max-width: 220px; }
.logo-preview { background: var(--bg); border: 1px dashed var(--line); border-radius: 8px; padding: 16px; display: flex; justify-content: center; }
.logo-preview img { max-height: 70px; width: auto; }
table.edit td { padding: 4px 6px; vertical-align: middle; }
table.edit input, table.edit select { padding: 6px 8px; font-size: 14px; }
table.items-table { min-width: 760px; }
td.c, th.c { text-align: center; }
.clause { border-top: 1px solid var(--line); padding-top: 12px; }
.clause:first-of-type { border-top: 0; padding-top: 0; }
.quote-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
@media (max-width: 860px) { .quote-grid { grid-template-columns: minmax(0, 1fr); } }
.quote-grid .summary { position: sticky; top: 72px; }
@media (max-width: 860px) { .quote-grid .summary { position: static; } }
.summary .price { font-size: 40px; font-weight: 700; line-height: 1; }
.summary dl { font-size: 14px; }
.note { background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.quote-item { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.quote-item:first-child { border-top: 0; }
.quote-item input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }
.quote-name { color: var(--fg); font-size: 15px; }
.quote-name small { display: block; color: var(--muted); font-size: 13px; }
.check-fixed { color: var(--accent); font-weight: 700; text-align: center; }
.quote-text { white-space: pre-wrap; font-family: var(--font); font-size: 15px; margin: 0; }
.report-summary { background: var(--accent-soft); border-radius: 8px; padding: 12px 14px; }
@media print {
  .top, .nav, .timerbar, .no-print, .flash, .public-brand ~ .row { display: none !important; }
  body { background: #fff; color: #000; padding: 0; }
  .wrap { max-width: none; padding: 0; }
  .panel { border: 0; padding: 0; }
  .stat { border: 1px solid #ccc; }
}
