:root {
  --green: #2f6b4f;
  --green-dark: #1b3a2c;
  --green-soft: #6b9c7d;
  --cream: #f5f2e9;
  --text: #33362f;
  --muted: #7b7f74;
  --line: #e3dfd2;
  --white: #ffffff;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  background: var(--cream);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--green);
  color: var(--white);
  font-weight: 800;
  font-size: 28px;
  line-height: 46px;
  text-align: center;
  margin: 0 auto 14px;
}
.brand-mark.small { width: 36px; height: 36px; font-size: 21px; line-height: 35px; margin: 0; border-radius: 9px; }

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--green-dark);
}
.login-box {
  background: var(--white);
  padding: 40px 34px 34px;
  border-radius: 16px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.login-box h1 { margin: 0; font-size: 26px; font-weight: 800; color: var(--green-dark); }
.login-sub { margin: 4px 0 26px; color: var(--muted); font-size: 14px; }
.login-box input {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  background: var(--white);
}
.login-box input:focus { outline: none; border-color: var(--green); }
.login-box button { width: 100%; margin-top: 4px; }

.error-text { color: #b3402f; font-size: 13px; margin: 10px 0 0; min-height: 18px; }

.btn {
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 10px 18px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn-primary { background: var(--green); color: var(--white); }
.btn-primary:hover { background: var(--green-dark); }
.btn-ghost { background: transparent; color: var(--green-dark); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--green); }
.btn-danger { background: transparent; color: #b3402f; border-color: #e6c3bb; }
.btn-danger:hover { background: #fbefec; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 32px;
  background: var(--white);
  border-bottom: 1px solid var(--line);
}
.topbar-title { display: flex; align-items: center; gap: 12px; }
.topbar-title h1 { margin: 0; font-size: 18px; font-weight: 800; color: var(--green-dark); line-height: 1.1; }
.topbar-title span { font-size: 12px; color: var(--muted); }
.topbar-actions { display: flex; gap: 10px; }

.content { max-width: 1280px; margin: 0 auto; padding: 28px 32px 60px; }

.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 26px; }
.stat-card { background: var(--white); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; }
.stat-value { font-size: 30px; font-weight: 800; color: var(--green-dark); line-height: 1; }
.stat-label { margin-top: 8px; font-size: 13px; color: var(--muted); }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.tab:hover { color: var(--green-dark); }
.tab.active { background: var(--green); color: var(--white); }

.filters { display: flex; gap: 10px; flex-wrap: wrap; }
.filter-select, .search-input {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 13px;
  background: var(--white);
  color: var(--text);
}
.search-input { min-width: 260px; }
.filter-select:focus, .search-input:focus { outline: none; border-color: var(--green); }

.table-wrap { background: var(--white); border: 1px solid var(--line); border-radius: 14px; overflow-x: auto; }
.leads-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.leads-table th {
  text-align: left;
  padding: 14px 16px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.leads-table td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
.leads-table tbody tr { cursor: pointer; }
.leads-table tbody tr:hover { background: #faf8f2; }
.leads-table tbody tr:last-child td { border-bottom: none; }

.cell-date { white-space: nowrap; color: var(--muted); font-size: 13px; }
.cell-name { font-weight: 700; color: var(--green-dark); }
.cell-city { display: block; font-size: 12px; color: var(--muted); font-weight: 500; margin-top: 2px; }
.cell-contact a { color: var(--text); text-decoration: none; display: block; }
.cell-contact a:hover { color: var(--green); }
.cell-contact .muted { color: var(--muted); font-size: 13px; }
.notes-cell { max-width: 280px; color: var(--muted); font-size: 13px; line-height: 1.45; }

.tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: #ece9dc;
  font-size: 12px;
  font-weight: 600;
  color: var(--green-dark);
  white-space: nowrap;
}

.status-select {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 6px 28px 6px 12px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  appearance: none;
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 8px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23555' stroke-width='1.6'/%3E%3C/svg%3E");
}
.status-nowy { background-color: #e3eefb; color: #2459a3; }
.status-kontakt { background-color: #fbf0d6; color: #8a6313; }
.status-oferta { background-color: #ece3f7; color: #5d3d8c; }
.status-wygrany { background-color: #dcf0e4; color: #1f6b43; }
.status-przegrany { background-color: #efe6e3; color: #8a4a3d; }

.empty-state { text-align: center; padding: 48px 16px; color: var(--muted); margin: 0; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(27, 58, 44, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal-box {
  background: var(--white);
  border-radius: 16px;
  padding: 30px;
  width: 100%;
  max-width: 540px;
  max-height: 92vh;
  overflow-y: auto;
}
.modal-box h2 { margin: 0 0 20px; font-size: 20px; font-weight: 800; color: var(--green-dark); }
.modal-box label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 14px; }
.modal-box input, .modal-box select, .modal-box textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--white);
}
.modal-box textarea { resize: vertical; }
.modal-box input:focus, .modal-box select:focus, .modal-box textarea:focus { outline: none; border-color: var(--green); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modal-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.modal-actions-right { display: flex; gap: 10px; margin-left: auto; }

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 20px 16px 48px; }
  .topbar { padding: 14px 16px; }
  .search-input { min-width: 0; width: 100%; }
  .filters { width: 100%; }
  .filter-select { flex: 1; }
}

@media (max-width: 720px) {
  .leads-table thead { display: none; }
  .leads-table, .leads-table tbody, .leads-table tr, .leads-table td { display: block; width: 100%; }
  .leads-table tr { padding: 14px 16px; border-bottom: 1px solid var(--line); }
  .leads-table td { padding: 4px 0; border: none; }
  .leads-table td::before { content: attr(data-label); display: block; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 8px; }
  .notes-cell { max-width: none; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
}
