:root {
  color-scheme: light;
  --bg: #f3f5f7;
  --surface: rgba(255, 255, 255, .94);
  --surface-solid: #ffffff;
  --surface-soft: #f7f8fa;
  --surface-raised: rgba(255, 255, 255, .88);
  --line: #d8dee6;
  --line-strong: #b8c2cf;
  --text: #17202b;
  --muted: #667386;
  --primary: #f97316;
  --primary-dark: #c2410c;
  --primary-soft: #fff0e5;
  --blue: #2563eb;
  --danger: #dc2626;
  --sidebar: #fbfcfe;
  --map-panel: rgba(255, 255, 255, .9);
  --shadow: 0 18px 44px rgba(15, 23, 42, .14);
  --shadow-soft: 0 8px 22px rgba(15, 23, 42, .10);
  --radius: 8px;
  --radius-sm: 6px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #080a0d;
  --surface: rgba(17, 19, 23, .92);
  --surface-solid: #111318;
  --surface-soft: #171a20;
  --surface-raised: rgba(18, 20, 25, .88);
  --line: #2a2f38;
  --line-strong: #3b4350;
  --text: #f4f5f7;
  --muted: #a1a8b3;
  --primary: #fb923c;
  --primary-dark: #fdba74;
  --primary-soft: rgba(251, 146, 60, .16);
  --blue: #60a5fa;
  --danger: #fb7185;
  --sidebar: #0d1015;
  --map-panel: rgba(12, 14, 18, .86);
  --shadow: 0 22px 52px rgba(0, 0, 0, .48);
  --shadow-soft: 0 10px 26px rgba(0, 0, 0, .34);
}

* { box-sizing: border-box; }

html { min-width: 320px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.35;
}

button, input, select, textarea { font: inherit; }
h1, h2, h3, p { margin: 0; }
.hidden { display: none !important; }
.small { font-size: 11px; }
.muted { color: var(--muted); }

button, a.link-button, .file-button {
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  color: inherit;
  white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .15s ease;
}

button:hover, a.link-button:hover, .file-button:hover { transform: translateY(-1px); }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-solid);
  color: var(--text);
  padding: 9px 10px;
  outline: none;
  font-size: 13px;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

label span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  margin-bottom: 5px;
  text-transform: uppercase;
}

.required-field > span::after {
  content: " *";
  color: var(--primary);
}

.primary { background: var(--primary); color: #16100b; border-color: var(--primary); }
.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #120b05; }
.secondary, .file-button {
  background: var(--surface-soft);
  color: var(--text);
  border-color: var(--line);
}
.blue { background: var(--blue); color: #fff; border-color: var(--blue); }
.orange { background: var(--primary); color: #16100b; border-color: var(--primary); }
.danger {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 28%, transparent);
}

.notice { border-radius: var(--radius); padding: 11px; font-weight: 700; }
.notice.error { background: #fee2e2; color: #991b1b; }

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at top, var(--primary-soft), transparent 38%), var(--bg);
  padding: 20px;
}

.login-panel {
  width: min(390px, 100%);
  background: var(--surface-solid);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 12px;
  padding: 24px;
}

.stack { display: grid; gap: 13px; }
.mobile-header { display: none; }

.app-shell {
  display: grid;
  grid-template-columns: 284px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar-backdrop { display: none; }
.app-shell.sidebar-collapsed { grid-template-columns: 68px minmax(0, 1fr); }
.app-shell.sidebar-collapsed .sidebar { padding-inline: 8px; }
.app-shell.sidebar-collapsed .brand-block div,
.app-shell.sidebar-collapsed .nav h2,
.app-shell.sidebar-collapsed .sidebar-footer { display: none; }
.app-shell.sidebar-collapsed .sidebar-top {
  display: grid;
  justify-content: center;
  justify-items: center;
  gap: 10px;
  padding: 0 0 14px;
}
.app-shell.sidebar-collapsed .brand-block {
  justify-content: center;
  width: 100%;
}
.app-shell.sidebar-collapsed .brand-mark { margin-inline: auto; }
.app-shell.sidebar-collapsed .menu-toggle {
  position: static;
  width: 36px;
  min-height: 36px;
}
.app-shell.sidebar-collapsed .nav button {
  width: 48px;
  padding: 0;
  justify-content: center;
  font-size: 0;
}
.app-shell.sidebar-collapsed .nav button .nav-icon { font-size: 13px; }

.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 16px 12px;
  position: relative;
  z-index: 20;
}

.sidebar-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  padding: 0 4px 14px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  background: var(--primary);
  color: #16100b;
  font-size: 15px;
  font-weight: 900;
  flex: 0 0 auto;
}

