:root {
  --bg: #12141a;
  --surface: #1a1d26;
  --surface-2: #21242f;
  --border: #2a2e3a;
  --accent: #4A9EFF;
  --accent-dim: #2f6bb8;
  --amber: #f5b942;
  --coral: #e8724a;
  --text: #f2f3f6;
  --text-dim: #9096a6;
  --text-faint: #5c6172;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: 'Inter', sans-serif; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
.mono { font-family: 'IBM Plex Mono', monospace; }
#app { max-width: 720px; margin: 0 auto; padding: 24px 20px 100px; }

/* ---------- AUTH ---------- */
.auth-screen { padding-top: 60px; }
.brand-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.brand-mark { width: 40px; height: 40px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; }
.brand { font-family: 'Oswald', sans-serif; font-weight: 700; font-size: 26px; text-transform: uppercase; }
.brand span { color: var(--accent); }
.tagline { color: var(--text-dim); font-size: 14px; margin-bottom: 36px; }

.auth-tabs { display: flex; gap: 10px; margin-bottom: 24px; }
.auth-tabs button {
  flex: 1; padding: 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-dim); font-size: 14px; font-weight: 600; cursor: pointer;
}
.auth-tabs button.active { border-color: var(--accent); color: var(--accent); }

.field { margin-bottom: 18px; }
.field label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-dim); margin-bottom: 8px; }
.field input, .field textarea, .field select {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; color: var(--text); font-size: 15px; font-family: inherit;
}
.field textarea { resize: vertical; min-height: 90px; }

.btn-primary {
  width: 100%; background: var(--accent); color: #061018; border: none; border-radius: 10px;
  padding: 15px; font-weight: 600; font-size: 15px; cursor: pointer; margin-top: 6px;
}
.btn-secondary {
  width: 100%; background: transparent; color: var(--text); border: 1px solid var(--border); border-radius: 10px;
  padding: 13px; font-weight: 600; font-size: 14px; cursor: pointer;
}
.error-msg { color: var(--coral); font-size: 13px; margin-top: 12px; min-height: 18px; }

/* ---------- TOPBAR ---------- */
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.back-btn { background: none; border: none; color: var(--text-dim); font-size: 14px; cursor: pointer; padding: 8px 0; }
.logout-btn { background: none; border: none; color: var(--text-faint); font-size: 13px; cursor: pointer; }
.screen-title { font-family: 'Oswald', sans-serif; font-weight: 600; font-size: 22px; text-transform: uppercase; margin-bottom: 20px; }

/* ---------- CARDS ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 18px 20px; margin-bottom: 12px; cursor: pointer;
}
.card:hover { border-color: var(--accent-dim); }
.card-title { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.card-sub { font-size: 13px; color: var(--text-dim); }
.badge {
  display: inline-block; font-family: 'IBM Plex Mono', monospace; font-size: 11px;
  padding: 3px 9px; border-radius: 6px; margin-top: 8px;
}
.badge.draft { background: rgba(90,100,120,0.2); color: var(--text-dim); }
.badge.certified { background: rgba(74,158,255,0.15); color: var(--accent); }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-dim); }
.empty-state .big { font-size: 17px; color: var(--text); margin-bottom: 6px; }

.fab {
  position: fixed; bottom: calc(28px + env(safe-area-inset-bottom)); right: 50%; transform: translateX(340px);
  width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: #061018;
  font-size: 28px; border: none; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 24px rgba(74,158,255,0.4); cursor: pointer;
}
@media (max-width: 780px) { .fab { right: 24px; transform: none; } }

/* ---------- PERMIT CHECKLIST ---------- */
.block-header {
  font-family: 'Oswald', sans-serif; font-size: 13px; text-transform: uppercase;
  color: var(--text-faint); letter-spacing: 0.06em; margin: 24px 0 10px;
}
.block-header:first-child { margin-top: 0; }
.permit-row {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 8px; cursor: pointer;
}
.permit-num { font-family: 'IBM Plex Mono', monospace; color: var(--text-faint); font-size: 13px; width: 22px; flex-shrink: 0; }
.permit-info { flex: 1; min-width: 0; }
.permit-title { font-size: 14px; font-weight: 500; }
.permit-authority { font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.status-dot.not_started { background: var(--text-faint); }
.status-dot.in_progress { background: var(--amber); }
.status-dot.done { background: var(--accent); }
.status-dot.blocked { background: var(--coral); }

/* ---------- MODAL ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: flex-end; justify-content: center; z-index: 1000;
}
.modal-sheet {
  background: var(--bg); border: 1px solid var(--border); border-radius: 20px 20px 0 0;
  width: 100%; max-width: 720px; padding: 28px 24px calc(28px + env(safe-area-inset-bottom));
  max-height: 85vh; overflow-y: auto; position: relative;
}
.close-x {
  position: absolute; top: 18px; right: 18px; background: var(--surface-2); border: none;
  width: 34px; height: 34px; border-radius: 50%; color: var(--text-dim); font-size: 16px; cursor: pointer;
}
.modal-sheet h2 { font-family: 'Oswald', sans-serif; font-size: 20px; text-transform: uppercase; margin-bottom: 20px; }

.status-pills { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.pill {
  padding: 9px 14px; border-radius: 100px; border: 1px solid var(--border);
  font-size: 13px; color: var(--text-dim); cursor: pointer;
}
.pill.active { background: var(--accent); border-color: var(--accent); color: #061018; font-weight: 600; }

.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  padding: 13px 22px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none;
  transition: all 0.25s ease; z-index: 2000; max-width: 90%; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
