/* Software contable GLODCOM S.A.S. — colores tomados del logo */
:root {
  --azul: #0b63b6;
  --azul-osc: #083f75;
  --azul-claro: #0a9fe0;
  --azul-suave: #e8f2fc;
  --rojo: #e31e24;
  --rojo-suave: #fde9ea;
  --verde: #12805c;
  --verde-suave: #e3f5ee;
  --naranja: #b85c00;
  --naranja-suave: #fff1e0;
  --tinta: #1b1f24;
  --texto: #2f3640;
  --muted: #6b7480;
  --borde: #dfe4ea;
  --fondo: #f3f6f9;
  --blanco: #fff;
  --radio: 10px;
  --sombra: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 15px;
  color: var(--texto);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--fondo); }
h1, h2, h3 { color: var(--tinta); margin: 0; }
a { color: var(--azul); }
code { background: var(--azul-suave); padding: 1px 5px; border-radius: 4px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 16px; }

/* ---------- Botones y formularios ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--borde); background: var(--blanco); color: var(--texto);
  padding: 9px 16px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none; transition: background .15s, border-color .15s;
}
.btn:hover { border-color: #b9c3cf; background: #f8fafc; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--azul); border-color: var(--azul); color: #fff; }
.btn.primary:hover { background: var(--azul-osc); }
.btn.danger { background: var(--rojo); border-color: var(--rojo); color: #fff; }
.btn.green { background: var(--verde); border-color: var(--verde); color: #fff; }
.btn.red { background: var(--rojo); border-color: var(--rojo); color: #fff; }
.btn.orange { background: var(--naranja); border-color: var(--naranja); color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn.big { padding: 14px 20px; font-size: 16px; }
.icon-btn { border: 0; background: transparent; font-size: 20px; cursor: pointer; color: var(--muted); padding: 4px 8px; border-radius: 6px; }
.icon-btn:hover { background: var(--fondo); }
.link-btn { border: 0; background: none; color: var(--azul); cursor: pointer; font: inherit; padding: 2px 4px; }
.link-btn.danger { color: var(--rojo); }

label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--texto); }
input, select, textarea {
  font: inherit; font-weight: 400; padding: 9px 11px; border: 1px solid var(--borde); border-radius: 8px;
  background: #fff; color: var(--tinta); min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--azul-claro); outline-offset: -1px; border-color: var(--azul-claro); }
textarea { resize: vertical; min-height: 70px; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
label.check input { width: 18px; height: 18px; }
.form { display: flex; flex-direction: column; gap: 14px; }
.row-2, .row-3 { display: grid; gap: 14px; }
.row-2 { grid-template-columns: 1fr 1fr; }
.row-3 { grid-template-columns: 1fr 1fr 1fr; }
.hint { font-size: 12px; font-weight: 400; color: var(--muted); }
fieldset { border: 1px solid var(--borde); border-radius: var(--radio); padding: 14px; display: flex; flex-direction: column; gap: 12px; margin: 0; }
legend { font-weight: 700; color: var(--azul-osc); padding: 0 6px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

/* Selector grande de opciones (forma de pago) */
.segmented { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
  border: 2px solid var(--borde); border-radius: 10px; padding: 10px; text-align: center; cursor: pointer;
  font-weight: 600; align-items: center; gap: 2px; background: #fff;
}
.segmented label small { font-weight: 400; color: var(--muted); font-size: 11px; }
.segmented input:checked + span { color: var(--azul); }
.segmented label:has(input:checked) { border-color: var(--azul); background: var(--azul-suave); }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--azul-claro); }

