/* =====================================================================
   Ferreira Soluções Elétricas — style.css
   Paleta inspirada em lâmpada acesa: âmbar/laranja + cinza chumbo
   Mobile-first · PWA · Sem frameworks
   ===================================================================== */

/* ---------------------------------- TOKENS ---------------------------------- */
:root {
  /* Marca */
  --brand-500: #FF9800;
  --brand-600: #F57C00;
  --brand-700: #E65100;
  --brand-050: #FFF4E0;
  --brand-100: #FFE7C2;
  --brand-glow: rgba(255, 152, 0, .35);

  /* Neutros (tema claro) */
  --bg: #f4f4f9;
  --bg-elev: #ffffff;
  --bg-soft: #f7f7fb;
  --surface: #ffffff;
  --surface-2: #f1f2f7;
  --border: #e4e5ee;
  --border-strong: #d3d5e3;
  --text: #2b2d33;
  --text-soft: #5c6070;
  --text-muted: #8e93a3;

  /* Status */
  --ok-500: #16a34a;
  --ok-050: #e7f8ee;
  --warn-500: #d97706;
  --warn-050: #fff6e5;
  --danger-500: #dc2626;
  --danger-050: #fdeaea;

  /* Formas */
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --radius-pill: 999px;

  /* Sombras */
  --shadow-xs: 0 1px 2px rgba(24, 26, 35, .06);
  --shadow-sm: 0 2px 8px rgba(24, 26, 35, .07);
  --shadow-md: 0 8px 24px rgba(24, 26, 35, .10);
  --shadow-lg: 0 18px 48px rgba(24, 26, 35, .18);

  /* Tipografia */
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs-base: 16px;

  /* Layout */
  --header-h: 64px;
  --nav-h: 68px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Tamanho de fonte */
[data-font="small"]  { --fs-base: 15px; }
[data-font="normal"] { --fs-base: 16px; }
[data-font="large"]  { --fs-base: 18px; }

/* Tema escuro */
[data-theme="dark"] {
  --bg: #16181d;
  --bg-elev: #1e2128;
  --bg-soft: #1a1d23;
  --surface: #1e2128;
  --surface-2: #262a33;
  --border: #2f3440;
  --border-strong: #3c4250;
  --text: #f0f1f5;
  --text-soft: #b7bcc9;
  --text-muted: #858b9b;
  --brand-050: rgba(255, 152, 0, .12);
  --brand-100: rgba(255, 152, 0, .2);
  --ok-050: rgba(22, 163, 74, .14);
  --warn-050: rgba(217, 119, 6, .14);
  --danger-050: rgba(220, 38, 38, .14);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, .35);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, .45);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, .6);
}

/* ---------------------------------- RESET ---------------------------------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font-family);
  font-size: var(--fs-base);
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  transition: background-color .25s ease, color .25s ease;
}

h1, h2, h3, h4, p { margin: 0; }
button { font-family: inherit; font-size: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
img { max-width: 100%; display: block; }
ul { list-style: none; margin: 0; padding: 0; }

.is-hidden { display: none !important; }
.muted { color: var(--text-muted); font-size: .9rem; text-align: center; padding: 16px; }

/* ---------------------------------- SHELL ---------------------------------- */
.app-shell {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 12px);
}

