:root {
  --surface: #ffffff;
  --surface-variant: #f5f7f0;
  --background: #eef3e8;
  --primary: #5b7241;
  --primary-variant: #465831;
  --secondary: #9c27b0;
  --text: #1f2937;
  --text-secondary: #4b5563;
  --border: rgba(91, 114, 65, 0.18);
  --shadow: 0 16px 40px rgba(16, 24, 40, 0.08);
}
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
.admin-only {
  display: none !important;
}
.admin-only.admin-visible {
  display: inline-flex !important;
}
body:not(.is-admin) .admin-dashboard-buttons,
body:not(.is-admin) .admin-only {
  display: none !important;
  visibility: hidden !important;
}
html, body {
  margin: 0;
  min-height: 100%;
}
body {
  font-family: 'Roboto', sans-serif;
  background: radial-gradient(circle at top, rgba(91, 114, 65, 0.16), transparent 25%),
              linear-gradient(180deg, #f8fbf3 0%, #eef3e8 100%);
  color: var(--text);
}
button, input, select, textarea {
  font: inherit;
}
.app-shell {
  max-width: 1040px;
  margin: 0 auto;
  padding: 1.25rem;
}
.topbar {
  padding: 1.25rem 1.5rem;
  border-radius: 24px;
  background: linear-gradient(135deg, var(--primary), #718e4f);
  color: #fff;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}
.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  min-width: 0;
}
.topbar-logo {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.16);
  flex: 0 0 auto;
}
.topbar h1 {
  font-size: 1.45rem;
  font-weight: 700;
  margin: 0;
  text-align: left;
}
.menu-toggle {
  width: 52px;
  min-width: 52px;
  min-height: 52px;
  padding: 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  box-shadow: none;
  margin-top: 0;
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.28rem;
}
.menu-toggle span {
  display: block;
  width: 100%;
  height: 3px;
  border-radius: 999px;
  background: #ffffff;
}
.mobile-menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 950;
  background: rgba(15, 23, 42, 0.42);
  opacity: 0;
  transition: opacity 0.22s ease;
}
.mobile-menu-drawer {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 960;
  width: min(86vw, 340px);
  height: 100vh;
  padding: 0.65rem 1rem 1.5rem;
  box-sizing: border-box;
  background: var(--primary-variant);
  box-shadow: 24px 0 48px rgba(15, 23, 42, 0.18);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  transform: translateX(-100%);
  transition: transform 0.26s ease;
  will-change: transform;
}
.mobile-menu-overlay.is-open {
  opacity: 1;
}
.mobile-menu-drawer.is-open {
  transform: translateX(0);
}
.mobile-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0;
}
.mobile-menu-close {
  display: inline-flex;
  align-self: center;
  align-items: center;
  justify-content: flex-end;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 0;
  background: none;
  color: #fff;
  cursor: pointer;
  line-height: 0;
  font-size: 1.9rem;
  transition: opacity 0.18s ease;
}
.mobile-menu-close i {
  display: block;
  line-height: 1;
}
.mobile-menu-close:hover,
.mobile-menu-close:focus {
  opacity: 0.8;
}
.mobile-menu-content {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  gap: 1rem;
}
.mobile-menu-actions {
  display: grid;
  align-content: start;
  gap: 0.85rem;
}
.mobile-menu-admin-actions {
  display: grid;
  gap: 0.85rem;
  align-content: start;
}
.mobile-menu-footer {
  margin-top: auto;
  padding-bottom: env(safe-area-inset-bottom, 0);
  display: grid;
  gap: 0.85rem;
}
.mobile-menu-settings-trigger {
  width: auto;
  min-width: 0;
  min-height: 0;
  justify-self: auto;
  align-self: center;
  padding: 0;
  margin-top: 0;
  border: none;
  border-radius: 0;
  background: none;
  color: #fff;
  box-shadow: none;
  font-size: 1.1rem;
}
.mobile-menu-settings-trigger:hover,
.mobile-menu-settings-trigger:focus {
  background: none;
  color: rgba(255, 255, 255, 0.82);
  transform: none;
}
.mobile-menu-identity {
  padding: 0.15rem 0;
  color: #fff;
}
.mobile-menu-identity-label {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.7);
}
.mobile-menu-identity-name {
  margin-top: 0.35rem;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.25;
}
.mobile-menu-identity-meta {
  margin-top: 0.22rem;
  font-size: 0.88rem;
  color: rgba(255, 255, 255, 0.76);
  line-height: 1.35;
}
.mobile-menu-button,
.mobile-menu-admin-actions button {
  width: 100%;
  min-height: 3rem;
  justify-content: flex-start;
  padding: 0.95rem 1.1rem;
  margin-top: 0;
  border: none;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  box-shadow: 0 12px 24px rgba(91, 114, 65, 0.18);
  font-size: 1rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
}
.mobile-menu-button i,
.mobile-menu-admin-actions button i {
  width: 1.1rem;
  margin-right: 0.75rem;
  text-align: center;
  flex: 0 0 1.1rem;
}
.mobile-menu-button:hover,
.mobile-menu-button:focus,
.mobile-menu-admin-actions button:hover,
.mobile-menu-admin-actions button:focus {
  background: rgba(255, 255, 255, 0.22);
}
#installButton {
  background: #2563eb;
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.28);
}
#installButton:hover,
#installButton:focus {
  background: #1d4ed8;
}
.card {
  /* Primary screen container used for dashboard, forms, and admin panels. */
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: 24px;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}
.card h2 {
  margin: 0 0 1rem;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
}
.dashboard-actions {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.dashboard-actions h2 {
  margin: 0;
  text-align: left;
}
.dashboard-actions button {
  margin-top: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
}
.dashboard-actions button i {
  font-size: 0.95rem;
}
#desktopScreen {
  text-align: center;
}
#desktopScreen button {
  margin-left: auto;
  margin-right: auto;
}
label {
  display: block;
  margin-top: 1rem;
  color: var(--text-secondary);
  font-size: 0.95rem;
}
.live-search {
  position: relative;
}
.live-search-results {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  right: 0;
  z-index: 30;
  display: grid;
  gap: 0;
  padding: 0.35rem 0;
  border: 1px solid rgba(91, 114, 65, 0.16);
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 18px 38px rgba(15, 23, 42, 0.12);
}
.live-search-option {
  width: 100%;
  min-height: auto;
  justify-content: flex-start;
  padding: 0.85rem 1rem;
  margin-top: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  box-shadow: none;
  font-weight: 500;
  letter-spacing: 0;
}
.live-search-option:hover,
.live-search-option:focus {
  transform: none;
  background: #edf3e7;
  color: #0f172a;
}
.live-search-empty {
  padding: 0.85rem 1rem;
  color: #64748b;
  font-size: 0.92rem;
}
.checkbox-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  gap: 0.6rem;
}
.checkbox-row input[type="checkbox"] {
  width: auto;
  margin-top: 0;
  padding: 0;
  flex: 0 0 auto;
  position: relative;
  top: 2px;
}
input,
select,
textarea {
  /* Form controls are large enough for touch use on mobile devices. */
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1rem 1.1rem;
  margin-top: 0.5rem;
  background: #fff;
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(91, 114, 65, 0.65);
  box-shadow: 0 0 0 3px rgba(91, 114, 65, 0.12);
}
input.field-invalid,
select.field-invalid,
textarea.field-invalid {
  border-color: #dc2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}
.field-error {
  display: block;
  margin-top: 0.45rem;
  color: #dc2626;
  font-size: 0.92rem;
  line-height: 1.35;
}
button {
  /* Default command button style; specialized buttons override this below. */
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  border: none;
  border-radius: 16px;
  padding: 0.95rem 1.4rem;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
  box-shadow: 0 12px 24px rgba(91, 114, 65, 0.18);
  margin-top: 1.25rem;
}
button:hover {
  transform: translateY(-1px);
  background: var(--primary-variant);
}
button.secondary-button {
  background: #f3f4f6;
  color: var(--text);
  box-shadow: none;
}
button.secondary-button:hover {
  background: #e5e7eb;
}
button.tiny-button {
  width: auto;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
}
.dashboard-buttons {
  /* Dashboard actions are stacked on phones and become a grid on wider screens. */
  display: grid;
  gap: 20px;
  grid-template-columns: 1fr;
  justify-items: center;
}
.dashboard-buttons button {
  margin-top: 0;
  width: auto;
  min-width: 0;
  max-width: 100%;
}
.dashboard-buttons.normal-user-dashboard-buttons {
  justify-items: center;
}
.admin-dashboard-buttons {
  margin-top: 20px;
}
.hidden {
  display: none !important;
}
.install-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 1100;
  transform: translate(-50%, -50%);
  min-width: min(82vw, 320px);
  max-width: min(88vw, 420px);
  padding: 1rem 1.15rem;
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.94);
  color: #fff;
  text-align: center;
  box-shadow: 0 24px 50px rgba(15, 23, 42, 0.28);
  font-size: 0.95rem;
  line-height: 1.45;
}
.camera-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.72);
}
.camera-sheet {
  width: min(100%, 420px);
  display: grid;
  gap: 1rem;
  padding: 1rem;
  border-radius: 20px;
  background: #0f172a;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35);
}
#cameraPreview {
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: 16px;
  background: #020617;
  object-fit: cover;
}
.camera-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}
.message {
  margin-top: 1rem;
  color: var(--text-secondary);
  font-size: 0.95rem;
}
.notice-banner {
  margin: 0 0 1rem;
  padding: 0.95rem 1rem;
  border: 1px solid rgba(91, 114, 65, 0.18);
  border-radius: 16px;
  background: #f4f8ee;
  color: #465831;
  font-size: 0.95rem;
  line-height: 1.45;
}
input[readonly] {
  background: #f8fafc;
}
.batch-trips-card {
  /* Framed list area used when reviewing trips inside a selected batch. */
  padding: 1rem 1.1rem;
  margin: 1rem 0 0.5rem;
  border-radius: 18px;
  background: #f8fbf4;
  border: 1px solid rgba(91, 114, 65, 0.12);
}
.batch-trips-card h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  color: #0f172a;
}
.trip-list {
  display: grid;
  gap: 0.85rem;
}
.user-table-wrapper {
  overflow-x: auto;
}
.user-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.35rem;
}
.user-table th,
.user-table td {
  padding: 0.9rem 0.85rem;
  border-bottom: 1px solid rgba(91, 114, 65, 0.14);
  text-align: left;
  vertical-align: middle;
}
.user-table th {
  color: #465831;
  font-size: 0.9rem;
  font-weight: 700;
}
.user-table td:last-child,
.user-table th:last-child {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}
.user-table-identity {
  display: grid;
  gap: 0.2rem;
}
.user-table-name {
  color: #0f172a;
  font-weight: 600;
}
.user-table-email {
  font-size: 0.86rem;
  color: rgba(70, 88, 49, 0.72);
}
.user-table .approve-user-button {
  margin-top: 0;
  min-height: 2.4rem;
  min-width: 2.4rem;
  padding: 0.65rem;
  border-radius: 14px;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.user-table .approve-user-button i {
  font-size: 1rem;
}
.trip-card {
  /* Repeated trip item shown in current-batch and batch-detail lists. */
  padding: 1rem;
  border-radius: 18px;
  background: #ffffff;
  border: 1px solid rgba(148, 163, 184, 0.18);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
}
.trip-heading {
  font-weight: 600;
  color: #1e3a8a;
  margin-bottom: 0.35rem;
}
.trip-preview {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 1rem;
  align-items: center;
}
.trip-photo-wrapper {
  width: 88px;
  height: 88px;
  border-radius: 18px;
  overflow: hidden;
  background: #edf3e7;
  display: flex;
  align-items: center;
  justify-content: center;
}
.trip-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.trip-photo-placeholder {
  color: #64748b;
  text-align: center;
  padding: 0.65rem;
  font-size: 0.85rem;
}
.trip-info {
  display: grid;
  gap: 0.35rem;
}
.trip-meta {
  color: #475569;
  font-size: 0.95rem;
}
.trip-coordinates {
  margin-top: 0.85rem;
  color: #334155;
  font-size: 0.95rem;
}
.trip-detail {
  margin-top: 0.45rem;
  color: #334155;
  font-size: 0.95rem;
}
.trip-detail strong {
  color: #0f172a;
}
.signature-pad {
  /* Canvas-based signature capture section for batch approvals. */
  display: grid;
  gap: 0.75rem;
  margin-top: 0.75rem;
}
#signatureCanvas {
  width: 100%;
  max-width: 100%;
  height: 180px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 18px;
  background: #f8fafc;
  touch-action: none;
}
#signatureCanvas.field-invalid {
  border-color: #dc2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}
.signature-note {
  color: #475569;
  font-size: 0.95rem;
}
@media (display-mode: standalone) {
  /* Installed PWAs should never keep showing the browser install prompt. */
  #installButton {
    display: none !important;
  }
}
@media (max-width: 720px) {
  /* Trip image previews stack on narrow phones. */
  .trip-preview {
    grid-template-columns: 1fr;
  }
}
@media (min-width: 860px) {
  /* Constrain the whole desktop app shell to the card width so header/body/footer align. */
  .app-shell {
    max-width: 640px;
  }
  main {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  .card {
    width: 100%;
    max-width: none;
  }
}
