/* Logiciel MS · Facturación — tema claro con acentos de marca (cian → azul → violeta) */
:root {
  --bg: #f3f5fb; --surface: #fff; --surface-2: #f7f8fd; --surface-3: #eef1f9;
  --line: #e5e9f3; --line-strong: #d3dae9;
  --text: #0d1933; --text-2: #33405e; --muted: #5a6683; --muted-2: #8791aa;
  --cyan: #17b4cb; --blue: #4a6cf0; --violet: #8b4ff0;
  --accent: #3556d6; --accent-ink: #2443b8; --accent-soft: #e8edff;
  --ok: #0c8f60; --ok-soft: #dff5ea; --warn: #a35f00; --warn-soft: #fff1d6;
  --danger: #c4314b; --danger-soft: #fde7eb; --info: #0b7f93; --info-soft: #e4f6f9;
  --radius: 14px; --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(13, 25, 51, .04), 0 4px 16px rgba(13, 25, 51, .05);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--text); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.08rem; }
h3 { font-size: .95rem; margin-top: 1.4em; color: var(--text-2); }
code, pre { font-family: var(--mono); font-size: .85em; }
pre.code { background: var(--surface-3); padding: 12px 14px; border-radius: var(--radius-sm); overflow-x: auto; white-space: pre-wrap; word-break: break-all; }
.muted { color: var(--muted); }
.small, small { font-size: .82rem; }
.ok { color: var(--ok); } .danger { color: var(--danger); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Layout */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 18px 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none !important; }
.brand strong { display: block; font-size: 1rem; }
.brand small { display: block; color: var(--muted); font-size: .78rem; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: #fff; font-weight: 800; background: linear-gradient(135deg, var(--cyan), var(--blue) 55%, var(--violet)); }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; color: var(--text-2); font-weight: 500; }
.side nav a:hover { background: var(--surface-2); text-decoration: none; }
.side nav a.on { background: var(--accent-soft); color: var(--accent-ink); }
.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; display: flex; justify-content: space-between; align-items: center; font-size: .85rem; color: var(--muted); gap: 8px; }
.main { padding: 28px clamp(16px, 3vw, 40px) 60px; min-width: 0; max-width: 1280px; }
.menu-btn { display: none; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }
.actions, .actions-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; box-shadow: var(--shadow); }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > .table { margin: 0; }
.card.accent { border-color: #c9d4ff; background: linear-gradient(180deg, #f7f9ff, #fff); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
.pad { padding: 16px 20px; }
.card-head.pad { margin: 0; padding-bottom: 6px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 { margin-bottom: 18px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat span { display: block; color: var(--muted); font-size: .82rem; font-weight: 500; }
.stat strong { display: block; font-size: 1.45rem; margin: 4px 0 2px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat small { color: var(--muted); }
.stat.ok strong { color: var(--ok); } .stat.warn strong { color: var(--warn); } .stat.danger strong { color: var(--danger); }
.big-number { font-size: 2.2rem; font-weight: 750; letter-spacing: -.03em; font-variant-numeric: tabular-nums; background: linear-gradient(90deg, var(--blue), var(--violet)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.empty { text-align: center; padding: 48px 20px; background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--muted); }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 11px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
.table th.num, .table td.num { text-align: right; }
.table tbody tr:hover { background: #fafbff; }
.table tfoot td { font-weight: 600; background: var(--surface-2); }
.table.compact th, .table.compact td { padding: 7px 8px; }
.table .strong td { font-weight: 650; }
.table .total td { border-top: 2px solid var(--text); font-size: 1.05rem; }
.table tr.dim { opacity: .55; }
.table tr.sep td { border-top: 2px solid var(--line-strong); }
.table.edit input { width: 100%; }
.card > .table:first-child th:first-child { border-top-left-radius: var(--radius); }

/* Badges & flash */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap; background: var(--surface-3); color: var(--text-2); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.flash { padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; background: var(--info-soft); color: var(--info); font-weight: 500; }
.flash-ok { background: var(--ok-soft); color: var(--ok); }
.flash-error { background: var(--danger-soft); color: var(--danger); }
.flash-warn { background: var(--warn-soft); color: var(--warn); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 15px; border-radius: 10px; border: 1px solid transparent; font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; text-decoration: none !important; white-space: nowrap; line-height: 1.2; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); }
.btn-ghost { background: var(--surface); border-color: var(--line-strong); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger-ghost { background: var(--surface); border-color: #f2c4cd; color: var(--danger); }
.btn-link, .link { background: none; border: 0; color: var(--accent); padding: 4px 2px; cursor: pointer; font: inherit; display: inline-flex; gap: 6px; align-items: center; }
.btn-block { width: 100%; }
form.inline { display: inline; }
.icon-btn { background: none; border: 0; font-size: 1.3rem; color: var(--muted-2); cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.icon-btn:hover { background: var(--danger-soft); color: var(--danger); }

/* Forms */
.form .row, .row { display: flex; gap: 14px; flex-wrap: wrap; }
.row.align-end { align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; min-width: 150px; flex: 1 1 160px; }
.field.grow { flex: 3 1 260px; }
.field label { font-size: .82rem; font-weight: 600; color: var(--text-2); }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; padding: 9px 11px; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid #b7c6ff; border-color: var(--accent); }
input[readonly] { background: var(--surface-2); }
textarea { resize: vertical; }
.help { color: var(--muted); font-size: .8rem; }
.check { display: flex; gap: 8px; align-items: flex-start; margin: 6px 0 14px; cursor: pointer; flex: 1 1 260px; }
.check input { width: auto; margin-top: 4px; }
.check .help { display: block; }
fieldset.sub { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 16px 4px; margin: 6px 0 16px; }
fieldset.sub legend { font-weight: 600; font-size: .88rem; padding: 0 6px; color: var(--text-2); }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.form-actions.sticky { position: sticky; bottom: 0; background: linear-gradient(180deg, rgba(255,255,255,0), #fff 30%); padding: 14px 0 4px; }
.form.narrow { max-width: 760px; }
.out { display: block; padding: 9px 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters input, .filters select { width: auto; flex: 0 1 auto; }
.filters input[type=search] { flex: 1 1 220px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--accent-ink); border-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.copy-row { display: flex; gap: 8px; margin-bottom: 12px; }
.copy-row input { font-family: var(--mono); font-size: .82rem; }
details.pay-tax summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: .85rem; }
details.pay-tax[open] { margin-top: 6px; background: var(--surface-2); padding: 8px 10px; border-radius: 10px; }
.pager { display: flex; gap: 4px; margin: 10px 0; }
.pager a, .pager span { padding: 5px 10px; border-radius: 8px; border: 1px solid var(--line); }
.pager span { background: var(--accent); color: #fff; }

/* Invoice editor */
.items-wrap { overflow-x: auto; margin: 6px 0 10px; }
.items { width: 100%; border-collapse: collapse; min-width: 860px; }
.items th { font-size: .74rem; text-transform: uppercase; color: var(--muted); text-align: left; padding: 6px; }
.items th.num { text-align: right; }
.items td { padding: 5px 4px; vertical-align: top; }
.items td:nth-child(1) { width: 170px; }
.items td:nth-child(3) { width: 78px; }
.items td:nth-child(4), .items td:nth-child(5) { width: 140px; }
.items td:nth-child(6) { width: 86px; }
.items td[data-line] { padding-top: 14px; font-weight: 600; width: 130px; }
.items textarea { min-height: 40px; }
.totals-box { display: flex; justify-content: flex-end; margin: 10px 0 16px; }
.totals-box dl { display: grid; grid-template-columns: auto auto; gap: 6px 28px; margin: 0; min-width: 300px; }
.totals-box dt { color: var(--muted); }
.totals-box dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.totals-box .grand { font-size: 1.2rem; color: var(--text); font-weight: 750; border-top: 1px solid var(--line); padding-top: 6px; }
ol.steps { padding-left: 20px; margin: 0 0 14px; } ol.steps li { margin-bottom: 6px; }
ul.files, ul.log { padding-left: 18px; margin: 0 0 12px; } ul.files li, ul.log li { margin-bottom: 6px; }

/* Deadlines & chart */
.deadlines { list-style: none; padding: 0; margin: 0 0 10px; }
.deadlines li { display: flex; gap: 12px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--line); }
.deadlines li.past { opacity: .5; }
.deadlines.cols { columns: 2; column-gap: 28px; }
.deadlines.cols li { break-inside: avoid; }
.date-chip { background: var(--surface-3); border-radius: 8px; padding: 2px 8px; font-weight: 600; font-size: .82rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.date-chip.hot { background: var(--danger-soft); color: var(--danger); }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .bar-a { fill: var(--blue); } .chart .bar-b { fill: #c4cbe0; }
.chart text { font-size: 11px; fill: var(--muted); }
.legend { display: flex; gap: 8px; align-items: center; font-size: .82rem; color: var(--muted); margin-top: 6px; }
.legend span { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-left: 10px; }
.legend .la { background: var(--blue); } .legend .lb { background: #c4cbe0; }

/* Auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 10% -10%, #e4f6f9, transparent), radial-gradient(900px 500px at 110% 110%, #f0e8ff, transparent), var(--bg); }
.auth-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 28px; box-shadow: 0 10px 40px rgba(13, 25, 51, .08); }
.auth-card .brand { margin-bottom: 22px; }

/* Documento (factura imprimible) */
.doc { background: #fff; color: #111; font-size: 13px; }
.doc-preview { overflow-x: auto; }
.doc-head { display: flex; justify-content: space-between; gap: 24px; border-bottom: 2px solid #111; padding-bottom: 14px; margin-bottom: 14px; }
.doc-head h2 { font-size: 1.05rem; margin: 6px 0 4px; }
.doc-head p { margin: 0; color: #333; font-size: 12px; }
.doc-logo { height: 38px; }
.doc-num { text-align: right; min-width: 220px; }
.doc-num span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #555; }
.doc-num strong { display: block; font-size: 1.5rem; margin-bottom: 6px; }
.doc-num dl { display: grid; grid-template-columns: auto auto; gap: 2px 12px; margin: 0; font-size: 12px; }
.doc-num dt { color: #555; } .doc-num dd { margin: 0; }
.doc-client { background: #f6f7fb; border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; }
.doc-client h3 { margin: 0 0 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #555; }
.doc-client p { margin: 0; }
.doc-items { width: 100%; border-collapse: collapse; }
.doc-items th { background: #111; color: #fff; padding: 7px 8px; font-size: 11px; text-align: left; }
.doc-items th.num { text-align: right; }
.doc-items td { padding: 7px 8px; border-bottom: 1px solid #e3e3e3; vertical-align: top; }
.doc-bottom { display: flex; justify-content: space-between; gap: 24px; margin-top: 14px; }
.doc-notes { flex: 1; font-size: 12px; }
.doc-totals { min-width: 260px; border-collapse: collapse; }
.doc-totals td { padding: 5px 8px; }
.doc-totals .grand td { font-weight: 800; font-size: 1.15rem; border-top: 2px solid #111; }
.doc-totals .soft td { color: #555; font-size: 12px; }
.qr-box { display: flex; gap: 12px; align-items: flex-start; margin-top: 10px; font-size: 11px; }
.qr-box code { word-break: break-all; font-size: 10px; }
.qr { width: 110px; height: 110px; flex: none; }
.qr svg, .qr img { width: 110px; height: 110px; }
.pay { background: #f6f7fb; border-radius: 8px; padding: 8px 10px; margin: 8px 0; }
.pending-dian { color: #a35f00; font-weight: 600; }
.doc-foot { border-top: 1px solid #ddd; margin-top: 18px; padding-top: 8px; font-size: 10.5px; color: #444; }
.doc-foot p { margin: 2px 0; }
.print-body { background: var(--bg); padding: 20px; }
.print-body .doc, .doc-wrap { max-width: 900px; margin: 0 auto; }
.print-body .doc { padding: 36px; border-radius: 12px; box-shadow: var(--shadow); }
.print-bar { max-width: 900px; margin: 0 auto 14px; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.print-status { max-width: 900px; margin: 0 auto 10px; }

/* Portal */
.portal { background: var(--bg); }
.portal .wrap { max-width: 980px; margin: 0 auto; padding: 0 18px; }
.portal-top { background: var(--surface); border-bottom: 1px solid var(--line); margin-bottom: 26px; }
.portal-top .wrap { display: flex; justify-content: space-between; align-items: center; height: 64px; }
.portal-foot { color: var(--muted); font-size: .82rem; padding: 30px 18px; }

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 30; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.15); }
  .nav-open .side { transform: none; }
  .menu-btn { display: inline-block; position: sticky; top: 8px; z-index: 20; margin-bottom: 10px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; padding: 6px 12px; font-size: 1.1rem; cursor: pointer; }
  .grid-2 { grid-template-columns: 1fr; }
  .deadlines.cols { columns: 1; }
  .doc-head, .doc-bottom { flex-direction: column; }
  .doc-num { text-align: left; }
  .table { font-size: .88rem; }
  .card.flush { overflow-x: auto; }
}

@media print {
  @page { size: letter; margin: 12mm; }
  body, .print-body { background: #fff; padding: 0; }
  .no-print, .print-bar, .side, .menu-btn { display: none !important; }
  .print-body .doc { box-shadow: none; padding: 0; max-width: none; }
  a { color: #111; }
}
