:root {
  --navy: #0b1424;
  --navy-2: #121c2f;
  --ink: #1b2a41;
  --muted: #6b7c93;
  --line: #e6edf5;
  --bg: #f3f6fb;
  --card: #ffffff;
  --green: #12b76a;
  --green-dark: #0e9f5c;
  --mint: #dff8ec;
  --mint-2: #ecfbf3;
  --shadow: 0 10px 30px rgba(18, 40, 72, 0.08);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, Segoe UI, system-ui, sans-serif;
}

body {
  padding-bottom: 72px;
}

button,
input,
select,
textarea {
  font: inherit;
  font-size: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 28px 12px;
  padding-top: calc(18px + env(safe-area-inset-top));
  background: var(--navy);
  color: white;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  overflow: hidden;
  background: #eaf6ea;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 8px 18px rgba(18, 183, 106, 0.28);
}

.brand-mark img {
  width: 88%;
  height: 88%;
  object-fit: contain;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.brand h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.04em;
}

.brand p {
  margin: 0;
  color: #9aa8bd;
  font-size: 14px;
}

.btn-scan,
.btn-primary {
  border: 0;
  background: var(--green);
  color: white;
  border-radius: 999px;
  padding: 12px 20px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(18, 183, 106, 0.28);
}

.btn-scan:hover,
.btn-primary:hover {
  background: var(--green-dark);
}

.btn-scan svg,
.btn-primary svg,
.tab svg,
.icon-lg svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  padding: 10px 28px 16px;
  background: var(--navy);
}

body.is-owner .tabs {
  grid-template-columns: 1fr 1fr 1fr;
}

.tab {
  border: 0;
  background: transparent;
  color: #8b97ab;
  border-radius: 999px;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 650;
  cursor: pointer;
}

.tab.is-active {
  background: #243044;
  color: white;
}

.view {
  display: none;
  padding: 28px;
  max-width: 980px;
  margin: 0 auto;
}

.view.is-visible {
  display: block;
}

.empty {
  text-align: center;
  padding: 48px 16px 24px;
}

.icon-lg {
  width: 84px;
  height: 84px;
  margin: 0 auto 18px;
  border-radius: 26px;
  background: var(--mint-2);
  color: var(--green);
  display: grid;
  place-items: center;
}

.icon-lg svg {
  width: 36px;
  height: 36px;
}

.empty h2 {
  margin: 0 0 10px;
  font-size: 32px;
}

.empty p {
  margin: 0 auto 24px;
  max-width: 560px;
  color: var(--muted);
  line-height: 1.55;
  font-size: 16px;
}

.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-top: 42px;
}

.step {
  background: var(--card);
  border-radius: 22px;
  padding: 28px 18px;
  box-shadow: var(--shadow);
}

.step .mini {
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  border-radius: 16px;
  background: var(--mint);
  color: var(--green);
  display: grid;
  place-items: center;
}

.step .mini svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.step h3 {
  margin: 0 0 6px;
  font-size: 16px;
}

.step p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.search {
  width: 100%;
  border: 1px solid var(--line);
  background: white;
  border-radius: 16px;
  padding: 16px 18px 16px 46px;
  outline: none;
  box-shadow: var(--shadow);
}

.search-wrap {
  position: relative;
  margin-bottom: 16px;
}

.search-wrap svg {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  stroke: #98a6b8;
  fill: none;
  stroke-width: 2;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.clear-bar {
  display: grid;
  gap: 10px;
  margin: 0 0 18px;
}

.clear-slot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.clear-slot.is-confirm {
  padding: 10px 12px;
  border-radius: 14px;
  background: #fff4f2;
  border: 1px solid #f5c2c0;
}

.clear-slot span {
  color: #b42318;
  font-size: 14px;
  font-weight: 650;
}

.btn-danger {
  border: 0;
  background: #d92d20;
  color: white;
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 700;
}

.btn-danger:hover {
  background: #b42318;
}

.btn-ghost:disabled {
  opacity: 0.45;
  cursor: default;
}

.voice-panel {
  background: white;
  border-radius: 18px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  min-height: 0;
}

.voice-panel:empty {
  display: none;
}

.voice-panel p {
  margin: 0 0 10px;
  color: var(--muted);
}

.voice-status {
  color: var(--ink) !important;
  font-weight: 650;
}
  background: white;
  border-radius: 18px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.pending-panel h3 {
  margin: 0;
}

.pending-panel p {
  color: var(--muted);
  margin: 8px 0 14px;
}

.chip {
  border: 1px solid var(--line);
  background: white;
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  color: var(--muted);
  font-weight: 650;
}

.chip.is-active {
  background: var(--navy);
  border-color: var(--navy);
  color: white;
}

.card {
  background: white;
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 48px 20px;
  text-align: center;
}

.card .box-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 14px;
  color: #c5d0dd;
}

