:root {
  --bg-app: #f3f5f8;
  --bg-app-grad:
    radial-gradient(980px 420px at 0% -5%, rgba(31, 111, 235, 0.14), transparent 58%),
    radial-gradient(820px 380px at 100% 105%, rgba(15, 138, 106, 0.10), transparent 55%),
    linear-gradient(165deg, #e8eef7 0%, #f3f5f8 48%, #e4ebf4 100%);
  --bg-sidebar: #0f2744;
  --bg-sidebar-2: #163557;
  --bg-panel: #ffffff;
  --line: #d8dee8;
  --text: #142033;
  --muted: #5b6b82;
  --primary: #1f6feb;
  --primary-2: #1557c0;
  --accent: #0f8a6a;
  --danger: #c62828;
  --radius: 10px;
  --shadow: 0 10px 30px rgba(15, 39, 68, 0.08);
  --font: "DM Sans", "IBM Plex Sans", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-app);
}
body.page-app {
  background: var(--bg-app-grad);
  background-attachment: fixed;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  padding: 0.55rem 0.95rem;
  min-height: 2.45rem;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  box-shadow: none;
  text-shadow: none;
  transform: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn:hover { text-decoration: none; background: #f7f9fc; }
.btn:active { transform: none; }
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-2);
  border-color: var(--primary-2);
  color: #fff;
}
.btn-primary.is-active,
.btn.is-active {
  background: var(--primary-2);
  border-color: var(--primary-2);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.2);
}
.btn-block { width: 100%; }

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 8px;
  background: linear-gradient(145deg, #2b7fff, #0f8a6a);
  color: #fff;
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
}

/* Login */
.page-login {
  min-height: 100vh;
  background:
    radial-gradient(1100px 560px at 8% -8%, rgba(31, 111, 235, 0.42), transparent 58%),
    radial-gradient(900px 480px at 92% 108%, rgba(15, 138, 106, 0.28), transparent 55%),
    radial-gradient(700px 380px at 70% 18%, rgba(22, 53, 87, 0.16), transparent 60%),
    linear-gradient(155deg, #c5d6ef 0%, #e7eef8 38%, #f4f7fb 62%, #d2e0f2 100%);
}
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 0.95fr 1.05fr;
}
.login-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 2.5rem;
  max-width: 440px;
  margin: 0 auto;
}
.login-brand {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1.75rem;
}
.login-brand p { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.9rem; }
.login-panel h1 {
  margin: 0 0 1rem;
  font-size: 1.65rem;
  letter-spacing: -0.02em;
}
.login-form {
  display: grid;
  gap: 0.85rem;
}
.login-form label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.92rem;
  font-weight: 600;
}
.login-form input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.7rem 0.8rem;
  font: inherit;
  background: #fff;
}
.login-form input:focus {
  outline: 2px solid rgba(31, 111, 235, 0.25);
  border-color: var(--primary);
}
.login-hint {
  margin-top: 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.login-aside {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 2rem 2.5rem;
  color: #e8f0ff;
  background: transparent;
}
.login-aside-logo {
  background: transparent;
  color: inherit;
}
.login-aside-master {
  display: block;
  width: min(92%, 780px);
  max-height: min(72vh, 560px);
  height: auto;
  object-fit: contain;
  background: transparent;
}
.login-brand-logo {
  display: block;
  width: 2.6rem;
  height: 2.6rem;
  object-fit: contain;
  background: transparent;
}
.login-aside h2 {
  margin: 0 0 0.75rem;
  font-size: 2rem;
  letter-spacing: -0.03em;
}
.login-aside p {
  margin: 0;
  max-width: 28rem;
  line-height: 1.5;
  color: rgba(232, 240, 255, 0.85);
}

.alert {
  border-radius: 8px;
  padding: 0.7rem 0.85rem;
  margin-bottom: 0.85rem;
  font-size: 0.92rem;
}
.alert-danger {
  background: #fdecea;
  color: var(--danger);
  border: 1px solid #f5c6c2;
}

/* App shell */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px 1fr;
}
.sidebar {
  background: linear-gradient(180deg, var(--bg-sidebar) 0%, var(--bg-sidebar-2) 100%);
  color: #d7e4f5;
  display: flex;
  flex-direction: column;
  padding: 1rem 0.75rem;
}
.sidebar-brand {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  padding: 0.5rem 0.6rem 1.1rem;
}
.sidebar-brand strong { display: block; color: #fff; }
.sidebar-brand small { color: rgba(215, 228, 245, 0.65); }
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1 1 auto;
  justify-content: flex-start;
  align-content: flex-start;
  min-height: 0;
}
.nav-item {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  align-self: stretch;
  width: 100%;
  height: 2.65rem;
  min-height: 2.65rem;
  max-height: 2.65rem;
  padding: 0 0.8rem;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #d7e4f5;
  font-weight: 500;
  font-size: 0.92rem;
  line-height: 1.25;
  box-sizing: border-box;
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  text-decoration: none;
  color: #fff;
}
.nav-item.is-active {
  background: rgba(31, 111, 235, 0.35);
  border-color: transparent;
  color: #fff;
  font-weight: 500;
  flex: 0 0 auto;
  height: 2.65rem;
  min-height: 2.65rem;
  max-height: 2.65rem;
}
.nav-item .nav-label { display: block; }
.nav-muted { color: rgba(215, 228, 245, 0.7); font-size: 0.92rem; }
.sidebar-foot { padding-top: 0.75rem; border-top: 1px solid rgba(255,255,255,0.08); }

