:root {
  --bg: #0f1218;
  --surface: #181c27;
  --border: #2a3142;
  --text: #e8eaef;
  --muted: #8b93a7;
  --accent: #c9a227;
  --ok: #3d9a6b;
  --no: #b84c4c;
  --chip: #252a38;
  --header-base-h: 57px;
  --touch-min: 44px;
  --layout-h: calc(100vh - var(--header-base-h));
  --layout-h-d: calc(100dvh - var(--header-base-h));
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: rgba(201, 162, 39, 0.15);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(1rem + env(safe-area-inset-top, 0px)) calc(1rem + env(safe-area-inset-right, 0px))
    calc(1rem + env(safe-area-inset-bottom, 0px)) calc(1rem + env(safe-area-inset-left, 0px));
  min-height: 100dvh;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  max-width: 360px;
  width: 100%;
  text-align: center;
}

.login-card h1 {
  margin: 0 0 0.5rem;
  font-size: 1.35rem;
}

.login-card input {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  margin: 1rem 0;
  font-size: 16px;
}

.login-accounts {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0 0 1rem;
  text-align: left;
}

.login-account-opt {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.75rem 0.85rem;
  min-height: 48px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.login-account-opt:has(input:checked) {
  border-color: var(--accent);
  background: rgba(201, 162, 39, 0.08);
}

.login-account-opt input {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.login-account-name {
  font-size: 0.95rem;
  line-height: 1.3;
  color: var(--text);
}

.login-card button {
  width: 100%;
  padding: 0.75rem;
  min-height: 48px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: #1a1508;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
}

.error {
  color: var(--no);
  margin-top: 0.75rem;
}

.app-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.65rem 1rem;
  padding-top: calc(0.65rem + env(safe-area-inset-top, 0px));
  padding-left: calc(1rem + env(safe-area-inset-left, 0px));
  padding-right: calc(1rem + env(safe-area-inset-right, 0px));
  border-bottom: 1px solid var(--border);
  background: rgba(24, 28, 39, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 1200;
}

.header-lead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  width: 100%;
  flex: 1 1 100%;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
}

.btn-header-logout {
  flex-shrink: 0;
  min-height: 44px;
  min-width: 5.5rem;
  font-weight: 600;
  z-index: 2;
}

.user-chip {
  font-size: 0.72rem;
  color: var(--muted);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 960px) {
  .user-chip {
    max-width: 100px;
  }
}

@media (max-width: 560px) {
  .my-motivation-grid {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }

  .my-motivation-card {
    min-height: 50px;
  }

  .my-motivation-lines {
    font-size: 0.8rem;
  }
}

.header-logo {
  display: block;
  /* Явная ширина: в WebKit во flex иногда даёт 0×0 при height+aspect-ratio+max-width */
  width: clamp(100px, 52vw, 236px);
  height: auto;
  max-height: 48px;
  flex-shrink: 0;
  object-fit: contain;
  object-position: left center;
}

.build-chip {
  font-size: 0.65rem;
  color: var(--muted);
  white-space: nowrap;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toolbar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  width: 100%;
}

.toolbar-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.toolbar input[type="search"] {
  padding: 0.5rem 0.85rem;
  min-height: var(--touch-min);
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  min-width: 160px;
  font-size: 0.9rem;
  flex: 1 1 260px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.toolbar button,
.toggle-btn {
  padding: 0.5rem 0.9rem;
  min-height: var(--touch-min);
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--chip);
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
  transition: border-color 0.15s ease, transform 0.12s ease, background 0.15s ease;
}

.toolbar-filters .toggle-btn {
  flex-shrink: 0;
  white-space: nowrap;
}

.toggle-btn:focus-visible,
.toolbar input:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.toolbar-logout {
  border-color: rgba(184, 76, 76, 0.45);
  color: #e8b4b4;
}

.toolbar button:hover,
.toggle-btn:hover {
  border-color: var(--muted);
  transform: translateY(-1px);
}

.toggle-btn.active {
  background: var(--accent);
  color: #1a1508;
  border-color: var(--accent);
}

.toggle-btn,
.btn-file,
.btn-tape-save,
.tape-template-btn,
.detail-quick-btn {
  box-shadow: none !important;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 380px);
  grid-template-rows: minmax(0, 1fr);
  height: var(--layout-h);
  height: var(--layout-h-d);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  padding-top: env(safe-area-inset-top, 0px);
  z-index: 10001;
  background: rgba(0, 0, 0, 0.48);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.28s ease, visibility 0.28s;
  -webkit-tap-highlight-color: transparent;
}

