:root {
  --bg: #f4f7f9;
  --panel: #ffffff;
  --text: #17212b;
  --muted: #6d7a86;
  --primary: #00a6b4;
  --primary-dark: #007b85;
  --border: #dce5ea;
  --danger: #c93535;
  --dark: #0b1117;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.crm-shell {
  display: flex;
  min-height: 100vh;
}

.hidden { display: none !important; }

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #0b1117, #003c43);
}

.login-card {
  width: min(430px, 94vw);
  background: white;
  border-radius: 24px;
  padding: 30px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}

.login-logo {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  background: var(--primary);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 800;
  margin-bottom: 18px;
}

.login-card form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.login-help {
  margin-top: 18px;
  background: #eef7f8;
  border: 1px solid #ccecef;
  border-radius: 14px;
  padding: 14px;
  color: var(--text);
}

code {
  background: #dfe8ec;
  padding: 2px 5px;
  border-radius: 6px;
}

.sidebar {
  width: 275px;
  background: var(--dark);
  color: white;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--primary);
  display: grid;
  place-items: center;
  font-weight: 800;
}

.brand span, .storage-note p, .user-box span {
  display: block;
  color: #b8c2cc;
  font-size: 13px;
  margin-top: 4px;
}

.user-box {
  border: 1px solid rgba(255,255,255,0.12);
  padding: 14px;
  border-radius: 14px;
}

nav {
  display: grid;
  gap: 8px;
}

.nav-btn {
  border: 0;
  background: transparent;
  color: #cbd5df;
  text-align: left;
  padding: 13px 14px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 15px;
}

.nav-btn:hover, .nav-btn.active {
  background: rgba(255,255,255,0.1);
  color: white;
}

.storage-note {
  margin-top: auto;
  border: 1px solid rgba(255,255,255,0.12);
  padding: 14px;
  border-radius: 14px;
}

.full {
  width: 100%;
  margin-top: 10px;
}

.app {
  flex: 1;
  padding: 28px;
  overflow: auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 24px;
}

h1, h2, p { margin-top: 0; }
.topbar p { color: var(--muted); }

.top-actions, .toolbar, .section-header {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

button, input, select, textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 10px;
  padding: 11px 14px;
  cursor: pointer;
  font-weight: 700;
}

.primary {
  background: var(--primary);
  color: white;
}

.primary:hover { background: var(--primary-dark); }

.secondary {
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
}

.danger {
  background: var(--danger);
  color: white;
}

.icon {
  background: transparent;
  font-size: 26px;
  padding: 0 8px;
}

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

.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 16px;
}

.card, .panel, .table-wrap, dialog {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(11,17,23,0.05);
}

.card { padding: 20px; }

.card span {
  color: var(--muted);
  font-size: 14px;
}

.card strong {
  display: block;
  font-size: 34px;
  margin-top: 8px;
}

.grid-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 20px;
}

.panel {
  padding: 20px;
  margin-bottom: 18px;
}

.toolbar { margin-bottom: 14px; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: white;
}

.toolbar input { max-width: 460px; }
.toolbar select { max-width: 240px; }

textarea {
  min-height: 90px;
  resize: vertical;
}

.table-wrap { overflow: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 850px;
}

th, td {
  text-align: left;
  padding: 14px;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
}

.badge {
  display: inline-block;
  padding: 6px 9px;
  border-radius: 999px;
  background: #e9f7f8;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 700;
}

.actions {
  display: flex;
  gap: 8px;
}

.actions button { padding: 8px 10px; }

.kanban {
  display: grid;
  grid-template-columns: repeat(6, minmax(230px, 1fr));
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 12px;
}

.column {
  background: #eaf0f4;
  border-radius: 16px;
  padding: 12px;
  min-height: 400px;
}

.column h3 {
  margin: 4px 4px 12px;
  font-size: 15px;
}

.lead-card, .item {
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 10px;
}

.lead-card strong, .item strong {
  display: block;
  margin-bottom: 6px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 12px;
}

dialog {
  width: min(760px, 94vw);
  padding: 0;
}

dialog::backdrop { background: rgba(0,0,0,0.45); }

#leadForm {
  padding: 22px;
  display: grid;
  gap: 14px;
}

.modal-head, .modal-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

@media (max-width: 900px) {
  .crm-shell { flex-direction: column; }
  .sidebar { width: 100%; }
  .cards, .grid-two, .form-grid { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; flex-direction: column; }
}


.city-groups {
  display: grid;
  gap: 18px;
}

.city-group {
  background: white;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 10px 30px rgba(11,17,23,0.05);
}

.city-group h2 {
  margin-bottom: 14px;
}

.client-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.client-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}

.client-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(11,17,23,0.09);
}

.client-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.client-card h3 {
  margin: 0 0 8px;
}

.client-meta {
  display: grid;
  gap: 5px;
  margin-top: 10px;
}

.wide-dialog {
  width: min(1050px, 96vw);
  max-height: 92vh;
  overflow: auto;
}

.client-detail {
  padding: 24px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.detail-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  background: #f8fbfc;
}

.detail-card span {
  color: var(--muted);
  font-size: 13px;
}

.detail-card strong {
  display: block;
  margin-top: 6px;
}

.no-shadow {
  box-shadow: none;
}

.detail-list {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.detail-row span {
  color: var(--muted);
}

.quick-form {
  display: grid;
  gap: 10px;
}

.timeline {
  position: relative;
  display: grid;
  gap: 12px;
}

.timeline-item {
  border-left: 4px solid var(--primary);
  background: #f8fbfc;
  border-radius: 12px;
  padding: 14px 14px 14px 16px;
}

.timeline-item strong {
  display: block;
  margin-bottom: 4px;
}

@media (max-width: 900px) {
  .detail-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 520px) {
  .detail-grid {
    grid-template-columns: 1fr;
  }
}