.brand-block h1 {
  font-size: 18px;
  line-height: 1.1;
  letter-spacing: 0;
}

.brand-block p {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
  overflow-wrap: anywhere;
}

.icon-action {
  min-height: 34px;
  width: 34px;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: var(--shadow-soft);
}

.menu-toggle {
  display: grid;
  place-items: center;
  gap: 0;
  align-content: center;
  border-radius: 9px;
}

.menu-toggle span {
  display: block;
  width: 14px;
  height: 1.5px;
  border-radius: 999px;
  background: currentColor;
  margin: 2px 0;
  opacity: .88;
}

.nav {
  display: grid;
  gap: 5px;
  padding: 0 2px;
}

.nav h2, .filter-card h2 {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--muted);
  margin: 7px 0 6px;
}

.nav button {
  justify-content: flex-start;
  gap: 10px;
  background: transparent;
  color: var(--text);
  border-color: transparent;
  min-height: 42px;
  padding-inline: 10px;
  font-size: 14px;
}

.nav button .nav-icon {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
  position: relative;
  flex: 0 0 auto;
}

.nav-icon::before,
.nav-icon::after {
  content: "";
  position: absolute;
  box-sizing: border-box;
}

.nav-map::before {
  inset: 3px 4px;
  border: 1.8px solid currentColor;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
}

.nav-map::after {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
}

.nav-table::before {
  inset: 4px 3px;
  border: 1.8px solid currentColor;
  border-radius: 3px;
}

.nav-table::after {
  left: 4px;
  right: 4px;
  top: 9px;
  height: 1.8px;
  background: currentColor;
  box-shadow: 0 4px 0 currentColor;
}

.nav-dashboard::before {
  inset: 4px;
  border: 1.8px solid currentColor;
  border-radius: 50%;
  clip-path: inset(0 0 45% 0);
}

.nav-dashboard::after {
  left: 10px;
  top: 10px;
  width: 7px;
  height: 1.8px;
  border-radius: 999px;
  background: currentColor;
  transform: rotate(-35deg);
  transform-origin: left center;
}

.nav-admin::before {
  inset: 4px;
  border: 1.8px solid currentColor;
  border-radius: 50%;
}

.nav-admin::after {
  left: 9px;
  top: 2px;
  width: 4px;
  height: 18px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 0 0 currentColor;
  transform: rotate(45deg);
}

.theme-toggle {
  gap: 9px;
}

.theme-icon-button {
  padding: 0;
}

.theme-icon {
  width: 18px;
  height: 18px;
  display: block;
  position: relative;
  border-radius: 50%;
  border: 2px solid currentColor;
}

.theme-icon::before {
  content: "";
  position: absolute;
  inset: 2px 2px 2px 8px;
  border-radius: 0 999px 999px 0;
  background: currentColor;
}

.theme-icon::after {
  content: "";
  position: absolute;
  left: -5px;
  right: -5px;
  top: 7px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  opacity: .28;
}

.nav button.active, .tabs button.active, .draw-tool.active {
  background: var(--primary-soft);
  color: var(--primary-dark);
  border-color: color-mix(in srgb, var(--primary) 36%, transparent);
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 8px;
  padding: 0 2px;
}

.workspace { min-width: 0; position: relative; }
.view {
  display: none;
  height: 100vh;
  overflow: auto;
  padding: 18px;
  background: var(--bg);
}
.view.active { display: block; }

#mapView { padding: 0; position: relative; overflow: hidden; }
#map {
  height: 100vh;
  width: 100%;
  z-index: 1;
  background: #d9e2da;
}

:root[data-theme="dark"] #map { background: #d9e2da; }

