/* styles.css – Minimalista tipo Busuu con grises y tonos crema */
:root{
  --bg: #f7f4ef;        /* crema muy claro */
  --panel: #ffffff;     /* panel blanco */
  --ink: #2b2b2b;       /* texto gris oscuro */
  --muted: #6d6d6d;     /* gris medio */
  --border: #e7e2da;    /* borde crema/gris claro */
  --accent: #2f7d6d;    /* acento sobrio verdoso */
  --accent-2: #a07e5b;  /* crema tostado */
  --hover: #f0ece6;     /* hover suave */
  --danger-ink: #a13a32;        /* rojo oscuro */
  --danger-bg: #ffeceb;         /* rojo muy claro */
  --danger-border: #f1c0bd;     /* borde rojizo claro */
}

*{ box-sizing: border-box; }
html, body{ height:100%; }
body{
  margin:0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
}

/* Grid principal: sidebar estrecha + contenido */
.app-grid{
  display:grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar{
  border-right: 1px solid var(--border);
  background: #fbf9f5;
  display:flex;
  flex-direction: column;
  padding: 16px;
  gap: 16px;
}
.brand{
  display:flex;
  align-items:center;
  gap:10px;
  padding: 6px 4px;
}
.brand .logo{
  width: 10px; height:10px; display:inline-block; border-radius:999px; background: var(--accent);
}

.brand h1{ font-size:16px; margin:0; font-weight:700; }

.nav{ display:flex; flex-direction: column; gap:8px; }

.nav-btn{
  appearance:none; border:1px solid var(--border); background: var(--panel);
  padding:10px 12px; text-align:left; border-radius:10px; cursor:pointer;
  color: var(--ink); font-weight:700;
}
.nav-btn:hover{ background: var(--hover); }
.nav-btn.active{ border-color: var(--accent); color: var(--accent); }

.sidebar-foot{ margin-top:auto; color: var(--muted); }

/* Contenido */
.content{ padding: 24px; display:flex; flex-direction: column; gap: 24px; }
.section{ display:none; }
.section.visible{ display:block; }
.section-head h2{ margin: 0 0 6px; font-size: 20px; }
.section-head .muted{ color: var(--muted); }

.card{ background: var(--panel); border:1px solid var(--border); border-radius:14px; }
.card + .card{ margin-top: 12px; }
.card-body{ padding:16px; }
.row-actions{ display:flex; gap:12px; align-items:center; }
.row-actions + .row-actions{ margin-top: 10px; }
/* Subcabeceras y badges */
.section-subhead{ display:flex; align-items:center; gap:10px; }
.section-subhead h3{ margin:0; font-size:16px; }
.badge{ display:inline-block; padding:2px 8px; border:1px solid var(--border); background:#fffdf9; border-radius:999px; font-size:12px; color: var(--muted); }
.op-actions{ margin-top:8px; }

/* CTAs de reportes */
.cta-grid{ display:grid; grid-template-columns: 1fr 1fr; gap:16px; }
.cta-block{ background: #fffdf9; border:1px solid var(--border); border-radius:12px; padding:16px; }
.cta-block h3{ margin:0 0 6px; font-size:16px; }
.cta-block p{ margin:0 0 12px; }
.btn.block{ width:100%; }
.cta-block .cta-actions{ display:flex; flex-direction:column; gap:10px; }
.historial-row{ display:flex; gap:10px; align-items:flex-end; flex-wrap:wrap; }
.historial-select{ flex:1; min-width: 220px; display:flex; flex-direction:column; gap:6px; }
.historial-select select{ width:100%; }

.grid-2{ display:grid; grid-template-columns: 1fr 1fr; gap:18px; }
@media (max-width: 900px){
  .app-grid{ grid-template-columns: 1fr; }
  .grid-2{ grid-template-columns: 1fr; }
  .cta-grid{ grid-template-columns: 1fr; }
}

/* Controles */
.file-row{ display:flex; gap:10px; align-items:center; }
.upload-stack{ display:flex; flex-direction:column; gap:14px; }
.upload-block{ border:1px solid var(--border); background: var(--panel); border-radius:12px; padding:16px; }
.upload-block.drag-over{ outline: 2px dashed var(--accent); background: #f6fffb; }
.upload-block.loading{ opacity: .8; pointer-events: none; }
.file-input{ display:none; }
.file-btn{ background: var(--accent); color: black; border-color: var(--accent); }
.file-btn:hover{ filter: brightness(.95); }
.file-btn.disabled{ opacity:.6; cursor:not-allowed; pointer-events:none; }
.file-name{ display:inline-flex; align-items:center; gap:8px; color: var(--muted); font-weight:600; }
.file-ico{ font-size:16px; }
.upload-overlay{
  display:none;
  margin-top:12px;
  padding:12px;
  border:1px dashed #d48f00;
  background:#fff4e0;
  color:#8a5a00;
  font-weight:700;
  border-radius:8px;
  text-align:center;
  font-size: 14px;
}
.upload-overlay.active{ display:block; }
.btn{
  appearance:none; border:1px solid var(--border); background: var(--panel);
  padding:8px 12px; border-radius:10px; cursor:pointer; font-weight:600;
}
.btn:hover{ background: var(--hover); }
.btn.primary{ background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.alt{ background:#fff7f0; border-color:#f1e0cf; color:#8c6b45; }
.btn.danger{ background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger-ink); }
.btn.danger:hover{ filter: brightness(.98); }
.btn.disabled{ opacity:.6; cursor:not-allowed; }
.right{ margin-left:auto; }
.muted{ color: var(--muted); }
.info{ margin-top:6px; font-size: 12px; color: var(--muted); }

/* Tabla genérica */
.table-wrap{
  border:1px solid var(--border);
  border-radius: 12px;
  overflow:auto;
  background: var(--panel);
}
table{ width:100%; border-collapse: collapse; }
thead th{
  position: sticky; top: 0;
  background: #fffdf9;
  border-bottom: 1px solid var(--border);
  font-size: 12px; color: var(--muted);
  text-transform: uppercase; letter-spacing:.02em;
}
th, td{ padding:10px 8px; border-bottom:1px solid var(--border); }
tbody tr:hover{ background: #fffaf3; }
.row-revision{ background:#ffa3a3; }
.row-revision:hover{ background:#ffa3a3 !important; }
.row-sugerido-old{ background:#ffa3a3; }
.row-sugerido-old:hover{ background:#ffa3a3 !important; }
/* Forzar fondo en filas especiales aun con zebra striping */
tbody tr.row-revision,
tbody tr.row-revision:nth-child(even),
tbody tr.row-sugerido-old,
tbody tr.row-sugerido-old:nth-child(even){
  background:#ffa3a3 !important;
}

/* Toolbar para tablas */
.toolbar{
  display:flex; flex-wrap:wrap; align-items:center; gap:10px;
  padding: 8px 0;
}

/* Aviso de reglas */
.notice{
  background: #fff8e6;
  border:1px solid #f2e2b8;
  color:#5b4a1f;
  border-radius:10px;
  padding:10px 12px;
}
.notice ul{ margin:6px 0 0; padding-left: 18px; }
.notice li{ margin:2px 0; }

/* Nueva disposición de filtros */
.toolbar-grid{ display:grid; grid-template-columns: 1fr; gap:10px; }
.toolbar-top{ display:flex; justify-content:flex-end; align-items:center; }
.filter-row{
  display:grid;
  grid-template-columns: 1fr 1fr 160px 160px auto;
  gap:10px; align-items:end;
}
.filter-actions{ display:flex; gap:8px; justify-content:flex-end; }
.date-group{ display:flex; flex-direction: column; gap:6px; }
.date-group label{ font-weight:600; font-size:12px; color: var(--muted); }
.actions-row{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; min-width:0; }
.actions-left{ display:flex; gap:8px; overflow-x:auto; white-space:nowrap; -webkit-overflow-scrolling:touch; padding-bottom:6px; min-width:0; margin-left:auto; }
.toolbar-grid{ min-width:0; }
/* Botones compactos solo dentro de toolbars */
.toolbar .btn.sm{ padding:6px 10px; font-size:13px; }

/* Toggles (segmented control) */
.toggles-wrap{ display:flex; align-items:center; gap:8px; }
.toggles{ display:inline-flex; border:1px solid var(--border); border-radius:10px; overflow:hidden; background: var(--panel); }
.toggles .btn.toggle{
  border:0; border-radius:0; background: transparent; color: var(--muted);
}
.toggles .btn.toggle + .btn.toggle{ border-left:1px solid var(--border); }
.toggles .btn.toggle.active{ background: var(--accent); color:#fff; }

/* Filtros más grandes en Elegir Viajes */
.toolbar input[type="text"],
.toolbar input[type="date"]{
  flex: 1 1 280px;
  min-width: 260px;
  height: 40px;
  padding: 10px 12px;
  border:1px solid var(--border);
  border-radius:10px;
  background: var(--panel);
  color: var(--ink);
  font-size: 15px;
}

/* Asegurar mismo alto para fechas dentro de .date-group */
.date-group input[type="date"]{
  flex: 0 0 40px; /* no crecer en vertical */
  height: 40px;
  width: 100%;
  min-width: 0; /* permite compactar a 160px */
}

/* Checkboxes más grandes */
.table-wrap input[type="checkbox"]{
  transform: scale(1.25);
  transform-origin: center;
  accent-color: var(--accent);
  cursor: pointer;
}

/* KPIs destacados */
.kpis{ display:flex; gap:8px; align-items:center; }
.kpis span{ white-space:nowrap; font-weight:700; background:#fff1da; border:1px solid #f1e0cf; color:#5b4a1f; padding:6px 10px; border-radius:999px; }

/* Zebra striping y numéricos a la derecha */
tbody tr:nth-child(even){ background: #fffdf9; }
th.num, td.num, td.money{ text-align:right; font-variant-numeric: tabular-nums; }
td.money{ font-weight:600; }
th.col-icon, td.col-icon{ width:40px; text-align:center; }
th.col-stop, td.col-stop{ width:56px; text-align:center; }
th.col-numpago, td.col-numpago{ width:90px; }
td.col-numpago, th.col-numpago{ text-align: center; }
th.col-estado, td.col-estado{ width: 200px; min-width: 170px; }
th.col-op, td.col-op{ min-width:260px; }
th.col-fecha, td.col-fecha{ min-width:160px; }
th.col-archivo, td.col-archivo{ width:120px; }
.chip{ display:inline-block; min-width:18px; padding:2px 6px; border-radius:999px; font-size:12px; font-weight:700; line-height:1; }
.chip-c{ background:#e6f7f3; color:#1b5f53; border:1px solid #c6e9e1; }
.chip-p{ background:#e7f0ff; color:#134c9e; border:1px solid #c7dafe; }

/* Dashboard de reportes (tabla de circuitos) */
#tablaDashCircuitos th:nth-child(2),
#tablaDashCircuitos td:nth-child(2),
#tablaDashCircuitos th:nth-child(3),
#tablaDashCircuitos td:nth-child(3){
  text-align: center;
}
.dash-total td{
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

@media (max-width: 900px){
  .filter-row{ grid-template-columns: 1fr; }
  .actions-row{ flex-wrap:wrap; }
  .actions-left{ width:100%; }
  .toggles-wrap{ width:100%; }
  .kpis{ width:100%; align-items:flex-start; }
}

/* Join placeholder */
.join-placeholder{
  display:grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px; align-items: end;
}
.join-placeholder .row{ display:flex; flex-direction: column; gap:6px; }
.join-placeholder select{ padding:8px 10px; border:1px solid var(--border); border-radius: 10px; background: var(--panel); color: var(--ink); }
label{ font-weight:600; font-size: 13px; }

/* Estado activo para botones de toggle */
.btn.active{ border-color: var(--accent); color: var(--accent); background: var(--hover); }

/* Modal simple */
.modal{ position: fixed; inset:0; background: rgba(0,0,0,.25); display:none; align-items:center; justify-content:center; padding: 16px; z-index: 1000; }
.modal.open{ display:flex; }
.modal .dialog{ background:#fff; border:1px solid var(--border); border-radius:12px; padding:16px; width: 100%; max-width: 420px; display:flex; flex-direction:column; gap:10px; }
.modal .dialog h3{ margin:0; }
.modal input[type="text"]{ height: 38px; padding: 8px 10px; border:1px solid var(--border); border-radius:10px; }
.dialog-wide{ max-width: 640px; }

.form-grid{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 6px;
}
.form-grid label{
  display:flex;
  flex-direction: column;
  gap:6px;
}
.form-grid input[type="text"],
.form-grid input[type="number"],
.form-grid input[type="date"]{
  height: 38px;
  padding: 8px 10px;
  border:1px solid var(--border);
  border-radius:10px;
  background: var(--panel);
  color: var(--ink);
}
.form-grid input:focus{
  outline:none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47,125,109,.12);
}
.form-grid select{
  height: 38px;
  padding: 8px 10px;
  border:1px solid var(--border);
  border-radius:10px;
  background: var(--panel);
  color: var(--ink);
}
.form-grid select:focus{
  outline:none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47,125,109,.12);
}
.estado-select{
  width: 100%;
  min-width: 140px;
  display:block;
  padding: 5px 10px;
  border:1px solid var(--border);
  border-radius:10px;
  background:#fffdf9;
  color: var(--ink);
  font-weight:600;
  font-size:12.5px;
  letter-spacing:-0.1px;
}
.estado-select:focus{
  outline:none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47,125,109,.12);
}
.cell-editor{
  width: 100%;
  padding: 6px 8px;
  border:1px solid var(--border);
  border-radius:8px;
  font-variant-numeric: tabular-nums;
}
.cell-editor:focus{
  outline:none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47,125,109,.12);
}
.field-hint{
  font-size:12px;
  color: var(--danger-ink);
  font-weight:600;
}

/* Toast */
.toast{ position: fixed; right: 16px; bottom: 16px; background:#2b2b2b; color:#fff; padding:10px 12px; border-radius:10px; opacity:0; transform: translateY(8px); transition: .25s ease; z-index: 1100; pointer-events:none; }
.toast.show{ opacity:1; transform: translateY(0); }

/* Celdas de canónico con icono */
.canon-wrap{ display:flex; align-items:center; gap:8px; }
.map-ico{ font-size:14px; color: var(--accent); }
/* Input de canónico mejorado */
.canon-cell{ min-width: 320px; }
.op-canon{
  width: 100%;
  min-width: 240px;
  height: 34px;
  padding: 6px 10px;
  border:1px solid var(--border);
  border-radius:10px;
}
.op-canon:focus{ outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,125,109,.12); }
.op-merge{
  flex:1;
  min-width: 220px;
  height: 34px;
  padding: 6px 10px;
  border:1px solid var(--border);
  border-radius:10px;
  background: var(--panel);
  color: var(--ink);
}
.op-merge:focus{
  outline:none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47,125,109,.12);
}
.canon-pill{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding: 6px 10px;
  background:#fff7f0;
  color:#8c6b45;
  border:1px solid #f1e0cf;
  border-radius:999px;
  font-weight:700;
  font-size:12px;
}
.merge-btn{ white-space:nowrap; }

/* ---- Login ---- */
.auth-page{
  min-height:100vh;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:24px;
  background: radial-gradient(circle at 20% 20%, #f9f2e7, transparent 40%), radial-gradient(circle at 80% 0%, #f0f7f4, transparent 40%), var(--bg);
}
.auth-card{
  width: min(440px, 96vw);
  background: var(--panel);
  border:1px solid var(--border);
  border-radius:16px;
  padding:24px;
  box-shadow: 0 18px 40px rgba(0,0,0,0.08);
  display:flex;
  flex-direction: column;
  gap: 14px;
}
.auth-brand{
  display:flex;
  align-items:center;
  gap:12px;
}
.auth-logo{
  width:16px;
  height:16px;
  background: var(--accent);
  border-radius:999px;
  box-shadow: 0 0 0 6px #e9f2ee;
}
.auth-brand h1{ margin:0; font-size:22px; }
.auth-kicker{ margin:0; text-transform: uppercase; letter-spacing:.08em; font-size:11px; }
.auth-subtitle{ margin:0; color: var(--muted); }
.auth-form{
  display:flex;
  flex-direction: column;
  gap:12px;
}
.auth-form label{
  display:flex;
  flex-direction: column;
  gap:6px;
  font-weight:700;
}
.auth-form input{
  padding:10px 12px;
  border:1px solid var(--border);
  border-radius:10px;
  background:#fff;
  font-size:14px;
}
.auth-form input:focus{
  outline:2px solid var(--accent);
}
.auth-msg{
  margin:4px 0 0;
  font-size:13px;
}