.alert { padding: 11px 14px; border-radius: 8px; background: var(--azul-suave); color: var(--azul-osc); font-size: 14px; }
.alert.error { background: var(--rojo-suave); color: #9b1116; }
.alert.ok { background: var(--verde-suave); color: #0b5c41; }

/* ---------- Ingreso e instalador ---------- */
.login, body.instalador {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: linear-gradient(160deg, var(--azul-osc) 0%, var(--azul) 55%, var(--azul-claro) 100%);
}
.login-card, .install-card {
  background: #fff; border-radius: 16px; padding: 32px; width: 100%; max-width: 400px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .25); display: flex; flex-direction: column; gap: 14px; text-align: center;
}
.install-card { max-width: 620px; text-align: left; }
.install-card h1 { text-align: center; }
.login-card label { text-align: left; }
.login-logo { width: 190px; max-height: 160px; object-fit: contain; margin: 0 auto 4px; }
.login-card h1, .install-card h1 { font-size: 22px; }

/* ---------- Estructura ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 250px; flex-shrink: 0; background: #fff; border-right: 1px solid var(--borde);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { padding: 18px 20px 14px; border-bottom: 3px solid var(--rojo); text-align: center; }
.brand img { max-width: 150px; max-height: 110px; object-fit: contain; }
.menu { display: flex; flex-direction: column; padding: 12px 10px; gap: 2px; overflow-y: auto; flex: 1; }
.menu a {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px;
  color: var(--texto); text-decoration: none; font-weight: 500;
}
.menu a:hover { background: var(--fondo); }
.menu a.active { background: var(--azul); color: #fff; }
.menu .ico { width: 22px; text-align: center; }
.sidebar-foot { padding: 12px 20px; font-size: 12px; border-top: 1px solid var(--borde); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 12px 26px; background: #fff;
  border-bottom: 1px solid var(--borde); position: sticky; top: 0; z-index: 5;
}
.topbar h2 { font-size: 20px; flex: 1; }
.user-box { display: flex; align-items: center; gap: 10px; }
.user-info { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.user-info strong { font-size: 14px; }
.menu-toggle { display: none; }
.content { padding: 24px 26px 40px; display: flex; flex-direction: column; gap: 18px; }
.print-header { display: none; }

/* ---------- Componentes ---------- */
.panel { background: #fff; border: 1px solid var(--borde); border-radius: var(--radio); box-shadow: var(--sombra); padding: 18px; }
.panel > h3 { font-size: 16px; margin-bottom: 12px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.toolbar .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filters label { min-width: 140px; }
.filters label.grow { flex: 1; min-width: 200px; }
.welcome { font-size: 22px; font-weight: 700; color: var(--tinta); }
.welcome .muted { font-size: 15px; font-weight: 400; display: block; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.card { background: #fff; border: 1px solid var(--borde); border-radius: var(--radio); padding: 16px 18px; box-shadow: var(--sombra); border-top: 4px solid var(--azul); }
.card .label { font-size: 13px; color: var(--muted); font-weight: 600; }
.card .value { font-size: 24px; font-weight: 700; color: var(--tinta); margin-top: 6px; font-variant-numeric: tabular-nums; }
.card .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.card.green { border-top-color: var(--verde); }
.card.red { border-top-color: var(--rojo); }
.card.orange { border-top-color: var(--naranja); }
.card.sky { border-top-color: var(--azul-claro); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 700; padding: 10px; border-bottom: 2px solid var(--borde); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--borde); vertical-align: top; }
tbody tr:hover { background: #fafcfe; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.anulado td { color: #9aa3ad; text-decoration: line-through; }
tr.anulado td:last-child, tr.anulado td.estado { text-decoration: none; }
tr.total td { font-weight: 700; border-top: 2px solid var(--tinta); background: #f7f9fb; }
tr.grupo td { font-weight: 700; background: var(--azul-suave); color: var(--azul-osc); }
tr.cabecera-asiento td { background: #f7f9fb; font-weight: 600; }
td.indent { padding-left: 28px; }
.empty { text-align: center; padding: 30px 10px; color: var(--muted); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--fondo); color: var(--texto); white-space: nowrap; }
.badge.blue { background: var(--azul-suave); color: var(--azul-osc); }
.badge.green { background: var(--verde-suave); color: var(--verde); }
.badge.red { background: var(--rojo-suave); color: #b3161c; }
.badge.orange { background: var(--naranja-suave); color: var(--naranja); }
.badge.gray { background: #edf0f3; color: #59626d; }

.tabs { display: flex; flex-wrap: wrap; gap: 6px; border-bottom: 1px solid var(--borde); }
.tabs button { border: 0; background: none; padding: 10px 14px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs button.active { color: var(--azul); border-bottom-color: var(--azul); }

.total-box { background: var(--azul-suave); border-radius: 10px; padding: 12px 16px; display: grid; grid-template-columns: 1fr auto; gap: 4px 20px; font-variant-numeric: tabular-nums; }
.total-box .big { font-size: 20px; font-weight: 700; color: var(--azul-osc); }
.retenciones { border: 1px dashed var(--borde); border-radius: 10px; padding: 10px 14px; }
.retenciones summary { cursor: pointer; font-weight: 600; color: var(--azul-osc); font-size: 14px; }
.cuadre { font-weight: 700; }
.cuadre.ok { color: var(--verde); }
.cuadre.no { color: var(--rojo); }
.lineas-table input, .lineas-table select { width: 100%; padding: 7px 8px; }
.lineas-table td { padding: 5px; border-bottom: 0; }

/* Gráfica de barras */
.chart { display: flex; align-items: flex-end; gap: 14px; height: 210px; padding: 10px 4px 0; border-bottom: 1px solid var(--borde); }
.chart .mes { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.chart .bars { flex: 1; display: flex; align-items: flex-end; gap: 4px; width: 100%; justify-content: center; }
.chart .bar { width: 40%; max-width: 26px; border-radius: 5px 5px 0 0; min-height: 2px; }
.chart .bar.ing { background: var(--azul); }
.chart .bar.gas { background: var(--rojo); }
.chart-labels { display: flex; gap: 14px; padding: 6px 4px 0; }
.chart-labels span { flex: 1; text-align: center; font-size: 12px; color: var(--muted); }
.legend { display: flex; gap: 16px; font-size: 13px; margin-top: 10px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* Proyectos */
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.proj { background: #fff; border: 1px solid var(--borde); border-radius: var(--radio); padding: 16px; box-shadow: var(--sombra); display: flex; flex-direction: column; gap: 8px; }
.proj h4 { margin: 0; font-size: 16px; color: var(--tinta); }
.proj .meta { font-size: 13px; color: var(--muted); }
.progress { height: 10px; background: var(--fondo); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--azul); border-radius: 999px; }
.progress > div.over { background: var(--rojo); }
.proj .nums { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; font-size: 13px; }
.proj .nums b { font-variant-numeric: tabular-nums; }

/* Roles */
.roles-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.role-card { border: 1px solid var(--borde); border-radius: var(--radio); padding: 14px; background: #fff; }
.role-card h4 { margin: 0 0 4px; color: var(--azul-osc); }
.role-card ul { margin: 8px 0 0; padding-left: 18px; font-size: 13px; color: var(--texto); }

/* Logo en datos de empresa */
.logo-preview { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.logo-preview img { width: 180px; height: 140px; object-fit: contain; border: 1px dashed var(--borde); border-radius: 10px; padding: 8px; background: #fff; }

/* ---------- Ventana emergente y avisos ---------- */
.modal { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50; overflow-y: auto; }
.modal-card { background: #fff; border-radius: 14px; width: 100%; max-width: 560px; box-shadow: 0 25px 60px rgba(0, 0, 0, .3); }
.modal-card.wide { max-width: 900px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--borde); }
.modal-head h3 { font-size: 18px; }
.modal-body { padding: 20px; }
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--tinta); color: #fff; padding: 12px 18px; border-radius: 10px; box-shadow: var(--sombra); max-width: 380px; font-size: 14px; animation: aparecer .2s ease-out; }
.toast.ok { background: var(--verde); }
.toast.error { background: var(--rojo); }
@keyframes aparecer { from { transform: translateY(10px); opacity: 0; } }
.loading { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- Celular y tablet ---------- */
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 30px rgba(0, 0, 0, .2); }
  .sidebar.open { transform: none; }
  .menu-toggle { display: inline-block; }
  .grid-2, .row-2, .row-3 { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .topbar { padding: 10px 14px; }
  .user-info, #btnClave { display: none; }
}

/* ---------- Impresión de reportes ---------- */
@media print {
  @page { margin: 14mm; }
  body { background: #fff; font-size: 12px; }
  .sidebar, .topbar, .toolbar, .filters, .tabs, .no-print, .toasts, .modal { display: none !important; }
  .content { padding: 0; }
  .panel { border: 0; box-shadow: none; padding: 0; }
  .print-header { display: flex; align-items: center; gap: 16px; border-bottom: 3px solid var(--rojo); padding-bottom: 10px; margin-bottom: 14px; }
  .print-header img { width: 90px; height: 70px; object-fit: contain; }
  .print-title { font-size: 16px; font-weight: 700; margin-top: 4px; }
  table { font-size: 11px; }
  tbody tr:hover { background: none; }
}
