:root {
  --primary: #16a34a;
  --primary-dark: #15803d;
  --primary-light: #dcfce7;
  --accent-blue: #2563eb;
  --accent-blue-light: #dbeafe;
  --accent-orange: #f59e0b;
  --accent-orange-light: #fef3c7;
  --lime: #84cc16;
  --lime-dark: #65a30d;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-900: #111827;
  --white: #ffffff;
  --border: #e5e7eb;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --radius: 10px;
  --radius-lg: 14px;
  --surface: #ffffff;
  --muted: #6b7280;
  --text: #111827;
}

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

body {
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Noto Sans Devanagari", sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  line-height: 1.55;
  min-height: 100vh;
}

.app-container { max-width: 960px; margin: 0 auto; padding: 12px 16px 80px; }

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 8px 0;
  flex-wrap: wrap;
}
.header-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.header-logo { height: 48px; width: auto; border-radius: 8px; }
.header-title h1 { font-size: 1.35rem; font-weight: 800; line-height: 1.15; letter-spacing: -0.3px; }
.header-title h1 .k { color: var(--primary); }
.header-title h1 .g { color: var(--accent-orange); }
.header-title p { font-size: 0.8rem; color: var(--muted); margin: 0; }

.auth-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--white); border: 1px solid var(--border); color: var(--text);
  padding: 8px 14px; border-radius: 999px; font-size: 0.88rem; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: all 0.15s; white-space: nowrap;
}
.auth-btn:hover { background: #f0fdf4; border-color: var(--primary); }
.auth-btn .avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 0.8rem; font-weight: 700;
}

/* Nav */
.nav {
  display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 16px;
  padding: 8px 0; border-bottom: 1px solid var(--gray-200);
}
.nav a {
  text-decoration: none; color: var(--gray-500); font-weight: 700;
  padding: 7px 13px; border-radius: 999px; font-size: 0.88rem;
  display: inline-flex; align-items: center; gap: 6px;
}
.nav a:hover, .nav a.active { background: var(--primary-light); color: var(--primary); }
.nav a .dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--accent-blue);
}

/* Cards */
.card {
  background: var(--white); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px;
  border: 1px solid var(--border);
}
.card-header {
  font-size: 1.1rem; font-weight: 700; margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px;
}
.card-header .icon {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--primary-light); display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
}