/* -------------------------------- HEADER ---------------------------------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(var(--safe-top) + 10px) 14px 10px;
  min-height: var(--header-h);
  background: linear-gradient(135deg, var(--brand-600), var(--brand-500) 70%);
  color: #fff;
  box-shadow: 0 4px 18px var(--brand-glow);
}

[data-theme="dark"] .app-header {
  background: linear-gradient(135deg, #b35c00, #e07b00 70%);
  box-shadow: 0 4px 18px rgba(0, 0, 0, .5);
}

.header-brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }

.header-logo {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  background: rgba(255, 255, 255, .2);
  border: 1px solid rgba(255, 255, 255, .35);
  flex-shrink: 0;
  overflow: hidden;
}
.header-logo.has-logo {
  background: #fff;
  border-color: rgba(255, 255, 255, .8);
}
.header-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 3px;
  display: block;
}

.header-text { min-width: 0; }
.header-text h1 {
  font-size: 1.06rem;
  font-weight: 700;
  letter-spacing: -.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}
.header-text span {
  display: block;
  font-size: .72rem;
  opacity: .9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1rem;
  background: rgba(255, 255, 255, .18);
  border: 1px solid rgba(255, 255, 255, .28);
  color: #fff;
  flex-shrink: 0;
  transition: transform .15s ease, background-color .15s ease;
}
.header-btn:active { transform: scale(.93); background: rgba(255, 255, 255, .3); }
.header-btn--ghost { background: transparent; border-color: transparent; }
.header-btn--ghost:active { background: rgba(255, 255, 255, .18); }

/* -------------------------------- SCREENS --------------------------------- */
.screens { flex: 1; position: relative; }

.screen {
  display: none;
  padding: 16px 14px 24px;
  animation: screenIn .26s ease both;
}
.screen.is-active { display: block; }

@keyframes screenIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* -------------------------------- STATS ----------------------------------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}
.stat-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 11px 9px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  text-align: left;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.stat-card:active { transform: scale(.97); }
.stat-card.is-selected { border-color: var(--brand-500); box-shadow: 0 0 0 2px var(--brand-glow); }

.stat-icon {
  width: 27px;
  height: 27px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-size: .76rem;
  margin-bottom: 2px;
}
.stat-card--pending .stat-icon  { background: var(--warn-050); color: var(--warn-500); }
.stat-card--approved .stat-icon { background: var(--ok-050); color: var(--ok-500); }
.stat-card--refused .stat-icon  { background: var(--danger-050); color: var(--danger-500); }
.stat-card--running .stat-icon  { background: var(--brand-050); color: var(--brand-700); }
.stat-card--done .stat-icon     { background: var(--surface-2); color: var(--text-soft); }

.stat-value { font-size: 1.24rem; font-weight: 800; line-height: 1.1; letter-spacing: -.5px; }
.stat-label {
  font-size: .64rem;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .2px;
  line-height: 1.25;
}

/* ------------------------------ SECTION HEAD ------------------------------- */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 2px 10px;
}
.section-title { font-size: .95rem; font-weight: 700; letter-spacing: -.2px; }

.link-btn {
  font-size: .78rem;
  font-weight: 700;
  color: var(--brand-600);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 2px;
}
[data-theme="dark"] .link-btn { color: var(--brand-500); }

/* --------------------------------- SEARCH ---------------------------------- */
.search-box {
  position: relative;
  margin-bottom: 12px;
}
.search-box i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: .85rem;
  pointer-events: none;
}
.search-box input {
  width: 100%;
  padding: 12px 14px 12px 40px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.search-box input::placeholder { color: var(--text-muted); }
.search-box input:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px var(--brand-glow);
}

/* ----------------------------- QUOTE CARD --------------------------------- */
.list { display: flex; flex-direction: column; gap: 10px; }

.quote-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 14px;
  box-shadow: var(--shadow-xs);
  transition: transform .15s ease, box-shadow .15s ease;
}
.quote-card:active { transform: scale(.985); box-shadow: var(--shadow-sm); }

.quote-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.quote-card-info { min-width: 0; display: flex; flex-direction: column; gap: 1px; }

.quote-number {
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--brand-600);
}
[data-theme="dark"] .quote-number { color: var(--brand-500); }