.app-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
  background: transparent;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.4rem;
  background: rgba(255, 255, 255, 0.72);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 5;
}
.page-title {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}
.user-chip {
  background: #eaf1fb;
  color: #1d3b66;
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.88rem;
  font-weight: 600;
}
.app-content {
  padding: 1.25rem 1.4rem 2rem;
  flex: 1;
  background: transparent;
}

.home-logo-stage {
  min-height: calc(100vh - 7rem);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  background:
    radial-gradient(720px 340px at 50% 35%, rgba(31, 111, 235, 0.16), transparent 62%),
    radial-gradient(560px 280px at 78% 78%, rgba(15, 138, 106, 0.10), transparent 60%);
}
.home-logo-master {
  display: block;
  width: min(70%, 920px);
  max-height: min(52vh, 480px);
  height: auto;
  object-fit: contain;
  background: transparent;
}
.home-logo-fallback {
  text-align: center;
  display: grid;
  gap: 0.85rem;
  justify-items: center;
}

.hero-strip {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.hero-strip h2 { margin: 0 0 0.35rem; font-size: 1.2rem; }
.hero-strip p { margin: 0; color: var(--muted); max-width: 42rem; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1rem;
}
.dash-card {
  display: block;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  color: inherit;
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.dash-card:hover {
  text-decoration: none;
  border-color: #9db7df;
  transform: translateY(-1px);
}
.dash-card h3 { margin: 0 0 0.35rem; font-size: 1.02rem; }
.dash-card p { margin: 0; color: var(--muted); font-size: 0.92rem; }
.dash-card-link { cursor: pointer; }
.dash-card-link:hover { border-color: #1f6feb; }

.dash-col-chart {
  display: flex;
  align-items: flex-end;
  gap: 0.55rem;
  min-height: 11rem;
  overflow-x: auto;
  padding: 0.25rem 0.15rem 0.35rem;
}
.dash-col {
  flex: 1 1 0;
  min-width: 3.2rem;
  max-width: 5.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}
.dash-col-val {
  font-size: 0.72rem;
  color: var(--muted);
  text-align: center;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  min-height: 1.7rem;
}
.dash-col-track {
  width: 100%;
  height: 7.5rem;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: #eef3f9;
  border-radius: 6px 6px 0 0;
  overflow: hidden;
}
.dash-col-bar {
  width: 70%;
  min-height: 2px;
  background: linear-gradient(180deg, #3d8bfd 0%, #1f6feb 100%);
  border-radius: 5px 5px 0 0;
}
.dash-col-label {
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
  white-space: nowrap;
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow);
}
.panel h2, .panel h3 { margin-top: 0; }
.muted { color: var(--muted); }
.status-list { margin: 0; padding-left: 1.1rem; line-height: 1.7; }
.callout {
  background: #eef5ff;
  border: 1px solid #c9dbf5;
  border-radius: 8px;
  padding: 0.8rem 0.9rem;
  margin: 0.85rem 0;
}
.callout p { margin: 0; }

/* Menu mobile: hamburger + drawer */
.btn-menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  height: 2.4rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  flex: 0 0 auto;
}
.menu-toggle-bars {
  display: block;
  width: 1.1rem;
  height: 2px;
  background: #1a2b3c;
  border-radius: 1px;
  position: relative;
}
.menu-toggle-bars::before,
.menu-toggle-bars::after {
  content: "";
  position: absolute;
  left: 0;
  width: 1.1rem;
  height: 2px;
  background: #1a2b3c;
  border-radius: 1px;
}
.menu-toggle-bars::before { top: -5px; }
.menu-toggle-bars::after { top: 5px; }
.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}
.sidebar-close {
  display: none;
  margin-left: auto;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.2rem 0.45rem;
}
.sidebar-backdrop {
  display: none;
}

.demanda-chart { display: flex; flex-direction: column; gap: 0.55rem; }
.demanda-chart-row {
  display: grid;
  grid-template-columns: 4.5rem 1fr 6.5rem;
  gap: 0.6rem;
  align-items: center;
}
.demanda-chart-label { font-size: 0.85rem; color: var(--muted); }
.demanda-chart-track {
  height: 0.7rem;
  background: #e8eef6;
  border-radius: 999px;
  overflow: hidden;
}
.demanda-chart-bar {
  height: 100%;
  background: linear-gradient(90deg, #1f6feb, #3d8bfd);
  border-radius: 999px;
  min-width: 2px;
}
.demanda-chart-value {
  font-size: 0.85rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

@media (max-width: 900px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-aside { display: none; }
  .app-shell { grid-template-columns: 1fr; }
  .btn-menu-toggle { display: inline-flex; }
  .sidebar-close { display: inline-block; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(280px, 86vw);
    z-index: 40;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: none;
    overflow-y: auto;
  }
  .app-shell.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: 8px 0 28px rgba(15, 39, 68, 0.28);
  }
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 39, 68, 0.45);
    z-index: 35;
  }
  .sidebar-backdrop[hidden] { display: none !important; }
  body.nav-locked { overflow: hidden; }
  .card-grid { grid-template-columns: 1fr; }
  .hero-strip { flex-direction: column; align-items: flex-start; }
  .demanda-chart-row {
    grid-template-columns: 3.5rem 1fr;
  }
  .demanda-chart-value {
    grid-column: 2;
    text-align: left;
  }
}
@media (max-width: 900px) {
  section.card-grid[style*="repeat(3"],
  section.card-grid[style*="repeat(4"],
  section.card-grid[style*="repeat(5"] { grid-template-columns: 1fr !important; }
}

