:root {
  color-scheme: light;
  --ink: #17201c;
  --ink-soft: #5e6a66;
  --background: #eef2f4;
  --surface: rgba(255, 255, 255, .78);
  --surface-strong: rgba(255, 255, 255, .92);
  --line: rgba(61, 74, 70, .14);
  --green: #2f9d73;
  --green-dark: #217a59;
  --blue: #3c74d6;
  --cyan: #258ca0;
  --rose: #cf6678;
  --amber: #ca8736;
  --red: #c84e4e;
  --shadow: 0 18px 50px rgba(36, 48, 52, .12), 0 2px 10px rgba(36, 48, 52, .05);
  --max-width: 1360px;
  --radius: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; min-height: 100%; background: var(--background); }
body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(155deg, rgba(47, 157, 115, .10), transparent 36%),
    linear-gradient(45deg, rgba(60, 116, 214, .08), transparent 42%),
    linear-gradient(180deg, #f6f8f7 0%, #e7edf0 100%);
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; }
svg {
  display: block;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.topbar,
.metric-card,
.map-panel,
.offer-panel,
.offer-card,
.login-card {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, .72);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .75);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  border-radius: var(--radius);
}

.topbar {
  position: sticky;
  z-index: 40;
  top: 12px;
  display: grid;
  width: min(calc(100% - 24px), var(--max-width));
  height: 64px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  margin: 12px auto 0;
  padding: 0 10px 0 14px;
}

.brand,
.login-brand {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 760;
  letter-spacing: 0;
  text-decoration: none;
}

.brand-icon {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, var(--green), var(--blue));
  border-radius: var(--radius);
  box-shadow: 0 8px 18px rgba(34, 122, 91, .24), inset 0 1px rgba(255, 255, 255, .34);
}
.brand-icon svg { width: 21px; height: 21px; }

.sync-label {
  overflow: hidden;
  margin: 0;
  color: var(--ink-soft);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-actions,
.map-actions,
.card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  padding: 0;
  place-items: center;
  color: #47534f;
  background: rgba(255, 255, 255, .34);
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  transition: background .18s ease, border-color .18s ease, transform .18s ease;
}
.icon-button:hover { background: rgba(255, 255, 255, .82); border-color: rgba(61, 74, 70, .10); }
.icon-button:active { transform: scale(.96); }
.icon-button:disabled { opacity: .48; cursor: wait; }
.icon-button.is-spinning svg { animation: spin .8s linear infinite; }
.map-control { width: 38px; height: 38px; background: rgba(255, 255, 255, .72); }

.page-shell {
  width: min(calc(100% - 24px), var(--max-width));
  margin: 0 auto;
  padding: 18px 0 80px;
}

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