.drawer-backdrop.open {
  opacity: 1;
  visibility: visible;
}

@media (min-width: 961px) {
  .drawer-backdrop {
    display: none !important;
  }
}

.detail-drawer-head {
  display: none;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 0.5rem 0.5rem 0.65rem;
  margin: -0.5rem -1rem 0.65rem;
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  touch-action: none;
  cursor: grab;
}

.detail-drawer-head:active {
  cursor: grabbing;
}

.drawer-handle {
  width: 48px;
  height: 6px;
  border-radius: 4px;
  background: var(--muted);
  opacity: 0.85;
}

.drawer-close {
  position: absolute;
  right: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--chip);
  color: var(--text);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tape-block {
  margin: 0 0 0.85rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}

.tape-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 0.25rem;
}

.tape-hint {
  margin: 0 0 0.45rem;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.35;
}

.tape-hint-kbd {
  display: inline-block;
  margin-left: 0.15rem;
  padding: 0.08rem 0.28rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text);
}

.tape-block textarea {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  min-height: 88px;
  resize: vertical;
  margin-bottom: 0.5rem;
}

.tape-templates {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0 0 0.5rem;
}

.tape-template-btn {
  border: 1px solid var(--border);
  background: var(--chip);
  color: var(--text);
  border-radius: 999px;
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
  line-height: 1.25;
  cursor: pointer;
  min-height: 34px;
  -webkit-tap-highlight-color: transparent;
}

.tape-template-btn:active {
  opacity: 0.85;
}

.btn-tape-save {
  width: 100%;
  padding: 0.85rem 1rem;
  min-height: 48px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: #1a1508;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
}

.btn-tape-save:active {
  opacity: 0.92;
}

.btn-tape-save:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.history-order-hint {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.7rem;
}

