.geo-rate-guardrails {
  display: grid;
  grid-template-columns: 1.35fr repeat(5, 1fr);
  overflow: hidden;
  margin-bottom: 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  box-shadow: var(--shadow);
}

.guardrail-title {
  display: flex;
  min-height: 82px;
  flex-direction: column;
  justify-content: center;
  padding: 15px 17px;
  color: white;
  background: linear-gradient(135deg, #101a22, #173847);
}

.guardrail-title span,
.guardrail-card span {
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: 7px;
  font-weight: 850;
}

.guardrail-title span { color: #78bed0; }
.guardrail-title strong { max-width: 245px; margin-top: 6px; font-size: 10px; line-height: 1.4; }

.guardrail-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  padding: 13px 14px;
  border-left: 1px solid var(--line-soft);
}

.guardrail-card span { color: var(--muted); }
.guardrail-card strong { margin: 4px 0 2px; color: var(--ink); letter-spacing: -.03em; font-size: 19px; }
.guardrail-card small { color: #829097; font-size: 7px; }

.guardrail-policy {
  grid-column: 1 / -1;
  padding: 8px 14px;
  color: #6e7c83;
  border-top: 1px solid var(--line-soft);
  background: #f8fafb;
  font-size: 8px;
}

.geo-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 11px;
  margin-bottom: 15px;
}

.geo-stat {
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
}

.geo-stat span { display: block; color: var(--muted); font-size: 8px; }
.geo-stat strong { display: block; margin: 3px 0 1px; letter-spacing: -.035em; font-size: 21px; }
.geo-stat small { color: #88959b; font-size: 7px; }

.geo-loading,
.geo-error {
  grid-column: 1 / -1;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--muted);
  text-align: center;
}

.geo-error { color: var(--red); }
.geo-error strong,
.geo-error span { display: block; }

.geo-workspace {
  display: grid;
  grid-template-columns: minmax(0, 2.1fr) minmax(300px, .9fr);
  align-items: stretch;
  gap: 15px;
}

.geo-map-panel,
.territory-panel { min-width: 0; overflow: hidden; }

.geo-toolbar {
  display: flex;
  min-height: 55px;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
}

.geo-toolbar .inline-search { flex: 1; }
.geo-toolbar .select-control { width: 180px; }
.geo-map-key { display: grid; min-width: 160px; gap: 2px; color: var(--ink-2); font-size: 8px; }
.geo-map-key span { display: flex; align-items: center; gap: 6px; font-weight: 800; }
.geo-map-key i { width: 10px; height: 10px; border: 2px solid white; border-radius: 3px; background: #176f8c; box-shadow: 0 0 0 1px #aac2ca; }
.geo-map-key small { color: var(--muted); font-size: 7px; }

.market-map {
  z-index: 1;
  width: 100%;
  height: 620px;
  background: #dce8ec;
}

.leaflet-container { font-family: inherit; }
.leaflet-control-attribution { font-size: 7px !important; }
.leaflet-control-zoom a { color: var(--ink) !important; }
.territory-tooltip { padding: 7px 9px !important; border: 0 !important; box-shadow: 0 6px 20px rgba(16, 31, 39, .2) !important; font-family: inherit; font-size: 9px; }
.territory-tooltip strong { color: var(--ink); }
.territory-tooltip span { color: var(--muted); font-size: 7px; }

.geo-map-foot {
  display: flex;
  min-height: 34px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 12px;
  color: var(--muted);
  border-top: 1px solid var(--line-soft);
  font-size: 7px;
}

.geo-map-foot a { color: var(--blue); text-decoration: none; }

.territory-panel { min-height: 710px; }
.territory-detail { height: 100%; }
.territory-empty { display: grid; min-height: 520px; place-content: center; padding: 25px; text-align: center; }
.territory-empty strong { font-size: 14px; }
.territory-empty p { max-width: 250px; margin: 7px auto 0; color: var(--muted); font-size: 9px; line-height: 1.55; }
.territory-compass { display: grid; width: 54px; height: 54px; margin: 0 auto 13px; place-items: center; color: var(--blue); border: 1px solid #bad7df; border-radius: 50%; background: var(--blue-pale); font-size: 25px; }

.territory-head {
  position: relative;
  padding: 24px 21px 19px;
  border-bottom: 1px solid var(--line);
}

.territory-head::before { content: ""; position: absolute; top: 0; right: 0; left: 0; height: 4px; background: var(--territory-color); }
.territory-head h2 { margin: 9px 0 5px; letter-spacing: -.025em; font-size: 19px; line-height: 1.25; }
.territory-head p { margin: 0; color: var(--muted); font-size: 8px; }
.territory-chip { display: inline-block; padding: 4px 6px; color: var(--blue); border-radius: 5px; background: var(--blue-pale); text-transform: uppercase; letter-spacing: .07em; font-size: 7px; font-weight: 850; }

.territory-section { padding: 17px 18px; border-bottom: 1px solid var(--line-soft); }
.territory-section-head { display: flex; align-items: center; justify-content: space-between; gap: 9px; }
.territory-section-head > div { display: flex; align-items: center; gap: 6px; }
.territory-section-head span { color: var(--ink-2); text-transform: uppercase; letter-spacing: .07em; font-size: 7px; font-weight: 850; }
.territory-section-head strong { display: grid; min-width: 18px; height: 18px; place-items: center; color: var(--blue); border-radius: 9px; background: var(--blue-pale); font-size: 7px; }
.territory-section-head .mini-button { white-space: nowrap; }

.territory-records { display: grid; gap: 6px; margin-top: 10px; }
.territory-record { display: grid; grid-template-columns: 29px 1fr auto; align-items: center; gap: 8px; padding: 8px; border: 1px solid var(--line-soft); border-radius: 8px; background: #fbfcfc; }
.territory-avatar { display: grid; width: 29px; height: 29px; place-items: center; color: var(--blue); border-radius: 7px; background: var(--blue-pale); font-size: 7px; font-weight: 850; }
.territory-record strong,
.territory-record small { display: block; }
.territory-record strong { font-size: 8px; }
.territory-record small { margin-top: 2px; color: var(--muted); font-size: 7px; }
.territory-unlink { width: 23px; height: 23px; color: #8c989d; border: 0; border-radius: 50%; background: transparent; cursor: pointer; }
.territory-unlink:hover { color: var(--red); background: var(--red-pale); }
.territory-record-empty { padding: 16px 8px; color: var(--muted); text-align: center; font-size: 8px; }
.territory-disclaimer { margin: 16px 18px; padding: 10px; color: #7a6845; border: 1px solid #eadbbd; border-radius: 7px; background: #fffaf0; font-size: 7px; line-height: 1.5; }

.geo-directory-panel { margin-top: 15px; }
.geo-directory-note { color: var(--muted); font-size: 8px; }
.geo-directory { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border-top: 1px solid var(--line-soft); }
.geo-directory-column { min-width: 0; padding: 15px 17px 18px; }
.geo-directory-column + .geo-directory-column { border-left: 1px solid var(--line-soft); }
.geo-directory-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; font-size: 7px; font-weight: 850; }
.geo-directory-head strong { color: var(--blue); }
.geo-directory-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.geo-directory-record { min-width: 0; padding: 10px; border: 1px solid var(--line-soft); border-radius: 8px; background: #fbfcfc; }
.geo-directory-identity { display: grid; grid-template-columns: 30px minmax(0, 1fr); align-items: center; gap: 8px; }
.geo-directory-identity > span { display: grid; width: 30px; height: 30px; place-items: center; color: var(--blue); border-radius: 7px; background: var(--blue-pale); font-size: 7px; font-weight: 850; }
.geo-directory-identity strong,
.geo-directory-identity small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.geo-directory-identity strong { font-size: 8px; }
.geo-directory-identity small { margin-top: 2px; color: var(--muted); font-size: 7px; }
.geo-assignment-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.geo-assignment-tags button { max-width: 100%; overflow: hidden; padding: 3px 5px; color: #506b76; text-overflow: ellipsis; white-space: nowrap; border: 0; border-radius: 4px; background: #e7eff2; cursor: pointer; font-size: 6px; }
.geo-assignment-tags em,
.geo-assignment-tags small { color: var(--muted); font-size: 6px; font-style: normal; }
.geo-directory-empty { grid-column: 1 / -1; padding: 24px; color: var(--muted); text-align: center; font-size: 8px; }

.geo-modal-backdrop { position: fixed; z-index: 88; inset: 0; background: rgba(9, 19, 25, .56); backdrop-filter: blur(2px); }
.geo-record-modal { position: fixed; z-index: 89; top: 50%; left: 50%; width: min(660px, calc(100vw - 30px)); max-height: calc(100vh - 30px); overflow-y: auto; transform: translate(-50%, -50%); border: 1px solid var(--line); border-radius: 12px; background: white; box-shadow: var(--shadow-high); }
.geo-record-modal form { padding: 18px; }

@media (max-width: 1260px) {
  .geo-rate-guardrails { grid-template-columns: repeat(3, 1fr); }
  .guardrail-title { grid-column: span 3; min-height: auto; }
  .guardrail-title strong { max-width: none; }
  .guardrail-card:nth-of-type(4) { border-left: 0; }
  .geo-workspace { grid-template-columns: minmax(0, 1.8fr) minmax(285px, .9fr); }
  .geo-toolbar { flex-wrap: wrap; }
  .geo-toolbar .inline-search { min-width: 280px; }
  .geo-map-key { margin-left: auto; }
  .geo-directory-list { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .geo-workspace { grid-template-columns: 1fr; }
  .territory-panel { min-height: auto; }
  .territory-empty { min-height: 260px; }
  .market-map { height: 540px; }
  .geo-directory { grid-template-columns: 1fr; }
  .geo-directory-column + .geo-directory-column { border-top: 1px solid var(--line-soft); border-left: 0; }
}

@media (max-width: 680px) {
  .geo-rate-guardrails { grid-template-columns: 1fr 1fr; }
  .guardrail-title { grid-column: 1 / -1; }
  .guardrail-card:nth-of-type(4) { border-left: 1px solid var(--line-soft); }
  .guardrail-card:nth-of-type(odd) { border-left: 0; }
  .geo-summary { grid-template-columns: 1fr 1fr; }
  .geo-toolbar .inline-search,
  .geo-toolbar .select-control,
  .geo-map-key { width: 100%; min-width: 0; }
  .geo-map-key { margin: 2px 0 0; }
  .market-map { height: 460px; }
  .geo-map-foot { align-items: flex-start; flex-direction: column; }
  .geo-directory-note { display: none; }
}