.quote-client {
  font-size: .98rem;
  font-weight: 700;
  letter-spacing: -.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.quote-meta {
  font-size: .76rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-pill {
  font-size: .68rem;
  font-weight: 800;
  padding: 4px 9px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.status-pill[data-status="pendente"] { background: var(--warn-050); color: var(--warn-500); }
.status-pill[data-status="aprovado"] { background: var(--ok-050); color: var(--ok-500); }
.status-pill[data-status="recusado"] { background: var(--danger-050); color: var(--danger-500); }
.status-pill[data-status="execucao"] { background: var(--brand-050); color: var(--brand-700); }
.status-pill[data-status="finalizado"] { background: var(--surface-2); color: var(--text-soft); }

.quote-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.quote-total { font-size: 1.04rem; font-weight: 800; letter-spacing: -.3px; }
.quote-arrow { color: var(--text-muted); font-size: .78rem; }

/* ----------------------------- CLIENT CARD -------------------------------- */
.client-card {
  display: flex;
  align-items: center;
  gap: 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 12px;
  box-shadow: var(--shadow-xs);
}
.client-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.client-name {
  font-size: .94rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.client-phone { font-size: .78rem; color: var(--text-muted); }
.client-actions { display: flex; gap: 5px; flex-shrink: 0; }

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: .92rem;
  color: #fff;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  flex-shrink: 0;
  letter-spacing: -.3px;
}

/* -------------------------------- EMPTY ---------------------------------- */
.empty-state {
  text-align: center;
  padding: 38px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.empty-state--sm { padding: 26px 16px; }
.empty-icon {
  width: 62px;
  height: 62px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  background: var(--brand-050);
  color: var(--brand-600);
  margin-bottom: 4px;
}
[data-theme="dark"] .empty-icon { color: var(--brand-500); }
.empty-state--sm .empty-icon { width: 48px; height: 48px; font-size: 1.15rem; border-radius: 16px; }
.empty-state h3 { font-size: 1rem; font-weight: 700; }
.empty-state p { font-size: .85rem; color: var(--text-muted); max-width: 290px; }
.empty-state .btn { margin-top: 8px; }

/* --------------------------------- BUTTONS -------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 12px 18px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: .9rem;
  letter-spacing: -.1px;
  border: 1px solid transparent;
  transition: transform .14s ease, filter .14s ease, background-color .14s ease;
  white-space: nowrap;
}
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .55; pointer-events: none; }

.btn--primary {
  background: linear-gradient(135deg, var(--brand-500), var(--brand-600));
  color: #fff;
  box-shadow: 0 6px 16px var(--brand-glow);
}
.btn--success {
  background: linear-gradient(135deg, #22c55e, #15803d);
  color: #fff;
  box-shadow: 0 6px 16px rgba(22, 163, 74, .32);
}
.btn--danger {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  color: #fff;
  box-shadow: 0 6px 16px rgba(220, 38, 38, .28);
}
.btn--danger-soft { background: var(--danger-050); color: var(--danger-500); }
.btn--pdf {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  color: #fff;
  box-shadow: 0 6px 16px rgba(220, 38, 38, .28);
}
.btn--pdf:disabled { opacity: .6; }

/* Alternância de status */
.btn--ok-soft { background: var(--ok-050); color: var(--ok-500); }
.btn--warn-soft { background: var(--warn-050); color: var(--warn-500); }
.btn--ghost { background: var(--surface-2); color: var(--text-soft); border-color: var(--border); }
.btn--soft {
  background: var(--brand-050);
  color: var(--brand-700);
  border-color: var(--brand-100);
}
[data-theme="dark"] .btn--soft { color: var(--brand-500); }
.btn--sm { padding: 9px 14px; font-size: .82rem; }
.btn--block { display: flex; width: 100%; }

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--text-soft);
  font-size: .85rem;
  transition: transform .14s ease, background-color .14s ease;
  flex-shrink: 0;
}
.icon-btn:active { transform: scale(.9); }
.icon-btn--sm { width: 33px; height: 33px; border-radius: 10px; font-size: .76rem; }
.icon-btn--danger { color: var(--danger-500); background: var(--danger-050); }

/* -------------------------------- WIZARD ---------------------------------- */
.wizard-steps {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2px;
  padding: 4px 2px 16px;
  margin-bottom: 4px;
}

.step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  position: relative;
  z-index: 1;
}
.step-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: .74rem;
  font-weight: 800;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 2px solid var(--border);
  transition: all .2s ease;
}
.step-name {
  font-size: .62rem;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.15;
}
.step.is-active .step-dot {
  background: linear-gradient(135deg, var(--brand-500), var(--brand-600));
  border-color: var(--brand-500);
  color: #fff;
  box-shadow: 0 0 0 4px var(--brand-glow);
}
.step.is-active .step-name { color: var(--brand-700); }
[data-theme="dark"] .step.is-active .step-name { color: var(--brand-500); }
.step.is-done .step-dot {
  background: var(--ok-050);
  border-color: var(--ok-500);
  color: var(--ok-500);
}
.step.is-done .step-name { color: var(--ok-500); }

