/* Edgewise — Tool Dashboard Styles
   Brand: dark slate + orange grinding sparks + steel gray */

:root {
  --primary: #0F172A;
  --primary-2: #1E293B;
  --primary-3: #334155;
  --accent: #F97316;
  --accent-hover: #EA580C;
  --highlight: #94A3B8;
  --steel: #CBD5E1;
  --paper: #F8FAFC;
  --ink: #0F172A;
  --ink-2: #475569;
  --line: #E2E8F0;
  --good: #16A34A;
  --warn: #EAB308;
  --bad: #DC2626;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 14px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.18);
  --radius: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

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

/* ---------- Header ---------- */
.tool-header {
  background: var(--primary);
  color: #fff;
  padding: 18px 0;
  border-bottom: 3px solid var(--accent);
}
.tool-header .container { display: flex; align-items: center; justify-content: space-between; }
.brand { color: #fff; text-decoration: none; display: flex; align-items: center; gap: 10px; }
.brand-mark {
  color: var(--accent);
  font-size: 28px;
  line-height: 1;
  transform: rotate(-20deg);
  display: inline-block;
}
.brand-name { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.tool-nav { display: flex; gap: 18px; }
.nav-link { color: rgba(255,255,255,0.85); text-decoration: none; font-weight: 500; font-size: 14px; }
.nav-link:hover { color: var(--accent); }

/* ---------- Hero ---------- */
.tool-main { padding: 36px 0 60px; }
.tool-hero { text-align: center; margin-bottom: 28px; }
.tool-hero h1 {
  font-size: clamp(28px, 4vw, 40px);
  margin: 0 0 10px;
  letter-spacing: -0.02em;
  font-weight: 800;
}
.tool-hero .lede {
  color: var(--ink-2);
  font-size: 17px;
  max-width: 640px;
  margin: 0 auto;
}

/* ---------- Cards ---------- */
.input-card, .results-card, .history-card, .signup-card, .loading-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px;
  margin-bottom: 22px;
}

.section-title {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--primary);
  margin: 0 0 6px;
}
.section-title:not(:first-child) { margin-top: 22px; }
.section-sub { color: var(--ink-2); margin: 0 0 14px; font-size: 14px; }

/* ---------- Upload ---------- */
.upload-zone {
  position: relative;
  border: 2px dashed var(--primary-3);
  border-radius: var(--radius-sm);
  background: #FAFBFC;
  transition: border-color 0.2s, background 0.2s;
}
.upload-zone:hover { border-color: var(--accent); background: #FFF7ED; }
.upload-zone.drag { border-color: var(--accent); background: #FFEDD5; }
.upload-btn {
  width: 100%;
  background: transparent;
  border: 0;
  padding: 36px 20px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--ink-2);
  font-family: inherit;
}
.upload-icon { font-size: 38px; }
.upload-label { font-size: 17px; font-weight: 600; color: var(--ink); }
.upload-sub { font-size: 12px; color: var(--ink-2); }
.preview { padding: 16px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.preview img { max-width: 100%; max-height: 320px; border-radius: var(--radius-sm); box-shadow: var(--shadow); }
.preview-clear {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
}

/* ---------- Job context ---------- */
.job-context {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.job-context label {
  display: flex;
  flex-direction: column;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  gap: 6px;
}
.job-context-full { grid-column: 1 / -1; }
.job-context input,
.job-context textarea {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  width: 100%;
  resize: vertical;
}
.job-context input:focus,
.job-context textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }

/* ---------- Buttons ---------- */
.primary-btn {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 16px;
  font-family: inherit;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: background 0.15s, transform 0.05s;
  margin-top: 18px;
}
.primary-btn:hover:not(:disabled) { background: var(--accent-hover); }
.primary-btn:active:not(:disabled) { transform: translateY(1px); }
.primary-btn:disabled { background: var(--steel); cursor: not-allowed; opacity: 0.6; }
.primary-btn .btn-sub { font-size: 12px; font-weight: 500; opacity: 0.85; }

.primary-btn-sm {
  background: var(--primary);
  color: #fff;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.primary-btn-sm:hover { background: var(--primary-2); }

.ghost-btn {
  background: #fff;
  color: var(--primary);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-family: inherit;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.ghost-btn:hover { border-color: var(--accent); color: var(--accent); }

.hint { font-size: 13px; color: var(--ink-2); margin: 10px 0 0; }

/* ---------- Loading ---------- */
.loading-card { text-align: center; padding: 50px 20px; }
.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Results ---------- */
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
  margin-bottom: 18px;
}
.results-header h2 { margin: 0; font-size: 24px; }
.results-sub { color: var(--ink-2); font-size: 14px; margin: 4px 0 0; }
.results-sub span:empty::after { content: 'this customer'; color: var(--ink-2); }
.results-total {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.total-label { font-size: 12px; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.06em; }
.total-amount { font-size: 32px; font-weight: 800; color: var(--primary); line-height: 1; margin: 4px 0; }
.total-time { font-size: 13px; color: var(--ink-2); }

.results-meta {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 22px;
}
.meta-tile {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
}
.meta-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-2); font-weight: 700; }
.meta-value { font-size: 20px; font-weight: 700; color: var(--primary); margin-top: 2px; }

.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 22px;
}
.chart-tile {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px;
}
.chart-tile h3 { font-size: 13px; margin: 0 0 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-2); font-weight: 700; }

.line-title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-2); font-weight: 700; margin: 0 0 10px; }
.table-wrap { overflow-x: auto; margin-bottom: 22px; }
.quote-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.quote-table th, .quote-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); }
.quote-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-2);
  font-weight: 700;
  background: var(--paper);
}
.quote-table td.right, .quote-table th.right { text-align: right; }
.quote-table tr:last-child td { border-bottom: 0; }
.cond-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
}
.cond-1, .cond-2 { background: rgba(220, 38, 38, 0.1); color: var(--bad); }
.cond-3 { background: rgba(234, 179, 8, 0.13); color: #92400E; }
.cond-4, .cond-5 { background: rgba(22, 163, 74, 0.12); color: var(--good); }

.advice-card {
  background: #FFF7ED;
  border: 1px solid #FED7AA;
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-bottom: 22px;
}
.advice-card h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 8px; color: #9A3412; }
.advice-card ul { margin: 0; padding-left: 18px; color: var(--ink); font-size: 14px; }
.advice-card li { margin-bottom: 4px; }

.actions-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- History ---------- */
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 14px;
}
.history-item .h-when { color: var(--ink-2); font-size: 12px; }
.muted { color: var(--ink-2); }

