:root {
  --primary: #b8892f;
  --primary-dark: #745316;
  --gold: #c89645;
  --gold-light: #f0d87c;
  --black: #050505;
  --cream: #fbf4ea;
  --cream-strong: #f3e3cf;
  --paper: #fffdf9;
  --ink: #251d1a;
  --muted: #786d66;
  --line: #ead8c4;
  --success: #178a4d;
  --danger: #c1352b;
  --shadow: 0 14px 34px rgba(68, 38, 23, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: #ece0d2;
}

body {
  min-height: 100dvh;
  margin: 0;
  display: flex;
  justify-content: center;
  background:
    linear-gradient(180deg, rgba(184, 137, 47, 0.12), transparent 260px),
    var(--cream);
  color: var(--ink);
  font-family: "Cairo", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  cursor: pointer;
}

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

.app-shell {
  width: 100%;
  max-width: 420px;
  min-height: 100dvh;
  background: var(--paper);
  box-shadow: var(--shadow);
  overflow-x: hidden;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--black);
  color: #fff;
  padding: 14px 14px 10px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.32);
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: right;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  font-size: 25px;
}

.brand-logo {
  width: 118px;
  max-width: 36%;
  height: auto;
  display: block;
}

.brand h1,
.brand p,
.screen-head h2,
.screen-head p,
.table-title h3,
.field-group p {
  margin: 0;
}

.brand h1 {
  color: var(--gold-light);
  font-size: 20px;
  line-height: 1.1;
  font-weight: 800;
}

.brand p {
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 6px;
  margin-top: 12px;
}

.tab-button,
.tab-link {
  display: grid;
  place-items: center;
  min-height: 42px;
  border: 1px solid rgba(240, 216, 124, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  text-align: center;
  text-decoration: none;
}

.tab-button.active,
.tab-link.active {
  background: var(--gold);
  color: #120d07;
}

.screen {
  display: none;
  padding: 18px 14px 28px;
}

.screen.active {
  display: block;
}

.screen-head {
  margin-bottom: 14px;
}

.kicker {
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}

.screen-head h2 {
  margin-top: 4px;
  font-size: 22px;
  font-weight: 800;
}

.progress-dots {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 14px 0 18px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--cream-strong);
  transition:
    width 180ms ease,
    background 180ms ease;
}

.dot.active {
  width: 28px;
  background: var(--primary);
}

form {
  display: block;
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 14px;
  font-size: 17px;
  font-weight: 800;
}

.form-step {
  display: none;
}

.form-step.active {
  display: grid;
  gap: 13px;
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(184, 137, 47, 0.16);
}

.invalid input,
.invalid select,
.invalid textarea,
input.invalid,
select.invalid,
textarea.invalid {
  border-color: var(--danger);
  background: #fff8f6;
}

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

.field-group {
  display: grid;
  gap: 9px;
}

.field-group p {
  font-size: 13px;
  font-weight: 800;
}

.choice-row,
.pill-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.chip {
  display: block;
  min-width: 0;
}

.chip input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.chip span {
  display: grid;
  min-height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 8px 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  line-height: 1.35;
}

.chip input:checked + span {
  border-color: var(--primary);
  background: #fff7e5;
  color: var(--primary);
}

.field-group.invalid .chip span {
  border-color: var(--danger);
}

.notice {
  border: 1px solid #f0c36d;
  border-radius: 8px;
  background: #fff7df;
  color: #76540d;
  padding: 11px 12px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.6;
}

.map-selector {
  display: grid;
  gap: 8px;
}

.map-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.map-search-field {
  gap: 5px;
  min-width: 0;
}

.map-search button,
.map-results button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--primary);
  padding: 0 12px;
  font-size: 12px;
  font-weight: 800;
}

.map-results {
  display: grid;
  gap: 6px;
}

.map-results[hidden] {
  display: none;
}

.map-results p {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf2;
  color: var(--muted);
  padding: 10px;
  font-size: 12px;
  font-weight: 700;
}

.map-results button {
  display: grid;
  justify-items: start;
  gap: 3px;
  min-height: 50px;
  text-align: right;
}

