/* ============================================================
   Lire Llamadas — Modern light-default theme
   ============================================================ */
:root {
  /* Base palette */
  --bg:           #f4f6fb;
  --bg-2:         #ffffff;
  --bg-3:         #fbfbfd;
  --fg:           #0f172a;
  --fg-2:         #475569;
  --fg-3:         #64748b;
  --muted:        #94a3b8;
  --border:       #e5e9f2;
  --border-soft:  #eef1f7;
  --accent:       #2563eb;
  --accent-hi:    #1d4ed8;
  --accent-soft:  #eff5ff;
  --ok:           #16a34a;
  --warn:         #d97706;
  --danger:       #dc2626;
  --hot:          #ef4444;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.04);
  --shadow:    0 1px 3px rgba(15,23,42,.04), 0 6px 18px rgba(15,23,42,.05);
  --shadow-lg: 0 4px 8px rgba(15,23,42,.06), 0 18px 40px rgba(15,23,42,.07);
  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 16px;
  --side-w:   232px;
  --topbar-h: 56px;
  --font:     ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji";
}
[data-theme="dark"] {
  --bg:           #0b1020;
  --bg-2:         #131a32;
  --bg-3:         #0e1428;
  --fg:           #e7ecf5;
  --fg-2:         #cbd5e1;
  --fg-3:         #94a3b8;
  --muted:        #64748b;
  --border:       #1f2944;
  --border-soft:  #182142;
  --accent:       #3b82f6;
  --accent-hi:    #60a5fa;
  --accent-soft:  rgba(59,130,246,.12);
  --shadow:    0 2px 6px rgba(0,0,0,.45);
  --shadow-lg: 0 6px 18px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hi); text-decoration: underline; }
hr { border: 0; border-top: 1px solid var(--border-soft); margin: 16px 0; }

/* ---- Layout ---- */
.side {
  position: fixed; inset: 0 auto 0 0; width: var(--side-w);
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 20;
}
.brand { padding: 18px 20px; }
.brand a { display: flex; align-items: center; gap: .65rem; color: var(--fg); font-weight: 600; font-size: 15px; }
.brand a:hover { text-decoration: none; }
.logo {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, #4f46e5, #2563eb);
  color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: 14px;
  box-shadow: 0 6px 16px rgba(37,99,235,.35);
}
.nav { flex: 1; padding: 6px 12px; overflow: auto; }
.nav-item {
  display: flex; align-items: center; gap: .7rem;
  padding: 9px 12px; border-radius: 8px;
  color: var(--fg-2); margin: 2px 0;
  font-weight: 500; font-size: 13.5px;
  transition: background .15s, color .15s;
}
.nav-item svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.nav-item:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }

.side-foot { padding: 12px; border-top: 1px solid var(--border-soft); }
.locale-form { display: flex; gap: 6px; margin-bottom: 10px; }
.locale-form button {
  flex: 1; padding: 5px 8px; border: 1px solid var(--border); background: transparent;
  border-radius: 6px; color: var(--fg-2); cursor: pointer; font-size: 12px; font-weight: 600;
}
.locale-form .on { background: var(--accent); border-color: var(--accent); color: #fff; }
.user { display: flex; align-items: center; gap: .55rem; font-size: 13px; color: var(--fg-2); margin-bottom: 4px; }
.avatar {
  width: 28px; height: 28px; background: var(--accent); color: #fff;
  border-radius: 50%; display: grid; place-items: center;
  font-weight: 600; font-size: 12px;
}
.signout { font-size: 12.5px; color: var(--muted); }

.main { margin-left: var(--side-w); min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  height: var(--topbar-h);
  padding: 0 24px;
  display: flex; align-items: center; gap: 1rem;
  background: rgba(255,255,255,.85);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border-soft);
}
[data-theme="dark"] .topbar { background: rgba(19,26,50,.85); }
.page-title { margin: 0; font-size: 15px; font-weight: 600; }
.menu-toggle { display: none; background: none; border: 0; font-size: 1.2rem; color: var(--fg); }

.content { padding: 22px 24px; }

/* Mobile sidebar */
@media (max-width: 900px) {
  .side {
    transform: translateX(-100%);
    transition: transform .2s ease;
    width: 268px; box-shadow: var(--shadow-lg);
  }
  body.side-open .side { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-block; }
}