.metric-card {
  min-height: 104px;
  padding: 17px 18px;
}
.metric-card span,
.metric-card small {
  display: block;
  overflow: hidden;
  color: var(--ink-soft);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.metric-card span { font-size: 12px; font-weight: 690; }
.metric-card strong {
  display: block;
  overflow: hidden;
  margin: 11px 0 5px;
  font-size: 27px;
  line-height: 1.05;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.metric-card small { font-size: 11px; }

.workspace {
  display: grid;
  min-height: 660px;
  grid-template-columns: minmax(0, 1.42fr) minmax(360px, .58fr);
  align-items: stretch;
  gap: 10px;
}

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

.map-panel {
  display: grid;
  grid-template-rows: auto minmax(520px, 1fr);
  padding: 14px;
}

.map-heading,
.panel-heading {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.eyebrow {
  margin: 0 0 4px;
  color: #66736f;
  font-size: 10px;
  font-weight: 760;
  letter-spacing: 0;
  text-transform: uppercase;
}

.map-heading h1,
.panel-heading h2 {
  overflow: hidden;
  margin: 0;
  font-size: 24px;
  line-height: 1.12;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map {
  position: relative;
  min-height: 520px;
  overflow: hidden;
  touch-action: none;
  background: #d8e4df;
  border: 1px solid rgba(61, 74, 70, .12);
  border-radius: var(--radius);
  cursor: grab;
}
.map.is-dragging { cursor: grabbing; }
.tile-layer,
.marker-layer {
  position: absolute;
  inset: 0;
}
.tile-layer img {
  position: absolute;
  width: 256px;
  height: 256px;
  user-select: none;
  -webkit-user-drag: none;
}
.marker-layer { pointer-events: none; }

.marker {
  position: absolute;
  display: grid;
  width: 34px;
  height: 34px;
  padding: 0;
  place-items: center;
  color: #fff;
  background: var(--green);
  border: 2px solid #fff;
  border-radius: 50% 50% 50% 7px;
  box-shadow: 0 10px 20px rgba(20, 42, 35, .22);
  cursor: pointer;
  pointer-events: auto;
  transform: translate(-50%, -100%) rotate(-45deg);
}
.marker span {
  display: block;
  max-width: 22px;
  overflow: hidden;
  font-size: 11px;
  font-weight: 780;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
  transform: rotate(45deg);
}
.marker.is-selected { background: var(--rose); z-index: 4; }
.marker.is-empty { background: #7c8984; }
.marker-current {
  position: absolute;
  width: 22px;
  height: 22px;
  background: var(--blue);
  border: 4px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 8px rgba(60, 116, 214, .18), 0 8px 18px rgba(34, 73, 140, .2);
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.map-empty {
  position: absolute;
  top: 50%;
  left: 50%;
  padding: 10px 12px;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, .86);
  border: 1px solid rgba(61, 74, 70, .14);
  border-radius: var(--radius);
  font-size: 12px;
  transform: translate(-50%, -50%);
}

.map-attribution {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 4px 6px;
  color: #53605c;
  background: rgba(255, 255, 255, .82);
  border-radius: 4px;
  font-size: 10px;
  text-decoration: none;
}

.offer-panel {
  display: flex;
  max-height: 760px;
  flex-direction: column;
  padding: 14px;
}

.status-pill {
  display: inline-flex;
  min-width: 92px;
  height: 30px;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  color: var(--green-dark);
  background: rgba(47, 157, 115, .10);
  border: 1px solid rgba(47, 157, 115, .14);
  border-radius: 99px;
  font-size: 11px;
  font-weight: 710;
  white-space: nowrap;
}
.status-pill.is-alert {
  color: #9d3c3c;
  background: rgba(200, 78, 78, .10);
  border-color: rgba(200, 78, 78, .16);
}

.filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  margin-bottom: 12px;
  padding: 5px;
  background: rgba(255, 255, 255, .54);
  border: 1px solid rgba(255, 255, 255, .72);
  border-radius: var(--radius);
}
.filter-button {
  min-width: 0;
  height: 36px;
  overflow: hidden;
  color: var(--ink-soft);
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 690;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.filter-button.is-active {
  color: var(--ink);
  background: var(--surface-strong);
  box-shadow: 0 4px 14px rgba(36, 48, 52, .08);
}

.offer-list {
  display: grid;
  min-height: 0;
  gap: 8px;
  overflow: auto;
  padding: 1px 2px 4px;
}

.offer-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-color: rgba(61, 74, 70, .10);
  box-shadow: 0 8px 26px rgba(36, 48, 52, .08), inset 0 1px rgba(255, 255, 255, .68);
}
.offer-card.is-selected {
  border-color: rgba(207, 102, 120, .42);
  box-shadow: 0 0 0 2px rgba(207, 102, 120, .14), 0 8px 26px rgba(36, 48, 52, .08);
}
.offer-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}
.offer-title {
  min-width: 0;
}
.offer-title strong,
.offer-title span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.offer-title strong { font-size: 15px; }
.offer-title span { margin-top: 4px; color: var(--ink-soft); font-size: 12px; }
.availability {
  display: inline-flex;
  min-width: 38px;
  height: 30px;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: var(--green);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 780;
}

.offer-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}
.meta-cell {
  min-width: 0;
  padding: 8px;
  background: rgba(255, 255, 255, .50);
  border: 1px solid rgba(61, 74, 70, .08);
  border-radius: 6px;
}
.meta-cell span,
.meta-cell strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}
.meta-cell span { color: var(--ink-soft); font-size: 10px; }
.meta-cell strong {
  min-height: 30px;
  margin-top: 3px;
  font-size: 12px;
  line-height: 1.25;
  overflow-wrap: anywhere;
  white-space: normal;
}

.card-actions {
  justify-content: space-between;
  gap: 8px;
}
.button {
  display: inline-flex;
  min-width: 0;
  height: 38px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 12px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 730;
  text-decoration: none;
  cursor: pointer;
}
.button svg { width: 16px; height: 16px; }
.button-primary {
  color: #fff;
  background: linear-gradient(145deg, var(--green), var(--green-dark));
  border: 1px solid rgba(255, 255, 255, .22);
}
.button-secondary {
  color: var(--ink);
  background: rgba(255, 255, 255, .64);
  border: 1px solid rgba(61, 74, 70, .10);
}

.loading-state,
.empty-state,
.error-state {
  display: grid;
  min-height: 220px;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 24px;
  color: var(--ink-soft);
  text-align: center;
}
.loading-state p,
.empty-state p,
.error-state p {
  max-width: 290px;
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
}
.error-state strong,
.empty-state strong {
  color: var(--ink);
  font-size: 15px;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 2px solid rgba(47, 157, 115, .18);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

.toast {
  position: fixed;
  z-index: 80;
  right: 16px;
  bottom: 16px;
  width: min(360px, calc(100vw - 32px));
  padding: 12px 14px;
  color: #fff;
  background: rgba(23, 32, 28, .92);
  border-radius: var(--radius);
  box-shadow: 0 14px 40px rgba(20, 30, 28, .24);
  font-size: 13px;
  line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity .18s ease, transform .18s ease;
}
.toast.is-visible { opacity: 1; transform: translateY(0); }

.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-shell {
  width: min(100%, 430px);
}
.login-card {
  padding: 28px;
}
.login-heading { margin: 34px 0 24px; }
.login-heading h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.08;
  letter-spacing: 0;
}
.login-heading p:last-child {
  margin: 14px 0 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.5;
}
.login-form {
  display: grid;
  gap: 14px;
}
.field {
  display: grid;
  gap: 7px;
}
.field span {
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 690;
}
.field input {
  width: 100%;
  height: 46px;
  padding: 0 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, .70);
  border: 1px solid rgba(61, 74, 70, .14);
  border-radius: var(--radius);
  outline: none;
}
.field input:focus {
  border-color: rgba(47, 157, 115, .52);
  box-shadow: 0 0 0 3px rgba(47, 157, 115, .12);
}
.login-button { width: 100%; margin-top: 2px; }
.login-error {
  margin: -2px 0 0;
  color: var(--red);
  font-size: 12px;
  font-weight: 690;
}
.privacy-note,
.login-caption {
  margin: 18px 0 0;
  color: var(--ink-soft);
  font-size: 12px;
  text-align: center;
}
.login-caption { color: #75817d; }

@media (max-width: 1040px) {
  .overview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workspace {
    grid-template-columns: 1fr;
    min-height: 0;
  }
  .offer-panel { max-height: none; }
  .map-panel { grid-template-rows: auto minmax(500px, 58vh); }
}

@media (max-width: 720px) {
  .topbar {
    top: 8px;
    width: min(calc(100% - 16px), var(--max-width));
    height: auto;
    min-height: 58px;
    grid-template-columns: auto auto;
    gap: 8px;
    padding: 8px;
  }
  .sync-label {
    grid-column: 1 / -1;
    grid-row: 2;
    padding: 0 4px 2px;
  }
  .top-actions { justify-content: end; gap: 4px; }
  .icon-button { width: 38px; height: 38px; }
  .page-shell { width: min(calc(100% - 16px), var(--max-width)); padding-top: 12px; }
  .overview { grid-template-columns: 1fr 1fr; gap: 8px; }
  .metric-card { min-height: 92px; padding: 14px; }
  .metric-card strong { font-size: 22px; }
  .map-panel,
  .offer-panel { padding: 10px; }
  .map-heading h1,
  .panel-heading h2 { font-size: 20px; }
  .map-actions { gap: 4px; }
  .map-panel { grid-template-rows: auto minmax(420px, 56vh); }
  .map { min-height: 420px; }
  .offer-meta { grid-template-columns: 1fr; }
  .card-actions { align-items: stretch; flex-direction: column; }
  .button { width: 100%; }
  .login-card { padding: 22px; }
  .login-heading h1 { font-size: 30px; }
}

@media (max-width: 430px) {
  .overview { grid-template-columns: 1fr; }
  .brand span:last-child { display: none; }
  .filters { grid-template-columns: 1fr; }
  .map-panel { grid-template-rows: auto minmax(360px, 52vh); }
  .map { min-height: 360px; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
