/**
 * Mobile-Optimized App CSS
 */

/* Base Styles */
:root {
  --brand-primary: #0ea5e9;
  --brand-primary-light: #38bdf8;
  --brand-primary-dark: #0284c7;
  --brand-on-primary: #ffffff;
  --brand-primary-rgb: 14, 165, 233;
  --brand-primary-light-rgb: 56, 189, 248;
}

* {
  box-sizing: border-box;
}

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, Arial, sans-serif;
  background: #0f172a;
  color: #e5e7eb;
  margin: 0;
  min-height: 100vh;
  position: relative;
}

/* Add subtle animated background gradient */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: 
    radial-gradient(circle at 10% 20%, rgba(var(--brand-primary-light-rgb), 0.08), transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(139, 92, 246, 0.06), transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(59, 130, 246, 0.04), transparent 60%);
  pointer-events: none;
  z-index: -1;
  animation: gentle-pulse 15s ease-in-out infinite;
}

@keyframes gentle-pulse {
  0%, 100% {
    opacity: 0.6;
  }
  50% {
    opacity: 0.9;
  }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px; /* Touch-friendly */
  min-width: 44px;
  padding: 12px 16px;
  border: 1px solid #1f2937;
  border-radius: 8px;
  background: #111827;
  color: #e5e7eb;
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), transparent);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.btn:hover::before {
  opacity: 1;
}

.btn:hover, .btn:active {
  background: #1f2937;
  border-color: #374151;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.btn:active {
  transform: translateY(0);
}

.btn-secondary {
  background: #1f2937;
  border-color: #1f2937;
}

.btn-secondary:hover,
.btn-secondary:active {
  background: #374151;
  border-color: #475569;
}

.btn-primary {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  border-color: #2563eb;
  color: #fff;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
}

.btn-primary:hover,
.btn-primary:active {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  border-color: #1d4ed8;
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
}

.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  border-color: #059669;
  color: #fff;
  box-shadow: 0 4px 14px rgba(5, 150, 105, 0.4);
}

.btn-success:hover,
.btn-success:active {
  background: linear-gradient(135deg, #059669, #047857);
  border-color: #047857;
  box-shadow: 0 6px 20px rgba(5, 150, 105, 0.5);
}

.btn-danger {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
}

.btn-danger:hover,
.btn-danger:active {
  background: #b91c1c;
  border-color: #b91c1c;
}

.btn-ghost {
  background: rgba(148, 163, 184, 0.18);
  border-color: rgba(148, 163, 184, 0.32);
  color: #e5e7eb;
}

.btn-ghost:hover,
.btn-ghost:active {
  background: rgba(148, 163, 184, 0.28);
  border-color: rgba(148, 163, 184, 0.45);
}

.btn-small {
  min-height: 36px;
  padding: 8px 12px;
  font-size: 14px;
}

.btn-accent {
  background: linear-gradient(135deg, var(--brand-primary-light), var(--brand-primary));
  border-color: var(--brand-primary);
  color: var(--brand-on-primary);
  box-shadow: 0 4px 14px rgba(var(--brand-primary-rgb), 0.4);
}

.btn-accent:hover, .btn-accent:active {
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-primary-dark));
  border-color: var(--brand-primary-dark);
  box-shadow: 0 6px 20px rgba(var(--brand-primary-rgb), 0.5);
}

/* Landing page layout (index.php) */
.page-shell {
  width: min(1200px, 100%);
  margin: 0 auto;
  padding: clamp(20px, 4vw, 48px) clamp(18px, 5vw, 56px);
  display: flex;
  flex-direction: column;
  gap: clamp(32px, 5vw, 56px);
}

.hero-banner {
  position: relative;
  overflow: hidden;
  border-radius: 24px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: radial-gradient(circle at top left, rgba(var(--brand-primary-light-rgb), 0.28), transparent 58%),
              radial-gradient(circle at bottom right, rgba(59, 130, 246, 0.28), transparent 60%),
              radial-gradient(circle at center, rgba(139, 92, 246, 0.15), transparent 65%),
              linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(15, 23, 42, 0.8));
  padding: clamp(28px, 5vw, 60px);
  display: grid;
  gap: clamp(24px, 4vw, 40px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hero-banner:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(var(--brand-primary-light-rgb), 0.15);
}

