/* Cartera App — sistema de diseño inspirado en Quanto (chrome azul marino,
   acento azul, tarjetas blancas redondeadas con pill del KPI). */
:root {
  --navy: #0f1d3a;
  --navy-2: #0b1730;
  --navy-3: #14264a;
  --blue: #2563eb;          /* azul principal de Quanto (links/acento) */
  --blue-cta: #2d5ffe;      /* azul de botón/CTA de Quanto */
  --blue-dark: #1d4ed8;
  --blue-soft: #e8f0ff;
  --page: #eef1f6;
  --card: #ffffff;
  --ink: #1f2a44;
  --muted: #6b7891;
  --line: #e6eaf1;
  --green: #22c07a;
  --cyan: #35bfe0;
  --amber: #f5b433;
  --orange: #f0863c;
  --red: #e0495f;
  --purple: #9b6ef0;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(16, 32, 64, .06), 0 8px 24px rgba(16, 32, 64, .06);
  --sidebar-w: 232px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body { background: var(--page); color: var(--ink); font-size: 14px; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ===== Layout ===== */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; grid-template-rows: 56px 1fr; min-height: 100vh; }
.topbar { grid-column: 1 / 3; background: var(--navy); color: #fff; display: flex; align-items: center; gap: 16px; padding: 0 18px; position: sticky; top: 0; z-index: 30; }
.sidebar { background: var(--navy-2); color: #c7d2e6; padding: 14px 10px; overflow-y: auto; }
.main { padding: 20px 26px 60px; overflow-x: hidden; }

/* ===== Topbar ===== */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: .3px; }
.brand-iso { height: 26px; width: auto; display: block; }
.brand .mark { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, var(--blue), #5b8bff); display: grid; place-items: center; color: #fff; font-size: 16px; }
.topbar .section { display: flex; align-items: center; gap: 8px; font-weight: 600; opacity: .95; padding-left: 6px; }
.topbar .center { margin-left: auto; margin-right: auto; display: flex; align-items: center; gap: 14px; font-weight: 600; opacity: .92; }
.topbar .right { display: flex; align-items: center; gap: 14px; }
.topbar .icon-btn { width: 34px; height: 34px; border-radius: 9px; border: 0; background: rgba(255,255,255,.08); color: #fff; display: grid; place-items: center; font-size: 15px; }
.topbar .icon-btn:hover { background: rgba(255,255,255,.16); }
.pill-date { background: rgba(255,255,255,.10); padding: 5px 10px; border-radius: 8px; font-size: 13px; }

/* ===== Sidebar ===== */
.side-search { width: 100%; background: var(--navy-3); border: 1px solid rgba(255,255,255,.08); color: #dbe4f4; border-radius: 9px; padding: 9px 12px; margin-bottom: 12px; font-size: 13px; }
.side-search::placeholder { color: #8fa0bd; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 9px; color: #c1cde3; cursor: pointer; font-weight: 500; margin-bottom: 2px; }
.nav-item .ic { width: 20px; text-align: center; opacity: .85; font-size: 15px; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--blue); color: #fff; box-shadow: 0 6px 16px rgba(47,107,242,.35); }
.nav-sep { height: 1px; background: rgba(255,255,255,.07); margin: 10px 4px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: #7688a8; padding: 8px 12px 4px; }

/* ===== Toolbar / filtros ===== */
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0; font-weight: 700; }
.page-head .sub { color: var(--muted); font-size: 13px; }
.filters { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 3px; }
.field label { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.field input, .field select { border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; font-size: 13px; background: #fff; color: var(--ink); }
.btn { background: var(--blue-cta); color: #fff; border: 0; border-radius: 9px; padding: 9px 16px; font-weight: 600; font-size: 13px; }
.btn:hover { background: var(--blue-dark); }
.btn.ghost { background: #fff; color: var(--blue); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--blue-soft); }

/* ===== KPI row ===== */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--blue); }
.kpi.green::before { background: var(--green); } .kpi.red::before { background: var(--red); }
.kpi.amber::before { background: var(--amber); } .kpi.cyan::before { background: var(--cyan); }
.kpi .k-label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi .k-value { font-size: 24px; font-weight: 800; margin-top: 6px; letter-spacing: -.5px; }
.kpi .k-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* ===== Cards ===== */
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 1100px) { .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; } }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-head h3 { margin: 0; font-size: 16px; color: var(--blue); font-weight: 700; }
.badge { background: var(--blue); color: #fff; font-weight: 700; font-size: 13px; padding: 4px 12px; border-radius: 8px; }
.badge.green { background: var(--green); } .badge.red { background: var(--red); } .badge.muted { background: #64748b; }
.chart-wrap { position: relative; height: 300px; }
.chart-wrap.tall { height: 360px; }

/* ===== Tabla ===== */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 2px solid var(--line); white-space: nowrap; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data tr:hover td { background: #f8fafd; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tag { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.tag.current { background: #e5f0ff; color: var(--blue-dark); }
.tag.delayed { background: #fff2d8; color: #9a6b00; }
.tag.default { background: #fde2e6; color: #b02233; }
.tag.recover { background: #ece6ff; color: #5b3fb0; }
.tag.complete { background: #e2f6ec; color: #1a8a56; }

/* ===== Login (dos paneles, estilo Quanto) ===== */
.login2 { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
@media (max-width: 820px) { .login2 { grid-template-columns: 1fr; } .login2-brand { display: none; } }
.login2-brand { background: radial-gradient(1000px 700px at 20% 0%, #21386a, var(--navy)); color: #fff; display: grid; place-items: center; padding: 40px; }
.lb-inner { max-width: 380px; }
.lb-logo { display: flex; align-items: center; gap: 14px; font-size: 34px; font-weight: 800; letter-spacing: -.5px; }
.lb-logo img { height: 52px; width: auto; filter: drop-shadow(0 6px 16px rgba(0,0,0,.25)); }
.lb-inner h2 { font-size: 22px; font-weight: 700; margin: 28px 0 10px; line-height: 1.3; }
.lb-inner p { color: #b9c6e0; font-size: 14px; line-height: 1.6; margin: 0; }
.lb-foot { margin-top: 40px; font-size: 13px; color: #8fa0bd; letter-spacing: .06em; text-transform: uppercase; }
.login2-form { background: #fff; display: grid; place-items: center; padding: 40px; }
.login2-card { width: 340px; }
.login2-card h1 { font-size: 24px; margin: 0 0 4px; color: var(--ink); }
.login2-card > p { margin: 0 0 24px; font-size: 13px; }
.login2-card .field { margin-bottom: 16px; }
.login2-card .field input { width: 100%; padding: 11px 13px; font-size: 14px; }
.login2-card .btn { width: 100%; padding: 12px; font-size: 15px; margin-top: 6px; }
.error { color: var(--red); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* ===== Utilidades ===== */
.hidden { display: none !important; }
.muted { color: var(--muted); }
.right { text-align: right; }
.spinner { border: 3px solid var(--line); border-top-color: var(--blue); border-radius: 50%; width: 26px; height: 26px; animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; }
.legend .li { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.legend .sw { width: 12px; height: 12px; border-radius: 3px; }
.dropzone { border: 2px dashed #c4d0e6; border-radius: 12px; padding: 30px; text-align: center; color: var(--muted); background: #fbfcfe; }
.dropzone.drag { border-color: var(--blue); background: var(--blue-soft); }
.file-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; border: 1px solid var(--line); border-radius: 9px; margin-top: 8px; font-size: 13px; }
.ok { color: var(--green); font-weight: 600; } .bad { color: var(--red); font-weight: 600; }

/* ===== Expedientes ===== */
.checklist { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chk { font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 20px; }
.chk.yes { background: #e2f6ec; color: #1a8a56; }
.chk.no { background: #fde2e6; color: #b02233; }
.exp-groups { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 900px) { .exp-groups { grid-template-columns: 1fr; } }
.exp-group { border: 1px solid var(--line); border-radius: 11px; padding: 12px 14px; background: #fbfcfe; }
.exp-group-h { font-weight: 700; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.exp-files { list-style: none; margin: 8px 0 0; padding: 0; }
.exp-files li { font-size: 13px; padding: 4px 0; color: #334; border-bottom: 1px dashed var(--line); }
code { background: #eef1f6; padding: 2px 6px; border-radius: 5px; font-size: 12px; }

/* ===== Filas clicables + modal de contrato ===== */
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--blue-soft); }
.modal-overlay { position: fixed; inset: 0; background: rgba(12, 24, 48, .55); display: none; align-items: flex-start; justify-content: center; z-index: 100; padding: 40px 16px; overflow-y: auto; }
.modal-overlay.show { display: flex; }
.modal { background: #fff; border-radius: 16px; box-shadow: 0 30px 70px rgba(0,0,0,.4); width: 100%; max-width: 780px; padding: 22px 24px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding-bottom: 14px; border-bottom: 2px solid var(--line); margin-bottom: 4px; }
.modal-title { font-size: 20px; font-weight: 800; color: var(--ink); }
.icon-x { border: 0; background: #f0f2f5; width: 32px; height: 32px; border-radius: 8px; font-size: 14px; color: var(--muted); }
.icon-x:hover { background: #e3e7ee; }
.modal-body h4 { color: var(--blue); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; margin: 18px 0 8px; }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 14px 0 4px; }
.stat { border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; }
.stat-l { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.stat-v { font-size: 18px; font-weight: 800; margin-top: 4px; letter-spacing: -.3px; }
.activo-box { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.activo-box > div { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.activo-box span { display: block; font-size: 10px; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.activo-box b { font-size: 13px; }
.hist-scroll { max-height: 260px; overflow: auto; }
.desc-box { border: 1px solid var(--line); border-radius: 10px; padding: 10px 13px; margin-top: 8px; font-size: 13px; color: var(--ink); }
.desc-box span { display: block; font-size: 10px; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-bottom: 3px; letter-spacing: .04em; }
/* Nombre de usuario en el topbar */
.topbar .icon-btn.user-name { width: auto; padding: 0 14px; font-size: 13px; font-weight: 600; gap: 8px; }
/* Datos como texto alineado a la izquierda (no cajitas) */
.info-block { margin: 4px 0 2px; }
.info-block .il { margin: 3px 0; font-size: 13px; color: var(--ink); line-height: 1.5; }
.info-block .il span { color: var(--muted); font-weight: 600; }
tr.total-row td { border-top: 2px solid #cfd8e6; font-weight: 700; background: #f6f9fc; }

/* ===== Responsivo: iPad y celular ===== */
@media (max-width: 1024px) {
  .kpi-row { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
  .grid.cols-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 820px) {
  :root { --sidebar-w: 100%; }
  .app { grid-template-columns: 1fr; grid-template-rows: 52px auto 1fr; }
  .topbar { grid-column: 1; padding: 0 12px; gap: 8px; }
  .topbar .section, .topbar .center { display: none; }
  .brand { font-size: 16px; }
  .sidebar { grid-column: 1; display: flex; flex-direction: row; overflow-x: auto; gap: 6px; padding: 8px 10px; -webkit-overflow-scrolling: touch; }
  .sidebar .nav-label, .sidebar .nav-sep, .side-search { display: none; }
  .nav-item { flex: 0 0 auto; margin: 0; padding: 8px 12px; font-size: 13px; }
  .main { grid-column: 1; padding: 14px 12px 50px; }
  .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: 1fr 1fr; gap: 10px; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .page-head h1 { font-size: 19px; }
  .filters { margin-left: 0; width: 100%; }
  .chart-wrap { height: 260px; }
  .modal-overlay { padding: 12px; }
  .modal { max-width: 100%; padding: 16px; border-radius: 12px; }
  .modal-head { flex-wrap: wrap; }
  .stat-row, .activo-box { grid-template-columns: 1fr 1fr; }
  .kpi .k-value { font-size: 20px; }
}
@media (max-width: 480px) {
  .kpi-row, .stat-row, .activo-box { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 17px; }
  table.data th, table.data td { padding: 8px 9px; font-size: 12px; }
  .modal-title { font-size: 17px; }
}
@media (max-width: 720px) { .stat-row, .activo-box { grid-template-columns: 1fr 1fr; } }
