:root {
  --bg: #f6f8fc;
  --panel: #ffffff;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #475569;
  --border: rgba(15, 23, 42, 0.12);
  --link: #0f172a;
  --accent: #1d4ed8;
  --accent-2: #0b2a6b;
  --danger: #dc2626;
  --danger-bg: rgba(220, 38, 38, 0.10);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: radial-gradient(1100px 700px at 10% 0%, #e8efff 0%, var(--bg) 55%);
  color: var(--text);
}

.crmLayout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 16px;
  width: 100%;
  padding: 0 16px;
}

.crmSidebar {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(8px);
  border-radius: 14px;
  padding: 14px 12px;
  position: sticky;
  top: 16px;
  height: fit-content;
}

.crmSidebar__title {
  font-weight: 800;
  letter-spacing: 0.2px;
  padding: 6px 10px 10px;
}

.crmSidebar__nav {
  display: grid;
  gap: 6px;
}

.crmSidebar__nav a {
  display: block;
  padding: 10px 10px;
  border-radius: 12px;
  font-size: 14px;
}

.crmSidebar__nav a:hover {
  text-decoration: none;
  background: rgba(15, 23, 42, 0.05);
}

.crmContent {
  min-width: 0;
}

.crmAgencyCards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 12px;
}

.crmAgencyCard {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  border-radius: 14px;
  padding: 14px;
}

.crmAgencyCard__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.crmAgencyCard__grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
}

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

.crmTopRow {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.crmHamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
}

.crmHamburger:hover {
  cursor: pointer;
  background: rgba(15, 23, 42, 0.04);
}

.crmSidebarOverlay {
  display: none;
}

html.crm-sidebar-open .crmSidebarOverlay {
  display: block;
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.container {
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar {
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(8px);
}

.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
}

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

.brand__logo {
  width: 36px;
  height: 36px;
}

.brand__name {
  font-weight: 650;
  letter-spacing: 0.2px;
  line-height: 1.2;
}

.topnav {
  display: flex;
  gap: 14px;
  font-size: 14px;
}

.topnav a {
  padding: 8px 10px;
  border-radius: 10px;
}

.topnav a:hover {
  text-decoration: none;
  background: rgba(15, 23, 42, 0.05);
}

.main {
  padding: 28px 0 48px;
}

.main--full {
  width: calc(100% - 32px);
  margin: 0 auto;
  max-width: none;
}

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

.panel {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  border-radius: 14px;
  padding: 18px;
  margin-top: 16px;
}

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

.panel__row h2 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0.2px;
}

.panel h1 {
  margin-top: 0;
}

.kv {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.02);
}

.kv__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.kv__k {
  color: var(--muted);
  font-weight: 600;
}

.kv__v {
  font-weight: 700;
}

.row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}

.form {
  display: grid;
  gap: 12px;
  max-width: 560px;
}

.select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
}

.hero {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 18px;
  align-items: stretch;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.78) 100%);
  border-radius: 14px;
  padding: 18px;
}

.hero h1 {
  margin: 0 0 6px;
  font-size: 28px;
  letter-spacing: -0.2px;
}

.hero__actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.hero__media {
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.03);
  overflow: hidden;
}

.hero__mediaInner {
  width: 100%;
  height: 100%;
  min-height: 140px;
  background-size: cover;
  background-position: center;
  filter: saturate(1.02) contrast(1.02);
}

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

.tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

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

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

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

.sectionTitle {
  margin: 22px 0 0;
  font-size: 16px;
  letter-spacing: 0.2px;
}

.searchbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
  flex-wrap: wrap;
}

.input {
  flex: 1;
  min-width: 220px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
}

.tableWrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th,
.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.table th {
  text-align: left;
  color: var(--muted);
  font-weight: 700;
  background: rgba(15, 23, 42, 0.02);
  position: sticky;
  top: 0;
}

.agencyNameCell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.crmTypeIcon {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.9);
  color: var(--accent-2);
  flex: 0 0 auto;
}

.crmTypeIcon--fire {
  background: var(--danger-bg);
  color: var(--danger);
}

.crmTypeIcon--law {
  background: rgba(29, 78, 216, 0.08);
  color: var(--accent);
}

.crmTypeIcon--ngo {
  background: rgba(15, 23, 42, 0.04);
  color: var(--text);
}

.crmTypeIcon--other {
  background: rgba(15, 23, 42, 0.04);
  color: var(--muted);
}

.leafletMap {
  height: 380px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.table tr:last-child td {
  border-bottom: none;
}

.tile {
  display: grid;
  place-items: center;
  gap: 10px;
  padding: 18px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  text-align: center;
}

.tile:hover {
  text-decoration: none;
  border-color: rgba(29, 78, 216, 0.35);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

.tile__icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: rgba(29, 78, 216, 0.10);
  color: var(--accent-2);
  font-size: 22px;
}

.tile__label {
  font-weight: 700;
  letter-spacing: 0.2px;
}

.card {
  display: block;
  padding: 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
}

.card:hover {
  text-decoration: none;
  border-color: rgba(29, 78, 216, 0.35);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

.card h2 {
  margin: 0 0 6px;
  font-size: 18px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
}

.btn--primary {
  background: var(--accent);
  color: #ffffff;
  border-color: transparent;
}

.btn--primary:hover {
  text-decoration: none;
  background: #1a43bd;
}

.footer {
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.82);
}

.footer__inner {
  padding: 14px 0;
  font-size: 13px;
}

.auth {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  border-radius: 14px;
  padding: 18px;
  margin-top: 18px;
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}

.auth__brand {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.auth__brand h1 {
  margin: 10px 0 6px;
  font-size: 22px;
  line-height: 1.2;
  text-wrap: balance;
}

.auth__logo {
  width: clamp(140px, 30vw, 384px);
  height: clamp(140px, 30vw, 384px);
}

.auth__form {
  display: grid;
  gap: 12px;
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}

.auth__form .btn {
  width: 100%;
}

.field {
  display: grid;
  gap: 6px;
}

.field input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
}

.field input:focus {
  outline: none;
  border-color: rgba(29, 78, 216, 0.55);
  box-shadow: 0 0 0 4px rgba(29, 78, 216, 0.12);
}

.alert {
  border: 1px solid rgba(255, 120, 120, 0.35);
  background: rgba(255, 120, 120, 0.12);
  padding: 10px 12px;
  border-radius: 10px;
}

.error {
  color: #ffd0d0;
}

@media (max-width: 820px) {
  .crmLayout {
    grid-template-columns: 1fr;
    padding: 0 16px;
  }

  .crmSidebar {
    position: fixed;
    left: 16px;
    right: 16px;
    top: 16px;
    max-height: calc(100vh - 32px);
    overflow: auto;
    z-index: 50;
    transform: translateY(-130%);
    transition: transform 160ms ease-out;
  }

  html.crm-sidebar-open .crmSidebar {
    transform: translateY(0);
  }

  .crmSidebarOverlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    z-index: 40;
  }

  html.crm-sidebar-open {
    overflow: hidden;
  }

  .crmHamburger {
    display: inline-flex;
  }

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

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

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

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

  .row {
    grid-template-columns: 1fr;
  }
  .auth {
    grid-template-columns: 1fr;
  }

  .auth__brand h1 {
    font-size: 20px;
  }
  .topbar__inner {
    align-items: flex-start;
  }

  .brand__name {
    font-size: 14px;
  }
}

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