﻿
    :root {
      --bg: #f3f7f7;
      --ink: #122127;
      --muted: #5d6b70;
      --brand: #0e8f83;
      --brand-strong: #096b62;
      --accent: #ee7f3b;
      --line: rgba(18, 33, 39, 0.1);
      --shadow: 0 20px 45px rgba(9, 41, 49, 0.12);
      --card: #ffffff;
      --danger: #c0392b;
    }
    * { box-sizing: border-box; margin: 0; padding: 0; }
    body {
      font-family: 'Manrope', sans-serif;
      color: var(--ink);
      background:
        radial-gradient(circle at 8% 5%, rgba(14, 143, 131, 0.15), transparent 28%),
        radial-gradient(circle at 95% 10%, rgba(238, 127, 59, 0.12), transparent 24%),
        linear-gradient(180deg, #f8fbfb 0%, var(--bg) 75%);
      min-height: 100vh;
      overflow-x: hidden;
    }
    .shell { width: min(1200px, 96%); margin: 0 auto; }
    header {
      position: sticky;
      top: 0;
      z-index: 50;
      backdrop-filter: blur(10px);
      background: rgba(248, 251, 251, 0.85);
      border-bottom: 1px solid var(--line);
    }
    .topbar {
      display: grid;
      grid-template-columns: 1fr auto 1fr;
      align-items: center;
      padding: 14px 0;
      gap: 16px;
    }
    .brand {
      display: flex;
      align-items: center;
      gap: 10px;
      justify-self: start;
      text-decoration: none;
      color: var(--ink);
      font-family: 'Sora', sans-serif;
      font-weight: 700;
    }
    .brand-badge {
      width: 34px;
      height: 34px;
      border-radius: 10px;
      display: grid;
      place-items: center;
      background: linear-gradient(145deg, var(--brand), #0fb8a9);
      color: #fff;
      font-weight: 800;
      font-size: 0.88rem;
    }
    nav {
      display: flex;
      align-items: center;
      justify-self: center;
      justify-content: center;
      flex-wrap: nowrap;
      gap: 6px;
      overflow-x: hidden;
      -webkit-overflow-scrolling: touch;
    }
    nav a {
      text-decoration: none;
      color: var(--muted);
      padding: 8px 13px;
      border-radius: 999px;
      font-size: 0.9rem;
      font-weight: 600;
      white-space: nowrap;
      transition: background 0.2s, color 0.2s;
    }
    nav a:hover,
    nav a.active {
      background: rgba(14, 143, 131, 0.13);
      color: var(--brand-strong);
    }
    .user-area {
      display: flex;
      justify-self: end;
      align-items: center;
      gap: 10px;
      flex-shrink: 0;
      position: relative;
    }
    .user-chip {
      display: flex;
      align-items: center;
      gap: 8px;
      border: 1px solid var(--line);
      border-radius: 999px;
      padding: 7px 13px 7px 9px;
      background: var(--card);
      font-size: 0.85rem;
      font-weight: 700;
      color: var(--ink);
      max-width: 280px;
      display: inline-flex;
      align-items: baseline;
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .user-chip span strong {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      min-width: 0;
    }
    .user-menu-trigger {
      border: 1px solid var(--line);
      cursor: pointer;
      font-family: 'Manrope', sans-serif;
      text-align: left;
    }
    .user-menu-panel {
      position: absolute;
      top: calc(100% + 10px);
      right: 48px;
      width: min(420px, calc(100vw - 26px));
      border: 1px solid var(--line);
      border-radius: 14px;
      background: #ffffff;
      padding: 14px;
      box-shadow: 0 20px 48px rgba(8, 37, 44, 0.18);
      z-index: 70;
      display: none;
    }
    .user-menu-panel.open {
      display: block;
    }
    .subscription-top {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      margin-bottom: 12px;
    }
    .subscription-label {
      font-size: 0.75rem;
      text-transform: uppercase;
      color: var(--muted);
      font-weight: 800;
      letter-spacing: 0.4px;
    }
    .subscription-top h2 {
      font-family: 'Sora', sans-serif;
      font-size: 1.05rem;
    }
    .subscription-status {
      background: rgba(238, 127, 59, 0.16);
      color: #8b3a18;
      font-size: 0.76rem;
      font-weight: 800;
      border-radius: 999px;
      padding: 5px 10px;
    }
    .subscription-status.is-active {
      background: rgba(14, 143, 131, 0.16);
      color: #0a6a5f;
    }
    .subscription-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 10px;
    }
    .sub-item {
      background: rgba(14, 143, 131, 0.06);
      border: 1px solid rgba(14, 143, 131, 0.16);
      border-radius: 10px;
      padding: 10px;
      display: grid;
      gap: 4px;
    }
    .sub-item span {
      color: var(--muted);
      font-size: 0.76rem;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.35px;
    }
    .sub-item strong {
      color: #173a42;
      font-size: 0.93rem;
    }
    .sub-item-name-wrapper {
      display: flex;
      align-items: center;
      gap: 6px;
    }
    .btn-edit-name {
      background: none;
      border: none;
      padding: 2px 4px;
      cursor: pointer;
      font-size: 0.9rem;
      opacity: 0;
      transition: opacity 0.2s;
      min-width: auto;
      min-height: auto;
    }
    .sub-item:hover .btn-edit-name {
      opacity: 1;
    }
    .btn-edit-name:hover {
      filter: brightness(1.2);
    }
    .subscription-actions {
      display: grid;
      grid-template-columns: 1fr;
      gap: 10px;
      margin-top: 12px;
    }
    .subscription-actions select,
    .subscription-actions input {
      width: 100%;
      border: 1px solid var(--line);
      border-radius: 10px;
      padding: 10px 12px;
      font-size: 0.9rem;
      font-family: 'Manrope', sans-serif;
      outline: none;
      background: #fafcfc;
      transition: border-color 0.2s, box-shadow 0.2s;
    }
    .subscription-actions select:focus,
    .subscription-actions input:focus {
      border-color: rgba(14, 143, 131, 0.55);
      box-shadow: 0 0 0 4px rgba(14, 143, 131, 0.12);
    }
    .avatar {
      width: 26px;
      height: 26px;
      border-radius: 50%;
      background: linear-gradient(145deg, var(--brand), #0fb8a9);
      display: grid;
      place-items: center;
      color: #fff;
      font-size: 0.75rem;
      font-weight: 800;
    }
    .btn-logout {
      border: 1px solid rgba(192, 57, 43, 0.55);
      background: rgba(192, 57, 43, 0.13);
      color: var(--danger);
      border-radius: 999px;
      padding: 7px 13px;
      font-size: 0.82rem;
      font-weight: 700;
      cursor: pointer;
      transition: background 0.2s, border-color 0.2s;
    }
    .btn-logout:hover { background: rgba(192, 57, 43, 0.22); border-color: rgba(192, 57, 43, 0.8); }

    /* Toolbar padrão fornecedores */
    .toolbar {
      display: flex;
      align-items: center;
      gap: 10px;
      margin-bottom: 12px;
      flex-wrap: wrap;
    }
    .toolbar .toolbar-btn {
      min-height: 42px;
      min-width: 148px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
    }
    .toolbar .btn-new.toolbar-btn { padding: 0 16px; }

    @media (max-width: 1100px) {
      .topbar { grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; }
      .brand { min-width: 0; }
      nav { justify-self: stretch; justify-content: flex-start; }
      .user-area { gap: 6px; }
      .user-chip { max-width: 155px; padding: 6px 10px 6px 8px; }
      .btn-logout { padding: 6px 10px; }
      .toolbar .toolbar-btn { min-width: 126px; }
    }
    @media (max-width: 920px) {
      .topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
      .brand { order: 1; }
      .user-area { order: 2; margin-left: auto; }
      nav { order: 3; width: 100%; padding-bottom: 2px; }
      .toolbar .toolbar-btn { flex: 1 1 calc(50% - 8px); min-width: 0; }
    }
    @media (max-width: 1200px) {
      .chip-greeting { display: none; }
      .user-chip { max-width: 180px; }
    }
    @media (max-width: 768px) {
      .topbar { display: flex; align-items: flex-start; flex-direction: column; }
      .brand { width: 100%; }
      nav { width: 100%; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
      nav a { white-space: nowrap; flex: 0 0 auto; }
      .user-area { width: 100%; justify-content: space-between; margin-left: 0; }
      .user-chip { max-width: 65vw; }
      .toolbar { flex-direction: column; align-items: stretch; }
      .toolbar > div { width: 100%; }
      .toolbar .btn, .toolbar .btn-new { width: 100%; }
      .user-menu-panel { right: 0; }
    }
    @media (max-width: 560px) {
      .user-chip span { display: none; }
      .toolbar .btn, .toolbar .btn-new, .modal-actions button { min-height: 44px; }
      .modal-actions { flex-direction: column-reverse; gap: 8px; }
      .table-actions { flex-wrap: wrap; }
      .btn-edit, .btn-delete { flex: 1 1 120px; }
    }
    main { padding: 36px 0 64px; }

    .hero-spaced {
      margin-bottom: 18px;
    }

    .hero-title {
      font-family: 'Sora', sans-serif;
      font-size: 2rem;
      font-weight: 800;
      margin-bottom: 8px;
    }

    .hero-description {
      color: var(--muted);
      font-size: 1.04rem;
      line-height: 1.6;
      max-width: 600px;
      margin-bottom: 10px;
    }

    .hero-actions {
      margin-top: 14px;
      display: flex;
      gap: 10px;
      flex-wrap: wrap;
    }

    .subscription-top {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      margin-bottom: 12px;
    }

    .subscription-label {
      font-size: 0.75rem;
      text-transform: uppercase;
      color: var(--muted);
      font-weight: 800;
      letter-spacing: 0.4px;
    }

    .subscription-top h2 {
      font-family: 'Sora', sans-serif;
      font-size: 1.05rem;
    }

    .subscription-status {
      background: rgba(238, 127, 59, 0.16);
      color: #8b3a18;
      font-size: 0.76rem;
      font-weight: 800;
      border-radius: 999px;
      padding: 5px 10px;
    }

    .subscription-status.is-active {
      background: rgba(14, 143, 131, 0.16);
      color: #0a6a5f;
    }

    .subscription-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 10px;
      margin-bottom: 12px;
    }

    .sub-item {
      background: rgba(14, 143, 131, 0.06);
      border: 1px solid rgba(14, 143, 131, 0.16);
      border-radius: 10px;
      padding: 10px;
      display: grid;
      gap: 4px;
    }

    .sub-item span {
      color: var(--muted);
      font-size: 0.76rem;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.35px;
    }

    .sub-item strong {
      color: #173a42;
      font-size: 0.93rem;
    }

    .sub-item-name-wrapper {
      display: flex;
      align-items: center;
      gap: 6px;
    }

    .btn-edit-name {
      background: none;
      border: none;
      padding: 2px 4px;
      cursor: pointer;
      font-size: 0.9rem;
      opacity: 0;
      transition: opacity 0.2s;
      min-width: auto;
      min-height: auto;
    }

    .sub-item:hover .btn-edit-name {
      opacity: 1;
    }

    .btn-edit-name:hover {
      filter: brightness(1.2);
    }

    .subscription-actions {
      display: grid;
      grid-template-columns: 1fr;
      gap: 10px;
    }

    .subscription-actions select,
    .subscription-actions input {
      width: 100%;
      border: 1px solid var(--line);
      border-radius: 10px;
      padding: 10px 12px;
      font-size: 0.9rem;
      font-family: 'Manrope', sans-serif;
      outline: none;
      background: #fafcfc;
      transition: border-color 0.2s, box-shadow 0.2s;
    }

    .subscription-actions select:focus,
    .subscription-actions input:focus {
      border-color: rgba(14, 143, 131, 0.55);
      box-shadow: 0 0 0 4px rgba(14, 143, 131, 0.12);
    }

    .kpi-row {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 12px;
      margin-bottom: 24px;
    }
    .kpi {
      border: 1px solid var(--line);
      border-radius: 16px;
      background: var(--card);
      padding: 16px;
      box-shadow: 0 4px 14px rgba(8, 37, 44, 0.06);
      position: relative;
      overflow: hidden;
    }
    .kpi::before {
      content: '';
      position: absolute;
      top: 0; left: 0; right: 0;
      height: 3px;
      background: linear-gradient(90deg, var(--brand), #0fb8a9);
    }
    .kpi-label {
      font-size: 0.8rem;
      color: var(--muted);
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.4px;
      margin-bottom: 8px;
    }
    .kpi-value {
      font-family: 'Sora', sans-serif;
      font-size: 1.7rem;
      font-weight: 800;
      color: var(--ink);
      line-height: 1;
      margin-bottom: 4px;
    }
    .kpi-sub {
      font-size: 0.8rem;
      color: var(--muted);
      font-weight: 600;
    }
    .toolbar {
      display: flex;
      align-items: center;
      gap: 10px;
      margin-bottom: 12px;
      flex-wrap: wrap;
    }
    .search-wrap {
      flex: 1;
      min-width: 220px;
      position: relative;
    }
    .search-wrap svg {
      position: absolute;
      left: 12px;
      top: 50%;
      transform: translateY(-50%);
      color: var(--muted);
      pointer-events: none;
    }
    .search-wrap input {
      width: 100%;
      border: 1px solid var(--line);
      border-radius: 10px;
      padding: 10px 12px 10px 38px;
      font-size: 0.92rem;
      font-family: 'Manrope', sans-serif;
      background: var(--card);
      outline: none;
      transition: border-color 0.2s, box-shadow 0.2s;
    }
    .search-wrap input:focus {
      border-color: rgba(14, 143, 131, 0.55);
      box-shadow: 0 0 0 4px rgba(14, 143, 131, 0.12);
    }
    .btn {
      border: 0;
      padding: 10px 18px;
      border-radius: 10px;
      font-weight: 800;
      font-size: 0.9rem;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      gap: 7px;
      transition: transform 0.2s, box-shadow 0.2s;
      text-decoration: none;
      white-space: nowrap;
    }
    .btn:hover { transform: translateY(-1px); }
    .btn-soft {
      background: rgba(14, 143, 131, 0.1);
      color: var(--brand-strong);
      border: 1px solid rgba(14, 143, 131, 0.25);
    }

    .btn-main {
      background: linear-gradient(135deg, var(--brand), #0cac9c);
      color: #fff;
      box-shadow: 0 10px 22px rgba(14, 143, 131, 0.28);
    }

    .field-preco-readonly {
      background: rgba(14, 143, 131, 0.06);
      font-weight: 700;
    }

    .overlay {
      display: none;
      position: fixed;
      inset: 0;
      background: rgba(10, 25, 30, 0.45);
      z-index: 100;
      backdrop-filter: blur(3px);
      align-items: center;
      justify-content: center;
      padding: 16px;
      overflow-y: auto;
      overscroll-behavior: contain;
    }

    .overlay.open { display: flex; }

    body.modal-open {
      overflow: hidden;
    }

    #productionOverlay {
      align-items: flex-start;
      overflow-y: auto;
    }

    .modal {
      background: var(--card);
      border-radius: 22px;
      padding: 28px;
      width: 100%;
      max-width: 480px;
      max-height: calc(100dvh - 32px);
      overflow-y: auto;
      box-shadow: 0 32px 80px rgba(0,0,0,0.22);
      animation: popIn 0.25s ease;
    }

    #productionOverlay .modal {
      max-width: 760px;
      max-height: calc(100vh - 32px);
      margin: 16px auto;
      overflow-y: auto;
    }

    #entradaOverlay .modal {
      max-width: 780px;
      max-height: calc(100vh - 32px);
      margin: 16px auto;
      overflow-y: auto;
    }

    .entrada-search-wrap {
      margin-bottom: 12px;
    }

    .entrada-search-wrap input {
      width: 100%;
      padding: 9px 14px;
      border-radius: 8px;
      border: 1px solid var(--border);
      background: var(--surface2, rgba(255,255,255,0.04));
      color: var(--text);
      font-size: 14px;
      outline: none;
      box-sizing: border-box;
    }

    .entrada-search-wrap input:focus {
      border-color: var(--brand, #6366f1);
    }

    .entrada-table-wrap {
      max-height: 420px;
      overflow-y: auto;
      border: 1px solid var(--border);
      border-radius: 8px;
    }

    .entrada-historico-table {
      width: 100%;
      border-collapse: collapse;
      font-size: 13px;
      margin-top: 12px;
      table-layout: fixed;
    }

    .entrada-historico-table thead tr {
      background: var(--surface2, rgba(255,255,255,0.04));
    }

    .entrada-historico-table th {
      text-align: left;
      padding: 10px 12px;
      color: var(--text-muted);
      font-weight: 700;
      font-size: 11px;
      letter-spacing: 0.06em;
      text-transform: uppercase;
      border-bottom: 2px solid var(--border);
      position: sticky;
      top: 0;
      z-index: 1;
      background: var(--bg, #0f0f1a);
    }

    .entrada-historico-table td {
      padding: 10px 12px;
      border-bottom: 1px solid var(--border);
      color: var(--text);
      vertical-align: middle;
    }

    .entrada-historico-table tbody tr:nth-child(even) td {
      background: var(--surface2, rgba(255,255,255,0.02));
    }

    .entrada-historico-table tbody tr:hover td {
      background: var(--surface2, rgba(255,255,255,0.05));
    }

    .entrada-historico-table tr:last-child td {
      border-bottom: none;
    }

    .entrada-col-data {
      width: 180px;
      white-space: nowrap;
      color: var(--text-muted);
      font-size: 12px;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .entrada-col-item {
      width: 34%;
      font-weight: 600;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .entrada-col-tipo {
      width: 150px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .entrada-col-qtd {
      width: 86px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .entrada-col-obs {
      width: 220px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      color: var(--text-muted);
      font-size: 12px;
    }

    .entrada-tipo-badge {
      font-size: 11px;
      font-weight: 700;
      padding: 3px 8px;
    }

    .entrada-tipo-desconhecido {
      color: var(--text-muted);
      font-size: 12px;
    }

    .entrada-badge {
      display: inline-block;
      background: rgba(16, 185, 129, 0.15);
      color: #10b981;
      font-weight: 700;
      font-size: 12px;
      padding: 3px 10px;
      border-radius: 999px;
      border: 1px solid rgba(16, 185, 129, 0.3);
    }

    @keyframes popIn {
      from { opacity: 0; transform: scale(0.96) translateY(12px); }
      to { opacity: 1; transform: scale(1) translateY(0); }
    }

    .modal h2 {
      font-family: 'Sora', sans-serif;
      font-size: 1.25rem;
      margin-bottom: 4px;
    }

    .modal .sub {
      color: var(--muted);
      font-size: 0.88rem;
      margin-bottom: 20px;
    }

    .production-hint {
      margin-top: 2px;
      color: var(--muted);
      font-size: 0.8rem;
      line-height: 1.5;
    }

    .production-components-field {
      margin-bottom: 10px;
    }

    .prod-components-list {
      display: grid;
      gap: 10px;
      margin-bottom: 10px;
    }

    .prod-component-row {
      border: 1px solid var(--line);
      border-radius: 12px;
      padding: 10px;
      background: #fbfdfd;
      display: grid;
      gap: 8px;
    }

    .prod-row-main {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      align-items: center;
      gap: 8px;
    }

    .prod-row-inputs {
      display: grid;
      grid-template-columns: minmax(0, 1fr) 180px;
      gap: 8px;
    }

    .prod-comp-picker {
      position: relative;
      min-width: 0;
    }

    .prod-row-inputs-extra {
      grid-template-columns: minmax(0, 1fr) 180px;
    }

    .prod-row-main > * {
      min-width: 0;
    }

    .prod-component-row .prod-comp-select,
    .prod-component-row .prod-comp-search,
    .prod-component-row .prod-comp-qty,
    .prod-component-row .prod-extra-cost-label,
    .prod-component-row .prod-extra-cost-value {
      width: 100%;
      border: 1px solid var(--line);
      border-radius: 10px;
      padding: 10px 12px;
      font-size: 0.9rem;
      font-family: 'Manrope', sans-serif;
      background: #fafcfc;
      outline: none;
    }

    .prod-comp-dropdown {
      position: absolute;
      top: calc(100% + 4px);
      left: 0;
      right: 0;
      z-index: 40;
      max-height: 210px;
      overflow-y: auto;
      background: var(--card);
      border: 1px solid rgba(14, 143, 131, 0.32);
      border-radius: 10px;
      box-shadow: 0 8px 22px rgba(8, 37, 44, 0.2);
      list-style: none;
      margin: 0;
      padding: 4px 0;
    }

    .prod-comp-option,
    .prod-comp-option-empty {
      padding: 9px 12px;
      font-size: 0.86rem;
      line-height: 1.35;
    }

    .prod-comp-option {
      color: var(--ink);
      cursor: pointer;
      transition: background 0.15s, color 0.15s;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .prod-comp-option:hover {
      background: rgba(14, 143, 131, 0.12);
      color: var(--brand-strong);
    }

    .prod-comp-option-empty {
      color: var(--muted);
      cursor: default;
    }

    @media (max-width: 1200px) {
      .kpi-row { grid-template-columns: repeat(2, 1fr); }
      .chip-greeting { display: none; }
      .user-chip { max-width: 180px; }
    }

    @media (max-width: 768px) {
      .topbar {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
      }

      nav {
        width: 100%;
        justify-content: flex-start;
        padding-bottom: 4px;
      }

      .user-area {
        width: 100%;
        justify-content: space-between;
      }

      .hero-actions,
      .toolbar,
      .modal-actions {
        flex-direction: column;
        align-items: stretch;
      }

      .hero-actions .btn,
      .toolbar .btn,
      .modal-actions .btn {
        width: 100%;
        justify-content: center;
      }

      .prod-row-main,
      .prod-row-inputs,
      .field-row {
        grid-template-columns: 1fr;
      }

      .production-price-tools {
        grid-template-columns: 1fr;
      }

      .prod-summary-grid {
        grid-template-columns: 1fr;
      }

      .prod-summary-item-total {
        grid-column: auto;
      }

      #productionOverlay .modal {
        max-height: calc(100vh - 24px);
        margin: 12px auto;
      }
    }

    @media (max-width: 560px) {
      main { padding: 24px 0 48px; }

      .shell { width: 94%; }

      .kpi-row { grid-template-columns: 1fr; gap: 8px; }

      .hero,
      .kpi,
      .table-card {
        border-radius: 14px;
      }

      .hero-title {
        font-size: 1.7rem;
      }

      .search-wrap { min-width: unset; }

      .user-chip span { display: none; }

      .modal { padding: 20px 16px; }

      .overlay {
        padding: 10px;
      }

      .modal input,
      .modal select,
      .modal textarea {
        font-size: 16px;
      }

      .btn,
      .toolbar .btn,
      .modal-actions .btn,
      .prod-comp-remove {
        min-height: 44px;
      }

      .table-wrap {
        max-height: 56dvh;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
      }

      table {
        min-width: 900px;
      }

      .prod-comp-dropdown {
        max-height: 44dvh;
      }

      .user-menu-panel {
        right: 0;
      }
    }

    .prod-component-row .prod-comp-select:focus,
    .prod-component-row .prod-comp-search:focus,
    .prod-component-row .prod-comp-qty:focus,
    .prod-component-row .prod-extra-cost-label:focus,
    .prod-component-row .prod-extra-cost-value:focus {
      border-color: rgba(14, 143, 131, 0.55);
      box-shadow: 0 0 0 4px rgba(14, 143, 131, 0.12);
    }

    .prod-comp-remove {
      padding: 9px 12px;
      justify-content: center;
      min-width: 96px;
      white-space: nowrap;
    }

    .prod-component-price {
      display: flex;
      gap: 16px;
      flex-wrap: wrap;
      font-size: 0.83rem;
      color: var(--muted);
      line-height: 1.4;
      padding-left: 2px;
    }

    .prod-component-price strong {
      color: #173a42;
    }

    .production-summary {
      border: 1px solid rgba(14, 143, 131, 0.28);
      background: rgba(14, 143, 131, 0.08);
      border-radius: 10px;
      padding: 8px 10px;
      font-size: 0.84rem;
      font-weight: 700;
      color: #0d5f57;
      margin-bottom: 10px;
    }

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

    .prod-summary-item {
      border: 1px solid rgba(14, 143, 131, 0.2);
      border-radius: 10px;
      background: rgba(255, 255, 255, 0.68);
      padding: 6px 8px;
      display: grid;
      gap: 2px;
    }

    .prod-summary-label {
      font-size: 0.72rem;
      font-weight: 700;
      letter-spacing: 0.2px;
      color: #2e5a61;
    }

    .prod-summary-value {
      font-size: 0.88rem;
      font-weight: 800;
      line-height: 1.2;
      color: #0f4f59;
    }

    .prod-summary-item-profit {
      border-width: 2px;
    }

    .prod-summary-item-total {
      grid-column: 1 / -1;
      background: rgba(14, 143, 131, 0.13);
    }

    .production-summary.is-profit-positive {
      border-color: rgba(11, 125, 69, 0.35);
      background: rgba(11, 125, 69, 0.08);
    }

    .production-summary.is-profit-negative {
      border-color: rgba(179, 39, 39, 0.35);
      background: rgba(179, 39, 39, 0.08);
      color: #7f1f1f;
    }

    .production-summary.is-profit-neutral {
      border-color: rgba(95, 109, 115, 0.35);
      background: rgba(95, 109, 115, 0.08);
      color: #3d5258;
    }

    .prod-profit {
      font-weight: 800;
    }

    .prod-profit-positive {
      color: #0b7d45;
    }

    .prod-profit-negative {
      color: #b32727;
    }

    .prod-profit-neutral {
      color: #4d5f65;
    }

    .prod-profit-positive .prod-summary-label,
    .prod-profit-positive .prod-summary-value {
      color: #0b7d45;
    }

    .prod-profit-negative .prod-summary-label,
    .prod-profit-negative .prod-summary-value {
      color: #b32727;
    }

    .prod-profit-neutral .prod-summary-label,
    .prod-profit-neutral .prod-summary-value {
      color: #4d5f65;
    }

    .field-help {
      color: var(--muted);
      font-size: 0.8rem;
      line-height: 1.4;
    }

    #labelQtdMeta {
      display: block;
      font-weight: 700;
      font-size: 0.8rem;
      color: #0b7d45;
      margin-top: 6px;
    }

    .field-row .field label {
      white-space: nowrap;
      min-height: 22px;
      display: inline-flex;
      align-items: center;
    }

    #modalOverlay .field-row {
      align-items: start;
    }

    #modalOverlay .field-row .field {
      margin-bottom: 0;
      align-content: start;
    }

    #modalOverlay .field-row .field input,
    #modalOverlay .field-row .field select {
      min-height: 44px;
    }

    .production-price-tools {
      display: grid;
      grid-template-columns: minmax(0, 1fr);
      gap: 8px;
      align-items: center;
    }

    .production-margin-quick {
      display: flex;
      gap: 8px;
      margin-top: 8px;
      flex-wrap: wrap;
    }

    .production-margin-quick .btn {
      width: auto;
      min-width: 64px;
      padding: 8px 12px;
      border-radius: 999px;
      font-size: 0.8rem;
      font-weight: 800;
    }

    .production-margin-quick .btn.is-active {
      background: linear-gradient(135deg, var(--brand), #0fb8a9);
      border-color: transparent;
      color: #ffffff;
      box-shadow: 0 8px 18px rgba(14, 143, 131, 0.28);
    }

    .field {
      display: grid;
      gap: 6px;
      margin-bottom: 14px;
    }

    .field label {
      font-size: 0.88rem;
      font-weight: 700;
      color: #1f3840;
    }

    .auto-consumo-box {
      margin-top: 0;
      margin-bottom: 10px;
      padding: 12px 14px;
      border: 1px solid rgba(14, 143, 131, 0.28);
      border-radius: 12px;
      background: linear-gradient(180deg, rgba(14, 143, 131, 0.09) 0%, rgba(14, 143, 131, 0.05) 100%);
      display: grid;
      gap: 7px;
    }

    .auto-consumo-toggle {
      display: grid;
      grid-template-columns: 18px 1fr;
      align-items: start;
      column-gap: 10px;
      row-gap: 2px;
      font-size: 0.9rem;
      font-weight: 800;
      color: #15343b;
      cursor: pointer;
      line-height: 1.3;
    }

    .auto-consumo-toggle input {
      width: 16px;
      height: 16px;
      margin-top: 1px;
      accent-color: var(--brand);
    }

    .auto-consumo-box small {
      color: #4c5d62;
      font-size: 0.82rem;
      line-height: 1.45;
      padding-left: 28px;
    }

    .auto-consumo-toggle input:disabled {
      opacity: 0.55;
      cursor: not-allowed;
    }

    .auto-consumo-box:has(.auto-consumo-toggle input:disabled) {
      border-color: rgba(18, 33, 39, 0.2);
      background: linear-gradient(180deg, rgba(18, 33, 39, 0.07) 0%, rgba(18, 33, 39, 0.04) 100%);
    }

    .field input {
      width: 100%;
      border: 1px solid var(--line);
      border-radius: 10px;
      padding: 11px 13px;
      font-size: 0.92rem;
      font-family: 'Manrope', sans-serif;
      outline: none;
      background: #fafcfc;
      transition: border-color 0.2s, box-shadow 0.2s;
    }

    .field input:focus {
      border-color: rgba(14, 143, 131, 0.55);
      box-shadow: 0 0 0 4px rgba(14, 143, 131, 0.12);
    }

    .field select {
      width: 100%;
      border: 1px solid var(--line);
      border-radius: 10px;
      padding: 11px 13px;
      font-size: 0.92rem;
      font-family: 'Manrope', sans-serif;
      outline: none;
      background: #fafcfc;
      transition: border-color 0.2s, box-shadow 0.2s;
    }

    .field select:focus {
      border-color: rgba(14, 143, 131, 0.55);
      box-shadow: 0 0 0 4px rgba(14, 143, 131, 0.12);
    }

    /* ===== MODAL OVERLAY (modal-overlay class) ===== */
    .modal-overlay {
      display: none;
      position: fixed;
      inset: 0;
      background: rgba(10, 25, 30, 0.45);
      z-index: 100;
      backdrop-filter: blur(3px);
      align-items: center;
      justify-content: center;
      padding: 16px;
      overflow-y: auto;
      overscroll-behavior: contain;
    }

    .modal-overlay:not(.is-hidden) {
      display: flex;
    }

    .modal-overlay .modal {
      background: var(--card);
      border-radius: 22px;
      padding: 28px;
      width: 100%;
      max-width: 480px;
      max-height: calc(100dvh - 32px);
      overflow-y: auto;
      box-shadow: 0 32px 80px rgba(0,0,0,0.22);
      animation: popIn 0.25s ease;
      position: relative;
    }

    .modal-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 20px;
      gap: 12px;
    }

    .modal-header h3 {
      font-family: 'Sora', sans-serif;
      font-size: 1.18rem;
      font-weight: 700;
      color: var(--ink);
    }

    .modal-close {
      background: none;
      border: none;
      font-size: 1.3rem;
      cursor: pointer;
      padding: 4px 8px;
      color: var(--muted);
      transition: color 0.2s;
      min-width: auto;
      min-height: auto;
    }

    .modal-close:hover {
      color: var(--ink);
    }

    .modal-body {
      margin-bottom: 20px;
    }

    .modal-actions {
      display: flex;
      gap: 10px;
      justify-content: flex-end;
    }

    .modal-actions .btn {
      flex: 1;
      min-height: 42px;
    }

    .field-row {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 12px;
    }

    .field-meta-spacer {
      display: block;
      min-height: 18px;
      margin-top: 6px;
      visibility: hidden;
    }

    .modal-actions {
      display: flex;
      gap: 10px;
      justify-content: flex-end;
      margin-top: 20px;
      border-top: 1px solid rgba(18, 33, 39, 0.08);
      padding-top: 14px;
      flex-wrap: wrap;
    }

    #modalOverlay .modal-actions {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      align-items: stretch;
      justify-content: stretch;
    }

    #modalOverlay .modal-actions:has(#btnDeleteModal:not(.is-hidden)) {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    #modalOverlay .modal-actions:has(#btnDeleteModal:not(.is-hidden)):not(:has(#btnEditProductionRecipe:not(.is-hidden))) #btnSaveModal {
      grid-column: 1 / -1;
    }

    #modalOverlay .modal-actions:has(#btnDeleteModal:not(.is-hidden)):has(#btnEditProductionRecipe:not(.is-hidden)) {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    #modalOverlay .modal-actions .btn {
      min-height: 42px;
      padding-inline: 18px;
      width: 100%;
      justify-content: center;
      min-width: 0;
    }

    .modal-feedback {
      display: none;
      border-radius: 8px;
      padding: 9px 12px;
      margin-bottom: 12px;
      font-size: 0.85rem;
    }

    .modal-feedback.error {
      display: block;
      color: #8b3a18;
      background: rgba(238, 127, 59, 0.16);
      border: 1px solid rgba(238, 127, 59, 0.38);
    }
    .table-card {
      border: 1px solid var(--line);
      border-radius: 18px;
      background: var(--card);
      box-shadow: var(--shadow);
      overflow: hidden;
    }
    .table-wrap {
      overflow-x: auto;
      overflow-y: auto;
      max-height: 470px;
      scrollbar-gutter: stable;
      -webkit-overflow-scrolling: touch;
    }
    table {
      width: 100%;
      min-width: 980px;
      border-collapse: collapse;
    }
    thead th {
      position: sticky;
      top: 0;
      background: #d2e1e1;
      text-align: left;
      font-size: 0.78rem;
      text-transform: uppercase;
      letter-spacing: 0.35px;
      color: #1b3d45;
      padding: 12px 14px;
      border-bottom: 1px solid var(--line);
      white-space: nowrap;
    }
    tbody td {
      padding: 12px 14px;
      border-bottom: 1px solid var(--line);
      font-size: 0.9rem;
      vertical-align: middle;
    }
    tbody tr:hover { background: rgba(14, 143, 131, 0.05); }
    tbody tr:last-child td { border-bottom: 0; }
    .material-name {
      font-weight: 800;
      color: #183841;
      margin-bottom: 2px;
      display: block;
      max-width: 320px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .material-id {
      color: var(--muted);
      font-size: 0.8rem;
    }
    .cell-fornecedor {
      max-width: 190px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      color: var(--muted);
      font-size: 0.86rem;
    }
    .badge {
      display: inline-flex;
      align-items: center;
      border-radius: 999px;
      padding: 4px 9px;
      font-weight: 800;
      font-size: 0.75rem;
      white-space: nowrap;
    }
    .badge-ok { color: #0a6a5f; background: rgba(14, 143, 131, 0.14); }
    .badge-low { color: #9a4b1b; background: rgba(238, 127, 59, 0.22); }
    .badge-zero { color: #8e2f24; background: rgba(192, 57, 43, 0.14); }
    .badge-cat-final {
      color: #1a4fb5;
      background: rgba(51, 119, 255, 0.12);
      border: 1px solid rgba(51, 119, 255, 0.28);
    }
    .badge-cat-raw {
      color: #0a6a5f;
      background: rgba(14, 143, 131, 0.12);
      border: 1px solid rgba(14, 143, 131, 0.28);
    }
    .cell-actions {
      white-space: nowrap;
    }
    .btn-sell {
      padding: 7px 12px;
      font-size: 0.78rem;
      font-weight: 800;
      border-radius: 8px;
      border-color: rgba(14, 143, 131, 0.35);
    }
    .btn-edit {
      padding: 7px 12px;
      font-size: 0.78rem;
      font-weight: 800;
      border-radius: 8px;
      border-color: rgba(90, 110, 200, 0.35);
      color: #3a56cc;
    }
    .btn-edit:hover {
      background: rgba(90, 110, 200, 0.1);
      border-color: rgba(90, 110, 200, 0.6);
    }
    .btn-danger {
      padding: 10px 18px;
      font-size: 0.88rem;
      font-weight: 700;
      border-radius: 10px;
      background: transparent;
      border: 1.5px solid rgba(192, 57, 43, 0.4);
      color: #c0392b;
      cursor: pointer;
      transition: background 0.15s, border-color 0.15s;
    }
    .btn-danger:hover {
      background: rgba(192, 57, 43, 0.08);
      border-color: rgba(192, 57, 43, 0.7);
    }
    .is-hidden { display: none !important; }

    .fornecedor-dropdown {
      position: absolute;
      top: calc(100% + 4px);
      left: 0;
      right: 0;
      z-index: 9999;
      background: var(--card);
      border: 1px solid rgba(14, 143, 131, 0.3);
      border-radius: 10px;
      box-shadow: 0 8px 24px rgba(8, 37, 44, 0.18);
      padding: 4px 0;
      list-style: none;
      max-height: 180px;
      overflow-y: auto;
    }
    .fornecedor-dropdown-item {
      padding: 9px 14px;
      font-size: 0.9rem;
      font-weight: 600;
      color: var(--ink);
      cursor: pointer;
      transition: background 0.15s;
    }
    .fornecedor-dropdown-item:hover {
      background: rgba(14, 143, 131, 0.12);
      color: var(--brand-strong);
    }
    .empty-state {
      text-align: center;
      padding: 42px 10px;
      color: var(--muted);
      font-size: 0.94rem;
    }
    @media (max-width: 1000px) {
      .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    }
    @media (max-width: 760px) {
      .topbar { display: flex; align-items: flex-start; flex-direction: column; }
      .user-area { width: 100%; justify-content: space-between; }
      .kpi-row { grid-template-columns: 1fr; }
      .hero { padding: 16px; }
      .user-menu-panel { right: 0; }
      #modalOverlay .field-row {
        grid-template-columns: 1fr;
        gap: 10px;
      }
      #modalOverlay .field-meta-spacer {
        display: none;
      }
      .prod-row-main { grid-template-columns: 1fr; }
      .prod-row-inputs { grid-template-columns: 1fr; }
      #productionOverlay .field-row { grid-template-columns: 1fr; gap: 10px; }
      #productionOverlay .field-row .field label {
        white-space: normal;
        min-height: 0;
        line-height: 1.3;
      }
      #productionOverlay .production-margin-quick .btn {
        min-height: 40px;
      }
      .prod-comp-remove { width: 100%; }
      .auto-consumo-box small { padding-left: 0; }
      #modalOverlay .modal-actions .btn { flex: 1 1 100%; }
      #productionOverlay .modal {
        max-width: 100%;
        margin: 0;
        max-height: calc(100vh - 20px);
      }

      #entradaOverlay {
        padding: 10px;
      }

      #entradaOverlay .modal {
        max-width: 100%;
        margin: 0;
        padding: 16px;
        max-height: calc(100dvh - 20px);
      }

      .entrada-search-wrap {
        margin-bottom: 10px;
      }

      .entrada-search-wrap input {
        font-size: 16px;
        padding: 10px 12px;
      }

      .entrada-table-wrap {
        max-height: 56dvh;
        overflow: auto;
        -webkit-overflow-scrolling: touch;
      }

      .entrada-historico-table {
        margin-top: 0;
        min-width: 640px;
        table-layout: auto;
      }

      .entrada-historico-table th,
      .entrada-historico-table td {
        padding: 9px 10px;
      }

      .entrada-col-item,
      .entrada-col-obs {
        max-width: 180px;
      }

      #entradaOverlay .modal-actions .btn {
        width: 100%;
      }
    }

    @media (max-width: 420px) {
      #entradaOverlay .modal {
        padding: 14px;
      }

      .entrada-table-wrap {
        max-height: 52dvh;
      }

      .entrada-historico-table {
        min-width: 600px;
      }
    }
    .reveal-section { opacity: 0; transform: translateY(18px); transition: opacity 0.55s ease, transform 0.55s ease; }
    .reveal-section.visible { opacity: 1; transform: translateY(0); }
    .kpi.reveal-section:nth-child(1) { transition-delay: 0ms; }
    .kpi.reveal-section:nth-child(2) { transition-delay: 80ms; }
    .kpi.reveal-section:nth-child(3) { transition-delay: 160ms; }
    .kpi.reveal-section:nth-child(4) { transition-delay: 240ms; }
  




