:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --text: #e8eef5;
  --muted: #8b9cb3;
  --accent: #3d8bfd;
  --accent2: #22c55e;
  --danger: #ef4444;
  --radius: 10px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --sidebar-w: 270px;
  --header-h: 52px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* —— App shell: sidebar + conteúdo amplo —— */
.app-shell {
  display: flex;
  min-height: 100vh;
  background: linear-gradient(160deg, var(--bg) 0%, #151c28 45%, #0c1018 100%);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 90;
  backdrop-filter: blur(2px);
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--surface2);
  display: flex;
  flex-direction: column;
  z-index: 100;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
}

.sidebar-brand {
  padding: 1rem 1.25rem;
  font-weight: 800;
  font-size: 1.05rem;
  border-bottom: 1px solid var(--surface2);
}
.sidebar-brand a {
  color: var(--text);
  text-decoration: none;
}
.sidebar-brand a:hover {
  color: var(--accent);
  text-decoration: none;
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0;
  overflow-y: auto;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 1.25rem;
  color: var(--muted);
  font-size: 0.95rem;
  text-decoration: none;
  border-left: 3px solid transparent;
}
.sidebar-nav a:hover {
  color: var(--text);
  background: rgba(61, 139, 253, 0.08);
  text-decoration: none;
}
.sidebar-nav a.is-active {
  color: var(--text);
  background: rgba(61, 139, 253, 0.12);
  border-left-color: var(--accent);
}

.nav-ico {
  width: 1.25rem;
  text-align: center;
  opacity: 0.85;
  font-size: 0.9rem;
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.app-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: var(--header-h);
  padding: 0.5rem 1rem 0.5rem 0.75rem;
  background: rgba(26, 35, 50, 0.92);
  border-bottom: 1px solid var(--surface2);
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(8px);
}

.app-header-title {
  margin: 0;
  font-size: clamp(1.05rem, 2.5vw, 1.35rem);
  font-weight: 700;
  flex: 1;
  min-width: 0;
  line-height: 1.25;
}

.app-header-user {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
  padding-left: 0.5rem;
}

.app-header-user-link {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  max-width: min(46vw, 16rem);
  padding: 0.15rem 0.35rem 0.15rem 0.15rem;
  margin: -0.15rem;
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
}

.app-header-user-link:hover .app-header-user-name {
  color: var(--accent);
  text-decoration: underline;
}

.app-header-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--surface2);
}

.app-header-user-name {
  font-size: 0.88rem;
  color: var(--muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 480px) {
  .app-header-user-link {
    max-width: min(52vw, 12rem);
  }
}

.btn-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: var(--surface2);
  cursor: pointer;
  flex-shrink: 0;
}
.btn-hamburger-bar {
  display: block;
  width: 20px;
  height: 2px;
  margin: 0 auto;
  background: var(--text);
  border-radius: 1px;
}
.btn-hamburger:hover {
  background: var(--accent);
}

.main-wrap {
  flex: 1;
  width: 100%;
  max-width: 1800px;
  margin: 0 auto;
  padding: 1.5rem clamp(0.75rem, 2vw, 2rem) 2.75rem;
}

@media (max-width: 960px) {
  .btn-hamburger {
    display: flex;
  }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
  }
  body.sidebar-open .sidebar {
    transform: translateX(0);
  }
  body.sidebar-open .sidebar-overlay {
    display: block;
  }
}

@media (min-width: 961px) {
  .sidebar-overlay {
    display: none !important;
  }
  /* Menu lateral fixo: não rola com a página; só o miolo (.app-main) rola. */
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-w);
    height: 100vh;
    max-height: 100vh;
    overflow: hidden;
    transform: none !important;
  }
  .app-main {
    margin-left: var(--sidebar-w);
    width: calc(100% - var(--sidebar-w));
    max-width: none;
    min-width: 0;
  }
}

/* Perfil (perfil.php) */
.perfil-foto-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}

.perfil-foto-preview {
  width: 96px;
  height: 96px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid var(--surface2);
  flex-shrink: 0;
}

