:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #667085;
  --line: #d8dee8;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --success-bg: #ecfdf3;
  --success: #067647;
  --warning-bg: #fff8e6;
  --warning: #92400e;
  --shadow: 0 14px 35px rgba(24, 36, 54, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

input,
select,
button,
textarea {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  color: var(--text);
  background: #fff;
}

textarea {
  min-height: 220px;
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: #344054;
  font-weight: 650;
}

h1,
h2 {
  margin: 0 0 16px;
  line-height: 1.2;
}

h1 {
  font-size: 1.45rem;
}

h2 {
  font-size: 1.08rem;
}

.topbar {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px clamp(14px, 3vw, 28px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  position: sticky;
  top: 0;
  z-index: 500;
}

.topbar div {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.topbar strong,
.topbar span {
  overflow-wrap: anywhere;
}

.topbar span {
  color: var(--muted);
  font-size: 0.94rem;
}

.mode-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #fff7d6;
  border: 1px solid #f2d675;
  color: #8a5a00;
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1;
}

.topbar nav {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.button,
button.button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 14px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
}

.button:hover {
  text-decoration: none;
  border-color: #aab4c3;
}

.button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.button.primary:hover {
  background: var(--primary-dark);
}

.button.danger {
  border-color: #fecdca;
  background: var(--danger-bg);
  color: var(--danger);
}

.button.small {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 0.9rem;
}

.button-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.demo-login-form {
  margin-top: 12px;
}

.auth-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(100%, 460px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(20px, 4vw, 32px);
  box-shadow: var(--shadow);
}

.install-card {
  width: min(100%, 760px);
}

.form-grid,
.settings-form {
  display: grid;
  gap: 14px;
}

.form-grid.two,
.form-grid.three {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-grid .button,
.form-grid button {
  justify-self: start;
}

.alert {
  margin: 0 0 14px;
  padding: 11px 13px;
  border-radius: 8px;
  border: 1px solid var(--line);
  font-weight: 650;
}

.alert.success,
.oauth-state.ok {
  border-color: #abefc6;
  background: var(--success-bg);
  color: var(--success);
}

.alert.error {
  border-color: #fecdca;
  background: var(--danger-bg);
  color: var(--danger);
}

.oauth-state.warn {
  border-color: #fedf89;
  background: var(--warning-bg);
  color: var(--warning);
}

.muted {
  color: var(--muted);
}

.copy-line {
  display: block;
  overflow-x: auto;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  white-space: nowrap;
}

.map-shell {
  height: calc(100vh - 58px);
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
}

.side-panel {
  padding: 16px;
  border-right: 1px solid var(--line);
  background: #fff;
  overflow: auto;
}

.date-form {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.search-panel {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.search-results {
  max-height: 245px;
  overflow: auto;
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.search-result {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  padding: 7px 8px;
  border: 1px solid #e5e7eb;
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

.search-result.selected {
  border-color: #ca8a04;
  background: #fef9c3;
}

.search-result input {
  width: 16px;
  min-height: 16px;
  margin-top: 3px;
}

.search-result-main {
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.search-result-sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.search-empty {
  color: var(--muted);
  font-size: 0.92rem;
  padding: 4px 2px;
}

.status-box {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #f8fafc;
  color: #344054;
}

.legend {
  display: grid;
  gap: 9px;
  margin-top: 14px;
  color: #344054;
  font-size: 0.94rem;
}

.legend div {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid #111827;
  display: inline-block;
}

.dot.red { background: #dc2626; border-color: #991b1b; }
.dot.orange { background: #f97316; border-color: #9a3412; }
.dot.green { background: #16a34a; border-color: #166534; }
.dot.gray { background: #6b7280; border-color: #374151; }
.dot.blue { background: #2563eb; border-color: #1e3a8a; }
.dot.white { background: #fff; border-color: #111827; }

.map {
  width: 100%;
  height: 100%;
  min-height: 0;
  background: #dce7ef;
}

.map-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  height: 100%;
}

.map-attribution {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 800;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 18px rgba(24, 36, 54, 0.14);
}

.mapy-logo-link,
.mapy-copy-link {
  display: inline-flex;
  align-items: center;
}

.mapy-logo {
  display: block;
  height: 30px;
  width: auto;
}

.mapy-copy-link {
  color: #17202a;
  font-size: 0.92rem;
  font-weight: 600;
  text-decoration: none;
}

.mapy-copy-link:hover {
  text-decoration: underline;
}

.leaflet-tooltip.point-label {
  border: 1px solid rgba(17, 24, 39, 0.2);
  border-radius: 6px;
  box-shadow: 0 8px 18px rgba(24, 36, 54, 0.12);
  font-weight: 750;
  color: #17202a;
  max-width: 220px;
  padding: 4px 8px;
  line-height: 1.2;
  pointer-events: none;
}

.leaflet-tooltip-top.point-label::before,
.leaflet-tooltip-right.point-label::before,
.leaflet-tooltip-bottom.point-label::before,
.leaflet-tooltip-left.point-label::before {
  display: none;
}

.popup-table {
  border-collapse: collapse;
  min-width: 220px;
  max-width: 330px;
}

.popup-table th,
.popup-table td {
  text-align: left;
  vertical-align: top;
  padding: 5px 7px;
  border-bottom: 1px solid #e5e7eb;
}

.popup-table th {
  color: #475467;
  white-space: nowrap;
}

.popup-status {
  margin: 0 0 8px;
  font-weight: 800;
}

.admin-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 18px auto 34px;
  display: grid;
  gap: 16px;
}

.panel,
.subpanel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(16px, 2.4vw, 22px);
}

.subpanel {
  background: #fbfcfe;
}

.columns-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

fieldset {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

legend {
  padding: 0 6px;
  font-weight: 800;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-weight: 500;
}

.check input {
  width: 17px;
  min-height: 17px;
  flex: 0 0 17px;
}

.oauth-state {
  margin: 12px 0;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  font-weight: 650;
}

.stats {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.stats div {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.stats dt {
  color: var(--muted);
  font-size: 0.86rem;
}

.stats dd {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
  font-weight: 750;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 9px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: #475467;
  font-size: 0.9rem;
}

td.actions form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.config-output {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.88rem;
}

@media (max-width: 820px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .map-shell {
    min-height: calc(100vh - 98px);
    height: auto;
    grid-template-columns: 1fr;
  }

  .side-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .map {
    height: auto;
    min-height: 62vh;
  }

  .map-stage {
    height: auto;
    min-height: 62vh;
  }

  .form-grid.two,
  .form-grid.three,
  .columns-grid,
  .stats {
    grid-template-columns: 1fr;
  }
}
