/* ============================
   LotGuard Design System
   Matching landing page tokens
   ============================ */

:root {
  --navy: #1B3A6B;
  --navy-deep: #0F2444;
  --amber: #E8912A;
  --amber-light: #F5A84A;
  --cream: #FDF8F3;
  --gray-light: #F4F5F7;
  --gray-mid: #4B5563;
  --white: #FFFFFF;
  --text: #1A1D23;
  --text-secondary: #374151;
  --green: #16A34A;
  --green-light: #F0FDF4;
  --red: #DC2626;
  --red-light: #FEF2F2;
  --blue: #2563EB;
  --blue-light: #EFF6FF;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; font-size: 17px; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text);
  background: var(--gray-light);
  font-size: 1rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

/* ============================
   App Nav
   ============================ */
.app-nav {
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 100;
  padding: 0.9rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--navy);
  color: var(--white);
  box-shadow: 0 2px 12px rgba(15, 36, 68, 0.15);
}

.app-nav .nav-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--white);
}

.app-nav .nav-logo .shield-icon { width: 28px; height: 28px; }

.app-nav .nav-logo span {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}

.app-nav .nav-links {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  list-style: none;
}

.app-nav .nav-links a {
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 500;
  transition: color 0.2s;
}

.app-nav .nav-links a:hover { color: var(--white); }

.app-nav .nav-links .active { color: var(--white); font-weight: 700; }

.nav-user {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.nav-user-name {
  font-size: 0.875rem;
  opacity: 0.85;
}

.btn-nav {
  padding: 0.45rem 1.1rem;
  background: var(--amber);
  color: var(--white);
  border: none;
  border-radius: 100px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s;
}

.btn-nav:hover { background: var(--amber-light); }

.btn-nav-outline {
  padding: 0.45rem 1.1rem;
  background: transparent;
  color: rgba(255,255,255,0.85);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 100px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
}

.btn-nav-outline:hover {
  background: rgba(255,255,255,0.1);
  color: var(--white);
}

/* ============================
   Layout
   ============================ */
.app-body {
  padding-top: 56px;
  min-height: 100vh;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
}

.container-narrow {
  max-width: 520px;
  margin: 0 auto;
  padding: 3rem 1.5rem;
}

.container-wide {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ============================
   Typography
   ============================ */
h1, h2, h3 {
  font-family: 'Syne', sans-serif;
  color: var(--navy);
  letter-spacing: -0.02em;
}

h1 { font-size: 2.2rem; font-weight: 800; line-height: 1.15; }
h2 { font-size: 1.6rem; font-weight: 800; line-height: 1.25; }
h3 { font-size: 1.2rem; font-weight: 700; line-height: 1.35; }

.text-secondary { color: var(--text-secondary); }
.text-amber { color: var(--amber); }
.text-navy { color: var(--navy); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-sm { font-size: 0.9375rem; }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

/* ============================
   Cards
   ============================ */
.card {
  background: var(--white);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: 0 2px 16px rgba(27, 58, 107, 0.06);
  border: 1px solid rgba(27, 58, 107, 0.06);
}

.card-sm { padding: 1.25rem; }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.card-header h2 { margin: 0; font-size: 1.35rem; }

.card-hero {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-deep) 100%);
  color: var(--white);
  border-radius: 20px;
  padding: 2.5rem;
  margin-bottom: 2rem;
  position: relative;
  overflow: hidden;
}

.card-hero::before {
  content: '';
  position: absolute;
  top: -50px;
  right: -50px;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(232,145,42,0.2) 0%, transparent 70%);
  pointer-events: none;
}

.card-hero h1, .card-hero h2, .card-hero h3 { color: var(--white); }
.card-hero p { color: rgba(255,255,255,0.85); }

