:root {
  --bg: #f6f6ee;
  --panel: #fffdf7;
  --accent: #1f6f5f;
  --accent-strong: #155648;
  --text: #232323;
  --muted: #686868;
  --line: #d7d3c8;
  --danger: #bc3f33;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Space Grotesk', sans-serif;
  background:
    radial-gradient(circle at 12% 12%, #dbe9d7 0%, transparent 20%),
    radial-gradient(circle at 88% 20%, #f0ddc5 0%, transparent 24%),
    var(--bg);
  color: var(--text);
}

.app-shell {
  width: min(1200px, 92vw);
  margin: 1.5rem auto 2.5rem;
}

.hero h1 {
  margin: 0;
  font-size: clamp(1.45rem, 3vw, 2.2rem);
}

.hero p {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.layout-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.9rem;
  box-shadow: 0 8px 24px rgba(20, 30, 20, 0.06);
}

.map-panel,
.list-panel {
  grid-column: 1 / 2;
}

.form-panel {
  grid-column: 2 / 3;
  grid-row: 1 / 3;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.65rem;
}

.panel-header h2 {
  margin: 0;
  font-size: 1rem;
}

.panel-header small {
  color: var(--muted);
}

#map {
  width: 100%;
  height: 420px;
  border-radius: 10px;
  border: 1px solid var(--line);
}

.message {
  min-height: 1.3rem;
  margin-bottom: 0.45rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.message.error {
  color: var(--danger);
}

.message.success {
  color: var(--accent-strong);
}

form {
  display: grid;
  gap: 0.6rem;
}

label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.88rem;
  color: var(--muted);
}

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

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.52rem 0.62rem;
  background: #fff;
  color: var(--text);
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 35%, white);
  border-color: var(--accent);
}

.latlng-row {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.3rem;
}

button {
  border: none;
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
  cursor: pointer;
  font-weight: 600;
}

#save-btn {
  background: var(--accent);
  color: #fff;
}

#save-btn:hover {
  background: var(--accent-strong);
}

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

.address-list {
  display: grid;
  gap: 0.6rem;
}

.copy-field-list {
  display: grid;
  gap: 0.65rem;
}

.copy-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: start;
  border: 1px solid rgba(215, 211, 200, 0.9);
  border-radius: 10px;
  padding: 0.65rem;
  background: rgba(255, 255, 255, 0.85);
}

.copy-field.is-empty {
  background: #fffcf4;
}

.copy-field-meta {
  min-width: 0;
}

.copy-field-label {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.copy-field-value {
  margin: 0.28rem 0 0;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.35;
  word-break: break-word;
}

.copy-field.is-empty .copy-field-value {
  color: #8b867a;
  font-style: italic;
}

.copy-btn {
  align-self: center;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  min-width: 74px;
}

.copy-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.copy-btn:disabled {
  opacity: 0.56;
  cursor: not-allowed;
}

.address-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem;
  background: #fff;
}

.address-item h3 {
  margin: 0;
  font-size: 0.97rem;
}

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

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

.item-actions button {
  padding: 0.42rem 0.68rem;
  font-size: 0.84rem;
}

.brand-action {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 1.45rem;
  height: 1.45rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  color: #fff;
}

.brand-action.shopee .brand-mark {
  background: linear-gradient(135deg, #ff7a2f, #ee4d2d);
}

.brand-action.pinduoduo .brand-mark {
  background: linear-gradient(135deg, #ff5a74, #d91f3d);
}

.brand-text {
  font-weight: 700;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 1.2rem;
  background: rgba(30, 28, 24, 0.42);
  backdrop-filter: blur(3px);
}

.modal-overlay.hidden {
  display: none;
}

.modal-card {
  width: min(860px, 100%);
  max-height: min(82vh, 900px);
  overflow: auto;
  border: 1px solid rgba(215, 211, 200, 0.95);
  border-radius: 18px;
  padding: 1rem;
  background:
    radial-gradient(circle at top right, rgba(255, 234, 214, 0.85), transparent 26%),
    linear-gradient(180deg, #fffdf8, #faf6eb);
  box-shadow: 0 26px 60px rgba(28, 30, 25, 0.24);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
  margin-bottom: 0.9rem;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.15rem;
}

.modal-subtitle {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.icon-close {
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font-size: 1.35rem;
  line-height: 1;
}

.modal-fields {
  display: grid;
  gap: 0.7rem;
}

.item-actions .danger {
  background: #fff0ee;
  color: var(--danger);
  border: 1px solid #f1cac6;
}

.empty-state {
  color: var(--muted);
  font-size: 0.92rem;
  text-align: center;
  padding: 1rem;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: #fffcf4;
}

@media (max-width: 980px) {
  .layout-grid {
    grid-template-columns: 1fr;
  }

  .map-panel,
  .form-panel,
  .list-panel {
    grid-column: auto;
    grid-row: auto;
  }

  #map {
    height: 360px;
  }
}

@media (max-width: 640px) {
  .copy-field {
    grid-template-columns: 1fr;
  }

  .copy-btn {
    width: 100%;
  }

  .modal-overlay {
    padding: 0.75rem;
  }

  .modal-card {
    padding: 0.85rem;
  }
}
