:root {
  color-scheme: light;
  --bg: #f2f5f1;
  --surface: #ffffff;
  --surface-muted: #e6ebe5;
  --surface-strong: #dbe3dc;
  --text: #182019;
  --muted: #657068;
  --hint: #7b857d;
  --accent: #3e704c;
  --accent-text: #ffffff;
  --danger: #a04444;
  --danger-soft: #f4e6e3;
  --positive: #356f49;
  --positive-soft: #e2eee5;
  --dark-status: #303731;
  --dark-status-soft: #e2e6e2;
  --schedule-open: #4f805f;
  --schedule-closed: #a05f58;
  --schedule-unknown: #858b87;
  --map-marker-gap: #ffffff;
  --shadow: 0 16px 50px rgb(24 32 25 / 12%);
  --radius: 16px;
  --radius-control: 12px;
  --bottom-nav-height: 70px;
  --content-max: 1120px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111512;
  --surface: #19201a;
  --surface-muted: #222a23;
  --surface-strong: #2a342c;
  --text: #f0f3f0;
  --muted: #a1aaa3;
  --hint: #89938c;
  --accent: #6e9e7b;
  --accent-text: #0d160f;
  --danger: #d07878;
  --danger-soft: #382626;
  --positive: #8ab797;
  --positive-soft: #24372a;
  --dark-status: #dce3de;
  --dark-status-soft: #303833;
  --schedule-open: #79a989;
  --schedule-closed: #ce8178;
  --schedule-unknown: #929b95;
  --map-marker-gap: #202721;
  --shadow: 0 18px 55px rgb(0 0 0 / 28%);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  min-height: var(--tg-viewport-stable-height, 100vh);
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  color: inherit;
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 38%, transparent);
  outline-offset: 2px;
}

button:disabled,
input:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.app-shell {
  min-height: 100vh;
  min-height: var(--tg-viewport-stable-height, 100vh);
  padding: max(26px, env(safe-area-inset-top)) 24px
    calc(var(--bottom-nav-height) + 36px + env(safe-area-inset-bottom));
}

.app-shell.detail-shell {
  padding-bottom: max(36px, env(safe-area-inset-bottom));
}

.content {
  width: min(100%, var(--content-max));
  margin: 0 auto;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 26px;
}

.page-header h1,
.detail-header h1 {
  margin: 0;
  font-size: clamp(30px, 4vw, 40px);
  line-height: 1.1;
  letter-spacing: -0.035em;
}

.page-subtitle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  margin-top: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 700;
}

.page-subtitle.static {
  pointer-events: none;
}

.icon-button {
  display: inline-grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
}

.icon-button:hover {
  background: var(--surface-muted);
}

.icon {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.search-field {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 58px;
  border-radius: var(--radius-control);
  background: var(--surface-muted);
}

.search-field > .icon {
  width: 22px;
  margin-left: 17px;
  color: var(--muted);
}

.search-field input {
  width: 100%;
  min-width: 0;
  height: 58px;
  padding: 0 52px 0 13px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.search-field input::placeholder {
  color: var(--muted);
}

.search-clear {
  position: absolute;
  right: 7px;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
}

.filter-button,
.button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 18px;
  border: 0;
  border-radius: var(--radius-control);
  background: var(--surface-muted);
  color: var(--text);
  font-weight: 700;
}

.filter-button {
  min-height: 58px;
}

.filter-button .count {
  display: inline-grid;
  min-width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 12px;
}

.button.primary {
  background: var(--accent);
  color: var(--accent-text);
}

.button.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.button.ghost {
  background: transparent;
  color: var(--accent);
}

.button.full {
  width: 100%;
}

.button.compact {
  min-height: 40px;
  padding: 0 14px;
  font-size: 14px;
}

.active-filters {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.active-filters::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  display: inline-flex;
  flex: 0 0 auto;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--text);
  font-size: 13px;
  line-height: 1;
  white-space: nowrap;
}

.result-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  color: var(--muted);
  font-size: 14px;
}

.branch-list {
  display: grid;
  gap: 6px;
}

.branch-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(260px, 2fr) minmax(140px, 0.85fr) minmax(180px, 1.15fr) minmax(140px, 0.9fr) 44px;
  gap: 18px;
  width: 100%;
  min-height: 82px;
  align-items: center;
  padding: 14px 18px;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  transition: background-color 150ms ease, transform 150ms ease;
}