.hero-banner::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 80% 20%, rgba(var(--brand-primary-light-rgb), 0.2), transparent 52%),
              radial-gradient(circle at 20% 80%, rgba(139, 92, 246, 0.15), transparent 55%);
  pointer-events: none;
  opacity: 0.8;
  animation: pulse-glow 4s ease-in-out infinite;
}

.hero-banner__body {
  position: relative;
  z-index: 1;
  display: grid;
  gap: clamp(16px, 3vw, 24px);
}

.hero-kicker {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 13px;
  font-weight: 600;
  color: var(--brand-primary-light);
}

.hero-banner__body h1 {
  font-size: clamp(40px, 5vw, 64px);
  margin: 0;
  line-height: 1.03;
}

.hero-lead {
  margin: 0;
  max-width: 620px;
  color: rgba(226, 232, 240, 0.92);
  font-size: clamp(18px, 2.4vw, 22px);
  line-height: 1.5;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.hero-actions--secondary {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}

.hero-user {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 12px 16px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.12);
  color: #e0f2fe;
  font-size: 14px;
}

.hero-stats {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: clamp(12px, 3vw, 20px);
  list-style: none;
  padding: 0;
  margin: 0;
}

.hero-stat {
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 18px;
  padding: clamp(16px, 3vw, 24px);
  display: grid;
  gap: 8px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: default;
}

.hero-stat:hover {
  transform: translateY(-4px) scale(1.02);
  border-color: rgba(var(--brand-primary-light-rgb), 0.35);
  box-shadow: 0 8px 20px rgba(var(--brand-primary-light-rgb), 0.15);
  background: rgba(15, 23, 42, 0.88);
}

.hero-stat__label {
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.14em;
  color: rgba(148, 163, 184, 0.8);
}

.hero-stat__value {
  font-size: clamp(28px, 3.5vw, 40px);
  font-weight: 700;
  color: #f8fafc;
}

.hero-stat__delta {
  font-size: 14px;
  color: rgba(203, 213, 225, 0.85);
}

.content-grid {
  display: grid;
  gap: clamp(24px, 4vw, 36px);
}

.panel {
  background: rgba(15, 23, 42, 0.95);
  border-radius: 24px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  padding: clamp(24px, 4vw, 40px);
  display: grid;
  gap: clamp(16px, 3vw, 24px);
  position: relative;
  overflow: hidden;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease, border-color 0.3s ease;
}

.panel:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.3);
  border-color: rgba(148, 163, 184, 0.24);
}

.panel--info {
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.92), rgba(30, 41, 59, 0.9));
}

.panel__header {
  display: grid;
  gap: 8px;
}

.panel__eyebrow {
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.16em;
  color: rgba(148, 163, 184, 0.8);
}

.panel__lead {
  color: rgba(203, 213, 225, 0.9);
  max-width: 640px;
}

.panel__body--grid {
  display: grid;
  gap: 16px;
}

.status-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(520px, 100%);
}

.status-form input[type="email"] {
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: rgba(15, 23, 42, 0.8);
  color: #e5e7eb;
  font-size: 16px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.status-form input[type="email"]:focus {
  border-color: var(--brand-primary-light);
  background: rgba(15, 23, 42, 0.95);
  box-shadow: 0 0 0 3px rgba(var(--brand-primary-light-rgb), 0.1);
  outline: none;
}

.status-form input[type="email"]:hover {
  border-color: rgba(148, 163, 184, 0.35);
}

.status-form input[type="email"]:focus {
  outline: 2px solid rgba(var(--brand-primary-rgb), 0.65);
  outline-offset: 2px;
  border-color: rgba(var(--brand-primary-rgb), 0.4);
}

.permit-stack {
  display: grid;
  gap: 18px;
}

.status-card,
.recent-card {
  background: rgba(15, 23, 42, 0.9);
  border-radius: 20px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  padding: clamp(18px, 3vw, 24px);
  display: grid;
  gap: 14px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.status-card:hover,
.recent-card:hover {
  transform: translateY(-4px);
  border-color: rgba(var(--brand-primary-light-rgb), 0.3);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3), 0 0 30px rgba(var(--brand-primary-light-rgb), 0.1);
  background: rgba(15, 23, 42, 0.95);
}

.status-card__header,
.recent-card__header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
}