.step-progress {
  position: absolute;
  left: 12%;
  right: 12%;
  top: 17px;
  height: 3px;
  border-radius: 3px;
  background: var(--surface-2);
  z-index: 0;
  overflow: hidden;
}
.step-progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--brand-500), var(--ok-500));
  transition: width .3s ease;
}

.wizard-body { min-height: 40vh; }
.wizard-panel { display: none; animation: panelIn .22s ease both; }
.wizard-panel.is-active { display: block; }

@keyframes panelIn {
  from { opacity: 0; transform: translateX(10px); }
  to   { opacity: 1; transform: translateX(0); }
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.panel-head h3 { font-size: .98rem; font-weight: 700; }
.panel-head p { font-size: .76rem; color: var(--text-muted); }
.panel-title { font-size: .98rem; font-weight: 700; margin-bottom: 12px; }

.wizard-footer {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 9px;
  padding: 12px 0 4px;
  margin-top: 18px;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.wizard-footer .btn { flex: 1; }

/* --------------------------------- FIELDS --------------------------------- */
.field-group { margin-bottom: 14px; }

.field { margin-bottom: 13px; min-width: 0; }
.field label {
  display: block;
  font-size: .78rem;
  font-weight: 700;
  color: var(--text-soft);
  margin-bottom: 5px;
  letter-spacing: .1px;
}
.req { color: var(--danger-500); }
.opt {
  font-size: .62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  margin-left: 4px;
  vertical-align: middle;
}

.field input[type="text"],
.field input[type="tel"],
.field input[type="email"],
.field input[type="number"],
.field input[type="search"],
.field select,
.field textarea {
  width: 100%;
  padding: 12px 13px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease;
  -webkit-appearance: none;
  appearance: none;
}
.field select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238e93a3' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 17px;
  padding-right: 38px;
}
.field textarea { resize: vertical; min-height: 74px; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px var(--brand-glow);
}
.field input::placeholder, .field textarea::placeholder { color: var(--text-muted); }
.field.has-error input, .field.has-error select { border-color: var(--danger-500); }

.field-error {
  display: none;
  font-size: .73rem;
  color: var(--danger-500);
  font-weight: 600;
  margin-top: 4px;
}
.field.has-error .field-error { display: block; }
.field-hint { display: block; font-size: .7rem; color: var(--text-muted); margin-top: 4px; }

.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }
.field-row--3 .field:nth-child(1) { flex: 1.1; }
.field-row--3 .field:nth-child(2) { flex: .85; }
.field-row--3 .field:nth-child(3) { flex: 1.2; }

/* --------------------------------- ITEMS --------------------------------- */
.items-list { display: flex; flex-direction: column; gap: 8px; }

.item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-xs);
}
.item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.item-desc {
  font-size: .88rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item-calc { font-size: .72rem; color: var(--text-muted); }
.item-value { font-size: .88rem; font-weight: 800; white-space: nowrap; color: var(--brand-700); }
[data-theme="dark"] .item-value { color: var(--brand-500); }
.item-actions { display: flex; gap: 4px; flex-shrink: 0; }

.panel-subtotal {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: var(--brand-050);
  border: 1px dashed var(--brand-100);
  font-size: .82rem;
  font-weight: 700;
  color: var(--brand-700);
}
[data-theme="dark"] .panel-subtotal { color: var(--brand-500); }
.panel-subtotal strong { font-size: 1rem; }

/* --------------------------------- UPLOAD -------------------------------- */
.upload-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 26px 16px;
  border-radius: var(--radius);
  border: 2px dashed var(--border-strong);
  background: var(--bg-soft);
  text-align: center;
  cursor: pointer;
  transition: border-color .18s ease, background-color .18s ease;
  margin-bottom: 14px;
}
.upload-box:active { border-color: var(--brand-500); background: var(--brand-050); }
.upload-box i { font-size: 1.5rem; color: var(--brand-600); margin-bottom: 4px; }
.upload-box strong { font-size: .88rem; }
.upload-box span { font-size: .74rem; color: var(--text-muted); }

