/* Real Estate CRM — web app styles.
   Theme: white + deep navy (#131a24) with one accent (emerald #1b9e57).
   Vanilla CSS only; layout = sidebar + topbar shell, responsive down to
   phone widths (the sales team works on phones). */
:root {
  --navy: #131a24;
  --navy-2: #1c2735;
  --accent: #1b9e57;
  --accent-dark: #14743f;
  --bg: #eef1f5;
  --card: #ffffff;
  --ink: #1c2735;
  --muted: #68768a;
  --line: #dde3ec;
  --red: #d64545;
  --red-bg: #fbe9e6;
  --amber: #b7791f;
  --amber-bg: #fdf0d8;
  --green-bg: #e5f5ec;
  --blue-bg: #e3ecfd;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(19, 26, 36, .08), 0 4px 14px rgba(19, 26, 36, .05);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.45;
}
a { color: var(--accent-dark); }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }
h1, h2, h3 { margin: 0; }
.hidden { display: none !important; }

/* ── Buttons / forms ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); border-radius: 9px; padding: 8px 14px;
  font-weight: 600; font-size: 14px; text-decoration: none; transition: background .15s, border-color .15s;
}
.btn:hover { border-color: #c3cdda; background: #f7f9fc; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger:hover { background: #b93636; }
.btn.small { padding: 5px 10px; font-size: 13px; border-radius: 7px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.block { width: 100%; justify-content: center; }
.field { margin-bottom: 13px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px;
  background: #fff; color: var(--ink); outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(27, 158, 87, .15); }
.field textarea { resize: vertical; min-height: 64px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-error {
  background: var(--red-bg); color: #8f2b2b; border: 1px solid #f2c4bd;
  border-radius: 9px; padding: 10px 12px; margin-bottom: 14px; font-size: 14px;
}
.form-warn {
  background: var(--amber-bg); color: #7c5410; border: 1px solid #ecd29c;
  border-radius: 9px; padding: 10px 12px; margin-bottom: 14px; font-size: 14px;
}
.form-warn .actions { margin-top: 9px; display: flex; gap: 8px; }

/* ── Auth screens ────────────────────────────────────────────────── */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(160deg, var(--navy) 0%, var(--navy-2) 60%, #24344a 100%); }
.auth-card { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); width: 100%; max-width: 400px; padding: 34px 30px; }
.auth-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.auth-logo img { width: 38px; height: 38px; }
.auth-logo span { font-size: 20px; font-weight: 700; color: var(--navy); }
.auth-sub { color: var(--muted); font-size: 14px; margin: 0 0 22px; }