.perfil-foto-actions .perfil-hint {
  margin: 0.35rem 0 0;
  font-size: 0.82rem;
}

.perfil-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.perfil-subtitle {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  font-weight: 600;
}

.perfil-senha-block {
  padding-top: 0.75rem;
  border-top: 1px solid var(--surface2);
  margin-top: 0.35rem;
}

.perfil-remove-foto {
  display: block;
  margin-top: 0.65rem;
  font-size: 0.88rem;
  cursor: pointer;
}

/* Voltar ao topo (layout_bottom) */
.back-to-top {
  position: fixed;
  right: 1rem;
  bottom: 1.25rem;
  z-index: 55;
  width: 3rem;
  height: 3rem;
  padding: 0;
  border: 1px solid rgba(61, 139, 253, 0.45);
  border-radius: 50%;
  background: linear-gradient(165deg, rgba(61, 139, 253, 0.35) 0%, rgba(26, 35, 50, 0.95) 100%);
  color: #e8eef5;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
  align-items: center;
  justify-content: center;
  display: flex;
}

.back-to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top:hover {
  filter: brightness(1.12);
  border-color: var(--accent);
}

.back-to-top:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.back-to-top__inner {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

@media (max-width: 640px) {
  .back-to-top {
    right: 0.65rem;
    bottom: 1rem;
    width: 2.85rem;
    height: 2.85rem;
  }
}

.footer {
  text-align: center;
  padding: 1rem 1.25rem 1.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}

h1 {
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 700;
  margin: 0 0 1rem;
}

h2 {
  font-size: 1.2rem;
  margin: 1.5rem 0 0.75rem;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--surface2);
  padding: 1.35rem 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.35rem;
}

.card > h2:first-child,
.card > h3:first-child {
  margin-top: 0;
}

.card--hint {
  background: rgba(21, 28, 40, 0.55);
  border-style: dashed;
  border-color: rgba(139, 156, 179, 0.28);
}
.card--hint > p.muted:last-child {
  margin-bottom: 0;
}
.card--hint-lead {
  margin: 0;
  line-height: 1.55;
}

/* Painel / início: introdução leve acima dos cards */
.page-intro {
  margin-bottom: 1.25rem;
  max-width: 52rem;
}
.page-intro__lead {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.5;
  color: var(--muted);
}

/* Cards de totais no painel (index): link, hierarquia rótulo → valor → ajuda → CTA */
.grid-cards.grid-cards--stats .stat-card {
  margin-bottom: 0;
}

.stat-card {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  min-height: 7.5rem;
  padding: 1.1rem 1.25rem 1.05rem 1.35rem;
  border-left: 3px solid var(--accent);
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

a.stat-card {
  color: inherit;
  text-decoration: none;
}

a.stat-card:hover {
  text-decoration: none;
}

a.stat-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(145deg, rgba(61, 139, 253, 0.07) 0%, transparent 52%);
  pointer-events: none;
}

.stat-card:hover {
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  transform: translateY(-2px);
}

.stat-card--clients {
  border-left-color: #94a3b8;
}
.stat-card--clients::before {
  background: linear-gradient(145deg, rgba(148, 163, 184, 0.12) 0%, transparent 52%);
}
.stat-card--clients:hover {
  border-left-color: #cbd5e1;
}

.stat-card--orc {
  border-left-color: var(--accent);
}
.stat-card--orc:hover {
  border-left-color: #60a5fa;
}

.stat-card--os {
  border-left-color: var(--accent2);
}
.stat-card--os::before {
  background: linear-gradient(145deg, rgba(34, 197, 94, 0.1) 0%, transparent 52%);
}
.stat-card--os:hover {
  border-left-color: #4ade80;
}

.stat-card--fat {
  border-left-color: #a855f7;
}
.stat-card--fat::before {
  background: linear-gradient(145deg, rgba(168, 85, 247, 0.1) 0%, transparent 52%);
}
.stat-card--fat:hover {
  border-left-color: #c084fc;
}

.stat-card__label {
  position: relative;
  z-index: 1;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1.25;
  max-width: 100%;
}

