/* Sistema de Procura Río — colores de Río Supermarket */
:root {
  color-scheme: light;
  --green: #00782f;
  --green-hover: #00662a;
  --green-dark: #0a4d24;
  --green-deep: #062e16;
  --green-soft: #e8f4ec;
  --green-softer: #f3f9f5;
  --bg: #f4f7f5;
  --card: #ffffff;
  --text: #13261b;
  --muted: #5b6e62;
  --border: #dfe8e2;
  --input: #cfdcd3;
  --red: #c8102e;
  --red-soft: #fdecee;
  --amber: #a85b00;
  --amber-soft: #fff8e6;
  --blue: #1a5fb4;
  --blue-soft: #eaf2fc;
  --purple: #6250d6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 40, 24, .06), 0 4px 16px rgba(16, 40, 24, .05);
  --font: "Segoe UI", "Source Sans 3", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.45; }
a { color: var(--green); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid rgba(0, 120, 47, .35); outline-offset: 2px; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; word-break: break-all; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- Inicio de sesión ---------- */
.login-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px; gap: 40px; }
.brand { display: flex; align-items: center; gap: 16px; }
.brand img { width: 100px; height: 100px; }
.brand b { display: block; font-size: 40px; color: var(--green); font-weight: 800; line-height: 1; }
.brand span { color: var(--green); font-weight: 600; font-size: 17px; }
.login-card { width: 100%; max-width: 480px; background: var(--card); border: 1px solid var(--border); border-radius: 22px; padding: 40px; box-shadow: var(--shadow); }
.eyebrow { color: var(--green); font-weight: 700; font-size: 13px; letter-spacing: .1em; text-transform: uppercase; }
.login-card h1 { font-size: 28px; margin: 10px 0 12px; }
.login-card p.lead { color: var(--muted); margin: 0 0 24px; }

