:root {
  --bg: #f4f1ec;
  --panel: #ffffff;
  --ink: #161616;
  --muted: #6b6560;
  --line: #e6e0d8;
  --accent: #ff7a1a;
  --accent-dark: #e86a12;
  --here: #c45a10;
  --near: #8a5a12;
  --danger: #b42318;
  --header-bg: #0c0c0c;
  --shadow: 0 12px 32px rgba(12, 12, 12, 0.08);
  --radius: 16px;
  --header: 64px;
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
button, input, textarea, select { font: inherit; }
a { color: inherit; }

.header {
  height: var(--header);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  background: var(--header-bg);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
}
.header a { text-decoration: none; }
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.brand-logo {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: block;
  object-fit: contain;
  border-radius: 4px;
}
.brand-copy { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: 0.01em; }
.brand-sub { font-size: 11px; color: #b9b3ad; font-weight: 500; margin-top: 2px; }
.nav { display: flex; gap: 4px; align-items: center; }
.nav a, .nav button {
  border: 0;
  background: transparent;
  color: #cfc8c0;
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 500;
}
.nav a.active { color: var(--accent); }
.nav a:hover, .nav button:hover { color: #fff; }

.btn {
  border: 0;
  border-radius: 12px;
  padding: 11px 16px;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}
.btn:hover { background: var(--accent-dark); }
.btn.secondary {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn.secondary:hover { background: #f7f4f0; }
.btn.danger { background: var(--danger); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.pale {
  background: transparent;
  color: #9aa6b4;
  font-weight: 500;
}
.btn.pale:hover {
  background: #f4f6f9;
  color: var(--muted);
}
.row-actions { white-space: nowrap; }
.row-actions .btn { margin-right: 6px; }

.login-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 88px 24px 24px;
  position: relative;
  background:
    linear-gradient(180deg, rgba(8, 8, 8, 0.72), rgba(8, 8, 8, 0.78)),
    radial-gradient(900px 480px at 18% 35%, rgba(255, 122, 26, 0.18), transparent 55%),
    #1a1410;
}
.login-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      90deg,
      transparent 0 42px,
      rgba(255, 255, 255, 0.015) 42px 43px
    );
  pointer-events: none;
}
.login-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header);
  display: flex;
  align-items: center;
  padding: 0 22px;
  background: var(--header-bg);
  z-index: 2;
}
.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  padding: 28px;
  position: relative;
  z-index: 1;
}
.login-pill {
  display: inline-block;
  margin: 0 0 12px;
  padding: 6px 12px;
  border: 1px solid #f3d2b8;
  background: #fff6ee;
  color: var(--accent-dark);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.login-card h1 {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.03em;
  line-height: 1.15;
}
.login-card > p:not(.login-pill):not(.error) { margin: 0 0 20px; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field span { font-size: 13px; color: var(--muted); font-weight: 500; }
.field input, .field textarea, .field select {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  background: #fff;
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: 2px solid rgba(255, 122, 26, 0.35);
  border-color: var(--accent);
}
.error { color: var(--danger); min-height: 20px; margin: 0 0 8px; font-size: 14px; }
.login-card .btn { width: 100%; padding: 13px 16px; font-size: 15px; }

.app { height: calc(100% - var(--header)); display: grid; grid-template-columns: 360px 1fr 360px; }
.side {
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow: auto;
  padding: 16px;
}
.side.right { border-right: 0; border-left: 1px solid var(--line); }
#map { min-height: 0; }

.search-box { position: relative; width: 100%; min-width: 0; }
.search-box input { width: 100%; }
.search-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
}
.search-row .btn {
  width: 100%;
  padding: 10px 12px;
  white-space: nowrap;
}
.suggest {
  position: absolute;
  left: 0; right: 0; top: calc(100% + 4px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 5;
  max-height: 280px;
  overflow: auto;
}
.suggest button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f0f3f7;
}
.suggest button:hover { background: #fff6ee; }

.hint, .warn, .empty { font-size: 14px; color: var(--muted); }
.warn { color: #8a4b12; background: #fff6ee; padding: 10px 12px; border-radius: 12px; }
.place { margin: 12px 0; }
.place b { display: block; margin-bottom: 4px; }
.place small { color: var(--muted); }

.block-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 18px 0 4px;
}
#results .block-title:first-child { margin-top: 0; }
.block-title h2 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 800; }
.block-title.here h2 { color: var(--here); }
.block-title.near h2 { color: var(--near); }
.count { font-size: 12px; color: var(--muted); }
.block-hint {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

.card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: #fff;
  cursor: pointer;
}
.card:hover { border-color: #e0c4a8; }
.card.open { border-color: var(--accent); }
.card.pinned { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.card-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.card h3 { margin: 0; font-size: 15px; font-weight: 700; flex: 1; }
.card .meta { color: var(--muted); font-size: 13px; margin: 2px 0; }
.km { font-weight: 700; color: var(--near); font-size: 13px; white-space: nowrap; }
.rating {
  flex-shrink: 0;
  min-width: 1.6em;
  padding: 2px 7px;
  border-radius: 999px;
  background: #fff1e6;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}
.card-work {
  display: none;
  margin: 8px 0 0;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.4;
}
.card.open .card-work { display: block; }

.page { max-width: 1200px; margin: 0 auto; padding: 24px; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 16px; }
.toolbar h1 { margin: 0; font-size: 28px; font-weight: 800; letter-spacing: -0.03em; }
.toolbar-actions { display: flex; gap: 8px; align-items: center; }
.toolbar-actions input[type="search"] {
  width: min(280px, 42vw);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
}
.name-cell { font-weight: 700; }
table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; color: var(--muted); background: #faf7f3; letter-spacing: 0.04em; }
.zones, .location { font-size: 13px; color: var(--muted); }
.location { max-width: 240px; }
.field-hint { font-size: 12px; color: var(--muted); line-height: 1.35; }
.modal .suggest { z-index: 40; }
.card-work .meta-line {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.modal-back {
  position: fixed; inset: 0; background: rgba(12, 12, 12, 0.55);
  display: none; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow: auto; z-index: 30;
}
.modal-back.open { display: flex; }
.modal {
  width: min(760px, 100%);
  background: #fff;
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.2);
}
.modal h2 { margin: 0 0 16px; font-weight: 800; letter-spacing: -0.02em; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tree { border: 1px solid var(--line); border-radius: 12px; max-height: 420px; overflow: auto; padding: 8px; }
.oblast { border-bottom: 1px solid #f0f3f7; padding: 8px; }
.oblast summary { cursor: pointer; font-weight: 600; display: flex; gap: 8px; align-items: center; }
.children { padding: 8px 8px 4px 26px; display: grid; gap: 6px; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.filter { margin: 0 0 10px; width: 100%; }

@media (max-width: 1100px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 50vh auto; }
  .side { border: 0; border-bottom: 1px solid var(--line); }
}