@media (max-width: 960px) {
  .sidebar-hint-desktop {
    display: none;
  }

  .sidebar-hint-mobile {
    display: block;
  }

  .my-motivation {
    margin: 0.2rem 0.75rem 0.55rem;
  }

  .my-motivation-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.45rem;
  }

  .my-motivation-card {
    min-height: 48px;
    padding: 0.5rem 0.55rem;
  }

  .my-motivation-value {
    font-size: 0.9rem;
  }

  .layout {
    grid-template-columns: 1fr;
    height: auto;
    min-height: var(--layout-h);
    min-height: var(--layout-h-d);
  }

  #map-wrap {
    height: min(42dvh, 46vh) !important;
    min-height: min(220px, 42dvh);
    flex: 1;
  }

  .sidebar {
    border-left: none;
    border-top: 1px solid var(--border);
    height: auto;
    max-height: none;
    min-height: 0;
    flex: 1;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .sidebar-list-wrap {
    flex: 1 1 auto;
    min-height: min(140px, 28dvh);
    max-height: min(40dvh, 360px);
  }

  .detail-drawer-head {
    display: flex;
  }

  .sidebar .detail-panel:not([hidden]) {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: min(88dvh, 100dvh - env(safe-area-inset-top, 0px) - 8px) !important;
    min-height: 200px !important;
    margin: 0;
    flex: none !important;
    border-radius: 16px 16px 0 0;
    border-top: 3px solid var(--accent);
    z-index: 10002;
    transform: translateY(108%);
    transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
    box-shadow: 0 -12px 48px rgba(0, 0, 0, 0.5);
    padding: 0.75rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
    padding-left: calc(1rem + env(safe-area-inset-left, 0px));
    padding-right: calc(1rem + env(safe-area-inset-right, 0px));
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar .detail-panel.drawer-open:not([hidden]) {
    transform: translateY(0);
  }

  .app-header {
    position: sticky;
    top: 0;
    z-index: 100;
  }

  .header-lead {
    order: 1;
  }

  .app-header .toolbar {
    order: 10;
    flex: 1 1 100%;
    width: 100%;
    max-width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .toolbar input[type="search"] {
    width: 100%;
    min-width: 0;
    flex: none;
    font-size: 16px;
  }

  .toolbar-filters {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.4rem;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    padding-bottom: 0.2rem;
    margin: 0 calc(-1 * env(safe-area-inset-left, 0px));
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: calc(0.5rem + env(safe-area-inset-right, 0px));
    scrollbar-width: thin;
  }

  .toolbar-filters::-webkit-scrollbar {
    height: 4px;
  }

  .toolbar-filters::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
  }

  .toolbar-filters .toggle-btn {
    scroll-snap-align: start;
    min-height: 44px;
    padding: 0.5rem 0.8rem;
    font-size: 0.86rem;
  }

  .place-item {
    padding: 0.85rem 0.9rem;
    min-height: 56px;
  }

  .place-thumb {
    width: 52px;
    height: 52px;
  }

  .place-meta strong {
    font-size: 0.95rem;
  }

  .field input,
  .field textarea,
  .tape-block textarea {
    font-size: 16px;
  }

  .detail-panel h2 {
    font-size: 1.05rem;
    line-height: 1.3;
    padding-right: 2.5rem;
  }

  .history-scroll {
    max-height: min(42dvh, 280px);
  }

  .row-btns {
    gap: 0.45rem;
    position: sticky;
    top: 0;
    z-index: 4;
    padding: 0.45rem 0 0.35rem;
    background: linear-gradient(to bottom, var(--surface) 65%, rgba(24, 28, 39, 0));
  }

  .row-btns .toggle-btn {
    min-height: 48px;
    flex: 1 1 calc(50% - 0.25rem);
    justify-content: center;
  }

  .btn-file {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    width: 100%;
    text-align: center;
  }

  .tape-templates {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.25rem;
    scroll-snap-type: x proximity;
  }

  .tape-template-btn {
    flex: 0 0 auto;
    min-height: 38px;
    padding: 0.42rem 0.72rem;
    font-size: 0.78rem;
    scroll-snap-align: start;
  }
}

@media (min-width: 481px) and (max-width: 960px) {
  .app-header .toolbar {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    align-items: center;
    -webkit-overflow-scrolling: touch;
  }

  .toolbar input[type="search"] {
    flex: 1 1 140px;
    min-width: 120px;
    width: auto;
  }

  .toolbar-filters {
    flex: 0 0 auto;
    overflow-x: visible;
    padding-bottom: 0;
    margin: 0;
    padding-left: 0;
    padding-right: 0;
  }
}

@media (max-width: 560px) {
  .app-header {
    gap: 0.65rem;
    padding-top: calc(0.5rem + env(safe-area-inset-top, 0px));
    padding-bottom: 0.55rem;
  }

  .header-brand {
    gap: 0.35rem;
  }

  .toolbar input[type="search"] {
    border-radius: 12px;
    padding: 0.62rem 0.9rem;
    box-shadow: 0 0 0 1px rgba(201, 162, 39, 0.06) inset;
  }

  .toolbar-filters .toggle-btn {
    border-radius: 999px;
    padding: 0.5rem 0.78rem;
  }

  .btn-add-place,
  #btn-follow-me {
    width: 100%;
    min-height: 48px;
    font-size: 0.9rem;
    font-weight: 700;
  }

  .sidebar-hint {
    padding: 0.58rem 0.75rem;
    font-size: 0.76rem;
    line-height: 1.45;
  }

  .sidebar-list-wrap {
    max-height: min(38dvh, 330px);
  }

  .place-item {
    border: 1px solid var(--border);
    border-radius: 12px;
    margin: 0.35rem 0.48rem;
    padding: 0.75rem 0.7rem;
    background: rgba(24, 28, 39, 0.7);
  }

  .place-item.focus {
    border-color: rgba(201, 162, 39, 0.55);
    box-shadow: 0 0 0 1px rgba(201, 162, 39, 0.26), 0 8px 22px rgba(0, 0, 0, 0.28);
  }

  .place-thumb {
    width: 56px;
    height: 56px;
    border-radius: 10px;
  }

  .place-meta strong {
    font-size: 0.93rem;
    line-height: 1.3;
  }

  .place-meta small {
    font-size: 0.78rem;
    line-height: 1.35;
  }

  .sidebar .detail-panel:not([hidden]) {
    border-radius: 18px 18px 0 0;
    border-top-width: 2px;
    padding-top: 0.6rem;
  }

  .detail-drawer-head {
    margin-bottom: 0.55rem;
  }

  .row-btns .toggle-btn {
    border-radius: 12px;
    font-weight: 600;
  }

  .tape-template-btn {
    border-radius: 999px;
    padding: 0.45rem 0.74rem;
    font-size: 0.8rem;
  }

  .detail-quick-actions {
    gap: 0.42rem;
  }

  .detail-quick-btn {
    border-radius: 10px;
  }
}