.map-panel {
  position: absolute;
  z-index: 5;
  top: 12px;
  left: 12px;
  width: min(340px, calc(100vw - 44px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  padding: 8px;
  display: grid;
  align-content: start;
  gap: 8px;
  background: var(--map-panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.map-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 0 2px 4px;
}

.map-panel-header strong {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--muted);
}

.panel-toggle {
  min-height: 28px;
  width: 28px;
  box-shadow: none;
  border-radius: 8px;
}

.filter-icon {
  width: 14px;
  height: 14px;
  position: relative;
  display: block;
}

.filter-icon::before,
.filter-icon::after {
  content: "";
  position: absolute;
  left: 1px;
  right: 1px;
  height: 1.5px;
  border-radius: 999px;
  background: currentColor;
}

.filter-icon::before {
  top: 3px;
  box-shadow: 0 8px 0 currentColor;
}

.filter-icon::after {
  top: 2px;
  left: 8px;
  right: auto;
  width: 4px;
  height: 4px;
  border: 1.5px solid currentColor;
  background: var(--surface-solid);
  box-shadow: -6px 8px 0 -1.5px var(--surface-solid), -6px 8px 0 0 currentColor;
}

.map-panel-body {
  display: grid;
  gap: 8px;
}

.map-panel.collapsed {
  width: auto;
  padding: 6px;
  border-radius: 999px;
}

.map-panel.collapsed .map-panel-header { padding: 0; min-height: 30px; }
.map-panel.collapsed .map-panel-header strong,
.map-panel.collapsed .map-panel-body { display: none; }
.map-panel.collapsed .panel-toggle { border-radius: 999px; }

.search-card, .panel-control, .filter-card {
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: none;
}

.search-card {
  min-height: 56px;
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 9px;
  align-items: center;
  padding: 9px 10px;
}

.search-icon {
  width: 21px;
  height: 21px;
  border: 1.8px solid var(--text);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: transparent;
  position: relative;
  opacity: .82;
}

.search-icon::after {
  content: "";
  width: 8px;
  height: 1.8px;
  background: var(--text);
  position: absolute;
  right: -5px;
  bottom: 1px;
  transform: rotate(45deg);
}

.search-card input {
  border: 0;
  padding: 0;
  background: transparent;
  font-size: 14px;
  box-shadow: none;
}

.panel-control { display: grid; padding: 10px; }
.panel-control select {
  border: 0;
  padding: 0;
  background: transparent;
  font-size: 14px;
  box-shadow: none;
}

.filter-card {
  padding: 10px;
  display: grid;
  gap: 9px;
}

.filter-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.filter-options label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-solid);
  padding: 0 9px;
  font-size: 13px;
  font-weight: 650;
}

.filter-options input {
  width: 14px;
  height: 14px;
  accent-color: var(--primary);
}

.draw-toolbar {
  position: absolute;
  z-index: 6;
  left: 14px;
  bottom: 18px;
  transform: none;
  display: flex;
  gap: 5px;
  padding: 5px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.draw-tool {
  width: 36px;
  min-height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: none;
  border-radius: 9px;
}

.draw-tool:hover {
  background: var(--primary-soft);
  border-color: color-mix(in srgb, var(--primary) 36%, transparent);
}

.tool-icon {
  width: 18px;
  height: 18px;
  display: block;
  position: relative;
  color: currentColor;
}

.tool-light::before {
  content: "";
  position: absolute;
  inset: 2px 4px 5px;
  border: 2px solid var(--primary);
  border-radius: 50% 50% 45% 45%;
  background: color-mix(in srgb, var(--primary) 18%, transparent);
}

.tool-light::after {
  content: "";
  position: absolute;
  left: 7px;
  bottom: 1px;
  width: 4px;
  height: 5px;
  border-radius: 1px;
  background: var(--primary);
}

.tool-cabinet::before {
  content: "";
  position: absolute;
  left: 4px;
  right: 4px;
  top: 2px;
  bottom: 2px;
  border: 2px solid var(--blue);
  border-radius: 3px;
  background: color-mix(in srgb, var(--blue) 16%, transparent);
}

.tool-cabinet::after {
  content: "";
  position: absolute;
  left: 8px;
  top: 5px;
  width: 2px;
  height: 8px;
  border-radius: 999px;
  background: var(--blue);
  box-shadow:
    -3px 0 0 var(--blue),
    3px 0 0 var(--blue),
    0 7px 0 -1px var(--blue);
}

.tool-cable::before {
  content: "";
  position: absolute;
  left: 2px;
  right: 2px;
  top: 8px;
  height: 4px;
  border-radius: 999px;
  background: var(--primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 22%, transparent);
}

.tool-select::before {
  content: "";
  position: absolute;
  inset: 2px;
  border: 2px solid var(--line-strong);
  border-radius: 4px;
}

.tool-select::after {
  content: "";
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 6px;
  height: 6px;
  border-right: 2px solid var(--primary);
  border-bottom: 2px solid var(--primary);
}

.draw-tool.active .tool-select::before,
.draw-tool.active .tool-cabinet::before,
.draw-tool.active .tool-light::before {
  border-color: var(--primary);
}

.draw-tool.active .tool-cable::before {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 42%, transparent);
}