.branch-card-open {
  position: absolute;
  z-index: 1;
  inset: 0;
  border: 0;
  border-radius: inherit;
  background: transparent;
}

.branch-card-open:focus-visible {
  outline-offset: -3px;
}

.branch-card > :not(.branch-card-open, .branch-map-link) {
  pointer-events: none;
}

.branch-map-link {
  position: relative;
  z-index: 2;
  display: inline-grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-muted);
  color: var(--accent);
  transition: background-color 150ms ease, transform 150ms ease;
}

.branch-map-link:hover {
  background: var(--surface-strong);
}

.branch-map-link:active {
  transform: scale(0.96);
}

.branch-map-link:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 38%, transparent);
  outline-offset: 2px;
}

.branch-map-link .icon {
  width: 20px;
  height: 20px;
}

.branch-card:hover {
  background: color-mix(in srgb, var(--surface) 86%, var(--surface-muted));
}

.branch-card:active {
  transform: scale(0.997);
}

.eyebrow {
  color: var(--muted);
  font-size: 14px;
}

.branch-address {
  display: -webkit-box;
  overflow: hidden;
  font-size: 17px;
  font-weight: 750;
  line-height: 1.28;
  letter-spacing: -0.015em;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.branch-status-field {
  display: inline-flex;
  width: fit-content;
  min-height: 34px;
  align-items: center;
  padding: 0 11px;
  border-radius: 10px;
  background: var(--surface-muted);
}

.branch-status-field .status-line {
  margin: 0;
  font-size: 14px;
}

.compact-status-empty {
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 7px;
  font-weight: 750;
}

.status-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--muted);
}

.status-dot.dark {
  background: var(--dark-status);
}

.status-dot.positive {
  background: var(--positive);
}

.status-dot.negative {
  background: var(--danger);
}

.status-empty {
  margin-top: 7px;
  color: var(--muted);
}

.schedule-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin: 0;
  font-size: 14px;
  line-height: 1.35;
}

.schedule-line .icon {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
  color: var(--muted);
}

.branch-card-meta {
  min-width: 0;
}