.map-results button span {
  color: var(--ink);
  font-size: 13px;
}

.map-results button small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.map-toolbar,
.map-actions {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
}

.map-actions {
  grid-template-columns: 1fr 1fr;
}

.map-toolbar button,
.map-actions button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--primary);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
}

.map-toolbar span,
.map-coords {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
}

.mini-map {
  position: relative;
  height: 220px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #e8dfd1;
  cursor: crosshair;
  touch-action: none;
  will-change: contents;
}

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

.map-tiles img {
  position: absolute;
  width: 256px;
  height: 256px;
  user-select: none;
  -webkit-user-drag: none;
  opacity: 0;
  animation: mapTileFade 160ms ease forwards;
}

.map-pin {
  position: absolute;
  display: none;
  width: 18px;
  height: 18px;
  border: 3px solid #fff;
  border-radius: 50% 50% 50% 0;
  background: var(--primary);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transform: translate(-50%, -100%) rotate(-45deg);
  transition: left 180ms ease, top 180ms ease;
}

.map-pin::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: #fff;
}

.map-coords {
  margin: 0;
}

.form-error {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--danger);
  font-size: 13px;
  font-weight: 800;
}

.success-message {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  border: 1px solid rgba(23, 138, 77, 0.28);
  border-radius: 10px;
  background: #effaf3;
  color: var(--success);
  padding: 12px;
  font-size: 14px;
}

.success-message[hidden] {
  display: none;
}

.success-message button,
.success-message a,
.ghost {
  display: grid;
  place-items: center;
  min-height: 38px;
  border: 1px solid currentColor;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font-weight: 800;
  text-decoration: none;
}

.success-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.form-actions button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  font-weight: 800;
}

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

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

.secondary {
  background: var(--cream-strong);
  color: var(--ink);
}

#submitButton {
  display: none;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.stat-card {
  display: grid;
  gap: 6px;
  min-height: 104px;
  align-content: space-between;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.stat-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
}

.stat-card strong {
  color: var(--primary);
  font-size: 22px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.table-panel,
.category-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.section-block {
  margin-top: 16px;
}

.table-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.table-title h3 {
  font-size: 16px;
  font-weight: 800;
}

.ghost {
  color: var(--primary);
  padding: 0 11px;
  font-size: 12px;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}

th,
td {
  border-bottom: 1px solid #f0e1d2;
  padding: 11px 10px;
  text-align: right;
  font-size: 12px;
  vertical-align: middle;
}

th {
  background: #fff8f1;
  color: #5a4033;
  font-weight: 800;
}

td {
  color: #352a25;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  min-height: 26px;
  border-radius: 999px;
  padding: 3px 9px;
  color: #fff;
  font-weight: 800;
}

.badge.yes {
  background: var(--success);
}

.badge.no {
  background: var(--danger);
}

.badge.pending {
  background: var(--gold);
  color: #170f05;
}

.category-table {
  table-layout: fixed;
  white-space: normal;
}

.category-table th:nth-child(1),
.category-table td:nth-child(1) {
  width: 38%;
}

.category-table th:nth-child(2),
.category-table td:nth-child(2) {
  width: 18%;
  text-align: center;
}

.bar-wrap {
  height: 12px;
  min-width: 98px;
  overflow: hidden;
  border-radius: 999px;
  background: #eee1d4;
}

.bar-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #e38b3e);
  transition: width 220ms ease;
}

.empty-state {
  color: var(--muted);
  text-align: center;
  white-space: normal;
}

.route-list {
  display: grid;
  gap: 10px;
}

.route-card {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 14px;
  text-decoration: none;
}

.route-card span {
  color: var(--primary);
  font-size: 15px;
  font-weight: 800;
}

.route-card strong {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.55;
}

.image-grid {
  display: grid;
  gap: 10px;
}

.image-upload {
  min-width: 0;
}

.image-upload input[type="file"] {
  min-height: 44px;
  padding: 8px;
}

