/* =============================================
   InstaBoQ — Main Stylesheet
   Target: architects & contractors in India
   ============================================= */

:root {
  --teal:        #1D9E75;
  --teal-light:  #E1F5EE;
  --teal-dark:   #0F6E56;
  --teal-hover:  #18896A;
  --text:        #1a1a1a;
  --text-sec:    #6b7280;
  --border:      #e5e7eb;
  --bg:          #ffffff;
  --surface:     #f9fafb;
  --radius:      6px;
  --shadow:      0 1px 3px rgba(0,0,0,0.07);
  --shadow-md:   0 4px 12px rgba(0,0,0,0.09);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
}

a { color: var(--teal); text-decoration: none; }
a:hover { color: var(--teal-dark); }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---- Navbar ---- */
.navbar {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.brand {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.3px;
  text-decoration: none;
}
.brand span { color: var(--teal); }

.nav-links {
  list-style: none;
  display: flex;
  gap: 4px;
}
.nav-links a {
  color: var(--text-sec);
  font-size: 14px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius);
  transition: color 0.15s, background 0.15s;
}
.nav-links a:hover, .nav-links a.active {
  color: var(--teal);
  background: var(--teal-light);
}

/* ---- Buttons ---- */
.btn {
  display: inline-block;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
  text-decoration: none;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary  { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-hover); color: #fff; }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--teal);
  color: var(--teal);
  padding: 7px 14px;
}
.btn-outline:hover { background: var(--teal-light); }

.btn-ghost {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-sec);
  padding: 7px 14px;
}
.btn-ghost:hover { border-color: var(--teal); color: var(--teal); background: var(--teal-light); }

.btn-full { width: 100%; text-align: center; padding: 11px; }

/* ---- Hero ---- */
.hero {
  padding: 64px 0 56px;
  border-bottom: 1px solid var(--border);
}

.hero-inner { text-align: center; }

.pill-badge {
  display: inline-block;
  background: var(--teal-light);
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 14px;
  border-radius: 20px;
  margin-bottom: 20px;
}

.hero h1 {
  font-size: 32px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 12px;
  line-height: 1.25;
}

.hero-sub {
  font-size: 15px;
  color: var(--text-sec);
  max-width: 520px;
  margin: 0 auto 36px;
  line-height: 1.7;
}

/* Mode cards */
.mode-cards {
  display: flex;
  gap: 16px;
  justify-content: center;
  max-width: 480px;
  margin: 0 auto 20px;
}

.mode-card {
  flex: 1;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 20px 16px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.mode-card:hover { border-color: var(--teal); box-shadow: var(--shadow); }
.mode-card.selected { border-color: var(--teal); background: var(--teal-light); }

.mode-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.mode-card-desc {
  font-size: 12px;
  color: var(--text-sec);
  line-height: 1.5;
  margin-bottom: 10px;
}

.mode-badge {
  display: inline-block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 11px;
  color: var(--text-sec);
  padding: 2px 10px;
  font-weight: 500;
}
.mode-card.selected .mode-badge {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
}

.cta-wrap { max-width: 480px; margin: 0 auto; }

/* ---- Page layout ---- */
.page-container { padding: 48px 0 60px; }
.page-header { margin-bottom: 28px; }
.page-header h1 {
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--text);
}
.page-header p { color: var(--text-sec); margin-top: 4px; }

/* ---- Estimator Quick ---- */
.estimator-wrap {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.form-panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  box-shadow: var(--shadow);
}

.results-panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  box-shadow: var(--shadow);
}

.form-panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.sample-note {
  font-size: 12px;
  color: var(--text-sec);
  font-style: italic;
}

.panel-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 5px;
}

.unit-hint { font-weight: 400; color: var(--text-sec); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.form-group input,
.form-group select {
  width: 100%;
  padding: 8px 11px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus { outline: none; border-color: var(--teal); }
.form-group input.invalid { border-color: #ef4444; }

.field-note { font-size: 11px; color: var(--text-sec); margin-top: 3px; display: block; }

/* Radio cards for foundation / project type */
.radio-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.radio-card {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
}
.radio-card input[type="radio"] { position: absolute; opacity: 0; }
.radio-card:hover { border-color: var(--teal); }
.radio-card.checked { border-color: var(--teal); background: var(--teal-light); }

.radio-card-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  display: block;
}
.radio-card-hint {
  font-size: 11px;
  color: var(--text-sec);
  margin-top: 2px;
  display: block;
}

/* ---- Results ---- */
.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}

.results-actions { display: flex; gap: 8px; }

.summary-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-align: center;
}
.summary-card .s-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-sec);
  margin-bottom: 5px;
}
.summary-card .s-value {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  font-family: monospace;
}
.summary-card.highlight .s-value { color: var(--teal); }

