:root {
  color-scheme: light;
  --bg: #eef3f7;
  --panel: #ffffff;
  --ink: #172331;
  --muted: #5f6d7c;
  --line: #cbd5df;
  --primary: #005ea8;
  --primary-strong: #003b70;
  --secondary: #008b8b;
  --accent: #e59b12;
  --success: #16784a;
  --danger: #b42318;
  --shadow: 0 4px 18px rgba(23, 43, 66, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo",
    "Noto Sans KR", "Malgun Gothic", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: progress;
  opacity: 0.62;
}

a {
  color: var(--primary-strong);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(380px, 440px) 1fr;
  width: 100%;
  height: 100%;
}

.sidebar {
  display: flex;
  min-width: 0;
  height: 100%;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  z-index: 500;
}

.brand {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  border-top: 5px solid var(--primary);
  border-bottom: 1px solid var(--line);
  padding: 18px 22px 16px;
}

.brand::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  width: 34%;
  height: 3px;
  background: var(--secondary);
  content: "";
}

.brand-copy {
  min-width: 0;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 7px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}

.eyebrow span {
  width: 8px;
  height: 8px;
  background: var(--accent);
}

h1 {
  margin: 0;
  font-size: 25px;
  font-weight: 800;
  line-height: 1.18;
}

.icon-button {
  display: inline-flex;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--primary-strong);
  font-size: 20px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border-top: 1px solid var(--line);
  border-bottom: 0;
  background: #f2f5f8;
  padding: 8px 16px;
}

.stats div {
  min-width: 0;
  border: 0;
  border-right: 1px solid #d5dee6;
  border-radius: 0;
  padding: 7px 8px;
  background: transparent;
}

.stats div:last-child {
  border-right: 0;
}

.stats span {
  display: block;
  overflow-wrap: anywhere;
  color: #445466;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.15;
}

.stats small {
  display: block;
  margin-top: 2px;
  color: #748192;
  font-size: 11px;
}

.filters {
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding: 18px 22px 16px;
}

.nearby-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid #b9c9d8;
  border-top: 3px solid var(--primary);
  border-radius: 4px;
  background: #f8fbfd;
  padding: 14px;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid #dbe4ec;
  padding-bottom: 10px;
}

.section-heading strong {
  color: var(--primary-strong);
  font-size: 16px;
}

.section-heading span {
  overflow: hidden;
  border-left: 3px solid var(--secondary);
  color: #42566b;
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-left: 7px;
}

.address-search {
  display: grid;
  grid-template-columns: 1fr 74px;
  gap: 8px;
  align-items: end;
}

.address-suggestions {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  padding: 8px;
}

.address-suggestions[hidden] {
  display: none;
}

.suggestion-title {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.suggestion-item {
  display: grid;
  gap: 2px;
  width: 100%;
  border: 1px solid #e3e8ef;
  border-radius: 4px;
  background: #fbfcfe;
  padding: 8px 10px;
  text-align: left;
}

.suggestion-item:hover,
.suggestion-item:focus {
  border-color: var(--primary);
  background: #edf6fc;
  outline: none;
}

.suggestion-item strong {
  color: var(--ink);
  font-size: 13px;
}

.suggestion-item span {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wide-button {
  width: 100%;
}

.button-symbol {
  display: inline-flex;
  margin-right: 5px;
  font-size: 18px;
  line-height: 1;
}

.location-help {
  margin: -2px 0 0;
  border-left: 3px solid var(--accent);
  border-radius: 2px;
  background: #fff8e8;
  padding: 8px 10px;
  color: #6f4a00;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
}

.location-help[hidden] {
  display: none;
}

.address-button,
.field-button {
  min-height: 42px;
}

.field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 6px;
}

.field span,
.toggle span {
  color: #30465b;
  font-size: 13px;
  font-weight: 700;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field input,
.field select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
  outline: none;
  padding: 0 12px;
}

.field input:focus,
.field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 94, 168, 0.14);
}

.toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 32px;
  border: 1px solid #d4dee7;
  background: #f7f9fb;
  padding: 9px 11px;
}

.compact-toggle {
  min-height: 38px;
  border: 0;
  border-top: 1px solid #dbe4ec;
  background: transparent;
  padding: 10px 0 0;
}

.task-finder {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid #b9c9d8;
  border-top: 3px solid var(--secondary);
  border-radius: 4px;
  background: #fff;
  padding: 14px;
}