/* ---- Cards / grids ---- */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-soft);
}
.card-header h3 { margin: 0; font-size: 14px; font-weight: 600; color: var(--fg); letter-spacing: .005em; }
.card h2 { margin: 0 0 14px; font-size: 18px; font-weight: 600; }
.card h3 { font-size: 14px; color: var(--fg); margin: 14px 0 8px; }
.card h4 { font-size: 13px; color: var(--fg-2); margin: 12px 0 6px; text-transform: uppercase; letter-spacing: .04em; }

.link-card { transition: transform .15s; cursor: pointer; display: block; color: inherit; }
.link-card:hover { transform: translateY(-2px); text-decoration: none; box-shadow: var(--shadow); }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-lead-main { grid-template-columns: 1.05fr 1.25fr 1fr; align-items: start; }
@media (max-width: 1280px) { .grid-lead-main { grid-template-columns: 1fr 1fr; } }
@media (max-width: 820px)  { .grid-lead-main, .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.col { display: flex; flex-direction: column; gap: 0; }
.col > .card { margin-bottom: 18px; }
.span-2 { grid-column: span 2; }

/* Stats */
.stat-card { padding: 18px; display: flex; flex-direction: column; gap: 6px; color: var(--fg); }
.stat-card.hot { border-left: 4px solid var(--hot); }
.stat-label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; font-weight: 600; }
.stat-value { font-size: 28px; font-weight: 700; letter-spacing: -.01em; }
.stat-value.small { font-size: 16px; }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border-soft); }
.table thead th {
  background: var(--bg-3);
  font-weight: 600; font-size: 11.5px; color: var(--fg-3);
  text-transform: uppercase; letter-spacing: .05em;
}
.table tbody tr:hover { background: var(--bg-3); }
.table.compact th, .table.compact td { padding: 7px 8px; font-size: 13px; }
.row-actions { text-align: right; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* Forms */
input[type="text"], input[type="email"], input[type="password"], input[type="tel"],
input[type="search"], input[type="number"], input[type="date"], input[type="time"],
input[type="datetime-local"], input[type="file"], input[type="url"], select, textarea {
  width: 100%; padding: 8px 10px; background: var(--bg-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--fg);
  font: inherit;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
label { display: block; margin-bottom: 5px; font-size: 12.5px; color: var(--fg-2); font-weight: 500; }
label.checkbox { display: flex; align-items: center; gap: .5rem; }
label input, label select, label textarea { margin-top: 4px; }
.form-grid label { margin: 4px 0 10px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
form.inline { display: inline; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: 8px 14px;
  border: 1px solid var(--border); background: var(--bg-2); color: var(--fg);
  border-radius: var(--radius-sm); cursor: pointer; font: inherit;
  font-weight: 500;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
  text-decoration: none;
}
.btn:hover { background: var(--bg-3); border-color: #d4dae9; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent); color: #fff; border-color: var(--accent);
  box-shadow: 0 1px 0 rgba(255,255,255,.15) inset, 0 4px 10px rgba(37,99,235,.25);
}
.btn-primary:hover { background: var(--accent-hi); border-color: var(--accent-hi); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-block { width: 100%; margin-top: 8px; }
.big { font-size: 15px; padding: 11px 18px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border: 1px solid var(--border); background: var(--bg-2);
  border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--fg-2);
  transition: all .15s;
}
.icon-btn:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* Pills / badges / flashes */
.pill {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  background: var(--bg-3); color: var(--fg-2);
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em;
  border: 1px solid var(--border-soft);
}
.pill.stage-new                 { background: #eff6ff; color: #1d4ed8; border-color: #c7d8fb; }
.pill.stage-contacted           { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.pill.stage-responded           { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.pill.stage-left_voicemail      { background: #ffe4e6; color: #9f1239; border-color: #fda4af; }
.pill.stage-in_progress         { background: #e0f2fe; color: #075985; border-color: #7dd3fc; }
.pill.stage-doing_research      { background: #ede9fe; color: #5b21b6; border-color: #c4b5fd; }
.pill.stage-offer_sent          { background: #fef9c3; color: #854d0e; border-color: #fde68a; }
.pill.stage-offer_rejected      { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.pill.stage-under_contract,
.pill.stage-deal_closed         { background: #bbf7d0; color: #14532d; border-color: #86efac; }
.pill.stage-appointment         { background: #cffafe; color: #155e75; border-color: #67e8f9; }
.pill.stage-referred_to_realtor { background: #fae8ff; color: #6b21a8; border-color: #e9d5ff; }
.pill.stage-dead,
.pill.stage-do_not_contact      { background: #f1f5f9; color: #475569; border-color: #cbd5e1; }
.pill.stage-review              { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.pill.lang-es                   { background: #fff7ed; color: #9a3412; border-color: #fed7aa; }
.pill.lang-en                   { background: #ecfeff; color: #155e75; border-color: #a5f3fc; }
.pill.lang-unknown              { background: #f1f5f9; color: #475569; border-color: #cbd5e1; }
.pill.lvl-error, .pill.lvl-critical { background: #fee2e2; color: #7f1d1d; }
.pill.lvl-warn { background: #fef3c7; color: #92400e; }
.pill.lvl-info { background: #dbeafe; color: #1e3a8a; }

.badge { display: inline-block; padding: 2px 6px; border-radius: 5px; font-size: 10.5px; background: var(--bg-3); color: var(--fg-3); font-weight: 600; letter-spacing: .04em; margin-left: 4px; text-transform: uppercase; }
.badge.hot { background: var(--hot); color: #fff; padding: 2px 8px; }
.badge.ok { background: #d1fae5; color: #065f46; }
.badge.danger { background: #fee2e2; color: #991b1b; }
.badge.muted { background: var(--bg-3); color: var(--fg-3); }

.flash { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; border: 1px solid var(--border); font-size: 13px; }
.flash-success { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.flash-error   { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.flash-info    { background: #dbeafe; color: #1e3a8a; border-color: #93c5fd; }

/* Auth */
.auth-body { background: radial-gradient(at 30% 20%, #6366f1 0%, #1e3a8a 50%, #0f172a 100%); min-height: 100vh; display: grid; place-items: center; }
.auth-wrap { width: 100%; max-width: 440px; padding: 24px; }
.auth-card { background: #fff; padding: 36px; border-radius: var(--radius-lg); box-shadow: 0 30px 80px rgba(0,0,0,.32); color: #0f172a; }
.auth-card h2 { margin: 0 0 18px; font-size: 22px; }
.auth-brand { display: flex; align-items: center; gap: .65rem; margin-bottom: 20px; font-weight: 600; font-size: 16px; }
.auth-card label { color: #475569; margin-top: 12px; }
.auth-card .btn-primary { width: 100%; margin-top: 18px; padding: 11px 14px; justify-content: center; }

/* Toolbar */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar h2 { margin: 0; }
.toolbar-form { display: flex; gap: .5rem; flex-wrap: wrap; align-items: end; }
.toolbar-form select, .toolbar-form input { max-width: 220px; }
.pager { display: flex; gap: 6px; padding: 12px 0; }
.pager a { padding: 6px 12px; border: 1px solid var(--border); border-radius: 6px; color: var(--fg-2); font-size: 13px; }
.pager a.on { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ============ LEAD PAGE — the meat ============ */
.lead-header {
  display: flex; justify-content: space-between; align-items: stretch; gap: 24px; flex-wrap: wrap;
  padding: 20px 24px;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
[data-theme="dark"] .lead-header { background: linear-gradient(135deg, #131a32 0%, #1a2244 100%); }
.lead-header-main { flex: 1 1 auto; min-width: 280px; }
.lead-name { margin: 0 0 8px; font-size: 22px; font-weight: 700; letter-spacing: -.01em; display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; }
.lead-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.meta-chip {
  font-size: 12.5px; color: var(--fg-2);
  background: var(--bg-3); border: 1px solid var(--border-soft);
  padding: 4px 10px; border-radius: 999px;
}
.meta-chip.locked { background: #fef9c3; color: #854d0e; border-color: #fde68a; }
.lead-header-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.select-group { display: flex; flex-direction: column; gap: 2px; min-width: 120px; }
.select-group label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; margin: 0; }
.select-group select { padding: 6px 8px; font-size: 13px; }

.contact-list { list-style: none; padding: 0; margin: 0; }
.contact-list li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--border-soft);
}
.contact-list li:last-child { border-bottom: 0; }
.phone-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.phone-num { font-weight: 500; font-size: 14px; color: var(--fg); font-feature-settings: "tnum" 1; }
.phone-tags { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }
.contact-actions { display: flex; gap: 6px; }

.address-line { margin: 8px 0; font-size: 14px; color: var(--fg); }
.streetview-img {
  width: 100%; height: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
}

.edit-block { margin: 8px 0; }
.edit-block summary { cursor: pointer; color: var(--accent); font-size: 12.5px; padding: 4px 0; }
.edit-block summary:hover { color: var(--accent-hi); }
.edit-block form { padding: 10px 0; }

.kv {
  display: grid; grid-template-columns: 120px 1fr; gap: 4px 12px;
  margin: 10px 0 0; font-size: 13px;
}
.kv dt { color: var(--fg-3); font-weight: 500; }
.kv dd { margin: 0; font-weight: 500; color: var(--fg); font-feature-settings: "tnum" 1; }

.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.action-grid .btn { width: 100%; }

/* Pictures */
.pic-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.pic { position: relative; margin: 0; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border-soft); }
.pic img { display: block; width: 100%; height: 110px; object-fit: cover; }
.pic figcaption { padding: 4px 8px; font-size: 11px; background: var(--bg-3); color: var(--fg-3); }
.pic-del {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px; border: none; border-radius: 50%;
  background: rgba(220,38,38,.85); color: #fff; font-weight: 700;
  cursor: pointer; opacity: 0; transition: opacity .15s;
}
.pic:hover .pic-del { opacity: 1; }

.attach-list { list-style: none; padding: 0; margin: 0; }
.attach-list li {
  display: grid; grid-template-columns: 1fr auto auto; gap: 8px;
  align-items: center;
  padding: 6px 0; border-bottom: 1px solid var(--border-soft);
}
.attach-list li:last-child { border-bottom: 0; }

.task-list { list-style: none; padding: 0; margin: 8px 0 0; }
.task-list li {
  display: grid; grid-template-columns: 18px 1fr auto auto; gap: 6px;
  align-items: center;
  padding: 6px 0; border-bottom: 1px solid var(--border-soft);
}
.task-list li.done .task-title { text-decoration: line-through; color: var(--muted); }
.task-title { font-size: 13.5px; }

.notes { list-style: none; padding: 0; margin: 8px 0 0; max-height: 380px; overflow: auto; }
.notes li { padding: 8px 0; border-bottom: 1px dashed var(--border-soft); }
.note-head { margin-bottom: 2px; }
.note-body { white-space: pre-wrap; font-size: 13.5px; }

.timeline { list-style: none; padding: 0; margin: 8px 0 0; max-height: 540px; overflow: auto; font-size: 13px; }
.timeline li {
  display: grid; grid-template-columns: 50px 18px 1fr auto; gap: 6px;
  padding: 6px 0; border-bottom: 1px dashed var(--border-soft);
  align-items: start;
}
.timeline .tl-ch { font-size: 10.5px; font-weight: 700; color: var(--muted); padding-top: 2px; }
.timeline .tl-out .tl-dir { color: var(--accent); }
.timeline .tl-in  .tl-dir { color: var(--ok); }
.timeline .tl-body { word-break: break-word; }

/* Modals */
.modal {
  border: 0; border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-lg);
  width: min(540px, 95vw);
  background: var(--bg-2); color: var(--fg);
}
.modal::backdrop { background: rgba(15,23,42,.4); backdrop-filter: blur(3px); }
.modal h3 { margin: 0 0 14px; }
.modal label { margin-top: 10px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }

/* Permission grid (admin) */
.perm { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; }
.perm input { transform: translateY(2px); }
.perm-label { font-weight: 500; }
.perm-key { font-family: ui-monospace, monospace; }

/* Dialer */
.big-input { font-size: 22px; text-align: center; padding: 12px; font-feature-settings: "tnum" 1; letter-spacing: .04em; }
.dialpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0; }
.dialpad .key { padding: 18px; font-size: 20px; border: 1px solid var(--border); background: var(--bg-2); border-radius: var(--radius-sm); cursor: pointer; transition: background .12s; }
.dialpad .key:hover { background: var(--accent-soft); }
.dialpad .key:active { transform: scale(.97); }
.dialer-actions { display: flex; gap: 8px; align-items: center; }

/* Preview area in templates */
.preview { padding: 12px; background: var(--bg-3); border: 1px dashed var(--border); border-radius: var(--radius-sm); white-space: pre-wrap; min-height: 80px; font-size: 13.5px; }
