:root {
  /* aliensmokeshop.com — dark alien palette */
  --bg: #0a0d0b;
  --surface: #11161300;
  --surface: #121815;
  --surface-soft: #18211c;
  --sidebar-bg: #0c100e;
  --text: #e9fff5;
  --muted: #87a496;
  --line: #1f2b24;
  --primary: #00c888;       /* alien green */
  --primary-dark: #00a06d;
  --accent: #2ad9c4;        /* teal/cyan */
  --teal: #2ad9c4;
  --cyan: #22d3ee;
  --success: #00c888;
  --warning: #f5b301;
  --danger: #ff5d6c;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  --glow: 0 0 24px rgba(0, 200, 136, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

/* Hide the dashboard until unlocked */
html:not(.authed) .app-shell {
  display: none;
}

html.authed .lock-screen {
  display: none;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(900px circle at 100% -5%, rgba(0, 200, 136, 0.14), transparent 45%),
    radial-gradient(700px circle at -5% 110%, rgba(42, 217, 196, 0.1), transparent 45%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

/* ===================== Lock screen ===================== */
.lock-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(800px circle at 50% -10%, rgba(0, 200, 136, 0.3), transparent 55%),
    radial-gradient(600px circle at 50% 120%, rgba(42, 217, 196, 0.18), transparent 55%),
    #05080600;
  background-color: #060907;
}

.lock-card {
  width: min(420px, 100%);
  display: grid;
  gap: 12px;
  justify-items: center;
  text-align: center;
  padding: 38px 32px 32px;
  border: 1px solid rgba(0, 200, 136, 0.25);
  border-radius: 20px;
  background: rgba(14, 20, 17, 0.92);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.6), var(--glow);
  color: var(--text);
}

.lock-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  font-size: 1.8rem;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  box-shadow: 0 10px 30px rgba(0, 200, 136, 0.45);
}

.lock-card h1 {
  margin: 4px 0 0;
  font-size: 1.5rem;
  letter-spacing: -0.03em;
}

.lock-card p {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.92rem;
}

.lock-card input {
  width: 100%;
  text-align: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(0, 200, 136, 0.25);
  color: #fff;
}

.lock-card input::placeholder {
  color: #6f8a7e;
}

.lock-card .button {
  width: 100%;
}

.lock-error {
  min-height: 18px;
  color: #ff8a96;
  font-size: 0.85rem;
  font-weight: 700;
}

/* ===================== App shell ===================== */
.app-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 14px;
  background: linear-gradient(180deg, #0d1410 0%, #060907 100%);
  border-right: 1px solid var(--line);
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #04140a;
  box-shadow: var(--glow);
  font-weight: 800;
}

.brand p {
  margin: 0;
  font-weight: 800;
  font-size: 1rem;
}

.brand span,
.sidebar-card p {
  color: var(--muted);
}

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

.nav-list a {
  color: #9fc2b2;
  text-decoration: none;
  padding: 11px 12px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
}

.nav-list a.active,
.nav-list a:hover {
  background: rgba(0, 200, 136, 0.14);
  color: var(--primary);
}

.sidebar-card {
  margin-top: auto;
  padding: 18px;
  border: 1px solid rgba(0, 200, 136, 0.2);
  border-radius: 18px;
  background: rgba(0, 200, 136, 0.06);
}

.sidebar-card .eyebrow {
  color: var(--primary);
}

.sidebar-card p {
  margin-bottom: 0;
  line-height: 1.5;
}

.logout-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: #c2d6cc;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.logout-button:hover {
  border-color: rgba(255, 93, 108, 0.45);
  background: rgba(255, 93, 108, 0.12);
  color: #ff8a96;
}

.main-content {
  padding: 28px;
  display: grid;
  gap: 16px;
}

