:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef1f4;
  --text: #111827;
  --muted: #667085;
  --line: #dfe3e8;
  --accent: #2f3a46;
  --accent-strong: #111827;
  --accent-soft: #e8edf2;
  --success: #157347;
  --danger: #b42318;
  --warning: #9a6700;
  --shadow: 0 14px 35px rgba(17, 24, 39, .08);
  --shadow-hover: 0 20px 48px rgba(17, 24, 39, .14);
}

html[data-theme="dark"] {
  --bg: #111418;
  --surface: #191d22;
  --surface-2: #20252b;
  --surface-3: #282e35;
  --text: #f3f4f6;
  --muted: #aab2bd;
  --line: #343b44;
  --accent: #d7dde4;
  --accent-strong: #ffffff;
  --accent-soft: #262d34;
  --shadow: 0 14px 35px rgba(0,0,0,.25);
  --shadow-hover: 0 20px 48px rgba(0,0,0,.34);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: radial-gradient(circle at 50% -20%, rgba(148,163,184,.16), transparent 36rem), var(--bg);
  color: var(--text);
  transition: background-color .25s ease, color .25s ease;
}
button, input { font: inherit; }
a { color: inherit; }
svg { width: 1em; height: 1em; fill: currentColor; display: block; }

.shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0 96px; }
.top-actions { position: fixed; right: 20px; top: 18px; display: flex; gap: 9px; z-index: 20; }
.icon-btn {
  width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 92%, transparent); color: var(--text);
  display: grid; place-items: center; cursor: pointer; box-shadow: 0 6px 18px rgba(17,24,39,.06);
}
.icon-btn:hover { transform: translateY(-1px); border-color: #b9c0c8; }
.icon-btn svg { width: 20px; height: 20px; }

.brand-header { text-align: center; padding: 30px 120px 14px; }
.brand-lockup { display: inline-flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 50px; height: 50px; border-radius: 15px; display: grid; place-items: center;
  background: var(--accent-strong); color: var(--surface); font-weight: 800; letter-spacing: -.04em;
  box-shadow: var(--shadow);
}
.brand-title { margin: 0; font-size: clamp(2rem, 5vw, 3.35rem); letter-spacing: -.045em; line-height: 1; }
.brand-subtitle { margin: 12px 0 0; color: var(--muted); font-size: .96rem; }
.brand-subtitle strong { color: var(--text); letter-spacing: .08em; font-size: .82rem; }

.user-strip {
  margin: 22px auto 28px; display: flex; justify-content: space-between; align-items: center; gap: 18px;
  padding: 12px 14px 12px 18px; border: 1px solid var(--line); background: var(--surface);
  border-radius: 16px; box-shadow: 0 8px 28px rgba(17,24,39,.045);
}
.user-info { min-width: 0; }
.user-name { font-weight: 700; }
.user-meta { color: var(--muted); font-size: .82rem; margin-top: 2px; }
.status-pill { display: inline-flex; align-items: center; gap: 7px; font-size: .78rem; color: var(--muted); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #22a06b; box-shadow: 0 0 0 4px rgba(34,160,107,.12); }

.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.action-card {
  position: relative; min-height: 190px; padding: 28px 22px; border-radius: 22px;
  background: var(--surface); border: 1px solid var(--line); text-decoration: none; text-align: center;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: var(--shadow); transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.action-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); border-color: #b9c0c8; }
.action-card .card-icon { width: 54px; height: 54px; display: grid; place-items: center; color: var(--accent-strong); margin-bottom: 15px; }
.action-card .card-icon svg { width: 46px; height: 46px; }
.action-card h2 { font-size: 1.1rem; margin: 0 0 7px; letter-spacing: -.018em; }
.action-card p { margin: 0; color: var(--muted); font-size: .85rem; line-height: 1.45; }
.card-count {
  position: absolute; right: 13px; top: 13px; min-width: 31px; height: 25px; padding: 0 8px;
  display: grid; place-items: center; border-radius: 999px; background: var(--accent-soft); color: var(--text);
  font-size: .72rem; font-weight: 800;
}

.divider { margin: 36px 0 24px; border: 0; border-top: 1px dashed var(--line); }
.center { text-align: center; }
.link-button {
  border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 9px 14px;
  border-radius: 10px; font-weight: 650; display: inline-flex; align-items: center; gap: 8px;
}
.link-button:hover { background: var(--surface-3); color: var(--text); }
.future-wrap { display: none; margin-top: 18px; }
.future-wrap.open { display: block; animation: reveal .22s ease; }
@keyframes reveal { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.future-grid .action-card { min-height: 160px; opacity: .72; box-shadow: none; }
.future-grid .action-card:hover { opacity: 1; }

.bottom-cards { margin-top: 32px; display: flex; justify-content: flex-end; gap: 12px; }
.small-card {
  width: 118px; min-height: 92px; padding: 16px 12px; border: 1px solid var(--line); border-radius: 18px;
  background: var(--surface); text-decoration: none; display: flex; flex-direction: column; gap: 8px; align-items: center;
  justify-content: center; position: relative; cursor: pointer;
}
.small-card:hover { box-shadow: var(--shadow); }
.small-card svg { width: 28px; height: 28px; }
.small-card span { font-size: .82rem; font-weight: 700; }
.chat-dot { position: absolute; right: 16px; top: 13px; width: 9px; height: 9px; border-radius: 50%; background: #d92d20; display: none; }
.chat-dot.show { display: block; }

.footer {
  position: fixed; left: 0; right: 0; bottom: 0; min-height: 48px; padding: 9px 24px;
  border-top: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(14px); display: flex; align-items: center; justify-content: space-between; gap: 16px;
  color: var(--muted); font-size: .75rem; z-index: 15;
}
.consultatica { font-weight: 850; color: var(--text); letter-spacing: .12em; text-decoration: none; }

.modal-backdrop { position: fixed; inset: 0; display: none; place-items: center; padding: 20px; background: rgba(8,12,18,.68); z-index: 50; }
.modal-backdrop.open { display: grid; }
.modal { width: min(430px, 100%); border-radius: 22px; background: var(--surface); padding: 26px; border: 1px solid var(--line); box-shadow: 0 30px 80px rgba(0,0,0,.28); }
.modal h3 { margin: 0 0 8px; }
.modal p { margin: 0 0 20px; color: var(--muted); line-height: 1.55; }
.btn {
  border: 0; border-radius: 12px; padding: 11px 16px; cursor: pointer; font-weight: 750;
  background: var(--accent-strong); color: var(--surface); text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:hover { filter: brightness(.95); }
.btn.secondary { background: var(--surface-3); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: #b42318; color: #fff; }

.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 28px 16px; }
.auth-card { width: min(430px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 26px; padding: 32px; box-shadow: var(--shadow); }
.auth-brand { text-align: center; margin-bottom: 26px; }
.auth-brand .brand-mark { margin: 0 auto 15px; }
.auth-brand h1 { margin: 0; letter-spacing: -.04em; font-size: 2rem; }
.auth-brand p { margin: 8px 0 0; color: var(--muted); font-size: .88rem; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 7px; font-size: .82rem; font-weight: 720; }
.form-control {
  width: 100%; height: 46px; border: 1px solid var(--line); border-radius: 12px; padding: 0 13px;
  color: var(--text); background: var(--surface-2); outline: none;
}
.form-control:focus { border-color: #89939f; box-shadow: 0 0 0 3px rgba(100,116,139,.12); }
.form-note { color: var(--muted); font-size: .77rem; line-height: 1.45; margin-top: 6px; }
.auth-submit { width: 100%; height: 46px; margin-top: 4px; }
.alert { padding: 11px 13px; border-radius: 12px; margin-bottom: 16px; font-size: .84rem; line-height: 1.45; }
.alert.error { background: rgba(180,35,24,.09); color: var(--danger); border: 1px solid rgba(180,35,24,.2); }
.alert.success { background: rgba(21,115,71,.09); color: var(--success); border: 1px solid rgba(21,115,71,.2); }
.alert.info { background: var(--surface-3); color: var(--text); border: 1px solid var(--line); }
.setup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.setup-grid .wide { grid-column: 1 / -1; }

.page-card { max-width: 820px; margin: 38px auto; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 28px; box-shadow: var(--shadow); }
.page-card h1 { margin-top: 0; }
.kpi-list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 22px 0; }
.kpi { background: var(--surface-2); border: 1px solid var(--line); border-radius: 15px; padding: 14px; }
.kpi strong { display: block; font-size: 1.5rem; }
.kpi span { color: var(--muted); font-size: .76rem; }

@media (max-width: 900px) {
  .grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .brand-header { padding-left: 80px; padding-right: 80px; }
  .kpi-list { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .shell { width: min(100% - 22px, 1180px); padding-top: 18px; }
  .top-actions { right: 11px; top: 11px; }
  .brand-header { padding: 72px 4px 8px; }
  .brand-lockup { display: block; }
  .brand-mark { margin: 0 auto 14px; }
  .grid { grid-template-columns: 1fr; }
  .action-card { min-height: 150px; }
  .bottom-cards { justify-content: center; flex-wrap: wrap; }
  .user-strip { align-items: flex-start; flex-direction: column; }
  .footer { position: static; margin-top: 40px; flex-direction: column; text-align: center; }
  body { padding-bottom: 0; }
  .setup-grid { grid-template-columns: 1fr; }
  .setup-grid .wide { grid-column: auto; }
}


/* ===== FASE 3: módulos de Clientes e Produtos ===== */
.module-shell { padding-top: 54px; }
.module-header { display:flex; align-items:flex-end; justify-content:space-between; gap:20px; margin-bottom:24px; }
.module-header h1 { margin:4px 0 8px; font-size:clamp(2rem,4vw,3rem); letter-spacing:-.04em; }
.module-header p { margin:0; color:var(--muted); }
.eyebrow { color:var(--muted); font-size:.72rem; font-weight:800; letter-spacing:.13em; text-transform:uppercase; }
.danger-text { color:var(--danger); }
.no-margin { margin:0!important; }
.muted { color:var(--muted); }
.small { font-size:.78rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }

.toolbar-card { display:flex; align-items:end; justify-content:space-between; gap:14px; flex-wrap:wrap; background:var(--surface); border:1px solid var(--line); border-radius:18px; padding:14px; margin-bottom:16px; box-shadow:0 8px 26px rgba(17,24,39,.04); }
.search-form { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.search-form.grow { flex:1 1 360px; }
.search-box { position:relative; min-width:min(460px, 68vw); flex:1; }
.search-box > span { position:absolute; left:13px; top:50%; transform:translateY(-50%); color:var(--muted); pointer-events:none; }
.search-box > span svg { width:18px; height:18px; }
.search-box .form-control { padding-left:40px; }
.category-form { min-width:250px; }
.category-form label { display:block; color:var(--muted); font-size:.74rem; font-weight:750; margin-bottom:6px; }
.toolbar-actions { display:flex; gap:8px; flex-wrap:wrap; }
.btn.ghost { background:transparent; color:var(--muted); border:1px solid transparent; }
.btn.ghost:hover { color:var(--text); background:var(--surface-3); }

.data-card { background:var(--surface); border:1px solid var(--line); border-radius:20px; overflow:hidden; box-shadow:var(--shadow); }
.data-card-head { padding:15px 18px; display:flex; align-items:center; justify-content:space-between; gap:12px; border-bottom:1px solid var(--line); background:var(--surface-2); font-size:.86rem; }
.table-scroll { width:100%; overflow:auto; }
.data-table { width:100%; border-collapse:separate; border-spacing:0; min-width:1040px; font-size:.82rem; }
.data-table th { position:sticky; top:0; z-index:2; background:var(--surface-2); color:var(--muted); font-size:.69rem; letter-spacing:.04em; text-transform:uppercase; text-align:left; padding:11px 13px; border-bottom:1px solid var(--line); white-space:nowrap; }
.data-table th a { text-decoration:none; color:inherit; }
.data-table th a:hover { color:var(--text); }
.data-table td { padding:12px 13px; border-bottom:1px solid var(--line); vertical-align:top; }
.data-table tbody tr:hover td { background:color-mix(in srgb,var(--surface-3) 62%,transparent); }
.data-table tbody tr:last-child td { border-bottom:0; }
.data-table .num { text-align:right; white-space:nowrap; }
.wrap-cell { min-width:180px; max-width:340px; white-space:normal; line-height:1.5; }
.actions-col { text-align:center!important; }
.empty-cell { text-align:center; color:var(--muted); padding:36px!important; }
.row-actions { display:flex; justify-content:center; gap:6px; align-items:center; }
.row-actions form { margin:0; }
.square-btn { width:32px; height:32px; border-radius:9px; display:inline-grid; place-items:center; border:1px solid var(--line); background:var(--surface-2); color:var(--text); cursor:pointer; text-decoration:none; padding:0; }
.square-btn:hover { background:var(--surface-3); transform:translateY(-1px); }
.square-btn svg { width:16px; height:16px; }
.square-btn.history { color:#7255a6; }
.square-btn.danger-outline { color:var(--danger); }
.pagination { display:flex; gap:6px; align-items:center; justify-content:center; padding:15px; border-top:1px solid var(--line); }
.pagination a { min-width:34px; height:34px; display:grid; place-items:center; border:1px solid var(--line); border-radius:9px; text-decoration:none; font-size:.78rem; }
.pagination a.active { background:var(--accent-strong); color:var(--surface); border-color:var(--accent-strong); }

.wide-modal { width:min(760px,100%); max-height:90vh; overflow:auto; }
.modal-head { display:flex; align-items:flex-start; justify-content:space-between; gap:16px; margin-bottom:20px; }
.modal-head h3 { margin:3px 0 0; font-size:1.45rem; }
.modal-head .icon-btn { flex:0 0 auto; box-shadow:none; font-size:1.4rem; text-decoration:none; }
.form-grid { display:grid; grid-template-columns:1fr 1fr; gap:14px; }
.form-grid .wide { grid-column:1/-1; }
.form-control.textarea, textarea.form-control { height:auto; min-height:92px; padding-top:11px; resize:vertical; }
.modal-actions { display:flex; justify-content:flex-end; gap:9px; margin-top:8px; }
button:disabled { opacity:.45; cursor:not-allowed; }
.history-list { display:grid; gap:10px; }
.history-list article { padding:12px 14px; border:1px solid var(--line); border-radius:14px; background:var(--surface-2); }
.history-list time { color:var(--muted); font-size:.72rem; }
.history-list article p { margin:6px 0 0; white-space:pre-wrap; }
.history-list details { border-top:1px dashed var(--line); padding-top:10px; }
.history-list summary { cursor:pointer; color:var(--muted); font-size:.8rem; }
.history-list pre { white-space:pre-wrap; overflow-wrap:anywhere; background:var(--surface-2); border:1px solid var(--line); padding:12px; border-radius:12px; font-size:.76rem; }
.products-table { min-width:1500px; }
.products-toolbar { align-items:flex-end; }

@media (max-width: 760px) {
  .module-shell { padding-top:72px; }
  .module-header { align-items:flex-start; flex-direction:column; }
  .module-header .btn { width:100%; }
  .search-form, .search-form.grow, .category-form { width:100%; min-width:0; }
  .search-box { min-width:0; width:100%; }
  .toolbar-card .btn { flex:1 1 auto; }
  .toolbar-actions { width:100%; }
  .form-grid { grid-template-columns:1fr; }
  .form-grid .wide { grid-column:auto; }
  .data-card-head { align-items:flex-start; flex-direction:column; }
}

/* ===== FASE 4: Gerador de Orçamentos ===== */
.generator-shell{padding-bottom:88px}.generator-header{align-items:flex-end}.quote-card{background:var(--surface);border:1px solid var(--line);border-radius:20px;padding:22px;margin-bottom:18px;box-shadow:var(--shadow)}.quote-section-head{display:flex;justify-content:space-between;align-items:center;gap:18px;padding-bottom:14px;margin-bottom:18px;border-bottom:1px solid var(--line)}.quote-section-head h2{margin:3px 0 0;font-size:1.45rem}.quote-items-card{padding:0;overflow:hidden}.quote-items-card .quote-section-head{padding:20px 22px 15px;margin:0}.quote-table{min-width:820px}.quote-description{min-width:340px;max-width:560px}.quote-description small{display:block;color:var(--muted);font-family:ui-monospace,monospace;font-size:.67rem;margin-top:4px}.line-input{width:76px;height:36px;border:1px solid var(--line);border-radius:9px;background:var(--surface-2);color:var(--text);padding:0 8px;text-align:right}.quote-summary{display:flex;justify-content:flex-end;padding:18px 22px 22px;border-top:1px solid var(--line);background:var(--surface-2)}.totals-box{width:min(360px,100%)}.totals-box>div{display:flex;justify-content:space-between;gap:20px;padding:9px 0;border-bottom:1px solid var(--line)}.totals-box>div.grand{font-size:1.18rem;border-bottom:0;padding-top:13px}.generator-actions{display:flex;justify-content:flex-end;gap:10px;margin:18px 0 36px}.save-quote-btn{background:#166534}.pdf-btn{color:#5d3f86!important}.product-picker-modal{width:min(1180px,100%);max-height:92vh;overflow:auto}.category-grid{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:9px}.category-chip{border:1px solid var(--line);background:var(--surface-2);color:var(--text);padding:11px 10px;border-radius:11px;cursor:pointer;font-weight:700;font-size:.79rem}.category-chip:hover,.category-chip.active{background:var(--accent-strong);color:var(--surface);border-color:var(--accent-strong)}.product-picker-stage{margin-top:22px;padding-top:18px;border-top:1px dashed var(--line)}.picker-title{display:flex;align-items:flex-end;justify-content:space-between;gap:18px;margin-bottom:11px}.picker-search{min-width:min(420px,48vw)}.picker-loading{text-align:center;color:var(--muted);padding:18px}.picker-table-scroll{max-height:48vh}.picker-table{min-width:980px}.picker-id{display:block;color:var(--muted);font-size:.67rem;margin-top:4px;font-family:ui-monospace,monospace}.picker-action{display:flex;align-items:center;justify-content:flex-end;gap:5px;min-width:230px}.picker-action .btn{padding:7px 10px;border-radius:8px;font-size:.72rem}.picker-qty{width:50px;height:32px;border:1px solid var(--line);background:var(--surface-2);color:var(--text);border-radius:7px;text-align:center}.qty-minus,.qty-plus{width:30px;height:30px;border:1px solid var(--line);border-radius:7px;background:var(--surface-3);color:var(--text);cursor:pointer}.added-badge{color:var(--success);font-weight:750;font-size:.76rem}.manual-modal{width:min(600px,100%)}.success-modal{text-align:center}.success-symbol{width:64px;height:64px;border-radius:50%;display:grid;place-items:center;background:rgba(21,115,71,.12);color:var(--success);font-size:2.2rem;font-weight:800;margin:0 auto 15px}.success-modal h3{font-size:1.5rem}.success-actions{display:grid;grid-template-columns:1fr 1fr;gap:9px}.success-home{width:100%;margin-top:9px;border:1px solid var(--line)!important}.alert[hidden]{display:none!important}
@media(max-width:900px){.category-grid{grid-template-columns:repeat(3,minmax(0,1fr))}.picker-title{align-items:stretch;flex-direction:column}.picker-search{min-width:0;width:100%}}
@media(max-width:650px){.generator-shell{padding-bottom:20px}.items-head{align-items:flex-start;flex-direction:column}.items-head .toolbar-actions{width:100%}.generator-actions{flex-direction:column}.generator-actions .btn{width:100%}.category-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.success-actions{grid-template-columns:1fr}.quote-card{padding:16px}.quote-items-card{padding:0}.quote-summary{padding:14px}.quote-section-head{align-items:flex-start}}

/* ===== FASE 5: Histórico de Orçamentos ===== */
.history-shell{padding-bottom:84px}.history-kpis{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px;margin-bottom:16px}.history-kpi{display:flex;align-items:center;justify-content:space-between;gap:14px;padding:14px 16px;border-radius:16px;background:var(--surface);border:1px solid var(--line);box-shadow:0 8px 26px rgba(17,24,39,.04);text-decoration:none;color:var(--text);transition:.18s ease}.history-kpi:hover,.history-kpi.active{transform:translateY(-1px);border-color:var(--accent-strong)}.history-kpi span{color:var(--muted);font-size:.78rem;font-weight:760}.history-kpi strong{font-size:1.25rem}.history-kpi.pending strong{color:#a16900}.history-kpi.approved strong{color:var(--success)}.history-kpi.rejected strong{color:var(--danger)}.history-toolbar{align-items:stretch}.history-filter-form{display:grid;grid-template-columns:minmax(280px,1fr) 160px 150px 150px auto;gap:10px;align-items:end;width:100%}.history-search{min-width:0}.history-filter-field label{display:block;color:var(--muted);font-size:.72rem;font-weight:760;margin-bottom:6px}.history-table{min-width:1050px}.history-client-meta{display:block;color:var(--muted);font-size:.69rem;margin-top:4px}.history-status-select{height:34px;padding:4px 28px 4px 9px;font-size:.75rem;font-weight:750;min-width:118px}.history-table tr[data-status="Pendente"] td{background:color-mix(in srgb,#f59e0b 5%,var(--surface))}.history-table tr[data-status="Aprovado"] td{background:color-mix(in srgb,#16a34a 5%,var(--surface))}.history-table tr[data-status="Rejeitado"] td{background:color-mix(in srgb,#dc2626 4%,var(--surface))}.history-table tbody tr:hover td{filter:brightness(.985)}.history-actions{min-width:158px}.history-edit{color:#2463a7}.history-copy{color:#0f766e}.history-pdf{color:#7c3aed}.status-badge{display:inline-flex;align-items:center;padding:5px 9px;border-radius:999px;font-size:.72rem;font-weight:760;border:1px solid var(--line)}.status-badge.pendente{color:#946200;background:rgba(245,158,11,.08)}.status-badge.aprovado{color:var(--success);background:rgba(22,163,74,.08)}.status-badge.rejeitado{color:var(--danger);background:rgba(220,38,38,.07)}.row-busy{opacity:.45;pointer-events:none}.pagination-gap{display:grid;place-items:center;color:var(--muted);padding:0 2px}
@media(max-width:980px){.history-filter-form{grid-template-columns:1fr 1fr}.history-search{grid-column:1/-1}.history-filter-form .toolbar-actions{grid-column:1/-1}.history-kpis{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:650px){.history-kpis{grid-template-columns:1fr 1fr}.history-filter-form{grid-template-columns:1fr}.history-search,.history-filter-form .toolbar-actions{grid-column:auto}.history-filter-form .toolbar-actions .btn{flex:1}.history-shell{padding-bottom:20px}}

/* ===== FASE 6: Definições ===== */
.settings-shell{padding-bottom:86px}.settings-header{align-items:flex-end}.settings-layout{display:grid;grid-template-columns:minmax(0,1.65fr) minmax(290px,.75fr);gap:18px;align-items:start}.settings-form{display:grid;gap:18px}.settings-card{background:var(--surface);border:1px solid var(--line);border-radius:20px;padding:22px;box-shadow:var(--shadow)}.settings-card-head{display:flex;align-items:flex-start;justify-content:space-between;gap:14px;border-bottom:1px solid var(--line);padding-bottom:14px;margin-bottom:18px}.settings-card-head h2{margin:3px 0 0;font-size:1.42rem}.settings-updated{color:var(--muted);font-size:.7rem;white-space:nowrap}.settings-grid .form-group{margin-bottom:0}.settings-footer-text{min-height:132px!important}.settings-actions{display:flex;justify-content:flex-end}.settings-save{background:#166534;min-width:210px}.settings-preview-wrap{position:sticky;top:62px}.settings-preview{background:#fff;color:#1f2937;border:1px solid #d7dce2;border-radius:18px;padding:24px;box-shadow:0 18px 48px rgba(17,24,39,.09);min-height:480px}.settings-preview-top{display:flex;align-items:center;gap:12px}.settings-preview-top h2{margin:2px 0 0;font-size:1.55rem;color:#111827}.cg-mark-mini{width:40px;height:40px;border-radius:11px;background:#111827;color:#fff;display:grid;place-items:center;font-weight:900;font-size:.78rem}.settings-preview-rule{height:2px;background:#374151;margin:16px 0 20px}.settings-preview-block{font-size:.78rem;line-height:1.55}.settings-preview-block>span{display:block;color:#6b7280;font-size:.7rem;margin-bottom:3px}.settings-preview-block strong{font-size:.9rem}.settings-preview-block p{margin:2px 0;color:#4b5563}.settings-preview-lines{margin:25px 0;display:grid;gap:9px}.settings-preview-lines i{display:block;height:8px;background:#eef0f3;border-radius:3px}.settings-preview-lines i:nth-child(2){width:82%}.settings-preview-lines i:nth-child(3){width:91%}.settings-preview-lines i:nth-child(4){width:64%}.settings-preview-total{display:flex;justify-content:space-between;border-top:1px solid #d8dde3;border-bottom:1px solid #d8dde3;padding:12px 0;font-size:.88rem}.settings-preview-footer{margin-top:32px;padding-top:14px;border-top:1px solid #d8dde3;text-align:center;color:#6b7280;font-size:.66rem;line-height:1.55;overflow-wrap:anywhere}.settings-note{margin-top:12px}.settings-form input:disabled,.settings-form textarea:disabled{opacity:.72;cursor:not-allowed}
@media(max-width:980px){.settings-layout{grid-template-columns:1fr}.settings-preview-wrap{position:static}.settings-preview{min-height:0}.settings-preview-wrap{max-width:620px;width:100%;justify-self:center}}
@media(max-width:650px){.settings-shell{padding-bottom:20px}.settings-card{padding:16px}.settings-card-head{flex-direction:column}.settings-actions .btn{width:100%}.settings-preview{padding:18px}}

/* ===== FASE 7: revisão global, acessibilidade e diagnóstico ===== */
:where(a,button,input,select,textarea):focus-visible{outline:3px solid color-mix(in srgb,var(--accent-strong) 34%,transparent);outline-offset:2px}
.table-scroll{scrollbar-width:thin;scrollbar-color:var(--line) transparent}
.table-scroll::-webkit-scrollbar{height:10px;width:10px}.table-scroll::-webkit-scrollbar-thumb{background:var(--line);border-radius:99px}
.health-shell{padding-bottom:86px}.health-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px;margin:0 0 16px}.health-card{background:var(--surface);border:1px solid var(--line);border-radius:18px;padding:16px;box-shadow:0 8px 26px rgba(17,24,39,.04)}.health-card span{display:block;color:var(--muted);font-size:.72rem;font-weight:800;text-transform:uppercase;letter-spacing:.08em}.health-card strong{display:block;font-size:1.15rem;margin:7px 0 5px}.health-card small{color:var(--muted);line-height:1.45}.health-table{min-width:520px}.health-kpis{margin-top:16px}
@media(max-width:900px){.health-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:600px){.health-grid{grid-template-columns:1fr}.health-shell{padding-bottom:20px}.module-header{align-items:flex-start;flex-direction:column}.module-header>.toolbar-actions,.module-header>.btn{width:100%}.module-header>.btn{justify-content:center}.data-card{border-radius:16px}.table-scroll{overscroll-behavior-x:contain}.toolbar-card{padding:12px}.search-box{min-width:0;width:100%}}

/* ===== FASE 8: PWA, instalação e acabamento para produção ===== */
html,body{min-height:100%;min-height:100dvh}
body{padding-left:env(safe-area-inset-left);padding-right:env(safe-area-inset-right)}
.top-actions{top:max(18px,env(safe-area-inset-top));right:max(20px,env(safe-area-inset-right))}
.pwa-install-trigger{font-size:1.25rem;font-weight:900;line-height:1}.pwa-install-trigger span{transform:translateY(-1px)}
.pwa-install-backdrop{position:fixed;inset:0;z-index:1000;display:none;place-items:center;padding:22px;background:rgba(7,10,15,.62);backdrop-filter:blur(8px)}
.pwa-install-backdrop.open{display:grid;animation:pwaFade .18s ease}
@keyframes pwaFade{from{opacity:0}to{opacity:1}}
.pwa-install-modal{width:min(560px,100%);display:grid;grid-template-columns:auto 1fr;gap:18px;background:var(--surface);border:1px solid var(--line);border-radius:26px;padding:24px;box-shadow:0 35px 100px rgba(0,0,0,.32)}
.pwa-install-icon{width:82px;height:82px;border-radius:22px;overflow:hidden;box-shadow:0 12px 28px rgba(17,24,39,.18)}
.pwa-install-icon img{display:block;width:100%;height:100%;object-fit:cover}
.pwa-install-content h2{margin:3px 0 8px;font-size:1.45rem;letter-spacing:-.025em}.pwa-install-content p{margin:0;color:var(--muted);line-height:1.55}.pwa-kicker{font-size:.68rem;font-weight:850;letter-spacing:.12em;text-transform:uppercase;color:var(--muted)}
.pwa-install-details{margin-top:12px!important;padding:10px 12px;border-radius:12px;background:var(--surface-3);border:1px solid var(--line);font-size:.78rem;color:var(--text)!important}
.pwa-install-actions{grid-column:1/-1;display:flex;justify-content:flex-end;gap:10px;padding-top:4px}.pwa-install-actions .btn{min-width:135px}
.pwa-update-toast{position:fixed;left:50%;bottom:max(64px,calc(16px + env(safe-area-inset-bottom)));transform:translateX(-50%);z-index:900;display:flex;align-items:center;gap:18px;width:min(520px,calc(100% - 28px));padding:12px 13px 12px 16px;border:1px solid var(--line);border-radius:16px;background:var(--surface);box-shadow:0 22px 65px rgba(0,0,0,.22)}
.pwa-update-toast span{display:flex;flex-direction:column;gap:2px;flex:1}.pwa-update-toast strong{font-size:.82rem}.pwa-update-toast small{font-size:.7rem;color:var(--muted)}.pwa-update-toast button{border:0;border-radius:10px;background:var(--accent-strong);color:var(--surface);font-weight:800;padding:9px 12px;cursor:pointer}

/* Aproveita melhor monitores grandes sem perder a grelha original. */
@media(min-width:1360px){.shell{width:min(1480px,calc(100% - 48px))}.grid{gap:22px}.action-card{min-height:198px}.module-shell,.generator-shell,.history-shell,.settings-shell,.health-shell{width:min(1540px,calc(100% - 48px))}}
@media(display-mode:standalone),(display-mode:fullscreen){body{background:var(--bg)}.shell{width:min(1580px,calc(100% - 40px));padding-top:22px}.module-shell,.generator-shell,.history-shell,.settings-shell,.health-shell{width:min(1640px,calc(100% - 40px))}.footer{padding-bottom:max(9px,env(safe-area-inset-bottom))}}
@media(display-mode:fullscreen){.top-actions{top:max(12px,env(safe-area-inset-top));right:max(12px,env(safe-area-inset-right))}}
@media(max-width:600px){.pwa-install-backdrop{padding:14px}.pwa-install-modal{grid-template-columns:1fr;text-align:center;padding:21px}.pwa-install-icon{margin:0 auto;width:76px;height:76px}.pwa-install-actions{grid-column:auto;display:grid;grid-template-columns:1fr}.pwa-install-actions .btn{width:100%}.pwa-update-toast{bottom:max(16px,env(safe-area-inset-bottom));align-items:flex-start}.top-actions{right:max(11px,env(safe-area-inset-right));top:max(11px,env(safe-area-inset-top))}}

/* ===== FASE 9: marca, leitura de tabelas, filtros e backups ===== */
:root{
  --row-a:#ffffff;
  --row-b:#f7f9fb;
  --row-hover:#eaf0f5;
  --brand-blue:#247fbd;
  --brand-blue-soft:rgba(36,127,189,.10);
}
html[data-theme="dark"]{
  --row-a:#191d22;
  --row-b:#1e2329;
  --row-hover:#29313a;
  --brand-blue:#49a4df;
  --brand-blue-soft:rgba(73,164,223,.12);
}
.brand-symbol{width:60px;height:60px;object-fit:contain;filter:drop-shadow(0 10px 18px rgba(17,24,39,.10))}
.auth-brand-symbol{display:block;width:94px;height:94px;object-fit:contain;margin:0 auto 10px;filter:drop-shadow(0 12px 22px rgba(17,24,39,.10))}
.cg-mark-mini.brand-symbol-img{width:44px;height:44px;object-fit:contain;border-radius:0;background:transparent;color:inherit;box-shadow:none}
.brand-lockup{gap:10px}
.status-pill{cursor:default;text-decoration:none}

/* Linhas alternadas para leitura rápida, com hover mais evidente. */
.data-table tbody tr:nth-child(odd) td{background:var(--row-a)}
.data-table tbody tr:nth-child(even) td{background:var(--row-b)}
.data-table tbody tr:hover td{background:var(--row-hover)!important;filter:none!important}
.data-table th{background:color-mix(in srgb,var(--surface-2) 88%,var(--brand-blue-soft));box-shadow:inset 0 -1px 0 var(--line)}
.data-table th.sortable a{display:inline-flex;align-items:center;gap:4px;font-weight:850;color:var(--text)}
.data-table th.sortable a:hover{color:var(--brand-blue)}
.data-table td{line-height:1.45}
.data-card{border-color:color-mix(in srgb,var(--line) 88%,var(--brand-blue))}
.data-card-head{background:color-mix(in srgb,var(--surface-2) 90%,var(--brand-blue-soft))}

/* O estado passa a ser assinalado por uma faixa lateral discreta. */
.history-table tr[data-status="Pendente"] td:first-child{box-shadow:inset 4px 0 #d9a21b}
.history-table tr[data-status="Aprovado"] td:first-child{box-shadow:inset 4px 0 #22a06b}
.history-table tr[data-status="Rejeitado"] td:first-child{box-shadow:inset 4px 0 #d92d20}

.filter-field label{display:block;color:var(--muted);font-size:.72rem;font-weight:760;margin-bottom:6px;white-space:nowrap}
.client-toolbar{align-items:stretch}
.client-filter-form{display:grid;grid-template-columns:minmax(320px,1fr) 160px 160px auto;gap:10px;align-items:end;flex:1 1 760px}
.client-search{min-width:0}
.clients-table{min-width:1380px}
.products-filter-form{display:grid;grid-template-columns:minmax(300px,1fr) 145px 160px 160px auto;gap:10px;align-items:end;flex:1 1 760px}
.product-search{min-width:0}
.products-toolbar{align-items:end}
.products-toolbar>.toolbar-actions{margin-left:auto}

.settings-backup-card{margin-top:12px;background:var(--surface);border:1px solid var(--line);border-radius:18px;padding:16px;display:flex;align-items:center;justify-content:space-between;gap:14px;box-shadow:0 8px 24px rgba(17,24,39,.04)}
.settings-backup-card h3{margin:3px 0 5px;font-size:1.05rem}.settings-backup-card p{margin:0;color:var(--muted);font-size:.78rem;line-height:1.45}

.backup-shell{padding-bottom:86px}.backup-kpis{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px;margin-bottom:16px}.backup-kpi{background:var(--surface);border:1px solid var(--line);border-radius:18px;padding:16px;box-shadow:0 8px 26px rgba(17,24,39,.04)}.backup-kpi span{display:block;color:var(--muted);font-size:.72rem;font-weight:800;text-transform:uppercase;letter-spacing:.06em}.backup-kpi strong{display:block;margin-top:7px;font-size:1.15rem}.backup-actions-card{display:flex;align-items:center;justify-content:space-between;gap:20px;background:var(--surface);border:1px solid var(--line);border-radius:18px;padding:18px;margin-bottom:14px;box-shadow:0 8px 26px rgba(17,24,39,.04)}.backup-actions-card h2{margin:0 0 6px;font-size:1.15rem}.backup-actions-card p{margin:0;color:var(--muted);font-size:.8rem;line-height:1.5;max-width:760px}.backup-offsite-note{margin-bottom:16px}.backup-table{min-width:720px}.backup-kind{display:inline-flex;padding:5px 9px;border-radius:999px;font-size:.71rem;font-weight:800;border:1px solid var(--line)}.backup-kind.auto{color:#2463a7;background:rgba(36,99,167,.08)}.backup-kind.manual{color:#0f766e;background:rgba(15,118,110,.08)}

@media(max-width:1100px){.products-filter-form{grid-template-columns:1fr 1fr 1fr}.product-search{grid-column:1/-1}.products-filter-form .toolbar-actions{grid-column:1/-1}.client-filter-form{grid-template-columns:1fr 1fr}.client-search{grid-column:1/-1}.client-filter-form .toolbar-actions{grid-column:1/-1}.backup-kpis{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:650px){.brand-symbol{width:70px;height:70px;margin:0 auto}.brand-lockup{display:block}.client-filter-form,.products-filter-form{grid-template-columns:1fr}.client-search,.product-search,.client-filter-form .toolbar-actions,.products-filter-form .toolbar-actions{grid-column:auto}.settings-backup-card,.backup-actions-card{align-items:stretch;flex-direction:column}.settings-backup-card .btn,.backup-actions-card .btn{width:100%}.backup-kpis{grid-template-columns:1fr 1fr}.backup-shell{padding-bottom:20px}}

/* ===== FASE 9.1: rodapé Consultática e quantidade por página ===== */
.footer .made-by{display:inline-flex;align-items:center;gap:7px}
.consultatica-logo-link{display:inline-flex;align-items:center;text-decoration:none}
.consultatica-logo-img{display:block;height:22px;width:auto;max-width:118px;object-fit:contain;opacity:.88;transition:opacity .18s ease,transform .18s ease}
.consultatica-logo-link:hover .consultatica-logo-img{opacity:1;transform:translateY(-1px)}
.status-pill[href]{cursor:pointer}
.status-pill[href]:hover{text-decoration:underline;text-underline-offset:3px}
.page-size-field{min-width:108px}
.client-filter-form{grid-template-columns:minmax(300px,1fr) 150px 150px 110px auto}
.products-filter-form{grid-template-columns:minmax(280px,1fr) 135px 150px 150px 110px auto}
.history-filter-form{grid-template-columns:minmax(260px,1fr) 145px 140px 140px 110px auto}
@media(max-width:1180px){.history-filter-form{grid-template-columns:1fr 1fr 1fr}.history-search{grid-column:1/-1}.history-filter-form .toolbar-actions{grid-column:1/-1}}
@media(max-width:650px){.history-filter-form{grid-template-columns:1fr}.history-search,.history-filter-form .toolbar-actions{grid-column:auto}.footer .made-by{gap:5px}.consultatica-logo-img{height:19px;max-width:100px}}