.stat-card__value {
  position: relative;
  z-index: 1;
  margin-top: 0.45rem;
  font-size: clamp(1.85rem, 4.2vw, 2.4rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.stat-card__sub {
  position: relative;
  z-index: 1;
  margin-top: 0.45rem;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--muted);
  flex: 1 1 auto;
  max-width: 100%;
}

.stat-card__cta {
  position: relative;
  z-index: 1;
  margin-top: 0.75rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
}

a.stat-card:hover .stat-card__cta {
  color: var(--accent2);
  text-decoration: underline;
}

/* Visualização de documento: hero + resumo */
.page-hero {
  padding-top: 1.5rem;
  padding-bottom: 1.4rem;
  border: 1px solid var(--surface2);
  box-shadow: var(--shadow), 0 0 0 1px rgba(61, 139, 253, 0.06);
  background: linear-gradient(180deg, rgba(61, 139, 253, 0.05) 0%, var(--surface) 42%);
}
.page-hero__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem 1.25rem;
  padding-bottom: 1.1rem;
  margin-bottom: 1.1rem;
  border-bottom: 1px solid var(--surface2);
}
.page-hero__identity {
  min-width: min(100%, 220px);
}
.doc-kicker {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.page-hero__title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 0.85rem;
}
.doc-title {
  margin: 0;
  font-size: clamp(1.2rem, 2.8vw, 1.65rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--text);
}
.status-pill {
  display: inline-block;
  padding: 0.28rem 0.75rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: capitalize;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid rgba(139, 156, 179, 0.35);
}
.status-pill--ok {
  background: rgba(34, 197, 94, 0.14);
  border-color: rgba(34, 197, 94, 0.45);
  color: #15803d;
}
.status-pill--muted {
  opacity: 0.75;
  text-transform: none;
}

/* Contas a pagar — vencimento pendente passado */
.cp-row-overdue {
  background: rgba(234, 179, 8, 0.08);
}

/* Assinatura do cliente (orçamento / OS) */
.assinatura-canvas {
  display: block;
  width: 100%;
  max-width: 640px;
  height: auto;
  min-height: 120px;
  border: 1px dashed rgba(139, 156, 179, 0.65);
  border-radius: 10px;
  cursor: crosshair;
  touch-action: none;
  background: #fff;
}
.assinatura-preview-card {
  margin-bottom: 1rem;
}
.assinatura-preview-title {
  margin-top: 0;
  font-size: 1.05rem;
}
.assinatura-preview-wrap {
  margin-top: 0.5rem;
}
.assinatura-preview-img {
  max-width: 100%;
  max-height: 140px;
  object-fit: contain;
  border: 1px solid rgba(139, 156, 179, 0.35);
  border-radius: 8px;
  background: #fafbfc;
}
.assinatura-preview-meta {
  margin: 0.5rem 0 0;
  font-size: 0.88rem;
}
.page-hero__actions.actions {
  justify-content: flex-end;
}
.page-hero__body {
  margin: 0;
}
.page-hero__body .form-grid {
  margin-top: 0;
}
.ver-field-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.ver-field-val {
  font-size: 0.98rem;
  line-height: 1.4;
  word-break: break-word;
}
.page-hero__footnote {
  margin: 1.1rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid var(--surface2);
  font-size: 0.86rem;
  line-height: 1.45;
}
.page-hero__flash {
  margin: 0 0 1rem;
}
.page-hero + .flash {
  margin-top: -0.35rem;
}

.card-inset {
  margin-top: 1.25rem;
  padding: 1rem 1.1rem;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--surface2);
}

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}
.grid-cards.grid-cards--stats {
  gap: 1.15rem;
}

@media (min-width: 960px) {
  .grid-cards.grid-cards--stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* Painel (index): gráficos */
.dashboard-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: 1.25rem;
  margin-top: 1.25rem;
}

.chart-card h2 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
}

.chart-card-hint {
  margin: 0 0 0.75rem;
  font-size: 0.82rem;
  line-height: 1.35;
}

.chart-card--wide {
  grid-column: 1 / -1;
}