.status-card__title,
.recent-card__title {
  display: block;
  font-size: 20px;
  font-weight: 600;
  color: #f8fafc;
}

.status-card__meta,
.recent-card__meta {
  font-size: 14px;
  color: rgba(148, 163, 184, 0.85);
}

.status-card__details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.status-card__details dt {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(148, 163, 184, 0.8);
  margin-bottom: 4px;
}

.status-card__details dd {
  margin: 0;
  font-size: 15px;
  color: rgba(226, 232, 240, 0.92);
}

.status-card__note {
  margin: 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(59, 130, 246, 0.14);
  color: #bfdbfe;
  font-size: 14px;
}

.status-card__actions,
.recent-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status-card__actions .btn,
.recent-card__actions .btn {
  min-width: 110px;
}

.recent-card__line {
  margin: 0;
  font-size: 15px;
  color: rgba(226, 232, 240, 0.92);
}

.card-carousel {
  display: grid;
  gap: 16px;
}

@media (min-width: 768px) {
  .card-carousel {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(260px, 1fr);
    overflow-x: auto;
    padding-bottom: 8px;
    scroll-snap-type: x mandatory;
  }

  .card-carousel > * {
    scroll-snap-align: start;
  }
}

.card-carousel {
  position: relative;
}

.card-carousel::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 64px;
  pointer-events: none;
  background: linear-gradient(270deg, rgba(15, 23, 42, 0.92), transparent);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.card-carousel[data-overflow="1"]::after {
  opacity: 1;
}

.card-carousel::-webkit-scrollbar {
  height: 6px;
}

.card-carousel::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.35);
  border-radius: 999px;
}

.template-gallery {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.template-tile {
  display: grid;
  gap: 10px;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(15, 23, 42, 0.88);
  color: inherit;
  text-decoration: none;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.template-tile:hover {
  transform: translateY(-4px);
  border-color: rgba(var(--brand-primary-light-rgb), 0.45);
  background: rgba(15, 23, 42, 0.94);
}

.template-tile__icon {
  font-size: 28px;
}

.template-tile__name {
  font-size: 18px;
  font-weight: 600;
  color: #f8fafc;
}

.template-tile__meta {
  font-size: 14px;
  color: rgba(148, 163, 184, 0.85);
}

.template-tile__cta {
  font-size: 14px;
  color: var(--brand-primary-light);
}

.info-card {
  padding: 20px;
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(15, 23, 42, 0.85);
}

.info-card h3 {
  margin-top: 0;
  margin-bottom: 8px;
  font-size: 18px;
}

.info-card p {
  margin: 0;
  color: rgba(203, 213, 225, 0.9);
}

.empty-panel {
  padding: clamp(24px, 4vw, 36px);
  border-radius: 20px;
  border: 1px dashed rgba(148, 163, 184, 0.35);
  text-align: center;
  display: grid;
  gap: 12px;
  justify-items: center;
  background: rgba(15, 23, 42, 0.78);
}

/* ==================== Animations & Keyframes ==================== */

@keyframes pulse-glow {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(var(--brand-primary-light-rgb), 0.4);
  }
  50% {
    box-shadow: 0 0 20px 8px rgba(var(--brand-primary-light-rgb), 0.15);
  }
}

@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

.animate-on-load {
  animation: slide-up 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.fade-in {
  animation: fade-in 0.4s ease-out;
}

/* Add staggered animation delays for child elements */
.hero-stats .hero-stat:nth-child(1) { animation-delay: 0.1s; }
.hero-stats .hero-stat:nth-child(2) { animation-delay: 0.2s; }
.hero-stats .hero-stat:nth-child(3) { animation-delay: 0.3s; }
.hero-stats .hero-stat:nth-child(4) { animation-delay: 0.4s; }

/* Improved focus states for accessibility */
.btn:focus-visible {
  outline: 2px solid var(--brand-primary-light);
  outline-offset: 2px;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--brand-primary-light);
  outline-offset: 2px;
  border-color: var(--brand-primary-light);
}

/* Loading skeleton animation */
.skeleton {
  background: linear-gradient(90deg, #1f2937 25%, #374151 50%, #1f2937 75%);
  background-size: 1000px 100%;
  animation: shimmer 2s infinite linear;
  border-radius: 8px;
}

.empty-panel__icon {
  font-size: 32px;
}

.empty-panel h3 {
  margin: 0;
  font-size: 20px;
}

.empty-panel p {
  margin: 0;
  color: rgba(203, 213, 225, 0.88);
}

.page-footer {
  text-align: center;
  color: rgba(148, 163, 184, 0.85);
  padding-bottom: 24px;
  font-size: 14px;
}

.permit-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(24px, 5vw, 60px);
  z-index: 1200;
}

.permit-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.58);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.permit-modal__dialog {
  position: relative;
  width: min(640px, 100%);
  max-height: min(540px, 100%);
  background: rgba(15, 23, 42, 0.98);
  border-radius: 28px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.5);
  transform: translateY(24px) scale(0.96);
  opacity: 0;
  transition: transform 0.24s ease, opacity 0.24s ease;
}

