:root {
  --primary: #0f4c81;
  --primary-hover: #0a355c;
  --primary-light: #eef5fc;
  --accent: #10b981;
  --bg-gradient: linear-gradient(135deg, #0f2027 0%, #203a43 50%, #2c5364 100%);
  --surface: rgba(255, 255, 255, 0.95);
  --surface-glass: rgba(255, 255, 255, 0.88);
  --border: #e2e8f0;
  --text-dark: #1e293b;
  --text-muted: #64748b;
  --radius-lg: 16px;
  --radius-md: 10px;
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
  background: var(--bg-gradient);
  min-height: 100vh;
  color: var(--text-dark);
  padding: 20px;
  display: flex;
  justify-content: center;
}

.app-container {
  width: 100%;
  max-width: 1280px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Header & Banner */
.header-card {
  background: var(--surface-glass);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius-lg);
  padding: 24px 30px;
  box-shadow: var(--shadow-lg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo-badge {
  background: var(--primary);
  color: #fff;
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 22px;
  box-shadow: 0 4px 12px rgba(15, 76, 129, 0.3);
}

.brand-info h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-info p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
}

.agent-badge {
  background: var(--primary-light);
  border: 1px solid rgba(15, 76, 129, 0.15);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 12px;
  color: var(--primary);
  font-weight: 600;
  display: inline-flex;
  gap: 8px;
}

/* Stats Row */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--surface-glass);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(255, 255, 255, 0.4);
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.stat-content h3 {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-dark);
}

.stat-content p {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

/* Search Card */
.search-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px 30px;
  box-shadow: var(--shadow-lg);
}

.search-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 14px;
}

.search-controls {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

@media (max-width: 900px) {
  .search-controls {
    grid-template-columns: 1fr;
  }
}

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

.field-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
}

.input-group input, .input-group select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13.5px;
  background: #f8fafc;
  outline: none;
  transition: all 0.2s;
}

.input-group input:focus, .input-group select:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(15, 76, 129, 0.12);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-outline:hover {
  background: var(--primary-light);
}

/* Results Section */
.results-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-lg);
  min-height: 350px;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.table-container {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

th {
  background: #f1f5f9;
  color: var(--text-muted);
  font-weight: 600;
  text-align: left;
  padding: 12px 16px;
  border-bottom: 2px solid var(--border);
}

td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-dark);
}

tbody tr {
  transition: background 0.15s;
}

tbody tr:hover {
  background: #f8fafc;
}

.tag-ntn {
  font-family: monospace;
  font-weight: 700;
  background: #e0f2fe;
  color: #0369a1;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12.5px;
}

.tag-status {
  background: #ecfdf5;
  color: #047857;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11.5px;
}

/* Modal / Certificate View */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(6px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 20px;
}

.modal-content {
  background: #fff;
  width: 100%;
  max-width: 900px;
  max-height: 92vh;
  border-radius: 12px;
  overflow-y: auto;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
  position: relative;
  display: flex;
  flex-direction: column;
}

.modal-actions {
  position: sticky;
  top: 0;
  background: #f8fafc;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
}

.cert-preview-body {
  padding: 24px;
  background: #fff;
}

/* Formal Tax Certificate Paper Layout */
.tax-cert-paper {
  border: 2px solid var(--primary);
  padding: 24px;
  background: #fff;
  position: relative;
}

.cert-header {
  text-align: center;
  border-bottom: 2px solid var(--primary);
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.cert-header h2 {
  font-size: 18px;
  color: var(--primary);
  font-weight: 800;
  letter-spacing: 0.5px;
}

.cert-header h3 {
  font-size: 14px;
  font-weight: 700;
  color: #334155;
  margin-top: 4px;
}

.cert-header p {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}

.cert-meta-bar {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  padding: 8px 14px;
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 16px;
}

.cert-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.cert-box {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  overflow: hidden;
}

.cert-box-title {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
  font-size: 11.5px;
  padding: 6px 12px;
  border-bottom: 1px solid #cbd5e1;
}

.cert-box-body {
  padding: 10px 12px;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cert-row {
  display: flex;
}

.cert-label {
  font-weight: 700;
  width: 105px;
  color: #475569;
}

.cert-val {
  color: #0f172a;
  flex: 1;
}

.cert-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-bottom: 16px;
}

.cert-table th {
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  text-align: center;
  padding: 8px;
  border: 1px solid var(--primary);
}

.cert-table td {
  padding: 8px;
  border: 1px solid #cbd5e1;
}

.cert-table tr.total-row td {
  background: #e2e8f0;
  font-weight: 800;
  color: var(--primary);
}

.words-box {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 16px;
}

.cert-declaration {
  font-size: 11px;
  font-style: italic;
  color: #475569;
  line-height: 1.5;
  margin-bottom: 40px;
}

.cert-signatures {
  display: flex;
  justify-content: space-between;
  margin-top: 30px;
  padding: 0 20px;
}

.sig-block {
  text-align: center;
  width: 200px;
}

.sig-line {
  border-top: 1px solid #64748b;
  margin-bottom: 6px;
}

.sig-title {
  font-weight: 700;
  font-size: 12px;
}

.sig-sub {
  font-size: 10px;
  color: var(--text-muted);
}

/* Print Rules */
@media print {
  body {
    background: #fff;
    padding: 0;
  }
  .app-container, 
  .modal-actions, 
  .no-print {
    display: none !important;
  }
  .modal-overlay {
    position: static;
    background: transparent;
    backdrop-filter: none;
    display: block !important;
    padding: 0;
  }
  .modal-content {
    max-width: 100%;
    box-shadow: none;
    max-height: none;
    overflow: visible;
  }
  .cert-preview-body {
    padding: 0;
  }
  .tax-cert-paper {
    border: none;
    padding: 0;
  }
}
