:root {
  --indigo-dark: #1e1b4b;
  --indigo-mid: #4f46e5;
  --indigo: #6366f1;
  --indigo-light: #818cf8;
  --indigo-pale: #e0e7ff;
  --indigo-bg: #f5f3ff;
  --amber: #d97706;
  --amber-light: #fef3c7;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #cbd5e1;
  --white: #ffffff;
  --slate-dark: #0f172a;
  --slate-panel: rgba(30, 41, 59, 0.4);
  --success: #10b981;
  --danger: #ef4444;
}

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

body {
  font-family: 'Mukta', 'Noto Sans Devanagari', 'Inter', sans-serif;
  background: radial-gradient(circle at top, #1e1b4b 0%, #0f172a 100%);
  min-height: 100vh;
  color: #cbd5e1;
  padding-top: 75px; /* space for topbar */
}

/* Topbar styling */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1000;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 15px;
}

.topbar-title h1 {
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.topbar-logo-title {
  color: var(--indigo-light);
  letter-spacing: -0.02em;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.back-btn {
  text-decoration: none;
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.3s;
  background: rgba(255, 255, 255, 0.08);
  padding: 6px 16px;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.back-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.03);
}

.user-badge,
.balance-badge {
  background: rgba(255, 255, 255, 0.08);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #a5b4fc;
}

.balance-badge span #balanceAmount {
  color: #fbbf24;
  font-weight: 800;
}

/* Main Container */
.main {
  max-width: 1200px;
  margin: 20px auto;
  padding: 0 16px 40px;
}

/* Tabs styling */
.tabs {
  display: flex;
  background: var(--slate-panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 14px 14px 0 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: none;
  overflow: hidden;
}

.tab-btn {
  flex: 1;
  padding: 14px 20px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  color: #cbd5e1;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  transition: all 0.2s ease-in-out;
}

.tab-btn:last-child {
  border-right: none;
}

.tab-btn.active {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.2);
}

.tab-btn:hover:not(.active) {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* Panel Content */
.panel {
  background: var(--slate-panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-top: none;
  border-radius: 0 0 14px 14px;
  padding: 25px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.tab-content {
  display: none;
}

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

/* Section Head */
.section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 10px;
  padding: 10px 16px;
  margin-bottom: 20px;
}

.section-head h3 {
  font-size: 15px;
  font-weight: 700;
  color: #a5b4fc;
}

/* PDF Upload Area */
.pdf-upload-section {
  background: rgba(15, 23, 42, 0.4);
  border: 1.5px dashed rgba(99, 102, 241, 0.3);
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 25px;
  transition: all 0.3s ease;
}

.pdf-upload-section:hover {
  border-color: var(--indigo);
  background: rgba(15, 23, 42, 0.6);
}

.pdf-upload-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 15px;
}

.pdf-upload-icon {
  font-size: 32px;
}

.pdf-upload-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: #f1f5f9;
}

.pdf-upload-header p {
  font-size: 12px;
  color: #94a3b8;
}

.pdf-upload-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.pdf-upload-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: white;
  padding: 10px 20px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.pdf-upload-label:hover {
  transform: translateY(-1.5px);
  box-shadow: 0 6px 15px rgba(99, 102, 241, 0.3);
}

.pdf-upload-status {
  font-size: 13px;
  font-weight: 600;
  color: #94a3b8;
}

/* Form Styling */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
  margin-bottom: 25px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 13px;
  font-weight: 700;
  color: #94a3b8;
}

.form-group input,
.form-group select {
  padding: 10px 12px;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  color: #f1f5f9;
  font-size: 14px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group select option {
  background: #0f172a;
  color: #f1f5f9;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.photo-sign-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 25px;
}

/* Photo Box Custom Input */
.photo-box {
  border: 2px dashed rgba(255, 255, 255, 0.12);
  background: rgba(15, 23, 42, 0.3);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
}

.photo-box:hover {
  border-color: var(--indigo-light);
  background: rgba(15, 23, 42, 0.5);
  color: #fff;
}

.photo-box img {
  max-height: 100px;
  max-width: 100%;
  object-fit: contain;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Family Members Table Section */
.family-section {
  margin-bottom: 25px;
}

.land-table-wrap {
  overflow-x: auto;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.3);
}

.land-table-wrap table {
  width: 100%;
  border-collapse: collapse;
}

.land-table-wrap th,
.land-table-wrap td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 13.5px;
}

.land-table-wrap th {
  background: rgba(15, 23, 42, 0.6);
  color: #cbd5e1;
  font-weight: 700;
}

.land-table-wrap td input {
  width: 100%;
  padding: 6px 10px;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  color: #f1f5f9;
  font-family: inherit;
  font-size: 13px;
  outline: none;
}

