:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #475569;
  --line: #cbd5e1;
  --accent: #1e40af;
  --accent-dark: #1d4ed8;
  --danger: #b91c1c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Segoe UI, system-ui, Arial, sans-serif;
}

.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 16px;
}

.header {
  margin-bottom: 12px;
}

.header h1 {
  margin: 0;
  font-size: 1.4rem;
}

.header p {
  margin: 4px 0 0;
  color: var(--muted);
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
}

.card h2 {
  margin: 0 0 12px;
  font-size: 1.1rem;
}

.card h3 {
  margin: 14px 0 6px;
  font-size: 1rem;
}

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

.section-title-row h2 {
  margin: 0;
}

.btn-back {
  background: #f8fafc;
  border-color: #94a3b8;
  color: #334155;
  min-width: 88px;
}

.btn-back:hover {
  background: #e2e8f0;
}

.sync-card {
  padding: 10px 14px;
}

.sync-status {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  font-size: 0.9rem;
  font-weight: 600;
}

.sync-ok {
  background: #ecfdf5;
  border-color: #34d399;
  color: #065f46;
}

.sync-warn {
  background: #fffbeb;
  border-color: #f59e0b;
  color: #92400e;
}

.sync-error {
  background: #fef2f2;
  border-color: #f87171;
  color: #991b1b;
}

.sync-pending {
  background: #eff6ff;
  border-color: #60a5fa;
  color: #1d4ed8;
}

.legend-box {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #f8fafc;
}

.legend-box ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

.legend-box li {
  margin: 4px 0;
}

.report-box {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #f8fafc;
}

.report-header {
  font-size: 0.95rem;
  margin-bottom: 6px;
}

.report-summary {
  font-size: 0.86rem;
  color: var(--muted);
  margin-bottom: 10px;
}

.report-table {
  margin-bottom: 12px;
}

.report-sign,
.report-sign-line {
  margin-top: 10px;
  font-size: 0.9rem;
}

.dashboard-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 10px 0;
}

.dash-card {
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 12px;
  background: #f8fafc;
}