/* Forms */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block; font-weight: 600; margin-bottom: 4px;
  font-size: 0.86rem; color: var(--gray-700);
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 11px 12px; border: 1.5px solid var(--gray-300);
  border-radius: var(--radius); font-size: 1rem; font-family: inherit;
  transition: border-color 0.15s; background: var(--white);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .form-row { grid-template-columns: 1fr; } }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 20px; border: none; border-radius: var(--radius);
  font-size: 1rem; font-weight: 600; cursor: pointer; text-decoration: none;
  transition: background 0.15s; font-family: inherit;
}
.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-blue { background: var(--accent-blue); color: #fff; }
.btn-blue:hover { background: #1d4ed8; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-outline {
  background: transparent; color: var(--primary); border: 1.5px solid var(--primary);
}
.btn-outline:hover { background: var(--primary-light); }
.btn-sm { padding: 7px 13px; font-size: 0.875rem; }
.btn-block { display: flex; width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* Alerts */
.alert {
  padding: 12px 16px; border-radius: var(--radius); margin-bottom: 14px;
  font-size: 0.9rem; font-weight: 500;
}
.alert-error { background: var(--danger-light); color: var(--danger); border: 1px solid #fecaca; }
.alert-success { background: var(--primary-light); color: var(--primary-dark); border: 1px solid #bbf7d0; }
.alert-info { background: var(--accent-blue-light); color: #1e40af; border: 1px solid #bfdbfe; }
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fde68a; }

/* Auth */
.auth-container { max-width: 420px; margin: 24px auto; }
.auth-container .card { padding: 28px 24px; }
.auth-title { text-align: center; font-size: 1.35rem; font-weight: 800; margin-bottom: 6px; color: var(--primary); }
.auth-subtitle { text-align: center; color: var(--muted); margin-bottom: 20px; font-size: 0.9rem; }

/* OTP / device code */
.otp-box {
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  border: 2px dashed var(--primary); border-radius: var(--radius-lg);
  padding: 20px 16px; text-align: center; margin: 16px 0;
}
.otp-label {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--primary-dark); font-weight: 700; margin-bottom: 8px; opacity: 0.8;
}
.otp-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 2.4rem; font-weight: 700; letter-spacing: 8px;
  color: var(--primary-dark); line-height: 1.15; text-indent: 8px;
}
.otp-timer { display: flex; align-items: center; gap: 10px; font-size: 0.85rem; color: var(--muted); margin: 12px 0; justify-content: center; }
.otp-timer .bar { height: 5px; background: var(--border); border-radius: 3px; overflow: hidden; flex: 1; max-width: 180px; }
.otp-timer .bar span { display: block; height: 100%; background: var(--primary); transition: width 1s linear; }
.otp-timer.low .bar span { background: var(--warning); }

/* Status banners */
.status-banner {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px; border-radius: var(--radius-lg); margin-bottom: 16px;
  font-size: 0.9rem; line-height: 1.55; border: 1px solid transparent;
}
.status-banner.trial { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.status-banner.validated { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.status-banner.blocked { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.status-banner.message { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.status-banner .icon { font-size: 1.3rem; line-height: 1.2; }
.status-banner strong { display: block; margin-bottom: 2px; }

/* Sections / advisory */
.section-grid { display: grid; gap: 14px; }
@media (min-width: 720px) {
  .section-grid.cols-2 { grid-template-columns: 1fr 1fr; }
  .section-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
}
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--primary-light); color: var(--primary-dark);
  padding: 4px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 700;
}
.chip.blue { background: var(--accent-blue-light); color: #1e40af; }
.chip.orange { background: var(--accent-orange-light); color: #92400e; }
.chip.lime { background: #ecfccb; color: #3f6212; }

.variety {
  border: 1.5px solid var(--border); border-radius: var(--radius-lg);
  padding: 16px; background: var(--white);
}
.variety.released { border-color: #bbf7d0; background: #f0fdf4; }
.variety h4 { font-size: 1.05rem; font-weight: 800; margin-bottom: 4px; color: var(--primary-dark); }
.variety .code { font-size: 0.75rem; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.variety p { font-size: 0.88rem; color: var(--gray-700); margin-top: 6px; }
.variety .meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.table-wrap { overflow-x: auto; margin-top: 8px; }
table.advisory { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.advisory th, table.advisory td { padding: 9px 10px; text-align: left; border-bottom: 1px solid #f1f5f9; }
table.advisory th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; background: var(--gray-50); }
table.advisory tr:hover td { background: #fcfdfe; }

.pest-row {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 0; border-bottom: 1px solid #f1f5f9;
}
.pest-row:last-child { border-bottom: none; }
.pest-row .emoji { font-size: 1.4rem; line-height: 1.2; }
.pest-row h5 { font-size: 0.95rem; font-weight: 700; margin-bottom: 3px; }
.pest-row p { font-size: 0.87rem; color: var(--gray-700); }
.pest-row .note { font-size: 0.8rem; color: var(--muted); margin-top: 3px; font-style: italic; }

.econ-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 640px) { .econ-grid { grid-template-columns: repeat(4, 1fr); } }
.econ {
  background: var(--gray-50); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px; text-align: center;
}
.econ .k { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; }
.econ .v { font-size: 1.15rem; font-weight: 800; color: var(--primary-dark); margin-top: 4px; }

.source-list { list-style: none; }
.source-list li { margin-bottom: 8px; }
.source-list a {
  color: var(--accent-blue); font-size: 0.88rem; text-decoration: none; font-weight: 500;
}
.source-list a:hover { text-decoration: underline; }

/* Calendar */
.cal-toolbar {
  display: flex; gap: 8px; align-items: center; justify-content: space-between;
  flex-wrap: wrap; margin-bottom: 14px;
}
.month-nav { display: flex; gap: 6px; align-items: center; }
.month-nav button {
  width: 38px; height: 38px; border-radius: 10px; border: 1.5px solid var(--border);
  background: var(--white); font-size: 1.1rem; font-weight: 700; cursor: pointer; color: var(--gray-700);
}
.month-nav button:hover { border-color: var(--primary); color: var(--primary); }
.month-label { font-size: 1.1rem; font-weight: 800; min-width: 140px; text-align: center; color: var(--primary-dark); }

.task {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px; border: 1.5px solid var(--border); border-radius: var(--radius-lg);
  background: var(--white); margin-bottom: 10px; transition: all 0.15s;
}
.task.key { border-color: #86efac; background: #f0fdf4; }
.task.done { opacity: 0.65; background: var(--gray-100); border-color: var(--gray-200); }
.task .check {
  width: 28px; height: 28px; border-radius: 8px; border: 2px solid var(--gray-300);
  background: var(--white); cursor: pointer; flex-shrink: 0; display: flex;
  align-items: center; justify-content: center; font-size: 1rem; color: transparent; margin-top: 2px;
}
.task.done .check { background: var(--primary); border-color: var(--primary); color: #fff; }
.task .body { flex: 1; min-width: 0; }
.task .body h5 { font-size: 0.95rem; font-weight: 600; line-height: 1.45; }
.task.done .body h5 { text-decoration: line-through; color: var(--muted); }
.task .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }

.empty-state {
  text-align: center; padding: 36px 16px; color: var(--muted);
}
.empty-state .icon { font-size: 2.4rem; margin-bottom: 10px; }

/* Profile modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5);
  z-index: 250; display: none; align-items: center; justify-content: center; padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal-sheet {
  background: white; border-radius: var(--radius-lg);
  width: 100%; max-width: 420px; max-height: 90vh; overflow-y: auto; padding: 24px;
}
.profile-field {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; background: var(--gray-50); border-radius: var(--radius);
  margin-bottom: 10px; border: 1px solid var(--border); gap: 8px;
}
.profile-field .label { font-size: 0.84rem; color: var(--muted); }
.profile-field .value { font-size: 0.95rem; font-weight: 600; text-align: right; }

/* Toast */
.toast-stack {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 24px;
  z-index: 400; display: flex; flex-direction: column; gap: 8px;
  width: calc(100% - 32px); max-width: 420px;
}
.toast {
  background: #111827; color: #fff; padding: 13px 16px; border-radius: var(--radius);
  font-size: 0.9rem; box-shadow: var(--shadow-md); text-align: center;
}
.toast.ok { background: var(--primary); }
.toast.err { background: var(--danger); }

/* Admin */
.admin-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff; padding: 16px 20px;
}
.admin-header-inner {
  max-width: 1180px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.admin-header h1 { font-size: 1.2rem; font-weight: 700; margin: 0; }
.admin-header p { font-size: 0.82rem; opacity: 0.9; margin: 0; }
.admin-header .auth-btn { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.35); color: #fff; }
.admin-header .auth-btn:hover { background: rgba(255,255,255,.22); }

.wrap { max-width: 1180px; margin: 0 auto; padding: 20px 16px; }
.gate { min-height: 70vh; display: flex; align-items: center; justify-content: center; }
.gate .card { width: 100%; max-width: 420px; text-align: center; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 18px; }
@media (min-width: 700px) { .stats { grid-template-columns: repeat(5, 1fr); } }
.stat {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow);
}
.stat .k { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; }
.stat .v { font-size: 1.7rem; font-weight: 800; line-height: 1.2; margin-top: 4px; color: var(--primary-dark); }

.toolbar {
  display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px;
}
@media (min-width: 720px) { .toolbar { flex-direction: row; align-items: center; justify-content: space-between; } }
.tabs { display: flex; gap: 6px; background: var(--gray-100); padding: 4px; border-radius: 999px; overflow-x: auto; }
.tab {
  border: none; background: transparent; cursor: pointer; white-space: nowrap;
  padding: 8px 14px; border-radius: 999px; font-size: 0.84rem; font-weight: 700;
  color: var(--muted); transition: all 0.15s; font-family: inherit;
}
.tab.active { background: var(--white); color: var(--primary); box-shadow: var(--shadow); }

.registry { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow: hidden; }
.registry-head, .registry-row {
  display: grid; grid-template-columns: 1.3fr 1.1fr .9fr .55fr .9fr 1.8fr;
  gap: 10px; align-items: center;
}
.registry-head {
  padding: 12px 14px; background: var(--gray-50); border-bottom: 1px solid var(--border);
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); font-weight: 700;
}
.registry-row { padding: 13px 14px; border-bottom: 1px solid #f1f5f9; }
.registry-row:last-child { border-bottom: none; }
.registry-row:hover { background: #fcfdfe; }
.registry-row.is-pending { box-shadow: inset 3px 0 0 #94a3b8; }
.registry-row.is-trial { box-shadow: inset 3px 0 0 var(--warning); }
.registry-row.is-validated { box-shadow: inset 3px 0 0 var(--primary); }
.registry-row.is-blocked { box-shadow: inset 3px 0 0 var(--danger); opacity: 0.75; }

.cell { font-size: 0.88rem; min-width: 0; }
.cell .muted { color: var(--muted); font-size: 0.78rem; }
.phone { font-weight: 700; font-variant-numeric: tabular-nums; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 999px; font-size: 0.74rem; font-weight: 700; white-space: nowrap;
}
.badge.pending { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.badge.trial { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.badge.validated { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.badge.blocked { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }

.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.mini {
  border: 1px solid var(--border); background: var(--white); cursor: pointer;
  padding: 7px 11px; border-radius: 8px; font-size: 0.78rem; font-weight: 700;
  color: var(--muted); font-family: inherit; transition: all 0.15s;
}
.mini:hover { border-color: var(--primary); color: var(--primary); background: #f0fdf4; }
.mini.approve { background: var(--primary); border-color: var(--primary); color: #fff; }
.mini.danger:hover { border-color: var(--danger); color: #fff; background: var(--danger); }

.msg-row { display: flex; gap: 6px; align-items: center; margin-top: 8px; width: 100%; }
.msg-row input {
  flex: 1; min-width: 0; font-family: inherit; font-size: 0.82rem;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--white); color: var(--text); outline: none;
}
.msg-row input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.12); }

@media (max-width: 860px) {
  .registry { background: transparent; border: none; box-shadow: none; overflow: visible; }
  .registry-head { display: none; }
  .registry-row {
    grid-template-columns: 1fr; gap: 8px; background: var(--white);
    border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow);
  }
  .cell[data-label]::before {
    content: attr(data-label);
    display: block; font-size: 0.68rem; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--muted); font-weight: 700; margin-bottom: 2px;
  }
  .actions .mini { flex: 1; justify-content: center; }
}

/* Footer */
.app-footer {
  text-align: center; font-size: 0.78rem; color: var(--muted);
  padding: 20px 8px 10px; line-height: 1.6;
}
.app-footer a { color: var(--accent-blue); text-decoration: none; }

/* Install banner */
.install-banner {
  position: fixed; left: 16px; right: 16px; bottom: 16px;
  z-index: 300; display: none; align-items: center; gap: 12px;
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px 16px;
  box-shadow: var(--shadow-md); max-width: 480px; margin: 0 auto;
}
.install-banner.show { display: flex; }
.install-banner .txt { flex: 1; min-width: 0; font-size: 0.85rem; color: var(--gray-700); }
.install-banner .txt strong { display: block; font-size: 0.95rem; color: var(--gray-900); margin-bottom: 2px; }

/* Section label */
.section-label { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 8px; }

/* Period tabs (calendar months) */
.period-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.period-tab {
  border: 1.5px solid var(--border); background: var(--white); cursor: pointer;
  padding: 6px 11px; border-radius: 999px; font-size: 0.78rem; font-weight: 700;
  color: var(--gray-700); font-family: inherit; transition: all 0.15s;
}
.period-tab:hover { border-color: var(--primary); color: var(--primary); }
.period-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* Utilities */
.hidden { display: none !important; }
.text-muted { color: var(--muted); }
.mt-8 { margin-top: 8px; }
.mb-0 { margin-bottom: 0; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.small { font-size: 0.82rem; }
.center { text-align: center; }
.hint { font-size: 0.78rem; opacity: 0.85; margin-top: 4px; }

@media (max-width: 640px) {
  .app-container { padding: 8px 12px 72px; }
  .card { padding: 16px; }
  .header-logo { height: 40px; }
  .header-title h1 { font-size: 1.15rem; }
  .install-banner { left: 12px; right: 12px; bottom: 12px; flex-wrap: wrap; }
}
