*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  background-color: #FFFFFF;
  color: #09090B;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.mono {
  font-family: 'JetBrains Mono', monospace;
}

h1, h2, h3, h4, h5, h6 {
  letter-spacing: -0.03em;
  font-weight: 700;
  color: #09090B;
}

a {
  color: #09090B;
  text-decoration: underline;
  text-underline-offset: 2px;
}

a:hover {
  color: #71717A;
}

/* App Header & Navigation */
.header-bar {
  border-bottom: 1px solid #E4E4E7;
  background-color: #FFFFFF;
  position: sticky;
  top: 0;
  z-index: 50;
  width: 100%;
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.badge-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #FAFAFA;
  border: 1px solid #E4E4E7;
  padding: 2px 8px;
  border-radius: 4px;
  color: #09090B;
}

.brand-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0;
  white-space: nowrap;
}

.brand-sub {
  font-size: 12px;
  color: #71717A;
  margin-left: 8px;
  font-weight: 500;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 4px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: #000000;
  color: #FFFFFF;
  border-color: #000000;
}

.btn-primary:hover {
  background: #27272A;
  border-color: #27272A;
  color: #FFFFFF;
}

.btn-outline {
  background: #FFFFFF;
  color: #09090B;
  border-color: #E4E4E7;
}

.btn-outline:hover {
  background: #FAFAFA;
  border-color: #A1A1AA;
}

.btn-sm {
  font-size: 12px;
  padding: 5px 10px;
}

/* Layout Container */
.main-wrapper {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 20px 60px 20px;
  min-width: 0;
}

/* Banner / Intro */
.lead-header {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid #E4E4E7;
}

.lead-header h1 {
  font-size: 28px;
  line-height: 1.2;
  margin-bottom: 8px;
}

.lead-header p {
  font-size: 14px;
  color: #71717A;
  max-width: 880px;
}

/* Ad Placement Boxes */
.ad-slot-wrapper {
  margin: 24px 0;
  border: 1px solid #E4E4E7;
  background: #FAFAFA;
  border-radius: 4px;
  padding: 12px 16px;
  text-align: center;
  min-height: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.ad-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #A1A1AA;
  margin-bottom: 4px;
  font-weight: 600;
}

.ad-content-placeholder {
  font-size: 12px;
  color: #71717A;
  font-family: 'JetBrains Mono', monospace;
}

/* Main Grid Layout */
.app-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.app-grid > * {
  min-width: 0;
}

/* Panel Cards */
.panel-card {
  background: #FAFAFA;
  border: 1px solid #E4E4E7;
  border-radius: 4px;
  padding: 20px;
  min-width: 0;
}

.panel-title-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #E4E4E7;
}

.panel-title {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  color: #71717A;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10B981;
}

/* Form & Input Elements */
.control-group {
  margin-bottom: 16px;
}

.control-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #09090B;
}

.control-hint {
  font-size: 11px;
  color: #71717A;
  font-weight: normal;
}

.input-control, .select-control, .textarea-control {
  width: 100%;
  background: #FFFFFF;
  border: 1px solid #E4E4E7;
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  color: #09090B;
}

.input-control:focus, .select-control:focus, .textarea-control:focus {
  outline: none;
  border-color: #000000;
}

.range-slider {
  width: 100%;
  height: 4px;
  background: #E4E4E7;
  outline: none;
  -webkit-appearance: none;
  border-radius: 2px;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #000000;
  cursor: pointer;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: #E4E4E7;
  padding: 2px;
  border-radius: 4px;
  gap: 2px;
}

.seg-btn {
  background: transparent;
  border: none;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 3px;
  color: #71717A;
  text-align: center;
}