.card .box-icon svg {
  width: 64px;
  height: 64px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
}

.packages {
  display: grid;
  gap: 12px;
}

.package {
  background: white;
  border-radius: 18px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 16px;
}

.package h3 {
  margin: 0;
  font-size: 16px;
}

.package p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.status {
  align-self: start;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
}

.status.pending {
  background: #eef3fb;
  color: #35507a;
}

.status.delivered {
  background: var(--mint);
  color: #0b7a45;
}

.status.failed {
  background: #fde8e8;
  color: #b42318;
}

.package-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-ghost {
  border: 1px solid var(--line);
  background: white;
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 650;
}

.map-wrap {
  height: 360px;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

body.is-scanning .map-wrap,
body.is-scanning .leaflet-pane,
body.is-scanning .leaflet-control-container {
  display: none !important;
}

.route-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.route-head h2 {
  margin: 0;
}

.stops {
  display: grid;
  gap: 12px;
}

.stop {
  background: white;
  border-radius: 18px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.stop-title {
  display: flex;
  gap: 12px;
  align-items: center;
}

.stop-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

.stop-packages {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.package.is-stop {
  box-shadow: none;
  border: 1px solid var(--line);
}

.note {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f3fbf6;
  border-left: 4px solid var(--green);
  color: var(--ink);
  font-size: 14px;
  text-align: left;
}

.note strong {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #0b7a45;
}

.note span {
  display: block;
}

.note .linkish {
  margin-top: 6px;
}

.note-full {
  margin: 12px 0 18px;
  font-size: 16px;
  line-height: 1.5;
}

.no-note {
  font-size: 13px;
  font-style: italic;
}

.form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  resize: vertical;
  min-height: 84px;
}

.badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--green);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 800;
}

.building {
  margin-top: 10px;
  padding-left: 44px;
  color: var(--muted);
  font-size: 14px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 14, 28, 0.88);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 4000;
}

.modal[hidden] {
  display: none;
}

.sheet {
  width: min(560px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: white;
  border-radius: 24px;
  padding: 22px;
}

.sheet h2 {
  margin: 0 0 8px;
}

.sheet p {
  color: var(--muted);
}

#reader {
  overflow: hidden;
  border-radius: 16px;
  margin: 12px 0;
  min-height: 220px;
  background: #0b1424;
}

#reader video,
#reader img,
#reader canvas {
  width: 100% !important;
  max-height: 320px;
  object-fit: cover;
  border-radius: 16px;
}

#scan-status {
  min-height: 1.4em;
  font-size: 14px;
}

