/* ScopeVault — Design System */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=DM+Sans:ital,wght@0,300;0,400;0,500;0,600;1,400&display=swap');

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

:root {
  --ink: #0a0f1a;
  --slate: #2d3548;
  --muted: #6b7a94;
  --accent: #e85d26;
  --accent-light: #ff7a45;
  --accent-dark: #c44d1e;
  --surface: #f7f5f0;
  --white: #ffffff;
  --card: #fdfcfa;
  --border: #e8e4dd;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --info: #2563eb;
  --info-bg: #eff6ff;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 10px 40px rgba(0,0,0,.1);
  --radius: 10px;
  --radius-lg: 16px;
}

body {
  font-family: 'DM Sans', sans-serif;
  color: var(--ink);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

/* ---- TYPOGRAPHY ---- */
h1,h2,h3,h4 { font-family: 'Space Grotesk', sans-serif; font-weight: 700; line-height: 1.15; letter-spacing: -0.5px; }

/* ---- LAYOUT ---- */
.container { max-width: 1200px; margin: 0 auto; padding: 0 48px; }
@media (max-width: 768px) { .container { padding: 0 20px; } }

/* ---- NAV ---- */
.nav {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.nav-inner {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 48px; max-width: 1200px; margin: 0 auto;
}
.logo { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 22px; color: var(--ink); text-decoration: none; letter-spacing: -0.5px; }
.logo span { color: var(--accent); }
.nav-links { display: flex; gap: 24px; align-items: center; }
.nav-link { color: var(--muted); text-decoration: none; font-size: 15px; font-weight: 500; transition: color .2s; }
.nav-link:hover { color: var(--ink); }

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif; font-size: 15px; font-weight: 600;
  cursor: pointer; border: none; text-decoration: none;
  transition: all .2s; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: var(--white); }
.btn-primary:hover { background: var(--accent-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(232,93,38,.3); }
.btn-secondary { background: var(--white); color: var(--ink); border: 1.5px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--ink); background: var(--surface); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border: 1.5px solid #fecaca; }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 17px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }

/* ---- CARDS ---- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; box-shadow: var(--shadow-sm); }
.card-hover:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); transition: all .2s; cursor: pointer; }

/* ---- HERO ---- */
.hero {
  padding: 100px 48px 80px;
  max-width: 1200px; margin: 0 auto;
  display: grid; grid-template-columns: 1fr 1fr; gap: 80px; align-items: center;
}
.hero-text h1 { font-size: 58px; margin-bottom: 20px; color: var(--ink); }
.hero-text h1 em { font-style: normal; color: var(--accent); }
.hero-text p { font-size: 19px; color: var(--muted); line-height: 1.65; margin-bottom: 32px; }
.hero-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.hero-visual {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 28px; box-shadow: var(--shadow-lg);
}
.preview-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.preview-title { font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 16px; }
.score-badge { background: var(--success-bg); color: var(--success); padding: 6px 14px; border-radius: 20px; font-weight: 700; font-size: 14px; }
.preview-items { display: flex; flex-direction: column; gap: 10px; }
.preview-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: var(--surface); border-radius: 8px; font-size: 14px; }
.preview-item-code { font-family: monospace; font-weight: 600; color: var(--accent); font-size: 12px; background: rgba(232,93,38,.1); padding: 2px 8px; border-radius: 4px; }
.preview-flags { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 16px; }
.flag-item { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--warning); padding: 6px 0; }
.flag-dot { width: 8px; height: 8px; background: var(--warning); border-radius: 50%; margin-top: 5px; flex-shrink: 0; }

/* ---- STATS STRIP ---- */
.stats-strip { background: var(--ink); padding: 48px; margin: 0; }
.stats-inner { max-width: 1200px; margin: 0 auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 40px; text-align: center; }
.stat-num { font-family: 'Space Grotesk', sans-serif; font-size: 48px; font-weight: 700; color: var(--accent); }
.stat-label { color: rgba(255,255,255,.6); font-size: 15px; margin-top: 4px; }