.land-table-wrap td input:focus {
  border-color: var(--indigo);
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-primary {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: white;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-green {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
}

.btn-green:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-outline {
  background: rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
}

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

.btn-row {
  display: flex;
  gap: 12px;
  margin-top: 25px;
  flex-wrap: wrap;
}

/* Preview Section Controls */
.preview-controls {
  background: rgba(30, 41, 59, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 15px 20px;
  margin-bottom: 25px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
}

.preview-controls p {
  font-size: 13.5px;
  font-weight: 700;
  color: #cbd5e1;
}

/* Card Visual Layout for Preview */
.card-print-area {
  display: flex;
  flex-wrap: wrap;
  gap: 30px;
  justify-content: center;
  margin: 30px auto;
  width: 100%;
}

.card-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.card-label {
  font-size: 12px;
  font-weight: 800;
  color: #94a3b8;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Card Sizing (Standard Credit Card Ratio scaled for screen rendering) */
.card-front, .card-back {
  width: 342px;
  height: 216px;
  background: #fff;
  color: #000;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #c5b6a7;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  position: relative;
  font-family: 'Mukta', 'Noto Sans Devanagari', 'Inter', sans-serif !important;
  user-select: none;
}

/* Card Overlay content wrapper */
.card-overlay {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 0;
  background: #ffffff;
}

/* Card Front Elements styling */
.cf-header, .cb-header {
  background: #c5b6a7;
  padding: 4px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 42px;
  color: #37251b;
  border-bottom: none;
}

.cf-logo-container {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cf-logo-img {
  height: 32px;
  width: auto;
}

.cf-header-text-block {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.cf-dept-title {
  font-size: 8.5px;
  font-weight: 800;
  line-height: 1.15;
  color: #37251b;
}

.cf-govt-title {
  font-size: 7px;
  font-weight: 700;
  line-height: 1;
  color: #37251b;
  opacity: 0.95;
}

.cf-annp-logo {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cf-annp-logo svg {
  width: 100%;
  height: 100%;
}

/* Card Front Body details */
.cf-body {
  flex: 1;
  display: flex;
  padding: 6px 10px;
  gap: 10px;
  align-items: flex-start;
  position: relative;
  background: #ffffff;
}

.cf-photo-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 54px;
  flex-shrink: 0;
  margin-top: 14px;
}

.cf-photo {
  width: 54px;
  height: 66px;
  background: #fafafa;
  border: 1px solid #000000;
  border-radius: 2px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cf-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cf-photo-placeholder {
  font-size: 8px;
  color: #94a3b8;
  font-weight: 700;
  text-align: center;
}

.cf-date-label {
  font-size: 7px;
  font-weight: 700;
  color: #000000;
  margin-top: 4px;
  line-height: 1.2;
  text-align: center;
}

.cf-info-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: #000000;
  line-height: 1.2;
}

.cf-main-title {
  font-size: 18px;
  font-weight: 800;
  color: #0b2265;
  text-align: center;
  margin-top: 1px;
  line-height: 1.1;
  font-family: 'Inter', sans-serif !important;
}

.cf-sub-title {
  font-size: 10px;
  font-weight: 800;
  color: #000000;
  text-align: center;
  margin-bottom: 4px;
  line-height: 1.1;
}

.cf-info-details {
  display: flex;
  flex-direction: column;
  gap: 2.5px;
}

.cf-row {
  display: flex;
  align-items: flex-start;
  font-size: 9.5px;
}

.cf-lbl {
  font-weight: 800;
  width: 84px;
  flex-shrink: 0;
  color: #000000;
}

.cf-val {
  font-weight: 700;
  color: #333333;
  word-break: break-word;
}

/* Bottom area with card number and signatures */
.cf-footer {
  padding: 0 10px 4px 10px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  height: 40px;
  background: #ffffff;
}

.cf-sign-block {
  width: 55px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
}

.cf-sign-img {
  width: 50px;
  height: 18px;
  object-fit: contain;
}

.cf-sign-line {
  width: 100%;
  border-top: 0.5px solid #000000;
  margin-top: 1px;
}

.cf-sign-lbl {
  font-size: 6.5px;
  font-weight: 700;
  color: #000000;
  width: 100%;
  text-align: center;
  margin-top: 2px;
}

.cf-number-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.cf-no-lbl {
  font-size: 9px;
  font-weight: 800;
  color: #000000;
  line-height: 1;
  text-align: center;
}

.cf-no-val {
  font-size: 17px;
  font-weight: 900;
  color: #0b2265;
  line-height: 1.15;
  font-family: 'Inter', sans-serif !important;
  letter-spacing: 0.3px;
  text-align: center;
}

.cf-bottom-bar {
  background: #c5b6a7;
  color: #37251b;
  font-size: 7.5px;
  font-weight: 700;
  padding: 2px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 20px;
  border-top: none;
}

/* Card Back Side (Table Layout) */
.cb-table-container {
  flex: 1;
  padding: 6px 10px;
  overflow: hidden;
  background: #ffffff;
  z-index: 2;
}

.cb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 7.5px;
  line-height: 1.15;
}

.cb-table th, .cb-table td {
  border: none;
  border-bottom: 0.5px solid #e2e8f0;
  padding: 3.5px 4px;
  text-align: left;
}

.cb-table th {
  background: #ffffff;
  color: #000000;
  font-weight: 800;
  border-bottom: 1px solid #94a3b8;
}

.cb-table td {
  color: #333333;
  font-weight: 700;
}

.cb-table tr:nth-child(even) {
  background-color: #f8f9fa;
}

.cb-table td.center, .cb-table th.center {
  text-align: center;
}

.cb-footer-bar {
  background: #c5b6a7;
  color: #37251b;
  font-size: 7.5px;
  font-weight: 700;
  padding: 2.5px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 20px;
  border-top: none;
}

/* Interactive crop overlay */
#cropModal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(8px);
}

.crop-card {
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 24px;
  border-radius: 16px;
  max-width: 500px;
  width: 100%;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.crop-card h3 {
  margin-top: 0;
  margin-bottom: 15px;
  font-size: 16px;
  color: #fff;
  font-weight: 700;
  text-align: center;
}

.crop-canvas-wrap {
  overflow: hidden;
  height: 300px;
  width: 100%;
  margin-bottom: 15px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: #0f172a;
}

.crop-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 15px;
}

/* Insufficient Balance Modal */
#insufficientBalanceModal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.balance-card {
  background: #fff;
  color: #0f172a;
  border-radius: 16px;
  padding: 24px;
  max-width: 380px;
  width: 90%;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  text-align: center;
  border: 1px solid #eaeaea;
}

.balance-icon-circle {
  width: 60px;
  height: 60px;
  background: #fef2f2;
  border: 1px solid #fee2e2;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 15px auto;
  font-size: 24px;
}

.balance-card h3 {
  margin-top: 0;
  margin-bottom: 10px;
  color: #dc2626;
  font-size: 18px;
  font-weight: 700;
}

.balance-card p {
  color: #64748b;
  font-size: 13.5px;
  line-height: 1.6;
  margin-bottom: 20px;
}

.balance-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* FAQ Accordion Styling */
.faq-section {
  margin-top: 40px;
  background: var(--slate-panel);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 25px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
}

.faq-title {
  font-size: 16px;
  color: #fff;
  font-weight: 700;
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.faq-item {
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding: 12px 0;
}

.faq-item:last-child {
  border-bottom: none;
}

.faq-q {
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  font-size: 14.5px;
  font-weight: 600;
  color: #cbd5e1;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  transition: color 0.2s;
  font-family: inherit;
}

.faq-q:hover {
  color: var(--indigo-light);
}

.faq-q span {
  font-size: 12px;
  transition: transform 0.2s;
}

.faq-item.open .faq-q span {
  transform: rotate(180deg);
}

.faq-a {
  display: none;
  padding-top: 10px;
  font-size: 13.5px;
  color: #94a3b8;
  line-height: 1.6;
}

.faq-item.open .faq-a {
  display: block;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 99999;
}

.loading-card {
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 30px 40px;
  border-radius: 20px;
  text-align: center;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(99, 102, 241, 0.1);
  border-top-color: #6366f1;
  border-radius: 50%;
  margin: 0 auto 20px auto;
  animation: spin 1s linear infinite;
}

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

/* Print CSS Media Query Override */
@media print {
  body {
    background: #fff !important;
    color: #000 !important;
    padding-top: 0 !important;
    margin: 0 !important;
    min-height: auto !important;
  }

  .topbar,
  .tabs,
  .panel,
  .faq-section,
  .preview-controls,
  #formSection,
  .loading-overlay,
  #cropModal,
  #insufficientBalanceModal,
  .card-label {
    display: none !important;
  }

  .main {
    margin: 0 !important;
    padding: 0 !important;
    max-width: none !important;
  }

  .card-print-area {
    display: block !important;
    visibility: visible !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
  }

  .card-wrapper {
    page-break-inside: avoid;
    page-break-after: always;
    margin-bottom: 20px;
  }

  .card-front, .card-back {
    visibility: visible !important;
    display: block !important;
    box-shadow: none !important;
    border: 1px solid #777 !important;
  }
}

/* Mobile responsive layout */
@media (max-width: 768px) {
  body {
    padding-top: 130px;
  }

  .topbar {
    flex-direction: column;
    gap: 10px;
    padding: 12px;
  }

  .topbar-left {
    width: 100%;
    justify-content: space-between;
  }

  .topbar-right {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }

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

  .photo-sign-row {
    grid-template-columns: 1fr;
  }

  .preview-controls {
    flex-direction: column;
    text-align: center;
  }
}