.file-btn {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.form {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.form input,
.form select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.linkish {
  background: none;
  border: 0;
  color: var(--green-dark);
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}

@media (max-width: 760px) {
  .topbar,
  .tabs,
  .view {
    padding-left: 16px;
    padding-right: 16px;
  }

  .topbar {
    flex-wrap: wrap;
    padding-bottom: 16px;
  }

  .btn-scan {
    width: 100%;
    justify-content: center;
  }

  .brand h1 {
    font-size: 22px;
  }

  .brand p {
    font-size: 13px;
  }

  .steps {
    grid-template-columns: 1fr;
  }

  .map-wrap {
    height: 240px;
  }

  .empty h2 {
    font-size: 26px;
  }

  .route-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .package-actions .btn-ghost,
  .btn-ghost,
  .btn-primary,
  .file-btn {
    min-height: 44px;
  }
}

.device-bar {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  background: var(--navy);
  color: white;
  border-radius: 16px;
  padding: 12px 14px;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  z-index: 15;
  box-shadow: var(--shadow);
  font-size: 14px;
}

.device-bar[hidden] {
  display: none;
}

.device-bar a,
.device-bar button {
  color: white;
}

.device-bar .btn-primary {
  padding: 8px 14px;
  font-size: 14px;
  box-shadow: none;
  white-space: nowrap;
}

.device-bar p {
  margin: 0;
  color: #c5d0dd;
}

.admin-bar {
  display: flex;
  align-items: center;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  border-radius: 12px;
}

.admin-bar[hidden] {
  display: none;
}

.admin-bar .btn-service {
  border: 0;
  border-radius: 8px;
  padding: 6px 12px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

.admin-bar .btn-service.is-on {
  background: var(--green);
  color: white;
}

.admin-bar .btn-service.is-off {
  background: #d92d20;
  color: white;
}

.gate {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
}

.gate[hidden] {
  display: none;
}

.gate-card {
  max-width: 420px;
  background: white;
  border-radius: 24px;
  padding: 28px 24px;
  box-shadow: var(--shadow);
  text-align: center;
}

.gate-card h2 {
  margin: 0 0 10px;
}

.gate-card p {
  color: var(--muted);
  margin: 0;
}

.logout-link {
  margin-top: 4px;
  padding: 0;
  border: 0;
  background: none;
  color: #9aa8bd;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}

.logout-link:hover {
  color: white;
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: max(16px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom));
  background: var(--navy);
}

.auth-screen[hidden] {
  display: none;
}

.auth-card {
  width: min(420px, 100%);
  margin-block: auto;
  flex-shrink: 0;
  background: white;
  color: var(--ink);
  border-radius: 24px;
  padding: 28px 24px;
  box-shadow: var(--shadow);
}

.auth-card .brand-mark {
  margin-bottom: 12px;
}

.auth-card h1,
.auth-card h2 {
  margin: 0 0 8px;
}

.auth-card h1 {
  font-size: 28px;
  letter-spacing: -0.04em;
}

.auth-tagline,
.auth-card p {
  color: var(--muted);
  margin: 0 0 16px;
}

.auth-card form {
  display: grid;
  gap: 8px;
}

.auth-card label {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.auth-card input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 6px;
}

.auth-card .btn-primary {
  justify-content: center;
  width: 100%;
  margin: 8px 0 4px;
}

.auth-card .linkish {
  display: block;
  width: 100%;
  text-align: center;
  margin-top: 10px;
  color: var(--navy);
}

.auth-error {
  color: #d92d20;
  font-size: 14px;
  font-weight: 650;
}

.confirm-code {
  font-size: 32px;
  letter-spacing: 0.24em;
  font-weight: 800;
  text-align: center;
  padding: 12px;
  border-radius: 16px;
  background: var(--mint);
  color: var(--navy);
  margin-bottom: 10px;
}

.auth-hint {
  font-size: 13px !important;
}

body.need-auth .topbar,
body.need-auth .tabs,
body.need-auth main,
body.need-auth .btn-scan,
body.need-auth .device-bar,
body.need-auth .gate {
  display: none !important;
}

body.gated .tabs,
body.gated main,
body.gated .btn-scan,
body.gated .device-bar {
  display: none !important;
}

.mail-card {
  background: white;
  border-radius: 18px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.mail-card ol.mail-steps {
  margin: 0;
  padding-left: 1.2em;
  display: grid;
  gap: 6px;
  font-size: 14px;
  line-height: 1.4;
}

.mail-card a {
  color: #1d4ed8;
}

.mail-card form {
  display: grid;
  gap: 8px;
}

.mail-card label {
  font-size: 13px;
  font-weight: 600;
}

.mail-card input {
  border: 1px solid #d5deea;
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
}

.account-list {
  display: grid;
  gap: 12px;
}

.account-card {
  background: white;
  border-radius: 18px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
}

.account-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

@media (max-width: 760px) {
  body.is-owner .tabs {
    gap: 8px;
  }

  body.is-owner .tab {
    padding: 10px 8px;
    font-size: 13px;
  }
}