.permit-modal[data-open="1"] .permit-modal__dialog {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.permit-modal[data-open="1"] .permit-modal__backdrop {
  opacity: 1;
}

.permit-modal__header {
  padding: clamp(22px, 3vw, 32px);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}

.permit-modal__header h3 {
  margin: 4px 0 0;
}

.permit-modal__eyebrow {
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.18em;
  color: rgba(148, 163, 184, 0.75);
}

.permit-modal__body {
  padding: clamp(18px, 3vw, 28px);
  display: grid;
  gap: 12px;
  overflow-y: auto;
}

.permit-modal__link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  text-decoration: none;
  color: inherit;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.permit-modal__link:hover {
  transform: translateX(6px);
  border-color: rgba(var(--brand-primary-light-rgb), 0.45);
  background: rgba(15, 23, 42, 0.92);
}

.permit-modal__icon {
  font-size: 26px;
}

@media (max-width: 768px) {
  .page-shell {
    padding: 24px 16px 32px;
    gap: 32px;
  }

  .hero-banner {
    border-radius: 20px;
  }

  .hero-actions,
  .hero-actions--secondary {
    flex-direction: column;
    align-items: stretch;
  }

  .hero-actions .btn,
  .hero-actions--secondary .btn {
    width: 100%;
  }

  .panel {
    border-radius: 20px;
  }

  .status-card,
  .recent-card {
    border-radius: 18px;
  }

  .permit-modal {
    align-items: flex-end;
    padding: 0;
  }

  .permit-modal__dialog {
    width: 100%;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    max-height: 80vh;
  }
}

/* Wrap / Container */
.wrap {
  max-width: 100%;
  margin: 0 auto;
  padding: 12px;
}

/* Desktop: increase max-width and padding */
@media (min-width: 768px) {
  .wrap {
    max-width: 1100px;
    padding: 24px;
  }
}

/* Card/Section */
.card {
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover {
  border-color: #374151;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  transform: translateY(-2px);
}

.card summary {
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
  font-size: 17px;
  font-weight: 600;
  list-style: none; /* Hide default arrow */
}

.card summary::-webkit-details-marker {
  display: none;
}

.card summary::before {
  content: '▼ ';
  display: inline-block;
  transition: transform 0.2s;
  margin-right: 8px;
}

.card[open] summary::before {
  transform: rotate(0deg);
}

.card:not([open]) summary::before {
  transform: rotate(-90deg);
}

.card strong.cp {
  font-size: 17px;
}

/* Meta Section - Form Fields */
.meta {
  display: grid;
  grid-template-columns: 1fr; /* Single column on mobile */
  gap: 12px;
  margin-bottom: 16px;
}

/* 2 columns on tablets */
@media (min-width: 640px) {
  .meta {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* 4 columns on desktop */
@media (min-width: 1024px) {
  .meta {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Form Fields */
.field {
  display: flex;
  flex-direction: column;
}

.field label {
  font-size: 13px;
  color: #94a3b8;
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
}

.field .required {
  color: #f87171;
  margin-left: 4px;
  font-weight: 600;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 44px; /* Touch-friendly */
  background: #0a101a;
  color: #e5e7eb;
  border: 1px solid #1f2937;
  border-radius: 10px;
  padding: 12px;
  font-size: 16px; /* Prevent zoom on iOS */
  font-family: inherit;
}

.field textarea {
  min-height: 80px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--brand-primary-light);
  box-shadow: 0 0 0 3px rgba(var(--brand-primary-light-rgb), 0.12);
  transform: translateY(-1px);
}

.field input:hover,
.field select:hover,
.field textarea:hover {
  border-color: #374151;
}

.field-description {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 6px;
  display: block;
}

/* Checklist Items */
.items {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 0;
}

.item {
  border: 1px dashed #1f2937;
  border-radius: 12px;
  padding: 12px;
  background: #0a101a;
}

.row {
  display: grid;
  grid-template-columns: 32px 1fr; /* Checkbox + text on mobile */
  gap: 12px;
  align-items: start;
  margin-bottom: 8px;
}

.row input[type="checkbox"] {
  width: 24px;
  height: 24px;
  margin-top: 2px;
  cursor: pointer;
}

.label-text {
  font-size: 15px;
  line-height: 1.5;
  word-break: break-word;
}

/* Status Pills */
.status {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.pill {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  border: 1px solid #1f2937;
  background: #0a101a;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 14px;
  min-height: 40px; /* Touch-friendly */
  cursor: pointer;
  transition: all 0.2s;
}

.pill:has(input:checked) {
  background: #1f2937;
  border-color: #374151;
}

.pill input[type="radio"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  margin: 0;
}

/* Desktop: row layout */
@media (min-width: 640px) {
  .row {
    grid-template-columns: 32px 1fr auto;
    align-items: center;
  }
  
  .status {
    margin-top: 0;
  }
}

/* Notes */
.note {
  margin-top: 8px;
}

.note textarea {
  width: 100%;
  min-height: 60px;
  background: #111827;
  color: #e5e7eb;
  border: 1px solid #1f2937;
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}

.note textarea:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(var(--brand-primary-rgb), 0.1);
}

/* Signatures */
.sig-wrap {
  margin-top: 16px;
}

.sig {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sigtitle {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}

.siggrid {
  display: grid;
  grid-template-columns: 1fr; /* Single column on mobile */
  gap: 16px;
}

/* 2 columns on tablet and up */
@media (min-width: 640px) {
  .siggrid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.sigbox {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sigbox .sigtitle {
  font-size: 14px;
  color: #94a3b8;
  margin-bottom: 4px;
}

.sig canvas {
  width: 100%;
  height: 200px; /* Taller for mobile */
  background: #fff;
  border: 2px solid #1f2937;
  border-radius: 8px;
  cursor: crosshair;
  touch-action: none; /* Prevent scroll while signing */
}

.rowish {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.muted {
  font-size: 13px;
  color: #6b7280;
}

/* Tools / Action Buttons */
.tools {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  padding: 16px 0;
  position: sticky;
  bottom: 0;
  background: #0b1220;
  border-top: 1px solid #1f2937;
  margin-left: -12px;
  margin-right: -12px;
  padding-left: 12px;
  padding-right: 12px;
  z-index: 50;
}

.tools .btn {
  flex: 1;
  min-height: 52px; /* Extra touch-friendly */
  font-size: 17px;
  font-weight: 600;
}

/* Table */
.grid {
  display: grid;
  grid-template-columns: 1fr; /* Single column on mobile */
  gap: 12px;
  padding: 12px 0;
}

@media (min-width: 640px) {
  .grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.tbl th,
.tbl td {
  border: 1px solid #1f2937;
  padding: 8px;
  text-align: left;
}

.tbl th {
  background: #111827;
  font-weight: 600;
}

/* Responsive table on small screens */
@media (max-width: 639px) {
  .tbl {
    font-size: 13px;
  }
  
  .tbl th,
  .tbl td {
    padding: 6px;
  }
}

/* Print Styles */
@media print {
  html, body {
    background: #fff !important;
    color: #111 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    font-size: 12px;
  }
  
  .page-head,
  .top,
  .btn,
  .tools {
    display: none !important;
  }
  
  .wrap {
    padding: 0;
  }
  
  .card,
  .item,
  .field,
  .tbl th,
  .tbl td {
    background: #fff !important;
    border-color: #bbb !important;
  }
  
  .row {
    grid-template-columns: 18px 1fr auto !important;
  }
  
  .label-text,
  th,
  td,
  textarea {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    word-break: break-word !important;
    hyphens: auto !important;
  }

  .card.highlight {
    background: #1e293b;
    border-color: #334155;
  }
  
  .sig canvas {
    background: #fff !important;
    border: 1px solid #bbb !important;
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Dark mode support (already dark, but good practice) */
@media (prefers-color-scheme: dark) {
  body {
    background: #0b1220;
    color: #e5e7eb;
  }
}

/* -------------------------------------------------------------------------- */
/*  Shared Admin Theme                                                         */
/* -------------------------------------------------------------------------- */

.site-header {
  background: #1e293b;
  border-bottom: 1px solid #334155;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-header__title {
  font-size: 22px;
  font-weight: 600;
  color: #e5e7eb;
  display: flex;
  align-items: center;
  gap: 8px;
}

.site-header__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.top {
  background: #111827;
  border-bottom: 1px solid #1f2937;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.top-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark > div {
  min-width: 0;
}

.brand-mark__logo {
  width: 52px;
  height: 52px;
  object-fit: contain;
  border-radius: 14px;
  background: #0b1220;
  border: 1px solid rgba(var(--brand-primary-rgb), 0.35);
  padding: 8px;
}

.brand-mark__name {
  font-size: 20px;
  font-weight: 600;
  color: #e5e7eb;
  overflow-wrap: anywhere;
}

.brand-mark:focus-within .brand-mark__logo,
.brand-mark:hover .brand-mark__logo {
  border-color: var(--brand-primary);
}

.brand-mark__sub {
  font-size: 13px;
  color: #94a3b8;
}

.site-header__actions .user-info {
  color: #94a3b8;
  font-size: 14px;
  margin-right: 8px;
}

.site-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
  width: 100%;
}

@media (max-width: 640px) {
  .site-container {
    padding: 16px;
  }
}

.hero-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
}

.hero-card h2 {
  margin: 0 0 8px;
  font-size: 24px;
  color: #e5e7eb;
}

.hero-card p {
  margin: 0;
  color: #94a3b8;
  font-size: 15px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: #3b82f6;
}

.stat-card .icon {
  font-size: 34px;
  margin-bottom: 12px;
}

.stat-card .value {
  font-size: 32px;
  font-weight: 700;
  color: #e5e7eb;
  margin-bottom: 6px;
}

.stat-card .label {
  color: #94a3b8;
  text-transform: uppercase;
  font-size: 13px;
  letter-spacing: 0.6px;
}

.admin-grid,
.surface-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

/* Tighter cards on very small screens to avoid horizontal scroll */
@media (max-width: 480px) {
  .surface-grid { grid-template-columns: 1fr; }
}

.admin-card,
.surface-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 24px;
  transition: transform 0.2s ease, border-color 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.admin-card:hover,
.surface-card:hover {
  transform: translateY(-2px);
  border-color: #3b82f6;
}

.admin-card .icon,
.surface-card .icon {
  font-size: 42px;
  opacity: 0.85;
}

.admin-card h3,
.surface-card h3 {
  margin: 0;
  font-size: 20px;
  color: #e5e7eb;
}

.admin-card p,
.surface-card p {
  margin: 0;
  color: #94a3b8;
  font-size: 14px;
  line-height: 1.6;
  flex: 1;
}

.surface-card .meta {
  font-size: 13px;
  color: #94a3b8;
}

.template-card {
  background: linear-gradient(135deg, #1e293b 0%, #1a2332 100%);
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  color: inherit;
  display: block;
  position: relative;
  overflow: hidden;
}

.template-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(59, 130, 246, 0.15), transparent 70%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.template-card:hover::before {
  opacity: 1;
}

.template-card:hover {
  transform: translateY(-6px) scale(1.02);
  border-color: #3b82f6;
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.2), 0 16px 48px rgba(0, 0, 0, 0.3);
}

.template-card .icon {
  font-size: 48px;
  margin-bottom: 12px;
  display: block;
}

.template-card .name {
  font-size: 16px;
  font-weight: 600;
  color: #e5e7eb;
  margin-bottom: 4px;
}

.template-card .version {
  font-size: 12px;
  color: #94a3b8;
}

.alert {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 20px;
}

.alert-success {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #bbf7d0;
}

.alert-error {
  background: rgba(220, 38, 38, 0.12);
  border: 1px solid rgba(220, 38, 38, 0.35);
  color: #fecaca;
}

.toast {
  position: fixed;
  top: 24px;
  right: 24px;
  background: #111827;
  border: 1px solid #1f2937;
  color: #e5e7eb;
  padding: 14px 18px;
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.35);
  z-index: 1500;
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.toast.success {
  border-left: 4px solid #16a34a;
}

.toast.error {
  border-left: 4px solid #dc2626;
}

.tab-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

@media (max-width: 640px) {
  .tab-actions {
    gap: 8px;
  }
  .tab-actions .btn {
    font-size: 14px;
    padding: 8px 12px;
    white-space: nowrap;
  }
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  border-radius: 12px;
  overflow: hidden;
  background: #111827;
  border: 1px solid #1f2937;
}

.data-table thead {
  background: #1e293b;
}

.data-table th,
.data-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid #1f2937;
  font-size: 14px;
}

.data-table tbody tr:hover {
  background: rgba(59, 130, 246, 0.1);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.4px;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.badge:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.badge-success {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.2), rgba(22, 163, 74, 0.15));
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.4);
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.12);
}

.badge-warning {
  background: linear-gradient(135deg, rgba(250, 204, 21, 0.22), rgba(234, 179, 8, 0.18));
  color: #facc15;
  border-color: rgba(250, 204, 21, 0.45);
  box-shadow: 0 0 12px rgba(250, 204, 21, 0.12);
}

.badge-danger {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(220, 38, 38, 0.15));
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.4);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.12);
}

.badge-gray {
  background: linear-gradient(135deg, rgba(148, 163, 184, 0.18), rgba(100, 116, 139, 0.15));
  color: #cbd5f5;
  border-color: rgba(148, 163, 184, 0.3);
}

.badge-info {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(37, 99, 235, 0.15));
  color: #93c5fd;
  border-color: rgba(59, 130, 246, 0.4);
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.12);
}

.filter-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 24px;
}