/* ============================
   Stat Cards
   ============================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--white);
  border-radius: 14px;
  padding: 1.25rem;
  border: 1px solid rgba(27, 58, 107, 0.06);
  box-shadow: 0 1px 8px rgba(27, 58, 107, 0.04);
}

.stat-card .stat-value {
  font-family: 'Syne', sans-serif;
  font-size: 2rem;
  font-weight: 800;
  color: var(--navy);
  line-height: 1;
}

.stat-card .stat-label {
  font-size: 0.875rem;
  color: var(--gray-mid);
  font-weight: 500;
  margin-top: 0.35rem;
}

/* ============================
   Buttons
   ============================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 12px;
  font-family: 'Inter', sans-serif;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  line-height: 1.4;
}

.btn-primary {
  background: var(--navy);
  color: var(--white);
}

.btn-primary:hover { background: var(--navy-deep); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(27, 58, 107, 0.25); }

.btn-amber {
  background: var(--amber);
  color: var(--white);
}

.btn-amber:hover { background: var(--amber-light); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(232, 145, 42, 0.3); }

.btn-outline {
  background: transparent;
  color: var(--navy);
  border: 1.5px solid rgba(27, 58, 107, 0.2);
}

.btn-outline:hover { border-color: var(--navy); background: rgba(27, 58, 107, 0.04); }

.btn-danger {
  background: var(--red);
  color: var(--white);
}

.btn-danger:hover { background: #B91C1C; }

.btn-sm {
  padding: 0.45rem 0.95rem;
  font-size: 0.8125rem;
  border-radius: 8px;
}

.btn-lg {
  padding: 1rem 2rem;
  font-size: 1.0625rem;
  border-radius: 14px;
}

.btn-full { width: 100%; }

.btn:disabled, .btn.loading {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

/* ============================
   Forms
   ============================ */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.4rem;
}

.form-group .hint {
  font-size: 0.8125rem;
  color: var(--gray-mid);
  margin-top: 0.25rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1.5px solid rgba(27, 58, 107, 0.15);
  border-radius: 12px;
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  color: var(--text);
  background: var(--white);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(27, 58, 107, 0.08);
}

input.code-input {
  font-family: 'Syne', monospace;
  font-size: 1.8rem;
  font-weight: 800;
  text-align: center;
  letter-spacing: 0.08em;
  color: var(--navy);
  padding: 1rem;
  text-transform: uppercase;
}