@media (min-width: 1100px) {
  .dashboard-charts {
    grid-template-columns: 1fr 1fr;
  }
  .chart-card--wide {
    grid-column: 1 / -1;
  }
}

.chart-canvas-wrap {
  position: relative;
  height: 260px;
  width: 100%;
}

.chart-canvas-wrap--donut {
  max-width: 320px;
  margin: 0 auto;
  height: 280px;
}

.chart-canvas-wrap--tall {
  height: min(420px, 70vh);
}

.chart-canvas-wrap canvas {
  max-height: 100%;
}

/* —— Drive (pastas / arquivos / compartilhar) —— */
.drive-toolbar {
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.drive-toolbar__nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.drive-toolbar__nav .btn.is-active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(61, 139, 253, 0.12);
}

.drive-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.25rem;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.92rem;
}

.drive-breadcrumb a {
  color: var(--accent);
  text-decoration: none;
}

.drive-breadcrumb a:hover {
  text-decoration: underline;
}

.drive-breadcrumb__sep {
  color: var(--muted);
  user-select: none;
}

.drive-breadcrumb__current {
  font-weight: 700;
  color: var(--text);
}

.drive-panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.drive-panel {
  margin-bottom: 0;
}

.drive-section-title {
  margin: 0 0 0.75rem;
  font-size: 1.02rem;
  font-weight: 700;
}

.drive-section-title--spaced {
  margin-top: 1.25rem;
}

.drive-subtitle {
  margin: 1rem 0 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
}

.drive-hint {
  margin: 0.5rem 0 0;
  font-size: 0.82rem;
  line-height: 1.45;
}

.drive-inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.drive-inline-form input[type="text"] {
  flex: 1 1 160px;
  min-width: 0;
  max-width: 100%;
}

.drive-upload-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.drive-upload-form input[type="file"] {
  flex: 1 1 200px;
  min-width: 0;
  font-size: 0.88rem;
}

.drive-share-form .form-grid {
  margin-bottom: 0;
}

.drive-share-form__row {
  grid-template-columns: 1fr 1fr auto;
  align-items: end;
  gap: 0.75rem;
}

@media (max-width: 640px) {
  .drive-share-form__row {
    grid-template-columns: 1fr;
  }
}

.drive-share-form--nested {
  margin-top: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.drive-share-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.drive-share-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--surface2);
  font-size: 0.9rem;
}

.drive-file-share {
  margin-top: 0.35rem;
}

.drive-file-share summary {
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--accent);
  font-weight: 600;
}

.drive-file-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.drive-file-share--linkonly {
  margin-top: 0;
  display: inline-block;
}

.drive-file-share__summary.btn {
  list-style: none;
}

.drive-file-share__summary.btn::-webkit-details-marker {
  display: none;
}

.drive-file-share__panel {
  margin-top: 0.5rem;
  padding: 0.65rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: 8px;
  min-width: min(100%, 22rem);
}

.drive-share-list--compact li:last-child {
  border-bottom: none;
}

.drive-pub-link-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
}

.drive-pub-link-input {
  flex: 1 1 140px;
  min-width: 0;
  font-size: 0.78rem;
  padding: 0.35rem 0.5rem;
}

.drive-rename-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  margin-bottom: 0.35rem;
}

.drive-rename-row input[type="text"] {
  flex: 1 1 120px;
  min-width: 0;
  max-width: 14rem;
  padding: 0.4rem 0.55rem;
  font-size: 0.88rem;
}

.drive-table-card {
  margin-bottom: 1.5rem;
}