.hero,
.panel,
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.hero {
  padding: 0 0 6px;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.eyebrow {
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero h1 {
  max-width: 760px;
  margin: 0 0 8px;
  font-size: 1.9rem;
  line-height: 1.1;
  letter-spacing: -0.04em;
}

.hero p,
.stat-card p,
.panel p {
  color: var(--muted);
}

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

.button {
  border: 0;
  border-radius: 10px;
  padding: 11px 16px;
  cursor: pointer;
  font-weight: 800;
}

.primary {
  background: var(--primary);
  color: #04140a;
  box-shadow: var(--glow);
}

.primary:hover {
  background: var(--primary-dark);
  color: #04140a;
}

.secondary {
  background: rgba(0, 200, 136, 0.1);
  color: var(--primary);
  border: 1px solid rgba(0, 200, 136, 0.3);
}

.secondary:hover {
  background: rgba(0, 200, 136, 0.16);
}

.connection-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.connection-panel h2 {
  margin: 6px 0 8px;
}

.connection-status {
  margin: 0;
  padding: 12px 14px;
  border-radius: 999px;
  background: rgba(0, 200, 136, 0.12);
  color: var(--primary);
  border: 1px solid rgba(0, 200, 136, 0.28);
  font-weight: 800;
}

.connection-status.error {
  background: rgba(255, 93, 108, 0.12);
  color: #ff8a96;
  border-color: rgba(255, 93, 108, 0.3);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.stat-card {
  position: relative;
  min-height: 112px;
  padding: 18px 16px 16px 64px;
}

.stat-card::before {
  position: absolute;
  left: 18px;
  top: 24px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(0, 200, 136, 0.14);
  color: var(--primary);
  content: "▣";
  font-weight: 900;
}

.stat-card.success::before {
  background: rgba(0, 200, 136, 0.16);
  color: var(--success);
  content: "✓";
}

.stat-card.warning::before {
  background: rgba(245, 179, 1, 0.16);
  color: var(--warning);
  content: "!";
}

.stat-card.danger::before {
  background: rgba(255, 93, 108, 0.16);
  color: var(--danger);
  content: "×";
}

.stat-card.neutral::before {
  background: rgba(42, 217, 196, 0.16);
  color: var(--teal);
  content: "⚑";
}

.stat-card span {
  color: var(--muted);
  font-weight: 700;
}

.stat-card strong {
  display: block;
  margin-top: 10px;
  font-size: 2rem;
  letter-spacing: -0.05em;
}

.stat-card.success strong {
  color: var(--success);
}

.stat-card.warning strong {
  color: var(--warning);
}

.stat-card.danger strong {
  color: var(--danger);
}

.stat-card.neutral strong {
  color: var(--teal);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(330px, 0.7fr);
  gap: 14px;
}

.panel {
  padding: 18px;
}

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

.panel h2 {
  margin: 6px 0 0;
  letter-spacing: -0.04em;
}

.location-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.location-summary-header,
.location-card {
  display: grid;
  grid-template-columns: minmax(200px, 1.8fr) repeat(5, minmax(70px, 1fr));
  align-items: center;
  gap: 10px;
}

.location-summary-header {
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.location-card {
  width: 100%;
  padding: 13px 14px;
  border-radius: 0;
  background: var(--surface);
  border: 0;
  border-top: 1px solid var(--line);
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-align: left;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.location-card:hover,
.location-card.selected {
  background: rgba(0, 200, 136, 0.08);
  box-shadow: inset 4px 0 0 var(--primary);
}

.location-card h3 {
  margin: 0;
  font-size: 0.98rem;
}

.location-card small {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.cell-metric {
  font-weight: 800;
}

.metric-ready { color: var(--success); }
.metric-pending { color: var(--warning); }
.metric-missing { color: var(--danger); }
.metric-verified { color: var(--teal); }
.metric-zero { color: var(--muted); font-weight: 700; }

.permit-breakdown-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.permit-group {
  display: grid;
  gap: 10px;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
}

.permit-group-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.permit-group h4 {
  margin: 0 0 4px;
}

.permit-group p {
  margin: 0;
}

.permit-detail-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.permit-detail-card strong,
.permit-detail-card span {
  display: block;
}

.permit-detail-card span,
.permit-detail-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.permit-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.badge,
.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 800;
}

.badge {
  background: rgba(255, 255, 255, 0.06);
  color: #cde8dc;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.status-ready {
  background: rgba(0, 200, 136, 0.16);
  color: #4fe3ad;
  border: 1px solid rgba(0, 200, 136, 0.32);
}

.status-pending {
  background: rgba(245, 179, 1, 0.16);
  color: #fcd34d;
  border: 1px solid rgba(245, 179, 1, 0.3);
}

.status-missing {
  background: rgba(255, 93, 108, 0.16);
  color: #ff8a96;
  border: 1px solid rgba(255, 93, 108, 0.3);
}

.status-verified {
  background: rgba(42, 217, 196, 0.16);
  color: #5ee6d4;
  border: 1px solid rgba(42, 217, 196, 0.32);
}

.table-header {
  align-items: flex-end;
}

input,
select {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
  padding: 0 12px;
  color: var(--text);
}

input::placeholder {
  color: var(--muted);
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 200, 136, 0.2);
}

input[type="search"] {
  width: min(320px, 100%);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1000px;
}

th,
td {
  padding: 13px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

tbody tr:hover {
  background: var(--surface-soft);
}

td a {
  color: var(--teal);
  text-decoration: none;
  font-weight: 700;
}

td a:hover {
  text-decoration: underline;
}

.cell-sub {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.mono {
  font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  color: var(--teal);
}

@media (max-width: 1100px) {
  .app-shell,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .location-summary-header,
  .location-card {
    grid-template-columns: 1.5fr repeat(2, 1fr);
  }

  .location-summary-header span:nth-child(n+4),
  .location-card > span:nth-child(n+4) {
    display: none;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .hero {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 720px) {
  .main-content,
  .sidebar {
    padding: 18px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .permit-breakdown-grid {
    grid-template-columns: 1fr;
  }
}

/* Vendor detail modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  background: rgba(3, 6, 4, 0.72);
  backdrop-filter: blur(4px);
  overflow-y: auto;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  width: min(960px, 100%);
  margin: auto;
  border: 1px solid rgba(0, 200, 136, 0.25);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow), var(--glow);
  animation: modal-pop 0.18s ease-out;
}

@keyframes modal-pop {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
}

.modal-header h3 {
  margin: 6px 0 4px;
  font-size: 1.5rem;
  letter-spacing: -0.03em;
}

.modal-header p {
  margin: 2px 0;
}

.modal-close {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.modal-close:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.modal-body {
  padding: 22px 24px 26px;
}

body.modal-open {
  overflow: hidden;
}

/* Action queue checklist */
.checklist {
  display: grid;
  gap: 16px;
}

.checklist-group {
  display: grid;
  gap: 8px;
}

.checklist-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--primary);
}

.checklist-group-title .count {
  color: var(--muted);
}

.checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
  transition: border-color 0.2s ease;
}

.checklist-item:hover {
  border-color: rgba(0, 200, 136, 0.4);
}

.checklist-item input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  min-height: 0;
  margin-top: 2px;
  padding: 0;
  border: 2px solid var(--line);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.checklist-item input[type="checkbox"]::after {
  content: "✓";
  font-size: 0.85rem;
  font-weight: 900;
  color: #04140a;
  opacity: 0;
}

.checklist-item input[type="checkbox"]:checked {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: var(--glow);
}

.checklist-item input[type="checkbox"]:checked::after {
  opacity: 1;
}

.checklist-content {
  flex: 1;
  display: grid;
  gap: 4px;
}

.checklist-item.done .checklist-content {
  opacity: 0.55;
  text-decoration: line-through;
}

.checklist-title {
  font-weight: 800;
}

.checklist-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  color: var(--muted);
  font-size: 0.85rem;
}

.checklist-meta b {
  color: var(--text);
  font-weight: 700;
}

.empty-state {
  color: var(--muted);
  padding: 8px 0;
}

/* ===================== Employee view ===================== */
.emp-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.emp-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 28px;
  background: linear-gradient(180deg, #0d1410 0%, #080b09 100%);
  border-bottom: 1px solid var(--line);
}

.emp-header .brand span {
  display: block;
  font-size: 0.8rem;
}

.emp-header .brand span.error {
  color: #ff8a96;
}

.emp-logout {
  width: auto;
  padding: 10px 16px;
}

.emp-main {
  flex: 1;
  padding: 24px 28px 40px;
  display: grid;
  gap: 18px;
  align-content: start;
}

.emp-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.emp-toolbar input[type="search"] {
  flex: 1;
  min-width: 220px;
  max-width: 420px;
}

.emp-count {
  margin-left: auto;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.9rem;
}

.emp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.coa-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.coa-card:hover {
  border-color: rgba(0, 200, 136, 0.4);
  transform: translateY(-2px);
}

.coa-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.coa-vendor {
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: right;
}

.coa-title {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.coa-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.coa-meta span {
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.coa-details {
  margin: 0;
  display: grid;
  gap: 8px;
}

.coa-details div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 7px;
}

.coa-details dt {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.coa-details dd {
  margin: 0;
  text-align: right;
  font-size: 0.88rem;
  font-weight: 600;
}

.coa-report-link {
  margin-top: auto;
  text-align: center;
  text-decoration: none;
}

.coa-report-disabled {
  margin-top: auto;
  background: var(--surface-soft);
  color: var(--muted);
  border: 1px dashed var(--line);
  cursor: not-allowed;
}

@media (max-width: 720px) {
  .emp-header,
  .emp-main {
    padding-left: 18px;
    padding-right: 18px;
  }

  .emp-count {
    margin-left: 0;
  }
}

/* Lab report viewer modal */
.report-modal {
  width: min(1000px, 100%);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 80px);
}

.report-modal-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.report-modal-actions .button {
  text-decoration: none;
  white-space: nowrap;
}

.report-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.report-body iframe {
  width: 100%;
  height: 70vh;
  min-height: 360px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.report-fallback {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.86rem;
}

.report-fallback p {
  margin: 0;
}

.report-fallback .button {
  text-decoration: none;
}
