:root {
  /* 75% Deep Matte Black Surfaces */
  --bg-primary: #09090b;
  --bg-card: #111114;
  --bg-elevated: #18181d;
  --border: #23232a;
  --border-strong: #32323c;

  /* 15% Crisp White & High-Contrast Neutrals */
  --white: #ffffff;
  --text-main: #f4f4f6;
  --text-muted: #8e8e98;

  /* 10% Functional Status Accents */
  --accent: #ffffff;
  --accent-hover: #e4e4e7;
  --cyan: #38bdf8;
  --cyan-dim: rgba(56, 189, 248, 0.14);
  --emerald: #22c55e;
  --emerald-dim: rgba(34, 197, 94, 0.14);
  --crimson: #ef4444;
  --crimson-dim: rgba(239, 68, 68, 0.14);
  --amber: #f59e0b;
  --amber-dim: rgba(245, 158, 11, 0.14);

  --radius: 10px;
  --radius-sm: 7px;
  --ease: cubic-bezier(0.2, 0, 0, 1);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  color-scheme: dark;
}

body {
  background: var(--bg-primary);
  color: var(--text-main);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--white);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h2 {
  font-size: 1.25rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.3;
  color: var(--white);
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.84em;
  background: var(--bg-elevated);
  color: var(--white);
  border: 1px solid var(--border);
  padding: 0.1rem 0.4rem;
  border-radius: 5px;
}

:focus-visible {
  outline: 2px solid var(--white);
  outline-offset: 2px;
}

/* Minimal Top Bar */
.topbar {
  background: rgba(9, 9, 11, 0.9);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--white);
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--white);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.88rem;
}

.nav-user {
  color: var(--text-muted);
}

.container {
  width: 100%;
  max-width: 1260px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 3rem;
  flex: 1;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.site-footer {
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
  text-align: center;
  padding: 1rem;
}

.mobile-bottom-nav {
  display: none;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 1.25rem;
  align-items: start;
}

.grid-equal {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 920px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 0.98rem;
  font-weight: 650;
  color: var(--white);
}

label {
  display: block;
  font-size: 0.83rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  margin-top: 0.9rem;
}

input, select, textarea {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--white);
  padding: 0.62rem 0.8rem;
  border-radius: var(--radius-sm);
  font: inherit;
  transition: border-color 0.15s var(--ease), background-color 0.15s var(--ease);
}

input::placeholder, textarea::placeholder {
  color: #646470;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--white);
  background: #1e1e24;
}

textarea {
  resize: vertical;
}

/* Crisp White Primary & Dark Secondary Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.05rem;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.2;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease), transform 0.1s var(--ease);
}

.btn:hover {
  text-decoration: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-cyan {
  background: var(--white);
  color: #09090b;
}

.btn-cyan:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-emerald {
  background: var(--emerald);
  color: #052e16;
}

.btn-emerald:hover:not(:disabled) {
  background: #16a34a;
  color: var(--white);
}

.btn-crimson {
  background: var(--bg-elevated);
  border-color: rgba(239, 68, 68, 0.35);
  color: var(--crimson);
}

.btn-crimson:hover:not(:disabled) {
  background: var(--crimson-dim);
}

.btn-ghost {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
  color: var(--text-main);
}

.btn-ghost:hover:not(:disabled) {
  background: #24242c;
  border-color: #484856;
}

.btn-sm {
  padding: 0.38rem 0.72rem;
  font-size: 0.8rem;
}

.badge {
  display: inline-block;
  padding: 0.16rem 0.58rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}

.badge-cyan { background: rgba(255, 255, 255, 0.12); color: var(--white); }
.badge-emerald { background: var(--emerald-dim); color: var(--emerald); }
.badge-crimson { background: var(--crimson-dim); color: var(--crimson); }
.badge-amber { background: var(--amber-dim); color: var(--amber); }
.badge-muted { background: var(--bg-elevated); color: var(--text-muted); border: 1px solid var(--border); }

button.badge {
  border: 1px solid var(--border-strong);
  font-family: inherit;
  cursor: pointer;
  transition: background-color 0.15s var(--ease);
}

button.badge-cyan:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th, td {
  text-align: left;
  padding: 0.7rem 0.6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bg-primary);
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr {
  transition: background-color 0.12s var(--ease);
}

tbody tr:hover {
  background: #16161b;
}

.thumb {
  width: 56px;
  height: 44px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  display: block;
}

/* Flash & Status Pills */
.flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.25rem;
  font-size: 0.88rem;
  border: 1px solid;
  transition: opacity 0.3s var(--ease);
}

.flash.hide {
  opacity: 0;
}

.flash-success { background: var(--emerald-dim); border-color: rgba(34, 197, 94, 0.35); color: #86efac; }
.flash-error { background: var(--crimson-dim); border-color: rgba(239, 68, 68, 0.35); color: #fca5a5; }

.keypad-pill {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  padding: 0.28rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--text-main);
}

/* Modals & Toasts */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal-backdrop.active {
  display: flex;
  animation: fade-in 0.18s var(--ease);
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-top: 3px solid var(--emerald);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.75);
  border-radius: var(--radius);
  max-width: 540px;
  width: 100%;
  padding: 1.5rem;
}

.modal-backdrop.active .modal-card {
  animation: rise-in 0.22s var(--ease);
}

.toast-alert {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  max-width: 360px;
  background: var(--bg-card);
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-left: 4px solid var(--crimson);
  color: #fca5a5;
  padding: 0.85rem 1.05rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  z-index: 110;
  display: none;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.65);
}

.toast-alert.active {
  display: block;
  animation: rise-in 0.22s var(--ease);
}