.dash-card.setor-1 {
  border-color: #60a5fa;
  background: linear-gradient(180deg, #eff6ff 0%, #f8fafc 100%);
}

.dash-card.setor-2 {
  border-color: #34d399;
  background: linear-gradient(180deg, #ecfdf5 0%, #f8fafc 100%);
}

.dash-card.total {
  border-color: #f59e0b;
  background: linear-gradient(180deg, #fffbeb 0%, #f8fafc 100%);
}

.dash-title {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.dash-value {
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1.1;
}

.dash-meta {
  margin-top: 4px;
  font-size: 0.82rem;
  color: var(--muted);
}

.dash-chart {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #f8fafc;
  margin-bottom: 8px;
}

.dash-row {
  display: grid;
  grid-template-columns: 64px 1fr 40px;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.dash-row:last-child {
  margin-bottom: 0;
}

.dash-bar-track {
  height: 14px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.dash-bar {
  height: 100%;
  border-radius: 999px;
  transition: width 0.35s ease;
}

.dash-bar.setor-1 {
  background: linear-gradient(90deg, #60a5fa 0%, #2563eb 100%);
}

.dash-bar.setor-2 {
  background: linear-gradient(90deg, #34d399 0%, #059669 100%);
}

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

.hub-item {
  display: grid;
  gap: 10px;
  justify-items: center;
  align-content: center;
  min-height: 120px;
  border: 1px solid #bfdbfe;
  border-radius: 14px;
  background: linear-gradient(180deg, #eff6ff 0%, #ffffff 100%);
  padding: 12px;
  text-align: center;
  cursor: pointer;
}

.hub-item:hover {
  background: linear-gradient(180deg, #dbeafe 0%, #eff6ff 100%);
  border-color: #60a5fa;
}

.hub-icon {
  width: 54px;
  height: 54px;
  border-radius: 999px;
  background: #1e40af;
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.hub-label {
  font-size: 0.86rem;
  font-weight: 700;
  color: #1e293b;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 0.9rem;
  margin-bottom: 8px;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.btn {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

.btn.primary,
.btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn:hover {
  background: #eff6ff;
}

.btn.primary:hover,
.btn.active:hover {
  background: var(--accent-dark);
}

.hidden {
  display: none;
}

.hint,
.muted,
.item-meta {
  color: var(--muted);
  font-size: 0.86rem;
}

.checklist {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  margin-bottom: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border-radius: 8px;
}

.check-row:nth-child(odd) {
  background: #f8fafc;
}

.sheet-box {
  border: 1px solid #334155;
  background: #ffffff;
  border-radius: 10px;
  padding: 8px;
  margin-bottom: 10px;
}

.sheet-topline {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid #64748b;
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 0.85rem;
}

.sheet-grid-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.sheet-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 0.78rem;
}

.sheet-table th,
.sheet-table td {
  border: 1px solid #0f172a;
  padding: 4px 5px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sheet-table th:nth-child(1),
.sheet-table td:nth-child(1) {
  width: 260px;
}

.sheet-table th:nth-child(3),
.sheet-table td:nth-child(3) {
  width: 260px;
}

.sheet-table th {
  background: #e2e8f0;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.7rem;
}

.sheet-table td:nth-child(3),
.sheet-table td:nth-child(4),
.sheet-table td:nth-child(5) {
  text-align: center;
}

#viewInspecao .sheet-box {
  overflow-x: auto;
}

#viewInspecao .sheet-table {
  min-width: unset;
}

#viewInspecao .sheet-table th:nth-child(1),
#viewInspecao .sheet-table td:nth-child(1) {
  width: 10%;
}

#viewInspecao .sheet-table th:nth-child(2),
#viewInspecao .sheet-table td:nth-child(2) {
  width: 16%;
}

#viewInspecao .sheet-table th:nth-child(3),
#viewInspecao .sheet-table td:nth-child(3) {
  width: 13%;
}

#viewInspecao .sheet-table th:nth-child(4),
#viewInspecao .sheet-table td:nth-child(4),
#viewInspecao .sheet-table th:nth-child(5),
#viewInspecao .sheet-table td:nth-child(5) {
  width: auto;
}

#viewInspecao .sheet-table th:nth-child(6),
#viewInspecao .sheet-table td:nth-child(6) {
  width: 16%;
}

#viewInspecao .sheet-table select,
#viewInspecao .sheet-table input[type="text"] {
  min-height: 38px;
  padding: 8px;
}

.sheet-row-select {
  cursor: pointer;
}

.sheet-row-select:hover {
  background: #eff6ff;
}

.sheet-row-active {
  background: #dbeafe;
}

body.mode-liberacao .ins-related {
  display: none !important;
}

.lib-cell {
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
}

.lib-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.lib-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: #0f172a;
  border-radius: 6px;
  padding: 18px 30px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  min-height: 72px;
  text-align: left;
}

.lib-btn-model {
  display: block;
  font-size: 1.3rem;
  font-weight: 700;
}

.lib-btn-forma {
  display: block;
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1.1;
}

tr.row-liberada td {
  background: #dcfce7 !important;
  border-color: #16a34a;
}

.lib-btn.active.btn-liberado {
  background: #dcfce7;
  border-color: #16a34a;
  color: #166534;
}

.lib-btn.active.btn-nao {
  background: #fef3c7;
  border-color: #d97706;
  color: #92400e;
}

.lib-btn.active.btn-manut {
  background: #fee2e2;
  border-color: #dc2626;
  color: #991b1b;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.forma-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.forma-grid.forma-grid-blocos {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  align-items: end;
}

.forma-block-wrap {
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  background: #f8fbff;
  padding: 6px;
}

.forma-block-divider {
  text-align: center;
  font-weight: 700;
  font-size: 0.72rem;
  color: #1e3a8a;
  background: #dbeafe;
  border-radius: 6px;
  padding: 4px 6px;
  margin-bottom: 6px;
  border: 1px solid #93c5fd;
}

.forma-block {
  display: flex;
  flex-direction: column-reverse;
  gap: 6px;
  min-width: 0;
}

.forma-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.forma-col-header {
  text-align: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: #1e40af;
  padding: 4px 0 6px;
  border-bottom: 2px solid #1e40af;
  margin-bottom: 6px;
}

.forma-btn {
  border: 2px solid var(--accent);
  background: #fff;
  color: var(--accent);
  border-radius: 8px;
  padding: 8px 8px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.1s;
  text-align: left;
  width: 100%;
  display: grid;
  grid-template-columns: 86px 128px;
  align-items: center;
  gap: 8px;
  justify-content: start;
}

.forma-numero {
  font-weight: 800;
  color: inherit;
  white-space: nowrap;
  text-align: left;
}

.forma-modelo {
  color: inherit;
  opacity: 0.9;
  font-size: 0.74rem;
  white-space: nowrap;
  width: 128px;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}

.forma-btn:hover {
  background: #dbeafe;
}

.forma-btn:active {
  background: var(--accent);
  color: #fff;
  transform: scale(0.95);
}

.forma-btn.clicked {
  background: #dcfce7;
  border-color: #16a34a;
  color: #166534;
}

.forma-btn-done {
  background: #dcfce7 !important;
  border-color: #16a34a !important;
  color: #166534 !important;
  opacity: 0.7;
  cursor: not-allowed;
}

.forma-btn-done:hover {
  background: #dcfce7 !important;
}

.btn-limpar {
  margin-top: 16px;
  width: 100%;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #f59e0b;
  font-size: 0.85rem;
}

.btn-limpar:hover {
  background: #fde68a;
}

.acmp-total {
  text-align: right;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 10px;
}

.acmp-setor-grupo {
  margin-bottom: 16px;
}

.acmp-setor-header {
  font-weight: 700;
  font-size: 0.92rem;
  background: #dbeafe;
  color: #1e3a8a;
  border: 1px solid #93c5fd;
  border-radius: 8px 8px 0 0;
  padding: 7px 10px;
}

.acmp-table {
  border-radius: 0 0 8px 8px;
  overflow: hidden;
}

.acmp-table th:nth-child(1),
.acmp-table td:nth-child(1) {
  width: 9%;
}

.acmp-table th:nth-child(2),
.acmp-table td:nth-child(2) {
  width: 14%;
}

.acmp-table th:nth-child(3),
.acmp-table td:nth-child(3) {
  width: 9%;
}

.acmp-table th:nth-child(4),
.acmp-table td:nth-child(4),
.acmp-table th:nth-child(5),
.acmp-table td:nth-child(5) {
  width: auto;
}

.acmp-input {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 3px 5px;
  font-size: 0.75rem;
  background: #fff;
}

.acmp-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.btn-acmp-salvar {
  background: #ecfdf5;
  border-color: #34d399;
  color: #065f46;
  font-weight: 700;
}

.btn-acmp-salvar:hover {
  background: #d1fae5;
}

.btn-acmp-imprimir {
  background: #eff6ff;
  border-color: #60a5fa;
  color: #1e3a8a;
  font-weight: 700;
}

.btn-acmp-imprimir:hover {
  background: #dbeafe;
}

@media print {
  body * {
    visibility: hidden;
  }
  #viewAcmpConcretagem,
  #viewAcmpConcretagem * {
    visibility: visible;
  }
  #viewAcmpConcretagem {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    border: none;
    box-shadow: none;
  }
  .acmp-actions,
  .section-title-row .btn-back,
  .btn-acmp-salvar,
  .btn-acmp-imprimir,
  #acmpFeedback,
  #acmpCarregar,
  .grid {
    display: none !important;
  }
  .acmp-input {
    border: none;
    background: transparent;
    padding: 0;
  }
}

.lib-feedback {
  padding: 10px 14px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 10px;
  text-align: center;
}

.lib-feedback.feedback-ok {
  background: #ecfdf5;
  border: 1px solid #34d399;
  color: #065f46;
}

.lib-feedback.feedback-error {
  background: #fef2f2;
  border: 1px solid #f87171;
  color: #991b1b;
}

.thumb {
  width: 100%;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.list {
  display: grid;
  gap: 8px;
}

.item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.item-main {
  min-width: 0;
}

.item-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 14px 0;
}

/* ================================================
   PRODUCAO / LIBERACAO — PREMIUM OPERATIONAL UI
   ================================================ */

.lib-global-panel {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
}

.lib-global-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.lib-global-fields label {
  margin-bottom: 0;
}

.lib-dual-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.lib-sector-block {
  border-radius: 14px;
  border: 2px solid #334155;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}

.lib-sector-1 {
  border-color: #1e40af;
}

.lib-sector-2 {
  border-color: #065f46;
}

.lib-sector-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  gap: 8px;
}

.lib-sector-1 .lib-sector-header {
  background: linear-gradient(90deg, #1e40af 0%, #1d4ed8 100%);
  color: #ffffff;
}

.lib-sector-2 .lib-sector-header {
  background: linear-gradient(90deg, #065f46 0%, #047857 100%);
  color: #ffffff;
}

.lib-sector-title {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.lib-sector-counter {
  font-size: 0.82rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
  transition: background 0.2s;
}

.lib-sector-counter.counter-done {
  background: rgba(255, 255, 255, 0.5);
  color: #fff;
}

.lib-sector-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 8px;
  background: #f8fafc;
}

.lib-forms-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* FORMA CARD */
.forma-card {
  position: relative;
  border: 2px solid #cbd5e1;
  border-radius: 10px;
  background: #ffffff;
  color: #1e293b;
  padding: 8px 4px;
  min-height: 54px;
  width: 100%;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: background 0.1s, border-color 0.1s, transform 0.07s, box-shadow 0.1s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  text-align: center;
  font-family: inherit;
  line-height: 1;
}

.forma-card:active:not(:disabled) {
  transform: scale(0.91);
}

.fc-number {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1.1;
}

.fc-status {
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
  min-height: 1em;
}

.forma-card.is-idle {
  border-color: #94a3b8;
  background: #f8fafc;
  color: #1e293b;
}

.forma-card.is-idle:hover:not(:disabled) {
  background: #dbeafe;
  border-color: #3b82f6;
  color: #1d4ed8;
  box-shadow: 0 2px 6px rgba(59,130,246,0.18);
}

.forma-card.is-saving {
  border-color: #818cf8;
  background: #eef2ff;
  color: #4338ca;
  cursor: wait;
  animation: forma-pulse 0.7s ease infinite;
}

.forma-card.is-saved {
  border-color: #16a34a;
  background: #dcfce7;
  color: #166534;
  cursor: default;
  opacity: 0.88;
}

.forma-card.is-error {
  border-color: #dc2626;
  background: #fef2f2;
  color: #991b1b;
  animation: forma-shake 0.3s ease;
}

@keyframes forma-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

@keyframes forma-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.lib-dummy-table { display: none; }

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

    .hub-item {
      min-height: 108px;
    }

  .container {
    padding: 10px;
  }

  .card {
    padding: 10px;
  }

  .sheet-topline {
    flex-direction: column;
    align-items: flex-start;
  }

  .item {
    flex-direction: column;
  }

  .sheet-grid-wrap {
    grid-template-columns: 1fr 1fr;
  }

  .forma-btn {
    grid-template-columns: 78px 112px;
    gap: 6px;
  }

  .forma-modelo {
    width: 112px;
  }

  .checklist {
    grid-template-columns: 1fr;
  }

  .dashboard-cards {
    grid-template-columns: 1fr;
  }

  .lib-dual-panel {
    grid-template-columns: 1fr;
  }

  .lib-global-fields {
    grid-template-columns: 1fr;
  }

  .lib-sector-cols {
    gap: 3px;
    padding: 6px;
  }

  .forma-card {
    min-height: 50px;
    padding: 6px 3px;
  }

  .fc-number {
    font-size: 0.88rem;
  }

  .forma-grid.forma-grid-blocos {
    gap: 6px;
  }

  .dash-row {
    grid-template-columns: 56px 1fr 34px;
    gap: 6px;
  }

  #viewInspecao .sheet-table {
    min-width: 640px;
    font-size: 0.82rem;
  }

  #viewInspecao .sheet-table th,
  #viewInspecao .sheet-table td {
    padding: 7px 6px;
  }

  #viewInspecao .sheet-table input[type="text"] {
    min-width: 120px;
  }
}
