:root {
  --bg: #f5efe6;
  --panel: #fffaf3;
  --panel-strong: #fff;
  --border: #d9c8af;
  --text: #1f1a17;
  --muted: #6e6258;
  --accent: #c96c3a;
  --accent-dark: #9f4f25;
  --danger: #9e2f2f;
  --shadow: 0 20px 45px rgba(86, 52, 28, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Georgia, "Noto Serif SC", serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(201, 108, 58, 0.16), transparent 32%),
    linear-gradient(135deg, #f4ecdf, #efe3d1 45%, #f8f2ea);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: linear-gradient(rgba(31, 26, 23, 0.03) 1px, transparent 1px), linear-gradient(90deg, rgba(31, 26, 23, 0.03) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
}

.landing,
.dashboard {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding: 32px;
}

.landing {
  display: grid;
  place-items: center;
}

.hero,
.panel {
  background: rgba(255, 250, 243, 0.9);
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.hero {
  max-width: 720px;
  padding: 48px;
  text-align: center;
}

.auth-page {
  align-items: center;
}

.auth-card {
  width: min(100%, 560px);
}

.hero-panel {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  margin-bottom: 24px;
  padding: 28px 32px;
}

.eyebrow {
  margin: 0 0 8px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-dark);
  font-size: 12px;
}

h1,
h2 {
  margin: 0;
  font-weight: 700;
}

.lead {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.primary-link,
.ghost-link,
.primary-button,
.ghost-button,
.danger-button {
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.primary-link,
.primary-button {
  background: var(--accent);
  color: #fff7f2;
}

.ghost-link,
.ghost-button {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

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

.primary-link:hover,
.ghost-link:hover,
.primary-button:hover,
.ghost-button:hover,
.danger-button:hover {
  transform: translateY(-1px);
}

.hero-actions,
.form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 24px;
}

.panel {
  padding: 24px;
}

.collapsible-panel {
  padding: 0;
  overflow: hidden;
}

.collapse-summary {
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 24px;
  cursor: pointer;
}

.collapse-summary::-webkit-details-marker {
  display: none;
}

.collapse-summary p {
  margin: 8px 0 0;
  color: var(--muted);
}

.collapse-body {
  padding: 0 24px 24px;
}

.collapse-hint {
  color: var(--accent-dark);
  font-size: 13px;
  white-space: nowrap;
}

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

.section-title {
  margin-bottom: 20px;
}

.section-title-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.section-title p {
  margin: 8px 0 0;
  color: var(--muted);
}

.route-form,
.route-form label {
  display: grid;
  gap: 10px;
}

.route-form label span {
  font-size: 14px;
  color: var(--muted);
}

.inline-tip {
  display: grid;
  align-content: end;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.row-two {
  grid-template-columns: 0.9fr 1.1fr;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 14px;
  font: inherit;
  color: var(--text);
  background: var(--panel-strong);
}

button:disabled {
  opacity: 0.6;
  cursor: wait;
}

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

select[multiple] {
  min-height: 220px;
}

.small-textarea {
  min-height: 120px;
}

.message {
  min-height: 24px;
  margin: 16px 0 0;
  color: var(--accent-dark);
}

.search-box {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.country-select-box {
  align-self: stretch;
}

.settings-panel {
  margin-bottom: 24px;
}

.select-card,
.textarea-card {
  display: grid;
  gap: 10px;
}

.template-box {
  display: grid;
  gap: 14px;
  margin-top: 18px;
  padding: 18px;
  border: 1px solid rgba(217, 200, 175, 0.8);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.55);
}

.template-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: end;
  flex-wrap: wrap;
}

.template-name-field {
  flex: 1 1 320px;
}

.template-list {
  display: grid;
  gap: 12px;
}

.template-tag-card {
  padding: 14px;
  border: 1px solid rgba(217, 200, 175, 0.8);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.78);
}

.template-tag-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.log-tools {
  display: grid;
  gap: 16px;
  margin-top: 18px;
  padding: 18px;
  border: 1px solid rgba(217, 200, 175, 0.8);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.5);
}

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

.stat-card {
  padding: 14px;
  border: 1px solid rgba(217, 200, 175, 0.8);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.75);
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.stat-card strong {
  font-size: 20px;
  color: var(--accent-dark);
}

.select-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

.mini-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.visits-page {
  max-width: 1320px;
  margin: 0 auto;
}

.visit-groups {
  display: grid;
  gap: 18px;
}

.visit-group {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.7);
}

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

.visit-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
}

.visit-table th,
.visit-table td {
  text-align: left;
  padding: 12px 10px;
  border-top: 1px solid rgba(217, 200, 175, 0.7);
  font-size: 14px;
}

.visit-table th {
  color: var(--muted);
  font-weight: 600;
}

.empty-state {
  padding: 24px;
  border: 1px dashed var(--border);
  border-radius: 20px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.4);
}

.route-list,
.log-list {
  display: grid;
  gap: 14px;
}

.route-card,
.log-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.65);
}

.route-card header,
.log-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 6px 10px;
  background: #f2e0cf;
  color: var(--accent-dark);
  font-size: 12px;
}

.meta,
.response-preview {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  word-break: break-all;
}

.response-preview {
  white-space: pre-wrap;
  max-height: 130px;
  overflow: auto;
}

.card-actions {
  margin-top: 14px;
  display: flex;
  gap: 10px;
}

.route-visit-block {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(217, 200, 175, 0.7);
}

.route-visit-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

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

.route-visit-panel {
  padding: 12px;
  border: 1px solid rgba(217, 200, 175, 0.8);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
}

.route-visit-title {
  margin-bottom: 10px;
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 600;
}

.mini-table {
  width: 100%;
  border-collapse: collapse;
}

.mini-table th,
.mini-table td {
  text-align: left;
  padding: 8px 6px;
  border-top: 1px solid rgba(217, 200, 175, 0.6);
  font-size: 13px;
  color: var(--muted);
  word-break: break-all;
}

.mini-table th {
  color: var(--text);
  font-weight: 600;
}

.small-button {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  color: var(--text);
  text-decoration: none;
}

.hidden {
  display: none;
}

@media (max-width: 900px) {
  .dashboard,
  .landing {
    padding: 18px;
  }

  .hero-panel,
  .grid,
  .row {
    grid-template-columns: 1fr;
    display: grid;
  }

  .inline-tip {
    align-content: start;
  }

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

  .template-toolbar,
  .template-tag-head {
    display: block;
  }

  .collapse-summary {
    display: block;
  }

  .hero-panel {
    justify-content: normal;
  }

  .visit-group header {
    display: block;
  }

  .route-visit-grid {
    grid-template-columns: 1fr;
  }

  .visit-table,
  .visit-table thead,
  .visit-table tbody,
  .visit-table tr,
  .visit-table th,
  .visit-table td,
  .mini-table,
  .mini-table thead,
  .mini-table tbody,
  .mini-table tr,
  .mini-table th,
  .mini-table td {
    display: block;
    width: 100%;
  }

  .visit-table thead,
  .mini-table thead {
    display: none;
  }

  .visit-table td,
  .mini-table td {
    padding: 8px 0;
    border-top: none;
  }
}
