/* Eventos Ikam — modo claro fijo, móvil primero */
:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1c2430;
  --muted: #62708a;
  --border: #dde3ec;
  --accent: #177a4c;
  --accent-soft: #e5f3ec;
  --danger: #c62828;
  --danger-soft: #fdecea;
  --warn: #b45309;
  --warn-soft: #fef3e2;
  --shadow: 0 1px 3px rgba(28, 36, 48, 0.08);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Barra superior */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-weight: 800; font-size: 17px; color: var(--text); }
.brand span { color: var(--accent); }
.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; }
.topbar nav a {
  padding: 6px 10px; border-radius: 8px; color: var(--text); font-weight: 600; font-size: 14px;
}
.topbar nav a:hover { background: var(--accent-soft); text-decoration: none; }
.topbar nav a.activa { background: var(--accent-soft); color: var(--accent); }
.topbar .quien { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }

.contenido { max-width: 1080px; margin: 0 auto; padding: 16px; }
.contenido.angosto { max-width: 560px; }

h1 { font-size: 22px; margin: 8px 0 14px; }
h2 { font-size: 17px; margin: 22px 0 10px; }
.sub { color: var(--muted); font-size: 13px; }

/* Tarjetas y KPIs */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; box-shadow: var(--shadow);
}
.kpi .k { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.kpi .v { font-size: 22px; font-weight: 900; margin-top: 2px; }
.kpi.bien .v { color: var(--accent); }
.kpi.mal .v { color: var(--danger); }
@media (max-width: 760px) { .kpis { grid-template-columns: repeat(2, 1fr); } }

/* Flash */
.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; font-weight: 600; font-size: 14px; }
.flash.ok { background: var(--accent-soft); color: var(--accent); border: 1px solid #bfe3d0; }
.flash.err { background: var(--danger-soft); color: var(--danger); border: 1px solid #f2c4c0; }

/* Tablas */
table { width: 100%; border-collapse: collapse; background: var(--card); }
.card table { box-shadow: none; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Tabla → tarjetas en móvil (patrón .rcards del PMS) */
@media (max-width: 640px) {
  table.rcards thead { display: none; }
  table.rcards, table.rcards tbody, table.rcards tr, table.rcards td { display: block; width: 100%; }
  table.rcards tr {
    border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px;
    background: var(--card); padding: 6px 0; box-shadow: var(--shadow);
  }
  table.rcards td { border: none; padding: 5px 14px; text-align: left; }
  table.rcards td.num { text-align: left; }
  table.rcards td::before {
    content: attr(data-label);
    display: block; font-size: 11px; color: var(--muted); font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.04em;
  }
  table.rcards td.sin-label::before { display: none; }
}

/* Badges de estado */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700;
}
.st-abierto, .st-aprobado { background: var(--accent-soft); color: var(--accent); }
.st-cerrado { background: #e8ebf0; color: var(--muted); }
.st-reportado { background: var(--warn-soft); color: var(--warn); }
.st-pendiente { background: #e8ebf0; color: var(--muted); }

/* Formularios */
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 15px; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.fila-form { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.fila-form > div { flex: 1; min-width: 130px; }
.form-inline { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.form-inline > div { min-width: 120px; }

.btn {
  display: inline-block; padding: 9px 16px; border: none; border-radius: 8px; cursor: pointer;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 14px; text-decoration: none;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn.sec { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn.peligro { background: var(--danger); }
.btn.chico { padding: 5px 10px; font-size: 13px; }
.btn.grande { width: 100%; padding: 14px; font-size: 16px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.acciones { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.mt { margin-top: 14px; }

/* Reporte del vendedor (móvil) */
.rep-producto {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.rep-producto h3 { margin: 0 0 2px; font-size: 16px; }
.rep-inicial { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.rep-inicial b { color: var(--text); font-size: 15px; }
.rep-campos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.rep-campos input { text-align: center; font-size: 17px; font-weight: 700; }
.rep-resultado { margin-top: 8px; font-size: 13px; color: var(--muted); }
.rep-resultado.ok { color: var(--accent); font-weight: 700; }
.rep-resultado.mal { color: var(--danger); font-weight: 700; }

.rep-resumen {
  position: sticky; bottom: 0; background: var(--card); border-top: 2px solid var(--accent);
  margin: 16px -16px -16px; padding: 12px 16px; box-shadow: 0 -2px 8px rgba(28,36,48,0.08);
}
.rep-resumen .totales { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 8px; flex-wrap: wrap; gap: 6px; }
.rep-resumen .totales b { font-size: 16px; }

/* Grillas de inventario */
.grilla-inv td input { max-width: 110px; }

/* Aviso */
.aviso { background: var(--warn-soft); color: var(--warn); border: 1px solid #f0d9b5; border-radius: 10px; padding: 10px 14px; font-size: 14px; margin-bottom: 14px; }

/* Login */
.login-caja { max-width: 380px; margin: 9vh auto 0; }
.login-caja .card { padding: 26px; }
.login-caja h1 { text-align: center; }

/* Impresión */
@media print {
  .topbar, .no-print, .flash { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: none; padding: 0; }
}

details.plegable { margin-top: 8px; }
details.plegable summary { cursor: pointer; font-weight: 600; color: var(--accent); font-size: 14px; }
.tabla-scroll { overflow-x: auto; }