#map-wrap {
  height: 100%;
  min-height: 200px;
  min-width: 0;
  position: relative;
  z-index: 0;
}

.map-fallback-msg {
  margin: 0;
  padding: 1rem 1.25rem;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--muted);
  max-width: 28rem;
}

.map-fallback-msg a {
  color: var(--accent);
  font-weight: 600;
}

.sidebar {
  border-left: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 100%;
  min-width: 0;
  overflow: hidden;
}

.sidebar-hint {
  flex-shrink: 0;
  margin: 0;
  padding: 0.5rem 0.75rem;
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.sidebar-hint strong {
  color: var(--accent);
  font-weight: 600;
}

.sidebar-hint-mobile {
  display: none;
}

.my-motivation {
  margin: 0.2rem 0.75rem 0.6rem;
  padding: 0.6rem 0.7rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(201, 162, 39, 0.08);
}

.my-motivation-title {
  margin: 0 0 0.45rem;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

.my-motivation-title::-webkit-details-marker {
  display: none;
}

.my-motivation-title::after {
  content: "▾";
  float: right;
  color: var(--muted);
  font-size: 0.75rem;
  transform: translateY(1px);
}

.my-motivation:not([open]) .my-motivation-title {
  margin-bottom: 0;
}

.my-motivation:not([open]) .my-motivation-title::after {
  content: "▸";
}

.my-motivation-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
}

.my-motivation-card {
  display: block;
  width: 100%;
  text-align: left;
  min-height: 44px;
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.my-motivation-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(201, 162, 39, 0.25) inset;
}

.my-motivation-card:active {
  opacity: 0.92;
}

.my-motivation-label {
  display: block;
  font-size: 0.68rem;
  color: var(--muted);
  margin-bottom: 0.15rem;
}

.my-motivation-value {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.my-motivation-detail {
  margin-top: 0.55rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border);
}

.my-motivation-detail-title {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.my-motivation-lines {
  margin: 0;
  padding-left: 1rem;
  font-size: 0.78rem;
  line-height: 1.45;
}

.my-motivation-lines li {
  margin-bottom: 0.22rem;
}

.my-motivation-lines-total {
  margin-top: 0.35rem;
}

.sidebar-list-meta {
  flex-shrink: 0;
  padding: 0.35rem 0.75rem 0.25rem;
  border-bottom: 1px solid var(--border);
  background: rgba(24, 28, 39, 0.92);
}

.list-count {
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.sidebar-list-wrap {
  flex: 1 1 42%;
  min-height: 100px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 2px;
}

.detail-panel:not([hidden]) {
  flex: 1 1 58%;
  min-height: 220px;
  max-height: 58%;
  overflow-y: auto;
  overflow-x: hidden;
  border-top: 3px solid var(--accent);
  box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.25);
}

.place-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.place-item {
  display: flex;
  gap: 0.65rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid transparent;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  align-items: flex-start;
  transition: background 0.14s ease, border-color 0.14s ease;
}

.place-item:hover,
.place-item.focus {
  background: var(--surface);
  border-color: rgba(201, 162, 39, 0.22);
}

.place-item:active {
  background: rgba(37, 42, 56, 0.95);
}

.place-item.focus {
  box-shadow: inset 3px 0 0 var(--accent);
}

.place-thumb {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--chip);
  flex-shrink: 0;
}

.place-meta {
  flex: 1;
  min-width: 0;
}

.place-meta strong {
  display: block;
  font-size: 0.9rem;
  line-height: 1.25;
}

.place-meta small {
  color: var(--muted);
  font-size: 0.75rem;
}

.place-meta mark {
  background: rgba(201, 162, 39, 0.28);
  color: #f6ebc3;
  border-radius: 4px;
  padding: 0 0.12rem;
}

.badge {
  display: inline-block;
  font-size: 0.65rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  margin-top: 0.25rem;
  margin-right: 0.25rem;
}

.badge.visited {
  background: rgba(61, 154, 107, 0.25);
  color: #7dcea0;
}

.badge.not {
  background: rgba(184, 76, 76, 0.25);
  color: #f5b7b7;
}

.detail-panel {
  padding: 1rem;
  background: var(--surface);
}

.detail-panel h2 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  line-height: 1.25;
}

