:root {
  --obra-primary: #f59e0b;
  --obra-primary-dark: #b45309;
  --obra-dark: #1f2937;
  --obra-soft: #fff7ed;
  --obra-line: #e5e7eb;
}

html {
  font-size: 15px;
  min-height: 100%;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

body {
  min-height: 100vh;
  background: #f8fafc;
  color: #111827;
  display: flex;
  flex-direction: column;
}

.app-navbar {
  background: linear-gradient(90deg, #111827, #374151);
  box-shadow: 0 8px 24px rgba(17, 24, 39, 0.14);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin-right: .45rem;
  border-radius: 8px;
  background: var(--obra-primary);
  color: #111827;
  font-weight: 800;
}

.app-container {
  padding-top: 1rem;
}

.page-heading {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.hero-panel {
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, #111827, #374151);
  color: #fff;
  overflow: hidden;
}

.stat-card,
.content-card {
  border: 1px solid var(--obra-line);
  border-radius: 10px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, .05);
}

.stat-card-primary {
  border-color: #f59e0b;
  background: #fffbeb;
}

.stat-card-primary .stat-label {
  color: #92400e;
  font-weight: 700;
}

.money-value.is-hidden {
  letter-spacing: .08em;
}

.privacy-icon {
  display: inline-block;
  width: 1.25rem;
  text-align: center;
}

.privacy-toggle {
  white-space: nowrap;
}

.stat-card .card-body {
  min-height: 108px;
}

.stat-label {
  color: #6b7280;
  font-size: .9rem;
}

.mobile-card-list {
  display: grid;
  gap: .75rem;
}

.mobile-list-card {
  border: 1px solid var(--obra-line);
  border-radius: 10px;
  background: #fff;
  padding: 1rem;
  box-shadow: 0 8px 20px rgba(15, 23, 42, .04);
}

.form-control,
.form-select,
.btn {
  min-height: 44px;
  border-radius: 8px;
}

.btn-primary {
  background: var(--obra-primary-dark);
  border-color: var(--obra-primary-dark);
}

.btn-primary:hover {
  background: #92400e;
  border-color: #92400e;
}

.btn-success {
  background: #15803d;
  border-color: #15803d;
}

.area-preview {
  border: 1px dashed #f59e0b;
  border-radius: 10px;
  background: var(--obra-soft);
  padding: .75rem;
}

.table-card {
  border: 1px solid var(--obra-line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}

.footer {
  background: #fff;
  margin-top: auto;
  padding: 1rem 0;
}

.status-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.status-actions .btn {
  min-height: 38px;
}

.status-badge {
  border: 1px solid transparent;
}

.status-em-andamento {
  background: #dbeafe;
  color: #1d4ed8;
  border-color: #93c5fd;
}

.status-parado {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fca5a5;
}

.status-finalizado {
  background: #dcfce7;
  color: #15803d;
  border-color: #86efac;
}

.status-aberto {
  background: #fef3c7;
  color: #92400e;
  border-color: #fcd34d;
}

@media (max-width: 767.98px) {
  .app-container {
    padding-left: .9rem;
    padding-right: .9rem;
  }

  .page-heading .btn,
  .action-stack .btn {
    width: 100%;
  }

  .table-responsive {
    display: none;
  }

  .desktop-only {
    display: none !important;
  }
}

@media (min-width: 768px) {
  .mobile-only {
    display: none !important;
  }
}


.btn, .content-card, .stat-card, .mobile-list-card, .service-option {
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease, background-color .15s ease;
}

.btn:active {
  transform: translateY(1px) scale(.99);
}

.content-card:hover, .stat-card:hover, .mobile-list-card:hover {
  box-shadow: 0 14px 32px rgba(15, 23, 42, .08);
}

.service-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: .75rem;
}

.service-option {
  display: flex;
  align-items: center;
  gap: .7rem;
  min-height: 72px;
  padding: .85rem;
  border: 1px solid var(--obra-line);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  user-select: none;
}

.service-option:hover {
  border-color: #f59e0b;
  transform: translateY(-1px);
}

.service-option:has(input:checked) {
  border-color: #f59e0b;
  background: #fffbeb;
  box-shadow: 0 10px 24px rgba(245, 158, 11, .16);
}

.service-option input {
  width: 20px;
  height: 20px;
  accent-color: var(--obra-primary-dark);
}

.service-option strong, .service-option small {
  display: block;
}

.service-option small {
  color: #6b7280;
}

.form-action-bar {
  position: sticky;
  bottom: 0;
  z-index: 1020;
  background: rgba(255, 255, 255, .96);
  border-top: 1px solid var(--obra-line);
  backdrop-filter: blur(8px);
}

.service-badge {
  white-space: normal;
  text-align: left;
}

@media (max-width: 767.98px) {
  .hero-panel {
    border-radius: 0 0 16px 16px;
    margin-left: -.9rem;
    margin-right: -.9rem;
  }

  .stat-card .card-body {
    min-height: 96px;
  }

  .footer {
    position: static;
    font-size: .9rem;
  }

  main {
    padding-bottom: 1rem;
  }
}

/* Força o rodapé a nunca ficar fixo/absoluto no meio da tela, inclusive no CSS isolado do Razor. */
html, body {
  min-height: 100%;
}

body.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body.app-shell > .app-container {
  flex: 1 0 auto;
}

body.app-shell > footer.footer,
.footer {
  position: static !important;
  bottom: auto !important;
  width: 100%;
  line-height: 1.4 !important;
  white-space: normal !important;
  flex-shrink: 0;
  z-index: 1;
}

.icon-actions {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: .5rem;
}

.action-flow-card {
  border-color: #fbbf24;
  background: #fffbeb;
}

.material-flow-card {
  border-color: #bfdbfe;
}

.material-estimate-card {
  border-color: #bfdbfe;
}

.material-toolbar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .5rem;
}

.material-estimate-list {
  display: grid;
  gap: .75rem;
}

.material-estimate-row {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(360px, 1fr);
  gap: .85rem;
  align-items: stretch;
  padding: .85rem;
  border: 1px solid var(--obra-line);
  border-radius: 8px;
  background: #fff;
}

.material-estimate-row.is-new-material {
  border-color: #93c5fd;
  background: #f8fbff;
}

.material-estimate-row small {
  display: block;
  color: #6b7280;
}

.material-main-fields,
.material-number-fields {
  min-width: 0;
}

.material-main-fields {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.material-number-fields {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(120px, .85fr) minmax(92px, auto) auto;
  gap: .5rem;
  align-items: center;
}

.material-card-label {
  color: #4b5563;
  font-size: .8rem;
  font-weight: 700;
  margin-bottom: .25rem;
}

.material-card-topline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem;
  margin-bottom: .25rem;
}

.material-card-topline .material-card-label {
  margin-bottom: 0;
}

.material-new-badge,
.material-service-badge {
  border-radius: 999px;
  padding: .12rem .45rem;
  font-size: .72rem;
  font-weight: 700;
}

.material-new-badge {
  background: #dbeafe;
  color: #1d4ed8;
}

.material-service-badge {
  background: #fef3c7;
  color: #92400e;
}

.material-quantity-control {
  display: grid;
  grid-template-columns: 42px minmax(74px, 1fr) 42px;
  gap: .35rem;
}

.material-quantity-control .btn {
  min-width: 40px;
  min-height: 44px;
}

.material-line-total {
  min-height: 44px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-end;
  padding: .35rem 0;
}

.material-line-total small {
  color: #6b7280;
  font-size: .78rem;
}

.material-remove {
  align-self: center;
  min-height: 44px;
  white-space: nowrap;
}

.material-table-actions,
.material-detail-actions {
  display: flex;
  align-items: center;
  gap: .4rem;
}

.material-table-actions .btn {
  min-width: 38px;
  min-height: 36px;
}

.material-table-actions {
  justify-content: end;
}

.material-detail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1.6fr;
}