.seg-btn.active {
  background: #FFFFFF;
  color: #09090B;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* File Upload & Drop Zone */
.dropzone-box {
  border: 1px dashed #A1A1AA;
  background: #FFFFFF;
  border-radius: 4px;
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.dropzone-box:hover {
  border-color: #000000;
}

.dropzone-icon {
  font-size: 18px;
  margin-bottom: 4px;
  color: #71717A;
}

/* Data Metric Cards */
.metric-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.metric-card {
  background: #FAFAFA;
  border: 1px solid #E4E4E7;
  border-radius: 4px;
  padding: 12px 14px;
  min-width: 0;
}

.metric-card-label {
  font-size: 11px;
  color: #71717A;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.03em;
  margin-bottom: 4px;
}

.metric-card-val {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #09090B;
  font-family: 'JetBrains Mono', monospace;
}

.metric-card-sub {
  font-size: 11px;
  color: #71717A;
  margin-top: 2px;
}

/* Canvas & Charting */
.chart-container {
  background: #FFFFFF;
  border: 1px solid #E4E4E7;
  border-radius: 4px;
  padding: 14px;
  margin-bottom: 20px;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.chart-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.chart-legend {
  display: flex;
  gap: 14px;
  font-size: 11px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.legend-color {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.chart-canvas-wrap {
  width: 100%;
  height: 220px;
  position: relative;
}

canvas#telemetryChart {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* Results & Telemetry Table */
.table-wrapper {
  background: #FFFFFF;
  border: 1px solid #E4E4E7;
  border-radius: 4px;
  overflow-x: auto;
  margin-bottom: 20px;
}

.table-native {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 12px;
}

.table-native th {
  background: #FAFAFA;
  padding: 10px 12px;
  font-weight: 700;
  color: #09090B;
  border-bottom: 1px solid #E4E4E7;
  white-space: nowrap;
}

.table-native td {
  padding: 10px 12px;
  border-bottom: 1px solid #E4E4E7;
  color: #09090B;
  white-space: nowrap;
}

.table-native tr:last-child td {
  border-bottom: none;
}

.table-native tr:hover td {
  background: #FAFAFA;
}

.pill-anomaly {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
}

.pill-critical {
  background: #FEE2E2;
  color: #991B1B;
  border: 1px solid #FECACA;
}

.pill-warning {
  background: #FEF3C7;
  color: #92400E;
  border: 1px solid #FDE68A;
}

.pill-normal {
  background: #ECFDF5;
  color: #065F46;
  border: 1px solid #A7F3D0;
}

/* Affiliate Recommendation Callout */
.affiliate-recom-box {
  background: #FAFAFA;
  border: 1px solid #E4E4E7;
  border-radius: 4px;
  padding: 16px;
  margin: 20px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.affiliate-info h4 {
  font-size: 13px;
  margin-bottom: 4px;
}

.affiliate-info p {
  font-size: 12px;
  color: #71717A;
}

/* Technical Methodology Section */
.methodology-section {
  border-top: 1px solid #E4E4E7;
  padding-top: 32px;
  margin-top: 40px;
}

.methodology-section h2 {
  font-size: 20px;
  margin-bottom: 12px;
}

.methodology-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-top: 16px;
}

.methodology-card {
  background: #FAFAFA;
  border: 1px solid #E4E4E7;
  border-radius: 4px;
  padding: 16px;
}

.methodology-card h3 {
  font-size: 14px;
  margin-bottom: 8px;
}

.methodology-card p {
  font-size: 12px;
  color: #71717A;
  line-height: 1.6;
}

/* Floating Coffee Widget */
.support-widget-float {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #000000;
  color: #FFFFFF;
  border: 1px solid #27272A;
  padding: 8px 14px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 100;
}

.support-widget-float:hover {
  background: #27272A;
  color: #FFFFFF;
}

/* Modal UI */
.modal-scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}

.modal-scrim.hidden {
  display: none !important;
}

.modal-card {
  background: #FFFFFF;
  border: 1px solid #E4E4E7;
  border-radius: 6px;
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 25px rgba(0,0,0,0.1);
  padding: 24px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-header h3 {
  font-size: 16px;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #71717A;
}

.modal-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  background: #FAFAFA;
  border: 1px solid #E4E4E7;
  border-radius: 4px;
  padding: 2px;
  margin-bottom: 16px;
}

.modal-tab-btn {
  background: transparent;
  border: none;
  padding: 6px 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  color: #71717A;
  border-radius: 3px;
  white-space: normal;
  word-break: break-word;
  text-align: center;
}

.modal-tab-btn.active {
  background: #FFFFFF;
  color: #09090B;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.form-group {
  margin-bottom: 12px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 4px;
}

/* Footer */
.structural-footer {
  border-top: 1px solid #E4E4E7;
  background: #FAFAFA;
  padding: 32px 20px;
  color: #71717A;
  font-size: 12px;
}

.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 24px;
}

.footer-col h5 {
  color: #09090B;
  font-size: 13px;
  margin-bottom: 10px;
}

.footer-col ul {
  list-style: none;
}

.footer-col li {
  margin-bottom: 6px;
}

.footer-bottom {
  max-width: 1280px;
  margin: 24px auto 0 auto;
  padding-top: 16px;
  border-top: 1px solid #E4E4E7;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
}

/* Responsiveness Guard */
@media (max-width: 900px) {
  .app-grid {
    grid-template-columns: 1fr;
  }
  .metric-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .methodology-grid {
    grid-template-columns: 1fr;
  }
  .footer-inner {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .main-wrapper {
    padding: 16px 12px 60px 12px;
  }
  .panel-card {
    padding: 14px;
  }
  .header-inner {
    padding: 10px 12px;
  }
  .brand-sub {
    display: none;
  }
  .metric-row {
    grid-template-columns: 1fr;
  }
  .segmented-control {
    grid-template-columns: 1fr;
  }
  .affiliate-recom-box {
    flex-direction: column;
    align-items: flex-start;
  }
}