.detail-address {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--muted);
  word-break: break-word;
}

.detail-quick-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin: -0.15rem 0 0.65rem;
}

.detail-quick-btn {
  min-height: 36px;
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
  text-decoration: none;
}

.detail-photo {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: 10px;
  margin-bottom: 0.75rem;
  background: var(--chip);
}

.row-btns {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.row-btns .toggle-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.field-notes-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.2rem;
}

.field-notes-label-row label {
  margin-bottom: 0;
}

.notes-save-hint {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--ok);
  min-height: 1em;
  transition: opacity 0.2s ease;
}

.notes-save-hint:empty {
  display: none;
}

.photo-block.photo-block-busy {
  opacity: 0.72;
  pointer-events: none;
}

.btn-visit-yes {
  background: rgba(61, 154, 107, 0.35);
  border-color: var(--ok);
  color: #c8f0dc;
}

.btn-visit-no {
  background: rgba(184, 76, 76, 0.25);
  border-color: var(--no);
  color: #f5d4d4;
}

.field {
  margin-bottom: 0.6rem;
}

.field label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.field input,
.field textarea {
  width: 100%;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
}

.field textarea {
  min-height: 72px;
  resize: vertical;
}

.samples-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0 0.75rem;
}

.samples-row input {
  width: auto;
}

