/* AUDERE CRM — sistema visual (Claude Design). Tokens y componentes con prefijo au-.
   Referencia: docs/design/DESIGN_SPEC.md. Mobile-first: la sidebar es off-canvas hasta 992px. */

:root {
  --au-navy: #17384F;
  --au-muted: #64727D;
  --au-rose: #D98383;
  --au-rose-soft: #E8B9B6;
  --au-rose-bg: #F8E5E5;
  --au-teal: #4FA5A3;
  --au-teal-soft: #9FD0CE;
  --au-teal-bg: #DFF3F2;
  --au-bg: #FAFAF8;
  --au-surface: #fff;
  --au-border: #E8E8E5;
  --au-neutral-bg: #F0F0ED;
  --au-hover: #F1F4F6;
  --au-hover-border: #CFD7DD;
  --au-rose-dark: #C46F6F;
  --au-banner-grad: linear-gradient(100deg, var(--au-rose-bg) 0%, var(--au-rose-bg) 55%, var(--au-rose-soft) 100%);
  --au-login-grad: linear-gradient(135deg, var(--au-rose-bg) 0%, var(--au-bg) 55%, var(--au-teal-bg) 100%);
  --au-pend-fg: #9E4E4E;
  --au-teal-fg: #2F6E6C;
  --au-radius: 14px;
  --au-radius-sm: 10px;
  --au-sidebar-w: 250px;
  --au-font-title: 'Playfair Display', Georgia, serif;
  --au-font-body: 'DM Sans', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body.au-body {
  margin: 0; background: var(--au-bg); color: var(--au-navy);
  font-family: var(--au-font-body); font-size: 14px; line-height: 1.45;
}
.au-body a { color: var(--au-navy); text-decoration: none; }
.au-body a:hover { color: var(--au-navy); text-decoration: underline; text-underline-offset: 3px; }
.au-title { font-family: var(--au-font-title); font-weight: 600; letter-spacing: 0; }

/* ---------- App shell ---------- */
.au-app { display: flex; min-height: 100vh; }
.au-sidebar {
  width: var(--au-sidebar-w); flex: none; background: var(--au-surface); border-right: 1px solid var(--au-border);
  display: flex; flex-direction: column; padding: 16px 14px; gap: 6px; overflow-y: auto;
  position: fixed; inset: 0 auto 0 0; z-index: 1040; transform: translateX(-100%); transition: transform .2s ease;
}
.au-sidebar.is-open { transform: none; box-shadow: 0 8px 24px rgba(23,56,79,.25); }
.au-sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(23,56,79,.35); z-index: 1030; }
.au-sidebar-backdrop.is-open { display: block; }
.au-logo { width: 150px; height: auto; align-self: center; margin: 4px 0 14px; }
.au-nav-item {
  display: flex; align-items: center; gap: 14px; padding: 11px 14px; border-radius: var(--au-radius-sm);
  color: var(--au-navy) !important; font-weight: 400; min-height: 44px;
}
.au-nav-item svg { flex: none; stroke: var(--au-muted); }
.au-nav-item { position: relative; }
.au-nav-item:hover { background: var(--au-hover); text-decoration: none !important; }
.au-nav-item:hover svg { stroke: var(--au-navy); }
.au-nav-item.is-active { background: var(--au-rose-bg); font-weight: 700; }
.au-nav-item.is-active::before { content: ''; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--au-rose); }
.au-nav-item.is-active svg { stroke: var(--au-rose); }
.au-nav-sep { margin-top: 14px; border-top: 1px solid var(--au-border); padding-top: 8px; }
.au-badge-count { margin-left: auto; font-size: 11px; background: var(--au-rose); color: #fff; border-radius: 10px; padding: 1px 7px; }

.au-main { flex: 1; min-width: 0; display: flex; flex-direction: column; margin-left: 0; }
.au-topbar {
  min-height: 68px; display: flex; align-items: center; gap: 12px; padding: 8px 16px;
  background: var(--au-surface); border-bottom: 1px solid var(--au-border); position: sticky; top: 0; z-index: 1020;
}
.au-burger { background: none; border: 0; padding: 8px; border-radius: 8px; color: var(--au-navy); min-width: 44px; min-height: 44px; }
.au-search {
  display: flex; align-items: center; gap: 10px; flex: 1; max-width: 460px; height: 42px;
  border: 1px solid var(--au-border); border-radius: var(--au-radius-sm); padding: 0 14px; background: var(--au-bg);
}
.au-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font: inherit; color: var(--au-navy); }
.au-topbar-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.au-user { display: flex; align-items: center; gap: 10px; }
.au-avatar {
  width: 38px; height: 38px; border-radius: 50%; background: var(--au-navy); color: #fff; flex: none;
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600;
}
.au-user-name { line-height: 1.2; display: none; }
.au-user-name small { display: block; font-size: 12px; color: var(--au-muted); }
.au-user-menu { position: relative; }
.au-user-menu summary { list-style: none; cursor: pointer; }
.au-user-menu summary::-webkit-details-marker { display: none; }
.au-user-pop {
  position: absolute; right: 0; top: 48px; min-width: 200px; background: var(--au-surface);
  border: 1px solid var(--au-border); border-radius: var(--au-radius-sm); box-shadow: 0 8px 24px rgba(23,56,79,.15); padding: 6px; z-index: 1050;
}
.au-user-pop a, .au-user-pop button {
  display: block; width: 100%; text-align: left; padding: 10px 12px; border: 0; background: none; border-radius: 8px;
  color: var(--au-navy); font: inherit; cursor: pointer;
}
.au-user-pop a:hover, .au-user-pop button:hover { background: var(--au-hover); color: var(--au-navy); text-decoration: none; }
.au-content { flex: 1; min-width: 0; padding: 16px; display: flex; flex-direction: column; gap: 22px; }

