/* AR — Panel de gestión. Paleta de marca + tema claro, mobile-first. */

:root {
  /* Marca AR */
  --brand-navy:  #14223f;   /* fondo del isotipo AR */
  --brand:       #2f7df6;   /* azul AR, acento principal */
  --gold:        #a97800;
  --sapphire:    #0172d8;
  --horizon:     #54a5f6;
  --aqua:        #007fa8;
  --pink:        #fc2495;

  /* Tema claro */
  --bg:          #f6f8fc;
  --bg-2:        #eef3fb;
  --bg-3:        #e6edf8;
  --panel:       #ffffff;
  --border:      #dce4f2aa;
  --border-2:    #d8e1ee;
  --txt:         #14223f;
  --txt-dim:     #5d6b83;
  --txt-mute:    #8a96aa;

  /* Estados */
  --ok:          #168a49;
  --warn:        #a86400;
  --danger:      #fc2495;

  --radius:      10px;
  --radius-sm:   8px;
  --shadow:      0 12px 28px -18px rgba(20,34,63,.28);
  --font:        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background:
    radial-gradient(900px 520px at 82% -12%, #dceaff 0%, rgba(220,234,255,0) 58%),
    linear-gradient(180deg, #ffffff 0%, var(--bg) 42%);
  color: var(--txt);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--horizon); text-decoration: none; }
h1,h2,h3 { margin: 0 0 .4em; font-weight: 700; letter-spacing: -.01em; }
small { color: var(--txt-dim); }

/* ----------------------------- Login ---------------------------------- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
}
.login-card {
  width: 100%; max-width: 380px; background: var(--panel);
  border: 1px solid var(--border-2); border-radius: var(--radius);
  padding: 32px 28px; box-shadow: var(--shadow);
}
/* Marca AR (isotipo + nombre) */
.brand-head { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.brand-mark { display: block; border-radius: 22%; box-shadow: 0 6px 18px -10px rgba(20,34,63,.55); flex: none; }
.brand-name { font-weight: 800; font-size: 22px; letter-spacing: .02em; color: var(--txt); line-height: 1; }
.login-card .brand-name { font-size: 30px; }
.login-card .brand-mark { width: 64px; height: 64px; }

/* ----------------------------- Layout --------------------------------- */
.app { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, #ffffff, #f3f7fc);
  border-right: 1px solid var(--border-2); padding: 20px 14px;
  display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand-head { padding: 4px 8px 14px; margin-bottom: 8px; }
.sidebar .brand-mark { width: 34px; height: 34px; }
.sidebar .brand-head small { display: block; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: var(--radius-sm); color: var(--txt-dim); font-weight: 500;
  cursor: pointer; transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--bg-3); color: var(--txt); }
.nav-link.active { background: #eaf2ff; color: var(--txt); box-shadow: inset 3px 0 0 var(--brand); }
.nav-link .ico { width: 20px; text-align: center; }
.nav-link span.txt-mobile { display: none; }   /* solo visible en móvil */
.sidebar .spacer { flex: 1; }

.main { padding: 26px 30px 60px; max-width: 1200px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; gap: 12px; }
.topbar h1 { font-size: 24px; margin: 0; }
.section-head h2 { margin: 0; }

/* --------------------------- Componentes ------------------------------ */
.card {
  background: var(--panel); border: 1px solid var(--border-2);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

.kpi { display: flex; flex-direction: column; gap: 4px; }
.kpi .label { color: var(--txt-dim); font-size: 13px; }
.kpi .value { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.kpi .value.gold { color: var(--horizon); }
.kpi .value.aqua { color: var(--aqua); }
.kpi .value.pink { color: var(--pink); }

/* Botones */
.btn {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  border: 1px solid var(--border-2); background: var(--bg-3); color: var(--txt);
  padding: 9px 15px; border-radius: var(--radius-sm); font-weight: 600; font-size: 14px;
  font-family: inherit; transition: transform .08s, filter .15s, background .15s;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); color: #fff; border-color: transparent; }
.btn.sapphire { background: var(--sapphire); color: #fff; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.danger { background: transparent; color: var(--pink); border-color: #fc249555; }
.btn.sm { padding: 6px 10px; font-size: 13px; }

/* Acciones rápidas flotantes */
.quick-actions {
  position: fixed; right: 22px; bottom: 22px; z-index: 80;
  display: grid; justify-items: end; gap: 10px; pointer-events: none;
}
.quick-main {
  width: 62px; height: 62px; border-radius: 18px; border: 0; padding: 0;
  background: transparent; color: #fff; line-height: 1;
  box-shadow: 0 18px 38px -18px rgba(20,34,63,.75); cursor: pointer;
  pointer-events: auto; transition: transform .18s ease, filter .18s ease;
}
.quick-main img { width: 62px; height: 62px; display: block; border-radius: 18px; }
.quick-main:hover { filter: brightness(1.05); transform: translateY(-1px) scale(1.02); }
.quick-main:active { transform: translateY(1px) scale(.98); }
.quick-menu {
  display: grid; gap: 10px; width: min(360px, calc(100vw - 28px));
  max-height: calc(100dvh - 112px); overflow-y: auto; overscroll-behavior: contain;
  padding: 12px; border: 1px solid rgba(216,225,238,.74); border-radius: 18px;
  background: rgba(255,255,255,.78); box-shadow: 0 24px 60px -28px rgba(20,34,63,.42);
  backdrop-filter: blur(18px) saturate(1.35); -webkit-backdrop-filter: blur(18px) saturate(1.35);
  opacity: 0; pointer-events: none; transform: translate(14px, 18px) scale(.72);
  transform-origin: calc(100% - 28px) calc(100% + 28px);
  transition: opacity .18s ease, transform .24s cubic-bezier(.2, .9, .2, 1.16);
}
.quick-actions.open .quick-menu { opacity: 1; pointer-events: auto; transform: translate(0, 0) scale(1); }
.quick-menu button, .quick-tile {
  border: 1px solid var(--border-2); background: var(--bg-3); color: var(--txt);
  border-radius: var(--radius-sm); padding: 10px 12px; font: inherit; font-weight: 700; cursor: pointer;
}
.dock-section { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.dock-section > span {
  grid-column: 1 / -1; color: var(--txt-dim); font-size: 11px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .08em; padding: 0 2px;
}
.dock-actions { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.dock-actions button { padding-inline: 8px; }

/* Tablas */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border-2); }
th { color: var(--txt-dim); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--bg-3); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Badges de estado */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--bg-3); color: var(--txt-dim); border: 1px solid var(--border-2);
}
.badge.tentativo  { color: var(--horizon); border-color: #54a5f655; }
.badge.confirmado { color: var(--aqua);    border-color: #01d0f855; }
.badge.completado { color: var(--ok);      border-color: #2ecc7155; }
.badge.cancelado  { color: var(--txt-mute); }
.badge.ok       { color: var(--ok); border-color:#2ecc7155; }
.badge.revisar  { color: var(--warn); border-color:#f5a62355; }
.badge.averiado { color: var(--pink); border-color:#fc249555; }

/* Centro operativo */
.command-center {
  display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, .9fr);
  gap: 16px; margin-bottom: 16px;
}
.command-main, .command-side {
  border: 1px solid var(--border-2); border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(47,125,246,.12), rgba(1,208,248,.08) 45%, var(--panel));
  box-shadow: var(--shadow);
}
.command-main { padding: 20px; display: flex; flex-direction: column; justify-content: space-between; min-height: 210px; }
.command-main h2 { font-size: 25px; margin-bottom: 8px; }
.command-main p { color: var(--txt-dim); margin: 0; max-width: 58ch; line-height: 1.45; }
.eyebrow { color: var(--aqua); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; font-weight: 800; }
.command-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.command-side { padding: 14px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; align-content: start; }
.mini-metric {
  background: rgba(255,255,255,.7); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px; min-width: 0;
}
.mini-metric span, .mini-metric small { display: block; color: var(--txt-dim); font-size: 12px; }
.mini-metric strong { display: block; font-size: 19px; margin: 3px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quick-grid { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }

.workflow-strip {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 0 0 16px;
}
.workflow-step {
  display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto;
  gap: 8px 10px; align-items: start;
  padding: 13px; border: 1px solid var(--border-2); border-radius: var(--radius);
  background: rgba(255,255,255,.78); box-shadow: var(--shadow); cursor: pointer;
}
.workflow-step:hover { border-color: #aac8f6; }
.workflow-step .step-num {
  width: 28px; height: 28px; display: grid; place-items: center;
  border-radius: 50%; background: #eaf2ff; color: var(--brand); font-weight: 800; font-size: 13px;
}
.workflow-step h3 { margin: 0; font-size: 15px; }
.workflow-step p { margin: 2px 0 0; color: var(--txt-dim); font-size: 13px; line-height: 1.35; }
.workflow-step .btn { grid-column: 1 / -1; justify-content: center; }

/* Formularios */
label.field { display: block; margin-bottom: 13px; }
label.field > span { display: block; font-size: 13px; color: var(--txt-dim); margin-bottom: 5px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-2); background: var(--bg); color: var(--txt);
  font-family: inherit; font-size: 14px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--horizon); }
textarea { resize: vertical; min-height: 70px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.list-toolbar {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 320px);
  align-items: center; gap: 12px; margin-bottom: 16px;
}
.filter-stack { display: grid; gap: 8px; min-width: 0; }
.segmented {
  display: flex; gap: 4px; padding: 4px; border: 1px solid var(--border-2);
  background: var(--bg-2); border-radius: var(--radius); overflow-x: auto;
}
.segmented button {
  border: 0; background: transparent; color: var(--txt-dim); border-radius: var(--radius-sm);
  padding: 8px 11px; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.segmented button.active { background: var(--bg-3); color: var(--txt); }
.searchbox input { height: 40px; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20,34,63,.28); backdrop-filter: blur(3px);
  display: grid; place-items: center; z-index: 100; padding: 18px;
}
.modal {
  width: 100%; max-width: 560px; max-height: 90vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--border-2);
  border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow);
}
.modal h2 { font-size: 19px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* Toast */
.toast-stack { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast {
  background: var(--bg-3); border: 1px solid var(--border-2); color: var(--txt);
  padding: 12px 16px; border-radius: var(--radius-sm); box-shadow: var(--shadow);
  border-left: 3px solid var(--brand); animation: slidein .2s ease; max-width: 340px;
}
.toast.error { border-left-color: var(--pink); }
.toast.ok { border-left-color: var(--ok); }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Kanban pipeline */
.kanban { display: grid; grid-template-columns: repeat(6, minmax(180px,1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.kanban-col { background: var(--bg-2); border: 1px solid var(--border-2); border-radius: var(--radius); padding: 10px; min-height: 120px; }
.kanban-col h3 { font-size: 12px; text-transform: uppercase; color: var(--txt-dim); letter-spacing: .05em; display:flex; justify-content:space-between; }
.lead-card { background: var(--panel); border: 1px solid var(--border-2); border-radius: var(--radius-sm); padding: 10px; margin-top: 8px; cursor: grab; }
.lead-card:hover { border-color: var(--horizon); }
.lead-card.vencido { border-left: 3px solid var(--pink); }
.lead-card .titulo { font-weight: 600; font-size: 14px; }
.lead-card .meta { font-size: 12px; color: var(--txt-dim); margin-top: 4px; }
.lead-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.lead-actions .btn { flex: 1; justify-content: center; min-width: 70px; }
.pipeline-focus { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 14px; }
.focus-item {
  background: var(--panel); border: 1px solid var(--border-2); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow);
}
.focus-item.hot { border-color: #fc249588; }
.focus-item span, .focus-item small { display: block; color: var(--txt-dim); font-size: 12px; }
.focus-item strong { display: block; font-size: 24px; margin: 3px 0; }

/* Cards de agenda */
.mobile-list { display: none; }
.event-list { display: grid; gap: 10px; }
.event-list.compact { margin-top: 12px; }
.event-card {
  display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 12px; border: 1px solid var(--border-2); border-radius: var(--radius);
  background: var(--bg-2);
}
.event-card h3 { font-size: 15px; margin: 0; overflow-wrap: anywhere; }
.event-card p { margin: 5px 0 0; font-size: 13px; }
.date-chip {
  width: 48px; height: 52px; border-radius: var(--radius-sm); display: grid; place-items: center;
  background: var(--bg-3); border: 1px solid var(--border-2);
}
.date-chip strong { font-size: 18px; line-height: 1; }
.date-chip span { font-size: 11px; color: var(--txt-dim); margin-top: -8px; }
.event-price { white-space: nowrap; color: var(--gold); }
.event-card-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }

/* Cards móviles genéricas para recursos que en escritorio usan tabla. */
.resource-list { gap: 10px; }
.resource-card {
  display: grid; gap: 12px; padding: 13px;
  border: 1px solid var(--border-2); border-radius: var(--radius);
  background: var(--panel); box-shadow: var(--shadow);
}
.resource-card h3 { margin: 0; font-size: 15px; overflow-wrap: anywhere; }
.resource-card p { margin: 6px 0 0; font-size: 13px; }
.resource-main { min-width: 0; }
.resource-meta {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px;
}
.resource-meta span {
  display: inline-flex; align-items: center; min-height: 28px;
  padding: 5px 8px; border-radius: 999px;
  background: var(--bg-2); color: var(--txt-dim); font-size: 12px; font-weight: 700;
}
.card-actions {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap;
}
.card-actions .btn { justify-content: center; }

/* Calendario mini */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .dow { font-size: 11px; color: var(--txt-mute); text-align: center; padding: 4px 0; }
.cal .day { aspect-ratio: 1; display: grid; place-items: center; border-radius: 8px; font-size: 13px; background: var(--bg-2); color: var(--txt-dim); }
.cal .day.busy { background: var(--sapphire); color: #fff; font-weight: 700; }
.cal .day.empty { background: transparent; }
.cal .day.today { outline: 2px solid var(--brand); }

/* Barras estacionalidad */
.bars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; align-items: end; height: 130px; }
.bars .bar { background: linear-gradient(180deg, var(--aqua), var(--sapphire)); border-radius: 5px 5px 0 0; min-height: 3px; position: relative; }
.bars .bar span { position: absolute; bottom: -18px; left: 0; right: 0; text-align: center; font-size: 10px; color: var(--txt-mute); }

.muted { color: var(--txt-dim); }
.right { text-align: right; }
.flex { display: flex; align-items: center; gap: 10px; }
.flex.between { justify-content: space-between; }
.mt { margin-top: 16px; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--txt-dim); }
.spinner { width: 26px; height: 26px; border: 3px solid var(--border-2); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; margin: 30px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Las tablas nunca se aplastan: scroll horizontal solo en tarjetas con tabla. */
.card:has(> table) { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 820px) { .card:has(> table) > table { min-width: 480px; } }

/* --------------------------- Responsive (móvil) ------------------------- */
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }

  /* En móvil la navegación vive en el AR dock flotante. */
  .sidebar {
    display: none;
  }

  .main {
    width: 100%; max-width: none;
    padding: calc(14px + env(safe-area-inset-top)) 12px calc(112px + env(safe-area-inset-bottom));
  }
  .topbar { flex-wrap: wrap; }
  .topbar h1 { font-size: 24px; }
  .topbar small { display: none; }
  .topbar .btn { flex: 1; justify-content: center; }
  .topbar > .flex { width: 100%; }
  .topbar > .flex .btn { flex: 1; }

  .quick-actions { right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); }
  .quick-main, .quick-main img { width: 64px; height: 64px; border-radius: 19px; }
  .quick-menu { width: calc(100vw - 24px); }

  .command-center { grid-template-columns: 1fr; }
  .command-main { min-height: 0; padding: 16px; }
  .command-main h2 { font-size: 21px; line-height: 1.15; }
  .command-side { grid-template-columns: 1fr 1fr; overflow: visible; }
  .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workflow-strip {
    grid-template-columns: 1fr; overflow: visible; padding: 0;
  }
  .workflow-step { min-width: 0; }

  .list-toolbar { grid-template-columns: 1fr; }
  .filter-stack { gap: 7px; }
  .segmented { margin-inline: -2px; }
  .searchbox input { height: 44px; }

  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .grid.cols-4 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card { padding: 14px; }
  .kpi .value { font-size: 22px; }
  .row-2 { grid-template-columns: 1fr; }

  .table-card { display: none; }
  .mobile-list { display: grid; }
  .resource-card { grid-template-columns: 1fr; }
  .card-actions { justify-content: stretch; }
  .card-actions .btn, .card-actions a.btn { flex: 1; min-width: 92px; }
  .event-card {
    grid-template-columns: 48px minmax(0, 1fr); align-items: start;
    padding: 12px; min-height: 76px;
  }
  .event-list.compact .event-card { grid-template-columns: 48px minmax(0, 1fr); }
  .event-list.compact .event-price { grid-column: 2; justify-self: start; margin-top: -6px; }
  .event-card .badge { flex: none; }
  .event-card-main .flex.between { align-items: flex-start; gap: 8px; }

  .kanban {
    grid-auto-flow: column; grid-auto-columns: minmax(260px, 86vw);
    grid-template-columns: none; scroll-snap-type: x mandatory;
    margin-inline: -12px; padding-inline: 12px;
  }
  .kanban-col { scroll-snap-align: start; }
  .pipeline-focus {
    grid-auto-flow: column; grid-auto-columns: minmax(150px, 52vw);
    grid-template-columns: none; overflow-x: auto; padding-bottom: 4px;
    scroll-snap-type: x mandatory;
  }
  .focus-item { scroll-snap-align: start; }

  /* Modales como hoja inferior (bottom sheet), más cómodos con el pulgar. */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal {
    max-width: 100%; max-height: 92vh; border-radius: 18px 18px 0 0;
    padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
    animation: sheetup .22s ease;
  }
  .modal-actions { position: sticky; bottom: 0; background: var(--panel); padding-top: 12px; }
  .modal-actions .btn { flex: 1; justify-content: center; padding: 12px; }

  /* Objetivos táctiles más generosos. */
  .btn { padding: 11px 16px; }
  .btn.sm { padding: 9px 12px; }
  input, select, textarea { font-size: 16px; } /* evita el zoom de iOS al enfocar */
}

@keyframes sheetup { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }

/* Teléfonos estrechos: KPIs en una sola columna. */
@media (max-width: 460px) {
  .grid.cols-4 { grid-template-columns: 1fr; }
  .command-side { grid-template-columns: 1fr; }
  .quick-grid { grid-template-columns: repeat(2, 1fr); }
  .dock-section, .dock-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lead-actions .btn { min-width: 0; }
  .mini-metric strong { font-size: 17px; }
}