/* ---------- Formularios ---------- */
label.field { display: block; margin-bottom: 16px; }
label.field > span { display: block; font-weight: 600; margin-bottom: 7px; font-size: 14px; }
label.field > small { display: block; color: var(--muted); font-size: 12px; margin-top: 5px; }
/* Campos prellenados por la IA: el usuario debe revisarlos antes de guardar. */
label.field > .ai-filled { border-color: var(--purple); background: #f4f2fd; }
label.field:has(.ai-filled) > span::after { content: " · sugerido por IA"; color: var(--purple); font-weight: 600; font-size: 12px; }
label.field > small.ai-reading { color: var(--purple); font-weight: 600; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=email], input[type=search], select, textarea {
  width: 100%; border: 1px solid var(--input); border-radius: 10px; padding: 11px 13px; background: #fff; min-height: 46px;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--green); outline: 3px solid rgba(0, 120, 47, .15); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 18px; }
@media (max-width: 760px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 10px; padding: 10px 18px; font-weight: 600; cursor: pointer; text-decoration: none; min-height: 42px; white-space: nowrap; }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-hover); }
.btn-block { width: 100%; min-height: 52px; font-size: 17px; border-radius: 12px; }
.btn-outline { background: #fff; border-color: var(--input); color: var(--text); }
.btn-outline:hover { border-color: var(--green); color: var(--green); }
.btn-danger { background: var(--red); color: #fff; }
.btn-ghost { background: transparent; color: var(--green); padding: 6px 10px; min-height: 34px; }
.btn-sm { padding: 6px 12px; min-height: 34px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

.alert { border-radius: 12px; padding: 14px 16px; margin-bottom: 18px; font-size: 14px; }
.alert-warn { background: var(--amber-soft); color: #8a4b00; border: 1px solid #f6e2b3; }
.alert-error { background: var(--red-soft); color: #9b0c22; border: 1px solid #f6c9d0; }
.alert-ok { background: var(--green-soft); color: var(--green-dark); border: 1px solid #c7e3d1; }
.alert-info { background: var(--blue-soft); color: #134a8c; border: 1px solid #cfe0f6; }

/* ---------- Estructura de la aplicación ---------- */
.shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: radial-gradient(500px 300px at 0% 0%, rgba(255, 255, 255, .07), transparent 70%), linear-gradient(180deg, var(--green-deep) 0%, var(--green-dark) 100%); color: #e6f2ea; padding: 20px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side-brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 20px; border-bottom: 1px solid rgba(255, 255, 255, .12); margin-bottom: 14px; }
.side-brand img { width: 46px; height: 46px; }
.side-brand b { display: block; font-size: 20px; color: #fff; }
.side-brand span { font-size: 12px; color: #a9d4b8; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: #d7eadf; text-decoration: none; font-weight: 500; margin-bottom: 2px; }
.nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav a.active { background: #fff; color: var(--green-dark); font-weight: 700; }
.nav .sep { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: #8fbf9f; padding: 16px 12px 6px; }
.nav svg { width: 18px; height: 18px; flex: none; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 28px; background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.topbar .who { display: flex; align-items: center; gap: 12px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--green-soft); color: var(--green-dark); display: grid; place-items: center; font-weight: 700; }
.who b { display: block; font-size: 14px; } .who span { font-size: 12px; color: var(--muted); }
.menu-btn { display: none; }
main { padding: 26px 28px 60px; max-width: 1400px; width: 100%; margin: 0 auto; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 270px; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35); }
  .menu-btn { display: inline-flex; }
  main { padding: 18px 16px 50px; }
  .topbar { padding: 10px 16px; }
  .who .who-text { display: none; }
}

.hero { background: radial-gradient(700px 260px at 100% 0%, rgba(244, 180, 0, .18), transparent 65%), linear-gradient(120deg, var(--green-deep) 0%, var(--green-dark) 55%, var(--green) 100%); color: #fff; border-radius: var(--radius); padding: 26px 28px; margin-bottom: 22px; display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.hero h1 { font-size: 26px; } .hero p { margin: 6px 0 0; color: #cfe8d8; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 26px; } .page-head p { margin: 4px 0 0; color: var(--muted); }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 20px; }
.card h2 { font-size: 18px; margin-bottom: 14px; }
.card h3 { font-size: 15px; margin: 18px 0 10px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; background: #fff; }
.t th { text-align: left; background: var(--green-softer); color: var(--green-dark); font-weight: 600; font-size: 13px; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.t td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.t tr:last-child td { border-bottom: 0; }
.t tr.click { cursor: pointer; } .t tr.click:hover td { background: var(--green-softer); }
.t td.num, .t th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.t tr.win td { background: var(--green-soft); font-weight: 600; }
.t tr.voided td { color: var(--muted); text-decoration: line-through; }
.empty { padding: 30px; text-align: center; color: var(--muted); }

.badge { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st-borrador { background: #eef1ef; color: #4b5a51; }
.st-aprobacion_director { background: var(--amber-soft); color: var(--amber); }
.st-evaluacion { background: var(--blue-soft); color: var(--blue); }
.st-comite { background: #f0edff; color: #4d3dbf; }
.st-orden_emitida { background: var(--green-soft); color: var(--green); }
.st-rechazada { background: var(--red-soft); color: var(--red); }
.st-cancelada { background: #f1f1f1; color: #666; }

/* Etapas del proceso */
.stepper { display: flex; gap: 6px; margin: 4px 0 20px; overflow-x: auto; padding-bottom: 4px; }
.step { flex: 1; min-width: 120px; border-radius: 10px; padding: 10px 12px; background: #fff; border: 1px solid var(--border); font-size: 13px; }
.step b { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.step.done { background: var(--green-soft); border-color: #c7e3d1; }
.step.done b { color: var(--green); }
.step.now { border: 2px solid var(--green); }
.step.now b { color: var(--green); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 11px 14px; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs button.on { color: var(--green); border-bottom-color: var(--green); }

.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px 22px; }
.kv div span { display: block; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kv div b { font-weight: 600; }

.check { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.check:last-child { border-bottom: 0; }
.check .ic { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; flex: none; }
.check.ok .ic { background: var(--green-soft); color: var(--green); }
.check.bad .ic { background: var(--red-soft); color: var(--red); }
.check.warn .ic { background: var(--amber-soft); color: var(--amber); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; border-left: 2px solid var(--border); margin-left: 6px; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--green); border: 2px solid #fff; }
.timeline .when { font-size: 12px; color: var(--muted); }
.timeline .det { font-size: 12px; color: var(--muted); word-break: break-word; }

/* Matriz */
.matrix select { min-height: 36px; padding: 4px 8px; width: 74px; }
.matrix input.cm { min-height: 34px; padding: 4px 8px; font-size: 12px; margin-top: 4px; width: 150px; }
.weight-bar { height: 10px; background: #e7eee9; border-radius: 999px; overflow: hidden; margin: 8px 0 4px; }
.weight-bar i { display: block; height: 100%; background: var(--green); transition: width .2s; }
.weight-bar.over i { background: var(--red); }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(6, 30, 16, .45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50; overflow-y: auto; }
.modal { background: #fff; border-radius: 18px; padding: 26px; width: 100%; max-width: 720px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal h2 { font-size: 20px; margin-bottom: 16px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px; }

.toast { position: fixed; bottom: 20px; right: 20px; background: var(--green-dark); color: #fff; padding: 14px 18px; border-radius: 12px; z-index: 60; box-shadow: var(--shadow); max-width: 420px; }
.toast.err { background: var(--red); }

/* ---------- Tablero estilo Power BI ---------- */
.bi { background: #eef2ef; border-radius: var(--radius); padding: 18px; }
.bi-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; background: linear-gradient(120deg, var(--green-deep), var(--green-dark)); color: #fff; padding: 16px 20px; border-radius: 12px; margin-bottom: 14px; }
.bi-head h1 { font-size: 22px; } .bi-head p { margin: 2px 0 0; color: #bfe0cb; font-size: 13px; }
.slicers { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 12px; align-items: flex-end; }
.slicers label { font-size: 12px; font-weight: 600; color: var(--muted); display: flex; flex-direction: column; gap: 4px; min-width: 160px; flex: 1; }
.slicers select { min-height: 38px; padding: 6px 10px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; border-top: 4px solid var(--green); }
.kpi span { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi b { display: block; font-size: 26px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--muted); font-size: 12px; }
.charts { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 12px; }
.chart { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; grid-column: span 6; min-width: 0; }
.chart.w4 { grid-column: span 4; } .chart.w8 { grid-column: span 8; } .chart.w12 { grid-column: span 12; }
.chart h3 { font-size: 14px; margin: 0 0 2px; } .chart p { margin: 0 0 8px; font-size: 12px; color: var(--muted); }
.chart .canvas { position: relative; height: 260px; }
.chart details { margin-top: 8px; font-size: 13px; } .chart details summary { cursor: pointer; color: var(--green); font-weight: 600; }
@media (max-width: 1000px) { .chart, .chart.w4, .chart.w8 { grid-column: span 12; } }

@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .shell { display: block; } main { padding: 0; }
  body { background: #fff; }
}

/* Ajustes: íconos en botones y ancho en pantallas pequeñas */
.btn svg { width: 18px; height: 18px; flex: none; }
.shell > div { min-width: 0; }
.page-head > div { min-width: 0; }
.page-head h1 { overflow-wrap: anywhere; }
main { overflow-x: clip; }

/* Logo oficial */
.brand img { width: 180px; height: auto; }
.logo-tile { width: 48px; height: 48px; background: #fff; border-radius: 12px; display: grid; place-items: center; flex: none; }
.logo-tile img { width: 42px; height: 42px; object-fit: contain; }
.side-brand { flex-direction: column; align-items: stretch; gap: 10px; }
.logo-card { background: #fff; border-radius: 14px; padding: 10px 12px; display: flex; justify-content: center; }
.logo-card img { width: 130px; height: auto; display: block; }
.side-title { text-align: center; font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: #cfe8d8; }

/* Logo circular */
.logo-round { border-radius: 50%; display: block; }
.brand .logo-round { width: 104px; height: 104px; box-shadow: 0 4px 14px rgba(0, 80, 30, .18); }
.brand b { font-size: 40px; }
.side-brand .side-logo { width: 92px; height: 92px; margin: 0 auto; box-shadow: 0 0 0 3px rgba(255, 255, 255, .25); }

/* Evaluación del solicitante: opciones en palabras completas */
.matrix select.lvl { width: 200px; }
#assess .matrix input.cm { width: 200px; display: block; }
#assess .matrix td.missing { background: var(--amber-soft); box-shadow: inset 3px 0 0 var(--amber); }
#assess .matrix td.missing select.lvl { border-color: var(--amber); }

/* Análisis de IA */
.ai-card { border-left: 5px solid var(--purple); background: linear-gradient(180deg, #faf9ff 0%, #fff 140px); }
.ai-card h2 { color: #4d3dbf; }
.ai-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 10px; }
.ai-sup { font-size: 20px; font-weight: 700; }
.ai-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.ai-sup-card { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; background: #fff; }
.ai-sup-card .ok, .ai-sup-card .warn, .ai-sup-card .bad { display: block; margin-top: 8px; font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.ai-sup-card .ok { color: var(--green); } .ai-sup-card .warn { color: var(--amber); } .ai-sup-card .bad { color: var(--red); }
.spin { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--border); border-top-color: var(--purple); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -1px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