.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-thumb button {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0, 0, 0, .62);
  color: #fff;
  font-size: .66rem;
  display: grid;
  place-items: center;
  backdrop-filter: blur(4px);
}

/* -------------------------------- SUMMARY -------------------------------- */
.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-xs);
  margin-bottom: 14px;
}
.summary-client {
  display: flex;
  align-items: center;
  gap: 11px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--border);
  margin-bottom: 10px;
}
.summary-client > div:last-child { min-width: 0; display: flex; flex-direction: column; }
.summary-client strong { font-size: .94rem; }
.summary-client span { font-size: .76rem; color: var(--text-muted); }
.summary-address { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.summary-rows { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.summary-description {
  font-size: .8rem;
  line-height: 1.5;
  color: var(--text-soft);
  background: var(--bg-soft);
  border-left: 3px solid var(--brand-500);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  margin-bottom: 10px;
  white-space: pre-wrap;
  word-break: break-word;
}
.summary-description.is-hidden { display: none; }
.summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .82rem;
  color: var(--text-soft);
}
.summary-row span:last-child { font-weight: 700; color: var(--text); }

.summary-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 2px solid var(--brand-500);
}
.summary-total span { font-size: .82rem; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--text-soft); }
.summary-total strong { font-size: 1.28rem; font-weight: 800; letter-spacing: -.5px; color: var(--brand-700); }
[data-theme="dark"] .summary-total strong { color: var(--brand-500); }

/* ------------------------------- SIGNATURE ------------------------------- */
.signature-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow-xs);
}
.signature-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.signature-head strong { font-size: .82rem; }
.badge-optional {
  font-size: .62rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  margin-left: 5px;
}
.signature-canvas-wrap {
  position: relative;
  border-radius: var(--radius-sm);
  border: 1.5px dashed var(--border-strong);
  background: var(--bg-soft);
  overflow: hidden;
  touch-action: none;
}
.signature-canvas-wrap canvas { display: block; width: 100%; height: 150px; touch-action: none; }
.signature-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: .78rem;
  color: var(--text-muted);
  pointer-events: none;
  transition: opacity .2s ease;
}
.signature-hint.is-hidden { display: none; }

/* --------------------------------- DETAIL -------------------------------- */
.detail-hero {
  background: linear-gradient(135deg, var(--brand-600), var(--brand-500));
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 10px 28px var(--brand-glow);
}
[data-theme="dark"] .detail-hero {
  background: linear-gradient(135deg, #b35c00, #e07b00);
  box-shadow: var(--shadow-md);
}
.detail-hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.detail-hero-top .quote-number { color: rgba(255, 255, 255, .85); }
.detail-hero-top .status-pill { background: rgba(255, 255, 255, .22); color: #fff; }
.detail-hero h2 { font-size: 1.16rem; font-weight: 800; letter-spacing: -.3px; margin-bottom: 2px; }
.detail-hero p { font-size: .78rem; opacity: .92; }
.detail-hero-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid rgba(255, 255, 255, .28);
}
.detail-hero-total span { font-size: .74rem; text-transform: uppercase; letter-spacing: .5px; opacity: .9; font-weight: 700; }
.detail-hero-total strong { font-size: 1.42rem; font-weight: 800; letter-spacing: -.6px; }

.detail-actions { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.detail-actions .btn { flex: 1; min-width: 110px; font-size: .82rem; padding: 11px 12px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-xs);
  margin-bottom: 12px;
}
.card-head {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  margin-bottom: 10px;
}
.card-head > i {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: var(--brand-050);
  color: var(--brand-600);
  font-size: .85rem;
  flex-shrink: 0;
}
[data-theme="dark"] .card-head > i { color: var(--brand-500); }
.card-head > div { display: flex; flex-direction: column; min-width: 0; }
.card-head strong { font-size: .88rem; }
.card-head span { font-size: .74rem; color: var(--text-muted); }

.detail-info-rows { display: flex; flex-direction: column; gap: 8px; }
.info-row { display: flex; align-items: flex-start; gap: 9px; font-size: .84rem; }
.info-row i { width: 16px; color: var(--brand-600); font-size: .8rem; margin-top: 3px; flex-shrink: 0; }
[data-theme="dark"] .info-row i { color: var(--brand-500); }
.info-row div { min-width: 0; display: flex; flex-direction: column; }
.info-row span { font-size: .7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .3px; font-weight: 700; }
.info-row strong { font-weight: 600; word-break: break-word; }

.detail-list { display: flex; flex-direction: column; gap: 1px; }
.detail-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
  font-size: .84rem;
}
.detail-item:last-child { border-bottom: 0; }
.detail-item > div { min-width: 0; display: flex; flex-direction: column; }
.detail-item strong { font-weight: 600; }
.detail-item span { font-size: .72rem; color: var(--text-muted); }
.detail-item > b { white-space: nowrap; font-size: .86rem; }

