:root {
  --white: #ffffff;
  --bg: #f8f9fa;
  --surface: #ffffff;
  --surface-dim: #f1f3f4;
  --outline: #dadce0;
  --outline-light: #e8eaed;
  --text-primary: #202124;
  --text-secondary: #5f6368;
  --text-hint: #9aa0a6;
  --accent: #c8a45a;
  --accent-light: #f5edda;
  --accent-dark: #a68a3e;
  --blue: #1a73e8;
  --blue-light: #e8f0fe;
  --green: #1e8e3e;
  --green-light: #e6f4ea;
  --red: #d93025;
  --red-light: #fce8e6;
  --orange: #e37400;
  --orange-light: #fef7e0;
  --radius: 16px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.06);
  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

.header {
  background: var(--white);
  border-bottom: 1px solid var(--outline-light);
  padding: 0 20px;
  height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
}
.header-brand { display: flex; align-items: center; gap: 12px; }
.header-logo {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 14px;
}
.header-brand h1 { font-size: 16px; font-weight: 600; color: var(--text-primary); letter-spacing: -0.2px; }
.header-link {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  text-decoration: none;
  transition: var(--transition);
}
.header-link:hover { background: var(--surface-dim); color: var(--accent-dark); }
.lang-toggle { display: flex; background: var(--surface-dim); border-radius: 20px; padding: 2px; }
.lang-toggle button {
  background: none; border: none; color: var(--text-secondary);
  font-size: 13px; font-weight: 600; padding: 6px 14px;
  cursor: pointer; border-radius: 18px; font-family: inherit;
  transition: var(--transition);
}
.lang-toggle button.active { background: var(--white); color: var(--text-primary); box-shadow: var(--shadow-sm); }

.progress-section {
  background: var(--white);
  border-bottom: 1px solid var(--outline-light);
  padding: 12px 20px 16px;
}
.progress-info { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.progress-label { font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.progress-count { font-size: 13px; font-weight: 600; color: var(--accent-dark); }
.progress-track { height: 4px; background: var(--surface-dim); border-radius: 2px; overflow: hidden; }
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-dark));
  border-radius: 2px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.main { max-width: 640px; margin: 0 auto; padding: 20px 16px 120px; }
.step { display: none; }
.step.active { display: block; animation: stepIn 0.3s ease; }
@keyframes stepIn { from { opacity: 0; transform: translateY(8px);} to { opacity: 1; transform: translateY(0);} }
.step-header { margin-bottom: 24px; }
.step-icon {
  width: 48px; height: 48px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 16px; font-size: 24px;
}
.step-icon.gold   { background: var(--accent-light); color: var(--accent-dark); }
.step-icon.blue   { background: var(--blue-light); color: var(--blue); }
.step-icon.green  { background: var(--green-light); color: var(--green); }
.step-icon.orange { background: var(--orange-light); color: var(--orange); }
.step-title { font-size: 24px; font-weight: 700; letter-spacing: -0.5px; color: var(--text-primary); line-height: 1.2; }
.step-subtitle { font-size: 14px; color: var(--text-secondary); margin-top: 6px; line-height: 1.5; }

.card {
  background: var(--surface);
  border: 1px solid var(--outline-light);
  border-radius: var(--radius);
  padding: 20px; margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}
