/* CRM Grupo Rand — navy #1F3864, cyan #00B0F0 */
:root {
  --navy: #1F3864;
  --navy-dark: #16294a;
  --cyan: #00B0F0;
  --cyan-light: #e6f7fe;
  --bg: #f4f6f9;
  --card: #ffffff;
  --border: #dfe4ec;
  --text: #1c2733;
  --muted: #6b7a8d;
  --green: #1e9e62;
  --red: #d64545;
  --amber: #b7791f;
  --radius: 10px;
  --shadow: 0 1px 4px rgba(31, 56, 100, .12);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; }
.hidden { display: none !important; }
a { color: var(--cyan); }
h1, h2, h3 { color: var(--navy); margin: 0 0 12px; }
p { margin: 0 0 10px; }
small, .muted { color: var(--muted); }

/* ---------- Forms & buttons ---------- */
label { display: block; font-size: 13px; font-weight: 600; color: var(--navy); margin-bottom: 12px; }
input, select, textarea {
  display: block; width: 100%; margin-top: 5px; padding: 9px 10px;
  border: 1px solid var(--border); border-radius: 8px; font: inherit; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--cyan); border-color: var(--cyan); }
input:disabled, select:disabled, textarea:disabled { background: #f0f2f5; color: var(--muted); cursor: not-allowed; }
textarea { min-height: 90px; resize: vertical; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-weight: 400; margin-bottom: 8px; }
.checkbox-row input { width: auto; margin: 0; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row > * { flex: 1; min-width: 160px; }
.btn {
  display: inline-block; padding: 9px 16px; border: 1px solid transparent; border-radius: 8px;
  font: inherit; font-weight: 600; cursor: pointer; background: #eef1f5; color: var(--navy);
  text-decoration: none; white-space: nowrap;
}
.btn:hover { filter: brightness(.96); }
.btn-primary { background: var(--navy); color: #fff; }
.btn-cyan { background: var(--cyan); color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.error { color: var(--red); font-size: 14px; }
.notice { background: var(--cyan-light); border-left: 4px solid var(--cyan); padding: 10px 12px; border-radius: 6px; font-size: 14px; }
.note { background: #fff8e6; border-left: 4px solid #e6a700; padding: 10px 12px; border-radius: 6px; font-size: 14px; }

/* ---------- Login ---------- */
.login-view { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(160deg, var(--navy) 0%, var(--navy-dark) 60%, #0f5e7a 100%); }
.login-card { background: #fff; border-radius: 14px; padding: 32px 28px; width: 100%; max-width: 400px; box-shadow: 0 12px 40px rgba(0,0,0,.3); }
.login-logo { display: block; max-width: 220px; margin: 0 auto 16px; }
.login-card h1 { text-align: center; font-size: 22px; }
.login-sub { text-align: center; color: var(--muted); margin-bottom: 20px; }

/* ---------- Shell / sidebar ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 240px; flex-shrink: 0; background: var(--navy); color: #fff; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.sidebar-brand { padding: 18px 16px 12px; border-bottom: 1px solid rgba(255,255,255,.15); }
.sidebar-logo { display: block; max-width: 100%; max-height: 64px; background: #fff; border-radius: 8px; padding: 6px 10px; }
.sidebar-nav { flex: 1; padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.sidebar-nav a { color: #d7e2f0; text-decoration: none; padding: 10px 12px; border-radius: 8px; font-weight: 500; }
.sidebar-nav a:hover { background: rgba(255,255,255,.1); color: #fff; }
.sidebar-nav a.active { background: var(--cyan); color: #fff; }
.sidebar-footer { padding: 14px; border-top: 1px solid rgba(255,255,255,.15); }
.user-chip { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.user-avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--cyan); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.user-info { min-width: 0; }
.user-info strong, .user-info small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info small { color: #a9bdd6; }
.sidebar-footer .btn-ghost { color: #fff; border-color: rgba(255,255,255,.4); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { background: #fff; border-bottom: 1px solid var(--border); padding: 14px 24px; display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 10; }
.topbar h2 { margin: 0; font-size: 20px; }
.menu-toggle { display: none; }
.view { padding: 24px; max-width: 1400px; width: 100%; margin: 0 auto; }

/* ---------- Cards, tables ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px; }
.card h3 { font-size: 16px; }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.stat-card .stat-num { font-size: 30px; font-weight: 800; color: var(--navy); line-height: 1.1; }
.stat-card .stat-label { color: var(--muted); font-size: 13px; margin-top: 4px; }
.stat-card .stat-sub { font-size: 13px; color: var(--cyan); font-weight: 600; }
.toolbar { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar label { margin-bottom: 0; flex: 1; min-width: 150px; }
.toolbar .btn { margin-bottom: 0; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--navy); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:hover { background: #f7fafc; }
tbody tr { cursor: pointer; }
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 14px; }
.bar-row .bar-label { width: 180px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; height: 14px; background: #e8edf3; border-radius: 7px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--cyan); border-radius: 7px; }
.bar-count { width: 34px; text-align: right; font-weight: 700; color: var(--navy); }

/* ---------- Badges / tags ---------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 12px; font-weight: 600; background: #e8edf3; color: var(--navy); }
.badge-green { background: #dcf5e5; color: var(--green); }
.badge-red { background: #fbe3e3; color: var(--red); }
.badge-amber { background: #fdf0d3; color: var(--amber); }
.badge-cyan { background: var(--cyan-light); color: #0077a3; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; background: var(--cyan-light); color: #0077a3; margin-right: 4px; }

/* ---------- Kanban ---------- */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.kanban-col { flex: 0 0 260px; background: #e9edf2; border-radius: var(--radius); padding: 10px; min-height: 200px; }
.kanban-col.drag-over { outline: 2px dashed var(--cyan); outline-offset: -2px; background: var(--cyan-light); }
.kanban-col h3 { font-size: 13px; margin-bottom: 4px; display: flex; justify-content: space-between; }
.kanban-col .col-count { background: var(--navy); color: #fff; border-radius: 12px; padding: 0 8px; font-size: 12px; }
.kanban-cards { display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.kanban-card { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; cursor: grab; box-shadow: var(--shadow); }
.kanban-card:hover { border-color: var(--cyan); }
.kanban-card.dragging { opacity: .5; }
.kanban-card .kc-name { font-weight: 700; color: var(--navy); margin-bottom: 2px; }
.kanban-card .kc-prop { font-size: 13px; }
.kanban-card .kc-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 12px; color: var(--muted); }
.kanban-card .kc-price { font-weight: 700; color: var(--navy); }

/* ---------- Lead detail ---------- */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.msg { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.msg-out { background: var(--cyan-light); border-color: #bfe8fa; }
.msg-in { background: #fff; }
.msg-head { font-size: 12px; color: var(--muted); margin-bottom: 4px; display: flex; gap: 8px; flex-wrap: wrap; }
.msg-head strong { color: var(--navy); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0 8px 18px; border-left: 2px solid var(--cyan); margin-left: 6px; position: relative; font-size: 14px; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 14px; width: 10px; height: 10px; border-radius: 50%; background: var(--cyan); }
.timeline .tl-date { color: var(--muted); font-size: 12px; }
.suggest-box { background: #f0fbf0; border: 1px solid #bfe6c8; border-radius: 8px; padding: 12px; margin-top: 10px; }
.suggest-box .suggest-reason { font-size: 13px; color: var(--muted); margin-bottom: 6px; }

/* ---------- Toast & modal ---------- */
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 12px 20px; border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.3); z-index: 100; max-width: 90vw; }
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }
.modal-overlay { position: fixed; inset: 0; background: rgba(15, 30, 55, .55); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 560px; box-shadow: 0 16px 48px rgba(0,0,0,.35); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; }
.modal-body { padding: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.empty { color: var(--muted); text-align: center; padding: 24px 0; }
.import-result { margin-top: 12px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: inline-block; }
  .view { padding: 16px; }
}
