/* YardQuote contractor portal: signup, login, dashboard, profile.
   Shared shell used across /signup, /login, /dashboard, /leads, /quotes,
   /profile, /embed-snippet. Uses CSS variables so the wildcard subdomain
   HTMLRewriter can override them per contractor. */

:root {
  --brand-primary: #1a6b4a;
  --brand-bg: #f8faf9;
  --brand-card: #ffffff;
  --brand-text: #111a15;
  --brand-text-muted: #5b6a63;
  --brand-border: #dce5e0;
  --brand-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --brand-error: #b91c1c;
  --brand-success: #166534;
  --shadow-card: 0 1px 2px rgba(17,26,21,0.06), 0 8px 24px rgba(17,26,21,0.05);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--brand-font);
  background: var(--brand-bg);
  color: var(--brand-text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--brand-primary); text-decoration: none; }
a:hover, a:focus { text-decoration: underline; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--brand-primary);
  color: #fff;
  padding: 12px 20px;
  z-index: 1000;
}
.skip-link:focus { left: 16px; top: 16px; }

.portal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--brand-border);
  background: var(--brand-card);
}
.portal-brand {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--brand-text);
  letter-spacing: -0.02em;
  text-decoration: none;
}
.portal-brand-accent { color: var(--brand-primary); font-weight: 600; }
.portal-header-nav a {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--brand-text-muted);
}

.portal-shell {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
  max-width: 1180px;
  width: 100%;
  margin: 32px auto;
  padding: 0 24px;
}
@media (min-width: 960px) {
  .portal-shell { grid-template-columns: 1fr 1.1fr; gap: 56px; }
}

.portal-pitch h1 {
  font-size: 2.4rem;
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 8px 0 16px;
}
.portal-pitch p { font-size: 1.05rem; color: var(--brand-text-muted); }
.portal-pitch code {
  background: var(--brand-card);
  border: 1px solid var(--brand-border);
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 0.95em;
  color: var(--brand-text);
}
.portal-pitch-list {
  list-style: none;
  padding: 0;
  margin: 24px 0 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.portal-pitch-list li { display: flex; align-items: flex-start; gap: 12px; font-size: 0.98rem; }
.portal-pitch-list .bullet {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand-primary);
  margin-top: 8px;
}

.portal-card {
  background: var(--brand-card);
  border: 1px solid var(--brand-border);
  border-radius: 16px;
  padding: 32px;
  box-shadow: var(--shadow-card);
}
.portal-card h2 { margin: 0 0 6px; font-size: 1.4rem; }
.portal-card .muted { color: var(--brand-text-muted); margin: 0 0 24px; font-size: 0.95rem; }

.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--brand-text);
  margin-bottom: 6px;
}
.field .req { color: var(--brand-error); }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--brand-border);
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--brand-text);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(26,107,74,0.15);
}
.field input[aria-invalid="true"] { border-color: var(--brand-error); }
.field .hint { color: var(--brand-text-muted); font-size: 0.85rem; margin: 6px 0 0; }
.field .error { color: var(--brand-error); font-size: 0.85rem; margin: 6px 0 0; min-height: 1.2em; }

.row { display: grid; grid-template-columns: 1fr; gap: 0; }
@media (min-width: 560px) { .row { grid-template-columns: 1fr 1fr; gap: 16px; } }

.error.global { margin: 8px 0 16px; }

.btn-primary, .btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 14px 20px;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn-primary { background: var(--brand-primary); color: #fff; }
.btn-primary:hover, .btn-primary:focus { filter: brightness(0.92); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-secondary {
  background: #fff;
  color: var(--brand-primary);
  border-color: var(--brand-primary);
}
.btn-secondary:hover, .btn-secondary:focus { background: var(--brand-bg); }

.terms-note { color: var(--brand-text-muted); font-size: 0.8rem; margin: 16px 0 0; text-align: center; }

.success-card {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 12px;
  padding: 24px;
  margin-top: 16px;
}
.success-card h3 { margin: 0 0 8px; color: var(--brand-success); }
.success-card p { margin: 0 0 12px; color: var(--brand-text); }

/* Dashboard layout */
.dash {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 0;
}
@media (min-width: 900px) {
  .dash { grid-template-columns: 240px 1fr; min-height: calc(100vh - 65px); }
}
.dash-side {
  background: var(--brand-card);
  border-right: 1px solid var(--brand-border);
  padding: 24px 16px;
}
.dash-side nav { display: flex; flex-direction: column; gap: 4px; }
.dash-side a {
  display: block;
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--brand-text);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
}
.dash-side a:hover { background: var(--brand-bg); text-decoration: none; }
.dash-side a.active { background: var(--brand-primary); color: #fff; }

.dash-main {
  padding: 32px 24px;
  min-width: 0;
}
.dash-main h1 { margin: 0 0 24px; font-size: 1.8rem; font-weight: 800; }
.dash-main h2 { margin: 32px 0 12px; font-size: 1.2rem; font-weight: 700; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.stat {
  background: var(--brand-card);
  border: 1px solid var(--brand-border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow-card);
}
.stat-label { color: var(--brand-text-muted); font-size: 0.85rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-value { font-size: 1.8rem; font-weight: 800; color: var(--brand-text); margin-top: 8px; }

.table-wrap {
  background: var(--brand-card);
  border: 1px solid var(--brand-border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.95rem;
  border-bottom: 1px solid var(--brand-border);
}
th { background: var(--brand-bg); font-weight: 600; color: var(--brand-text-muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
tr:last-child td { border-bottom: none; }
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--brand-text-muted);
}
.empty-state h3 { color: var(--brand-text); margin: 0 0 8px; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-new { background: #dbeafe; color: #1e40af; }
.badge-contacted { background: #fef3c7; color: #92400e; }
.badge-converted { background: #d1fae5; color: #065f46; }
.badge-lost { background: #fee2e2; color: #991b1b; }
.badge-active { background: #d1fae5; color: #065f46; }
.badge-pending { background: #fef3c7; color: #92400e; }

.embed-snippet {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 12px;
  padding: 20px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.85rem;
  overflow-x: auto;
  white-space: pre;
  position: relative;
}
.embed-snippet button {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(255,255,255,0.1);
  color: #e2e8f0;
  border: 1px solid rgba(255,255,255,0.15);
  padding: 6px 14px;
  border-radius: 8px;
  font-family: var(--brand-font);
  font-size: 0.85rem;
  cursor: pointer;
}

.flash {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}
.flash.error { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }

.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.toolbar select, .toolbar input {
  padding: 8px 12px;
  border: 1px solid var(--brand-border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
}

.color-input {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.color-input input[type="color"] {
  width: 44px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--brand-border);
  border-radius: 8px;
  cursor: pointer;
}