/* ---- BOQ Table ---- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  background: var(--teal);
  color: #fff;
  padding: 9px 10px;
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.data-table th.num, .data-table td.num { text-align: right; }

.data-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:hover td { background: var(--teal-light); }

.data-table tr.section-row td {
  background: var(--teal-light);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--teal-dark);
  padding: 6px 10px;
}

.data-table tr.total-row td {
  background: var(--teal);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  border: none;
}

.amount-cell { font-weight: 600; font-family: monospace; }
.dsr-code { font-family: monospace; font-size: 12px; color: var(--text-sec); }

/* ---- Material Rates Page ---- */
.category-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }

.tab-btn {
  padding: 6px 14px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  background: var(--bg);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-sec);
  transition: all 0.15s;
  font-family: inherit;
}
.tab-btn:hover { border-color: var(--teal); color: var(--teal); }
.tab-btn.active { background: var(--teal); color: #fff; border-color: var(--teal); }

.search-bar-row { margin-bottom: 16px; }
.search-input {
  width: 100%;
  max-width: 380px;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
}
.search-input:focus { outline: none; border-color: var(--teal); }

.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.loading-cell, .empty-cell {
  text-align: center !important;
  padding: 40px !important;
  color: var(--text-sec);
}

.rates-disclaimer {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-sec);
  text-align: center;
}

.results-disclaimer {
  margin-top: 20px;
  font-size: 12px;
  color: var(--text-sec);
  font-family: monospace;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  line-height: 1.7;
}

/* ---- Residential banner ---- */
.residential-banner {
  margin-bottom: 24px;
  padding: 16px 20px;
  background: var(--teal-light);
  border-left: 4px solid var(--teal);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.residential-title {
  font-size: 20px;
  font-weight: 500;
  color: var(--teal-dark);
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.residential-sub {
  font-size: 13px;
  color: var(--teal-dark);
  opacity: 0.85;
}

/* ---- Foundation info strip ---- */
.foundation-info {
  font-size: 12px;
  color: var(--text-sec);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  margin-bottom: 16px;
}
.foundation-info-icon { margin-right: 4px; color: var(--teal); }

/* ---- Project summary chips ---- */
.project-summary { margin-bottom: 16px; }
.summary-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-sec);
  padding: 3px 11px;
}

/* ---- Cost breakdown bar ---- */
.breakdown-wrap {
  margin-bottom: 20px;
}
.breakdown-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-sec);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.breakdown-bar {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--border);
  margin-bottom: 8px;
}
.bar-segment { transition: width 0.4s ease; }
.breakdown-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-sec);
}
.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ---- DSR description tooltip ---- */
.info-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  color: var(--teal);
  padding: 0 3px;
  vertical-align: middle;
  opacity: 0.7;
  transition: opacity 0.15s;
  font-family: inherit;
}
.info-btn:hover { opacity: 1; }
.item-name-wrap { display: inline-flex; align-items: center; gap: 2px; }

.dsr-tooltip {
  display: none;
  position: absolute;
  z-index: 500;
  max-width: 340px;
  background: #1a1a1a;
  color: #f9fafb;
  font-size: 12px;
  line-height: 1.6;
  padding: 10px 13px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  pointer-events: none;
}
.dsr-tooltip.visible { display: block; }

/* ---- Stats strip ---- */
.stats-strip {
  margin-top: 28px;
  font-size: 12px;
  color: var(--text-sec);
  font-family: monospace;
  letter-spacing: 0.3px;
}
.strip-sep { margin: 0 8px; color: var(--border); }

/* ---- How it works ---- */
.how-it-works {
  padding: 56px 0 64px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.hiw-title {
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--text);
  text-align: center;
  margin-bottom: 36px;
}
.hiw-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}
.hiw-step {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  max-width: 220px;
  text-align: left;
}
.hiw-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.hiw-step-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
}
.hiw-step-desc { font-size: 12px; color: var(--text-sec); line-height: 1.5; }
.hiw-arrow { font-size: 18px; color: var(--border); padding: 0 4px; }