/* Cadastros */
.alert-ok {
  background: #e8f6ef;
  color: #0f6b45;
  border: 1px solid #b7e0cb;
}
.btn-danger {
  background: #fff5f5;
  border-color: #f0c2c2;
  color: var(--danger);
}
.btn-danger:hover { background: #fdecea; }
.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.85rem;
  min-height: 2rem;
}
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
  margin-top: 1rem;
}
.btn-row .btn,
.btn-row button.btn { margin: 0; }
.btn-pair {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
}
.btn-pair > form { margin: 0; display: inline-flex; }
.btn-row-equal {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
  align-items: stretch;
}
.btn-row-equal-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
  align-items: stretch;
}
.btn-row-equal > form,
.btn-row-equal-3 > form {
  margin: 0;
  display: flex;
  min-width: 0;
}
.btn-row-equal .btn,
.btn-row-equal-3 .btn {
  width: 100%;
  min-height: 2.75rem;
  white-space: normal;
  text-align: center;
}
.btn:disabled,
button.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: #e8edf4 !important;
  border-color: var(--line) !important;
  color: var(--muted) !important;
  box-shadow: none !important;
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.lead { margin: 0 0 1rem; color: var(--muted); }
.cad-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
  margin-bottom: 0.85rem;
}
.inline-search {
  display: flex;
  gap: 0.45rem;
  flex: 1;
  min-width: 220px;
}
.inline-search input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  font: inherit;
}
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.92rem;
}
table.data th, table.data td {
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
table.data th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  background: #f7f9fc;
}
table.data tbody tr {
  transition: box-shadow 0.16s ease;
}
table.data tbody tr td {
  transition: background-color 0.14s ease, box-shadow 0.14s ease;
}
table.data tbody tr:hover {
  position: relative;
  z-index: 2;
  box-shadow:
    0 4px 16px rgba(15, 39, 68, 0.14),
    0 1px 3px rgba(15, 39, 68, 0.08);
}
table.data tbody tr:hover td {
  background: rgba(31, 111, 235, 0.09);
}
table.data tbody tr:hover td:first-child {
  box-shadow: inset 3px 0 0 var(--primary);
}
table.data tbody tr:active td {
  background: rgba(31, 111, 235, 0.14);
}
.row-actions { white-space: nowrap; text-align: right; }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem 0.9rem;
}
.form-grid .span-2 { grid-column: 1 / -1; }
.etq-catalogo-block {
  margin-bottom: 1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--line);
}
.form-grid label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
}
.form-grid input,
.form-grid select,
.form-grid textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  font: inherit;
  color: var(--text);
  background: #fff;
  width: 100%;
}
.form-grid textarea { min-height: 5rem; resize: vertical; }
.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus {
  outline: 2px solid rgba(31, 111, 235, 0.2);
  border-color: var(--primary);
}
.form-row-3 {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem 0.9rem;
}
.modal-dialog {
  border: none;
  border-radius: 12px;
  padding: 0;
  max-width: min(480px, 94vw);
  width: min(480px, 94vw);
  background: transparent;
}
.modal-dialog.modal-wide,
.modal-dialog:has(.modal-wide) {
  max-width: min(1100px, 96vw);
  width: min(1100px, 96vw);
  max-height: min(92vh, 900px);
}
.modal-dialog::backdrop { background: rgba(15, 39, 68, 0.45); }
.modal-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.1rem 1.15rem;
  box-shadow: var(--shadow);
}
.modal-dialog.modal-wide .modal-card,
.modal-dialog:has(.modal-wide) .modal-card {
  width: 100%;
  max-width: none;
  max-height: min(92vh, 900px);
  overflow: auto;
  box-sizing: border-box;
}
@media (max-width: 1000px) {
  .cad-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .cad-grid, .form-grid, .form-row-3 { grid-template-columns: 1fr; }
}