.detail-photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.detail-photos img {
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
}

.detail-signature {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #fff;
  padding: 6px;
}
.detail-signature img { width: 100%; }

.status-switch { display: flex; gap: 7px; margin-top: 4px; flex-wrap: wrap; }
.status-switch .btn { flex: 1 1 auto; font-size: .78rem; padding: 10px 8px; }
.status-switch .btn.is-active { box-shadow: 0 0 0 2px var(--text) inset; }
.status-switch--extra { margin-top: 8px; }

/* ------------------------- TRILHA DE STATUS ------------------------------ */
.status-track {
  display: flex;
  align-items: flex-start;
  gap: 2px;
  margin: 2px 0 14px;
  padding: 0 1px;
}
.status-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-width: 0;
  flex: 0 0 auto;
}
.status-step .dot {
  width: 23px;
  height: 23px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: .64rem;
  font-weight: 800;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 2px solid var(--border);
  transition: background .2s ease, color .2s ease, border-color .2s ease;
}
.status-step .step-label {
  font-size: .58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .2px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.2;
  max-width: 54px;
}
.status-step.is-past .dot {
  background: var(--ok-050);
  color: var(--ok-500);
  border-color: var(--ok-500);
}
.status-step.is-past .step-label { color: var(--ok-500); }
.status-step.is-current .dot {
  background: linear-gradient(135deg, var(--brand-500), var(--brand-600));
  color: #fff;
  border-color: var(--brand-600);
  box-shadow: 0 0 0 3px var(--brand-glow);
}
.status-step.is-current .step-label { color: var(--brand-700); }
[data-theme="dark"] .status-step.is-current .step-label { color: var(--brand-500); }

.status-step-line {
  flex: 1 1 auto;
  height: 2px;
  min-width: 8px;
  margin-top: 11px;
  border-radius: 2px;
  background: var(--border);
}
.status-step.is-past ~ .status-step-line { background: var(--ok-500); }

