/* ============================================================
   Oficina CEVET — Estilo SaaS (inspirado en paneles tipo Clienteli)
   Sidebar clara · cards suaves · acentos teal de marca
   ============================================================ */

:root {
  --brand-navy: #0B2A4A;
  --brand-teal: #0E9F95;
  --brand-teal-soft: #E6FAF7;
  --brand-teal-hover: #0B7F77;
  --brand-gold: #14B8A6;
  --accent: #0E9F95;
  --accent-soft: #E6FAF7;
  --accent-hover: #0B7F77;
  --sidebar-w: 260px;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #e8ecf1;
  --text: #1e293b;
  --text-muted: #64748b;
  --text-soft: #94a3b8;
  --success: #10b981;
  --success-bg: #d1fae5;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.03);
  --shadow-md: 0 4px 20px rgba(15, 23, 42, 0.06);
  --font: 'Inter', system-ui, sans-serif;
  --font-display: 'Poppins', 'Inter', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body.office-body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  line-height: 1.5;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; }
button, input, select, textarea { font-family: inherit; }

/* ---------- SIDEBAR (clara) ---------- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform 0.25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 18px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand img {
  height: 36px;
  width: auto;
}

.sidebar-brand .brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.sidebar-brand .brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--brand-navy);
}

.sidebar-brand .brand-sub {
  font-size: 0.7rem;
  color: var(--text-soft);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.sidebar-nav {
  flex: 1;
  padding: 14px 12px;
  overflow-y: auto;
}

.sidebar-nav .nav-section {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-soft);
  padding: 12px 12px 6px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.9rem;
  margin-bottom: 2px;
  transition: all 0.15s ease;
}

.sidebar-nav a i {
  width: 20px;
  text-align: center;
  font-size: 1rem;
  opacity: 0.85;
}

.sidebar-nav a:hover {
  background: var(--bg);
  color: var(--text);
}

.sidebar-nav a.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.sidebar-nav a.active i {
  opacity: 1;
  color: var(--accent);
}

.sidebar-footer {
  padding: 14px 16px 18px;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.sidebar-user .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
}

.sidebar-user .user-meta {
  flex: 1;
  min-width: 0;
}

.sidebar-user .user-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user .user-role {
  font-size: 0.72rem;
  color: var(--text-soft);
  text-transform: capitalize;
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-logout:hover {
  background: #fef2f2;
  color: var(--danger);
}

/* ---------- MAIN ---------- */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0; /* evita que tablas anchas desborden la página en móvil */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar h1 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
}

.topbar-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--success-bg);
  color: #065f46;
}

.status-pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--text);
  cursor: pointer;
  padding: 6px;
}

.content {
  padding: 24px 28px 40px;
  flex: 1;
}