input.code-input::placeholder {
  font-size: 1.2rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: rgba(27, 58, 107, 0.25);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%234A5060' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}

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

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* ============================
   Alerts / Toasts
   ============================ */
.alert {
  padding: 0.9rem 1.2rem;
  border-radius: 12px;
  font-size: 0.9375rem;
  font-weight: 500;
  margin-bottom: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.alert-success {
  background: var(--green-light);
  color: #15803D;
  border: 1px solid rgba(22, 163, 74, 0.15);
}

.alert-error {
  background: var(--red-light);
  color: #991B1B;
  border: 1px solid rgba(220, 38, 38, 0.15);
}

.alert-info {
  background: var(--blue-light);
  color: #1E40AF;
  border: 1px solid rgba(37, 99, 235, 0.15);
}

.toast-container {
  position: fixed;
  top: 70px;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.8rem 1.2rem;
  border-radius: 12px;
  font-size: 0.9375rem;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  animation: slideIn 0.3s ease-out;
  max-width: 360px;
}

.toast-success { background: #15803D; color: var(--white); }
.toast-error { background: var(--red); color: var(--white); }
.toast-info { background: var(--navy); color: var(--white); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ============================
   Badge
   ============================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.65rem;
  border-radius: 100px;
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-navy { background: rgba(27,58,107,0.1); color: var(--navy); }
.badge-amber { background: rgba(232,145,42,0.12); color: #B5700F; }
.badge-green { background: rgba(22,163,74,0.1); color: #15803D; }
.badge-blue { background: rgba(37,99,235,0.1); color: #1E40AF; }
.badge-gray { background: rgba(138,145,158,0.15); color: var(--gray-mid); }
.badge-red { background: rgba(220,38,38,0.1); color: #991B1B; }

/* ============================
   Tables
   ============================ */
.table-wrap {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid rgba(27,58,107,0.06);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

thead { background: var(--gray-light); }

th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

td {
  padding: 0.8rem 1rem;
  border-top: 1px solid var(--gray-light);
  vertical-align: middle;
}

tr:hover td { background: rgba(27,58,107,0.015); }

/* ============================
   Documents Grid
   ============================ */
.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.doc-card {
  background: var(--white);
  border-radius: 14px;
  padding: 1.25rem;
  border: 1px solid rgba(27,58,107,0.06);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: box-shadow 0.2s, transform 0.2s;
}

.doc-card:hover {
  box-shadow: 0 4px 16px rgba(27,58,107,0.08);
  transform: translateY(-2px);
}

.doc-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.doc-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.doc-icon.survey { background: rgba(27,58,107,0.1); }
.doc-icon.plat { background: rgba(232,145,42,0.12); }
.doc-icon.easement { background: rgba(22,163,74,0.1); }
.doc-icon.flood_zone { background: rgba(37,99,235,0.1); }
.doc-icon.other { background: rgba(138,145,158,0.1); }

.doc-card-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
}

.doc-card-meta {
  font-size: 0.8125rem;
  color: var(--gray-mid);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.doc-card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: auto;
}

/* ============================
   Upload Area
   ============================ */
.upload-area {
  border: 2px dashed rgba(27,58,107,0.15);
  border-radius: 16px;
  padding: 2.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: rgba(27,58,107,0.02);
}

.upload-area:hover, .upload-area.dragover {
  border-color: var(--amber);
  background: rgba(232,145,42,0.04);
}

.upload-area .upload-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}

.upload-area .upload-text {
  font-size: 1rem;
  color: var(--text-secondary);
}

.upload-area .upload-text strong {
  color: var(--navy);
}

/* ============================
   Tabs
   ============================ */
.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--gray-light);
}

.tab-btn {
  padding: 0.75rem 1.25rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--gray-mid);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--navy); border-bottom-color: var(--amber); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ============================
   Modal
   ============================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,36,68,0.45);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

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

.modal {
  background: var(--white);
  border-radius: 20px;
  padding: 2rem;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(15,36,68,0.2);
  animation: modalIn 0.3s ease-out;
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--gray-light);
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.modal-close:hover { background: var(--red-light); color: var(--red); }

/* ============================
   Property Info Card
   ============================ */
.property-card {
  background: linear-gradient(135deg, var(--cream) 0%, var(--white) 100%);
  border: 1px solid rgba(232,145,42,0.15);
  border-radius: 14px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.property-card .property-label {
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--amber);
  margin-bottom: 0.25rem;
}

.property-card .property-address {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--navy);
}

.property-card .property-city {
  font-size: 0.9375rem;
  color: var(--text-secondary);
}

/* ============================
   Plan Status
   ============================ */
.plan-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.85rem;
  border-radius: 100px;
  font-size: 0.8125rem;
  font-weight: 700;
}

.plan-badge.active {
  background: rgba(22,163,74,0.1);
  color: #15803D;
}

.plan-badge.active::before {
  content: '';
  width: 7px;
  height: 7px;
  background: var(--green);
  border-radius: 50%;
}

.plan-badge.expired {
  background: rgba(220,38,38,0.1);
  color: #991B1B;
}

/* ============================
   Empty State
   ============================ */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-secondary);
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state h3 { color: var(--text-secondary); margin-bottom: 0.5rem; }
.empty-state p { font-size: 0.9375rem; }

/* ============================
   Loading Spinner
   ============================ */
.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner-dark {
  border-color: rgba(27,58,107,0.15);
  border-top-color: var(--navy);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================
   Auth Pages
   ============================ */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(175deg, var(--cream) 0%, var(--gray-light) 100%);
  padding: 2rem;
}

.auth-card {
  background: var(--white);
  border-radius: 24px;
  padding: 2.5rem;
  width: 100%;
  max-width: 460px;
  box-shadow: 0 8px 40px rgba(27,58,107,0.08);
  border: 1px solid rgba(27,58,107,0.04);
}

.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin-bottom: 2rem;
  text-decoration: none;
}

.auth-logo .shield-icon { width: 36px; height: 36px; }

.auth-logo span {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 1.4rem;
  color: var(--navy);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.5rem 0;
  color: var(--gray-mid);
  font-size: 0.875rem;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--gray-light);
}

/* ============================
   Responsive
   ============================ */
@media (max-width: 768px) {
  .app-nav { padding: 0.75rem 1rem; }
  .app-nav .nav-links { gap: 0.6rem; }
  .app-nav .nav-links a { font-size: 0.875rem; }
  .container, .container-narrow { padding: 1.5rem 1rem; }
  .card { padding: 1.5rem; border-radius: 14px; }
  .auth-card { padding: 1.75rem; }
  h1 { font-size: 1.8rem; }
  h2 { font-size: 1.3rem; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .doc-grid { grid-template-columns: 1fr; }
  .nav-user-name { display: none; }
  input.code-input { font-size: 1.4rem; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 0.75rem; }
  .stat-card .stat-value { font-size: 1.5rem; }
}
