:root {
  --ink: #102033;
  --muted: #627084;
  --line: #d6dee8;
  --surface: #ffffff;
  --bg: #f4f7fb;
  --brand: #0d3b66;
  --blue: #2563eb;
  --green: #15803d;
  --amber: #b45309;
  --red: #b91c1c;
  --soft-blue: #e8f0ff;
  --shadow: 0 18px 48px rgba(13, 59, 102, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(135deg, #eef4f8 0%, #f7fafc 52%, #eef2ff 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, 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.55;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  padding: 0;
}

.shell {
  width: min(100%, 460px);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
  border-inline: 1px solid rgba(16, 32, 51, 0.08);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  min-height: 84px;
  padding: 18px 20px;
  color: #ffffff;
  background: var(--brand);
}

.topbar span {
  display: block;
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
}

.topbar strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

.network {
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  padding: 7px 10px;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.sign-out {
  min-height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 8px;
  background: transparent;
  color: #ffffff;
  padding: 0 9px;
  font-weight: 800;
}

.notice {
  margin: 14px 16px 0;
  padding: 12px 14px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  color: #1e3a8a;
  font-size: 14px;
}

.auth-notice {
  margin: 0;
}

.screen {
  padding: 20px 16px 32px;
}

.brand-block {
  padding: 22px;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  border-top: 5px solid #f4d35e;
}

.brand-block p {
  margin: 0 0 6px;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 12px;
}

h1 {
  margin: 0 0 18px;
  font-size: 28px;
  line-height: 1.12;
}

h2 {
  margin: 24px 0 12px;
  font-size: 18px;
}

.brand-block h1 {
  margin-bottom: 0;
}

.queue-strip {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin: 18px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.sync-strip,
.login-panel {
  margin: 18px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.sync-strip {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.sync-strip span,
.login-panel p {
  color: var(--muted);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.auth-tabs button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.auth-tabs button.active {
  background: var(--brand);
  color: #ffffff;
}

.auth-form {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.auth-form h2 {
  margin: 0;
}

.auth-form p {
  margin: 0;
}

.password-policy {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 10px 12px;
}

.password-policy > span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.password-policy ul {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.password-policy li {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--red);
  font-size: 14px;
}

.password-policy li.matched {
  color: var(--green);
}

.password-policy li span {
  width: 18px;
  font-weight: 900;
}

.auth-form .secondary + .secondary,
.auth-form .primary + .secondary {
  margin-top: 2px;
}

.queue-strip span {
  font-weight: 800;
}

.queue-strip button,
.primary,
.secondary,
.back,
.selected-pit button,
.history-item button {
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid var(--blue);
  background: var(--blue);
  color: #ffffff;
  padding: 0 14px;
  font-weight: 800;
}

.secondary,
.back,
.primary-soft,
.history-item button {
  background: #ffffff;
  color: var(--blue);
}

.full {
  width: 100%;
}

.menu-grid {
  display: grid;
  gap: 12px;
}

.menu-card {
  min-height: 112px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  text-align: left;
  box-shadow: 0 10px 28px rgba(13, 59, 102, 0.08);
}

.menu-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 20px;
}

.menu-card span {
  color: var(--muted);
}

.back {
  margin-bottom: 18px;
}

.field {
  display: block;
  margin: 14px 0;
}

.field span {
  display: block;
  margin-bottom: 7px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 0 12px;
}

textarea {
  min-height: 96px;
  padding: 12px;
  resize: vertical;
}

.check-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 14px 0;
}

.check-row input {
  width: 22px;
  min-height: 22px;
}

.map-panel {
  position: relative;
  height: 260px;
  margin: 16px 0;
  overflow: hidden;
  border: 1px solid #bdd0e8;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(13, 59, 102, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(13, 59, 102, 0.08) 1px, transparent 1px),
    #eaf4ef;
  background-size: 38px 38px;
}

.map-panel p {
  margin: 110px 0 0;
  text-align: center;
  color: var(--muted);
}

.map-label {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  border-radius: 999px;
  background: #ffffff;
  padding: 6px 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.pin {
  position: absolute;
  transform: translate(-50%, -50%);
  min-width: 40px;
  max-width: 92px;
  min-height: 32px;
  overflow: hidden;
  border: 2px solid #ffffff;
  border-radius: 999px;
  background: var(--brand);
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(13, 59, 102, 0.22);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-pit {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  background: #f0fdf4;
}

.nearest-list,
.history-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.nearest-list button,
.history-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 10px 12px;
}

.nearest-list small,
.meta {
  color: var(--muted);
}

.record-status {
  display: inline-flex;
  margin-bottom: 12px;
  border-radius: 999px;
  padding: 6px 10px;
  background: #e2e8f0;
  color: #334155;
  font-weight: 800;
  text-transform: capitalize;
}

.record-status.queued {
  background: #fef3c7;
  color: var(--amber);
}

.record-status.failed {
  background: #fee2e2;
  color: var(--red);
}

.record-status.synced {
  background: #dcfce7;
  color: var(--green);
}

.photo-actions {
  position: relative;
  margin-bottom: 10px;
}

.photo-button {
  display: grid;
  place-items: center;
  min-height: 48px;
  border: 1px solid var(--blue);
  border-radius: 8px;
  color: var(--blue);
  font-weight: 800;
}

.take-photo-button {
  padding-right: 58px;
}

.library-photo-button {
  position: absolute;
  right: 5px;
  bottom: 5px;
  display: grid;
  place-items: center;
  width: 38px;
  min-height: 38px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #ffffff;
  color: var(--brand);
  box-shadow: 0 6px 14px rgba(16, 32, 51, 0.18);
}

.library-photo-icon {
  position: relative;
  display: block;
  width: 21px;
  height: 17px;
  border: 2px solid currentColor;
  border-radius: 4px;
}

.library-photo-icon::before {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: currentColor;
}

.library-photo-icon::after {
  content: "";
  position: absolute;
  left: 3px;
  bottom: 2px;
  width: 11px;
  height: 7px;
  background: currentColor;
  clip-path: polygon(0 100%, 42% 30%, 62% 58%, 78% 36%, 100% 100%);
}

.photo-button input {
  display: none;
}

.library-photo-button input {
  display: none;
}

.photo-list {
  display: grid;
  gap: 8px;
}

.photo-list span {
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 9px 10px;
  color: var(--muted);
}

.duct-summary-map,
.duct-map-screen .duct-map-grid,
.duct-fields {
  margin: 10px 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.duct-summary-map {
  padding: 12px;
}

.duct-map-screen .duct-map-grid {
  padding: 14px;
}

.duct-map-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  width: min(100%, 340px);
  margin: 0 auto;
}

.duct-slot {
  display: grid;
  place-items: center;
  min-height: 92px;
  min-width: 0;
}

.duct-circle,
.duct-empty-space {
  width: clamp(56px, 17vw, 70px);
  aspect-ratio: 1;
  border-radius: 999px;
}

.duct-token {
  position: relative;
  display: grid;
  place-items: center;
  width: clamp(56px, 17vw, 70px);
  aspect-ratio: 1;
}

.duct-token .duct-circle {
  width: 100%;
}

.duct-circle {
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 0;
  font-weight: 900;
}

.duct-circle.filled {
  border: 3px solid #071829;
  background: #0d3b66;
  color: #ffffff;
  box-shadow: 0 9px 20px rgba(13, 59, 102, 0.22);
}

.duct-circle.filled.center {
  background: #06192b;
}

.duct-circle.filled.selected {
  border-color: #f4d35e;
  box-shadow: 0 9px 20px rgba(13, 59, 102, 0.22);
}

.duct-circle.add {
  border: 3px dotted #94a3b8;
  background: #e5e7eb;
  color: #334155;
  font-size: 32px;
  line-height: 1;
}

.duct-remove-button {
  position: absolute;
  top: -8px;
  right: -8px;
  display: grid;
  place-items: center;
  width: 34px;
  min-height: 34px;
  border: 2px solid #ffffff;
  border-radius: 999px;
  background: var(--red);
  color: #ffffff;
  font-size: 24px;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 7px 16px rgba(185, 28, 28, 0.28);
}

.duct-empty-space {
  display: block;
}

.duct-fields {
  padding: 14px;
}

.duct-fields h2 {
  margin-top: 0;
}

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

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  align-items: end;
  background: rgba(16, 32, 51, 0.48);
}

.location-picker {
  width: min(100%, 520px);
  max-height: 94vh;
  margin: 0 auto;
  overflow: auto;
  border-radius: 8px 8px 0 0;
  background: var(--bg);
  padding: 16px;
  box-shadow: 0 -18px 48px rgba(16, 32, 51, 0.26);
}

.location-header,
.address-search,
.location-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.location-header {
  justify-content: space-between;
  margin-bottom: 14px;
}

.location-header h2 {
  margin: 0;
}

.icon-button {
  width: 44px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font-weight: 900;
}

.address-search input {
  min-width: 0;
}

.address-results {
  display: grid;
  gap: 8px;
  margin: 10px 0;
}

.address-results button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 8px 10px;
  text-align: left;
}

.map-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
}

.segmented-control,
.zoom-controls {
  display: flex;
  gap: 6px;
  align-items: center;
}

.segmented-control {
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.segmented-control button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 0 10px;
  font-weight: 800;
}

.segmented-control button.active {
  background: var(--brand);
  color: #ffffff;
}

.location-map-panel {
  position: relative;
  height: min(56vh, 430px);
  min-height: 320px;
  margin: 14px 0 10px;
  overflow: hidden;
  border: 1px solid #9bb7d6;
  border-radius: 8px;
  background: #dbeafe;
}

.location-map-panel .maplibregl-canvas {
  outline: none;
}

.location-map-panel .maplibregl-ctrl-group {
  border-radius: 8px;
  box-shadow: 0 8px 18px rgba(16, 32, 51, 0.18);
}

.location-actions {
  position: sticky;
  bottom: -16px;
  grid-template-columns: 1fr 1fr;
  margin: 14px -16px -16px;
  padding: 12px 16px 16px;
  background: var(--bg);
}

.danger,
.success {
  flex: 1;
  min-height: 50px;
  border-radius: 8px;
  color: #ffffff;
  font-weight: 900;
}

.danger {
  border: 1px solid var(--red);
  background: var(--red);
}

.success {
  border: 1px solid var(--green);
  background: var(--green);
}

.history-item {
  display: grid;
  grid-template-columns: 88px 60px 1fr 64px;
  align-items: center;
}

.history-item strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (min-width: 860px) {
  .shell {
    margin: 28px auto;
    min-height: calc(100vh - 56px);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: var(--shadow);
  }
}