/* ---------- CARDS / PANELS ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.card + .card { margin-top: 16px; }

.card-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

/* ---------- KPIs ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  box-shadow: var(--shadow);
}

.kpi-card .label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-soft);
  margin-bottom: 6px;
}

.kpi-card .value {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.kpi-card .sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ---------- TABLES ---------- */
.table-wrap {
  overflow-x: auto;
  margin: 0 -4px;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

table.data th {
  text-align: left;
  padding: 10px 12px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-soft);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table.data td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

table.data tr:last-child td {
  border-bottom: none;
}

table.data tr:hover td {
  background: #fafbfc;
}

/* ---------- BADGES ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: capitalize;
}

.badge-cotizacion { background: #e0e7ff; color: #3730a3; }
.badge-solicitado { background: #fef3c7; color: #92400e; }
.badge-aprobado { background: #d1fae5; color: #065f46; }
.badge-enviado { background: #cffafe; color: #0e7490; }
.badge-entregado { background: #dcfce7; color: #166534; }
.badge-cancelado { background: #fee2e2; color: #991b1b; }
.badge-pendiente { background: #fef3c7; color: #92400e; }
.badge-rechazado { background: #fee2e2; color: #991b1b; }
.badge-activo { background: #d1fae5; color: #065f46; }
.badge-inactivo { background: #f1f5f9; color: #64748b; }
/* Semánticos usados en caja, agenda, dashboard */
.badge-success { background: #d1fae5; color: #047857; }
.badge-warning { background: #fef3c7; color: #b45309; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.badge-info { background: #dbeafe; color: #1d4ed8; }
.badge-muted { background: #f1f5f9; color: #64748b; }

/* ---------- BUTTONS ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.875rem;
  padding: 10px 18px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 12px rgba(14, 159, 149, 0.25);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--bg);
  border-color: #cbd5e1;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: none;
  padding: 8px 12px;
}
.btn-ghost:hover { color: var(--text); background: var(--bg); }

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: 8px;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 8px;
}

/* ---------- FORMS ---------- */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 159, 149, 0.12);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.input-inline {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.875rem;
  background: var(--surface);
}

/* ---------- MODAL ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
  backdrop-filter: blur(2px);
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
}

.modal h2 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin-bottom: 18px;
  color: var(--text);
}

/* ---------- EMPTY / LOADING ---------- */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.empty-state i {
  font-size: 2rem;
  color: var(--border);
  margin-bottom: 10px;
  display: block;
}

/* ---------- LOGIN / ACTIVAR ---------- */
body.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #e8f6f8 0%, #f4f6f9 50%, #fff 100%);
  font-family: var(--font);
}

.auth-card {
  background: var(--surface);
  border-radius: 20px;
  box-shadow: 0 8px 40px rgba(11, 42, 74, 0.08);
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  border: 1px solid var(--border);
}

.auth-card .logo {
  height: 52px;
  display: block;
  margin: 0 auto 20px;
}

.auth-card h1 {
  font-family: var(--font-display);
  text-align: center;
  font-size: 1.35rem;
  color: var(--brand-navy);
  margin-bottom: 4px;
}

.auth-card .sub {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 28px;
}

.auth-error {
  background: #fef2f2;
  color: #991b1b;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.85rem;
  margin-bottom: 14px;
  display: none;
}

.auth-info {
  background: var(--accent-soft);
  color: var(--brand-navy);
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 0.88rem;
  margin-bottom: 16px;
}

/* ---------- MAP ---------- */
#map {
  height: 280px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 1024px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: 8px 0 30px rgba(0,0,0,0.1); }
  .main { margin-left: 0; }
  .menu-toggle { display: block; }
  .content { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .form-row { grid-template-columns: 1fr; }
}

/* Overlay cuando sidebar móvil abierta */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.3);
  z-index: 99;
}
.sidebar-backdrop.show { display: block; }

/* Hint de lookup de cliente por teléfono (agenda, caja) */
.lookup-hint {
  font-size: 0.75rem;
  color: var(--success);
  margin-top: 2px;
  display: none;
}