/* ---- Formula note (one-liner below item name in BOQ table) ---- */
.formula-note {
  font-size: 11px;
  color: var(--text-sec);
  font-family: monospace;
  margin-top: 2px;
  line-height: 1.4;
}

/* ---- Error ---- */
.error-msg {
  margin-top: 0;
  margin-bottom: 16px;
  padding: 11px 14px;
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: var(--radius);
  color: #b91c1c;
  font-size: 13px;
}

/* ---- Detailed estimator ---- */
.detailed-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  align-items: start;
}

.item-list { display: flex; flex-direction: column; gap: 12px; }

.item-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.item-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.item-card-title { font-size: 13px; font-weight: 600; }
.item-card-dsr { font-size: 11px; color: var(--text-sec); font-family: monospace; }

.item-card-fields { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; align-items: end; }

.item-card-amount { font-size: 16px; font-weight: 600; color: var(--teal); font-family: monospace; }

.add-item-row { text-align: center; padding: 20px; }

.total-sidebar { position: sticky; top: 72px; }

.total-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.total-box h3 { font-size: 14px; font-weight: 600; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }

.total-line { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 13px; }
.total-line .label { color: var(--text-sec); }
.total-line .value { font-weight: 600; font-family: monospace; }
.total-line.grand { font-size: 16px; border-top: 1px solid var(--border); padding-top: 10px; margin-top: 4px; }
.total-line.grand .value { color: var(--teal); }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg);
  border-radius: 10px;
  padding: 24px;
  width: 480px;
  max-width: 95vw;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
}
.modal h3 { font-size: 16px; font-weight: 600; margin-bottom: 16px; }
.modal-close { float: right; background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-sec); }

.dsr-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.12s;
}
.dsr-option:hover { background: var(--teal-light); }
.dsr-option-name { font-size: 13px; font-weight: 500; }
.dsr-option-meta { font-size: 12px; color: var(--text-sec); }

/* ---- Footer ---- */
.footer {
  border-top: 1px solid var(--border);
  padding: 32px 0;
  text-align: center;
  font-size: 13px;
  color: var(--text-sec);
  margin-top: 40px;
}
.footer-brand {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.footer-brand span { color: var(--teal); }
.footer-tagline { font-size: 13px; color: var(--text-sec); margin-bottom: 4px; }
.footer-note { font-size: 12px; margin-bottom: 12px; }
.footer-disclaimer {
  max-width: 720px;
  margin: 0 auto;
  font-size: 11px;
  color: var(--text-sec);
  opacity: 0.75;
  line-height: 1.6;
  font-family: monospace;
}

/* ---- Print ---- */
@media print {
  .navbar, .form-panel, .btn, .footer, .results-actions { display: none !important; }
  .estimator-wrap { display: block; }
  .results-panel { border: none; box-shadow: none; padding: 0; }
}

/* ---- Responsive ---- */
@media (max-width: 860px) {
  .detailed-layout { grid-template-columns: 1fr; }
  .hero h1 { font-size: 26px; }
  .summary-cards { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .mode-cards { flex-direction: column; }
  .summary-cards { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .radio-cards { grid-template-columns: 1fr; }
}

/* ── Drawing standards collapsible (step2_upload) ── */
.drawing-standards {
  margin: 16px 0;
  padding: 12px 16px;
  background: #F9FAFB;
  border: 1px solid #E5E7EB;
  border-radius: 8px;
  font-size: 13px;
}
.drawing-standards summary {
  cursor: pointer;
  color: #1D9E75;
  font-weight: 500;
}
.drawing-standards .standards-block {
  margin-top: 12px;
  color: #374151;
}
.drawing-standards h4 {
  margin: 16px 0 8px 0;
  font-size: 14px;
  color: #0F6E56;
}
.drawing-standards ul {
  margin: 4px 0 8px 20px;
  line-height: 1.6;
}
.drawing-standards .note {
  margin-top: 12px;
  padding: 8px 12px;
  background: #E1F5EE;
  border-radius: 6px;
  color: #0F6E56;
  font-style: italic;
}
