/* AGRDATA Invoice Generator – PWA Styles */
:root {
  --navy: #0F172A;
  --green: #16A34A;
  --green-light: #86EFAC;
  --bg: #F1F5F9;
  --white: #FFFFFF;
  --text: #1E293B;
  --muted: #64748B;
  --border: #CBD5E1;
  --red: #DC2626;
  --card-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  --radius: 10px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
}

body {
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  overflow-x: hidden;
}

.app-header {
  background: var(--navy);
  color: white;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.app-header .brand { display: flex; align-items: baseline; gap: 6px; }
.app-header .brand strong { color: var(--green-light); font-size: 1.15rem; }
.app-header .brand span { font-size: 0.95rem; font-weight: 500; }

.menu-btn {
  background: transparent; border: none; color: white;
  font-size: 1.5rem; padding: 4px 8px; cursor: pointer; line-height: 1;
}

.nav-drawer {
  position: fixed; top: 0; left: 0; width: 280px; max-width: 85vw;
  height: 100%; background: var(--navy); color: white; z-index: 200;
  transform: translateX(-100%); transition: transform 0.25s ease;
  padding-top: calc(16px + var(--safe-top)); overflow-y: auto;
}
.nav-drawer.open { transform: translateX(0); }

.nav-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 150;
  opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
.nav-overlay.show { opacity: 1; pointer-events: auto; }

.nav-drawer .nav-title {
  padding: 8px 20px 16px; font-size: 0.85rem; color: var(--green-light);
  font-weight: 600; letter-spacing: 0.03em;
}
.nav-drawer a {
  display: block; padding: 14px 20px; color: white; text-decoration: none;
  font-weight: 500; border-left: 3px solid transparent;
}
.nav-drawer a:hover, .nav-drawer a.active {
  background: #1E293B; border-left-color: var(--green);
}

main {
  flex: 1; padding: 16px; max-width: 900px; margin: 0 auto; width: 100%;
  padding-bottom: 80px;
}

.page { display: none; }
.page.active { display: block; }

.page-title { font-size: 1.4rem; font-weight: 700; color: var(--navy); margin-bottom: 4px; }
.page-sub { color: var(--muted); font-size: 0.9rem; margin-bottom: 16px; }

.card {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 12px; box-shadow: var(--card-shadow);
}
.card h3 { font-size: 0.95rem; color: var(--navy); margin-bottom: 10px; }

.stats-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px;
}
@media (min-width: 560px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}

.stat-card {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; box-shadow: var(--card-shadow);
}
.stat-card .label { font-size: 0.8rem; color: var(--muted); }
.stat-card .value { font-size: 1.25rem; font-weight: 700; color: var(--navy); margin-top: 2px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border: none; border-radius: 8px; font-size: 0.9rem;
  font-weight: 600; cursor: pointer; transition: background 0.15s, transform 0.1s;
  text-decoration: none; color: inherit;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--green); color: white; }
.btn-primary:hover { background: #15803d; }
.btn-secondary { background: #E2E8F0; color: var(--navy); }
.btn-danger { background: var(--red); color: white; }
.btn-sm { padding: 7px 12px; font-size: 0.82rem; }
.btn-block { width: 100%; margin-bottom: 8px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }

.form-group { margin-bottom: 12px; }
.form-group label {
  display: block; font-size: 0.82rem; font-weight: 600; color: var(--text); margin-bottom: 4px;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 1rem; background: #F8FAFC; color: var(--text); appearance: none; -webkit-appearance: none;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
}
.form-group textarea { min-height: 80px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 480px) { .form-row { grid-template-columns: 1fr; } }

.list-item {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 12px 0; border-bottom: 1px solid var(--border); gap: 10px;
}
.list-item:last-child { border-bottom: none; }
.list-item .meta { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }
.list-item .actions { display: flex; gap: 6px; flex-shrink: 0; }

.empty-state { text-align: center; padding: 32px 16px; color: var(--muted); }
.empty-state p { margin-top: 8px; }

.search-bar {
  display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap;
}
.search-bar input, .search-bar select {
  flex: 1; min-width: 120px; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 0.95rem; background: white;
}

.toast {
  position: fixed; bottom: calc(24px + var(--safe-bottom)); left: 50%;
  transform: translateX(-50%) translateY(80px); background: var(--navy); color: white;
  padding: 12px 20px; border-radius: 10px; font-size: 0.9rem; z-index: 300;
  opacity: 0; transition: transform 0.25s, opacity 0.25s; max-width: 90vw;
  text-align: center; box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.error { background: var(--red); }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 250;
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.modal-overlay.show { opacity: 1; pointer-events: auto; }
.modal {
  background: white; border-radius: 16px 16px 0 0; width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto; padding: 20px 18px calc(20px + var(--safe-bottom));
  transform: translateY(100%); transition: transform 0.25s ease;
}
.modal-overlay.show .modal { transform: translateY(0); }
.modal h2 { font-size: 1.15rem; margin-bottom: 14px; color: var(--navy); }
.modal-close {
  float: right; background: none; border: none; font-size: 1.4rem;
  color: var(--muted); cursor: pointer; padding: 0 4px;
}

.install-banner {
  display: none; background: var(--green); color: white; padding: 10px 16px;
  text-align: center; font-size: 0.9rem; font-weight: 500;
}
.install-banner.show { display: block; }
.install-banner button {
  background: white; color: var(--green); border: none; padding: 6px 14px;
  border-radius: 6px; font-weight: 600; margin-left: 10px; cursor: pointer;
}

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 0.75rem; font-weight: 600; background: #E2E8F0; color: var(--navy);
}
.badge-green { background: #DCFCE7; color: #166534; }
.badge-blue { background: #DBEAFE; color: #1E40AF; }
.badge-orange { background: #FFEDD5; color: #9A3412; }
.badge-red { background: #FEE2E2; color: #991B1B; }

.item-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 0.9rem;
}
.item-row:last-child { border-bottom: none; }
.totals-box { margin-top: 12px; padding-top: 12px; border-top: 2px solid var(--navy); }
.totals-box .row { display: flex; justify-content: space-between; padding: 4px 0; }
.totals-box .row.total { font-weight: 700; font-size: 1.1rem; }

.hidden { display: none !important; }
.text-muted { color: var(--muted); }
.text-sm { font-size: 0.85rem; }
.mt-8 { margin-top: 8px; }
.mb-8 { margin-bottom: 8px; }