/* ── App shell ───────────────────────────────────────────────────── */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex: 0 0 232px; background: var(--navy); color: #cfd8e3;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; font-weight: 700; font-size: 16px; }
.brand img { width: 30px; height: 30px; }
.nav { padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav a {
  color: #cfd8e3; text-decoration: none; padding: 10px 12px; border-radius: 9px;
  font-size: 14.5px; font-weight: 500; display: flex; align-items: center; gap: 10px;
}
.nav a:hover { background: var(--navy-2); color: #fff; }
.nav a.active { background: var(--accent); color: #fff; }
.nav a .badge { margin-left: auto; }
.sidebar-foot { margin-top: auto; padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; color: #8fa0b5; }
.sidebar-foot .who { color: #fff; font-weight: 600; font-size: 14px; }
.badge {
  background: var(--red); color: #fff; border-radius: 999px; font-size: 11.5px; font-weight: 700;
  min-width: 20px; height: 20px; padding: 0 6px; display: inline-flex; align-items: center; justify-content: center;
}
.badge.gray { background: #42536a; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--card); border-bottom: 1px solid var(--line); padding: 12px 22px;
  display: flex; align-items: center; gap: 14px; position: sticky; top: 0; z-index: 30;
}
.topbar h1 { font-size: 19px; color: var(--navy); }
.topbar .spacer { flex: 1; }
.icon-btn {
  position: relative; border: 1px solid var(--line); background: #fff; border-radius: 9px;
  width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center; font-size: 17px;
}
.icon-btn .badge { position: absolute; top: -7px; right: -7px; }
.hamburger { display: none; }
.content { padding: 22px; max-width: 1280px; width: 100%; margin: 0 auto; }
.scrim { display: none; }

/* ── Cards / KPI / panels ────────────────────────────────────────── */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card h3 { font-size: 15px; color: var(--navy); margin-bottom: 12px; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.kpi .num { font-size: 30px; font-weight: 700; color: var(--navy); line-height: 1.1; }
.kpi .lbl { color: var(--muted); font-size: 13.5px; font-weight: 600; margin-top: 3px; }
.kpi.red .num { color: var(--red); }
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px;
  font-size: 13.5px; font-weight: 600; color: var(--ink); text-decoration: none;
}
.chip b { color: var(--accent-dark); }
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { padding: 9px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: baseline; }
.mini-list li:last-child { border-bottom: none; }
.mini-list .when { margin-left: auto; color: var(--muted); font-size: 13px; white-space: nowrap; }
.empty { color: var(--muted); font-size: 14px; padding: 8px 0; }
.overdue-text { color: var(--red); font-weight: 600; }

/* ── Tables ──────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table.grid { width: 100%; border-collapse: collapse; min-width: 640px; }
table.grid th {
  text-align: left; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.grid td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid tbody tr { cursor: pointer; }
table.grid tbody tr:hover { background: #f7f9fc; }
table.grid tbody tr.no-click { cursor: default; }
.pill { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.pill.green { background: var(--green-bg); color: var(--accent-dark); }
.pill.amber { background: var(--amber-bg); color: var(--amber); }
.pill.red { background: var(--red-bg); color: var(--red); }
.pill.blue { background: var(--blue-bg); color: #2b50a6; }
.pill.gray { background: var(--bg); color: var(--muted); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar input[type="search"], .toolbar select {
  border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px; background: #fff;
}
.toolbar input[type="search"] { min-width: 210px; }
.toolbar .spacer { flex: 1; }
.pager { display: flex; align-items: center; gap: 12px; margin-top: 14px; color: var(--muted); font-size: 14px; }

/* ── Lead detail ─────────────────────────────────────────────────── */
.detail-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 16px; }
.detail-head h2 { font-size: 22px; color: var(--navy); }
.detail-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px; align-items: start; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; border-left: 2px solid var(--line); margin-left: 5px; }
.timeline li:last-child { border-left-color: transparent; }
.timeline .dot {
  position: absolute; left: -6px; top: 3px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line);
}
.timeline .t-title { font-weight: 600; font-size: 14.5px; }
.timeline .t-meta { color: var(--muted); font-size: 12.5px; }
.timeline .t-body { font-size: 14px; margin-top: 3px; white-space: pre-wrap; word-break: break-word; }
.tabs-note { display: grid; gap: 12px; }

/* ── Pipeline (Kanban) ───────────────────────────────────────────── */
.board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 14px; align-items: flex-start; }
.column {
  flex: 0 0 272px; width: 272px; background: #f7f9fc; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px; min-height: 120px;
}
.column.drag-over { border-color: var(--accent); background: var(--green-bg); }
.column h3 { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--navy); margin-bottom: 10px; }
.column h3 .count { background: var(--navy); color: #fff; border-radius: 999px; font-size: 12px; padding: 1px 8px; }
.deal-card {
  background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px;
  margin-bottom: 10px; box-shadow: 0 1px 2px rgba(19,26,36,.05); cursor: grab;
}
.deal-card:active { cursor: grabbing; }
.deal-card .t { font-weight: 600; font-size: 14.5px; margin-bottom: 3px; }
.deal-card .s { color: var(--muted); font-size: 13px; }
.deal-card .v { color: var(--accent-dark); font-weight: 700; font-size: 13.5px; margin-top: 5px; }
.deal-card select { width: 100%; margin-top: 9px; border: 1px solid var(--line); border-radius: 7px; padding: 5px 7px; font-size: 13px; background: #fff; }
.stale-flag { color: var(--red); font-size: 12px; font-weight: 700; }

/* ── Tasks / notifications ───────────────────────────────────────── */
.task-row { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.task-row:last-child { border-bottom: none; }
.task-row .grow { flex: 1; min-width: 0; }
.task-row .title { font-weight: 600; }
.task-row.done .title { text-decoration: line-through; color: var(--muted); }
.task-row .meta { color: var(--muted); font-size: 13px; }
.notif-row { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.notif-row:last-child { border-bottom: none; }
.notif-row .grow { flex: 1; min-width: 0; }
.notif-row .title { font-weight: 600; font-size: 14.5px; }
.notif-row .body { color: var(--muted); font-size: 13.5px; }
.notif-row .when { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.unread-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); margin-top: 6px; flex: 0 0 9px; }
.read-dot { width: 9px; flex: 0 0 9px; }

/* ── Modal ───────────────────────────────────────────────────────── */
.modal-back {
  position: fixed; inset: 0; background: rgba(19, 26, 36, .5); z-index: 80;
  display: flex; align-items: flex-start; justify-content: center; padding: 26px 14px; overflow-y: auto;
}
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 560px; padding: 22px;
  box-shadow: var(--shadow);
}
.modal h3 { font-size: 17px; color: var(--navy); margin-bottom: 14px; }
.modal .row-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* ── Toasts ──────────────────────────────────────────────────────── */
#toast-root { position: fixed; bottom: 18px; right: 18px; z-index: 120; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--navy); color: #fff; border-radius: 10px; padding: 11px 16px; font-size: 14px;
  box-shadow: var(--shadow); max-width: 340px; animation: toast-in .18s ease-out;
}
.toast.error { background: var(--red); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 1020px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-grid, .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .sidebar {
    position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; background: rgba(19,26,36,.45); z-index: 35; }
  .hamburger { display: inline-flex; }
  .content { padding: 14px; }
  .topbar { padding: 10px 14px; }
  .form-grid { grid-template-columns: 1fr; }
  .column { flex-basis: 240px; width: 240px; }
  .auth-card { padding: 26px 20px; }
}