.branch-assignee {
  overflow: hidden;
  font-size: 14px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.branch-check-time {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.blocked-label {
  display: block;
  margin-top: 3px;
  color: var(--danger);
  font-size: 12px;
}

.blocked-inline {
  color: var(--danger);
}

.map-shell {
  height: var(--tg-viewport-stable-height, 100vh);
  min-height: 640px;
  overflow: hidden;
}

.map-content {
  display: flex;
  height: 100%;
  flex-direction: column;
}

.map-header {
  margin-bottom: 16px;
}

.map-meta {
  display: flex;
  min-height: 34px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.map-legend {
  display: flex;
  min-height: 58px;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.map-legend-row {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 14px;
  overflow-x: auto;
  scrollbar-width: none;
  white-space: nowrap;
}

.map-legend-row::-webkit-scrollbar {
  display: none;
}

.map-legend-row strong {
  min-width: 54px;
  color: var(--text);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.map-legend-row span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot,
.legend-ring {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border: 1px solid transparent;
  border-radius: 50%;
}

.legend-dot {
  background: #8b8f97;
}

.legend-dot.status-blacklist,
.map-marker-core.status-blacklist {
  background: #27272a;
}

.legend-dot.status-whitelist,
.map-marker-core.status-whitelist {
  border-color: #4b504b;
  background: #f5f2e8;
}

.legend-dot.status-not-working,
.map-marker-core.status-not-working {
  background: #b5534d;
}

.legend-dot.status-unset,
.map-marker-core.status-unset {
  background: #8b8f97;
}

.legend-ring {
  border-width: 2px;
  background: transparent;
}

.legend-ring.schedule-open,
.map-marker.schedule-open {
  border-color: var(--schedule-open);
}

.legend-ring.schedule-closed,
.map-marker.schedule-closed {
  border-color: var(--schedule-closed);
}

.legend-ring.schedule-unknown,
.map-marker.schedule-unknown {
  border-style: dashed;
  border-color: var(--schedule-unknown);
}

.map-stage {
  position: relative;
  min-height: 420px;
  flex: 1;
  overflow: hidden;
  border-radius: 20px;
  background: var(--surface-muted);
}

.map-stage .center-state {
  min-height: 100%;
  padding: 28px;
}

.map-canvas {
  position: absolute;
  inset: 0;
}

.map-stage > .map-canvas.maplibregl-map {
  position: absolute;
  width: 100%;
  height: 100%;
}

.map-loading {
  display: flex;
  height: 100%;
  min-height: 420px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 700;
}

.map-marker,
.map-cluster {
  display: grid;
  place-items: center;
  border-radius: 50%;
  box-shadow: 0 5px 16px rgb(17 25 20 / 24%);
  transition: box-shadow 160ms ease, transform 160ms ease;
}

.map-marker-anchor {
  display: grid;
  place-items: center;
}

.map-marker {
  width: 30px;
  height: 30px;
  padding: 3px;
  border-width: 3px;
  border-style: solid;
  background: var(--map-marker-gap);
}

.map-marker-core {
  width: 18px;
  height: 18px;
  border: 1px solid transparent;
  border-radius: 50%;
}

.map-marker-core.status-whitelist {
  border-color: #4b504b;
}

.map-marker:hover,
.map-marker:focus-visible,
.map-marker.selected {
  z-index: 2;
  box-shadow: 0 0 0 5px rgb(255 255 255 / 72%), 0 7px 20px rgb(17 25 20 / 28%);
  transform: scale(1.18);
}

.map-cluster {
  width: 40px;
  height: 40px;
  border: 2px solid #fff;
  background: #3f5546;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.map-cluster:hover,
.map-cluster:focus-visible {
  transform: scale(1.08);
}

.map-stage .maplibregl-ctrl-group {
  overflow: hidden;
  border: 0;
  border-radius: 12px;
  box-shadow: 0 4px 14px rgb(17 25 20 / 16%);
}

.map-stage .maplibregl-ctrl-attrib {
  font-size: 10px;
}

.map-preview {
  position: absolute;
  z-index: 5;
  bottom: 18px;
  left: 18px;
  width: min(360px, calc(100% - 36px));
  padding: 16px;
  border-radius: 18px;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.map-preview-close {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
}

.map-preview-close:hover {
  background: var(--surface-muted);
}

.map-preview-close .icon {
  width: 19px;
  height: 19px;
}

.map-preview-address {
  max-width: calc(100% - 36px);
  margin-bottom: 9px;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.3;
}

.map-preview-status {
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 750;
}

.map-preview-schedule {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.map-preview-schedule .icon {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  margin-top: 1px;
}

.map-preview-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.map-preview-meta span:last-child {
  text-align: right;
}

.map-preview-action {
  width: 100%;
  margin-top: 12px;
}

.bottom-nav {
  position: fixed;
  z-index: 20;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  min-height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
  justify-content: center;
  padding: 5px max(16px, env(safe-area-inset-right)) env(safe-area-inset-bottom)
    max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--surface) 97%, transparent);
  box-shadow: 0 -10px 28px rgb(20 30 22 / 6%);
}

.bottom-nav-inner {
  display: grid;
  width: min(100%, 700px);
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
}

.nav-item {
  display: grid;
  min-height: 60px;
  place-items: center;
  align-content: center;
  gap: 2px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}

.nav-item .icon {
  width: 23px;
  height: 23px;
}

.nav-item.active {
  color: var(--accent);
  font-weight: 750;
}

.center-state {
  display: grid;
  min-height: 45vh;
  place-items: center;
  padding: 30px 0;
  text-align: center;
}

.state-card {
  max-width: 420px;
}

.state-card h2 {
  margin: 16px 0 6px;
  font-size: 22px;
}

.state-card p {
  margin: 0 0 20px;
  color: var(--muted);
}

.state-icon {
  display: inline-grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-muted);
  color: var(--muted);
}

.skeleton {
  min-height: 126px;
  border-radius: var(--radius);
  background: var(--surface);
  animation: skeleton 1.2s ease-in-out infinite alternate;
}

@keyframes skeleton {
  to {
    opacity: 0.52;
  }
}

.detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.back-button {
  margin-left: -10px;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(300px, 0.75fr);
  gap: 12px;
}

.section {
  padding: 24px;
  border-radius: var(--radius);
  background: var(--surface);
}

.section + .section {
  margin-top: 10px;
}

.section h2,
.section h3 {
  margin: 0 0 12px;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.branch-summary,
.comment-section,
.history-section,
.schedule-section {
  padding: 18px;
}

.detail-address {
  margin: 3px 0 14px;
  font-size: 19px;
  font-weight: 750;
  line-height: 1.25;
}

.detail-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.fact {
  min-height: 64px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-muted);
}

.fact .eyebrow {
  font-size: 12px;
}

.fact-value {
  margin-top: 4px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
}

.fact-assignee {
  display: flex;
  align-items: center;
}

.fact-assignee .fact-value {
  margin-top: 0;
}

.detail-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.detail-actions .button {
  min-height: 44px;
  padding: 0 14px;
}

.detail-map-link {
  gap: 7px;
  text-decoration: none;
}

.detail-map-link .icon {
  width: 17px;
  height: 17px;
}

.schedule-list {
  display: grid;
  gap: 3px;
}

.schedule-row {
  display: flex;
  min-height: 32px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 8px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 14px;
}

.schedule-row.today {
  background: var(--surface-muted);
  color: var(--text);
  font-weight: 700;
}

.comment-form textarea,
.field,
.select {
  width: 100%;
  border: 0;
  border-radius: var(--radius-control);
  outline: 0;
  background: var(--surface-muted);
}

.comment-form textarea {
  min-height: 76px;
  resize: vertical;
  padding: 12px;
}

.field,
.select {
  min-height: 48px;
  padding: 0 14px;
}

.form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}

.load-more-wrap {
  justify-content: center;
  margin-top: 16px;
}

.char-count {
  color: var(--muted);
  font-size: 13px;
}

.char-count.spaced {
  margin-top: 6px;
}

.status-comment-field {
  min-height: 110px;
  padding: 14px;
  resize: vertical;
}

.history-list {
  display: grid;
  gap: 8px;
}

.history-item {
  padding: 12px;
  border-radius: 10px;
  background: var(--surface-muted);
}

.history-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.history-author {
  font-weight: 700;
}

.history-time {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.history-body {
  margin-top: 5px;
}

.history-comment {
  margin: 5px 0 0;
  line-height: 1.4;
  white-space: pre-wrap;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.72fr);
  gap: 18px;
}

.employee-list,
.invite-list {
  display: grid;
  gap: 8px;
}

.employee-row,
.invite-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: 12px 14px;
  border-radius: var(--radius-control);
  background: var(--surface-muted);
}

.row-title {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.row-subtitle {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.row-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.sheet-backdrop {
  position: fixed;
  z-index: 60;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  background: rgb(10 15 11 / 35%);
}

.sheet {
  width: min(100%, 620px);
  max-height: min(88vh, var(--tg-viewport-stable-height, 88vh));
  overflow: auto;
  padding: 10px 20px max(20px, env(safe-area-inset-bottom));
  border-radius: 22px 22px 14px 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.sheet-handle {
  width: 42px;
  height: 4px;
  margin: 2px auto 16px;
  border-radius: 999px;
  background: var(--surface-strong);
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.sheet-header h2 {
  margin: 0;
  font-size: 22px;
}

.sheet-section {
  margin: 20px 0;
}

.sheet-copy {
  margin: 0 0 10px;
  color: var(--muted);
}

.sheet-section h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

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

.choice {
  position: relative;
  display: flex;
  min-height: 48px;
  align-items: center;
  gap: 10px;
  padding: 0 13px;
  border-radius: var(--radius-control);
  background: var(--surface-muted);
}

.choice input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.employee-choice {
  display: flex;
  width: 100%;
  min-height: 52px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius-control);
  background: var(--surface-muted);
  text-align: left;
}

.employee-choice + .employee-choice {
  margin-top: 7px;
}

.employee-choice.selected {
  background: color-mix(in srgb, var(--accent) 15%, var(--surface-muted));
  color: var(--accent);
}

.sheet-footer {
  position: sticky;
  bottom: calc(-1 * max(20px, env(safe-area-inset-bottom)));
  display: grid;
  grid-template-columns: 0.7fr 1.3fr;
  gap: 8px;
  margin: 20px -20px calc(-1 * max(20px, env(safe-area-inset-bottom)));
  padding: 12px 20px max(20px, env(safe-area-inset-bottom));
  background: var(--surface);
}

.button.danger-solid {
  background: var(--danger);
  color: #fff;
}

.toast {
  position: fixed;
  z-index: 90;
  bottom: calc(var(--bottom-nav-height) + 22px + env(safe-area-inset-bottom));
  left: 50%;
  max-width: min(calc(100% - 32px), 460px);
  padding: 12px 16px;
  border-radius: var(--radius-control);
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow);
  transform: translateX(-50%);
  animation: toast-in 180ms ease-out;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid color-mix(in srgb, currentColor 25%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 860px) {
  .app-shell {
    padding-right: 16px;
    padding-left: 16px;
  }

  .branch-card {
    grid-template-columns: minmax(220px, 1.5fr) minmax(170px, 1fr) 44px;
    gap: 10px 16px;
  }

  .branch-card-primary {
    grid-column: 1;
    grid-row: 1;
  }

  .branch-status-field {
    grid-column: 2;
    grid-row: 1;
  }

  .schedule-line {
    grid-column: 1;
    grid-row: 2;
  }

  .branch-card-meta {
    grid-column: 2;
    grid-row: 2;
  }

  .branch-map-link {
    grid-column: 3;
    grid-row: 1 / span 2;
    align-self: center;
  }

  .detail-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .map-preview {
    right: 18px;
    left: auto;
  }
}

@media (max-width: 620px) {
  :root {
    --bottom-nav-height: 66px;
  }

  .app-shell {
    padding-top: max(18px, env(safe-area-inset-top));
  }

  .map-shell {
    min-height: 560px;
    padding-right: 0;
    padding-left: 0;
  }

  .map-header,
  .map-shell .toolbar,
  .map-shell .active-filters,
  .map-meta,
  .map-legend {
    margin-right: 16px;
    margin-left: 16px;
  }

  .map-legend {
    gap: 7px;
    padding: 5px 0 8px;
  }

  .map-legend-row {
    display: grid;
    grid-template-columns: 54px repeat(2, minmax(0, 1fr));
    gap: 5px 8px;
    overflow: visible;
    white-space: normal;
  }

  .map-legend-row strong {
    grid-row: 1 / span 2;
    align-self: start;
    padding-top: 1px;
  }

  .map-legend-row span {
    min-width: 0;
    font-size: 11px;
    line-height: 1.15;
    white-space: nowrap;
  }

  .map-stage {
    min-height: 360px;
    border-radius: 18px 18px 0 0;
  }

  .map-preview {
    right: 10px;
    bottom: 10px;
    left: 10px;
    width: auto;
    padding: 14px;
    border-radius: 16px;
  }

  .map-preview-meta {
    align-items: flex-end;
    flex-direction: column;
    gap: 2px;
  }

  .map-preview-meta span:last-child {
    text-align: left;
  }

  .map-loading {
    min-height: 360px;
  }

  .page-header {
    margin-bottom: 18px;
  }

  .page-header h1,
  .detail-header h1 {
    font-size: 30px;
  }

  .toolbar {
    grid-template-columns: 1fr auto;
  }

  .filter-button {
    width: 58px;
    padding: 0;
  }

  .filter-button .filter-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .filter-button .count {
    position: absolute;
    margin: -32px 0 0 33px;
  }

  .nav-item {
    min-width: 0;
    font-size: 11px;
  }

  .branch-card {
    grid-template-columns: auto minmax(0, 1fr) 44px;
    gap: 8px 10px;
    min-height: 0;
    padding: 12px 14px;
  }

  .branch-card-primary {
    grid-column: 1 / 3;
    grid-row: 1;
  }

  .branch-status-field {
    grid-column: 1;
    grid-row: 2;
    align-self: center;
  }

  .schedule-line {
    grid-column: 1 / -1;
    grid-row: 3;
  }

  .branch-address {
    font-size: 16px;
  }

  .branch-card-meta {
    grid-column: 2;
    grid-row: 2;
    align-self: center;
    text-align: right;
  }

  .branch-map-link {
    grid-column: 3;
    grid-row: 1;
    align-self: start;
  }

  .branch-check-time {
    margin-top: 2px;
  }

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

  .detail-actions .button {
    min-width: 0;
    padding: 0 8px;
    font-size: 14px;
  }

  .detail-map-link {
    grid-column: 1 / -1;
  }

  .branch-summary,
  .comment-section,
  .history-section,
  .schedule-section {
    padding: 14px;
  }

  .choice-grid {
    grid-template-columns: 1fr;
  }

  .employee-row,
  .invite-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .row-actions {
    width: 100%;
  }

  .row-actions .button {
    flex: 1;
  }

  .sheet-backdrop {
    padding: 0;
  }

  .sheet {
    border-radius: 22px 22px 0 0;
  }
}

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