/* ERP — fully offline stylesheet (no CDN dependencies, suitable for on-premise) */
:root {
  --sidebar: #14323c;
  --sidebar-ink: #c9d8dc;
  --accent: #2bb3a3;
  --accent-ink: #0c4a44;
  --bg: #f6f8f8;
  --surface: #ffffff;
  --ink: #1d2b30;
  --muted: #6b7d83;
  --line: #e2e9ea;
  --danger: #c0392b;
  --radius: 10px;
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; }
h1 { font-size: 1.5rem; font-weight: 600; margin: 0 0 .25rem; }
.muted { color: var(--muted); margin: 0; }

/* Shell */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex-shrink: 0; background: var(--sidebar); color: var(--sidebar-ink);
  display: flex; flex-direction: column; padding: 1.1rem .9rem;
}
.brand { display: flex; align-items: center; gap: .55rem; padding: .2rem .5rem 1.2rem; }
.brand-mark { color: var(--accent); font-size: 1.1rem; }
.brand-name { font-weight: 700; letter-spacing: .04em; color: #fff; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group {
  margin: .9rem .5rem .25rem; font-size: .68rem; text-transform: uppercase;
  letter-spacing: .12em; color: #7d979e;
}
.nav-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: .5rem .6rem; border-radius: 7px; color: var(--sidebar-ink);
  text-decoration: none; font-size: .9rem;
}
.nav-item.active { background: rgba(43, 179, 163, .18); color: #fff; }
a.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-item.disabled { color: #5f767d; cursor: default; }
.nav-item em {
  font-style: normal; font-size: .62rem; background: rgba(255,255,255,.08);
  padding: .1rem .4rem; border-radius: 99px;
}

/* Topbar */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: .6rem 1.4rem; gap: 1rem;
}
.topbar-right { display: flex; align-items: center; gap: .9rem; }
.company-chip {
  background: #eaf6f4; color: var(--accent-ink); border: 1px solid #cdebe6;
  padding: .3rem .8rem; border-radius: 99px; font-weight: 600;
  font-size: .85rem; text-decoration: none;
}
.user-name { color: var(--muted); font-size: .85rem; }

/* Language switcher */
.lang-form { display: inline-flex; gap: 2px; border: 1px solid var(--line); border-radius: 7px; padding: 2px; }
.lang {
  border: 0; background: transparent; padding: .2rem .55rem; border-radius: 5px;
  font-size: .78rem; color: var(--muted); cursor: pointer;
}
.lang.on { background: var(--sidebar); color: #fff; }

/* Content */
.content { padding: 1.6rem; }
.page-head { margin-bottom: 1.4rem; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; }
.stat-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: .4rem;
}
.stat-label { color: var(--muted); font-size: .8rem; }
.stat-value { font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.notice {
  margin-top: 1.6rem; background: #eaf6f4; border: 1px solid #cdebe6;
  color: var(--accent-ink); border-radius: var(--radius); padding: .8rem 1rem; font-size: .9rem;
}

/* Company selector */
.company-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.company-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem; display: flex; flex-direction: column; gap: .35rem; margin: 0;
}
.company-name { font-weight: 600; }
.company-nit { color: var(--muted); font-size: .85rem; margin-bottom: .6rem; }

/* Buttons & forms */
.btn-primary {
  background: var(--accent); color: #fff; border: 0; border-radius: 7px;
  padding: .55rem 1rem; font-weight: 600; cursor: pointer; font-size: .9rem;
}
.btn-primary:hover { filter: brightness(.94); }
.btn-block { width: 100%; }
.btn-ghost {
  background: transparent; border: 1px solid var(--line); border-radius: 7px;
  padding: .35rem .8rem; color: var(--muted); cursor: pointer; font-size: .82rem;
}
.btn-ghost:hover { color: var(--ink); border-color: var(--muted); }

/* One height for every form control (text, date, number, file, select). */
input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]),
select, textarea {
  width: 100%; height: 38px; padding: .45rem .7rem; border: 1px solid var(--line);
  border-radius: 7px; font-size: .95rem; margin: .25rem 0 .8rem; background: #fff;
  font-family: inherit; box-sizing: border-box; color: var(--ink);
}
textarea { height: auto; min-height: 38px; resize: vertical; }
input[type="file"] { padding: .32rem .5rem; line-height: 1.5; cursor: pointer; }
input[type="file"]::file-selector-button {
  border: 1px solid var(--line); border-radius: 5px; background: #f4f6f6;
  padding: .15rem .7rem; margin-right: .7rem; font: inherit; font-size: .85rem; cursor: pointer;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent;
}
label { font-size: .85rem; font-weight: 600; }
.check { display: flex; align-items: center; gap: .45rem; font-weight: 400; margin-bottom: 1rem; }