.public-page {
  background: linear-gradient(160deg, var(--bg) 0%, #151c28 45%, #0c1018 100%);
}

.public-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.public-main {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem clamp(0.75rem, 2vw, 2rem) 2.25rem;
}

.public-footer {
  border-top: 1px solid rgba(139, 156, 179, 0.18);
}

.public-hero {
  margin-bottom: 1rem;
}

.public-title {
  margin: 0 0 0.35rem;
  font-size: clamp(1.4rem, 3.2vw, 2rem);
}

.public-subtitle {
  margin: 0 0 0.75rem;
}

.public-breadcrumb {
  margin-bottom: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
  border: 1px solid var(--surface2);
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

table.data th,
table.data td {
  padding: 0.65rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--surface2);
  vertical-align: top;
}

table.data th {
  background: var(--surface2);
  color: var(--muted);
  font-weight: 600;
}

table.data tr:hover td {
  background: rgba(61, 139, 253, 0.06);
}

@media (max-width: 640px) {
  table.data.data-mobile-labels thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
  }
  table.data.data-mobile-labels tr {
    display: block;
    border-bottom: 1px solid var(--surface2);
    padding: 0.65rem 0;
  }
  table.data.data-mobile-labels td {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.4rem 0.85rem;
    border: none;
    text-align: right;
  }
  table.data.data-mobile-labels td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.8rem;
    text-align: left;
    flex-shrink: 0;
  }
  table.data.data-mobile-labels td.actions,
  table.data.data-mobile-labels td:last-child:has(button) {
    justify-content: flex-end;
    padding-top: 0.75rem;
  }
  table.data.data-mobile-labels td.actions::before,
  table.data.data-mobile-labels td:last-child:has(button)::before {
    content: none;
  }
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  color: #fff;
  background: var(--accent);
}
.btn:hover {
  filter: brightness(1.08);
  text-decoration: none;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--surface2);
  color: var(--text);
}

.btn-success {
  background: var(--accent2);
}

.pdf-toolbar-group {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.btn-share-mobile {
  background: var(--accent2);
  color: #0f172a;
}

.btn-share-mobile:hover:not(:disabled) {
  filter: brightness(1.06);
}

.btn-share-mobile:disabled {
  opacity: 0.65;
  cursor: wait;
}

@media (max-width: 640px) {
  .pdf-toolbar-group {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    max-width: 22rem;
  }

  .pdf-toolbar-group .btn-share-mobile {
    order: -1;
    min-height: 48px;
    font-size: 1rem;
  }
}

.btn-danger {
  background: var(--danger);
}

/* Materiais — coluna de ações: botões sempre lado a lado */
table.data th.mat-col-acoes,
table.data td.mat-row-actions {
  width: 1%;
  min-width: 11.5rem;
  white-space: nowrap;
  vertical-align: middle;
  text-align: right;
}

.mat-row-actions {
  display: inline-flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
}

.mat-row-actions .btn {
  flex: 0 0 auto;
}

@media (max-width: 640px) {
  table.data.data-mobile-labels td.mat-row-actions {
    flex-wrap: nowrap;
    justify-content: flex-end;
    gap: 0.5rem;
    align-items: center;
  }
}

/* Materiais — botões da tabela (Editar / Dar baixa) */

.btn-mat-edit {
  background: linear-gradient(165deg, rgba(61, 139, 253, 0.22) 0%, rgba(61, 139, 253, 0.06) 100%);
  border: 1px solid rgba(61, 139, 253, 0.55);
  color: #93c5fd;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease, filter 0.14s ease;
}

.btn-mat-edit:hover {
  filter: brightness(1.1);
  border-color: var(--accent);
  color: #bfdbfe;
  transform: translateY(-1px);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08) inset, 0 4px 14px rgba(61, 139, 253, 0.25);
}

.btn-mat-edit:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-mat-baixa {
  background: linear-gradient(165deg, rgba(245, 158, 11, 0.28) 0%, rgba(217, 119, 6, 0.1) 100%);
  border: 1px solid rgba(251, 191, 36, 0.45);
  color: #fde68a;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset, 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease, filter 0.14s ease;
}

.btn-mat-baixa:hover {
  filter: brightness(1.12);
  border-color: #fbbf24;
  color: #fffbeb;
  transform: translateY(-1px);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 4px 14px rgba(245, 158, 11, 0.3);
}

