/* ============================================================
   CRM MARCAS — Sistema de Estilos v2.0
   ============================================================ */
:root {
  --primary:      #1a3a5c;
  --primary-lt:   #2563a8;
  --primary-bg:   #e8f0fa;
  --gold:         #b07d2a;
  --gold-bg:      #fef9e7;
  --teal:         #0d7377;
  --teal-bg:      #e6f7f7;
  --green:        #16a34a;
  --green-bg:     #dcfce7;
  --amber:        #d97706;
  --amber-bg:     #fef3c7;
  --orange:       #ea580c;
  --orange-bg:    #fff0e6;
  --red-warm:     #dc2626;
  --red-warm-bg:  #ffe4e4;
  --red:          #dc2626;
  --red-bg:       #fee2e2;
  --purple:       #7c3aed;
  --border:       #e2e8f0;
  --surface:      #ffffff;
  --soft:         #f8fafc;
  --ink:          #1e293b;
  --muted:        #64748b;
  --dim:          #94a3b8;
  --sidebar-w:    240px;
  --topbar-h:     52px;
  --radius:       10px;
  --shadow:       0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--soft);
  line-height: 1.5;
}

/* ── Layout ──────────────────────────────────────────────── */
.app-wrapper    { display: flex; min-height: 100vh; }
.main-content   { flex: 1; display: flex; flex-direction: column; min-width: 0; margin-left: var(--sidebar-w); }
.page-body      { flex: 1; padding: 24px; }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--primary);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}
.sidebar-logo        { padding: 20px 16px 14px; border-bottom: 1px solid rgba(255,255,255,.1); }
.sidebar-logo-title  { font-size: 15px; font-weight: 700; color: #fff; }
.sidebar-logo-sub    { font-size: 10px; color: rgba(255,255,255,.45); margin-top: 2px; }
.sidebar-nav         { flex: 1; padding: 12px 8px; }
.nav-section-label   { font-size: 9px; font-weight: 700; letter-spacing: .1em;
                        text-transform: uppercase; color: rgba(255,255,255,.35);
                        padding: 14px 8px 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 7px;
  color: rgba(255,255,255,.75); font-size: 13px; font-weight: 500;
  text-decoration: none; transition: .15s; margin-bottom: 1px; cursor: pointer;
}
.nav-item:hover  { background: rgba(255,255,255,.1); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.18); color: #fff; font-weight: 600; }
.nav-item .icon  { font-size: 15px; width: 20px; text-align: center; }
.nav-badge       { margin-left: auto; background: var(--red);
                   color: #fff; font-size: 10px; font-weight: 700;
                   padding: 1px 6px; border-radius: 20px; }
.sidebar-footer  { padding: 12px; border-top: 1px solid rgba(255,255,255,.1); }
.sidebar-user    { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sidebar-user-name  { font-size: 12px; font-weight: 600; color: #fff; }
.sidebar-user-role  { font-size: 10px; color: rgba(255,255,255,.5); }
.btn-logout      { display: block; text-align: center; font-size: 11px; color: rgba(255,255,255,.5);
                   padding: 6px; border-radius: 6px; text-decoration: none;
                   transition: .15s; }
.btn-logout:hover { background: rgba(255,255,255,.1); color: #fff; }

/* ── Topbar ──────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 50;
}
.topbar-title   { font-size: 15px; font-weight: 700; color: var(--primary); }
.topbar-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ── Avatar ──────────────────────────────────────────────── */
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff; flex-shrink: 0;
}

/* ── Cards ───────────────────────────────────────────────── */
.card           { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 0; overflow: hidden; }
.card-header    { display: flex; align-items: center; justify-content: space-between;
                  padding: 14px 20px; border-bottom: 1px solid var(--border); }
.card-title     { font-size: 14px; font-weight: 700; color: var(--primary); }
.card-body      { padding: 20px; }
.mb-16          { margin-bottom: 16px; }
.mb-24          { margin-bottom: 24px; }

/* ── Metrics ─────────────────────────────────────────────── */
.metrics-row    { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 14px; }
.metric-card    { background: #fff; border-radius: var(--radius); padding: 18px 20px;
                  box-shadow: var(--shadow); border-top: 3px solid var(--border); }
.metric-card-label { font-size: 11px; font-weight: 600; color: var(--muted);
                     text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.metric-card-val   { font-size: 26px; font-weight: 800; color: var(--ink); line-height: 1; margin-bottom: 4px; }
.metric-card-sub   { font-size: 11px; color: var(--dim); }
.metric-card:hover { background: var(--primary-bg); transition: background 0.2s; }
.task-row:hover    { background: var(--soft); transition: background 0.2s; }

/* ── Tables ──────────────────────────────────────────────── */
.table-wrap     { overflow-x: auto; }
table           { width: 100%; border-collapse: collapse; }
th              { background: var(--soft); font-size: 11px; font-weight: 700;
                  text-transform: uppercase; letter-spacing: .04em;
                  color: var(--muted); padding: 10px 16px;
                  text-align: left; white-space: nowrap; }
td              { padding: 11px 16px; border-top: 1px solid var(--border); font-size: 13px; }
tr:hover td     { background: var(--soft); }
.text-muted     { color: var(--muted); }
.text-dim       { color: var(--dim); }

/* ── Badges ──────────────────────────────────────────────── */
.badge          { display: inline-flex; align-items: center; padding: 2px 8px;
                  border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge-gray     { background: #f1f5f9; color: #64748b; }
.badge-blue     { background: #dbeafe; color: #1d4ed8; }
.badge-green    { background: var(--green-bg); color: var(--green); }
.badge-red      { background: var(--red-bg);   color: var(--red); }
.badge-amber    { background: var(--amber-bg);    color: var(--amber); }
.badge-gold     { background: var(--gold-bg);     color: var(--gold); }
.badge-orange   { background: var(--orange-bg);   color: var(--orange); }
.badge-red-warm { background: var(--red-warm-bg); color: var(--red-warm); }
.badge-teal     { background: var(--teal-bg);  color: var(--teal); }
.badge-purple   { background: #f3e8ff;         color: var(--purple); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 7px; font-size: 13px; font-weight: 600;
  cursor: pointer; border: 1.5px solid transparent; transition: .15s;
  text-decoration: none; white-space: nowrap;
}
.btn-primary   { background: var(--primary-lt); color: #fff; border-color: var(--primary-lt); }
.btn-primary:hover  { background: var(--primary); border-color: var(--primary); }
.btn-success   { background: var(--green);    color: #fff; border-color: var(--green); }
.btn-success:hover  { filter: brightness(.9); }
.btn-warning   { background: var(--amber);    color: #fff; border-color: var(--amber); }
.btn-danger    { background: var(--red);      color: #fff; border-color: var(--red); }
.btn-outline   { background: transparent; color: var(--primary-lt); border-color: var(--border); }
.btn-outline:hover  { background: var(--primary-bg); }
.btn-sm        { padding: 5px 10px; font-size: 12px; }
.btn-xs        { padding: 3px 8px;  font-size: 11px; border-radius: 5px; }

/* ── Forms ───────────────────────────────────────────────── */
.form-group     { margin-bottom: 14px; }
.form-row       { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-label     { display: block; font-size: 12px; font-weight: 600;
                  color: var(--muted); margin-bottom: 5px; }
.form-control {
  width: 100%; padding: 8px 12px; border: 1.5px solid var(--border);
  border-radius: 7px; font-size: 13px; color: var(--ink);
  background: #fff; transition: border-color .15s;
  font-family: inherit;
}
.form-control:focus { outline: none; border-color: var(--primary-lt); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.search-input   { max-width: 280px; }

/* ── Alerts ──────────────────────────────────────────────── */
.alert          { padding: 12px 16px; border-radius: var(--radius);
                  font-size: 13px; border: 1px solid transparent; }
.alert-success  { background: var(--green-bg); color: #15803d; border-color: #bbf7d0; }
.alert-danger   { background: var(--red-bg);   color: #991b1b; border-color: #fecaca; }
.alert-warning  { background: var(--amber-bg); color: #92400e; border-color: #fde68a; }
.alert-info     { background: var(--primary-bg); color: var(--primary); border-color: #bfdbfe; }

/* ── Modals ──────────────────────────────────────────────── */
.modal-overlay  { display: none; position: fixed; inset: 0;
                  background: rgba(0,0,0,.45); z-index: 200;
                  align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.open { display: flex; }
.modal          { background: #fff; border-radius: 14px;
                  width: 100%; max-width: 580px;
                  max-height: 90vh; overflow-y: auto;
                  box-shadow: 0 24px 64px rgba(0,0,0,.2); }
.modal-header   { display: flex; align-items: center; justify-content: space-between;
                  padding: 18px 24px; border-bottom: 1px solid var(--border); }
.modal-title    { font-size: 16px; font-weight: 700; color: var(--primary); }
.modal-close    { background: none; border: none; font-size: 18px;
                  cursor: pointer; color: var(--dim); padding: 4px 8px; border-radius: 6px; }
.modal-close:hover { background: var(--soft); }
.modal-body     { padding: 22px 24px; }
.modal-footer   { display: flex; justify-content: flex-end; gap: 10px;
                  padding: 16px 24px; border-top: 1px solid var(--border); }

/* ── Kanban ──────────────────────────────────────────────── */
.kanban-board   { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.kanban-col     { min-width: 220px; width: 220px; flex-shrink: 0; }
.kanban-col-header { display: flex; align-items: center; justify-content: space-between;
                     padding: 10px 12px; border-radius: 8px 8px 0 0;
                     background: var(--soft); border: 1px solid var(--border); border-bottom: none; }
.kanban-col-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.kanban-count   { font-size: 11px; font-weight: 700; background: var(--border);
                  color: var(--muted); padding: 1px 7px; border-radius: 20px; }
.kanban-card    { background: #fff; border: 1px solid var(--border); border-top: none;
                  padding: 12px; cursor: pointer; transition: .15s; }
.kanban-card:hover { background: var(--primary-bg); }
.kanban-card:last-child { border-radius: 0 0 8px 8px; }
.kanban-card-name { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.kanban-card-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.kanban-card-source { font-size: 11px; color: var(--dim); }

/* ── Timeline ────────────────────────────────────────────── */
.timeline       { position: relative; padding-left: 24px; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 0; bottom: 0;
                    width: 2px; background: var(--border); }
.tl-item        { position: relative; margin-bottom: 20px; }
.tl-dot         { position: absolute; left: -21px; top: 4px;
                  width: 10px; height: 10px; border-radius: 50%;
                  background: var(--primary-lt); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--border); }
.tl-meta        { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.tl-text        { font-size: 13px; color: var(--ink); line-height: 1.5; }
.timeline-wrapper {
  max-height: 500px;
  overflow-y: auto;
  padding-right: 15px;
  margin-right: -10px;
}
.timeline-wrapper::-webkit-scrollbar { width: 5px; }
.timeline-wrapper::-webkit-scrollbar-track { background: var(--soft); }
.timeline-wrapper::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
.timeline-wrapper::-webkit-scrollbar-thumb:hover { background: var(--dim); }

/* ── Progress ────────────────────────────────────────────── */
.progress       { height: 6px; background: var(--border); border-radius: 4px; overflow: hidden; }
.progress-bar   { height: 100%; background: var(--primary-lt); border-radius: 4px; transition: width .4s; }

/* ── Detail view ─────────────────────────────────────────── */
.detail-label   { font-size: 11px; font-weight: 600; color: var(--dim);
                  text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }
.detail-val     { font-size: 13px; color: var(--ink); }

/* ── Filters bar ─────────────────────────────────────────── */
.filters-bar    { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filters-bar .form-control { max-width: 200px; }

/* ── Empty state ─────────────────────────────────────────── */
.empty-state    { text-align: center; padding: 40px 20px; color: var(--dim); }
.empty-state-icon { font-size: 36px; margin-bottom: 10px; }

/* ── Toast ───────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999;
                   display: flex; flex-direction: column; gap: 8px; }
.toast          { padding: 12px 18px; border-radius: 9px; font-size: 13px; font-weight: 600;
                  color: #fff; min-width: 200px; box-shadow: 0 8px 24px rgba(0,0,0,.2);
                  animation: slideIn .25s ease; }
.toast-success  { background: var(--green); }
.toast-error    { background: var(--red); }
.toast-info     { background: var(--primary-lt); }
@keyframes slideIn { from { transform: translateX(60px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Confirm overlay ─────────────────────────────────────── */
.confirm-overlay { display:none; position:fixed; inset:0;
                   background:rgba(0,0,0,.5); z-index:9000;
                   align-items:center; justify-content:center; }
.confirm-overlay.open { display:flex; }
.confirm-box    { background:#fff; border-radius:12px; padding:28px 32px;
                  max-width:360px; text-align:center; box-shadow:0 20px 60px rgba(0,0,0,.25); }
.confirm-box h3 { font-size:16px; margin-bottom:10px; color:var(--primary); }
.confirm-box p  { font-size:13px; color:var(--muted); margin-bottom:20px; }
.confirm-actions { display:flex; gap:12px; justify-content:center; }

/* ── Helpers ─────────────────────────────────────────────── */
.flex-center    { display: flex; align-items: center; }
.gap-8          { gap: 8px; }
.gap-12         { gap: 12px; }
.flex-wrap      { flex-wrap: wrap; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar        { transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open   { transform: translateX(0); }
  .main-content   { margin-left: 0; }
  #menu-toggle    { display: flex !important; }
  .form-row       { grid-template-columns: 1fr; }
  .kanban-board   { gap: 10px; }
  .metrics-row    { grid-template-columns: 1fr 1fr; }
  .page-body      { padding: 16px; }
}
@media (max-width: 480px) {
  .metrics-row    { grid-template-columns: 1fr; }
  .filters-bar .form-control { max-width: 100%; }
}

/* ── Autocomplete de Actividad Económica (ac-wrap) ────────────── */
.ac-wrap { position: relative; }

.ac-list {
  position: absolute; top: calc(100% + 3px); left: 0; right: 0;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.10);
  max-height: 260px;
  overflow-y: auto;
  z-index: 500;
  list-style: none;
  margin: 0; padding: 4px 0;
  display: none;
}
.ac-list::-webkit-scrollbar { width: 4px; }
.ac-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* Encabezado de grupo (nombre del sector) */
.ac-group-header {
  padding: 7px 12px 3px;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted);
  border-top: 1px solid var(--border);
}
.ac-group-header:first-child { border-top: none; }

/* Opción seleccionable */
.ac-item {
  padding: 7px 14px 7px 18px;
  cursor: pointer; font-size: 13px; color: var(--ink);
  transition: background .1s;
}
.ac-item:hover,
.ac-item.ac-hi { background: var(--primary-bg); color: var(--primary); }
.ac-item mark   { background: #fef08a; color: inherit; border-radius: 2px; padding: 0 1px; font-style: normal; }
.ac-empty       { padding: 10px 14px; color: var(--muted); font-style: italic; font-size: 13px; }
