* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: #f6f7f8;
  color: #18212f;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

a {
  text-decoration: none;
}

.shell {
  min-height: 100vh;
}

.topbar {
  align-items: center;
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  padding: 22px 28px;
}

.topbar h1 {
  font-size: 24px;
  line-height: 1.2;
  margin: 0;
}

.topbar p,
.panel-head p,
.stat-card span,
.city-head p,
.module-row em {
  color: #667085;
}

.topbar p,
.panel-head p {
  font-size: 13px;
  line-height: 1.5;
  margin: 6px 0 0;
}

.actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.checkbox {
  align-items: center;
  color: #475467;
  display: inline-flex;
  font-size: 14px;
  gap: 6px;
}

.primary-button,
.secondary-button {
  align-items: center;
  border-radius: 8px;
  display: inline-flex;
  font-size: 14px;
  justify-content: center;
  min-height: 38px;
  padding: 0 16px;
}

.primary-button {
  background: #0f766e;
  color: #ffffff;
}

.primary-button:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

.secondary-button {
  background: #eef2f7;
  color: #344054;
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

main {
  padding: 24px 28px 48px;
}

.message {
  border-radius: 8px;
  margin-bottom: 18px;
  padding: 12px 14px;
  background: #eef2ff;
  color: #3730a3;
}

.message.success {
  background: #ecfdf3;
  color: #027a48;
}

.message.error {
  background: #fef3f2;
  color: #b42318;
}

.stats-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
}

.city-count-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.stat-card,
.panel,
.city-card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

.stat-card {
  padding: 16px;
}

.stat-card span {
  display: block;
  font-size: 13px;
  margin-bottom: 8px;
}

.stat-card strong {
  color: #101828;
  display: block;
  font-size: 20px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.panel {
  margin-top: 18px;
  padding: 18px;
}

.panel-head {
  align-items: start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 14px;
}

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

.status-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status-lines {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.status-lines div {
  background: #f8fafc;
  border-radius: 8px;
  padding: 12px;
}

.status-lines span {
  color: #667085;
  display: block;
  font-size: 12px;
  margin-bottom: 6px;
}

.status-lines strong {
  color: #18212f;
  display: block;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.pill,
.city-code,
.module-row strong {
  border-radius: 6px;
  font-size: 12px;
  padding: 5px 8px;
}

.pill,
.module-row strong {
  background: #eef2f7;
  color: #344054;
}

.pill.ok,
.module-row strong.ok {
  background: #ecfdf3;
  color: #027a48;
}

.pill.unavailable,
.module-row strong.unavailable,
.pill.failed,
.module-row strong.failed {
  background: #fef3f2;
  color: #b42318;
}

.pill.not_configured,
.module-row strong.not_configured {
  background: #fff7ed;
  color: #c2410c;
}

.pill.not_applicable,
.pill.disabled,
.module-row strong.not_applicable,
.module-row strong.disabled {
  background: #f2f4f7;
  color: #667085;
}

.city-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1fr);
}

.city-card {
  min-width: 0;
  padding: 16px;
}

.city-card-detail {
  background: transparent;
  border: 0;
  padding: 0;
}

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

.city-head h3 {
  font-size: 18px;
  margin: 0;
}

.city-head p {
  font-size: 13px;
  margin: 6px 0 0;
}

.city-code {
  background: #f2f4f7;
  color: #475467;
}

.quick-lines {
  background: #f8fafc;
  border-radius: 8px;
  color: #344054;
  font-size: 13px;
  line-height: 1.6;
  margin: 14px 0;
  padding: 10px 12px;
  white-space: pre-line;
}

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

.module-card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  min-width: 0;
  padding: 14px;
}