.toast-feedback {
  border: 0;
  box-shadow: 0 12px 30px rgba(21, 128, 61, .14);
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .48);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  backdrop-filter: blur(2px);
}

.loading-overlay.is-visible {
  display: flex;
}

.loading-card {
  background: #fff;
  border-radius: 14px;
  padding: 1.1rem 1.25rem;
  min-width: 230px;
  box-shadow: 0 20px 50px rgba(0,0,0,.18);
  text-align: center;
  font-weight: 700;
}

.loading-spinner {
  width: 34px;
  height: 34px;
  border: 4px solid #e5e7eb;
  border-top-color: var(--obra-primary-dark);
  border-radius: 50%;
  margin: 0 auto .75rem;
  animation: spin .75s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.auth-page {
  min-height: calc(100vh - 190px);
  display: grid;
  place-items: center;
  padding: 1.5rem 0;
}

.auth-card {
  width: min(100%, 430px);
  border: 1px solid var(--obra-line);
  border-radius: 10px;
  background: #fff;
  padding: 1.25rem;
  box-shadow: 0 14px 34px rgba(15, 23, 42, .08);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--obra-line);
}

.auth-brand-mark {
  width: 48px;
  height: 48px;
  margin-right: 0;
  font-size: 1.15rem;
}

.auth-brand-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: #111827;
  line-height: 1.1;
}

.auth-brand-subtitle {
  color: #6b7280;
  font-size: .9rem;
}

.auth-links {
  display: flex;
  justify-content: center;
  gap: .4rem;
  margin-top: 1rem;
}

.support-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: 1rem;
  padding: .75rem 1rem;
  border: 1px solid #fbbf24;
  border-radius: 8px;
  background: #fffbeb;
  color: #78350f;
  font-weight: 700;
}

.logout-button {
  min-height: 34px;
}

@media (max-width: 767.98px) {
  body.app-shell {
    overflow-x: hidden;
  }

  .app-container {
    padding-bottom: 1rem;
  }

  .form-action-bar {
    position: sticky;
    bottom: 0;
    margin-left: -.9rem;
    margin-right: -.9rem;
    padding-left: .9rem;
    padding-right: .9rem;
  }

  .icon-actions {
    grid-template-columns: 1fr 1fr;
  }

  .icon-actions > :last-child {
    grid-column: span 2;
  }

  .action-flow-card .btn,
  .material-flow-card .btn {
    min-height: 48px;
  }

  .material-toolbar {
    grid-template-columns: 1fr;
  }

  .material-estimate-row {
    grid-template-columns: 1fr;
    padding: .8rem;
  }

  .material-number-fields {
    grid-template-columns: 1fr;
    gap: .75rem;
  }

  .material-line-total {
    align-items: stretch;
    border: 1px solid var(--obra-line);
    border-radius: 8px;
    padding: .65rem .75rem;
    background: #f8fafc;
  }

  .material-line-total strong {
    font-size: 1.05rem;
  }

  .material-remove {
    width: 100%;
  }
}