.filter-pill {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid #334155;
  background: #111827;
  color: #cbd5f5;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.filter-pill:hover {
  border-color: #3b82f6;
  background: #1a2332;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.filter-pill.active {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  border-color: #2563eb;
  color: white;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.filter-pill.active {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.12);
  color: #bfdbfe;
}

.filter-count {
  background: #334155;
  color: #94a3b8;
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}

.empty-state {
  padding: 32px;
  text-align: center;
  color: #94a3b8;
}

.surface-section {
  display: grid;
  gap: 24px;
}

.spacer-lg {
  height: 32px;
}

.grid-two {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 24px;
}

@media (max-width: 900px) {
  .grid-two {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .grid-two {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.card-header h3 {
  margin: 0;
  font-size: 18px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  background: #111827;
  border: 1px solid #1f2937;
  color: #cbd5f5;
}

/* Visibility helpers */
.mobile-only { display: none !important; }
.desktop-only { display: initial !important; }
@media (max-width: 640px) {
  .mobile-only { display: inline-flex !important; }
  .desktop-only { display: none !important; }
}

/* Floating action button (mobile) */
.fab-permit {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 1100;
  height: 52px;
  min-height: 52px;
  min-width: 52px;
  padding: 0 16px;
  border-radius: 999px;
  box-shadow: 0 10px 24px rgba(2,6,23,0.5);
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-primary-dark));
  color: #fff;
  border: none;
  display: none; /* default hidden; shown on mobile */
}
@media (max-width: 640px) {
  .fab-permit { display: inline-flex; align-items:center; gap:8px; }
}

/* -------------------------------------------------------------------------- */
/*  Permit picker modal                                                       */
/* -------------------------------------------------------------------------- */
.permit-popover-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 1000;
}

