:root {
  --bg: #f4f6f5;
  --paper: #ffffff;
  --ink: #17202a;
  --muted: #667085;
  --line: #d8dee4;
  --primary: #0f766e;
  --primary-dark: #0b5f59;
  --accent: #b76e00;
  --danger: #b42318;
  --soft: #e8f3ef;
  --shadow: 0 14px 34px rgba(23, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  letter-spacing: 0;
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.app-loading {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
  color: var(--ink);
  opacity: 1;
  visibility: visible;
  transition: opacity 0.28s ease, visibility 0.28s ease;
}

body.app-ready .app-loading {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-card {
  width: min(320px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px 20px;
  background: var(--paper);
  box-shadow: var(--shadow);
  text-align: center;
}

.loading-spinner {
  width: 38px;
  height: 38px;
  margin: 0 auto 14px;
  border: 4px solid #dbe7e3;
  border-top-color: var(--primary);
  border-radius: 999px;
  animation: loading-spin 0.8s linear infinite;
}

.loading-card p {
  margin: 0 0 7px;
  font-size: 18px;
  font-weight: 900;
}

.loading-card span {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

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

h1,
h2,
h3,
p {
  margin-top: 0;
}

.locator-page {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 28px;
}

.front-header,
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.front-header {
  min-height: 82px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.front-header h1 {
  margin-bottom: 0;
  font-size: 32px;
  line-height: 1.2;
}

.status-pill {
  min-width: 74px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px;
  background: var(--paper);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.finder-bar {
  display: grid;
  grid-template-columns: minmax(180px, 1.5fr) minmax(130px, 0.8fr) minmax(130px, 0.8fr) 86px 86px;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  background: var(--paper);
  color: var(--ink);
  outline: none;
}

textarea {
  min-height: 180px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
}

input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
  accent-color: var(--primary);
}

.delivery-field {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.delivery-field legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.check-line {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 14px;
}

.primary-button,
.ghost-button,
.file-button,
.link-button {
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 15px;
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

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

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

.ghost-button {
  border-color: var(--line);
  background: var(--paper);
  color: var(--ink);
}

.compact {
  min-height: 36px;
  padding-inline: 12px;
  font-size: 14px;
}

.locator-layout {
  display: grid;
  grid-template-columns: 390px minmax(0, 1fr);
  gap: 14px;
  min-height: 640px;
}

.result-pane,
.map-pane,
.edit-panel,
.list-panel,
.auth-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.result-pane {
  min-height: 640px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.result-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 48px;
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
  color: var(--muted);
  font-weight: 800;
}

.store-list {
  overflow: auto;
  padding: 12px;
}

.store-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
  cursor: pointer;
}

.store-card + .store-card {
  margin-top: 10px;
}

.store-card:hover,
.store-card.active {
  border-color: var(--primary);
  background: var(--soft);
}

.store-card h2 {
  margin-bottom: 8px;
  font-size: 18px;
  line-height: 1.35;
}

.store-meta,
.store-detail {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.meta-chip {
  border-radius: 999px;
  background: #f2f4f7;
  padding: 3px 9px;
}

.delivery-chip {
  background: #fff7ed;
  color: #9a3412;
}

.store-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 11px;
}

.link-button {
  min-height: 36px;
  background: var(--ink);
  color: #fff;
  font-size: 14px;
}

.phone-link {
  color: var(--primary-dark);
  font-weight: 800;
  text-decoration: none;
}

.map-pane {
  overflow: hidden;
}

.map-canvas {
  width: 100%;
  height: 100%;
  min-height: 640px;
  background: #dfeae6;
}

.google-map-frame {
  display: block;
  border: 0;
}

.empty-state,
.alert {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  color: var(--muted);
  background: #fbfcfd;
}

.alert.success {
  border-style: solid;
  border-color: #a7d6c5;
  color: var(--primary-dark);
  background: #eefaf5;
}

.alert.error {
  border-style: solid;
  border-color: #f1b6b0;
  color: var(--danger);
  background: #fff5f5;
}

.admin-body {
  min-height: 100vh;
}

.admin-header {
  min-height: 64px;
  border-bottom: 1px solid var(--line);
  padding: 0 22px;
  background: var(--paper);
}

.admin-brand,
.secondary-link {
  color: var(--primary-dark);
  font-weight: 900;
  text-decoration: none;
}

.admin-session {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
}

.admin-session form {
  margin: 0;
}

.admin-shell {
  width: min(1360px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 28px;
}

.auth-panel {
  min-height: calc(100vh - 118px);
  display: grid;
  place-items: center;
}

.auth-box {
  width: min(390px, 100%);
  padding: 22px;
}

.install-box {
  width: min(780px, 100%);
  margin: 0 auto;
}

.auth-box h1,
.edit-panel h1,
.list-panel h2 {
  margin-bottom: 16px;
  font-size: 22px;
}

.auth-box button {
  width: 100%;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.85fr) minmax(520px, 1.15fr);
  gap: 14px;
}

.edit-panel,
.list-panel {
  padding: 16px;
}

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

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

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

.wide {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-map {
  width: 100%;
  height: 300px;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #dfeae6;
}

.admin-tools {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) 130px 92px;
  gap: 10px;
  margin-bottom: 10px;
}

.table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.location-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

.location-table th,
.location-table td {
  border-bottom: 1px solid var(--line);
  padding: 11px;
  text-align: left;
  vertical-align: top;
}

.location-table th {
  background: #f8faf9;
  color: var(--muted);
  font-size: 13px;
}

.location-table tr:last-child td {
  border-bottom: 0;
}

.row-title {
  font-weight: 900;
}

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

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.table-actions form {
  margin: 0;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--primary-dark);
  cursor: pointer;
  font-weight: 900;
  padding: 0;
  text-decoration: none;
}

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

.code-textarea {
  min-height: 260px;
  font-family: Consolas, Monaco, monospace;
  font-size: 12px;
}

@media (max-width: 960px) {
  .finder-bar,
  .locator-layout,
  .admin-grid,
  .admin-tools {
    grid-template-columns: 1fr;
  }

  .locator-layout {
    min-height: 0;
  }

  .map-pane {
    order: 1;
  }

  .result-pane {
    order: 2;
    min-height: 0;
  }

  .map-canvas {
    min-height: 430px;
  }

  .store-list {
    max-height: 460px;
  }
}

@media (max-width: 560px) {
  .locator-page,
  .admin-shell {
    width: min(100% - 18px, 1180px);
  }

  .front-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .front-header h1 {
    font-size: 28px;
  }

  .location-form {
    grid-template-columns: 1fr;
  }

  .form-actions,
  .admin-session {
    align-items: stretch;
    flex-direction: column;
  }
}
