:root {
  --atlas-blue: #0057ad;
  --atlas-blue-dark: #004182;
  --atlas-bg: #f4f7fb;
  --atlas-line: #d8e2ef;
  --atlas-line-soft: #e8eef6;
  --atlas-muted: #5f6f86;
  --atlas-navy: #071d3a;
  --atlas-red: #b42318;
  --atlas-soft-blue: #edf6ff;
  --shadow-soft: 0 16px 44px rgba(7, 29, 58, 0.07);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  color: var(--atlas-navy);
  font-family: "Segoe UI", Arial, sans-serif;
  background: var(--atlas-bg);
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

[hidden] {
  display: none !important;
}

a {
  color: inherit;
  text-decoration: none;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
}

.login-shell {
  width: min(1180px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 48px;
  align-items: center;
}

.login-hero,
.login-card,
.map-toolbar,
.map-panel,
.map-workspace {
  background: #fff;
  border: 1px solid var(--atlas-line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

.login-hero,
.login-card {
  padding: 38px;
}

.hero-brand,
.topbar-brand,
.topbar-actions,
.side-nav a,
.db-status,
.breadcrumbs,
.map-toolbar,
.section-title-row,
.map-header,
.map-actions,
.layer-row,
.legend-item {
  display: flex;
  align-items: center;
}

.hero-brand img,
.login-logo,
.topbar-brand img {
  height: 54px;
  width: auto;
}

.hero-brand span,
.topbar-brand span {
  width: 1px;
  height: 36px;
  background: var(--atlas-line);
}

.hero-brand {
  gap: 22px;
}

.hero-copy h1 {
  margin: 42px 0 10px;
  font-size: 32px;
}

.login-card {
  text-align: center;
}

.login-card form {
  display: grid;
  gap: 15px;
  margin-top: 24px;
  text-align: left;
}

.login-card label,
.map-panel label {
  display: grid;
  gap: 7px;
  color: #40516a;
  font-weight: 750;
}

.login-card input,
.map-panel input,
.map-panel select,
.map-panel textarea,
.map-toolbar select {
  min-height: 38px;
  border: 1px solid #c9d5e5;
  border-radius: 7px;
  padding: 0 10px;
  color: var(--atlas-navy);
  background: #fff;
}

.map-panel textarea {
  min-height: 96px;
  padding: 10px;
  resize: vertical;
}

.form-message {
  min-height: 20px;
  color: var(--atlas-red);
  font-size: 13px;
}

.app-view {
  min-height: 100vh;
}

.topbar {
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 24px;
  background: #fff;
  border-bottom: 1px solid var(--atlas-line);
}

.topbar-brand {
  gap: 18px;
}

.topbar-brand button {
  border: 0;
  background: transparent;
  color: var(--atlas-navy);
  font-size: 18px;
  font-weight: 850;
}

.topbar-actions,
.map-actions {
  gap: 10px;
}

.session-pill {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--atlas-soft-blue);
  color: var(--atlas-blue);
  font-weight: 750;
}

.module-shell {
  display: grid;
  grid-template-columns: 184px minmax(0, 1fr);
  min-height: calc(100vh - 70px);
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: calc(100vh - 70px);
  padding: 20px 8px;
  background: #fff;
  border-right: 1px solid var(--atlas-line);
}

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

.side-nav a {
  gap: 10px;
  padding: 10px 12px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 800;
}

.side-nav a.active,
.side-nav a:hover {
  color: var(--atlas-blue);
  background: var(--atlas-soft-blue);
}

.nav-icon {
  width: 16px;
  height: 16px;
  display: inline-grid;
  place-items: center;
  color: var(--atlas-blue);
  font-size: 10px;
  font-weight: 900;
}

.nav-icon::before {
  content: "AT";
}

.nav-icon.map::before {
  content: "MP";
}

.nav-icon.file::before {
  content: "IF";
}

.nav-icon.database::before {
  content: "DB";
}

.db-status {
  gap: 10px;
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--atlas-line);
}

.db-status small,
.version-note,
.breadcrumbs,
.section-title-row p,
.map-header span,
.legend-box,
.figure-note,
.hero-copy p,
.hero-brand p {
  color: var(--atlas-muted);
}

.version-note {
  padding: 0 12px;
  font-size: 11px;
}

.content-area {
  min-width: 0;
  padding: 22px;
}

.breadcrumbs {
  gap: 9px;
  margin: 0 0 18px;
  font-size: 12px;
}

.map-toolbar {
  gap: 12px;
  padding: 12px 16px;
  margin-bottom: 14px;
}

.map-toolbar label {
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 850;
  color: #40516a;
}

.map-toolbar select {
  min-width: 280px;
  flex: 1;
}

.cartography-layout {
  display: grid;
  grid-template-columns: minmax(280px, 330px) minmax(0, 1fr);
  grid-template-rows: auto auto;
  gap: 12px;
  align-items: start;
}

.map-panel,
.map-workspace {
  min-width: 0;
  padding: 12px;
}

.map-panel--layers {
  grid-column: 1;
  grid-row: 1 / span 2;
  align-self: start;
  max-height: calc(100vh - 150px);
  overflow: auto;
}

.section-title-row {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.section-title-row h2,
.map-header h1 {
  font-size: 20px;
}

.section-title-row p,
.map-header span {
  display: block;
  margin-top: 5px;
  font-size: 13px;
  line-height: 1.35;
}

.layer-list {
  display: grid;
  gap: 12px;
  max-height: min(42vh, 430px);
  overflow: auto;
  padding-right: 3px;
}

.map-panel--figure {
  grid-column: 2;
  grid-row: 2;
  display: grid;
  grid-template-columns: minmax(340px, 0.95fr) minmax(420px, 1.05fr);
  gap: 12px;
  align-items: start;
}

.map-panel--figure .section-title-row {
  grid-column: 1 / -1;
  margin-bottom: 0;
}

.figure-fields-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.figure-fields-grid label:first-child,
.figure-fields-grid label:nth-child(4),
.figure-fields-grid .figure-note {
  grid-column: 1 / -1;
}

.address-search,
.query-box,
.layer-group {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--atlas-line);
  border-radius: 7px;
  background: #fbfdff;
}

.address-search {
  margin-bottom: 12px;
}

.address-search label,
.query-box label {
  display: grid;
  gap: 6px;
  color: #40516a;
  font-size: 12px;
  font-weight: 850;
}

.address-search-row,
.coordinate-search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.address-results,
.saved-figures-list {
  display: grid;
  gap: 6px;
  overflow: auto;
}

.address-results {
  max-height: 150px;
}

.saved-figures-list {
  max-height: 285px;
}

.address-result {
  display: grid;
  gap: 3px;
  width: 100%;
  padding: 8px;
  border: 1px solid var(--atlas-line);
  border-radius: 6px;
  background: #fff;
  color: var(--atlas-navy);
  text-align: left;
}

.address-result:hover {
  border-color: var(--atlas-blue);
  background: var(--atlas-soft-blue);
}

.address-result span,
.address-result small,
.query-box p,
.identify-result small {
  color: var(--atlas-muted);
  font-size: 12px;
  line-height: 1.35;
}

.address-status,
.coordinate-status {
  margin: 0;
  color: #40516a;
  font-size: 12px;
  line-height: 1.35;
}

.address-status--ok,
.coordinate-status--ok {
  color: #075e3b;
}

.address-status--warning,
.coordinate-status--warning {
  color: #8a4b00;
}

.address-status--error,
.coordinate-status--error {
  color: #b42318;
}

.saved-figures-box {
  display: grid;
  gap: 10px;
  min-height: 0;
  padding: 10px;
  border: 1px solid var(--atlas-line);
  border-radius: 7px;
  background: #fbfdff;
}

.saved-figures-box h3 {
  color: var(--atlas-navy);
  font-size: 14px;
}

.saved-figure-card {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 9px;
  padding: 8px;
  border: 1px solid var(--atlas-line);
  border-radius: 7px;
  background: #fff;
}

.saved-figure-thumb {
  display: grid;
  min-height: 56px;
  place-items: center;
  overflow: hidden;
  border: 1px solid #d7e3f1;
  border-radius: 6px;
  background: #eef5fc;
  color: var(--atlas-muted);
  font-size: 11px;
  font-weight: 850;
}

.saved-figure-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.saved-figure-body {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.saved-figure-body strong,
.saved-figure-body span,
.saved-figure-body small {
  overflow-wrap: anywhere;
}

.saved-figure-body span,
.saved-figure-body small {
  color: var(--atlas-muted);
  font-size: 11px;
  line-height: 1.35;
}

.saved-figure-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.saved-figure-location {
  color: var(--atlas-navy) !important;
  font-weight: 850;
}

.saved-figure-actions button {
  min-height: 30px;
  padding: 0 8px;
  border-radius: 6px;
}

.compact-toggle {
  display: flex !important;
  align-items: center;
  grid-template-columns: none !important;
  gap: 8px !important;
  padding: 7px 8px;
  border: 1px solid var(--atlas-line);
  border-radius: 6px;
  background: #ffffff;
}

.compact-toggle input {
  width: 16px;
  height: 16px;
}

.manual-point-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 7px;
}

.manual-point-status {
  margin: 0;
  padding: 8px;
  border: 1px solid #9cc7f1;
  border-radius: 6px;
  background: #edf6ff;
  color: var(--atlas-blue-dark);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}

.subtle-button {
  background: #ffffff;
  color: #40516a;
}

.danger-button {
  border-color: #f4b7ad;
  background: #fff8f6;
  color: #b42318;
}

.layer-group h3,
.query-box h3 {
  color: var(--atlas-navy);
  font-size: 14px;
}

.layer-row {
  align-items: stretch;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--atlas-line);
  border-radius: 7px;
  background: #f8fbff;
}

.layer-row label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: var(--atlas-navy);
}

