:root {
  --bg: #eef3f0;
  --bg-grad-1: #f5faf7;
  --bg-grad-2: #e6eeea;
  --panel: #ffffff;
  --panel-2: #f4f7f5;
  --border: #e3e9e6;
  --text: #17222c;
  --muted: #6b7885;
  --brand: #1f9d6b;
  --brand-2: #17805a;
  --accent: #d9950f;
  --danger: #e05a5a;
  --sidebar: #ffffff;
  --logo-ink: #15412f;
  --logo-ground: #ffffff;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(18, 50, 38, 0.08);
  --shadow-sm: 0 2px 8px rgba(18, 50, 38, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: linear-gradient(160deg, var(--bg-grad-1) 0%, var(--bg-grad-2) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); }

/* ---------- Logo ---------- */
.logo-pin { width: 34px; height: 44px; color: var(--logo-ink); flex: none; }
.brand { display: flex; align-items: center; gap: 11px; }
.brand h1 { font-size: 17px; margin: 0; letter-spacing: .2px; }
.brand small { color: var(--muted); }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(900px 500px at 50% -8%, rgba(31,157,107,0.16) 0%, rgba(31,157,107,0) 60%),
    linear-gradient(160deg, #f6faf8 0%, #e7efeb 100%);
}
.login-card {
  width: 100%;
  max-width: 390px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 34px 30px;
}
.login-card .brand { flex-direction: column; text-align: center; gap: 8px; margin-bottom: 4px; }
.login-card .logo-pin { width: 52px; height: 66px; }
.login-card .brand h1 { font-size: 20px; }
.subtitle { color: var(--muted); font-size: 13px; margin: 4px 0 22px; text-align: center; }

label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
input, select, textarea {
  width: 100%;
  padding: 11px 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(31,157,107,0.12); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 16px;
  background: linear-gradient(180deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #fff;
  border: none;
  border-radius: 9px;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: filter .15s ease;
}
.btn:hover { filter: brightness(1.05); }
.btn.block { width: 100%; margin-top: 20px; }
.btn.ghost { background: #fff; border: 1px solid var(--border); color: var(--text); }
.btn.ghost:hover { background: var(--panel-2); }
.btn.small { padding: 7px 11px; font-size: 13px; }
.btn.danger { background: var(--danger); }

.error { color: var(--danger); font-size: 13px; margin-top: 14px; min-height: 18px; }

/* ---------- App shell with sidebar ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 236px;
  flex: none;
  background: linear-gradient(180deg, #ffffff 0%, #f6faf8 100%);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand { padding: 4px 8px 18px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px;
  border-radius: 9px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px; font-weight: 500;
  cursor: pointer;
}
.nav a:hover { background: var(--panel-2); color: var(--text); }
.nav a.active { background: linear-gradient(180deg, var(--brand) 0%, var(--brand-2) 100%); color: #fff; box-shadow: var(--shadow-sm); }
.nav a .ico { width: 18px; text-align: center; font-size: 16px; }
.sidebar .foot { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 12px; }
.sidebar .who { font-size: 13px; color: var(--text); padding: 0 12px 10px; font-weight: 600; }
.sidebar .who span { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }

.main { flex: 1; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 26px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: rgba(255,255,255,0.75);
  backdrop-filter: blur(8px);
  z-index: 5;
}
.topbar h2 { margin: 0; font-size: 19px; }
.content { padding: 24px 26px; max-width: 1200px; }

.view { display: none; }
.view.active { display: block; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm);
}
.stat .num { font-size: 26px; font-weight: 700; color: var(--brand-2); }
.stat .lbl { color: var(--muted); font-size: 12px; margin-top: 4px; text-transform: uppercase; letter-spacing: .5px; }

.section-title { font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin: 0 0 12px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar input, .toolbar select { width: auto; min-width: 150px; }
.toolbar .spacer { flex: 1; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip {
  padding: 7px 13px; border: 1px solid var(--border); border-radius: 999px;
  background: #fff; color: var(--text); font-size: 13px; font-weight: 500;
  cursor: pointer; font-family: inherit; transition: all .12s ease;
}
.chip:hover { border-color: var(--brand); }
.chip.active { background: linear-gradient(180deg, var(--brand) 0%, var(--brand-2) 100%); color: #fff; border-color: transparent; }
.chip span { margin-left: 5px; color: var(--muted); font-weight: 700; }
.chip.active span { color: rgba(255, 255, 255, 0.9); }

.table-wrap { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow-sm); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; background: var(--panel-2); }
tbody tr:hover { background: #f0f6f3; cursor: pointer; }
tbody tr:last-child td { border-bottom: none; }
.ta-right { text-align: right; }
.when { font-variant-numeric: tabular-nums; color: var(--text); }
.when small { display: block; color: var(--muted); font-size: 11px; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.s-New { background: #e0edff; color: #1d4ed8; }
.s-Contacted { background: #ede9fe; color: #6d28d9; }
.s-Interested { background: #d1fae5; color: #047857; }
.s-SiteVisit { background: #fef3c7; color: #b45309; }
.s-Negotiation { background: #ffedd5; color: #c2410c; }
.s-ClosedWon { background: #dcfce7; color: #15803d; }
.s-ClosedLost { background: #fee2e2; color: #b91c1c; }
.src { color: var(--muted); font-size: 12px; }

.empty { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- Modal ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(20, 35, 28, 0.35);
  display: none; place-items: center; padding: 20px; z-index: 50;
  backdrop-filter: blur(2px);
}
.overlay.show { display: grid; }
.modal {
  width: 100%; max-width: 540px; max-height: 90vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow); padding: 22px;
}
.modal h2 { margin: 0 0 4px; font-size: 18px; }
.modal .muted { color: var(--muted); font-size: 13px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

.activity { margin-top: 10px; }
.activity-item { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.activity-item:last-child { border-bottom: none; }
.activity-item .meta { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ---------- Mobile ---------- */
.menu-toggle { display: none; background: none; border: none; color: var(--text); font-size: 22px; cursor: pointer; }

@media (max-width: 820px) {
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 40;
    transform: translateX(-100%); transition: transform .2s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: block; }
  .row2 { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
}
