:root {
  --bg: #f4f1ea;
  --card: #fffdf8;
  --ink: #14221d;
  --muted: #64736c;
  --line: #ddd7cb;
  --brand: #0b3a2e;
  --brand-2: #14664f;
  --accent: #d5a642;
  --danger: #a63d3d;
  --ok: #1f7a52;
  --warn: #9a6a12;
  --radius: 18px;
  --shadow: 0 18px 45px rgba(20, 34, 29, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(1200px 700px at 85% -10%, #e5efe8 0%, transparent 60%),
    radial-gradient(900px 600px at -10% 100%, #f0e6cf 0%, transparent 55%),
    var(--bg);
  color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; }
.legal { color: var(--muted); font-size: 12px; margin: 18px 0 0; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(440px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 42px 38px;
  box-shadow: var(--shadow);
  text-align: center;
}
.login-card h1 { font-size: 30px; line-height: 1.15; margin: 18px 0 10px; letter-spacing: -.03em; }
.login-widget { min-height: 50px; display: grid; place-items: center; margin: 26px 0 12px; }
.brand-mark {
  width: 56px; height: 56px; margin: 0 auto;
  display: grid; place-items: center;
  border-radius: 17px;
  background: linear-gradient(145deg, var(--brand), var(--brand-2));
  color: #f5e6bd; font-weight: 800; letter-spacing: .04em;
  box-shadow: 0 10px 25px rgba(11, 58, 46, .22);
}
.brand-mark.small { width: 38px; height: 38px; border-radius: 12px; font-size: 12px; margin: 0; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 14px clamp(18px, 4vw, 48px);
  background: rgba(244, 241, 234, .86);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(221, 215, 203, .8);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand strong { display: block; letter-spacing: -.02em; }
.brand .muted { display: block; font-size: 12px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.page { width: min(1180px, 100%); margin: 0 auto; padding: clamp(22px, 4vw, 44px); }
.loading { padding: 80px 0; text-align: center; color: var(--muted); }

.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 24px; }
.hero h1 { margin: 0 0 6px; font-size: clamp(26px, 3.4vw, 42px); letter-spacing: -.04em; line-height: 1.08; }
.eyebrow { margin: 0 0 8px; color: var(--brand-2); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .12em; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.grid { display: grid; gap: 16px; }
.cards { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 22px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 8px 24px rgba(20, 34, 29, .035);
}
.stat-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.stat-value { margin-top: 8px; font-size: 24px; font-weight: 750; letter-spacing: -.03em; }
.stat-note { color: var(--muted); font-size: 12px; margin-top: 5px; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 26px 0 18px; padding: 5px; background: #e9e4d8; border-radius: 14px; width: fit-content; }
.tab { border: 0; background: transparent; color: var(--muted); padding: 9px 16px; border-radius: 10px; font-weight: 650; }
.tab.active { background: var(--card); color: var(--ink); box-shadow: 0 2px 8px rgba(20,34,29,.08); }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.section-head h2 { margin: 0; font-size: 21px; letter-spacing: -.02em; }
.section-head p { margin: 3px 0 0; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; padding: 10px 12px; border-bottom: 1px solid var(--line); }
td { padding: 13px 12px; border-bottom: 1px solid #eee8dc; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.person { display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: #e6eee9; color: var(--brand); font-weight: 750; }
.role, .status { display: inline-flex; align-items: center; border-radius: 999px; padding: 3px 9px; font-size: 11px; font-weight: 700; background: #ede8dc; color: #5d5547; }
.status.ok { background: #e2f1e8; color: var(--ok); }
.status.warn { background: #f6ecd4; color: var(--warn); }
.status.bad { background: #f5e2e2; color: var(--danger); }
.status.info { background: #e3edf4; color: #2b5d7a; }

.btn {
  border: 1px solid transparent; border-radius: 11px; padding: 10px 15px;
  background: var(--brand); color: #fff; font-weight: 650;
  transition: transform .12s ease, background .12s ease, opacity .12s ease;
}
.btn:hover { background: var(--brand-2); transform: translateY(-1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn.secondary { background: #e9e4d8; color: var(--ink); }
.btn.secondary:hover { background: #dfd7c7; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { background: #f0ece2; }
.btn.danger { background: #f5e2e2; color: var(--danger); }
.btn.danger:hover { background: #efd4d4; }
.btn.small { padding: 7px 10px; font-size: 12px; border-radius: 8px; }
.btn.link { background: transparent; color: var(--brand-2); padding: 4px 0; font-weight: 650; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .wide { grid-column: 1 / -1; }
.field label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; background: #fff;
  padding: 10px 11px; color: var(--ink); outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(20,102,79,.12); }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.inline-form .field { min-width: 150px; }
.empty { padding: 34px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 14px; background: #fbf8f1; }

.lead-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.lead-card { background: var(--card); border: 1px solid var(--line); border-radius: 15px; padding: 16px; }
.lead-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.lead-title { font-weight: 700; line-height: 1.35; }
.lead-meta { color: var(--muted); font-size: 12px; margin-top: 5px; }
.lead-price { font-weight: 750; white-space: nowrap; }
.lead-desc { color: #48554f; font-size: 13px; margin: 10px 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.lead-actions { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 10px; }
.contact { background: #eef5f0; border: 1px solid #d5e5da; border-radius: 10px; padding: 10px 12px; margin-top: 10px; font-size: 13px; }
.contact a { color: var(--brand-2); font-weight: 700; }
.contact-row { display: flex; gap: 8px; justify-content: space-between; flex-wrap: wrap; }

.invite-box { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 12px; }
.invite-box input { width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 10px; background: #fff; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #14221d; color: #fff; border-radius: 12px; padding: 11px 16px;
  box-shadow: 0 14px 35px rgba(0,0,0,.22); z-index: 50; max-width: min(520px, 90vw);
}
.toast.bad { background: var(--danger); }
.toast.good { background: var(--ok); }

.notice { border-radius: 14px; padding: 14px 16px; border: 1px solid #e6d6ac; background: #fff7df; color: #6b521a; margin-bottom: 18px; }
.notice strong { display: block; margin-bottom: 3px; }

.filter-row { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-row .field { min-width: 160px; }
.mini-input { width: 78px; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 7px 8px; color: var(--ink); }
.check { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--ink); white-space: nowrap; }
.check input { width: auto; }
td select { max-width: 190px; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 7px 8px; color: var(--ink); }

.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.stat-grid .stat { border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: #fbf8f1; }

.board { display: grid; grid-template-columns: repeat(5, minmax(190px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.board-column { background: #efeadd; border-radius: 13px; padding: 10px; min-height: 140px; }
.board-column h3 { margin: 2px 4px 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.board-card { background: var(--card); border: 1px solid var(--line); border-radius: 11px; padding: 10px; margin-bottom: 8px; box-shadow: 0 3px 10px rgba(20,34,29,.04); }
.board-card select { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 6px; background: #fff; }
@media (max-width: 900px) {
  .board { grid-template-columns: repeat(5, minmax(170px, 1fr)); }
}

@media (max-width: 900px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lead-grid { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .login-card { padding: 32px 22px; }
  .hero { align-items: flex-start; flex-direction: column; }
  .cards { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; }
  .topbar-actions .muted { display: none; }
  th:nth-child(3), td:nth-child(3) { display: none; }
}