.permit-popover-backdrop[data-open="1"] {
  opacity: 1;
  pointer-events: auto;
}

.permit-popover {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -42%) scale(0.96);
  width: min(520px, calc(100% - 32px));
  max-height: min(80vh, 560px);
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 16px;
  box-shadow: 0 32px 56px rgba(2, 6, 23, 0.45);
  padding: 24px 24px 28px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 1010;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.permit-popover[data-open="1"] {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.permit-popover__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.permit-popover__header h3 {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
}

.permit-popover__list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  overflow-y: auto;
  padding-right: 4px;
  flex: 1 1 auto;
  min-height: 0;
}

.permit-popover__link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: #111827;
  border: 1px solid #334155;
  border-radius: 12px;
  color: #e5e7eb;
  text-decoration: none;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.permit-popover__link:hover,
.permit-popover__link:focus-visible {
  border-color: #3b82f6;
  box-shadow: 0 10px 24px rgba(59, 130, 246, 0.18);
  transform: translateY(-2px);
  outline: none;
}

.permit-popover__icon {
  font-size: 22px;
  line-height: 1;
}

.permit-popover__list .name {
  font-weight: 600;
  font-size: 16px;
}

@media (max-width: 360px) {
  .permit-popover {
    width: calc(100% - 24px);
    padding: 20px;
  }

  .permit-popover__link {
    padding: 12px;
  }
}

