:root {
  --bg: #F6F6F3;
  --surface: #FFFFFF;
  --surface-tint: #EFECE6;
  --carbon: #111413;
  --ink: #111413;
  --ink-muted: #5A645F;
  --emerald: #0E7C52;
  --emerald-hover: #0A6341;
  --emerald-soft: #E6F4EE;
  --danger: #B42318;
  --danger-soft: #FEE4E2;
  --border: rgba(17, 20, 19, 0.1);
  --radius: 14px;
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

h1, h2, strong {
  font-family: "Plus Jakarta Sans", "Inter", sans-serif;
}

[hidden] {
  display: none !important;
}

.container {
  width: min(1220px, 100% - 32px);
  margin-inline: auto;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--carbon);
  color: #FFFFFF;
  flex: none;
}

/* Botões */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-family: "Plus Jakarta Sans", "Inter", sans-serif;
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 140ms ease, transform 120ms ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn-sm {
  min-height: 34px;
  padding: 6px 12px;
  font-size: 12px;
}

.btn-block {
  width: 100%;
  min-height: 44px;
}

.btn-emerald {
  background: var(--emerald);
  color: #FFFFFF;
}

.btn-emerald:hover {
  background: var(--emerald-hover);
}

.btn-outline {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--border);
}

.btn-outline:hover {
  background: var(--surface-tint);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn-danger:hover {
  background: #FECDCA;
}

.link-btn {
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--emerald);
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
}

/* Login */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.login-shell {
  width: min(430px, 100%);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 32px 28px;
  box-shadow: 0 18px 42px rgba(17, 20, 19, 0.08);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.login-brand strong {
  display: block;
  font-size: 16px;
}

.login-brand small {
  color: var(--ink-muted);
  font-size: 12px;
}

.login-card h1 {
  font-size: 22px;
  margin: 0 0 8px;
}

.login-sub {
  margin: 0 0 20px;
  color: var(--ink-muted);
  font-size: 13px;
}

.login-form {
  display: grid;
  gap: 14px;
}

.password-wrap {
  position: relative;
  display: flex;
}

.password-wrap input {
  padding-right: 76px;
}

.toggle-pass {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--emerald);
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  padding: 4px 8px;
}

.login-footer {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.login-footer a {
  color: var(--ink-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
}

/* Topbar Painel */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 66px;
  padding-block: 8px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-left strong {
  display: block;
  font-size: 15px;
}

.topbar-left small {
  color: var(--ink-muted);
  font-size: 12px;
}

.topbar-tabs {
  display: inline-flex;
  padding: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  gap: 4px;
}

.tab-btn {
  border: 0;
  background: transparent;
  padding: 7px 18px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 13px;
  color: var(--ink-muted);
  cursor: pointer;
}

.tab-btn.is-active {
  background: var(--carbon);
  color: #FFFFFF;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.main-shell {
  padding: 26px 0 60px;
}

/* KPIs */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.stat-card span {
  display: block;
  color: var(--ink-muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.stat-card strong {
  font-size: 22px;
}

.stat-highlight {
  background: var(--carbon);
  color: #FFFFFF;
}

.stat-highlight span {
  color: rgba(255, 255, 255, 0.72);
}

/* Toolbars & Tabela */
.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.toolbar-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  flex: 1 1 320px;
}

.toolbar-filters input {
  flex: 1 1 240px;
}

.toolbar-filters select {
  width: 180px;
}

.toolbar-cta {
  display: flex;
  gap: 8px;
}

.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.data-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
  padding: 12px 14px;
  background: #FAFAF8;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.col-actions {
  text-align: right;
  white-space: nowrap;
}

.row-actions {
  display: inline-flex;
  gap: 6px;
  justify-content: flex-end;
}

.badge-status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: var(--surface-tint);
}

.badge-aberto { background: #E6F4EE; color: #0E7C52; }
.badge-producao { background: #FEF0C7; color: #B54708; }
.badge-entregue { background: #E0F2FE; color: #026AA2; }
.badge-cancelado { background: #FEE4E2; color: #B42318; }

.empty-box {
  padding: 42px 20px;
  text-align: center;
  color: var(--ink-muted);
}

/* Inputs & Modais */
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}

input, select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #FFFFFF;
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(14, 124, 82, 0.28);
  border-color: var(--emerald);
}

.alert-error {
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 12px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 200;
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--carbon);
  color: #FFFFFF;
  font-weight: 600;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(14, 17, 16, 0.6);
  backdrop-filter: blur(4px);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(760px, 100%);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}

.modal-card-wide {
  width: min(920px, 100%);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
}

.modal-head h2 {
  margin: 0;
  font-size: 18px;
}

.icon-close {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #FFFFFF;
  cursor: pointer;
}

.modal-body {
  padding: 18px 22px;
  overflow-y: auto;
}

.modal-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.form-group-box {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px 16px;
  margin: 0 0 14px;
}

.form-group-box legend {
  padding: 0 6px;
  font-weight: 700;
  font-size: 12px;
  color: var(--emerald);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.form-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }

.preset-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--ink-muted);
}