.status-current {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  margin-bottom: 11px;
}
.status-current small {
  font-size: .73rem;
  color: var(--text-muted);
  line-height: 1.35;
  flex: 1 1 140px;
}
.status-done-note {
  font-size: .8rem;
  color: var(--ok-500);
  font-weight: 600;
  margin: 2px 0 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* -------------------------------- SETTINGS ------------------------------- */
.settings-card { margin-bottom: 12px; }
.settings-card .card-head { margin-bottom: 12px; }

.segmented {
  display: flex;
  gap: 6px;
  padding: 4px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.segmented-btn {
  flex: 1;
  padding: 9px 8px;
  border-radius: var(--radius-pill);
  font-size: .82rem;
  font-weight: 700;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all .18s ease;
}
.segmented-btn.is-active {
  background: var(--surface);
  color: var(--brand-700);
  box-shadow: var(--shadow-xs);
}
[data-theme="dark"] .segmented-btn.is-active { color: var(--brand-500); }
#segFont .segmented-btn[data-font-value="small"] { font-size: .78rem; }
#segFont .segmented-btn[data-font-value="normal"] { font-size: .92rem; }
#segFont .segmented-btn[data-font-value="large"] { font-size: 1.08rem; }

.settings-preview {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  border: 1px dashed var(--border);
  font-size: .84rem;
  color: var(--text-soft);
}

.settings-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.settings-actions .btn { flex: 1; min-width: 130px; }
.settings-about { font-size: .8rem; color: var(--text-muted); line-height: 1.6; }
.settings-footer { display: flex; flex-direction: column; gap: 9px; margin-top: 18px; }

/* --- Abas internas de configurações --- */
.settings-tabs {
  display: flex;
  gap: 6px;
  padding: 5px;
  margin-bottom: 14px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.settings-tabs::-webkit-scrollbar { display: none; }

.settings-tab {
  flex: 1 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 9px 11px;
  border-radius: var(--radius-pill);
  font-size: .76rem;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
  transition: all .18s ease;
}
.settings-tab i { font-size: .82rem; }
.settings-tab.is-active {
  background: var(--surface);
  color: var(--brand-700);
  box-shadow: var(--shadow-xs);
}
[data-theme="dark"] .settings-tab.is-active { color: var(--brand-500); }

.settings-panel { display: none; }
.settings-panel.is-active { display: block; animation: fadeUp .22s ease both; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* --- Logo da empresa --- */
.logo-row { display: flex; gap: 14px; align-items: flex-start; }

.logo-preview {
  position: relative;
  flex: 0 0 96px;
  width: 96px;
  height: 96px;
  border-radius: var(--radius);
  border: 2px dashed var(--border);
  background: var(--bg-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
  color: var(--brand-500);
  font-size: 1.5rem;
}
.logo-preview.has-logo { border-style: solid; background: #fff; }
.logo-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 6px;
  background: #fff;
}
.logo-empty {
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.logo-preview.has-logo .logo-empty,
.logo-preview.has-logo > i { display: none; }

.logo-actions { flex: 1; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.logo-actions .btn { width: auto; }
.logo-actions .field-hint { margin-top: 0; }

/* --- Chips de presets --- */
.preset-chips {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.chip {
  padding: 7px 13px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--brand-100);
  background: var(--brand-050);
  color: var(--brand-700);
  font-size: .72rem;
  font-weight: 700;
  transition: all .16s ease;
}
.chip:hover { background: var(--brand-100); }
.chip:active { transform: scale(.96); }

[data-theme="dark"] .chip {
  color: var(--brand-500);
}

/* ------------------------------- BOTTOM NAV ------------------------------ */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  display: flex;
  padding: 6px 8px calc(6px + var(--safe-bottom));
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 24px rgba(24, 26, 35, .07);
  backdrop-filter: blur(12px);
}
[data-theme="dark"] .bottom-nav { box-shadow: 0 -4px 24px rgba(0, 0, 0, .5); }

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 7px 4px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: .64rem;
  font-weight: 700;
  letter-spacing: .1px;
  transition: color .18s ease, background-color .18s ease;
}
.nav-btn i { font-size: 1.08rem; transition: transform .18s ease; }
.nav-btn.is-active { color: var(--brand-600); background: var(--brand-050); }
[data-theme="dark"] .nav-btn.is-active { color: var(--brand-500); }
.nav-btn.is-active i { transform: translateY(-1px) scale(1.06); }

/* ---------------------------------- FAB ---------------------------------- */
.fab {
  position: fixed;
  right: 16px;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 16px);
  z-index: 46;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.22rem;
  color: #fff;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-600));
  box-shadow: 0 10px 26px var(--brand-glow), 0 2px 6px rgba(0, 0, 0, .12);
  transition: transform .18s cubic-bezier(.34, 1.56, .64, 1), opacity .18s ease;
}
/* O Font Awesome 7 também define .fab (ícones de marca) com largura própria */
button.fab { width: 56px; height: 56px; font-family: inherit; line-height: normal; }
.fab:active { transform: scale(.9); }
.fab.is-hidden { display: none; }

/* --------------------------------- MODAIS -------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: flex-end;
  justify-content: center;
  background: rgba(16, 18, 24, .55);
  backdrop-filter: blur(3px);
  padding: 0;
}
.modal-overlay.is-open { display: flex; animation: overlayIn .18s ease both; }
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: 100%;
  max-width: 540px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-lg);
  animation: modalUp .26s cubic-bezier(.22, 1, .36, 1) both;
  padding-bottom: var(--safe-bottom);
}
@keyframes modalUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.modal--sm { max-width: 420px; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-head::before {
  content: "";
  position: absolute;
  top: 7px;
  left: 50%;
  transform: translateX(-50%);
  width: 38px;
  height: 4px;
  border-radius: 4px;
  background: var(--border-strong);
}
.modal-head { position: relative; }
.modal-head h3 { font-size: 1rem; font-weight: 700; letter-spacing: -.2px; }

.modal-body { padding: 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modal-body--list { max-height: 56vh; }
.modal-foot {
  display: flex;
  gap: 9px;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-foot .btn { flex: 1; }

.modal-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  background: var(--brand-050);
  border: 1px dashed var(--brand-100);
  font-size: .84rem;
  font-weight: 700;
  color: var(--brand-700);
}
[data-theme="dark"] .modal-total { color: var(--brand-500); }
.modal-total strong { font-size: 1.04rem; }

.confirm-text { font-size: .9rem; color: var(--text-soft); line-height: 1.6; }

/* ---------------------------------- TOAST -------------------------------- */
.toast-container {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 78px);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: calc(100% - 32px);
  max-width: 420px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 16px;
  border-radius: var(--radius-pill);
  background: #23262e;
  color: #fff;
  font-size: .84rem;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  animation: toastIn .24s cubic-bezier(.22, 1, .36, 1) both;
  max-width: 100%;
  pointer-events: auto;
}
.toast i { font-size: .88rem; flex-shrink: 0; }
.toast--success i { color: #4ade80; }
.toast--error i { color: #f87171; }
.toast--info i { color: var(--brand-500); }
.toast.is-leaving { animation: toastOut .22s ease both; }

@keyframes toastIn  { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toastOut { from { opacity: 1; transform: translateY(0) scale(1); } to { opacity: 0; transform: translateY(-8px) scale(.96); } }

/* ------------------------------ PHOTO VIEWER ----------------------------- */
.modal-overlay--dark { background: rgba(0, 0, 0, .92); align-items: center; padding: 20px; }
.photo-viewer { position: relative; max-width: 90vw; max-height: 86vh; }
.photo-viewer img { border-radius: var(--radius); max-height: 86vh; object-fit: contain; margin: 0 auto; }
.photo-viewer-close {
  position: absolute;
  top: -14px;
  right: -8px;
  background: rgba(255, 255, 255, .16);
  color: #fff;
}

/* ------------------------------- UTILITIES ------------------------------- */
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }

/* ------------------------------ RESPONSIVE ------------------------------- */
@media (min-width: 640px) {
  .screens { max-width: 640px; margin: 0 auto; width: 100%; }
  .app-header { padding-left: 20px; padding-right: 20px; }
  .bottom-nav {
    max-width: 640px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border: 1px solid var(--border);
    border-bottom: 0;
  }
  .fab { right: calc(50% - 302px); }
  .photo-grid, .detail-photos { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 880px) {
  .modal-overlay { align-items: center; padding: 24px; }
  .modal { border-radius: var(--radius-lg); animation: modalPop .22s cubic-bezier(.22, 1, .36, 1) both; }
  @keyframes modalPop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }
  .modal-head::before { display: none; }
}

/* --------------------------- ACESSIBILIDADE ----------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; }

/* ------------------------------ PRINT / PDF ------------------------------ */
@media print {
  .app-header, .bottom-nav, .fab, .detail-actions, .wizard-footer,
  .wizard-steps, .search-box, .toast-container, .modal-overlay { display: none !important; }
  body { background: #fff; color: #000; }
  .card, .detail-hero { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  .screen { display: block !important; padding: 0; }
}