.map-tools {
  position: absolute;
  z-index: 6;
  right: 12px;
  bottom: 20px;
  display: grid;
  gap: 6px;
}

.object-card {
  position: absolute;
  left: 14px;
  bottom: 76px;
  z-index: 8;
  width: min(372px, calc(100vw - 340px));
  min-width: 320px;
  background: var(--surface-solid);
  color: var(--text);
  border: 1px solid var(--line);
  border-top: 3px solid var(--primary);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 12px;
}

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

.object-card-head strong {
  display: block;
  font-size: 18px;
  line-height: 1.15;
}

.object-card-head span {
  display: block;
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
  margin-top: 3px;
}

.object-card-close {
  min-height: 30px;
  width: 30px;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--text);
  font-size: 20px;
}

.object-card-icons {
  position: absolute;
  top: 10px;
  right: 48px;
  display: flex;
  gap: 6px;
}

.object-card-icons button {
  width: 36px;
  min-height: 36px;
  padding: 0;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.card-icon {
  width: 18px;
  height: 18px;
  display: block;
  position: relative;
}

.card-pin::before {
  content: "";
  position: absolute;
  inset: 2px 5px 5px;
  border: 2px solid currentColor;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
}

.card-pin::after {
  content: "";
  position: absolute;
  left: 3px;
  right: 3px;
  bottom: 0;
  height: 5px;
  border: 2px solid currentColor;
  border-top: 0;
  border-radius: 50%;
}

.card-map::before {
  content: "";
  position: absolute;
  inset: 2px;
  border: 2px solid currentColor;
  border-radius: 3px;
  transform: skewY(-12deg);
}

.card-map::after {
  content: "";
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 8px;
  width: 2px;
  background: currentColor;
  box-shadow: 5px 0 0 currentColor;
}

.card-close::before,
.card-close::after {
  content: "";
  position: absolute;
  left: 2px;
  right: 2px;
  top: 8px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.card-close::before { transform: rotate(45deg); }
.card-close::after { transform: rotate(-45deg); }

.object-card-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.object-card-actions button,
.object-card-more {
  min-height: 42px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.object-card-actions button {
  justify-content: space-between;
}

.info-dot {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 2px solid currentColor;
  border-radius: 50%;
  font-size: 12px;
  text-transform: none;
}

.card-action-icon {
  width: 18px;
  height: 18px;
  position: relative;
  display: inline-block;
  flex: 0 0 18px;
}

.card-move::before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.card-move::after {
  content: "";
  position: absolute;
  left: 1px;
  top: 8px;
  width: 16px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 -7px 0 -0.5px currentColor, 0 7px 0 -0.5px currentColor;
}

.card-copy::before,
.card-copy::after {
  content: "";
  position: absolute;
  border: 2px solid currentColor;
  border-radius: 4px;
}

.card-copy::before {
  inset: 5px 1px 1px 5px;
}

.card-copy::after {
  inset: 1px 5px 5px 1px;
  opacity: .62;
}

.object-card-more {
  width: 50%;
  margin-top: 6px;
  font-size: 24px;
  line-height: 1;
}

.leaflet-control-zoom, .leaflet-control-layers {
  border: 0 !important;
  box-shadow: var(--shadow-soft) !important;
}

.leaflet-control-zoom a, .leaflet-control-layers {
  background: var(--surface-solid) !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
}

.leaflet-control-layers {
  border-radius: 10px !important;
  overflow: hidden;
}

.leaflet-control-layers-toggle {
  width: 42px !important;
  height: 42px !important;
  background-size: 22px 22px !important;
}

.leaflet-control-layers-expanded {
  min-width: 210px;
  padding: 8px !important;
  background: var(--surface-solid) !important;
  border: 1px solid var(--line) !important;
  border-radius: 10px !important;
  box-shadow: var(--shadow) !important;
}

.leaflet-control-layers-list {
  display: grid;
  gap: 3px;
}

.leaflet-control-layers-base,
.leaflet-control-layers-overlays {
  display: grid;
  gap: 3px;
}

.leaflet-control-layers-separator {
  height: 1px !important;
  margin: 6px 0 !important;
  border: 0 !important;
  background: var(--line);
}

.leaflet-control-layers label {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 34px;
  margin: 0 !important;
  padding: 0 8px;
  border-radius: 7px;
  color: var(--text);
  font-size: 12px;
  font-weight: 750;
  text-transform: none;
  cursor: pointer;
}

.leaflet-control-layers label:hover {
  background: var(--primary-soft);
}

.leaflet-control-layers label span {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
  text-transform: none;
}

.leaflet-control-layers-selector {
  width: 16px;
  height: 16px;
  margin: 0 !important;
  accent-color: var(--primary);
  flex: 0 0 auto;
}

/* Pegman (Street View) kontroll — dra-og-slipp for å åpne Google Street View */
.leaflet-control-pegman {
  background: var(--surface-solid);
  border: 1px solid var(--line);
  border-radius: 4px;
  width: 34px;
  height: 34px;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-soft);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  transition: background .15s, transform .15s;
}
.leaflet-control-pegman:hover { background: rgba(251,188,4,.12); }
.leaflet-control-pegman:active,
.leaflet-control-pegman.is-dragging { cursor: grabbing; transform: scale(0.95); }
.leaflet-control-pegman svg { display: block; pointer-events: none; }

/* "Ghost" som følger musepekeren under dra-operasjonen */
.pegman-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  width: 40px;
  height: 44px;
  transform: translate(-20px, -40px);
  filter: drop-shadow(0 4px 6px rgba(0,0,0,.4));
}

/* Mens dra pågår: vis spesielt kart-cursor + lite hint */
.map-pegman-mode { cursor: crosshair !important; }
.map-pegman-mode .leaflet-interactive { cursor: crosshair !important; }
.pegman-hint {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,.78);
  color: #fff;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .02em;
  z-index: 8;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,.3);
}

