:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e4e7ec;
  --text: #1a2230;
  --muted: #6b7686;
  --primary: #2f6f4f;
  --primary-dark: #245a40;
  --primary-soft: #e7f1ec;
  --danger: #c0392b;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.18);
  --radius: 10px;
  --sidebar-w: 240px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
.muted { color: var(--muted); font-size: 13px; margin: 4px 0 0; }

/* ---------- Buttons / inputs ---------- */
.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { color: var(--danger); border-color: #f0c9c4; background: #fdf3f2; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 11px; font-size: 13px; }

.input, input[type="text"], input[type="password"], input[type="email"],
input[type="tel"], input[type="number"], input[type="search"], textarea, select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}
.input:focus, input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
textarea { resize: vertical; min-height: 72px; }
.search { max-width: 240px; }

.link-btn {
  background: none; border: none; color: var(--muted);
  padding: 0; font-size: 12px; cursor: pointer; text-align: left;
}
.link-btn:hover { color: var(--primary); text-decoration: underline; }
.icon-btn {
  background: none; border: none; cursor: pointer; font-size: 18px;
  color: var(--muted); padding: 4px 8px; border-radius: 6px;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.form-error {
  color: var(--danger); font-size: 13px; margin: 0;
  background: #fdf3f2; border: 1px solid #f0c9c4; padding: 8px 11px; border-radius: 8px;
}

/* ---------- Login ---------- */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
  background: linear-gradient(135deg, #eef2f0 0%, #e3ebe6 100%);
}
.login-card {
  width: 100%; max-width: 380px; background: var(--surface);
  border-radius: 16px; box-shadow: var(--shadow-lg); padding: 36px 32px;
}
.login-brand { text-align: center; margin-bottom: 24px; }
.login-brand h1 { font-size: 22px; margin-top: 12px; }
.login-brand p { color: var(--muted); font-size: 14px; margin: 4px 0 0; }
.login-logo {
  width: 48px; height: 48px; border-radius: 12px; margin: 0 auto;
  background: var(--primary); color: #fff; display: flex;
  align-items: center; justify-content: center; font-size: 24px; font-weight: 700;
}
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 550; }

/* ---------- App layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: #16261d; color: #d8e2dc;
  display: flex; flex-direction: column; padding: 20px 14px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; font-weight: 650; padding: 4px 8px 20px; }
.sidebar-brand .login-logo { width: 32px; height: 32px; font-size: 17px; border-radius: 8px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: none; border: none; color: #b6c6bd; padding: 10px 12px;
  border-radius: 8px; font-size: 14px; font-weight: 550; cursor: pointer;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.12); color: #fff; }
.nav-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .5; }
.nav-item.active .nav-dot { opacity: 1; background: #7bd6a3; }

.sidebar-user {
  display: flex; align-items: center; gap: 10px; padding: 12px 8px 4px;
  border-top: 1px solid rgba(255,255,255,.08); margin-top: 12px;
}
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: var(--primary); color: #fff; display: flex; align-items: center;
  justify-content: center; font-weight: 600; font-size: 14px;
}
.user-meta { flex: 1; display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.user-meta strong { font-size: 13px; color: #fff; }
.sidebar-user .icon-btn { color: #b6c6bd; }
.sidebar-user .icon-btn:hover { background: rgba(255,255,255,.1); color: #fff; }

.main { flex: 1; padding: 28px 32px; min-width: 0; }
.view-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: 22px; gap: 16px; flex-wrap: wrap;
}
.view-header h2 { font-size: 22px; }
.view-actions { display: flex; gap: 10px; align-items: center; }

/* ---------- Contacts list ---------- */
.card-list { display: flex; flex-direction: column; gap: 8px; }
.contact-row {
  display: flex; align-items: center; gap: 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 18px; cursor: pointer; box-shadow: var(--shadow); transition: border-color .15s;
}
.contact-row:hover { border-color: #c9d2cd; }
.contact-row .avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  background: var(--primary-soft); color: var(--primary); display: flex;
  align-items: center; justify-content: center; font-weight: 600;
}
.contact-row .info { flex: 1; min-width: 0; }
.contact-row .info strong { display: block; }
.contact-row .info span { color: var(--muted); font-size: 13px; }
.contact-row .contact-meta { color: var(--muted); font-size: 13px; text-align: right; }