.layer-row small {
  display: block;
  margin-top: 3px;
  color: var(--atlas-muted);
  font-weight: 600;
}

.layer-badge {
  display: inline-flex;
  width: fit-content;
  margin-top: 6px;
  padding: 2px 6px;
  border-radius: 999px;
  background: #eaf7ee;
  color: #16703a;
  font-size: 10px;
  font-style: normal;
  font-weight: 850;
  text-transform: uppercase;
}

.layer-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-height: 18px;
  accent-color: var(--atlas-blue);
}

.opacity-control {
  display: grid;
  grid-template-columns: auto minmax(90px, 1fr) 42px;
  gap: 8px;
  align-items: center;
  color: var(--atlas-muted);
  font-size: 11px;
  font-weight: 800;
}

.opacity-control input[type="range"] {
  width: 100%;
}

.opacity-control output {
  color: var(--atlas-blue);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.legend-box,
.query-box {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--atlas-line);
  border-radius: 7px;
  background: #fbfdff;
  font-size: 12px;
}

.legend-box {
  max-height: 170px;
  overflow: auto;
}

.legend-box h3,
.query-box h3 {
  margin-bottom: 8px;
  color: var(--atlas-navy);
  font-size: 14px;
}

.identify-result {
  display: grid;
  gap: 8px;
  max-height: 230px;
  overflow: auto;
}