.draw-hint {
  position: absolute;
  top: 14px;
  left: min(370px, calc(100vw - 48px));
  max-width: min(460px, calc(100vw - 430px));
  z-index: 7;
  background: var(--surface-solid);
  color: var(--text);
  border: 1px solid var(--line);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius);
  padding: 9px 11px;
  font-size: 13px;
  font-weight: 750;
  box-shadow: var(--shadow-soft);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
}
.panel-header h2 { font-size: 22px; }
.panel-header p { color: var(--muted); margin-top: 3px; font-size: 13px; }
.actions { display: flex; gap: 7px; flex-wrap: wrap; }
.tabs { display: flex; gap: 7px; margin-bottom: 11px; }
.tabs button { background: var(--surface-soft); color: var(--text); border-color: var(--line); }

.bulk-bar {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--primary-soft);
  border: 1px solid color-mix(in srgb, var(--primary) 28%, transparent);
  border-radius: var(--radius);
  padding: 9px;
  margin-bottom: 11px;
}
.bulk-bar select { width: 200px; }

.table-wrap {
  background: var(--surface-solid);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: auto;
  box-shadow: var(--shadow-soft);
}

table { width: 100%; border-collapse: collapse; min-width: 880px; }
th, td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
}
th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}
tr:hover td { background: color-mix(in srgb, var(--primary) 6%, transparent); }