.task-heading {
  align-items: center;
}

.text-button {
  border: 0;
  background: transparent;
  padding: 3px 0;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.text-button[hidden] {
  display: none;
}

.task-select-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.task-list {
  display: grid;
  gap: 6px;
  max-height: 260px;
  overflow-y: auto;
  border-top: 1px solid #dbe4ec;
  padding-top: 10px;
}

.task-list[hidden],
.selected-task[hidden] {
  display: none;
}

.task-item {
  display: grid;
  gap: 3px;
  width: 100%;
  min-height: 48px;
  border: 1px solid #d6e0e8;
  border-left: 4px solid #9ab6cc;
  border-radius: 4px;
  background: #f9fbfc;
  padding: 8px 10px;
  color: var(--ink);
  text-align: left;
}

.task-item:hover,
.task-item:focus {
  border-color: var(--primary);
  border-left-color: var(--secondary);
  background: #edf6fc;
  outline: none;
}

.task-item[aria-pressed="true"] {
  border-color: var(--primary);
  border-left-color: var(--accent);
  background: #eaf4fb;
  box-shadow: 0 0 0 2px rgba(0, 94, 168, 0.1);
}

.task-item strong {
  font-size: 13px;
  line-height: 1.35;
}

.task-item span {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-task {
  border: 1px solid #97bfdc;
  border-left: 4px solid var(--primary);
  border-radius: 4px;
  background: #edf6fc;
  padding: 10px;
}

.selected-task div {
  display: grid;
  gap: 3px;
}

.selected-task small {
  color: #496579;
  font-size: 11px;
  font-weight: 700;
}

.selected-task strong {
  color: var(--primary-strong);
  font-size: 14px;
  line-height: 1.4;
}

.selected-task p {
  margin: 7px 0 0;
  color: #34495d;
  font-size: 12px;
  line-height: 1.5;
}

.selected-task b {
  margin-right: 4px;
  color: var(--ink);
}

.toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.primary-button,
.secondary-button,
.more-button {
  min-height: 42px;
  border-radius: 4px;
  font-weight: 800;
}

.primary-button {
  border: 1px solid var(--primary-strong);
  background: var(--primary);
  color: #fff;
}

.primary-button:hover {
  background: var(--primary-strong);
}

.secondary-button,
.more-button {
  border: 1px solid var(--line);
  background: #fff;
  color: #263b50;
}

.secondary-button:hover,
.more-button:hover,
.icon-button:hover {
  border-color: var(--primary);
  background: #edf6fc;
}

.status-line {
  min-height: 40px;
  border-bottom: 1px solid #c9dce9;
  background: #eaf4fb;
  padding: 11px 22px;
  color: #274d6d;
  font-size: 13px;
  font-weight: 700;
}

.result-section {
  display: flex;
  min-height: 0;
  flex: 0 0 auto;
  flex-direction: column;
  gap: 10px;
  padding: 14px 12px 0 22px;
}

.result-list {
  min-height: 0;
  overflow: visible;
  padding-right: 10px;
}

.result-item {
  width: 100%;
  margin: 0 0 8px;
  border: 1px solid var(--line);
  border-left: 4px solid #9ab6cc;
  border-radius: 4px;
  background: #fff;
  padding: 12px;
  text-align: left;
}

.result-item:hover,
.result-item:focus {
  border-color: var(--primary);
  border-left-color: var(--secondary);
  background: #f8fbfd;
  outline: none;
}

.result-item[aria-current="true"] {
  border-color: var(--primary);
  border-left-color: var(--accent);
  background: #f1f8fd;
  box-shadow: 0 0 0 2px rgba(0, 94, 168, 0.1);
}

.result-item strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.35;
}

.result-item p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 3px;
  padding: 0 8px;
  background: #e5f1f8;
  color: #164f78;
  font-size: 12px;
  font-weight: 700;
}

.badge.warn {
  background: #fff1e8;
  color: #a94918;
}

.badge.ok {
  background: #eaf7ef;
  color: var(--success);
}

.badge.closed {
  background: #eef0f4;
  color: #59606c;
}

.task-result-summary {
  display: grid;
  gap: 3px;
  margin-top: 8px;
  border-left: 3px solid var(--secondary);
  background: #edf6fc;
  padding: 7px 9px;
}