.module-card-head {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.module-card h4 {
  font-size: 15px;
  margin: 0;
}

.module-card-head strong {
  border-radius: 6px;
  font-size: 12px;
  padding: 5px 8px;
}

.module-card-head strong.ok {
  background: #ecfdf3;
  color: #027a48;
}

.module-card-head strong.unavailable,
.module-card-head strong.failed {
  background: #fef3f2;
  color: #b42318;
}

.module-card-head strong.not_configured {
  background: #fff7ed;
  color: #c2410c;
}

.module-card-head strong.not_applicable,
.module-card-head strong.disabled,
.module-card-head strong.missing {
  background: #f2f4f7;
  color: #667085;
}

.module-headline {
  color: #475467;
  font-size: 12px;
  line-height: 1.5;
  margin: 10px 0;
  overflow-wrap: anywhere;
}

.field-grid {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.field-row {
  align-items: start;
  display: grid;
  gap: 10px;
  grid-template-columns: 84px minmax(0, 1fr);
}

.field-row span {
  color: #667085;
  font-size: 12px;
}

.field-row strong {
  color: #18212f;
  font-size: 12px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.module-list {
  display: grid;
  gap: 8px;
}

.module-row {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: 112px 46px 76px 72px minmax(0, 1fr);
}

.module-row span {
  color: #344054;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.empty-text {
  color: #667085;
  font-size: 13px;
  line-height: 1.6;
  margin: 0;
}

.module-row em {
  font-size: 12px;
  font-style: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.module-required {
  min-height: 24px;
}

.module-required.required {
  align-items: center;
  background: #fff1f2;
  border-radius: 6px;
  color: #be123c;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  justify-content: center;
  line-height: 1;
  padding: 6px 8px;
}

.module-toggle {
  align-items: center;
  color: #475467;
  display: inline-flex;
  font-size: 12px;
  gap: 6px;
}

.module-toggle input {
  height: 15px;
  margin: 0;
  width: 15px;
}

.module-detail {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  grid-column: 1 / -1;
  margin-top: 2px;
  min-width: 0;
}

.module-card .module-detail {
  margin-top: 10px;
}

.module-detail summary {
  color: #344054;
  cursor: pointer;
  font-size: 12px;
  line-height: 1.4;
  padding: 8px 10px;
}

.module-detail pre {
  border-top: 1px solid #e5e7eb;
  color: #18212f;
  font-size: 12px;
  line-height: 1.55;
  margin: 0;
  max-height: 260px;
  overflow: auto;
  padding: 10px;
  white-space: pre;
}

.job-detail {
  background: #101828;
  border-radius: 8px;
  color: #e5e7eb;
  font-size: 12px;
  line-height: 1.6;
  margin: 0;
  max-height: 280px;
  overflow: auto;
  padding: 14px;
}

.empty-state {
  background: #ffffff;
  border: 1px dashed #d0d5dd;
  border-radius: 8px;
  color: #667085;
  font-size: 14px;
  padding: 18px;
}

.city-search {
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  color: #18212f;
  height: 38px;
  min-width: min(320px, 100%);
  padding: 0 12px;
}

.city-toolbar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.city-toolbar .city-search {
  margin-left: auto;
}

.selection-summary {
  color: #667085;
  font-size: 13px;
  margin: 0 0 12px;
}

.city-tree {
  display: grid;
  gap: 10px;
}

.province-node {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
}

.province-node summary {
  align-items: center;
  background: #f8fafc;
  cursor: pointer;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  list-style: none;
  padding: 12px 14px;
}

.province-node summary::-webkit-details-marker {
  display: none;
}

.province-title {
  align-items: center;
  display: inline-flex;
  gap: 10px;
  min-width: 0;
}

.province-select {
  flex: 0 0 auto;
  height: 15px;
  width: 15px;
}

.province-node summary .province-name {
  color: #18212f;
  font-size: 15px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.province-node summary em {
  color: #667085;
  font-size: 12px;
  font-style: normal;
}

.province-children {
  display: grid;
}

.city-group {
  border-top: 1px solid #eef2f7;
}

.tree-row {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: 18px 44px minmax(0, 1fr) minmax(170px, auto);
  min-height: 54px;
  padding: 9px 14px;
}

.tree-row.enabled {
  background: #f0fdfa;
}

.tree-row.missing-coordinates {
  color: #667085;
}

.tree-row.county-level {
  padding-left: 48px;
}

.tree-row.pseudo-city {
  background: #fbfcfe;
}

.row-select {
  height: 15px;
  width: 15px;
}

.tree-row-main {
  min-width: 0;
}

.tree-row-main strong {
  color: #18212f;
  display: block;
  font-size: 14px;
  line-height: 1.3;
}

.tree-row-main p {
  color: #667085;
  font-size: 12px;
  margin: 4px 0 0;
}

.tree-row-meta {
  color: #667085;
  display: grid;
  font-size: 12px;
  gap: 4px;
  justify-items: end;
}

.county-group {
  border-top: 1px dashed #e5e7eb;
}

.city-list {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  max-height: 520px;
  overflow: auto;
}

.managed-city {
  align-items: center;
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  display: grid;
  gap: 12px;
  grid-template-columns: auto minmax(0, 1fr) minmax(180px, auto);
  min-height: 58px;
  padding: 10px 12px;
}

.managed-city:last-child {
  border-bottom: 0;
}

.managed-city.enabled {
  background: #f0fdfa;
}

.managed-city.missing-coordinates {
  color: #667085;
}

.managed-city-main {
  min-width: 0;
}

.managed-city-main strong {
  display: block;
  font-size: 14px;
  line-height: 1.3;
}

.managed-city-main p {
  color: #667085;
  font-size: 12px;
  line-height: 1.4;
  margin: 4px 0 0;
}

.managed-city-meta {
  color: #667085;
  display: grid;
  font-size: 12px;
  gap: 4px;
  justify-items: end;
}

.switch {
  display: inline-flex;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch span {
  background: #d0d5dd;
  border-radius: 999px;
  display: block;
  height: 22px;
  position: relative;
  transition: background 0.15s ease;
  width: 40px;
}

.switch span::after {
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.18);
  content: "";
  height: 18px;
  left: 2px;
  position: absolute;
  top: 2px;
  transition: transform 0.15s ease;
  width: 18px;
}

.switch input:checked + span {
  background: #0f766e;
}

.switch input:checked + span::after {
  transform: translateX(18px);
}

.switch input:disabled + span {
  cursor: not-allowed;
  opacity: 0.45;
}

.login-page {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 100vh;
}

.login-shell {
  padding: 24px;
  width: min(420px, 100%);
}

.login-panel {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 28px;
}

.login-brand h1 {
  font-size: 24px;
  margin: 0;
}

.login-brand p {
  color: #667085;
  font-size: 14px;
  line-height: 1.6;
  margin: 8px 0 22px;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form label {
  color: #344054;
  display: grid;
  font-size: 14px;
  gap: 8px;
}

.login-form input {
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  height: 40px;
  padding: 0 12px;
}

.login-button {
  margin-top: 4px;
  width: 100%;
}

.login-message {
  color: #667085;
  font-size: 13px;
  min-height: 20px;
  margin-top: 14px;
}

.login-message.error {
  color: #b42318;
}

@media (max-width: 900px) {
  .topbar,
  .panel-head {
    display: grid;
  }

  .stats-grid,
  .city-count-grid,
  .city-grid,
  .detail-grid,
  .status-lines {
    grid-template-columns: 1fr;
  }

  .city-toolbar .city-search {
    margin-left: 0;
    width: 100%;
  }

  .tree-row {
    align-items: start;
    grid-template-columns: 18px 44px minmax(0, 1fr);
  }

  .tree-row-meta {
    grid-column: 3;
    justify-items: start;
  }

  .tree-row.county-level {
    padding-left: 30px;
  }

  .managed-city {
    align-items: start;
    grid-template-columns: auto minmax(0, 1fr);
  }

  .managed-city-meta {
    grid-column: 2;
    justify-items: start;
  }

  .module-row {
    grid-template-columns: minmax(0, 1fr) 42px 62px 54px;
  }

  .module-row em {
    grid-column: 1 / -1;
  }

  main {
    padding: 18px;
  }
}