.preset-chip {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

.preset-chip:hover {
  background: var(--emerald-soft);
  color: var(--emerald);
}

.itens-list {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.item-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 90px 100px 105px 34px;
  gap: 8px;
  align-items: center;
}

.item-num {
  text-align: center;
  font-weight: 700;
  font-size: 12px;
  color: var(--ink-muted);
}

.item-line-total {
  text-align: right;
  font-weight: 700;
  font-size: 13px;
}

.total-readout {
  padding: 7px 11px;
  border-radius: 9px;
  background: var(--carbon);
  color: #FFFFFF;
}

.total-readout small {
  display: block;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.72);
}

.total-readout strong {
  font-size: 16px;
}

@media (max-width: 760px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid-3,
  .form-grid-4 {
    grid-template-columns: 1fr;
  }

  .span-2, .span-3, .span-4 {
    grid-column: span 1;
  }

  .item-row {
    grid-template-columns: 1fr 1fr;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
  }

  .item-row input[data-field="descricao"] {
    grid-column: span 2;
  }
}

/* Tabela de preços e orçamento */
.price-card { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:24px; margin-bottom:20px; }
.price-card h2 { margin:0 0 18px; font-size:19px; }
.pricing-heading h1 { margin-bottom:4px; }
.pricing-heading p,.price-help,.field small { color:var(--ink-muted); }
.price-actions { display:flex; align-items:center; flex-wrap:wrap; gap:12px; margin:18px 0; }
.price-scroll { overflow:auto; max-height:540px; }
.price-scroll th { position:sticky; top:0; background:var(--surface-tint); z-index:1; }
.price-scroll input[type=checkbox] { width:18px; height:18px; accent-color:var(--emerald); }
.price-scroll tr:has(input:checked) { background:var(--emerald-soft); }
#quote-output { display:block; width:100%; margin-top:8px; padding:16px; border:1px solid var(--border); border-radius:10px; font:inherit; line-height:1.65; resize:vertical; }
.price-help { margin-bottom:0; font-size:12px; }
.btn:disabled { cursor:default; opacity:.5; }
@media (max-width:700px) { .price-card { padding:16px; } .topbar-tabs { overflow-x:auto; max-width:100%; } }

.quote-layout { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:28px; align-items:start; }
.quote-selects { display:grid; gap:16px; }
.quote-options { border:0; padding:0; margin:22px 0; min-width:0; }
.quote-options legend { font-weight:600; margin-bottom:10px; }
.quote-choices { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; margin-top:10px; }
.quote-choice { display:flex; align-items:center; gap:10px; border:1px solid var(--border); border-radius:10px; padding:12px; cursor:pointer; }
.quote-choice:has(input:checked) { border-color:var(--emerald); background:var(--emerald-soft); }
.quote-choice input { accent-color:var(--emerald); width:17px; height:17px; flex:none; }
.quote-result { background:var(--bg); border-radius:12px; padding:18px; }
.quote-result .price-actions { margin-top:0; justify-content:space-between; }
.quote-result #quote-output { min-height:450px; font-family:ui-monospace,monospace; font-size:13px; white-space:pre; overflow:auto; }
@media(max-width:800px) { .quote-layout { grid-template-columns:1fr; } }

/* Instalação do painel */
.topbar-actions { flex-wrap:wrap; }
#install-help { width:min(440px,calc(100% - 32px)); border:1px solid var(--border); border-radius:var(--radius); padding:24px; color:var(--ink); box-shadow:0 20px 70px #0003; }
#install-help::backdrop { background:#11141388; }
#install-help h2 { font-size:20px; margin-top:0; }
#install-help p { line-height:1.7; }
#install-help form { display:flex; justify-content:flex-end; margin-top:20px; }
.login-footer #install-app { margin-bottom:12px; }
