:root {
  color-scheme: light;
  --bg: #f6f7f3;
  --surface: #ffffff;
  --surface-soft: #eef3eb;
  --ink: #1f2a24;
  --muted: #647067;
  --line: #dce3da;
  --accent: #1f7a4d;
  --accent-strong: #135f3a;
  --danger: #b42318;
  --warning: #a15c07;
  --shadow: 0 18px 42px rgba(28, 43, 34, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 700;
  padding: 0 16px;
}

button:hover {
  background: var(--accent-strong);
}

button.secondary {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

button.secondary:hover {
  background: var(--surface-soft);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
}

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 108px;
  padding: 10px 12px;
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
}

.login-brand {
  display: flex;
  min-height: 100%;
  flex-direction: column;
  justify-content: space-between;
  padding: 56px;
  background:
    linear-gradient(145deg, rgba(31, 122, 77, 0.92), rgba(31, 42, 36, 0.94)),
    url("https://images.unsplash.com/photo-1556742502-ec7c0e9f34b1?auto=format&fit=crop&w=1400&q=80");
  background-position: center;
  background-size: cover;
  color: white;
}

.brand-mark {
  width: fit-content;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 6px;
  padding: 10px 12px;
  font-weight: 800;
}

.login-brand h1 {
  max-width: 680px;
  margin: 0;
  font-size: clamp(2.3rem, 6vw, 5.8rem);
  line-height: 0.96;
  letter-spacing: 0;
}

.login-brand p {
  max-width: 620px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 1.08rem;
  line-height: 1.6;
}

.login-panel {
  display: grid;
  align-content: center;
  padding: 48px;
}

.login-card {
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
}

.login-card h2,
.page-title h1 {
  margin: 0;
  font-size: 2rem;
  letter-spacing: 0;
}

.login-card p,
.page-title p {
  color: var(--muted);
  line-height: 1.55;
}

.form-stack {
  display: grid;
  gap: 18px;
  margin-top: 28px;
}

.error {
  min-height: 24px;
  color: var(--danger);
  font-weight: 700;
}

.app-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 264px minmax(0, 1fr);
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #18231d;
  color: white;
  padding: 24px;
}

.sidebar .brand-mark {
  margin-bottom: 32px;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.8);
  padding: 10px 12px;
  text-decoration: none;
}

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

.badge {
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--accent-strong);
  font-size: 0.72rem;
  font-weight: 800;
  padding: 3px 8px;
}

.badge.pending {
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.7);
}

.badge.pending-dark {
  background: #fff3d8;
  color: var(--warning);
}

.main {
  padding: 28px;
}

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

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 700;
}

.avatar {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: white;
}

.stats-grid,
.module-grid {
  display: grid;
  gap: 16px;
}

.stats-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 26px 0;
}

.module-grid {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px;
}

.card h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.metric {
  color: var(--accent-strong);
  font-size: 1.8rem;
  font-weight: 850;
}

.muted {
  color: var(--muted);
}

.users-section,
.split-section {
  margin-top: 32px;
}

.split-section {
  display: grid;
  gap: 18px;
}

.toolbar {
  display: flex;
  align-items: end;
  gap: 12px;
  margin: 16px 0;
}

.toolbar label {
  min-width: 180px;
}

.data-form {
  box-shadow: none;
}

.data-form h2,
.card h2 {
  margin-top: 0;
}

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

.full-span {
  grid-column: 1 / -1;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 8px;
  background: var(--surface);
}

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

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

.clients-table th:first-child,
.clients-table td:first-child {
  width: 84px;
}

.clients-table img.client-photo,
.client-photo {
  display: block;
  width: 64px;
  max-width: 64px;
  height: 64px;
  max-height: 64px;
  border-radius: 8px;
  object-fit: cover;
}

.photo-placeholder {
  display: inline-grid;
  width: 64px;
  height: 64px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.72rem;
  text-align: center;
}

.map-picker {
  display: grid;
  gap: 12px;
}

.map-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.map-picker-header div {
  display: grid;
  gap: 4px;
}

.map-picker-header span,
.map-empty,
.map-status {
  color: var(--muted);
  font-size: 0.9rem;
}

.map-status {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  padding: 10px 12px;
}

.client-map,
.map-empty {
  width: 100%;
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-soft);
}

.map-empty {
  display: grid;
  min-height: 160px;
  place-items: center;
  padding: 18px;
  text-align: center;
}

@media (max-width: 900px) {
  .login-shell,
  .app-shell {
    grid-template-columns: 1fr;
  }

  .login-brand {
    min-height: 42vh;
    padding: 32px;
  }

  .login-panel,
  .main {
    padding: 24px;
  }

  .sidebar {
    padding: 18px;
  }

  .nav-list {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toolbar {
    display: grid;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .map-picker-header {
    align-items: stretch;
    flex-direction: column;
  }
}

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

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }
}