.card-flat {
  background: var(--surface);
  border: 1px solid var(--outline-light);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 12px;
}
.form-group { margin-bottom: 20px; }
.form-group:last-child { margin-bottom: 0; }
.form-label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.form-input, .form-textarea {
  width: 100%; background: var(--white);
  border: 1.5px solid var(--outline); color: var(--text-primary);
  padding: 14px 16px; border-radius: var(--radius-xs);
  font-size: 16px; font-family: inherit;
  transition: var(--transition);
  -webkit-appearance: none;
}
.form-input:focus, .form-textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.form-textarea { resize: vertical; min-height: 110px; line-height: 1.6; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-helper { font-size: 12px; color: var(--text-hint); margin-top: 6px; line-height: 1.5; }

.chip-group { display: flex; gap: 8px; }
.chip {
  flex: 1; padding: 12px 14px;
  background: var(--white); border: 1.5px solid var(--outline);
  border-radius: var(--radius-xs);
  font-size: 14px; font-weight: 500; color: var(--text-secondary);
  cursor: pointer; font-family: inherit; text-align: center;
  transition: var(--transition);
}
.chip:hover { border-color: var(--text-hint); background: var(--surface-dim); }
.chip.active { border-color: var(--accent); background: var(--accent-light); color: var(--accent-dark); font-weight: 600; }

.option-card {
  padding: 16px 20px; border-bottom: 1px solid var(--outline-light);
  cursor: pointer; transition: var(--transition);
  display: flex; align-items: flex-start; gap: 14px;
}
.option-card:last-child { border-bottom: none; }
.option-card:hover { background: var(--surface-dim); }
.option-card.selected { background: var(--accent-light); }
.option-radio {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--outline); margin-top: 1px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.option-card.selected .option-radio { border-color: var(--accent); background: var(--accent); }
.option-card.selected .option-radio::after { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #fff; }
.option-body { flex: 1; }
.option-title { font-size: 15px; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.option-desc  { font-size: 13px; color: var(--text-secondary); line-height: 1.6; }

.line-item {
  background: var(--surface);
  border: 1px solid var(--outline-light);
  border-radius: var(--radius);
  padding: 16px; margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
}
.line-item-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 8px; margin-bottom: 12px;
}
.line-item-desc {
  width: 100%; background: none; border: none;
  color: var(--text-primary);
  font-size: 15px; font-family: inherit;
  padding: 0; line-height: 1.5; resize: none;
}
.line-item-desc:focus { outline: none; }
.line-item-fields { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.li-field label {
  font-size: 10px; font-weight: 600; color: var(--text-hint);
  text-transform: uppercase; letter-spacing: 0.5px;
  display: block; margin-bottom: 4px;
}
.li-field input {
  width: 100%;
  background: var(--surface-dim);
  border: 1px solid var(--outline-light);
  color: var(--text-primary);
  padding: 10px; border-radius: 6px;
  font-size: 15px; font-family: inherit; text-align: right;
}
.li-field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-light); }
.line-item-footer {
  display: flex; justify-content: space-between; align-items: center;
  padding-top: 10px; border-top: 1px solid var(--outline-light);
}
.li-material-toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); }
.li-material-toggle input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.li-total { font-size: 16px; font-weight: 700; color: var(--accent-dark); }
.li-remove {
  background: none; border: none; color: var(--text-hint);
  cursor: pointer; padding: 4px; border-radius: 6px;
  transition: var(--transition);
  font-size: 20px; line-height: 1; display: flex; align-items: center;
}
.li-remove:hover { background: var(--red-light); color: var(--red); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 14px 24px; border-radius: var(--radius-xs);
  font-size: 15px; font-weight: 600;
  cursor: pointer; border: none; font-family: inherit;
  transition: var(--transition);
  width: 100%; letter-spacing: 0.1px;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); box-shadow: var(--shadow-md); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { background: var(--white); color: var(--text-primary); border: 1.5px solid var(--outline); }
.btn-secondary:hover { background: var(--surface-dim); }
.btn-sm { padding: 10px 18px; font-size: 14px; width: auto; }
.btn-add {
  background: none; border: 2px dashed var(--outline);
  color: var(--text-secondary);
  padding: 14px; border-radius: var(--radius-xs);
  font-size: 14px; font-weight: 600;
  cursor: pointer; width: 100%;
  font-family: inherit;
  transition: var(--transition);
  margin-top: 4px;
}
.btn-add:hover { border-color: var(--accent); color: var(--accent-dark); background: var(--accent-light); }

.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--white);
  border-top: 1px solid var(--outline-light);
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 100;
  display: flex; gap: 10px;
  max-width: 640px; margin: 0 auto;
}
.bottom-nav .btn { flex: 1; }

.info-banner {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px;
  background: var(--blue-light);
  border-radius: var(--radius-xs);
  margin-top: 12px;
}
.info-banner .material-icons-round { color: var(--blue); font-size: 20px; flex-shrink: 0; margin-top: 1px; }
.info-banner p { font-size: 13px; color: var(--text-secondary); line-height: 1.6; }