.status {
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 800;
  display: inline-block;
}
.status.ok { background: #dcfce7; color: #166534; }
.status.bad { background: #fee2e2; color: #991b1b; }
.status.plan { background: #ffedd5; color: #9a3412; }

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

.stat-card, .panel {
  background: var(--surface-solid);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  box-shadow: var(--shadow-soft);
}
.stat-card span { color: var(--muted); font-weight: 800; font-size: 10px; text-transform: uppercase; }
.stat-card strong { display: block; font-size: 24px; margin-top: 4px; }
.chart-grid, .admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.panel canvas { max-height: 300px; }

.user-list { display: grid; gap: 9px; margin-top: 11px; }
.user-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px auto;
  gap: 9px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px;
}
.user-row strong, .user-row span { overflow-wrap: anywhere; }

dialog {
  width: min(720px, calc(100vw - 24px));
  border: 0;
  border-radius: 12px;
  padding: 0;
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(0, 0, 0, .58); }
.object-form { padding: 18px; display: grid; gap: 15px; }
.dialog-header, .dialog-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.dialog-header p { color: var(--muted); margin-top: 3px; font-size: 13px; }
.icon-btn {
  min-height: 32px;
  width: 32px;
  padding: 0;
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 20px;
}
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .wide { grid-column: 1 / -1; }
.settings-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.dialog-actions { justify-content: flex-end; }
.dialog-actions .danger { margin-right: auto; }

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 10000;
  background: var(--surface-solid);
  color: var(--text);
  border: 1px solid var(--line);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 750;
  box-shadow: var(--shadow);
}

.map-point-icon {
  background: transparent;
  border: 0;
  image-rendering: auto;
}

.leaflet-container.crosshair { cursor: crosshair; }

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 260px minmax(0, 1fr); }
  .map-panel { width: min(320px, calc(100vw - 46px)); }
  .draw-hint {
    left: min(346px, calc(100vw - 48px));
    max-width: calc(100vw - 410px);
  }
  .stats-grid { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
}

@media (max-width: 760px) {
  .mobile-header {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 52px;
    z-index: 30;
    align-items: center;
    justify-content: space-between;
    padding: 7px 9px;
    background: var(--surface-solid);
    border-bottom: 1px solid var(--line);
  }

  .app-shell, .app-shell.sidebar-collapsed {
    grid-template-columns: 1fr;
    padding-top: 52px;
  }
  .hide-mobile { display: none; }
  .sidebar {
    position: fixed;
    top: 52px;
    left: 0;
    bottom: 0;
    width: min(292px, calc(100vw - 46px));
    transform: translateX(-105%);
    transition: transform .18s ease;
    box-shadow: var(--shadow);
    overflow: auto;
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-backdrop {
    position: fixed;
    inset: 52px 0 0;
    z-index: 15;
    background: rgba(0, 0, 0, .42);
  }
  body.sidebar-open .sidebar-backdrop { display: block; }

  .view {
    height: auto;
    min-height: calc(100vh - 52px);
    padding: 14px;
  }
  #map { height: calc(100vh - 52px); }
  #mapView { min-height: calc(100vh - 52px); }

  .map-panel {
    top: 60px;
    left: 8px;
    width: min(320px, calc(100vw - 68px));
    height: auto;
    max-height: 44vh;
  }
  .map-panel.collapsed { width: auto; max-height: none; }
  .search-card { min-height: 52px; }

  .draw-toolbar {
    left: 8px;
    right: auto;
    bottom: 12px;
  }
  .draw-tool {
    width: 36px;
    min-height: 36px;
  }

  .draw-hint {
    top: auto;
    left: 9px;
    right: 9px;
    bottom: 76px;
    max-width: none;
  }

  .object-card {
    left: 8px;
    right: 8px;
    bottom: 66px;
    width: auto;
    min-width: 0;
  }

  .object-card-icons {
    position: static;
    margin: 0 0 8px;
  }

  .map-tools { right: 10px; bottom: 14px; }
  .panel-header, .actions { flex-direction: column; align-items: stretch; }
  .stats-grid, .chart-grid, .admin-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .user-row { grid-template-columns: 1fr; }
  .bulk-bar { align-items: stretch; flex-direction: column; }
  .bulk-bar select { width: 100%; }
}

@media (max-width: 420px) {
  .map-panel { max-height: 48vh; gap: 8px; }
  .panel-control, .filter-card { padding: 9px; }
  .tabs { overflow-x: auto; }
  button, a.link-button, .file-button { width: 100%; }
  .draw-tool, .icon-action, .panel-toggle { width: 36px; }
  .icon-action { flex: 0 0 36px; }
  .mobile-header .icon-action { width: auto; padding-inline: 9px; }
  .theme-label { display: none; }
}