/* ---------- Signup ---------- */
.signup-card { background: var(--primary); color: #fff; border: 0; }
.signup-card h2 { margin: 0 0 6px; font-size: 22px; }
.signup-card p { color: rgba(255,255,255,0.85); margin: 0 0 14px; font-size: 14px; }
.signup-card form { display: flex; gap: 10px; flex-wrap: wrap; }
.signup-card input {
  flex: 1;
  min-width: 220px;
  font: inherit;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--primary-3);
  background: var(--primary-2);
  color: #fff;
}
.signup-card input::placeholder { color: rgba(255,255,255,0.45); }
.signup-card input:focus { outline: 2px solid var(--accent); }
.signup-card .primary-btn-sm { background: var(--accent); color: #fff; }
.signup-card .primary-btn-sm:hover { background: var(--accent-hover); }
.signup-confirm { color: #FED7AA; font-weight: 600; margin-top: 12px; }

/* ---------- Footer ---------- */
.tool-footer {
  background: var(--primary);
  color: rgba(255,255,255,0.8);
  padding: 18px 0;
  text-align: center;
  font-size: 13px;
}
.tool-footer .container { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.tool-footer a { color: var(--accent); text-decoration: none; }
.ai-badge { font-size: 12px; opacity: 0.85; }

/* ---------- Mobile ---------- */
@media (max-width: 720px) {
  .job-context { grid-template-columns: 1fr; }
  .chart-grid { grid-template-columns: 1fr; }
  .results-meta { grid-template-columns: repeat(2, 1fr); }
  .results-header { flex-direction: column; align-items: flex-start; }
  .total-amount { font-size: 28px; }
  .tool-hero h1 { font-size: 26px; }
  .actions-row { flex-direction: column; align-items: stretch; }
  .actions-row button { width: 100%; }
}

/* ---------- Embed mode ---------- */
body.embed-mode .tool-header,
body.embed-mode .tool-footer,
body.embed-mode .history-card,
body.embed-mode .signup-card,
body.embed-mode .tool-hero { display: none; }
body.embed-mode .tool-main { padding: 16px 0; }

@media print {
  .tool-header, .tool-footer, .input-card, .history-card, .signup-card, .actions-row, .loading-card { display: none !important; }
  body { background: #fff; }
  .results-card { box-shadow: none; border: 0; }
}