.client-ctx {
  background: var(--accent-light);
  border: 1px solid #ecd9a9;
  border-radius: var(--radius-xs);
  padding: 12px 14px;
  margin-bottom: 12px;
  display: flex; gap: 10px; align-items: flex-start;
  font-size: 13px;
}
.client-ctx.empty { background: var(--surface-dim); border-color: var(--outline-light); color: var(--text-hint); }
.client-ctx .material-icons-round { color: var(--accent-dark); font-size: 20px; flex-shrink: 0; }
.client-ctx-body strong { color: var(--text-primary); font-weight: 600; }
.client-ctx-body { color: var(--text-secondary); line-height: 1.5; }

.chat-wrap {
  background: var(--surface);
  border: 1px solid var(--outline-light);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
}
.chat-messages {
  display: flex; flex-direction: column; gap: 10px;
  min-height: 120px; max-height: 360px;
  overflow-y: auto; margin-bottom: 12px;
}
.chat-empty {
  color: var(--text-hint);
  font-size: 13px;
  text-align: center;
  padding: 24px 12px;
  font-style: italic;
}
.chat-bubble {
  padding: 12px 14px; border-radius: 14px;
  font-size: 14px; line-height: 1.55;
  max-width: 92%;
  white-space: pre-wrap; word-wrap: break-word;
}
.chat-bubble.user {
  align-self: flex-end;
  background: var(--accent); color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-bubble.assistant {
  align-self: flex-start;
  background: var(--surface-dim); color: var(--text-primary);
  border-bottom-left-radius: 4px;
  white-space: normal;
}
.chat-bubble.assistant p { margin: 0 0 10px; }
.chat-bubble.assistant p:last-child { margin-bottom: 0; }
.chat-bubble.assistant ul,
.chat-bubble.assistant ol { margin: 6px 0 10px; padding-left: 22px; }
.chat-bubble.assistant li { margin: 2px 0; }
.chat-bubble.assistant code {
  background: rgba(0,0,0,0.06);
  padding: 1px 5px; border-radius: 4px;
  font-size: 12.5px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.chat-bubble.assistant pre {
  background: rgba(0,0,0,0.06);
  padding: 10px 12px; border-radius: 6px;
  overflow-x: auto; margin: 6px 0 10px;
  font-size: 12.5px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.chat-bubble.assistant pre code { background: transparent; padding: 0; }
.chat-bubble.assistant strong { font-weight: 700; }
.chat-input-row { display: flex; gap: 8px; align-items: flex-end; }
.chat-input {
  flex: 1;
  background: var(--white);
  border: 1.5px solid var(--outline);
  color: var(--text-primary);
  padding: 12px 14px; border-radius: var(--radius-xs);
  font-size: 15px; font-family: inherit;
  resize: vertical; min-height: 56px; max-height: 200px;
  line-height: 1.5;
}
.chat-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.chat-send {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--accent); color: #fff;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: var(--transition);
}
.chat-send:hover { background: var(--accent-dark); }
.chat-send:disabled { opacity: 0.4; cursor: not-allowed; }

.draft-box {
  background: var(--surface);
  border: 1px solid var(--outline-light);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}
.draft-title {
  font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--accent-dark);
  margin-bottom: 4px;
}
.draft-project-title {
  font-size: 18px; font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
  letter-spacing: -0.3px;
}
.option-card-preview {
  border: 1.5px solid var(--outline-light);
  border-radius: var(--radius-xs);
  padding: 14px;
  margin-bottom: 10px;
  background: var(--surface);
}
.option-card-preview-header {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 8px; gap: 12px;
}
.option-card-preview-title {
  font-size: 14px; font-weight: 700;
  color: var(--accent-dark);
  text-transform: uppercase; letter-spacing: 0.4px;
}
.option-card-preview-total {
  font-size: 18px; font-weight: 800;
  color: var(--accent-dark); white-space: nowrap;
}
.option-card-preview-scope {
  font-size: 13px; color: var(--text-secondary);
  line-height: 1.55; margin-bottom: 10px;
  white-space: pre-wrap;
}
.option-card-preview-meta {
  display: flex; gap: 12px; flex-wrap: wrap;
  font-size: 12px; color: var(--text-hint);
}
.option-card-preview-meta strong { color: var(--text-secondary); font-weight: 600; }

.draft-questions {
  background: var(--orange-light);
  border-left: 3px solid var(--orange);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: #3c4043;
  margin-top: 12px;
}
.draft-questions-title {
  font-weight: 700; color: var(--orange);
  margin-bottom: 4px;
  font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.draft-questions ul { margin: 6px 0 0 16px; }
.draft-accept { margin-top: 12px; }

.options-tabs {
  display: flex; gap: 8px;
  margin-bottom: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.options-tabs::-webkit-scrollbar { display: none; }
.options-tab {
  flex-shrink: 0;
  padding: 10px 16px;
  background: var(--white); border: 1.5px solid var(--outline);
  border-radius: 20px;
  font-size: 13px; font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer; font-family: inherit;
  white-space: nowrap;
  transition: var(--transition);
}
.options-tab.active {
  background: var(--accent); color: #fff;
  border-color: var(--accent);
}
.options-tab .close { margin-left: 6px; opacity: 0.6; font-size: 14px; vertical-align: -2px; }
.options-tab .close:hover { opacity: 1; }

.option-editor-box {
  background: var(--surface);
  border: 1px solid var(--outline-light);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}
.option-editor-head { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }

.tax-box {
  background: var(--surface-dim);
  border: 1px solid var(--outline-light);
  border-radius: var(--radius-xs);
  padding: 14px;
  margin: 14px 0;
}
.tax-row {
  display: flex; justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
  color: var(--text-secondary);
}
.tax-row + .tax-row { border-top: 1px solid var(--outline-light); }
.tax-row.total {
  font-size: 16px; font-weight: 700;
  color: var(--accent-dark);
  border-top: 2px solid var(--accent);
  padding-top: 10px; margin-top: 4px;
}

.sig-pad-wrap {
  background: var(--surface);
  border: 1px solid var(--outline-light);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
}
.sig-label {
  font-size: 12px; font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 8px;
  display: flex; justify-content: space-between; align-items: center;
}
.sig-canvas-box {
  position: relative;
  border: 2px dashed var(--outline);
  border-radius: var(--radius-xs);
  background: #fafafa;
  height: 180px;
  overflow: hidden;
}
.sig-canvas-box canvas {
  width: 100%; height: 100%;
  display: block;
  cursor: crosshair;
  touch-action: none;
}
.sig-placeholder {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-hint);
  font-size: 14px;
  pointer-events: none; font-style: italic;
}
.sig-actions {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 10px; gap: 8px; flex-wrap: wrap;
}
.sig-clear {
  background: none; border: none;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer; font-family: inherit;
  padding: 6px 10px; border-radius: 6px;
  transition: var(--transition);
}
.sig-clear:hover { background: var(--surface-dim); color: var(--red); }
.sig-status { font-size: 12px; color: var(--green); font-weight: 600; text-transform: none; letter-spacing: 0; }

.share-box {
  background: var(--blue-light);
  border: 1px solid #b9d4fb;
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 12px;
}
.share-title {
  font-size: 13px; font-weight: 700;
  color: var(--blue);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.share-link-row { display: flex; gap: 8px; }
.share-link-input {
  flex: 1;
  background: #fff;
  border: 1px solid var(--outline);
  padding: 10px 12px;
  border-radius: var(--radius-xs);
  font-size: 13px;
  font-family: ui-monospace, monospace;
  color: var(--text-primary);
}
.share-hint { font-size: 12px; color: var(--text-secondary); margin-top: 10px; line-height: 1.5; }
.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.status-pill.draft   { background: var(--surface-dim); color: var(--text-secondary); }
.status-pill.sent    { background: var(--blue-light);  color: var(--blue); }
.status-pill.viewed  { background: var(--orange-light); color: var(--orange); }
.status-pill.signed  { background: var(--green-light); color: var(--green); }

.quote-preview {
  background: #fff; color: #1a1a1a;
  border-radius: var(--radius);
  padding: 36px 28px;
  font-size: 14px; line-height: 1.65;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--outline-light);
}
.quote-preview h1 { font-size: 22px; font-weight: 800; color: #c8a45a; margin-bottom: 2px; }
.qp-subtitle { font-size: 13px; color: #5f6368; }
.qp-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding-bottom: 16px;
  border-bottom: 3px solid #c8a45a;
  margin-bottom: 20px;
}
.qp-header-right { text-align: right; font-size: 13px; color: #5f6368; }
.qp-header-right strong { color: #202124; font-size: 15px; }
.quote-preview h2 {
  font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: #202124;
  margin-top: 24px; margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid #c8a45a;
}
.qp-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.qp-meta-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: #9aa0a6; }
.qp-meta-value { font-size: 13px; color: #3c4043; }
.qp-option-block {
  border: 1.5px solid #e8eaed;
  border-radius: 10px;
  padding: 18px;
  margin: 12px 0;
  background: #fafbfc;
}
.qp-option-block.accepted {
  border-color: #c8a45a;
  background: #fffaf0;
  box-shadow: 0 2px 8px rgba(200,164,90,0.15);
}
.qp-option-head {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 12px; margin-bottom: 10px;
}
.qp-option-title {
  font-size: 16px; font-weight: 800;
  color: #c8a45a;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.qp-option-total { font-size: 18px; font-weight: 800; color: #202124; white-space: nowrap; }
.quote-preview table { width: 100%; border-collapse: collapse; margin: 8px 0; }
.quote-preview th {
  background: #f8f9fa;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: #5f6368; text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid #e8eaed;
}
.quote-preview th.r { text-align: right; }
.quote-preview td { padding: 10px 12px; border-bottom: 1px solid #f1f3f4; font-size: 13px; }
.quote-preview td.r { text-align: right; }
.qp-totals { margin-top: 12px; border-top: 2px solid #e8eaed; padding-top: 10px; }
.qp-total-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13px; }
.qp-grand-total {
  font-size: 17px; font-weight: 800;
  color: #c8a45a;
  border-top: 3px solid #c8a45a;
  padding-top: 8px; margin-top: 4px;
}
.qp-section {
  margin-top: 12px;
  padding: 16px;
  background: #f8f9fa;
  border-radius: 10px;
  border-left: 4px solid #c8a45a;
  font-size: 13px;
  color: #3c4043;
  line-height: 1.7;
  white-space: pre-line;
}
.qp-signature { margin-top: 44px; display: grid; grid-template-columns: 1fr 1fr; gap: 32px; align-items: end; }
.qp-sig-col { display: flex; flex-direction: column; justify-content: flex-end; }
.qp-sig-img { min-height: 64px; display: flex; align-items: flex-end; margin-bottom: 4px; }
.qp-sig-img img { max-height: 60px; display: block; }
.qp-sig-line { border-top: 1px solid #dadce0; padding-top: 8px; font-size: 12px; color: #9aa0a6; }
.qp-sig-meta { font-size: 12px; color: #3c4043; margin-top: 4px; line-height: 1.4; }
.qp-closing { margin-top: 28px; text-align: center; font-style: italic; color: #5f6368; font-size: 13px; }
.qp-badge { display: inline-block; padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.qp-badge.included { background: #e6f4ea; color: #1e8e3e; }
.qp-badge.excluded { background: #fef7e0; color: #e37400; }

.quote-actions { display: flex; gap: 10px; margin-bottom: 16px; }
.quote-actions .btn { flex: 1; }

.toast {
  position: fixed; bottom: 80px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #202124; color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius-xs);
  font-size: 14px; font-weight: 500;
  z-index: 9999; opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  box-shadow: var(--shadow-lg);
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

.spinner-ring {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--outline-light);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--outline); border-radius: 3px; }

@media (max-width: 380px) {
  .line-item-fields { grid-template-columns: 1fr 1fr; }
  .qp-meta, .qp-signature { grid-template-columns: 1fr; }
  .option-editor-head { grid-template-columns: 1fr; }
}

/* Action items with progress */
.action-item-pro {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--outline-light);
}
.action-item-pro:last-child { border-bottom: none; }
.action-item-pro > .a-body { min-width: 0; }
.action-item-pro input[type="text"] {
  width: 100%;
  background: none; border: none;
  font-size: 14px; color: var(--text-primary); font-family: inherit;
  padding: 4px 0;
}
.action-item-pro input[type="text"]:focus { outline: none; background: var(--surface-dim); border-radius: 4px; padding: 4px; }
.action-progress {
  height: 6px;
  background: var(--surface-dim);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 6px;
}
.action-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-dark));
  border-radius: 3px;
  transition: width 0.3s ease;
}
.action-progress-fill.done { background: var(--green); }
.action-pct-select {
  min-width: 70px;
  padding: 6px 10px;
  border: 1.5px solid var(--outline);
  border-radius: 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--white);
  cursor: pointer;
  font-family: inherit;
}
.action-pct-select.done { background: var(--green-light); color: var(--green); border-color: var(--green); }

.overall-progress-card {
  background: linear-gradient(135deg, var(--accent-light), #fffaf0);
  border: 1px solid #ecd9a9;
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 14px;
}
.overall-progress-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}
.overall-progress-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--accent-dark); }
.overall-progress-pct { font-size: 24px; font-weight: 800; color: var(--accent-dark); letter-spacing: -0.5px; }
.overall-progress-bar { height: 10px; background: rgba(0,0,0,0.08); border-radius: 5px; overflow: hidden; }
.overall-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-dark));
  border-radius: 5px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.overall-progress-bar-fill.done { background: var(--green); }

/* Customer cards */
.customer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}
.customer-card {
  background: var(--surface);
  border: 1px solid var(--outline-light);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.customer-card:hover { box-shadow: var(--shadow-md); border-color: var(--accent); transform: translateY(-2px); }
.cc-head { display: flex; align-items: flex-start; gap: 12px; }
.cc-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  letter-spacing: -0.3px;
}
.cc-name { font-size: 16px; font-weight: 700; color: var(--text-primary); letter-spacing: -0.2px; line-height: 1.3; }
.cc-since { font-size: 11px; color: var(--text-hint); margin-top: 2px; }
.cc-contact { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-secondary); }
.cc-contact a, .cc-contact span { display: flex; align-items: center; gap: 8px; color: var(--text-secondary); text-decoration: none; min-width: 0; }
.cc-contact a:hover { color: var(--accent-dark); }
.cc-contact .material-icons-round { font-size: 16px; flex-shrink: 0; color: var(--accent-dark); }
.cc-contact .cc-val {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cc-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  padding: 10px;
  background: var(--surface-dim);
  border-radius: var(--radius-xs);
}
.cc-stat { text-align: center; }
.cc-stat-v { font-size: 15px; font-weight: 800; color: var(--accent-dark); }
.cc-stat-l { font-size: 10px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.4px; font-weight: 600; }
.cc-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.cc-actions .btn { flex: 1; min-width: 0; padding: 10px 12px; font-size: 13px; width: auto; }
.cc-actions .btn .material-icons-round { font-size: 16px; }

/* Quotes dashboard */
.quotes-list { background: var(--surface); border: 1px solid var(--outline-light); border-radius: var(--radius); overflow: hidden; }
.quote-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--outline-light);
  cursor: pointer;
  transition: var(--transition);
  gap: 12px;
}
.quote-row:last-child { border-bottom: none; }
.quote-row:hover { background: var(--surface-dim); }
.quote-row-main { flex: 1; min-width: 0; }
.quote-row-title { font-size: 14px; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.quote-row-sub { font-size: 12px; color: var(--text-secondary); }
.quote-row-right { text-align: right; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.quote-row-total { font-size: 14px; font-weight: 700; color: var(--accent-dark); }

/* ============================================
   PWA + mobile polish
   ============================================ */

/* iOS standalone: account for status-bar overlay (we use black-translucent). */
.header {
  padding-top: env(safe-area-inset-top);
  height: calc(56px + env(safe-area-inset-top));
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}
.main {
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

/* iOS keeps zooming inputs <16px on focus — bump on phone widths. */
@media (max-width: 720px) {
  .form-input,
  .form-textarea,
  .chat-input {
    font-size: 16px;
  }
  /* Bigger tap targets */
  .btn, .btn-sm, .btn-secondary, .btn-primary {
    min-height: 44px;
  }
  .header-link, .lang-toggle button, .chat-send {
    min-width: 44px; min-height: 44px;
  }
  /* Use most of the screen for the chat on a phone */
  .chat-messages {
    max-height: calc(100vh - 360px);
    min-height: 220px;
  }
  /* Bottom nav reserves room above the gesture bar / keyboard */
  .bottom-nav {
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
  /* Quote tables on the sign page: never sideways-scroll past the card */
  table { font-size: 13px; }
  table th, table td { padding: 8px 6px; }
  /* Header brand truncates instead of wrapping on tiny phones */
  .header-brand h1 { font-size: 15px; max-width: 60vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* When the contractor has the app installed (display-mode: standalone),
   hide elements explicitly marked as non-standalone (e.g. an "Install" button). */
@media (display-mode: standalone) {
  .install-only { display: none !important; }
}
@media not all and (display-mode: standalone) {
  .standalone-only { display: none !important; }
}