.links-row {
  margin-top: 0.5rem;
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.links-row a {
  color: var(--accent);
  font-size: 0.85rem;
}

.links-row-maps {
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}

.links-row .btn-route-yandex {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 48px;
  padding: 0.55rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #000;
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  text-align: center;
}

.links-row .btn-route-yandex:active {
  opacity: 0.88;
}

.link-yandex-open {
  padding: 0.35rem 0;
  font-weight: 500;
}

.manage-point-block {
  margin-top: 0.8rem;
  border-top: 1px solid var(--border);
  padding-top: 0.6rem;
}

.manage-point-summary {
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.manage-point-actions {
  margin-top: 0.45rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-danger {
  border-color: #8a3f3f;
  color: #f3c5c5;
  background: rgba(184, 76, 76, 0.2);
}

.edit-place-dialog {
  max-width: min(420px, 100vw - 2rem);
  width: 100%;
  margin: auto;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}

.edit-place-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.edit-place-form {
  padding: 1.1rem 1.15rem calc(1rem + env(safe-area-inset-bottom, 0px));
  max-height: min(88dvh, 100vh - 2rem);
  overflow-y: auto;
}

.leaflet-container {
  font-family: inherit;
  border-radius: 0;
}

.leaflet-control-zoom a {
  min-width: 36px !important;
  min-height: 36px !important;
  line-height: 34px !important;
  font-size: 1.25rem !important;
}

.leaflet-popup-content {
  margin: 10px 12px !important;
  min-width: 200px;
}

.popup-ph {
  width: 100%;
  height: 100px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 8px;
  background: #ddd;
}

.popup-btns {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.popup-btns button {
  padding: 0.45rem 0.75rem;
  min-height: 40px;
  font-size: 0.85rem;
  border-radius: 8px;
  border: 1px solid #999;
  cursor: pointer;
}

.popup-map-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.85rem;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.popup-map-links a {
  font-weight: 600;
  color: #c9a227;
}

.marker-photo-icon {
  border-radius: 8px;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  background: #333;
}

.marker-photo-icon img {
  display: block;
  width: 44px;
  height: 44px;
  object-fit: cover;
}

.marker-dot {
  width: 16px;
  height: 16px;
  background: var(--accent);
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.follow-me-marker-wrap {
  background: transparent;
  border: 0;
}

.follow-me-marker {
  position: relative;
  width: 30px;
  height: 30px;
}

.follow-dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  margin-top: -6px;
  border-radius: 999px;
  background: #4da3ff;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.follow-pulse {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  margin-top: -6px;
  border-radius: 999px;
  border: 2px solid rgba(77, 163, 255, 0.55);
  animation: followPulse 1.6s ease-out infinite;
}

@keyframes followPulse {
  0% {
    transform: scale(1);
    opacity: 0.95;
  }
  100% {
    transform: scale(2.8);
    opacity: 0;
  }
}

.follow-popup small {
  display: block;
  margin-top: 4px;
  color: #4f596d;
}

.saved-toast {
  position: fixed;
  bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  right: calc(1rem + env(safe-area-inset-right, 0px));
  left: auto;
  max-width: calc(100vw - 2rem - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
  background: var(--ok);
  color: #fff;
  padding: 0.55rem 1.1rem;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  z-index: 20000;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

@media (max-width: 960px) {
  .saved-toast {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    bottom: calc(0.85rem + env(safe-area-inset-bottom, 0px));
  }
}

.saved-toast.show {
  opacity: 1;
}

.saved-toast.toast-error {
  background: #b84c4c;
  color: #fff;
}

.undo-delete-bar {
  display: none !important;
  position: fixed;
  left: 50%;
  bottom: calc(0.8rem + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 20001;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  max-width: min(96vw, 520px);
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(24, 28, 39, 0.96);
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.undo-delete-bar button {
  border: 1px solid var(--accent);
  background: rgba(201, 162, 39, 0.15);
  color: #f0e6c0;
  border-radius: 8px;
  padding: 0.35rem 0.7rem;
  min-height: 36px;
  font-weight: 700;
  cursor: pointer;
}

.btn-note-history:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.badge.hist {
  background: rgba(201, 162, 39, 0.2);
  color: #e8d089;
}

.field-tight {
  margin-bottom: 0.55rem;
}

.field-tight input {
  font-size: 0.85rem;
}

.history-block {
  margin: 0.75rem 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem 0.65rem;
  background: var(--bg);
}

.history-summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  user-select: none;
}

.history-count {
  font-weight: 400;
  color: var(--muted);
}

.history-scroll {
  max-height: 240px;
  overflow-y: auto;
  margin: 0.5rem 0 0;
  padding-right: 0.25rem;
}

.history-item {
  border-left: 3px solid var(--border);
  padding: 0.45rem 0 0.45rem 0.6rem;
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
}

.history-item.kind-visit {
  border-left-color: var(--ok);
}

.history-item.kind-samples {
  border-left-color: #6b9dc9;
}

.history-item.kind-lpr {
  border-left-color: #9b7dc9;
}

.history-item.kind-note {
  border-left-color: var(--accent);
}

.history-item.kind-journal {
  border-left-color: var(--muted);
}

.history-item time {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  margin-bottom: 0.15rem;
}

.history-item .hi-title {
  font-weight: 600;
}

.history-item .hi-detail {
  margin-top: 0.25rem;
  color: var(--text);
  white-space: pre-wrap;
}

.history-empty {
  color: var(--muted);
  font-size: 0.8rem;
  padding: 0.35rem 0;
}

.journal-add {
  margin-top: 0.65rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}

.journal-label {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.journal-add textarea {
  width: 100%;
  margin-bottom: 0.4rem;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
  resize: vertical;
  min-height: 48px;
}

.btn-note-history {
  margin-top: 0.45rem;
  font-size: 0.8rem;
}

.photo-block {
  margin: 0.65rem 0 0.85rem;
  padding: 0.55rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.photo-block-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.photo-hint {
  margin: 0 0 0.45rem;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.35;
}

.photo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.add-place-photo-actions {
  margin-top: 0.35rem;
}

.btn-file-secondary {
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.btn-file {
  display: inline-block;
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: rgba(201, 162, 39, 0.15);
  color: #f0e6c0;
  font-size: 0.85rem;
  cursor: pointer;
  font-weight: 600;
}

.btn-file:active {
  opacity: 0.9;
}

.photo-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.photo-thumb {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
  background: var(--chip);
}

.photo-thumb:focus-visible {
  outline: 2px solid var(--accent);
}

.badge.photos {
  background: rgba(107, 157, 201, 0.25);
  color: #b8d4f0;
}

.history-item.kind-photo {
  border-left-color: #6b9dc9;
}

.lightbox {
  z-index: 15000;
  max-width: min(96vw, 900px);
  max-height: 92vh;
  padding: 0;
  border: none;
  background: #0a0c10;
  border-radius: 12px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.65);
}

.lightbox::backdrop {
  background: rgba(0, 0, 0, 0.75);
}

.lightbox img {
  display: block;
  max-width: 96vw;
  max-height: 88vh;
  width: auto;
  height: auto;
  margin: 0 auto;
}

.add-place-dialog {
  max-width: min(420px, 100vw - 2rem);
  width: 100%;
  margin: auto;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}

.add-place-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.add-place-draft-marker-wrap {
  background: transparent;
  border: 0;
}

.add-place-draft-marker {
  width: 22px;
  height: 22px;
  margin: 0 auto;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  cursor: grab;
}

.add-place-draft-marker:active {
  cursor: grabbing;
}

/* Режим «новая точка»: клик по карте ставит метку */
.leaflet-container.map-add-place-mode {
  cursor: crosshair;
}

.add-place-form {
  padding: 1.1rem 1.15rem calc(1rem + env(safe-area-inset-bottom, 0px));
  max-height: min(88dvh, 100vh - 2rem);
  overflow-y: auto;
}

.add-place-title {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
  font-weight: 700;
}

.add-place-lead {
  margin: 0 0 0.85rem;
  font-size: 0.75rem;
  line-height: 1.4;
}

.add-place-photo-field {
  margin-bottom: 0.75rem;
}

.add-place-photo-label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.add-place-photo-btn {
  display: inline-block;
  margin-bottom: 0.25rem;
}

.add-place-photo-name {
  display: block;
  font-size: 0.72rem;
  margin-top: 0.25rem;
  word-break: break-all;
}

.add-place-geo-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.add-place-geo-btn {
  min-height: 40px;
  font-size: 0.82rem;
}

.add-place-geo-state {
  font-size: 0.74rem;
  line-height: 1.35;
}

.add-place-form .req {
  color: var(--accent);
}

.add-place-err {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
}

.add-place-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}

.add-place-submit {
  font-weight: 700;
}

.btn-add-place {
  font-weight: 600;
}

.lightbox-close {
  position: fixed;
  top: calc(0.75rem + env(safe-area-inset-top, 0px));
  right: calc(0.75rem + env(safe-area-inset-right, 0px));
  z-index: 10;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

/* --- Сводка (overview) --- */
.overview-page {
  min-height: 100dvh;
}

.overview-header .overview-toolbar {
  flex: 1 1 100%;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.overview-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.overview-header .user-chip {
  font-size: 0.8rem;
  max-width: min(200px, 46vw);
  color: var(--text);
}

.overview-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1rem calc(1.5rem + env(safe-area-inset-bottom, 0px));
  padding-left: calc(1rem + env(safe-area-inset-left, 0px));
  padding-right: calc(1rem + env(safe-area-inset-right, 0px));
}

.overview-hero {
  margin: 0 0 1.1rem;
  padding: 1rem 1.1rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(201, 162, 39, 0.12) 0%, var(--surface) 55%);
  border-left: 4px solid var(--accent);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}

.overview-hero-kicker {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.overview-hero-name {
  margin: 0;
  font-size: clamp(1.25rem, 4.5vw, 1.65rem);
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
  word-break: break-word;
}

.overview-lead {
  margin: 0 0 1.35rem;
  font-size: 1.02rem;
  line-height: 1.5;
  color: var(--text);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(152px, 1fr));
  gap: 0.8rem;
  margin-bottom: 1.85rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 0.85rem;
  text-align: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.stat-value {
  font-size: clamp(1.45rem, 4vw, 1.85rem);
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.stat-label {
  font-size: 0.82rem;
  color: var(--text);
  margin-top: 0.4rem;
  line-height: 1.3;
}

.stat-hint {
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 0.3rem;
  line-height: 1.25;
}

.dash-section {
  margin-bottom: 1.85rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(24, 28, 39, 0.65);
  padding: 0.9rem 0.95rem;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
}

.dash-h2 {
  margin: 0 0 0.75rem;
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--text);
}

.kind-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.kind-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.45rem 0.65rem;
  font-size: 0.82rem;
}

.kind-item .kind-count {
  color: var(--accent);
  font-weight: 700;
  margin-left: 0.25rem;
  font-variant-numeric: tabular-nums;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  scrollbar-width: thin;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.table-wrap::-webkit-scrollbar {
  height: 8px;
}

.table-wrap::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.activity-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.activity-table th,
.activity-table td {
  padding: 0.55rem 0.65rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.activity-table th {
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  background: rgba(24, 28, 39, 0.65);
  position: sticky;
  top: 0;
  z-index: 1;
}

.activity-table tbody tr:last-child td {
  border-bottom: none;
}

.activity-table td:nth-child(5) {
  word-break: break-word;
  max-width: 420px;
}

.dash-empty {
  margin: 0.5rem 0 0;
  font-size: 0.88rem;
}

.motivation-section {
  margin-top: -0.2rem;
}

.motivation-lead {
  margin: 0 0 0.7rem;
  font-size: 0.82rem;
}

.motivation-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.65rem;
  margin-bottom: 0.8rem;
}

.motivation-card .stat-label {
  margin-top: 0;
}

.motivation-table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.motivation-table th,
.motivation-table td {
  padding: 0.55rem 0.65rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.motivation-table th {
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  background: rgba(24, 28, 39, 0.65);
}

.motivation-table tbody tr:last-child td {
  border-bottom: none;
}

.motivation-table td:last-child {
  color: var(--accent);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.overview-tpi-nav {
  margin: -0.65rem 0 1.15rem;
  font-size: 0.88rem;
}

.overview-tpi-anchor {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.overview-profile-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.55rem;
}

.overview-profile-controls label {
  font-size: 0.82rem;
  color: var(--muted);
}

.overview-profile-controls select {
  min-height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  padding: 0.35rem 0.65rem;
}

.overview-auto-refresh {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
}

.tpi-section {
  padding-bottom: 0.15rem;
}

.tpi-kpi-user {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  color: var(--text);
  line-height: 1.35;
}

.tpi-kpi-user strong {
  color: var(--accent);
  font-weight: 700;
}

.tpi-intro {
  margin: 0 0 0.9rem;
  font-size: 0.84rem;
  line-height: 1.45;
  max-width: 52rem;
}

.tpi-total-card {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.65rem;
  margin-bottom: 0.9rem;
  padding: 0.9rem 1.05rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(201, 162, 39, 0.11);
}

.tpi-total-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tpi-total-value {
  font-size: clamp(1.4rem, 5vw, 1.95rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  line-height: 1.15;
}

.tpi-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.tpi-table th,
.tpi-table td {
  padding: 0.55rem 0.65rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.tpi-table th {
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  background: rgba(24, 28, 39, 0.65);
}

.tpi-table tbody tr:last-child td {
  border-bottom: none;
}

.tpi-table td:nth-child(4) {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--accent);
}

.tpi-ref {
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.55rem 0.9rem 0.75rem;
  background: var(--surface);
}

.tpi-ref-summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
  outline-offset: 4px;
}

.tpi-ref-body {
  margin-top: 0.65rem;
  font-size: 0.82rem;
  line-height: 1.45;
}

.tpi-ref-body ul {
  margin: 0 0 0.65rem;
  padding-left: 1.2rem;
}

.tpi-ref-body li {
  margin-bottom: 0.45rem;
}

.tpi-ref-note {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.45;
}

@media (max-width: 640px) {
  .activity-table,
  .tpi-table,
  .motivation-table {
    min-width: 0;
  }

  .activity-table thead,
  .tpi-table thead,
  .motivation-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .activity-table tbody tr,
  .tpi-table tbody tr,
  .motivation-table tbody tr {
    display: block;
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid var(--border);
  }

  .activity-table tbody tr:last-child,
  .tpi-table tbody tr:last-child,
  .motivation-table tbody tr:last-child {
    border-bottom: none;
  }

  .activity-table tbody td,
  .tpi-table tbody td,
  .motivation-table tbody td {
    display: grid;
    grid-template-columns: minmax(5.2rem, 34%) 1fr;
    gap: 0.2rem 0.65rem;
    padding: 0.35rem 0;
    border-bottom: none;
    font-size: 0.88rem;
    max-width: none !important;
  }

  .activity-table tbody td::before,
  .tpi-table tbody td::before,
  .motivation-table tbody td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 600;
    font-size: 0.72rem;
    line-height: 1.35;
    padding-top: 0.12rem;
  }
}

@media (min-width: 641px) and (max-width: 900px) {
  .activity-table td:nth-child(4),
  .tpi-table td:nth-child(4) {
    max-width: 260px;
  }
}