/* ---- HOW IT WORKS ---- */
.section { padding: 80px 48px; max-width: 1200px; margin: 0 auto; }
.section-title { font-size: 40px; margin-bottom: 12px; }
.section-sub { color: var(--muted); font-size: 17px; margin-bottom: 52px; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 32px; }
.step { text-align: center; padding: 32px 24px; }
.step-num { width: 52px; height: 52px; background: var(--accent); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 20px; color: var(--white); margin: 0 auto 20px; }
.step h3 { font-size: 20px; margin-bottom: 10px; }
.step p { color: var(--muted); font-size: 15px; line-height: 1.6; }

/* ---- CTA ---- */
.cta-band { background: var(--accent); padding: 64px 48px; text-align: center; }
.cta-band h2 { font-size: 40px; color: var(--white); margin-bottom: 12px; }
.cta-band p { color: rgba(255,255,255,.8); font-size: 17px; margin-bottom: 28px; }
.btn-white { background: var(--white); color: var(--accent); }
.btn-white:hover { background: var(--surface); }

/* ---- FOOTER ---- */
footer { background: var(--ink); color: rgba(255,255,255,.5); text-align: center; padding: 28px; font-size: 14px; }
footer a { color: rgba(255,255,255,.5); text-decoration: none; }

/* ---- APP SHELL ---- */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.app-header {
  background: var(--white); border-bottom: 1px solid var(--border);
  padding: 16px 32px; display: flex; justify-content: space-between; align-items: center;
  position: sticky; top: 0; z-index: 100;
}
.app-content { flex: 1; padding: 32px; max-width: 1200px; margin: 0 auto; width: 100%; }
.app-content-wide { flex: 1; padding: 32px; width: 100%; }

/* ---- FORMS ---- */
.form-group { margin-bottom: 20px; }
.form-label { display: block; font-size: 14px; font-weight: 600; color: var(--slate); margin-bottom: 6px; }
.form-input {
  width: 100%; padding: 10px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius); font-family: 'DM Sans', sans-serif; font-size: 15px;
  color: var(--ink); background: var(--white); outline: none; transition: border-color .2s;
}
.form-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(232,93,38,.1); }
.form-input::placeholder { color: var(--muted); }
select.form-input { cursor: pointer; }
.form-row { display: grid; gap: 16px; }
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row-4 { grid-template-columns: 2fr 1.5fr 0.8fr 1fr 1fr auto; }

