*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: #FFFFFF;
  color: #09090B;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

code, pre, .mono-data {
  font-family: 'JetBrains Mono', monospace;
}

.main-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header & Top Navigation */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 20px;
  border-bottom: 1px solid #E4E4E7;
  margin-bottom: 24px;
}

.brand-group {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #09090B;
}

.brand-sub {
  font-size: 13px;
  color: #71717A;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Buttons & Interactive Elements */
.btn-primary {
  background: #000000;
  color: #FFFFFF;
  border: 1px solid #000000;
  padding: 8px 16px;
  font-size: 13px;
  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.9;
}

.btn-secondary {
  background: #FAFAFA;
  color: #09090B;
  border: 1px solid #E4E4E7;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-secondary:hover {
  background: #E4E4E7;
}

.btn-sm {
  padding: 4px 8px;
  font-size: 12px;
}

.btn-remove {
  background: transparent;
  color: #71717A;
  border: 1px solid #E4E4E7;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.btn-remove:hover {
  color: #09090B;
  border-color: #09090B;
}

.link-secondary {
  font-size: 13px;
  color: #71717A;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 500;
}

.link-secondary:hover {
  color: #09090B;
}

/* Advertisement Slot */
.ad-slot-wrapper {
  margin: 0 0 28px 0;
  border: 1px dashed #E4E4E7;
  padding: 16px;
  border-radius: 4px;
  background-color: #FAFAFA;
}

.ad-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #71717A;
  margin-bottom: 8px;
  font-weight: 600;
}

.ad-slot-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.ad-copy-title {
  font-size: 13px;
  font-weight: 700;
  color: #09090B;
}

.ad-copy-desc {
  font-size: 12px;
  color: #71717A;
}

/* Tool Layout Grid */
.app-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
  margin-bottom: 32px;
}

.app-grid > * {
  min-width: 0;
}

.panel-card {
  background: #FAFAFA;
  border: 1px solid #E4E4E7;
  border-radius: 4px;
  padding: 24px;
  min-width: 0;
}

.panel-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
  color: #09090B;
}

.panel-subtitle {
  font-size: 12px;
  color: #71717A;
  margin-bottom: 20px;
}

/* Quick Dimension Presets */
.preset-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.preset-chip {
  background: #FFFFFF;
  border: 1px solid #E4E4E7;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  font-weight: 600;
}

.preset-chip:hover {
  background: #F4F4F5;
  border-color: #09090B;
}

/* Item Batch Table */
.items-table-container {
  overflow-x: auto;
  margin-bottom: 16px;
  border: 1px solid #E4E4E7;
  border-radius: 4px;
  background: #FFFFFF;
}

.batch-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  text-align: left;
}

.batch-table th {
  background: #FAFAFA;
  padding: 10px 8px;
  border-bottom: 1px solid #E4E4E7;
  font-weight: 600;
  color: #71717A;
}

.batch-table td {
  padding: 8px;
  border-bottom: 1px solid #E4E4E7;
  vertical-align: middle;
}

.batch-table tr:last-child td {
  border-bottom: none;
}

.table-input {
  width: 100%;
  padding: 6px 8px;
  font-size: 12px;
  border: 1px solid #E4E4E7;
  border-radius: 4px;
  background: #FFFFFF;
  font-family: 'JetBrains Mono', monospace;
}

.table-input:focus {
  outline: 1px solid #000000;
}

/* Results & Metric Cards */
.results-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.metric-hero {
  background: #FFFFFF;
  border: 1px solid #E4E4E7;
  border-radius: 4px;
  padding: 20px;
  text-align: center;
}

.metric-hero-label {
  font-size: 12px;
  text-transform: uppercase;
  color: #71717A;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.metric-hero-value {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -0.04em;
  margin: 4px 0;
  font-family: 'JetBrains Mono', monospace;
}

.metric-hero-desc {
  font-size: 12px;
  color: #71717A;
}

.breakdown-list {
  background: #FFFFFF;
  border: 1px solid #E4E4E7;
  border-radius: 4px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.breakdown-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding-bottom: 6px;
  border-bottom: 1px solid #FAFAFA;
}

.breakdown-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.breakdown-label {
  color: #71717A;
}

.breakdown-val {
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
}

/* Reclass Risk Alert Box */
.warning-box {
  background: #FFFFFF;
  border-left: 3px solid #000000;
  border-top: 1px solid #E4E4E7;
  border-right: 1px solid #E4E4E7;
  border-bottom: 1px solid #E4E4E7;
  padding: 12px;
  font-size: 12px;
  border-radius: 4px;
  line-height: 1.4;
}