.image-preview {
  display: grid;
  min-height: 112px;
  place-items: center;
  overflow: hidden;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fffaf2;
  color: var(--muted);
  padding: 8px;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.image-preview img {
  width: 100%;
  height: 112px;
  object-fit: cover;
  border-radius: 6px;
}

.table-images {
  display: flex;
  align-items: center;
  gap: 6px;
}

.admin-image-gallery {
  display: grid;
  width: 122px;
  gap: 6px;
}

.admin-image-gallery.empty {
  min-height: 84px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: #fffaf2;
}

.gallery-main {
  width: 122px;
  height: 82px;
  border: 1px solid var(--line);
  border-radius: 10px;
  object-fit: cover;
  background: #fff8f1;
  box-shadow: 0 7px 16px rgba(68, 38, 23, 0.12);
}

.gallery-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}

.gallery-thumb {
  width: 100%;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  object-fit: cover;
  background: #fff8f1;
}

.table-thumb {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
  background: #fff8f1;
}

.image-empty {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.login-form {
  display: grid;
  gap: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.login-button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  font-weight: 800;
}

.screen-head.with-action {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.logout-button {
  min-width: 64px;
}

.admin-user-note {
  margin: 0 0 12px;
  border: 1px solid rgba(23, 138, 77, 0.24);
  border-radius: 8px;
  background: #effaf3;
  color: var(--success);
  padding: 9px 10px;
  font-size: 12px;
  font-weight: 800;
}

.admin-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.admin-actions .danger-ghost {
  grid-column: 1 / -1;
}

.danger-ghost {
  color: var(--danger);
}

.map-link {
  display: inline-block;
  margin-top: 4px;
  color: var(--primary);
  font-weight: 800;
  text-decoration: none;
}

.splash-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 22%, rgba(240, 216, 124, 0.13), transparent 38%),
    var(--black);
  color: #fff;
  opacity: 1;
  transition: opacity 420ms ease, visibility 420ms ease;
}

.splash-screen.hide {
  opacity: 0;
  visibility: hidden;
}

.splash-inner {
  display: grid;
  justify-items: center;
  gap: 18px;
  width: min(86vw, 340px);
  text-align: center;
}

.splash-logo {
  width: min(230px, 64vw);
  animation: logoRise 900ms ease both;
}

.splash-title {
  margin: 0;
  color: var(--gold-light);
  font-size: 18px;
  font-weight: 800;
  animation: textSlide 820ms ease both 180ms;
}

.splash-phrases {
  position: relative;
  width: 100%;
  min-height: 26px;
  overflow: hidden;
}

.splash-phrase {
  position: absolute;
  inset: 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 13px;
  font-weight: 700;
  opacity: 0;
  transform: translateY(18px);
  animation: phraseCycle 3.3s ease infinite;
}

.splash-phrase:nth-child(2) {
  animation-delay: 1.1s;
}

.splash-phrase:nth-child(3) {
  animation-delay: 2.2s;
}

.splash-bar {
  width: 160px;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}

.splash-bar::after {
  content: "";
  display: block;
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold), var(--gold-light));
  animation: splashLoad 1.25s ease-in-out infinite;
}

@keyframes logoRise {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes textSlide {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes phraseCycle {
  0% {
    opacity: 0;
    transform: translateY(18px);
  }
  12%,
  30% {
    opacity: 1;
    transform: translateY(0);
  }
  42%,
  100% {
    opacity: 0;
    transform: translateY(-18px);
  }
}

@keyframes splashLoad {
  0% {
    transform: translateX(120%);
  }
  100% {
    transform: translateX(-260%);
  }
}

@keyframes mapTileFade {
  to {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .splash-logo,
  .splash-title,
  .splash-phrase,
  .splash-bar::after,
  .map-tiles img {
    animation: none;
  }

  .map-pin {
    transition: none;
  }

  .map-tiles img {
    opacity: 1;
  }
}

@media (max-width: 520px) {
  .map-search {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 360px) {
  .screen {
    padding-inline: 12px;
  }

  .brand h1 {
    font-size: 18px;
  }

  .brand-logo {
    width: 104px;
  }

  .tab-button,
  .tab-link {
    font-size: 12px;
  }

  .two-col,
  .pill-grid,
  .success-actions,
  .admin-actions,
  .map-toolbar {
    grid-template-columns: 1fr;
  }
}
