:root {
  --azul-noche: #0D1F2D;
  --teal: #1A7F8E;
  --aqua: #2EC4D6;
  --gris-azulado: #7AAAB8;
  --gris-texto: #5A7080;
  --humo: #F2F4F7;
  --blanco: #FFFFFF;
  --rojo: #C0392B;
  --verde: #1E8449;
  --amarillo: #B7791F;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--humo);
  color: var(--azul-noche);
  -webkit-font-smoothing: antialiased;
}

h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 15px; margin: 0 0 12px; color: var(--azul-noche); }

/* ---------- LOGIN ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--azul-noche);
}
.login-box {
  background: var(--blanco);
  padding: 36px 32px;
  border-radius: var(--radius);
  width: 320px;
  max-width: 90vw;
  text-align: center;
}
.login-logo { font-size: 26px; font-weight: bold; text-transform: uppercase; letter-spacing: 1px; }
.login-logo span { color: var(--teal); }
.login-sub { color: var(--gris-texto); font-size: 13px; margin-bottom: 20px; }
.login-box label { display: block; text-align: left; font-size: 12px; color: var(--gris-texto); margin: 12px 0 4px; }
.login-box input { width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 4px; font-size: 14px; }
.login-box button { margin-top: 20px; width: 100%; padding: 12px; background: var(--teal); color: #fff; border: none; border-radius: 4px; font-weight: bold; cursor: pointer; font-size: 14px; }
.form-error { background: #fdecea; color: var(--rojo); padding: 8px 10px; border-radius: 4px; font-size: 12px; margin-top: 10px; }

/* ---------- TOPBAR ---------- */
.topbar {
  background: var(--azul-noche);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: bold; text-transform: uppercase; letter-spacing: 0.5px; font-size: 16px; }
.brand span { color: var(--aqua); }
.brand small { color: var(--gris-azulado); font-weight: normal; margin-left: 6px; font-size: 11px; }
.topnav { display: flex; gap: 6px; }
.topnav .nav-btn, .topbar-right .btn-ghost {
  background: transparent; border: none; color: var(--gris-azulado); padding: 8px 12px;
  border-radius: 4px; cursor: pointer; font-size: 13px;
}
.topnav .nav-btn.active, .topnav .nav-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }
.topbar-right { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--gris-azulado); }
.btn-ghost:hover { color: #fff; }

/* ---------- LAYOUT ---------- */
.main { max-width: 1100px; margin: 0 auto; padding: 24px 20px 90px; }
.view-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }

/* ---------- BUTTONS ---------- */
.btn-primary {
  background: var(--teal); color: #fff; border: none; padding: 10px 16px;
  border-radius: 4px; font-size: 13px; font-weight: bold; cursor: pointer;
}
.btn-primary:hover { background: var(--azul-noche); }
.btn-secondary {
  background: var(--humo); color: var(--azul-noche); border: 1px solid #ddd; padding: 9px 14px;
  border-radius: 4px; font-size: 13px; cursor: pointer;
}
.btn-danger { background: #fdecea; color: var(--rojo); border: none; padding: 8px 12px; border-radius: 4px; font-size: 12px; cursor: pointer; }
.btn-back { background: none; border: none; color: var(--teal); font-size: 13px; cursor: pointer; margin-bottom: 14px; padding: 0; }
.icon-btn { background: none; border: none; cursor: pointer; color: var(--gris-texto); font-size: 14px; }

/* ---------- KPI ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 24px; }
.kpi-card { background: #fff; border-radius: var(--radius); padding: 18px; }
.kpi-card .kpi-value { font-size: 26px; font-weight: bold; color: var(--teal); }
.kpi-card .kpi-label { font-size: 12px; color: var(--gris-texto); margin-top: 4px; }

.dash-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 720px) { .dash-columns { grid-template-columns: 1fr; } }

.card { background: #fff; border-radius: var(--radius); padding: 18px; }

/* ---------- TOOLBAR ---------- */
.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar input, .toolbar select {
  padding: 10px 12px; border: 1px solid #ddd; border-radius: 4px; font-size: 13px; background: #fff;
}
.toolbar input { flex: 1; min-width: 200px; }

/* ---------- CONTACTS GRID ---------- */
.contacts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.contact-card {
  background: #fff; border-radius: var(--radius); padding: 16px; cursor: pointer;
  border: 1px solid transparent; transition: border 0.15s;
}
.contact-card:hover { border-color: var(--teal); }
.contact-card .cc-name { font-weight: bold; font-size: 14px; }
.contact-card .cc-company { color: var(--gris-texto); font-size: 12px; margin-top: 2px; }
.contact-card .cc-meta { margin-top: 10px; font-size: 12px; color: var(--gris-texto); }
.tag { display: inline-block; background: var(--humo); color: var(--teal); font-size: 11px; padding: 3px 8px; border-radius: 10px; margin: 6px 4px 0 0; }

/* ---------- CONTACT DETAIL ---------- */
.detail-header { display: flex; justify-content: space-between; align-items: flex-start; background: #fff; border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.detail-header h2 { font-size: 20px; margin-bottom: 4px; }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.detail-actions a, .detail-actions button {
  text-decoration: none; font-size: 12px; padding: 8px 12px; border-radius: 4px; border: none; cursor: pointer;
}
.action-whatsapp { background: #25D366; color: #fff; }
.action-email { background: var(--teal); color: #fff; }
.action-edit { background: var(--humo); color: var(--azul-noche); }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 720px) { .detail-grid { grid-template-columns: 1fr; } }

.activity-item, .task-item, .deal-item {
  border-bottom: 1px solid #eee; padding: 10px 0; font-size: 13px;
}
.activity-item:last-child, .task-item:last-child, .deal-item:last-child { border-bottom: none; }
.activity-type { display: inline-block; font-size: 10px; text-transform: uppercase; color: var(--teal); font-weight: bold; margin-right: 6px; }
.activity-date, .task-date { color: var(--gris-texto); font-size: 11px; }

.mini-list .mini-item { padding: 8px 0; border-bottom: 1px solid #eee; font-size: 13px; cursor: pointer; }
.mini-list .mini-item:last-child { border-bottom: none; }

/* ---------- TASKS ---------- */
.task-list .task-item { display: flex; align-items: flex-start; gap: 10px; background: #fff; border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px; border: none; }
.task-item.done { opacity: 0.5; }
.task-item .task-title { flex: 1; }
.task-item input[type=checkbox] { margin-top: 3px; }

/* ---------- KANBAN ---------- */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 10px; }
.kanban-col { background: #fff; border-radius: var(--radius); min-width: 230px; flex: 1; padding: 12px; max-height: 70vh; overflow-y: auto; }
.kanban-col h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--gris-texto); margin: 0 0 10px; }
.kanban-card {
  background: var(--humo); border-radius: 6px; padding: 10px; margin-bottom: 8px; font-size: 12px; cursor: grab;
}
.kanban-card .kc-title { font-weight: bold; color: var(--azul-noche); margin-bottom: 4px; }
.kanban-card .kc-value { color: var(--teal); font-weight: bold; }
.kanban-card .kc-contact { color: var(--gris-texto); margin-top: 4px; }
.kanban-card select { width: 100%; margin-top: 8px; font-size: 11px; padding: 4px; }
.kanban-col.dragover { outline: 2px dashed var(--teal); }

/* ---------- MODAL ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(13,31,45,0.5); display: flex;
  align-items: center; justify-content: center; z-index: 100; padding: 16px;
}
.modal { background: #fff; border-radius: var(--radius); width: 460px; max-width: 100%; max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid #eee; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--gris-texto); }
.modal-body { padding: 20px; }
.modal-body label { display: block; font-size: 12px; color: var(--gris-texto); margin: 12px 0 4px; }
.modal-body label:first-child { margin-top: 0; }
.modal-body input, .modal-body select, .modal-body textarea {
  width: 100%; padding: 9px 10px; border: 1px solid #ddd; border-radius: 4px; font-size: 13px; font-family: inherit;
}
.modal-body textarea { resize: vertical; min-height: 60px; }
.modal-actions { margin-top: 20px; display: flex; gap: 8px; justify-content: flex-end; }

/* ---------- TOAST ---------- */
.toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
  background: var(--azul-noche); color: #fff; padding: 10px 18px; border-radius: 20px;
  font-size: 13px; z-index: 200;
}

/* ---------- BOTTOM NAV (mobile) ---------- */
.bottomnav { display: none; }

@media (max-width: 820px) {
  .topnav { display: none; }
  .topbar-right span#whoami { display: none; }
  .bottomnav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: #fff;
    border-top: 1px solid #eee; padding: 6px 0; z-index: 30; align-items: center; justify-content: space-around;
  }
  .bottomnav .nav-btn {
    background: none; border: none; display: flex; flex-direction: column; align-items: center;
    font-size: 10px; color: var(--gris-texto); gap: 2px; padding: 4px 8px;
  }
  .bottomnav .nav-btn.active { color: var(--teal); }
  .bottomnav .icon { font-size: 16px; }
  .fab {
    background: var(--teal); color: #fff; border: none; width: 46px; height: 46px; border-radius: 50%;
    font-size: 22px; margin-top: -26px; box-shadow: 0 3px 10px rgba(0,0,0,0.25); cursor: pointer;
  }
  .main { padding-bottom: 100px; }
}