.task-result-summary strong {
  color: var(--primary-strong);
  font-size: 12px;
}

.task-result-summary span {
  overflow: hidden;
  color: #526679;
  font-size: 11px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ok-text {
  color: var(--success);
}

.warn-text {
  color: var(--danger);
}

.popup-badges {
  margin: -2px 0 8px;
}

.more-button {
  display: none;
  width: calc(100% - 10px);
  margin: 0 10px 12px 0;
}

.more-button.is-visible {
  display: block;
}

.source-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-top: 1px solid var(--line);
  margin-top: 4px;
  padding: 13px 22px 18px;
  color: var(--muted);
  font-size: 12px;
}

.map-area {
  position: relative;
  min-width: 0;
  height: 100%;
  overflow: hidden;
}

#map {
  width: 100%;
  height: 100%;
  background: #dfe8ef;
}

.kiosk-marker {
  position: relative;
  display: block;
  width: 30px;
  height: 32px;
  border: 2px solid #fff;
  border-radius: 6px 6px 9px 9px;
  background: #c9362e;
  box-shadow: 0 4px 12px rgba(16, 24, 40, 0.28);
}

.kiosk-marker::before {
  position: absolute;
  bottom: -8px;
  left: 8px;
  width: 0;
  height: 0;
  border-top: 9px solid #c9362e;
  border-right: 5px solid transparent;
  border-left: 5px solid transparent;
  content: "";
}

.kiosk-screen {
  position: absolute;
  top: 5px;
  right: 5px;
  left: 5px;
  height: 10px;
  border: 2px solid #fff;
  background: #ffe59b;
}

.kiosk-screen::after {
  position: absolute;
  right: 2px;
  bottom: 2px;
  left: 2px;
  height: 2px;
  background: #c9362e;
  content: "";
}

.kiosk-slot {
  position: absolute;
  right: 7px;
  bottom: 7px;
  left: 7px;
  height: 4px;
  border-radius: 1px;
  background: #fff;
}

.kiosk-popup {
  min-width: 240px;
  max-width: 440px;
}

.kiosk-popup h2 {
  margin: 0 0 8px;
  font-size: 17px;
  line-height: 1.35;
}

.kiosk-popup dl {
  display: grid;
  grid-template-columns: 82px 1fr;
  gap: 5px 8px;
  margin: 0;
  color: #344054;
  font-size: 13px;
  line-height: 1.45;
}

.kiosk-popup dt {
  color: var(--muted);
  font-weight: 700;
}

.kiosk-popup dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.popup-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.popup-task {
  display: grid;
  gap: 3px;
  margin-top: 11px;
  border: 1px solid #9fc4dd;
  border-left: 4px solid var(--primary);
  border-radius: 4px;
  background: #edf6fc;
  padding: 9px 10px;
}

.popup-task small {
  color: #526679;
  font-size: 11px;
  font-weight: 800;
}

.popup-task strong {
  color: var(--primary-strong);
  font-size: 13px;
  line-height: 1.35;
}

.popup-task span {
  color: #3f5367;
  font-size: 11px;
  line-height: 1.4;
}

.popup-actions a {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  border: 1px solid #bdd2e2;
  border-radius: 4px;
  background: #edf6fc;
  padding: 0 10px;
  color: var(--primary-strong);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.document-panel {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.document-panel summary {
  color: var(--primary-strong);
  cursor: pointer;
  font-size: 14px;
  font-weight: 900;
}

.document-panel p {
  margin: 8px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.document-groups {
  display: grid;
  gap: 10px;
  max-height: 330px;
  overflow: auto;
  padding-right: 4px;
}

.doc-group {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
}

.doc-group summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 38px;
  padding: 7px 9px;
  color: var(--ink);
  cursor: pointer;
  font-size: 12px;
}

.doc-group summary strong {
  font-size: 12px;
}

.doc-group summary span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.doc-group[open] summary {
  border-bottom: 1px solid var(--line);
  background: #f4f8fb;
}

.doc-group ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 8px;
  list-style: none;
}

.doc-item {
  display: grid;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 8px;
}

.doc-item strong {
  color: var(--ink);
  font-size: 12px;
  line-height: 1.35;
}

.doc-item span,
.doc-item em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  line-height: 1.35;
}

.doc-item.unavailable {
  background: #fafafa;
}

.doc-item.unavailable strong {
  color: #7a828e;
  text-decoration: line-through;
}