.warning-title {
  font-weight: 700;
  margin-bottom: 2px;
}

/* Micro-Affiliate Injection */
.affiliate-block {
  margin-top: 20px;
  background: #FFFFFF;
  border: 1px solid #E4E4E7;
  border-radius: 4px;
  padding: 14px;
}

.affiliate-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: #71717A;
  margin-bottom: 4px;
}

.affiliate-title {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 4px;
}

.affiliate-text {
  font-size: 11px;
  color: #71717A;
  margin-bottom: 8px;
}

/* Methodology & Reference Section */
.methodology-section {
  border-top: 1px solid #E4E4E7;
  padding: 32px 0;
  margin-top: 24px;
}

.section-head {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 16px;
}

.methodology-content {
  font-size: 13px;
  color: #71717A;
  line-height: 1.6;
}

.methodology-content p {
  margin-bottom: 12px;
}

.methodology-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.methodology-card {
  background: #FAFAFA;
  border: 1px solid #E4E4E7;
  padding: 16px;
  border-radius: 4px;
}

.methodology-card h4 {
  color: #09090B;
  font-size: 13px;
  margin-bottom: 6px;
  font-weight: 700;
}

/* Reference NMFC Table */
.nmfc-reference-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  margin-top: 12px;
  background: #FFFFFF;
  border: 1px solid #E4E4E7;
}

.nmfc-reference-table th, .nmfc-reference-table td {
  padding: 6px 10px;
  border: 1px solid #E4E4E7;
  text-align: left;
}

.nmfc-reference-table th {
  background: #FAFAFA;
  color: #71717A;
}

/* Footer Section */
.site-footer {
  border-top: 1px solid #E4E4E7;
  background-color: #FAFAFA;
  padding: 24px 0;
  margin-top: auto;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 12px;
  color: #71717A;
}

.footer-links {
  display: flex;
  gap: 16px;
}

.footer-links a, .footer-links button {
  color: #71717A;
  background: transparent;
  border: none;
  font-size: 12px;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}

.footer-links a:hover, .footer-links button:hover {
  color: #09090B;
}

/* Modal Scrim & Form System */
.modal-scrim {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(9, 9, 11, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
}

.modal-scrim.hidden {
  display: none !important;
}

.modal-card {
  background: #FFFFFF;
  border: 1px solid #E4E4E7;
  border-radius: 4px;
  width: 100%;
  max-width: 520px;
  padding: 24px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 18px;
  color: #71717A;
  cursor: pointer;
}

/* Segmented Control Inside Modal */
.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: #FAFAFA;
  border: 1px solid #E4E4E7;
  border-radius: 4px;
  padding: 2px;
  margin-bottom: 20px;
}

.tab-btn {
  background: transparent;
  border: none;
  font-size: 11px;
  font-weight: 600;
  color: #71717A;
  padding: 8px 4px;
  cursor: pointer;
  border-radius: 3px;
  text-align: center;
}

.tab-btn.active {
  background: #FFFFFF;
  color: #09090B;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #09090B;
}

.input-control {
  width: 100%;
  border: 1px solid #E4E4E7;
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  background: #FAFAFA;
}

.input-control:focus {
  outline: 1px solid #000000;
  background: #FFFFFF;
}

textarea.input-control {
  min-height: 80px;
  resize: vertical;
}

.modal-alert {
  padding: 10px;
  font-size: 12px;
  margin-top: 12px;
  border-radius: 4px;
  display: none;
}

.modal-alert.success {
  display: block;
  background: #F4F4F5;
  border: 1px solid #E4E4E7;
  color: #09090B;
}

/* Support Floating Coffee Widget */
.support-widget-float {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #000000;
  color: #FFFFFF;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  text-decoration: none;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
  z-index: 999;
  border: 1px solid #E4E4E7;
}

.support-widget-float:hover {
  background: #27272A;
}

/* Mobile Responsiveness Overrides */
@media (max-width: 860px) {
  .app-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .main-wrapper {
    padding: 14px 12px;
  }
  .panel-card {
    padding: 16px 12px;
  }
  .site-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .nav-actions {
    width: 100%;
    justify-content: flex-start;
  }
  .segmented-control {
    grid-template-columns: 1fr;
  }
  .tab-btn {
    padding: 6px 4px;
    font-size: 11px;
    white-space: normal;
    word-break: break-word;
  }
  .footer-content {
    flex-direction: column;
    align-items: flex-start;
  }
}