@media (min-width: 576px) { .au-user-name { display: block; } }
@media (min-width: 992px) {
  .au-sidebar { position: sticky; top: 0; height: 100vh; transform: none; z-index: 1; }
  .au-burger, .au-sidebar-backdrop { display: none !important; }
  .au-topbar { padding: 0 28px; }
  .au-content { padding: 28px; }
}

/* ---------- Cabecera de página ---------- */
.au-page-head { display: flex; align-items: flex-end; gap: 12px 16px; flex-wrap: wrap; }
.au-page-head h1 { font-family: var(--au-font-title); font-size: 26px; font-weight: 700; margin: 0; }
.au-page-head .au-sub { color: var(--au-muted); margin-top: 4px; }
.au-page-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Botones ---------- */
.au-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: var(--au-radius-sm);
  padding: 10px 18px; font: inherit; font-weight: 600; cursor: pointer; min-height: 44px; color: var(--au-navy) !important; text-decoration: none;
}
.au-btn-primary { background: var(--au-rose); }
.au-btn-primary:hover { background: var(--au-rose-dark); text-decoration: none !important; }
.au-btn-teal { background: var(--au-teal); }
.au-btn-teal:hover { background: var(--au-teal-soft); text-decoration: none !important; }
.au-btn-outline { background: #fff; border-color: var(--au-border); }
.au-btn-outline:hover { background: var(--au-hover); border-color: var(--au-hover-border); text-decoration: none !important; }
.au-btn-danger { background: #fff; border-color: var(--au-rose); }
.au-btn-danger:hover { background: var(--au-rose); text-decoration: none !important; }
.au-btn[disabled], .au-btn.disabled { opacity: .55; cursor: not-allowed; }
.au-btn-sm { padding: 6px 12px; min-height: 36px; font-size: 13px; }

/* ---------- Tarjetas / KPI ---------- */
.au-card { background: var(--au-surface); border: 1px solid var(--au-border); border-radius: var(--au-radius); padding: 18px 20px; }
.au-card-title { font-family: var(--au-font-title); font-size: 18px; font-weight: 700; margin: 0 0 12px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.au-card-title a { font-family: var(--au-font-body); font-size: 12px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.au-banner {
  border-radius: 16px; background: var(--au-banner-grad);
  padding: 22px 24px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px;
}
.au-banner h1 { font-family: var(--au-font-title); font-size: 28px; font-weight: 600; margin: 0; }
.au-banner p { color: var(--au-muted); margin: 6px 0 0; font-size: 15px; }
.au-banner .au-fecha { font-size: 12px; color: var(--au-muted); margin-top: 12px; }
.au-lema {
  font-family: var(--au-font-title); font-size: 18px; line-height: 1.35; background: rgba(255,255,255,.55);
  border-radius: var(--au-radius); padding: 14px 24px; text-align: center;
}
.au-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.au-kpi { border-radius: var(--au-radius); padding: 16px; border: 1px solid transparent; display: block; color: var(--au-navy) !important; }
.au-kpi:hover { border-color: var(--au-hover-border); box-shadow: 0 4px 14px rgba(23,56,79,.08); text-decoration: none !important; }
.au-kpi-rose { background: var(--au-rose-bg); }
.au-kpi-teal { background: var(--au-teal-bg); }
.au-kpi-valor { font-family: var(--au-font-title); font-size: 26px; font-weight: 600; line-height: 1.1; }
.au-kpi-sub { margin-top: 10px; padding-top: 8px; border-top: 1px solid rgba(23,56,79,.1); font-size: 12.5px; color: var(--au-muted); }
.au-grid-2 { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); }
.au-grid-3 { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 768px) { .au-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1200px) {
  .au-kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .au-grid-2 { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
  .au-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Gráfica de barras y donut */
.au-chart-box { position: relative; height: 230px; margin-top: 14px; }
.au-donut-wrap { display: flex; align-items: center; gap: 24px; margin-top: 12px; flex-wrap: wrap; }
.au-chart-donut { position: relative; width: 170px; height: 170px; flex: none; }
.au-chart-donut canvas { display: block; }
.au-chart-donut .au-donut-in { display: flex; flex-direction: column; align-items: center; justify-content: center; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 100px; height: 100px; background: transparent; pointer-events: none; text-align: center; line-height: 1.15; }
.au-donut-in b { font-family: var(--au-font-title); font-size: 26px; }
.au-donut-in span { font-size: 12px; color: var(--au-muted); }
.au-legend { display: flex; flex-direction: column; gap: 9px; font-size: 13px; }
.au-legend-item { cursor: pointer; user-select: none; transition: opacity .15s; }
.au-legend-item:hover { opacity: .75; }
.au-legend-item.is-off { opacity: .4; text-decoration: line-through; }
.au-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; }

/* Listas de la home */
.au-list-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--au-border); }
.au-list-row .au-ini { width: 34px; height: 34px; border-radius: 50%; background: var(--au-rose-bg); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; flex: none; }
.au-list-row .au-grow { flex: 1; min-width: 0; }
.au-list-row .au-grow b { font-weight: 500; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.au-list-row small { color: var(--au-muted); font-size: 12px; }
.au-empty { color: var(--au-muted); padding: 14px 0; border-top: 1px solid var(--au-border); }

/* ---------- Badges / chips ---------- */
.au-pill { display: inline-block; font-weight: 700; font-size: 12px; padding: 3px 11px; border-radius: 12px; white-space: nowrap; background: var(--au-neutral-bg); color: var(--au-muted); }
.au-pill-pend { background: var(--au-rose-bg); color: var(--au-pend-fg); }
.au-pill-ok { background: var(--au-teal-bg); color: var(--au-teal-fg); }
.au-pill-err { background: var(--au-rose-soft); color: var(--au-navy); }
.au-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.au-chip {
  padding: 7px 15px; border-radius: 20px; font-size: 13px; font-weight: 500; border: 1px solid var(--au-border); background: #fff; color: var(--au-navy) !important;
  min-height: 36px; display: inline-flex; align-items: center;
}
.au-chip span { opacity: .7; margin-left: 4px; }
.au-chip:hover { background: var(--au-hover); border-color: var(--au-hover-border); text-decoration: none !important; }
.au-chip.is-active:hover { background: var(--au-navy); }
.au-chip.is-active { background: var(--au-navy); border-color: var(--au-navy); color: #fff !important; }

/* ---------- Tablas ---------- */
.au-table-wrap { background: #fff; border: 1px solid var(--au-border); border-radius: var(--au-radius); overflow-x: auto; }
.au-table { width: 100%; border-collapse: collapse; min-width: 640px; }
.au-table th {
  padding: 12px 18px; background: var(--au-bg); border-bottom: 1px solid var(--au-border); font-size: 12px; color: var(--au-muted);
  text-transform: uppercase; letter-spacing: .04em; text-align: left; font-weight: 700; white-space: nowrap;
}
.au-table td { padding: 13px 18px; border-bottom: 1px solid var(--au-border); vertical-align: middle; }
.au-table tbody tr:hover { background: var(--au-hover); }
.au-table tbody tr.au-fila-link { cursor: pointer; }
.au-td-strong { font-weight: 700; color: var(--au-navy); white-space: nowrap; }
.au-table td:first-child { font-weight: 600; }
.au-table tr:last-child td { border-bottom: 0; }

/* ---------- Formularios ---------- */
.au-body .form-control, .au-body .form-select {
  border: 1px solid var(--au-border); border-radius: var(--au-radius-sm); background: var(--au-bg); color: var(--au-navy); min-height: 44px; font: inherit;
}
.au-body .form-control:focus, .au-body .form-select:focus { border-color: var(--au-teal); box-shadow: 0 0 0 3px rgba(79,165,163,.18); background: #fff; }
.au-body .form-label { font-size: 12px; color: var(--au-muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.au-fields { display: grid; gap: 18px 24px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 768px) { .au-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.au-field { border-top: 1px solid var(--au-border); padding-top: 10px; }
.au-field .au-k { font-size: 11px; font-weight: 600; color: var(--au-muted); text-transform: uppercase; letter-spacing: .05em; }
.au-field .au-v { margin-top: 3px; font-size: 14.5px; font-weight: 600; color: var(--au-navy); word-break: break-word; }
.au-field .au-v.is-vacio { font-weight: 500; color: var(--au-muted); }
/* dl de Bootstrap (Cobros/Remesas) con el mismo aspecto que .au-field */
.au-card dl.row > dt { font-size: 11px; font-weight: 600; color: var(--au-muted); text-transform: uppercase; letter-spacing: .05em; padding-top: 12px; border-top: 1px solid var(--au-border); }
.au-card dl.row > dd { font-size: 14.5px; font-weight: 600; color: var(--au-navy); padding-top: 10px; border-top: 1px solid var(--au-border); margin-bottom: 0; word-break: break-word; }
.au-card dl.row > dt:first-of-type, .au-card dl.row > dt:first-of-type + dd { border-top: 0; }
.au-card dl.row .small.text-muted, .au-card dl.row .text-muted { font-weight: 400; }

/* ---------- Mensajes ---------- */
.au-flash { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); z-index: 2000; width: min(92vw, 520px); display: flex; flex-direction: column; gap: 8px; }
.au-flash .alert { margin: 0; border-radius: 12px; box-shadow: 0 8px 24px rgba(23,56,79,.25); border: 0; }
.au-body .alert-success { background: var(--au-navy); color: #fff; }
.au-body .alert-success .btn-close { filter: invert(1); }
.au-body .alert-danger { background: var(--au-rose); color: var(--au-navy); }
.au-body .alert-warning { background: var(--au-rose-bg); color: var(--au-pend-fg); }
.au-body .alert-info { background: var(--au-teal-bg); color: var(--au-teal-fg); }

/* ---------- Login ---------- */
.au-login-bg { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: var(--au-login-grad); }
.au-login-card { width: min(100%, 420px); background: #fff; border: 1px solid var(--au-border); border-radius: 16px; padding: 28px 24px; box-shadow: 0 8px 24px rgba(23,56,79,.08); }
.au-login-card img { display: block; width: 170px; margin: 0 auto 8px; }
.au-login-card h1 { font-family: var(--au-font-title); font-size: 24px; text-align: center; margin: 4px 0 18px; }
.au-lema-login { text-align: center; color: var(--au-muted); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; margin-bottom: 18px; }
.au-text-danger { color: #B24A4A; font-size: 13px; }

/* ---------- Acciones de fila (baja lógica) ---------- */
.au-iconbtn-sm {
  display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0;
  border: 1px solid var(--au-border); border-radius: 8px; background: #fff; color: var(--au-muted); cursor: pointer;
}
.au-iconbtn-sm:hover { background: var(--au-hover); border-color: var(--au-hover-border); color: var(--au-navy); }
.au-iconbtn-sm.is-danger { color: #B24A4A; border-color: var(--au-rose-soft); }
.au-iconbtn-sm.is-danger:hover { background: var(--au-rose-dark); border-color: var(--au-rose-dark); color: #fff; }
.au-iconbtn-sm[disabled] { opacity: .5; cursor: wait; }
.au-table td.au-td-acciones { width: 1%; white-space: nowrap; text-align: right; }
.au-btn-ghost { background: transparent; color: var(--au-muted) !important; border-color: transparent; }
.au-btn-ghost:hover { background: var(--au-hover); text-decoration: none !important; }
@media (max-width: 575.98px) {
  .au-toolbar .au-search, .au-toolbar .filtro-field, .au-toolbar .filtro-date-range { flex: 1 1 100%; max-width: none; width: 100%; }
  .au-toolbar .au-spacer { display: none; }
}

/* ---------- Pestañas de navegación entre vistas ---------- */
.au-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--au-border); flex-wrap: wrap; }
.au-tab { padding: 10px 16px; font-weight: 600; color: var(--au-muted) !important; border-bottom: 2px solid transparent; margin-bottom: -1px; border-radius: 8px 8px 0 0; }
.au-tab:hover { background: var(--au-hover); color: var(--au-navy) !important; text-decoration: none !important; }
.au-tab.is-active { color: var(--au-navy) !important; border-bottom-color: var(--au-rose); }