/* Responsive: ninguna vista desborda a 390 px; las tablas se desplazan dentro de su contenedor */
.content { min-width: 0; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
@media (max-width: 600px) { .topbar { flex-wrap: wrap; gap: 8px; } .topbar-right { flex-wrap: wrap; max-width: 100%; } .topbar-right .input-inline { min-width: 0; flex: 1 1 140px; } [role=tablist] .btn { flex: 0 0 auto; } }
.card { max-width: 100%; min-width: 0; }
.content > *, .content .grid > * { min-width: 0; }

/* ===== Componentes amigables (ui.js) ===== */
.ui-toasts{position:fixed;right:16px;bottom:16px;z-index:3000;display:grid;gap:8px;max-width:min(380px,calc(100vw - 32px))}
.ui-toast{display:flex;align-items:flex-start;gap:10px;padding:12px 14px;border-radius:12px;background:#0B2A4A;color:#fff;box-shadow:0 10px 30px -10px rgba(11,42,74,.5);font-size:.9rem;transition:opacity .35s,transform .35s}
.ui-toast-ok{background:#0B6E66}.ui-toast-error{background:#B42318}
.ui-toast.out{opacity:0;transform:translateY(8px)}
.ui-toast span{flex:1}
.ui-toast-x{background:none;border:0;color:inherit;font-size:1.1rem;cursor:pointer;line-height:1}
.ui-overlay{position:fixed;inset:0;background:rgba(7,28,51,.45);z-index:2500;display:grid;place-items:center;padding:16px}
.ui-dialog{background:#fff;border-radius:16px;width:min(520px,100%);max-height:calc(100vh - 32px);overflow:auto;padding:22px;box-shadow:0 30px 60px -20px rgba(7,28,51,.5)}
.ui-dialog h2{font-size:1.15rem;margin:0 0 6px}
.ui-dialog-intro{color:var(--text-muted);font-size:.9rem;margin:0 0 12px}
.ui-dialog-err{color:#B42318;font-size:.88rem;min-height:1em;margin:6px 0 0}
.ui-help{display:block;color:var(--text-muted);font-size:.78rem;margin:-6px 0 10px}
.ui-check{display:flex;align-items:center;gap:8px;font-size:.9rem;margin:6px 0 12px;cursor:pointer}
.help{display:block;color:var(--text-muted);font-size:.78rem;margin-top:3px;line-height:1.35}
.rowlist{display:grid;gap:10px}
.rowlist-item{border:1px solid var(--border);border-radius:12px;padding:12px;background:#fbfcfd;position:relative}
.rowlist-item .rl-remove{position:absolute;top:8px;right:8px}
.rowlist-empty{border:1px dashed var(--border);border-radius:12px;padding:16px;text-align:center;color:var(--text-muted);font-size:.88rem}
.sched{display:grid;gap:6px}
.sched-row{display:grid;grid-template-columns:110px auto 1fr;gap:10px;align-items:center;font-size:.9rem}
.sched-row .times{display:flex;gap:6px;align-items:center;flex-wrap:wrap}
.sched-row input[type=time]{width:auto}
.color-field{display:flex;gap:8px;align-items:center}.color-field input[type=color]{width:46px;height:38px;padding:2px;border-radius:8px}
.logo-prev{max-height:48px;margin-top:6px;border-radius:6px;background:#f4f6f9;padding:4px}
@media (max-width:560px){.sched-row{grid-template-columns:1fr;gap:4px}.ui-dialog{padding:18px}}
.btn-danger{background:#B42318;color:#fff;border:0}.btn-danger:hover{background:#912018}
.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
.site-sec{margin-bottom:14px;padding:16px}.site-sec>header{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-bottom:10px}.site-sec h2{font-size:1.02rem;margin:0}
.site-item{border:1px solid var(--border);border-radius:12px;padding:12px;margin-bottom:10px;background:#fafcfd}.site-item>header{display:flex;justify-content:space-between;align-items:center;margin-bottom:6px;font-weight:600;font-size:.88rem}
.site-save{position:sticky;bottom:0;display:flex;justify-content:flex-end;gap:10px;padding:12px 0;background:linear-gradient(transparent,var(--bg,#f5f7fa) 30%)}
.ben{display:flex;gap:6px;margin-bottom:6px}.ben input{flex:1}.gal-prev{width:100%;max-width:220px;aspect-ratio:16/10;object-fit:cover;border-radius:8px;background:#eef2f6;display:block;margin-top:6px}
.plat-row td small{color:var(--text-muted)}
.caja-grid>*,.resp-grid>*{min-width:0}.cal-grid{grid-template-columns:repeat(7,minmax(0,1fr))!important}.cal-day{min-width:0;overflow:hidden;word-break:break-word}
@media(max-width:760px){.resp-grid{grid-template-columns:1fr!important}.caja-grid{grid-template-columns:minmax(0,1fr)!important}.content input,.content select,.content textarea{max-width:100%}}
.site-save{flex-wrap:wrap}.plat-row select{padding:6px 8px;border:1px solid var(--border);border-radius:8px;background:#fff;font:inherit}
@media(max-width:520px){.site-save .btn{flex:1 1 100%;justify-content:center}}