.empty {
  text-align: center; color: var(--muted); padding: 60px 20px;
  background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius);
}

/* ---------- Pipeline board ---------- */
.board { display: flex; gap: 14px; align-items: flex-start; overflow-x: auto; padding-bottom: 12px; }
.board-col {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  width: 260px; flex-shrink: 0; display: flex; flex-direction: column; max-height: calc(100vh - 160px);
}
.board-col-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; font-weight: 600; font-size: 13px; position: sticky; top: 0;
}
.board-col-head .count {
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
  border-radius: 20px; padding: 1px 8px; font-size: 12px; font-weight: 600;
}
.board-col-body { padding: 0 10px 10px; overflow-y: auto; flex: 1; min-height: 40px; }
.board-col.drag-over { outline: 2px dashed var(--primary); outline-offset: -4px; }
.col-sum { font-size: 12px; color: var(--muted); padding: 0 14px 10px; }

.deal-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 11px 12px; margin-bottom: 8px; box-shadow: var(--shadow); cursor: grab;
}
.deal-card:active { cursor: grabbing; }
.deal-card.dragging { opacity: .4; }
.deal-card strong { display: block; font-size: 14px; }
.deal-card .deal-contact { color: var(--muted); font-size: 12px; margin-top: 2px; }
.deal-card .deal-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.deal-card .deal-value { font-weight: 650; font-size: 13px; color: var(--primary); }
.pill {
  font-size: 11px; background: var(--primary-soft); color: var(--primary);
  border-radius: 20px; padding: 1px 8px; font-weight: 600;
}

/* ---------- Overlay / panel / modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(16,24,40,.45); z-index: 40; }
.panel {
  position: fixed; top: 0; right: 0; height: 100vh; width: 440px; max-width: 92vw;
  background: var(--surface); box-shadow: var(--shadow-lg); z-index: 50;
  display: flex; flex-direction: column; animation: slideIn .2s ease;
}
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 22px; border-bottom: 1px solid var(--border);
}
.panel-body { padding: 22px; overflow-y: auto; flex: 1; }
.panel-section { margin-bottom: 26px; }
.panel-section h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 10px; }

.field-grid { display: flex; flex-direction: column; gap: 6px; }
.field-grid .row { display: flex; gap: 8px; align-items: baseline; padding: 7px 0; border-bottom: 1px solid var(--surface-2); }
.field-grid .row .k { width: 90px; flex-shrink: 0; color: var(--muted); font-size: 13px; }
.field-grid .row .v { flex: 1; word-break: break-word; }
.field-grid .row .v a { color: var(--primary); }

.note { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.note .note-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.note .note-body { white-space: pre-wrap; font-size: 14px; }

.modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 460px; max-width: 92vw; max-height: 90vh; overflow-y: auto;
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); z-index: 50;
}
.modal-head { padding: 20px 22px 0; }
.modal-head h3 { font-size: 18px; }
.modal-body { padding: 18px 22px; display: flex; flex-direction: column; gap: 14px; }
.modal-body label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 550; }
.modal-foot { padding: 0 22px 22px; display: flex; justify-content: space-between; gap: 10px; }
.modal-foot .right { display: flex; gap: 10px; margin-left: auto; }

@media (max-width: 720px) {
  .sidebar { width: 64px; }
  .sidebar-brand span, .nav-item, .user-meta { display: none; }
  .sidebar-nav .nav-item { display: flex; justify-content: center; }
  .nav-item span:last-child { display: none; }
  .main { padding: 20px 16px; }
}