/* PIN Pill */
.pin-box {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--white);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  padding: 0.18rem 0.6rem;
  border-radius: var(--radius-sm);
}

/* Camera Viewfinder & Lightbox */
.viewfinder-box {
  position: relative;
  background: #050507;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  min-height: 210px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.85rem;
}

.viewfinder-box img {
  width: 100%;
  max-height: 290px;
  object-fit: contain;
  display: block;
}

.live-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: var(--crimson);
  color: var(--white);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
}

.zoomable-img {
  cursor: zoom-in;
  transition: border-color 0.15s var(--ease);
}

.zoomable-img:hover {
  border-color: var(--white);
}

.lightbox-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.94);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1.25rem;
}

.lightbox-backdrop.active {
  display: flex;
  animation: fade-in 0.18s var(--ease);
}

.lightbox-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  color: var(--text-main);
  font-size: 0.88rem;
}

.lightbox-scroll {
  max-width: 94vw;
  max-height: 82vh;
  overflow: auto;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: #000;
}

.lightbox-img {
  display: block;
  max-width: 90vw;
  max-height: 80vh;
  object-fit: contain;
  cursor: zoom-in;
}

.lightbox-img.zoomed {
  max-width: none;
  max-height: none;
  width: 1650px;
  cursor: zoom-out;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* Layout & Helper Utilities */
.narrow { max-width: 390px; margin: 3.5rem auto; }
.narrow-md { max-width: 480px; margin: 2rem auto; }
.narrow-sm { max-width: 460px; margin: 3rem auto; }
.text-center { text-align: center; }
.muted { color: var(--text-muted); }
.small { font-size: 0.85rem; }
.xs { font-size: 0.78rem; }
.title-ok { color: var(--emerald); margin-bottom: 0.75rem; }
.title-err { color: var(--crimson); margin-bottom: 0.75rem; }
.lead { color: var(--text-muted); margin-bottom: 1.25rem; }
.lead-sm { font-size: 0.88rem; color: var(--text-muted); margin-bottom: 0.75rem; }
.btn-block { width: 100%; margin-top: 1.25rem; }
.btn-top { margin-top: 0.9rem; }
.row { display: flex; align-items: center; gap: 0.5rem; }
.row-wrap { flex-wrap: wrap; }
.field-row { display: flex; gap: 0.5rem; }
.grow-1 { flex: 1; }
.grow-2 { flex: 2; }
.grow-14 { flex: 1.4; }
.inline-form { margin: 0; }
.empty { color: var(--text-muted); font-size: 0.88rem; }
.help { font-size: 0.83rem; color: var(--text-muted); margin-bottom: 0.25rem; transition: color 0.15s var(--ease); }
.help.is-active { color: var(--white); }
.help.is-ok { color: var(--emerald); }

/* Minimal Collapsible Login Hint */
.dev-hint {
  margin-top: 1.1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.dev-hint summary {
  cursor: pointer;
  user-select: none;
  color: var(--text-muted);
}

.dev-hint summary:hover {
  color: var(--white);
}

.dev-hint-body {
  margin-top: 0.55rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.chip-group { margin-bottom: 1rem; }
.chip-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; margin-bottom: 0.35rem; }
.preauth-chip { margin: 2px; }
.quick-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.quick-row .btn { padding: 0.22rem 0.62rem; font-size: 0.76rem; }
.check-row { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.75rem; font-weight: 400; color: var(--text-main); cursor: pointer; }
.check-row input { width: auto; }
.capture-btn { margin-top: 0.75rem; }
.sleep-overlay { text-align: center; padding: 1.25rem; color: var(--text-muted); font-size: 0.86rem; }
.sleep-overlay p { margin-bottom: 0.6rem; }
.preview { margin-top: 0.9rem; background: var(--bg-primary); padding: 0.85rem; border-radius: var(--radius-sm); border: 1px solid rgba(34, 197, 94, 0.35); }
.preview-note { font-size: 0.82rem; color: var(--emerald); font-weight: 600; margin-bottom: 0.5rem; }
.preview-img { width: 100%; max-height: 300px; object-fit: contain; border-radius: 6px; border: 1px solid var(--border); margin-bottom: 0.7rem; display: block; }
.log-list { margin-top: 0.9rem; }
.log-item { padding: 0.6rem 0; border-top: 1px solid var(--border); font-size: 0.86rem; }
.log-meta { color: var(--text-muted); font-size: 0.78rem; }
.log-note { margin-top: 2px; }
.sub { color: var(--text-muted); font-size: 0.78rem; }
.parcel-item { display: flex; align-items: center; gap: 12px; background: var(--bg-primary); border: 1px solid var(--border); padding: 0.85rem; border-radius: var(--radius-sm); margin-bottom: 0.75rem; }
.parcel-photo { width: 88px; height: 68px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border-strong); flex-shrink: 0; }
.parcel-info { flex: 1; min-width: 0; }
.parcel-courier { font-weight: 650; color: var(--white); }
.parcel-time { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 6px; }
.visitor-item { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.7rem 0; border-bottom: 1px solid var(--border); }
.visitor-item:last-child { border-bottom: none; }
.btn-group { display: flex; gap: 6px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.modal-title { color: var(--emerald); margin-top: 0.35rem; }
.modal-confirm { width: 100%; margin-top: 1rem; padding: 0.8rem; font-size: 0.95rem; }
.page-head h2 { margin: 0; }

@media (max-width: 480px) {
  .parcel-item { flex-wrap: wrap; }
  .parcel-info { flex-basis: 60%; }
}

.app-splash {
  display: none;
}