*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: #FFFFFF;
  color: #09090B;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

code, pre, .mono {
  font-family: 'JetBrains Mono', monospace;
}

/* Typography Overrides */
h1, h2, h3, h4, h5, h6 {
  letter-spacing: -0.03em;
  font-weight: 700;
  color: #09090B;
}

h1 {
  font-size: clamp(1.75rem, 3.5vw, 2.5rem);
  font-weight: 800;
  line-height: 1.15;
}

h2 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

p {
  color: #71717A;
}

/* Nav & Top Header */
.site-header {
  border-bottom: 1px solid #E4E4E7;
  background-color: #FFFFFF;
  position: sticky;
  top: 0;
  z-index: 40;
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #09090B;
}

.brand-badge {
  background: #000000;
  color: #FFFFFF;
  font-size: 0.75rem;
  font-weight: 800;
  padding: 4px 6px;
  border-radius: 4px;
  letter-spacing: -0.02em;
}

.brand-title {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  display: inline-block;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.link-secondary {
  color: #71717A;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 4px;
  transition: color 0.15s ease;
}

.link-secondary:hover {
  color: #09090B;
}

.btn-primary {
  background: #000000;
  color: #FFFFFF;
  border: 1px solid #000000;
  padding: 7px 14px;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s ease;
}

.btn-primary:hover {
  opacity: 0.88;
}

.btn-outline {
  background: #FFFFFF;
  color: #09090B;
  border: 1px solid #E4E4E7;
  padding: 7px 14px;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease;
}

.btn-outline:hover {
  background: #FAFAFA;
  border-color: #D4D4D8;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.8125rem;
}

.btn-danger-outline {
  background: #FFFFFF;
  color: #DC2626;
  border: 1px solid #FCA5A5;
  padding: 5px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
}

.btn-danger-outline:hover {
  background: #FEF2F2;
}

/* Layout System */
.main-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 48px;
  flex: 1;
  width: 100%;
}

.hero-section {
  margin-bottom: 24px;
  border-bottom: 1px solid #E4E4E7;
  padding-bottom: 20px;
}

.hero-subtitle {
  font-size: 1rem;
  color: #71717A;
  margin-top: 8px;
  max-width: 780px;
}

.hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.badge-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  background: #FAFAFA;
  border: 1px solid #E4E4E7;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #09090B;
}

/* App Grid */
.app-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  margin-bottom: 32px;
}

@media (min-width: 1024px) {
  .app-grid {
    grid-template-columns: 360px minmax(0, 1fr);
    align-items: start;
  }
}

.app-grid > * {
  min-width: 0;
}

.panel-card {
  background: #FAFAFA;
  border: 1px solid #E4E4E7;
  border-radius: 6px;
  padding: 20px;
  min-width: 0;
  position: relative;
}

.panel-card-white {
  background: #FFFFFF;
  border: 1px solid #E4E4E7;
  border-radius: 6px;
  padding: 20px;
  min-width: 0;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.panel-title {
  font-size: 1rem;
  font-weight: 700;
  color: #09090B;
}

.panel-subtitle {
  font-size: 0.8125rem;
  color: #71717A;
}

/* Forms and Inputs */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #09090B;
  margin-bottom: 5px;
}

.input-control, .select-control {
  width: 100%;
  padding: 8px 10px;
  font-size: 0.875rem;
  font-family: inherit;
  color: #09090B;
  background-color: #FFFFFF;
  border: 1px solid #E4E4E7;
  border-radius: 4px;
  outline: none;
}

.input-control:focus, .select-control:focus {
  border-color: #09090B;
}

.input-mono {
  font-family: 'JetBrains Mono', monospace;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Config Subsections */
.sub-panel {
  background: #FFFFFF;
  border: 1px solid #E4E4E7;
  border-radius: 4px;
  padding: 12px;
  margin-bottom: 12px;
}

.sub-panel-title {
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #71717A;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.grant-item, .employee-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #F4F4F5;
}

.grant-item:last-child, .employee-item:last-child {
  border-bottom: none;
}

/* Matrix Table Styling */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 16px;
  border: 1px solid #E4E4E7;
  border-radius: 4px;
  background: #FFFFFF;
}

.matrix-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.8125rem;
}

.matrix-table th {
  background: #FAFAFA;
  font-weight: 600;
  color: #09090B;
  padding: 10px 12px;
  border-bottom: 1px solid #E4E4E7;
  border-right: 1px solid #F4F4F5;
  white-space: nowrap;
}

.matrix-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #E4E4E7;
  border-right: 1px solid #F4F4F5;
  vertical-align: middle;
}

.matrix-table tr:last-child td {
  border-bottom: none;
}

.matrix-table th:last-child, .matrix-table td:last-child {
  border-right: none;
}

.matrix-table tfoot td {
  background: #FAFAFA;
  font-weight: 700;
  color: #09090B;
  border-top: 2px solid #E4E4E7;
}

.split-input {
  width: 72px;
  padding: 5px 6px;
  font-size: 0.8125rem;
  font-family: 'JetBrains Mono', monospace;
  border: 1px solid #E4E4E7;
  border-radius: 4px;
  text-align: right;
}

.split-input:focus {
  border-color: #09090B;
}

/* Compliance Status Indicators */
.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
}