.field-error, .validation-summary { color: var(--danger); font-size: .8rem; }
.validation-summary ul { margin: 0 0 .8rem; padding-left: 1.1rem; }

/* Login */
.login-body {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: linear-gradient(160deg, var(--sidebar) 0%, #0d2228 100%);
}
.login-card {
  background: var(--surface); border-radius: 14px; padding: 2.2rem;
  width: min(400px, 92vw); box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
}
.brand-login { padding-bottom: .4rem; }
.brand-login .brand-name { color: var(--ink); }
.login-card h1 { font-size: 1.15rem; margin-bottom: 1.2rem; color: var(--muted); font-weight: 500; }
.lang-login { margin-top: 1.2rem; }

.empty-state { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 2rem; text-align: center; }

@media (max-width: 760px) {
  .sidebar { display: none; }
}

/* ---------- Phase 2: lists, forms, tables ---------- */
.row-between { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.h2 { font-size: 1.15rem; }

.alert { border-radius: var(--radius); padding: .7rem 1rem; margin-bottom: 1rem; font-size: .9rem; }
.alert-ok { background: #eaf6f4; border: 1px solid #cdebe6; color: var(--accent-ink); }
.alert-err { background: #fdf0ee; border: 1px solid #f2cfc9; color: var(--danger); }

.toolbar { display: flex; gap: .6rem; margin-bottom: 1rem; align-items: center; flex-wrap: wrap; }
.toolbar input[type="text"], .toolbar input[type="number"] { width: auto; min-width: 240px; margin: 0; }
.toolbar select { margin: 0; }

.toolbar select, .toolbar input { margin: 0; width: auto; }

table.grid {
  width: 100%; border-collapse: collapse; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
table.grid th {
  text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); padding: .65rem .9rem; border-bottom: 1px solid var(--line); background: #fbfcfc;
}
table.grid td { padding: .6rem .9rem; border-bottom: 1px solid var(--line); font-size: .92rem; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid tr:hover td { background: #fafcfc; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .88rem; }
.empty-row { text-align: center; color: var(--muted); padding: 1.6rem !important; }

.badge { font-size: .72rem; padding: .15rem .55rem; border-radius: 99px; font-weight: 600; }
.badge.ok { background: #eaf6f4; color: var(--accent-ink); }
.badge.off { background: #f1f3f4; color: var(--muted); }
.tag {
  font-size: .72rem; background: #eef4f6; color: #44606a; border-radius: 4px;
  padding: .12rem .45rem; margin-right: .3rem;
}

.actions-cell { white-space: nowrap; text-align: right; }
.actions-cell a { color: var(--accent-ink); font-weight: 600; font-size: .85rem; text-decoration: none; margin-right: .7rem; }
.actions-cell a:hover { text-decoration: underline; }
.actions-cell form { display: inline; }
.btn-link {
  background: none; border: 0; color: var(--muted); font-size: .85rem; cursor: pointer; padding: 0;
}
.btn-link:hover { color: var(--ink); text-decoration: underline; }
.btn-link.danger:hover { color: var(--danger); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.4rem; max-width: 860px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.2rem; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid .checks { display: flex; flex-wrap: wrap; gap: .4rem 1.4rem; align-items: center; padding: .4rem 0 .9rem; }
.form-grid .check { margin: 0; }
.id-row { display: grid; grid-template-columns: 1fr 78px; gap: .7rem; }
.dv-box input { background: #f3f6f6; text-align: center; }
.form-actions { display: flex; gap: .7rem; margin-top: .4rem; }
a.btn-ghost, a.btn-primary { text-decoration: none; display: inline-block; }
a.btn-ghost { padding: .5rem 1rem; font-size: .9rem; }

.pager { display: flex; gap: 1rem; align-items: center; margin-top: 1rem; color: var(--muted); font-size: .88rem; }
.pager a { color: var(--accent-ink); font-weight: 600; text-decoration: none; }
.pager a:hover { text-decoration: underline; }

@media (max-width: 760px) {
  .form-grid { grid-template-columns: 1fr; }
}

/* ---------- Phase 3: facturación ---------- */
.card-wide { max-width: 1180px; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 980px) { .form-grid-3 { grid-template-columns: 1fr; } }

table.lineas td { padding: .35rem .5rem; vertical-align: middle; }
table.lineas input, table.lineas select { margin: 0; padding: .3rem .5rem; height: 32px; font-size: .88rem; }
table.lineas input.num { text-align: right; }
.lineas-foot { display: flex; justify-content: space-between; align-items: center; margin: .8rem 0 1.2rem; flex-wrap: wrap; gap: .8rem; }
.totales-preview { display: flex; gap: 1.4rem; align-items: baseline; font-size: .92rem; color: var(--muted); flex-wrap: wrap; }
.totales-preview strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.totales-preview small { flex-basis: 100%; text-align: right; }

.badge.draft { background: #f1f3f4; color: var(--muted); }
.badge.void { background: #fdf0ee; color: var(--danger); }

.doc-meta { display: flex; gap: 1.6rem; flex-wrap: wrap; margin-bottom: 1rem; color: var(--muted); font-size: .9rem; }
.doc-meta strong { color: var(--ink); font-weight: 600; }

.totales-box {
  margin-top: 1rem; margin-left: auto; width: min(360px, 100%);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1.1rem;
}
.totales-box > div { display: flex; justify-content: space-between; padding: .22rem 0; font-size: .92rem; }
.totales-box strong { font-variant-numeric: tabular-nums; }
.totales-box .grand { border-top: 1px solid var(--line); margin-top: .4rem; padding-top: .55rem; font-size: 1.05rem; }

/* ---------- Confirmation dialog ---------- */
dialog#confirm-dialog {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 1.4rem 1.6rem;
  max-width: 420px; background: var(--surface); color: var(--ink);
  box-shadow: 0 18px 50px rgba(20, 35, 40, .18);
}
dialog#confirm-dialog::backdrop { background: rgba(20, 35, 40, .35); }
dialog#confirm-dialog p { margin: 0 0 1.1rem; font-size: .95rem; line-height: 1.5; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .7rem; }

/* ------------------------------------------------------------ conciliación */
.conciliar-form { display: flex; gap: .5rem; align-items: center; }
.conciliar-form select { flex: 1; min-width: 0; max-width: 420px; font-size: .85rem; }

/* ------------------------------------------------------------ fase 5: reportes */
.report-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.report-card {
  display: block; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.2rem 1.3rem; text-decoration: none; color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.report-card:hover { border-color: var(--accent); box-shadow: 0 6px 18px rgba(0, 0, 0, .06); }
.report-card h2 { font-size: 1.02rem; margin: 0 0 .35rem; color: var(--accent-ink); }
.report-card p { margin: 0; font-size: .87rem; color: var(--muted); }
table.grid tr.total-row td { font-weight: 700; background: #f4f8f7; border-top: 2px solid var(--line); }
.toolbar label { font-size: .85rem; font-weight: 600; }

/* ------------------------------------------------------------ fase 6: dashboard */
.stat-card.stat-warn .stat-value { color: var(--danger); }
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1rem; }
.dash-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; }
.dash-panel h2 { font-size: .95rem; margin: 0 0 .9rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.dash-wide { grid-column: 1 / -1; }
@media (max-width: 980px) { .dash-grid { grid-template-columns: 1fr; } }

.bar-chart { display: flex; align-items: stretch; gap: 6px; height: 190px; }
.bar-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.bar-area { flex: 1; display: flex; align-items: flex-end; }
.bar { width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 0; transition: opacity .15s; }
.bar-col:hover .bar { opacity: .75; }
.bar-label { text-align: center; font-size: .68rem; color: var(--muted); margin-top: .35rem; white-space: nowrap; overflow: hidden; }

.hbar-row { display: grid; grid-template-columns: minmax(90px, 38%) 1fr auto; align-items: center; gap: .6rem; margin-bottom: .55rem; font-size: .87rem; }
.hbar-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { background: #eef2f1; border-radius: 4px; height: 12px; }
.hbar { background: var(--accent); height: 100%; border-radius: 4px; min-width: 2px; }
.hbar-value { font-variant-numeric: tabular-nums; color: var(--muted); }

.aging-stack { display: flex; height: 16px; border-radius: 5px; overflow: hidden; margin-bottom: .8rem; background: #eef2f1; }
.aging-stack .seg { min-width: 3px; }
.seg-ok { background: #1fa588; } .seg-1 { background: #e9c46a; } .seg-2 { background: #f4a261; }
.seg-3 { background: #e76f51; } .seg-4 { background: #c0392b; }
.aging-table { width: 100%; font-size: .87rem; border-collapse: collapse; }
.aging-table td { padding: .25rem 0; }
.aging-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: .5rem; vertical-align: baseline; }
.panel-link { display: inline-block; margin-top: .7rem; font-size: .85rem; }

/* fase 6: puc */
tr.puc-grupo td { background: #f6f9f8; font-weight: 600; }
.btn-ghost.danger, .btn-link.danger { color: var(--danger); }

/* ------------------------------------------------------------ fase 7: seguridad */
.checks-inline { display: flex; flex-wrap: wrap; gap: .3rem 1.4rem; }
.checks-inline .check { margin-bottom: .3rem; }
tr.audit-changed td { background: #fff8ec; }
.audit-val { font-size: .82rem; word-break: break-word; max-width: 340px; }

/* ------------------------------------------------------------ fase 8: landing y suscripciones */
body.landing { background: var(--bg, #f4f6f6); display: block; }
.landing-top { display: flex; justify-content: space-between; align-items: center; padding: 1rem 6vw; background: var(--sidebar); }
.landing-top .brand-name { color: #fff; }
.landing-nav { display: flex; align-items: center; gap: 1.2rem; }
.landing-nav a { color: #d8e4e2; text-decoration: none; font-size: .92rem; }
.landing-nav a.btn-primary, .landing-nav a.btn-ghost { padding: .45rem 1rem; }
.landing-nav a.btn-ghost { border-color: #4a6a66; color: #fff; }
.hero { text-align: center; padding: 5rem 6vw 4rem; background: linear-gradient(160deg, var(--sidebar) 0%, #0d2228 100%); color: #fff; }
.hero h1 { font-size: clamp(1.8rem, 4vw, 3rem); max-width: 820px; margin: 0 auto .9rem; }
.hero p { color: #b9cdca; max-width: 640px; margin: 0 auto 1.6rem; font-size: 1.05rem; }
.hero-cta { display: flex; gap: 1rem; justify-content: center; align-items: center; flex-wrap: wrap; }
.hero-cta .muted { color: #8fa8a4; }
.btn-lg { padding: .8rem 1.8rem; font-size: 1.05rem; }
.features, .pricing { padding: 3.5rem 6vw; max-width: 1180px; margin: 0 auto; }
.features h2, .pricing h2 { text-align: center; margin-bottom: .4rem; }
.pricing > .muted { text-align: center; display: block; margin-bottom: 1.6rem; }
.roadmap-title { margin-top: 3rem; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; margin-top: 1.6rem; }
.feature { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem 1.3rem; }
.feature h3 { margin: 0 0 .4rem; font-size: 1rem; color: var(--accent-ink); }
.feature p { margin: 0; font-size: .88rem; color: var(--muted); }
.feature.soon { border-style: dashed; opacity: .85; }
.feature.soon h3::after { content: " · próximamente"; font-size: .72rem; color: var(--muted); font-weight: 400; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1.2rem; }
.plan-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.6rem 1.5rem; text-align: center; position: relative; display: flex; flex-direction: column; gap: .5rem; }
.plan-destacado { border: 2px solid var(--accent); box-shadow: 0 10px 30px rgba(0,0,0,.07); }
.plan-badge { position: absolute; top: -11px; left: 50%; transform: translateX(-50%); background: var(--accent); color: #fff; font-size: .72rem; padding: .15rem .8rem; border-radius: 99px; }
.plan-precio { font-size: 1.7rem; font-weight: 700; }
.plan-precio span { font-size: .85rem; font-weight: 400; color: var(--muted); }
.plan-anual { font-size: .82rem; color: var(--muted); }
.plan-desc { font-size: .86rem; color: var(--muted); min-height: 2.4em; }
.plan-limites { list-style: none; padding: 0; margin: .4rem 0 .8rem; font-size: .86rem; }
.plan-limites li { padding: .25rem 0; border-bottom: 1px dashed var(--line); }
.landing-foot { display: flex; justify-content: space-between; padding: 1.4rem 6vw; color: var(--muted); font-size: .85rem; }
.registro-card { width: min(680px, 94vw); }
.plan-pick { display: flex; flex-direction: column; gap: .4rem; margin: .3rem 0 .6rem; }
.plan-pick-item { display: flex; align-items: center; gap: .6rem; border: 1px solid var(--line); border-radius: 8px; padding: .55rem .8rem; cursor: pointer; font-size: .92rem; }
.plan-pick-item:has(input:checked) { border-color: var(--accent); background: #f0faf8; }