.btn-mat-baixa:focus-visible {
  outline: 2px solid #fbbf24;
  outline-offset: 2px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.form-grid-modal {
  grid-template-columns: 1fr;
}
@media (min-width: 520px) {
  .form-grid-modal {
    grid-template-columns: repeat(2, 1fr);
  }
}

.form-grid-full {
  grid-column: 1 / -1;
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

/* Campos de escrita: fundo, borda, foco e placeholder coerentes com o tema escuro */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="tel"],
input[type="url"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 0.62rem 0.85rem;
  border-radius: 10px;
  border: 1px solid rgba(139, 156, 179, 0.28);
  background: linear-gradient(180deg, rgba(15, 20, 25, 0.92) 0%, rgba(12, 16, 22, 0.98) 100%);
  background-color: var(--bg);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  line-height: 1.45;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  -webkit-appearance: none;
  appearance: none;
}

input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration,
input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

input[type="text"]::placeholder,
input[type="email"]::placeholder,
input[type="password"]::placeholder,
input[type="search"]::placeholder,
input[type="tel"]::placeholder,
input[type="url"]::placeholder,
input[type="number"]::placeholder,
textarea::placeholder {
  color: rgba(139, 156, 179, 0.72);
  opacity: 1;
}

input[type="text"]:hover,
input[type="email"]:hover,
input[type="password"]:hover,
input[type="search"]:hover,
input[type="tel"]:hover,
input[type="url"]:hover,
input[type="number"]:hover,
input[type="date"]:hover,
select:hover,
textarea:hover {
  border-color: rgba(61, 139, 253, 0.35);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
input[type="tel"]:focus,
input[type="url"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(61, 139, 253, 0.75);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 0 0 3px rgba(61, 139, 253, 0.22);
}

input[type="text"]:focus-visible,
input[type="email"]:focus-visible,
input[type="password"]:focus-visible,
input[type="search"]:focus-visible,
input[type="tel"]:focus-visible,
input[type="url"]:focus-visible,
input[type="number"]:focus-visible,
input[type="date"]:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: rgba(61, 139, 253, 0.85);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 0 0 3px rgba(61, 139, 253, 0.28);
}

input[type="text"]:disabled,
input[type="email"]:disabled,
input[type="password"]:disabled,
input[type="search"]:disabled,
input[type="number"]:disabled,
input[type="date"]:disabled,
select:disabled,
textarea:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

select {
  cursor: pointer;
  padding-right: 2.35rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' viewBox='0 0 14 14'%3E%3Cpath stroke='%238b9cb3' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m3.5 5.25 3.5 3.5 3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  background-size: 14px 14px;
}

select option {
  background: var(--surface);
  color: var(--text);
}

textarea {
  min-height: 88px;
  resize: vertical;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.toolbar-end {
  justify-content: flex-end;
}

.list-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem 0.75rem;
  flex: 1 1 auto;
  min-width: min(100%, 200px);
}

.list-filters .list-filters__q {
  flex: 1 1 140px;
  max-width: 22rem;
  min-width: 0;
  min-height: 2.65rem;
  padding-left: 2.45rem;
  background-color: var(--bg);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' viewBox='0 0 18 18'%3E%3Cpath stroke='%238b9cb3' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.35' d='M8.25 14.25a6 6 0 1 0 0-12 6 6 0 0 0 0 12Zm0 0 4.5 4.5'/%3E%3C/svg%3E"),
    linear-gradient(180deg, rgba(15, 20, 25, 0.92) 0%, rgba(12, 16, 22, 0.98) 100%);
  background-repeat: no-repeat, no-repeat;
  background-position: left 0.75rem center, center;
  background-size: 18px 18px, 100% 100%;
}

.list-filters .list-filters__status {
  width: auto;
  min-width: 10.5rem;
  max-width: 100%;
}

.list-filters .btn[type="submit"],
.list-filters .btn.btn-ghost {
  flex-shrink: 0;
}

.flash {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  background: var(--surface2);
  border: 1px solid var(--accent);
}

.flash-error {
  border-color: var(--danger);
  color: #fecaca;
}

.flash-success {
  border-color: var(--accent2);
  color: #bbf7d0;
}

.config-logo-preview {
  max-height: 80px;
  max-width: 220px;
  object-fit: contain;
  border-radius: 6px;
  border: 1px solid var(--surface2);
  background: var(--surface);
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  cursor: pointer;
}

/* —— Login (desktop + mobile “app-like”) —— */
html.login-html,
html.login-html body.login-page {
  height: 100%;
}

html.login-html {
  -webkit-tap-highlight-color: transparent;
}

.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background-color: #0a0e14;
  /* fundo.png na raiz do projeto (mesmo nível que login.php); caminho relativo ao CSS */
  background-image:
    linear-gradient(
      160deg,
      rgba(6, 10, 16, 0.88) 0%,
      rgba(8, 12, 20, 0.62) 42%,
      rgba(6, 10, 16, 0.9) 100%
    ),
    url('../fundo.png');
  background-size: cover, cover;
  background-position: center, center;
  background-repeat: no-repeat;
  background-attachment: scroll;
}