.scroll-row > * { scroll-snap-align: start; }
.approved-card { min-width: 280px; max-width: 360px; }

@media (max-width: 480px) {
  .approved-card { min-width: 240px; }
}

/* Center scroll rows when they don't overflow */
.scroll-row[data-overflow="0"] {
  justify-content: center;
}

/* Compact tweaks for narrow screens */
@media (max-width: 360px) {
  .wrap { padding: 8px; }
  .surface-card { padding: 16px; }
  .scroll-row { gap: 8px; padding: 6px 2px; }
  .approved-card { min-width: 220px; }
  .btn { padding: 10px 12px; min-height: 40px; }
}

/* Status form compact mode */
@media (max-width: 480px) {
  .status-row { gap: 8px; }
  .status-row input[type="email"] { min-height: 42px; padding: 10px 12px; }
  .status-row .btn { min-width: 120px; min-height: 42px; padding: 10px 12px; }
}

/* Larger, poppier template tiles */
.template-card--xl {
  padding: 26px;
  border-image: linear-gradient(135deg, rgba(59,130,246,.45), rgba(34,197,94,.35), rgba(236,72,153,.35)) 1;
  border: 1px solid #334155;
  background: radial-gradient(1200px 200px at -200px -200px, rgba(59,130,246,.12), transparent),
              linear-gradient(180deg, #0b1220, #111827);
}
.template-card--xl .icon { font-size: 56px; }
.template-card--xl .name { font-size: 17px; }

/* Ticker removed: keeping .scroll-row default behavior only */