.doc-item.unavailable em {
  color: var(--danger);
  font-weight: 900;
}

.user-location {
  position: relative;
  display: block;
  width: 28px;
  height: 28px;
  border: 3px solid #fff;
  border-radius: 50% 50% 50% 0;
  background: #e12d27;
  box-shadow:
    0 0 0 7px rgba(225, 45, 39, 0.18),
    0 5px 12px rgba(80, 21, 18, 0.28);
  transform: rotate(-45deg);
}

.user-location span {
  position: absolute;
  top: 7px;
  left: 7px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
}

.current-location-label {
  border: 1px solid #a91f1a;
  border-radius: 3px;
  background: #e12d27;
  box-shadow: 0 2px 7px rgba(80, 21, 18, 0.22);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
}

.leaflet-tooltip-top.current-location-label::before {
  border-top-color: #e12d27;
}

.search-area-border {
  filter: drop-shadow(0 0 5px rgba(229, 155, 18, 0.38));
}

.location-accuracy-border {
  filter: drop-shadow(0 0 4px rgba(0, 94, 168, 0.28));
}

.leaflet-popup-content-wrapper {
  border-top: 4px solid var(--primary);
  border-radius: 4px;
  box-shadow: 0 5px 22px rgba(23, 43, 66, 0.24);
}

.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background-color: rgba(0, 139, 139, 0.2);
}

.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  background-color: var(--secondary);
  color: #fff;
  font-weight: 800;
}

.map-loading {
  position: absolute;
  z-index: 1100;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 7px;
  background: rgba(238, 243, 247, 0.78);
  color: var(--primary-strong);
  backdrop-filter: blur(2px);
}

.map-loading[hidden],
.mobile-detail-panel[hidden] {
  display: none !important;
}

.map-loading strong {
  font-size: 16px;
}

.map-loading small {
  color: #4f6173;
  font-size: 12px;
}

.map-loading-spinner,
.button-loading-spinner {
  display: inline-block;
  width: 28px;
  height: 28px;
  border: 3px solid rgba(0, 94, 168, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: location-spin 0.8s linear infinite;
}

.button-loading-spinner {
  width: 16px;
  height: 16px;
  margin-right: 6px;
  border-width: 2px;
  border-color: rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  vertical-align: -3px;
}

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

.mobile-detail-panel {
  display: none;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(430px, 52vh) 1fr;
    height: auto;
    min-height: 100%;
  }

  .sidebar {
    grid-row: 2;
    height: auto;
    min-height: 48vh;
    border-right: 0;
    border-top: 1px solid var(--line);
  }

  .map-area {
    grid-row: 1;
    height: 52vh;
  }

  .leaflet-popup {
    display: none;
  }

  .mobile-detail-panel {
    position: absolute;
    z-index: 1200;
    right: 8px;
    bottom: 8px;
    left: 8px;
    display: block;
    max-height: calc(52vh - 16px);
    border: 1px solid #aebdca;
    border-top: 5px solid #c9362e;
    border-radius: 5px;
    background: #fff;
    box-shadow: 0 7px 26px rgba(22, 40, 60, 0.3);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px 14px 18px;
  }

  .mobile-detail-panel .kiosk-popup {
    min-width: 0;
    max-width: none;
  }

  .mobile-detail-close {
    position: sticky;
    z-index: 2;
    top: 0;
    float: right;
    width: 34px;
    height: 34px;
    margin: -10px -8px 2px 8px;
    border: 1px solid #c8d2dc;
    border-radius: 3px;
    background: #fff;
    color: #34495d;
    font-size: 24px;
    line-height: 1;
  }

  .result-section {
    max-height: none;
  }
}

@media (max-width: 520px) {
  .brand,
  .stats,
  .filters,
  .status-line,
  .source-line {
    padding-left: 16px;
    padding-right: 16px;
  }

  .result-section {
    padding-left: 16px;
  }

  h1 {
    font-size: 22px;
  }

  .brand {
    padding-top: 15px;
  }

  .stats {
    padding-right: 8px;
    padding-left: 8px;
  }

  .stats div {
    padding-right: 5px;
    padding-left: 5px;
  }

  .field-grid,
  .button-row,
  .address-search,
  .task-select-grid {
    grid-template-columns: 1fr;
  }

  .stats span {
    font-size: 17px;
  }
}