.identify-summary {
  display: grid;
  gap: 3px;
  padding: 8px;
  border: 1px solid #b7d4f1;
  border-radius: 6px;
  background: var(--atlas-soft-blue);
}

.identify-summary strong {
  color: var(--atlas-blue-dark);
}

.identify-summary span {
  color: #40516a;
  font-size: 12px;
}

.identify-table {
  width: 100%;
  border-collapse: collapse;
  overflow-wrap: anywhere;
}

.identify-table th,
.identify-table td {
  padding: 6px;
  border: 1px solid var(--atlas-line);
  text-align: left;
  vertical-align: top;
}

.identify-table th {
  width: 35%;
  background: #f1f6fc;
  color: #40516a;
}

.identify-empty,
.empty-state {
  padding: 8px;
  border: 1px dashed var(--atlas-line);
  border-radius: 6px;
  background: #fff;
  color: var(--atlas-muted);
}

.legend-item {
  gap: 8px;
  margin: 6px 0;
}

.legend-swatch {
  width: 16px;
  height: 10px;
  border-radius: 2px;
  background: var(--atlas-blue);
}

.map-workspace {
  grid-column: 2;
  grid-row: 1;
  display: grid;
  grid-template-rows: auto minmax(420px, 1fr);
  gap: 10px;
}