/* ---- TABLES ---- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; background: var(--white); }
thead { background: var(--surface); }
th { padding: 12px 16px; text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px 16px; font-size: 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface); }
.code-cell { font-family: monospace; font-size: 12px; font-weight: 700; color: var(--accent); background: rgba(232,93,38,.08); padding: 3px 8px; border-radius: 4px; }

/* ---- ESTIMATES LIST ---- */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 28px; }
.page-title { font-size: 28px; }
.empty-state { text-align: center; padding: 80px 40px; }
.empty-icon { font-size: 56px; margin-bottom: 16px; }
.empty-title { font-size: 22px; font-weight: 600; margin-bottom: 8px; }
.empty-text { color: var(--muted); margin-bottom: 28px; font-size: 15px; }
.estimate-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px 24px; display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: center;
  margin-bottom: 12px; transition: all .15s; text-decoration: none; color: inherit;
}
.estimate-card:hover { box-shadow: var(--shadow-md); border-color: var(--accent); transform: translateX(3px); }
.estimate-meta { display: flex; gap: 16px; margin-top: 6px; }
.meta-tag { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.score-chip {
  padding: 5px 12px; border-radius: 20px; font-size: 13px; font-weight: 700;
  font-family: 'Space Grotesk', sans-serif;
}
.score-high { background: var(--success-bg); color: var(--success); }
.score-mid { background: var(--warning-bg); color: var(--warning); }
.score-low { background: var(--danger-bg); color: var(--danger); }
.score-none { background: var(--surface); color: var(--muted); }

/* ---- ESTIMATE EDITOR ---- */
.editor-layout { display: grid; grid-template-columns: 1fr; gap: 24px; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.section-title-sm { font-size: 18px; font-weight: 600; }
.line-items-table input.form-input { padding: 7px 10px; font-size: 13px; }
.add-row-btn { margin-top: 12px; }
.total-row { background: var(--surface); font-weight: 600; }
.total-row td { border-top: 2px solid var(--border); }
.remove-btn { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 18px; padding: 4px 8px; border-radius: 6px; }
.remove-btn:hover { color: var(--danger); background: var(--danger-bg); }

/* ---- QA REPORT ---- */
.qa-banner {
  border-radius: var(--radius-lg); padding: 28px 32px; margin-bottom: 28px;
  display: grid; grid-template-columns: auto 1fr auto; gap: 24px; align-items: center;
}
.qa-banner-pass { background: var(--success-bg); border: 1.5px solid #bbf7d0; }
.qa-banner-warn { background: var(--warning-bg); border: 1.5px solid #fde68a; }
.qa-banner-fail { background: var(--danger-bg); border: 1.5px solid #fecaca; }
.score-circle {
  width: 80px; height: 80px; border-radius: 50%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; font-family: 'Space Grotesk', sans-serif;
}
.score-circle-pass { background: var(--success); color: var(--white); }
.score-circle-warn { background: var(--warning); color: var(--white); }
.score-circle-fail { background: var(--danger); color: var(--white); }
.score-circle .score-num { font-size: 24px; font-weight: 700; line-height: 1; }
.score-circle .score-label { font-size: 9px; text-transform: uppercase; opacity: .85; }
.qa-stats { display: flex; gap: 32px; }
.qa-stat { text-align: center; }
.qa-stat-num { font-family: 'Space Grotesk', sans-serif; font-size: 28px; font-weight: 700; }
.qa-stat-label { font-size: 12px; color: var(--muted); }
.issues-list { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.issue-item {
  padding: 14px 16px; border-radius: var(--radius); border-left: 4px solid;
  display: grid; grid-template-columns: auto 1fr; gap: 12px;
}
.issue-critical { background: var(--danger-bg); border-color: var(--danger); }
.issue-warning { background: var(--warning-bg); border-color: var(--warning); }
.issue-info { background: var(--info-bg); border-color: var(--info); }
.issue-icon { font-size: 20px; margin-top: 1px; }
.issue-title { font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.issue-desc { font-size: 13px; color: var(--slate); }
.supplement-item { padding: 16px; border-radius: var(--radius); background: var(--white); border: 1px solid var(--border); }
.supplement-code { font-family: monospace; font-weight: 700; color: var(--accent); font-size: 12px; }
.supplement-title { font-weight: 600; font-size: 15px; margin: 4px 0; }
.supplement-meta { font-size: 13px; color: var(--muted); }
.supplement-value { font-size: 13px; font-weight: 600; color: var(--success); margin-top: 4px; }

/* ---- MODAL ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 500;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal { background: var(--white); border-radius: var(--radius-lg); padding: 32px; max-width: 520px; width: 100%; box-shadow: var(--shadow-lg); }
.modal-title { font-size: 22px; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 12px; margin-top: 24px; justify-content: flex-end; }

/* ---- LOADING ---- */
.spinner { display: inline-block; width: 20px; height: 20px; border: 2px solid rgba(255,255,255,.3); border-top-color: var(--white); border-radius: 50%; animation: spin .7s linear infinite; }
.spinner-dark { border-color: rgba(0,0,0,.1); border-top-color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay { position: fixed; inset: 0; background: rgba(255,255,255,.8); display: flex; align-items: center; justify-content: center; z-index: 400; flex-direction: column; gap: 16px; font-size: 18px; font-weight: 600; color: var(--accent); }

/* ---- TOAST ---- */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 999; display: flex; flex-direction: column; gap: 10px; }
.toast { padding: 14px 20px; border-radius: var(--radius); font-size: 14px; font-weight: 500; animation: slideUp .3s ease; max-width: 320px; box-shadow: var(--shadow-md); }
.toast-success { background: var(--ink); color: var(--white); }
.toast-error { background: var(--danger); color: var(--white); }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* ---- TABS ---- */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 24px; }
.tab { padding: 10px 20px; font-size: 15px; font-weight: 500; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .2s; background: none; border-top: none; border-left: none; border-right: none; font-family: 'DM Sans', sans-serif; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---- RESPONSIVE ---- */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 40px; padding: 60px 24px; }
  .hero-text h1 { font-size: 40px; }
  .steps { grid-template-columns: 1fr; }
  .stats-inner { grid-template-columns: 1fr; }
  .form-row-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .app-header, .nav-inner { padding: 14px 20px; }
  .app-content { padding: 20px 16px; }
  .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
  .qa-stats { flex-wrap: wrap; gap: 16px; }
  .form-row-4 { grid-template-columns: 1fr; }
}
