/* Blueprint Theme - Subcontractor Invoice Generator */
:root {
  --bg-dark: #0b1329;
  --bg-darker: #070d1e;
  --bg-card: #131f37;
  --bg-input: #1e293b;
  --border-dark: #233554;
  --border-light: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #f8fafc;
  --primary-blue: #0284c7;
  --amber: #f59e0b;
  --amber-dark: #d97706;
  --emerald: #10b981;
  --emerald-dark: #059669;
  --radius: 8px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font-sans); background: #f1f5f9; color: var(--text-main); line-height: 1.5; -webkit-font-smoothing: antialiased; }

/* Header - Rock Solid Zero-Wrap */
.site-header {
  background: var(--bg-dark);
  color: #fff;
  padding: 10px 20px;
  border-bottom: 2px solid var(--amber);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}
.header-container {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
}
.header-brand-wrap {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  white-space: nowrap;
}
.brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: #fff;
  white-space: nowrap;
}
.logo-icon {
  background: var(--amber);
  color: var(--bg-dark);
  padding: 5px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.brand-text {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.brand-name {
  font-size: 1.18rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  white-space: nowrap;
}
.brand-tag {
  font-size: 0.65rem;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: var(--amber);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 800;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.text-amber { color: var(--amber); }
.text-emerald { color: var(--emerald); }
.text-slate { color: #334155; }

.header-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  flex-shrink: 0;
}
.nav-select-group {
  flex-shrink: 0;
}
.nav-select {
  background: var(--bg-card);
  color: #f1f5f9;
  border: 1px solid var(--border-dark);
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  white-space: nowrap;
  max-width: 175px;
  transition: all 0.15s ease;
}
.nav-select:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
}
.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  white-space: nowrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1.2;
}
.btn-amber { background: var(--amber); color: var(--bg-dark); }
.btn-amber:hover { background: var(--amber-dark); }
.btn-outline-amber { background: transparent; color: var(--amber); border: 1px solid var(--amber); }
.btn-outline-amber:hover { background: rgba(245, 158, 11, 0.12); }
.btn-emerald { background: var(--emerald); color: #fff; }
.btn-emerald:hover { background: var(--emerald-dark); }
.btn-slate { background: #334155; color: #fff; }
.btn-slate:hover { background: #1e293b; }
.btn-outline-slate { background: transparent; color: #475569; border: 1px solid #cbd5e1; }
.btn-outline-slate:hover { background: #e2e8f0; }

/* Header Responsive Control - Strict Zero-Wrap Single Line Box Model Guardrail */
@media (max-width: 1120px) {
  .site-header { padding: 8px 14px; }
  .nav-select { max-width: 135px; font-size: 0.78rem; padding: 5px 8px; }
  .btn { padding: 6px 10px; font-size: 0.78rem; }
  .brand-name { font-size: 1.05rem; }
}

@media (max-width: 860px) {
  .site-header { padding: 6px 12px; }
  .header-container { flex-direction: row; justify-content: space-between; align-items: center; gap: 8px; }
  .header-brand-wrap { flex-shrink: 0; }
  .brand-name { font-size: 0.94rem; }
  .brand-tag { display: none; }
  .header-nav { display: flex; gap: 6px; align-items: center; flex-shrink: 0; width: auto; }
  .nav-select { width: auto; max-width: 110px; font-size: 0.72rem; padding: 5px 6px; }
  .nav-actions { flex-shrink: 0; }
  .nav-actions .btn { padding: 5px 8px; font-size: 0.72rem; white-space: nowrap; }
}

@media (max-width: 520px) {
  .site-header { padding: 5px 10px; }
  .brand-name { font-size: 0.88rem; }
  .header-nav .nav-select-group:nth-child(2) { display: none; } /* Hide 2nd dropdown on narrow mobile */
  .nav-select { max-width: 105px; font-size: 0.70rem; padding: 4px 6px; }
  .nav-actions .btn span { display: none; } /* Show compact print icon only */
  .nav-actions .btn { padding: 5px 8px; }
}

/* Hero */
.hero-section {
  background: var(--bg-dark);
  color: #fff;
  padding: 32px 20px 24px;
  text-align: center;
}
.hero-container {
  max-width: 960px;
  margin: 0 auto;
}
.hero-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(245, 158, 11, 0.12);
  color: var(--amber);
  padding: 4px 12px;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 14px;
  border: 1px solid rgba(245, 158, 11, 0.3);
  max-width: 90%;
  box-sizing: border-box;
  text-align: center;
  line-height: 1.3;
}
.live-indicator {
  width: 7px;
  height: 7px;
  background: var(--amber);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--amber);
  display: inline-block;
}
.hero-title {
  font-size: clamp(1.6rem, 3.2vw, 2.3rem);
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.25;
  margin-bottom: 10px;
  text-wrap: balance;
}
.hero-subtitle {
  font-size: clamp(0.88rem, 1.8vw, 1.02rem);
  color: #94a3b8;
  max-width: 760px;
  margin: 0 auto 18px;
  line-height: 1.55;
  text-wrap: pretty;
}

/* Trade Quick Bar */
.trade-quick-bar {
  display: flex;
  gap: 8px;
  justify-content: flex-start;
  overflow-x: auto;
  padding: 6px 4px 10px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.trade-quick-bar::-webkit-scrollbar { display: none; }
@media (min-width: 1024px) {
  .trade-quick-bar {
    justify-content: center;
    flex-wrap: wrap;
  }
}
.trade-chip {
  background: var(--bg-card);
  color: #e2e8f0;
  padding: 5px 12px;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--border-dark);
  white-space: nowrap;
  transition: all 0.15s;
  flex-shrink: 0;
}
.trade-chip:hover, .trade-chip.active {
  background: var(--amber);
  color: var(--bg-dark);
  border-color: var(--amber);
  font-weight: 700;
}

/* Main Studio Layout */
.studio-section { padding: 28px 20px 60px; max-width: 1440px; margin: 0 auto; }
.studio-grid { display: grid; grid-template-columns: 46% 54%; gap: 28px; align-items: start; }
.studio-grid > * { min-width: 0; max-width: 100%; }
@media (max-width: 1080px) { .studio-grid { grid-template-columns: 1fr; } }

/* Form Panel */
.form-panel { background: #fff; border-radius: 12px; padding: 24px; box-shadow: 0 4px 16px rgba(0,0,0,0.06); border: 1px solid #e2e8f0; }
.panel-section-title { font-size: 1.05rem; font-weight: 700; color: #0f172a; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; border-bottom: 2px solid #f1f5f9; padding-bottom: 8px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.form-group { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.form-group label { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; color: #475569; letter-spacing: 0.5px; }
.form-control { border: 1px solid #cbd5e1; border-radius: 6px; padding: 8px 12px; font-size: 0.9rem; color: #0f172a; outline: none; transition: border-color 0.15s; font-family: inherit; }
.form-control:focus { border-color: var(--primary-blue); box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.15); }
.mono-input { font-family: var(--font-mono); }

/* Billing Mode Selector */
.mode-tabs { display: flex; background: #f1f5f9; padding: 4px; border-radius: 8px; margin-bottom: 16px; gap: 4px; }
.mode-tab { flex: 1; padding: 8px; text-align: center; border-radius: 6px; font-size: 0.8rem; font-weight: 700; border: none; background: transparent; color: #64748b; cursor: pointer; transition: all 0.15s; }
.mode-tab.active { background: #fff; color: var(--bg-dark); box-shadow: 0 2px 4px rgba(0,0,0,0.05); }

/* Line Items Table */
.items-table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.items-table th { background: #f8fafc; text-align: left; padding: 8px; font-size: 0.75rem; font-weight: 700; color: #64748b; border-bottom: 2px solid #e2e8f0; }
.items-table td { padding: 6px 4px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.item-remove-btn { background: #fee2e2; color: #dc2626; border: none; border-radius: 4px; padding: 4px 8px; cursor: pointer; font-size: 0.75rem; font-weight: 700; }
.item-remove-btn:hover { background: #fecaca; }

/* Responsive Tables & Mobile Overflows */
#itemsSectionWrapper {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  display: block;
}
.form-panel, .preview-panel, .paper-invoice {
  max-width: 100%;
  box-sizing: border-box;
}

@media (max-width: 768px) {
  body, html {
    overflow-x: hidden;
    max-width: 100vw;
  }
  .site-header {
    max-width: 100vw;
  }
  .hero-section {
    padding: 24px 12px 18px;
    max-width: 100vw;
    overflow-x: hidden;
  }
  .studio-section {
    padding: 16px 8px 40px;
    max-width: 100vw;
    overflow-x: hidden;
  }
  .form-panel {
    padding: 14px 10px;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }
  .form-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .form-control {
    max-width: 100%;
    box-sizing: border-box;
  }
  .paper-invoice {
    padding: 14px 8px;
    min-height: auto;
    font-size: 0.80rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .paper-header {
    flex-direction: column;
    gap: 8px;
  }
  .paper-meta {
    text-align: left;
  }
  .paper-addresses {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 8px;
  }
  .paper-title {
    font-size: 1.25rem;
  }
  .summary-box {
    width: 100%;
  }
  .paper-signatures {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

/* Paper Invoice Preview */
.preview-sticky-wrap { position: sticky; top: 80px; }
.paper-invoice { background: #fff; border-radius: 4px; padding: 40px; box-shadow: 0 10px 30px rgba(0,0,0,0.12); border: 1px solid #cbd5e1; font-size: 0.9rem; min-height: 800px; display: flex; flex-direction: column; justify-content: space-between; }
.paper-header { display: flex; justify-content: space-between; border-bottom: 3px solid #0f172a; padding-bottom: 16px; margin-bottom: 20px; }
.paper-title { font-size: 1.8rem; font-weight: 900; color: #0f172a; text-transform: uppercase; letter-spacing: 0.5px; }
.paper-meta { font-family: var(--font-mono); font-size: 0.85rem; text-align: right; }
.paper-addresses { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; background: #f8fafc; padding: 14px; border-radius: 6px; border: 1px solid #e2e8f0; }
.address-box h4 { font-size: 0.75rem; color: #64748b; text-transform: uppercase; margin-bottom: 4px; font-weight: 800; }
.address-box p { font-size: 0.9rem; font-weight: 600; color: #0f172a; white-space: pre-line; }

.paper-table { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
.paper-table th { background: #0f172a; color: #fff; text-align: left; padding: 8px 10px; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px; }
.paper-table td { padding: 8px 10px; border-bottom: 1px solid #e2e8f0; font-size: 0.85rem; }
.paper-table td.mono { font-family: var(--font-mono); text-align: right; }
.paper-table th.mono { text-align: right; }

.paper-summary { display: flex; justify-content: flex-end; margin-bottom: 20px; }
.summary-box { width: 300px; border: 1px solid #cbd5e1; border-radius: 6px; overflow: hidden; }
.summary-row { display: flex; justify-content: space-between; padding: 6px 12px; font-size: 0.85rem; border-bottom: 1px solid #f1f5f9; }
.summary-row.total-due { background: #0f172a; color: #fff; font-weight: 800; font-size: 1.05rem; padding: 10px 12px; }
.summary-row.retainage-row { background: #fffbeb; color: #b45309; font-weight: 700; }

.paper-lien-waiver { background: #f8fafc; border: 1px dashed #cbd5e1; padding: 12px; border-radius: 6px; font-size: 0.75rem; color: #475569; line-height: 1.4; margin-bottom: 20px; }
.paper-signatures { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 20px; padding-top: 14px; border-top: 1px solid #e2e8f0; }
.sign-line { border-bottom: 1px solid #0f172a; height: 36px; margin-bottom: 4px; display: flex; align-items: flex-end; font-family: 'Brush Script MT', cursive, sans-serif; font-size: 1.3rem; color: #0284c7; }
.sign-label { font-size: 0.7rem; font-weight: 700; color: #64748b; text-transform: uppercase; }

/* Simulator Section */
.simulator-section { padding: 40px 20px; max-width: 1400px; margin: 0 auto; }
.simulator-card { background: var(--bg-dark); color: #fff; border-radius: 12px; padding: 32px; border: 1px solid var(--border-dark); }
.simulator-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.simulator-title { font-size: 1.6rem; font-weight: 800; margin-top: 6px; }
.simulator-desc { color: #94a3b8; font-size: 0.95rem; }
.simulator-body { display: grid; grid-template-columns: 1.2fr 1fr; gap: 32px; }
@media (max-width: 840px) { .simulator-body { grid-template-columns: 1fr; } }
.slider-group { margin-bottom: 18px; }
.slider-label-row { display: flex; justify-content: space-between; font-weight: 700; font-size: 0.85rem; margin-bottom: 8px; color: #cbd5e1; }
.slider-val { font-family: var(--font-mono); color: var(--amber); }
.range-slider { width: 100%; height: 8px; border-radius: 4px; background: #334155; outline: none; cursor: pointer; accent-color: var(--amber); }
.simulator-results { display: flex; flex-direction: column; gap: 12px; justify-content: center; }
.sim-metric-card { background: var(--bg-card); padding: 16px; border-radius: 8px; border: 1px solid var(--border-dark); display: flex; flex-direction: column; gap: 2px; }
.sim-metric-card.highlight-amber { border-color: rgba(245, 158, 11, 0.4); background: rgba(245, 158, 11, 0.08); }
.sim-metric-card.highlight-emerald { border-color: rgba(16, 185, 129, 0.4); background: rgba(16, 185, 129, 0.08); }
.metric-title { font-size: 0.75rem; text-transform: uppercase; font-weight: 800; color: #94a3b8; letter-spacing: 0.5px; }
.metric-value { font-size: 1.6rem; font-weight: 900; font-family: var(--font-mono); }
.metric-sub { font-size: 0.75rem; color: #64748b; }

/* FAQ Section */
.faq-section { padding: 60px 20px; max-width: 1200px; margin: 0 auto; }
.section-title { font-size: 1.8rem; font-weight: 800; color: #0f172a; margin: 8px 0; }
.section-subtitle { color: #64748b; font-size: 0.95rem; margin-bottom: 30px; }
.faq-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 768px) { .faq-grid { grid-template-columns: 1fr; } }
.faq-card { background: #fff; padding: 20px; border-radius: 8px; border: 1px solid #e2e8f0; box-shadow: 0 2px 8px rgba(0,0,0,0.03); }
.faq-question { font-size: 0.95rem; font-weight: 700; color: #0f172a; margin-bottom: 8px; display: flex; gap: 8px; align-items: flex-start; }
.faq-q-badge { background: var(--bg-dark); color: #fff; padding: 2px 6px; border-radius: 4px; font-size: 0.7rem; }
.faq-answer { font-size: 0.85rem; color: #475569; line-height: 1.5; }

/* Footer */
.site-footer { background: var(--bg-dark); color: #94a3b8; padding: 60px 20px 30px; border-top: 1px solid var(--border-dark); font-size: 0.85rem; }
.footer-container { max-width: 1400px; margin: 0 auto; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1.2fr; gap: 36px; margin-bottom: 40px; }
@media (max-width: 900px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .footer-grid { grid-template-columns: 1fr; } }
.footer-heading { color: #fff; font-size: 0.9rem; font-weight: 800; text-transform: uppercase; margin-bottom: 14px; letter-spacing: 0.5px; }
.footer-links { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.footer-links a { color: #94a3b8; text-decoration: none; transition: color 0.15s; }
.footer-links a:hover { color: var(--amber); }
.affiliate-disclosure { background: rgba(255,255,255,0.03); border: 1px solid var(--border-dark); padding: 16px; border-radius: 8px; font-size: 0.75rem; color: #64748b; line-height: 1.5; margin-bottom: 30px; }
.footer-bottom { border-top: 1px solid var(--border-dark); padding-top: 20px; text-align: center; font-size: 0.8rem; color: #64748b; }

/* PRINT STYLES - 100% US Letter High Fidelity */
@media print {
  @page { size: letter portrait; margin: 12mm; }
  body { background: #fff !important; color: #000 !important; font-size: 9pt; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .no-print, .site-header, .hero-section, .form-panel, .simulator-section, .faq-section, .site-footer, .modal-overlay { display: none !important; }
  .studio-section { padding: 0 !important; max-width: 100% !important; margin: 0 !important; }
  .studio-grid { display: block !important; }
  .preview-sticky-wrap { position: static !important; }
  .paper-invoice { border: none !important; box-shadow: none !important; padding: 0 !important; min-height: auto !important; }
  .paper-header { border-bottom: 2pt solid #000 !important; }
  .paper-table th { background: #000 !important; color: #fff !important; font-size: 8pt !important; }
  .paper-table td { border-bottom: 0.5pt solid #ccc !important; font-size: 8pt !important; padding: 5px !important; }
  .summary-row.total-due { background: #000 !important; color: #fff !important; }
  .paper-lien-waiver { border: 0.5pt dashed #888 !important; background: #fff !important; }
  .sign-line { border-bottom: 1pt solid #000 !important; }
  .break-inside-avoid { break-inside: avoid; page-break-inside: avoid; }
}