/* Pré-load pós-login — login_splash.php (logo ~5s) */
.login-splash-page {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background-color: #0a0e14;
  background-image:
    linear-gradient(
      160deg,
      rgba(6, 10, 16, 0.92) 0%,
      rgba(8, 12, 20, 0.72) 45%,
      rgba(6, 10, 16, 0.96) 100%
    ),
    url('../fundo.png');
  background-size: cover, cover;
  background-position: center, center;
  background-repeat: no-repeat;
}

.login-splash-inner {
  text-align: center;
  max-width: 28rem;
  animation: login-splash-in 0.55s ease-out;
}

@keyframes login-splash-in {
  from {
    opacity: 0;
    transform: scale(0.94) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.login-splash-logo {
  width: 7.5rem;
  height: 7.5rem;
  margin: 0 auto 1.25rem;
  border-radius: 1.35rem;
  background: linear-gradient(145deg, var(--accent) 0%, #2563eb 100%);
  color: #fff;
  font-weight: 800;
  font-size: 2rem;
  letter-spacing: -0.03em;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 16px 48px rgba(61, 139, 253, 0.35);
  overflow: hidden;
  flex-shrink: 0;
  animation: login-splash-pulse 2.4s ease-in-out infinite;
}

@keyframes login-splash-pulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 16px 48px rgba(61, 139, 253, 0.35);
  }
  50% {
    transform: scale(1.04);
    box-shadow: 0 20px 56px rgba(61, 139, 253, 0.45);
  }
}

.login-splash-logo--image {
  background: var(--surface);
  font-size: 0;
  padding: 0.45rem;
  border: 1px solid var(--surface2);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.login-splash-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 0.85rem;
  display: block;
}

.login-splash-logo-text {
  line-height: 1;
}

.login-splash-name {
  margin: 0;
  font-size: clamp(1.15rem, 3.5vw, 1.45rem);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.login-splash-hint {
  margin: 1rem 0 0;
  font-size: 0.88rem;
  letter-spacing: 0.04em;
}

.login-native-shell {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
}

.login-native-brand {
  text-align: center;
  padding: 0 0 0.5rem;
}

.login-native-logo {
  width: 4.25rem;
  height: 4.25rem;
  margin: 0 auto 0.5rem;
  border-radius: 1.125rem;
  background: linear-gradient(145deg, var(--accent) 0%, #2563eb 100%);
  color: #fff;
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 32px rgba(61, 139, 253, 0.28);
  overflow: hidden;
  flex-shrink: 0;
}

.login-native-logo--image {
  background: var(--surface);
  color: inherit;
  font-size: 0;
  padding: 0.3rem;
  border: 1px solid var(--surface2);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.32);
}

.login-native-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 0.65rem;
  display: block;
}

.login-native-logo-text {
  line-height: 1;
}

.login-native-name {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.55), 0 0 1px rgba(0, 0, 0, 0.8);
}

.login-native-tagline {
  margin: 0.2rem 0 0;
  font-size: 0.88rem;
  color: var(--muted);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2rem;
  border: 1px solid var(--surface2);
  box-shadow: var(--shadow);
}

.login-card-title {
  margin: 0 0 1.25rem;
  text-align: center;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.login-native-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-field label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.45rem;
}