.map-header {
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}

.map-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.eyebrow {
  color: var(--atlas-blue);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.map-frame {
  position: relative;
  overflow: hidden;
  height: clamp(420px, 58vh, 620px);
  min-height: 420px;
  border: 1px solid var(--atlas-line);
  border-radius: 8px;
  background: #e9eff5;
}

.map-canvas {
  width: 100%;
  height: 100%;
  min-height: 420px;
}

.map-canvas canvas,
.map-canvas .ol-layer canvas {
  filter: none;
  image-rendering: auto;
}

.map-canvas.manual-point-mode,
.map-canvas.manual-point-mode .ol-viewport {
  cursor: crosshair;
}

.north-arrow {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 3;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid #8aa5c3;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: var(--atlas-navy);
  font-weight: 900;
}

.north-arrow::after {
  content: "";
  position: absolute;
  top: 5px;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 12px solid var(--atlas-blue);
}

.map-warning {
  position: absolute;
  left: 14px;
  bottom: 14px;
  z-index: 4;
  max-width: 520px;
  padding: 10px 12px;
  border: 1px solid #ffcf99;
  border-radius: 7px;
  background: #fff7ed;
  color: #8a4100;
  font-size: 13px;
}

.primary-action,
.ghost-button {
  min-height: 36px;
  border-radius: 7px;
  padding: 0 14px;
  font-weight: 850;
}

.primary-action {
  border: 1px solid var(--atlas-blue);
  background: var(--atlas-blue);
  color: #fff;
}

.ghost-button {
  border: 1px solid #c9d5e5;
  background: #fff;
  color: var(--atlas-blue);
}

.ghost-button.danger-button {
  border-color: #f4b7ad;
  background: #fff8f6;
  color: #b42318;
}

.figure-note {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--atlas-line);
  border-radius: 7px;
  background: #f8fbff;
  font-size: 12px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 100;
  max-width: 420px;
  padding: 12px 14px;
  border: 1px solid #b7d4f1;
  border-radius: 8px;
  background: #fff;
  color: var(--atlas-navy);
  box-shadow: var(--shadow-soft);
}

.toast.error {
  border-color: #f5b5ae;
  color: var(--atlas-red);
}

@media (max-width: 1280px) {
  .cartography-layout {
    grid-template-columns: minmax(260px, 300px) minmax(0, 1fr);
  }

  .map-panel--figure {
    grid-template-columns: minmax(300px, 0.9fr) minmax(360px, 1.1fr);
  }
}

@media (max-width: 1100px) {
  .module-shell,
  .cartography-layout,
  .login-shell,
  .map-panel--figure {
    grid-template-columns: 1fr;
  }

  .cartography-layout,
  .map-panel--layers,
  .map-workspace,
  .map-panel--figure {
    grid-column: 1;
    grid-row: auto;
  }

  .map-panel--layers {
    max-height: none;
  }

  .layer-list,
  .legend-box,
  .identify-result,
  .saved-figures-list {
    max-height: 260px;
  }

  .side-nav {
    min-height: 0;
  }

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

  .map-toolbar select {
    min-width: 0;
    width: 100%;
  }
}

@media (max-width: 900px) {
  .figure-fields-grid {
    grid-template-columns: 1fr;
  }
}