.pre.code-block, .code-block {
  background: #0f2744;
  color: #e8f0ff;
  border-radius: 8px;
  padding: 0.9rem 1rem;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.45;
  white-space: pre-wrap;
}
.orc-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.orc-toolbar .cnpj-select-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}
.topbar-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  min-width: 0;
}
.cnpj-select-form label {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}
.cnpj-select-form select {
  min-width: 200px;
  max-width: 260px;
  margin: 0;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  background: #fff;
}

/* Cards / superfícies (módulos portados) */
.card {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.2rem;
  margin-bottom: 1rem;
}
.card.surface,
.panel.surface { border-radius: 12px; }
.muted-card { opacity: 0.96; }
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.section-head h2 {
  margin: 0;
  font-size: 1.1rem;
}
.field-hint {
  margin: 0.25rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.3;
}
.info-banner {
  background: #eef5ff;
  border: 1px solid #c9dbf5;
  border-left: 4px solid var(--primary);
  color: #1d3b66;
  padding: 0.75rem 0.95rem;
  border-radius: 8px;
  margin: 0.75rem 0;
  font-weight: 600;
}
.error {
  background: #fdecea;
  border: 1px solid #f5c6c2;
  border-left: 4px solid var(--danger);
  color: #7a1212;
  padding: 0.75rem 0.95rem;
  border-radius: 8px;
  margin-bottom: 0.8rem;
  font-weight: 600;
}
.ok {
  background: #e8f6ef;
  border: 1px solid #b7e0cb;
  border-left: 4px solid var(--accent);
  color: #0f6b45;
  padding: 0.75rem 0.95rem;
  border-radius: 8px;
  margin-bottom: 0.8rem;
  font-weight: 600;
}

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}
.etiqueta-filtros {
  align-items: end;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9fc;
}
.etiqueta-filtros label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.25rem;
}
.etiqueta-filtros input,
.etiqueta-filtros select {
  width: 100%;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  font: inherit;
  background: #fff;
}
.etiqueta-filtros-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  background: #eaf1fb;
  border: 1px solid #c9dbf5;
  color: #1d3b66;
  font-size: 0.8rem;
  font-weight: 650;
}
.badge-status-gerado { background: #eaf1fb; border-color: #c9dbf5; color: #1d3b66; }
.badge-status-aprovado { background: #e8f6ef; border-color: #b7e0cb; color: #0f6b45; }
.badge-status-reprovado { background: #fdecea; border-color: #f5c6c2; color: #7a1212; }
.badge-status-analise { background: #f3e8ff; border-color: #c4b5fd; color: #6d28d9; }
.badge-status-rascunho { background: #f1f3f6; border-color: #d8dee8; color: #5b6b82; }
.badge-op-aguardando { background: #fff1e0; border-color: #f97316; color: #c2410c; }
.badge-op-gerada { background: #fef9e8; border-color: #f0e0a0; color: #854d0e; }
.badge-op-producao { background: #e8f6ef; border-color: #b7e0cb; color: #145c2c; }
.badge-op-apontamento { background: #eaf1fb; border-color: #c9dbf5; color: #1d3b66; }
.badge-op-finalizada { background: #f1f3f6; border-color: #d8dee8; color: #4b5563; }

.orc-grid {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 1rem;
  align-items: start;
}
@media (max-width: 960px) {
  .orc-grid { grid-template-columns: 1fr; }
}
.orc-col h3 {
  margin: 0 0 0.65rem;
  font-size: 1.05rem;
  color: var(--text);
}
.total-bar {
  margin-top: 0.85rem;
  padding: 0.75rem 0.9rem;
  background: linear-gradient(135deg, #163557 0%, #1f6feb 100%);
  color: #fff;
  border-radius: 8px;
  font-weight: 650;
}
.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.55rem;
  margin-top: 0.75rem;
}
.metrics > div {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  color: var(--text);
  font-size: 0.88rem;
}
.metrics strong {
  display: block;
  margin-top: 0.2rem;
  color: var(--text);
  font-weight: 700;
}
.result-highlight.metrics > div,
.metrics.result-highlight > div,
.live-metrics.result-highlight > div {
  background: #fffbeb;
  border-color: #f0d78c;
}
.result-highlight.metrics strong,
.metrics.result-highlight strong,
.live-metrics.result-highlight strong {
  color: #142033;
  font-size: 1.05rem;
}
.live-metrics {
  margin-top: 1rem;
  margin-bottom: 0.35rem;
  padding: 0.65rem;
  border-radius: 10px;
  background: #f7f9fc;
  border: 1px dashed #9db7df;
}
.live-metrics strong { font-size: 1.05rem; }
.live-metrics .price-input {
  display: block;
  width: 100%;
  max-width: 10rem;
  margin-top: 0.2rem;
  font-size: 1.05rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  font-family: inherit;
}
.live-metrics label.muted {
  display: block;
  margin: 0;
  font-size: inherit;
  font-weight: inherit;
}
.live-metrics.result-highlight {
  background: #fffbeb;
  border: 1px solid #f0d78c;
}
.exibir-etq-flag {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 0.65rem 0 0.15rem;
  font-size: 0.92rem;
  line-height: 1.35;
  cursor: pointer;
}
.exibir-etq-flag input {
  margin-top: 0.15rem;
  flex-shrink: 0;
}
#etq-exibicao-hint {
  margin: 0.15rem 0 0.35rem;
  min-height: 1.2em;
}
.is-hidden { display: none !important; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 39, 68, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
  z-index: 50;
  overflow: auto;
}
.modal-backdrop.js-modal:not(.is-open) {
  display: none !important;
  pointer-events: none;
}
.modal-backdrop.js-modal.is-open {
  display: flex !important;
  pointer-events: auto;
}
.modal {
  width: min(720px, 100%);
  max-height: none;
  margin-bottom: 2rem;
}
.modal.card { margin-bottom: 2rem; }
.modal-wide { width: min(1180px, 96vw); }
#modal-orc-grupo .modal-wide {
  width: min(1280px, 96vw);
}
#modal-orc-grupo .data td:nth-child(4),
#modal-orc-grupo .data th:nth-child(4) {
  white-space: nowrap;
}
#modal-mais-subclasse.modal-backdrop { z-index: 60; }

.preview-head {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  font-size: 0.92rem;
}
.preview-titulo-proposta {
  grid-column: 1 / -1;
  text-align: center;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  letter-spacing: 0.03em;
  margin-bottom: 0.15rem;
}
.preview-right { text-align: right; }
.preview-foot { margin-top: 0.75rem; font-size: 0.92rem; }
.preview-desc {
  margin: 0.85rem 0 0;
  font-weight: 600;
}
@media (max-width: 640px) {
  .preview-head { grid-template-columns: 1fr; }
  .preview-right { text-align: left; }
  .btn-row-equal,
  .btn-row-equal-3 { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: 1fr; }
}

.desc-modo-block {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}
.desc-modo-title-block {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
}
.desc-modo-help { margin: 0 0 0.75rem; }
.desc-modo-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-bottom: 0.85rem;
}
.desc-modo-option {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.65rem;
  align-items: start;
  margin: 0;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-weight: 400;
}
.desc-modo-option:has(input:checked) {
  border-color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--primary);
}
.desc-modo-option input[type="radio"] {
  width: 1.1rem;
  height: 1.1rem;
  margin: 0.15rem 0 0;
  flex-shrink: 0;
}
.desc-modo-content {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}
.desc-modo-label { font-weight: 650; color: var(--text); }
.desc-modo-previa {
  display: block;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.35;
}
.desc-modo-final label {
  display: block;
  margin-bottom: 0.35rem;
}
.desc-modo-final textarea {
  resize: vertical;
  min-height: 2.8rem;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  font: inherit;
}

.perm-menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.45rem 0.85rem;
}
.perm-menu-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9fc;
  font-weight: 600;
  cursor: pointer;
}
.perm-menu-item input {
  width: auto;
  margin: 0;
}

.mem-list {
  list-style: none;
  padding: 0;
  margin: 0.4rem 0 0;
  font-size: 0.9rem;
}
.mem-list li { padding: 0.15rem 0; border-bottom: 1px solid var(--line); }
.mem-resumo {
  grid-template-columns: repeat(2, minmax(140px, 1fr));
  margin: 0.85rem 0 1rem;
}
.mem-block { margin-top: 1rem; padding-top: 0.35rem; }
.mem-block h4 { margin: 0 0 0.65rem; font-weight: 700; }
.mem-table-wrap {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  margin-bottom: 0.75rem;
}
.mem-table-caption {
  background: #eaf1fb;
  color: #1d3b66;
  font-weight: 700;
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid var(--line);
}
.mem-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.mem-table td {
  padding: 0.4rem 0.7rem;
  border-bottom: 1px solid var(--line);
}
.mem-row-even { background: #fff; }
.mem-row-odd { background: #f7f9fc; }
.mem-campo { font-weight: 600; color: var(--muted); width: 55%; }
.mem-valor { font-weight: 700; color: var(--text); text-align: right; }

.nf-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 0.85rem;
}
.nf-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}
.nf-card[open] { border-color: #9db7df; box-shadow: var(--shadow); }
.nf-card summary {
  list-style: none;
  cursor: pointer;
  display: grid;
  grid-template-columns: minmax(90px, auto) auto 1fr auto;
  gap: 0.55rem 0.85rem;
  align-items: center;
  padding: 0.85rem 1rem;
  font-weight: 650;
  background: #f7f9fc;
}
.nf-card summary::-webkit-details-marker { display: none; }
.nf-title { color: var(--text); font-weight: 700; }
.nf-meta { color: var(--muted); font-weight: 500; font-size: 0.92rem; }
.nf-total {
  justify-self: end;
  background: var(--primary);
  color: #fff;
  padding: 0.25rem 0.55rem;
  border-radius: 8px;
  font-size: 0.9rem;
}
.nf-body { padding: 0.85rem 1rem 1rem; border-top: 1px solid var(--line); }
@media (max-width: 720px) {
  .nf-card summary { grid-template-columns: 1fr 1fr; }
  .nf-total { grid-column: 1 / -1; justify-self: start; }
}

.op-bobinas {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.op-bobina-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 8.5rem auto;
  gap: 0.45rem;
  align-items: center;
}
.op-bobina-row select,
.op-bobina-metros {
  width: 100%;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  font: inherit;
  background: #fff;
}
.op-bobina-metros.is-hidden { display: none; }
.op-bobinas:not([data-multi="1"]) .op-bobina-row {
  grid-template-columns: minmax(0, 1fr) auto;
}
.op-locked,
input.op-locked,
textarea.op-locked,
select.op-locked {
  background: #eef2f6 !important;
  color: #5b6b82 !important;
  cursor: default;
}
.op-head-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 0 0 0.65rem;
}
.op-criado {
  font-size: 0.95rem;
}
.op-status-line {
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}
.op-status-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
}
.op-estornar-form {
  display: inline;
  margin: 0;
}
.op-head-cliente {
  margin-top: 0;
}
.op-section-divider {
  grid-column: 1 / -1;
  height: 0;
  margin: 0.55rem 0 0.35rem;
  border: 0;
  border-top: 1px solid var(--line);
}
.op-status-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.85rem;
  padding: 0.35rem 0;
}
.op-status-dropdown {
  position: relative;
  min-width: 14rem;
}
.op-status-dd-toggle {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  font: inherit;
  color: var(--text);
  background: #fff;
  cursor: pointer;
  text-align: left;
}
.op-status-dd-toggle:hover,
.op-status-dropdown.is-open .op-status-dd-toggle {
  border-color: var(--primary);
}
.op-status-dd-caret {
  color: var(--muted);
  font-size: 0.75rem;
}
.op-status-dd-panel {
  position: absolute;
  z-index: 40;
  top: calc(100% + 0.25rem);
  left: 0;
  right: 0;
  min-width: 18rem;
  max-height: min(22rem, 60vh);
  overflow: auto;
  display: grid;
  gap: 0.35rem;
  padding: 0.55rem 0.65rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}
.op-status-dd-panel[hidden] {
  display: none !important;
}
.op-check {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.op-status-dd-panel .op-check {
  display: flex;
  width: 100%;
  padding: 0.25rem 0.15rem;
  border-radius: 6px;
}
.op-status-dd-panel .op-check:hover {
  background: rgba(31, 111, 235, 0.06);
}
.op-check input {
  margin: 0;
  width: 0.95rem;
  height: 0.95rem;
  flex: 0 0 auto;
}
@media (max-width: 720px) {
  .op-bobina-row { grid-template-columns: 1fr auto; }
  .op-bobina-metros:not(.is-hidden) { grid-column: 1 / -1; }
}

.relatorio-wrap {
  margin-top: 0.75rem;
  max-height: min(70vh, 720px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.relatorio-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin: 0.65rem 0;
}
.relatorio-table {
  table-layout: fixed;
  width: max-content;
  min-width: 1320px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.82rem;
}
.relatorio-table th,
.relatorio-table td {
  padding: 0.4rem 0.55rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
table.data.relatorio-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #eaf1fb !important;
  color: #1d3b66 !important;
  font-weight: 700;
  box-shadow: 0 1px 0 var(--line);
}
.relatorio-table .col-check {
  width: 2.4rem;
  min-width: 2.4rem;
  text-align: center;
}
.relatorio-table .col-check input {
  margin: 0;
  width: 1rem;
  height: 1rem;
}
.table-scroll {
  overflow: auto;
  max-height: min(60vh, 28rem);
  margin-top: 0.75rem;
}
.table-scroll .data th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f7f9fc;
}
.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
th.sort-th {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
th.sort-th:hover { color: var(--text); }
th.sort-th::after {
  content: " ↕";
  font-size: 0.75em;
  opacity: 0.45;
}
th.sort-th.is-asc::after { content: " ↑"; opacity: 0.9; }
th.sort-th.is-desc::after { content: " ↓"; opacity: 0.9; }
.logo-previews {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin: 0.75rem 0;
}
.logo-previews img {
  display: block;
  width: 100%;
  max-height: 90px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.35rem;
}