.login-native-form input[type="email"],
.login-native-form input[type="password"] {
  min-height: 3.25rem;
  padding: 0.65rem 1rem;
  font-size: 1rem;
  border-radius: 12px;
  border: 1px solid var(--surface2);
  background: var(--bg);
  -webkit-appearance: none;
  appearance: none;
}

.login-native-submit {
  width: 100%;
  margin-top: 0.25rem;
  min-height: 3.25rem;
  border-radius: 12px;
  font-size: 1.02rem;
  font-weight: 700;
  touch-action: manipulation;
}

.login-native-flash {
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

@media (max-width: 640px) {
  .login-page {
    min-height: 100vh;
    min-height: 100dvh;
    align-items: stretch;
    justify-content: flex-start;
    padding: max(0.75rem, env(safe-area-inset-top)) max(1.25rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1.25rem, env(safe-area-inset-left));
  }

  .login-native-shell {
    max-width: none;
    width: 100%;
    margin: 0 auto;
    padding: 0;
    justify-content: flex-start;
    gap: 0.35rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .login-native-brand {
    padding: 0.35rem 0 0.15rem;
    flex-shrink: 0;
  }

  .login-native-logo {
    width: 4.25rem;
    height: 4.25rem;
    font-size: 1.35rem;
    border-radius: 1.125rem;
  }

  .login-native-name {
    font-size: 1.35rem;
  }

  .login-card {
    max-width: none;
    margin-top: 0;
    border-radius: 1.25rem;
    padding: 1.35rem 1.25rem 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--surface2);
  }

  .login-card-title {
    font-size: 1.15rem;
    margin-bottom: 1rem;
  }

  .login-native-form input[type="email"],
  .login-native-form input[type="password"] {
    min-height: 3.35rem;
    font-size: 16px;
    border-radius: 14px;
  }

  .login-native-submit {
    min-height: 3.35rem;
    border-radius: 14px;
    font-size: 1.05rem;
  }
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.right {
  text-align: right;
}

/* —— Modais —— */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal.is-open {
  opacity: 1;
  visibility: visible;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.modal-dialog {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  margin: auto auto 0;
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  border: 1px solid var(--surface2);
  border-bottom: none;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  transform: translateY(12px);
  transition: transform 0.2s ease;
}

.modal.is-open .modal-dialog {
  transform: translateY(0);
}

@media (min-width: 540px) {
  .modal {
    align-items: center;
    padding: 1rem;
  }
  .modal-dialog {
    margin: 0 auto;
    border-radius: var(--radius);
    border: 1px solid var(--surface2);
    max-height: min(88vh, 720px);
  }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1rem 0.5rem 1.25rem;
  border-bottom: 1px solid var(--surface2);
  flex-shrink: 0;
}

.modal-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-close {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.modal-close:hover {
  color: var(--text);
  background: var(--surface2);
}

.modal-body {
  overflow-y: auto;
  padding: 1rem 1.25rem;
  flex: 1;
  min-height: 0;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
  padding-top: 1rem;
  margin-top: 0.5rem;
  border-top: 1px solid var(--surface2);
}

.modal-actions-center {
  justify-content: center;
  border-top: none;
  padding-top: 0;
  margin-top: 1rem;
}

.modal-actions-split {
  justify-content: flex-start;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.modal-actions-split .modal-actions-spacer {
  flex: 1 1 auto;
  min-width: 0.5rem;
}

.form-actions-row {
  margin-top: 0.5rem;
}

/* Formulários só com campos hidden (excluir linha) — fora do fluxo visual */
.form-del-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Pop-up de alerta do sistema (alert_redirect) */
.alert-popup {
  z-index: 250;
}

.modal-dialog-alert {
  max-width: 420px;
  text-align: center;
}

.modal-head-alert {
  justify-content: center;
  border-bottom-color: var(--surface2);
  padding-bottom: 0.35rem;
}

.modal-body-alert {
  padding-top: 0.5rem;
}

.alert-popup-message {
  margin: 0;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
}