.status-valid {
  background: #F0FDF4;
  color: #166534;
  border: 1px solid #BBF7D0;
}

.status-invalid {
  background: #FEF2F2;
  color: #991B1B;
  border: 1px solid #FECACA;
}

.status-warning {
  background: #FFFBEB;
  color: #92400E;
  border: 1px solid #FDE68A;
}

/* Summary Grid */
.stat-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 16px;
  margin-bottom: 16px;
}

.stat-box {
  background: #FAFAFA;
  border: 1px solid #E4E4E7;
  border-radius: 4px;
  padding: 12px;
}

.stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #71717A;
  font-weight: 600;
}

.stat-val {
  font-size: 1.25rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: #09090B;
  margin-top: 4px;
}

.stat-note {
  font-size: 0.75rem;
  color: #71717A;
  margin-top: 2px;
}

/* AdSense Placements */
.ad-container {
  margin: 32px 0;
  padding: 20px;
  background: #FAFAFA;
  border: 1px dashed #D4D4D8;
  border-radius: 6px;
  text-align: center;
  clear: both;
}

.ad-label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #A1A1AA;
  margin-bottom: 12px;
  font-weight: 600;
}

.ad-slot-box {
  min-height: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #FFFFFF;
  border: 1px solid #E4E4E7;
  border-radius: 4px;
  padding: 14px;
}

.ad-text-main {
  font-size: 0.875rem;
  font-weight: 600;
  color: #09090B;
}

.ad-text-sub {
  font-size: 0.75rem;
  color: #71717A;
  margin-top: 2px;
}

/* Affiliate Recommendation Callout */
.affiliate-box {
  background: #FAFAFA;
  border: 1px solid #E4E4E7;
  border-radius: 4px;
  padding: 14px;
  margin-top: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.affiliate-info {
  flex: 1;
  min-width: 220px;
}

.affiliate-title {
  font-size: 0.8125rem;
  font-weight: 700;
  color: #09090B;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.affiliate-desc {
  font-size: 0.8125rem;
  color: #71717A;
  margin-top: 2px;
}

/* Methodology Section (SEO E-E-A-T) */
.methodology-card {
  background: #FFFFFF;
  border: 1px solid #E4E4E7;
  border-radius: 6px;
  padding: 24px;
  margin-top: 32px;
}

.methodology-title {
  font-size: 1.125rem;
  margin-bottom: 12px;
}

.methodology-text {
  font-size: 0.875rem;
  color: #52525B;
  line-height: 1.6;
  margin-bottom: 12px;
}

.methodology-steps {
  list-style-type: decimal;
  padding-left: 20px;
  margin-bottom: 16px;
  font-size: 0.875rem;
  color: #52525B;
  line-height: 1.6;
}

.methodology-steps li {
  margin-bottom: 6px;
}

/* Footer Section */
.site-footer {
  background-color: #FAFAFA;
  border-top: 1px solid #E4E4E7;
  padding: 32px 20px;
  margin-top: auto;
  font-size: 0.8125rem;
  color: #71717A;
}

.footer-container {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

@media (min-width: 768px) {
  .footer-container {
    grid-template-columns: 2fr 1fr 1fr;
  }
}

.footer-col h4 {
  font-size: 0.875rem;
  color: #09090B;
  margin-bottom: 8px;
}

.footer-links {
  list-style: none;
}

.footer-links li {
  margin-bottom: 6px;
}

.footer-links a {
  color: #71717A;
  text-decoration: none;
}

.footer-links a:hover {
  color: #09090B;
}

.footer-bottom {
  max-width: 1200px;
  margin: 24px auto 0;
  padding-top: 16px;
  border-top: 1px solid #E4E4E7;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

/* Modal Overlay & Styling */
.modal-scrim {
  position: fixed;
  inset: 0;
  background-color: rgba(9, 9, 11, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-scrim.hidden {
  display: none !important;
}

.modal-window {
  background: #FFFFFF;
  border: 1px solid #E4E4E7;
  border-radius: 6px;
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  position: relative;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 1.25rem;
  line-height: 1;
  color: #71717A;
  cursor: pointer;
  padding: 4px;
}

.modal-close-btn:hover {
  color: #09090B;
}

.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 4px;
  background: #FAFAFA;
  padding: 4px;
  border: 1px solid #E4E4E7;
  border-radius: 4px;
  margin-bottom: 16px;
}

.segment-btn {
  background: transparent;
  border: none;
  padding: 6px 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #71717A;
  border-radius: 3px;
  cursor: pointer;
  text-align: center;
}

.segment-btn.active {
  background: #000000;
  color: #FFFFFF;
}

/* Floating Coffee Widget */
.support-widget-float {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #000000;
  color: #FFFFFF;
  border: 1px solid #27272A;
  border-radius: 50px;
  padding: 8px 14px;
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 50;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: transform 0.15s ease;
}

.support-widget-float:hover {
  transform: translateY(-2px);
}

/* Mobile Strict Safety Guard */
@media (max-width: 600px) {
  .main-wrapper, .panel-card, .panel-card-white {
    padding: 14px;
  }
  
  .segmented-control {
    grid-template-columns: 1fr;
  }

  .nav-actions .btn-outline {
    display: none;
  }
  
  .hero-tags {
    gap: 4px;
  }
}