/* ====================================================================
   TOKENS
   Paleta "blueprint": azul de prancha técnica + acentos ciano.
   Referência: pranchas de engenharia/obra, carimbos de aprovação.
==================================================================== */
:root {
  --blueprint-900: #0a2540;
  --blueprint-800: #0f3157;
  --blueprint-700: #14406e;
  --blue-600: #1f5c99;
  --blue-500: #2d74bf;
  --blue-400: #4a90d9;
  --cyan-300: #6fe3e0;
  --cyan-200: #a7f0ee;
  --paper: #f4f7fa;
  --paper-dim: #e7edf3;
  --card: #ffffff;
  --ink: #16232f;
  --slate-600: #45586b;
  --slate-500: #5c7186;
  --slate-400: #8a9bab;
  --line: #d7e0e8;

  --approve: #237a4b;
  --approve-bg: #e5f5ec;
  --reprove: #b23a3a;
  --reprove-bg: #fbe9e9;
  --analise: #a3760a;
  --analise-bg: #fbf1dc;
  --aberta: #45586b;
  --aberta-bg: #eaeef2;

  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;

  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(10, 37, 64, 0.08);
  --shadow-md: 0 8px 24px rgba(10, 37, 64, 0.12);
}

* { box-sizing: border-box; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; }

a { color: var(--blue-500); }

.hidden { display: none !important; }

/* ====================================================================
   PADRÃO DE GRADE (motivo "blueprint") — usado como textura de fundo
==================================================================== */
.grid-texture {
  background-image:
    repeating-linear-gradient(0deg, rgba(111, 227, 224, 0.08) 0, rgba(111,227,224,0.08) 1px, transparent 1px, transparent 32px),
    repeating-linear-gradient(90deg, rgba(111, 227, 224, 0.08) 0, rgba(111,227,224,0.08) 1px, transparent 1px, transparent 32px);
}

/* ====================================================================
   TELA DE LOGIN
==================================================================== */
.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
}

@media (max-width: 860px) {
  .login-screen { grid-template-columns: 1fr; }
  .login-side { display: none; }
}

.login-side {
  background: linear-gradient(160deg, var(--blueprint-900), var(--blueprint-700));
  color: white;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px;
  overflow: hidden;
}

.login-side .brand {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 1;
}

.login-side .brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--cyan-300); box-shadow: 0 0 12px var(--cyan-300); }

.login-side .headline {
  z-index: 1;
  max-width: 420px;
}

.login-side .headline h1 {
  font-size: 40px;
  line-height: 1.1;
  margin-bottom: 14px;
}

.login-side .headline p {
  color: var(--cyan-200);
  font-size: 15px;
  max-width: 360px;
}

/* Caixa de identificação estilo "title block" de prancha técnica */
.title-block {
  z-index: 1;
  border: 1px solid rgba(111, 227, 224, 0.4);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--cyan-200);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: fit-content;
  max-width: 100%;
}
.title-block div {
  padding: 8px 14px;
  border-right: 1px solid rgba(111, 227, 224, 0.25);
  border-top: 1px solid rgba(111, 227, 224, 0.25);
}
.title-block div:nth-child(3n) { border-right: none; }
.title-block span { display: block; text-transform: uppercase; letter-spacing: 0.06em; color: var(--slate-400); font-size: 9px; margin-bottom: 3px; }

.login-form-side {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.login-card {
  width: 100%;
  max-width: 380px;
}

.login-card h2 { font-size: 24px; margin-bottom: 6px; }
.login-card .sub { color: var(--slate-500); font-size: 14px; margin-bottom: 28px; }

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--slate-600);
  margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(45, 116, 191, 0.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: transform 0.1s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--blue-600); color: white; }
.btn-primary:hover { background: var(--blue-500); box-shadow: var(--shadow-sm); }
.btn-primary:focus-visible { outline: 2px solid var(--cyan-300); outline-offset: 2px; }
.btn-ghost { background: transparent; color: var(--slate-600); border: 1px solid var(--line); }
.btn-ghost:hover { border-color: var(--blue-400); color: var(--blue-600); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-danger { background: var(--reprove-bg); color: var(--reprove); }
.btn-danger:hover { background: #f6d6d6; }
.btn-approve { background: var(--approve-bg); color: var(--approve); }
.btn-approve:hover { background: #d3ecdd; }

.error-msg {
  background: var(--reprove-bg);
  color: var(--reprove);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* ====================================================================
   APP SHELL
==================================================================== */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

@media (max-width: 780px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

.sidebar {
  background: var(--blueprint-900);
  color: white;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
}

.sidebar .brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px 24px;
}
.sidebar .brand .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--cyan-300); }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--cyan-200);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
  transition: background 0.15s ease;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: white; }
.nav-item.active { background: var(--blue-600); color: white; }

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 16px;
}

.role-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(111, 227, 224, 0.15);
  color: var(--cyan-300);
  display: inline-block;
}

.main {
  padding: 28px 36px 60px;
  max-width: 1100px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.topbar h1 { font-size: 22px; }
.topbar .sub { color: var(--slate-500); font-size: 13px; margin-top: 4px; }

/* ====================================================================
   CARDS / TABELAS
==================================================================== */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title-row h3 { font-size: 15px; }
.card-title-row[data-toggle]:hover { background: var(--paper-dim); }
.chevron { display: inline-block; transition: transform 0.15s ease; width: 12px; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--slate-500);
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
td { padding: 10px 10px; border-bottom: 1px solid var(--paper-dim); vertical-align: middle; }
tr:last-child td { border-bottom: none; }

.mono { font-family: var(--font-mono); font-size: 12px; }

/* ====================================================================
   SELOS DE STATUS ("carimbo" de aprovação)
==================================================================== */
.stamp {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1.5px solid currentColor;
}
.stamp::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.stamp-conforme, .stamp-aprovado, .stamp-aprovada { color: var(--approve); background: var(--approve-bg); }
.stamp-nao_conforme, .stamp-reprovado, .stamp-reprovada { color: var(--reprove); background: var(--reprove-bg); }
.stamp-em_analise { color: var(--analise); background: var(--analise-bg); }
.stamp-aberta, .stamp-pendente { color: var(--aberta); background: var(--aberta-bg); }
.stamp-atrasada { color: var(--reprove); background: var(--reprove-bg); }
.stamp-recebido_parcialmente { background: #fdf3e0; color: #a3760a; }

.icon-btn {
  width: 18px;
  height: 18px;
  object-fit: contain;
  display: inline-block;
  vertical-align: middle;
  filter: brightness(0) saturate(100%) invert(41%) sepia(69%) saturate(720%) hue-rotate(190deg) brightness(96%) contrast(95%);
}

.btn img.icon-btn { filter: brightness(0) saturate(100%) invert(41%) sepia(69%) saturate(720%) hue-rotate(190deg) brightness(96%) contrast(95%); }

/* ====================================================================
   DASHBOARD DE ESTATÍSTICAS
==================================================================== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.section-header h3 {
  font-size: 15px;
}
.section-subtitle {
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--slate-500);
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
}
@media (max-width: 980px) { .stats-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 780px) { .stats-row { grid-template-columns: repeat(2, 1fr); } }

.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  min-height: 110px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.stat-value { font-family: var(--font-display); font-size: 26px; font-weight: 700; color: var(--blueprint-900); }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--slate-500); margin-top: 4px; }
.stat-card.stat-alert { border-color: var(--reprove); background: var(--reprove-bg); }
.stat-card.stat-alert .stat-value { color: var(--reprove); }
.stat-card.stat-alert .stat-label { color: var(--reprove); }

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
@media (max-width: 980px) { .info-grid { grid-template-columns: 1fr; } }

.section-surface {
  background: linear-gradient(180deg, #ffffff 0%, #f8fbfe 100%);
}

.mini-list {
  display: grid;
  gap: 10px;
}
.mini-list .doc-item {
  margin-bottom: 0;
}

.filter-card {
  padding: 18px;
}

.filter-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  align-items: center;
}
.filter-bar select {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  font-size: 13px;
  color: var(--ink);
}
.filter-bar select:focus { outline: none; border-color: var(--blue-500); }
.filter-count {
  grid-column: 1 / -1;
  font-size: 12.5px;
  color: var(--slate-500);
  justify-self: end;
}

.table-shell {
  overflow: auto;
  max-height: 600px;
  border: 1px solid var(--paper-dim);
  border-radius: 10px;
}
.table-shell table {
  margin: 0;
}

.table-shell table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fff;
}

.table-shell tbody tr:hover {
  background: rgba(45, 116, 191, 0.04);
}

/* ====================================================================
   FORM INLINE / MODAL SIMPLES
==================================================================== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}
.field { min-width: 0; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 37, 64, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}

.modal {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-md);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}
.modal-header h3 { font-size: 17px; }
.close-x { cursor: pointer; color: var(--slate-500); font-size: 20px; line-height: 1; background: none; border: none; }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--slate-500);
}
.empty-state h4 { font-size: 15px; color: var(--ink); margin-bottom: 6px; }

.doc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 8px;
}
.doc-item .doc-name { font-weight: 500; font-size: 13.5px; }
.doc-item .doc-meta { font-size: 12px; color: var(--slate-500); margin-top: 2px; }

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--blueprint-900);
  color: white;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 13.5px;
  box-shadow: var(--shadow-md);
  z-index: 100;
  animation: toast-in 0.2s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.toast.error { background: var(--reprove); }

.tag-select {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.tag-select button {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  cursor: pointer;
  font-size: 13px;
}
.tag-select button.active { background: var(--blue-600); color: white; border-color: var(--blue-600); }

/* ====================================================================
   NAVEGAÇÃO EMPRESA -> OBRA -> PENDÊNCIAS
==================================================================== */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  font-size: 13.5px;
}
.crumb { color: var(--blue-600); font-weight: 500; cursor: pointer; }
.crumb:hover { text-decoration: underline; }
.crumb-current { color: var(--ink); font-weight: 600; cursor: default; }
.crumb-current:hover { text-decoration: none; }
.crumb-sep { color: var(--slate-400); }

.nav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}

.nav-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}
.nav-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--blue-400);
}
.nav-card-title { font-family: var(--font-display); font-weight: 600; font-size: 16px; }
.nav-card-meta { color: var(--slate-500); font-size: 12.5px; margin-top: 4px; }

/* ====================================================================
   FILTROS COMBINÁVEIS
==================================================================== */
.filter-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  align-items: center;
}
.filter-bar select {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  font-size: 13px;
  color: var(--ink);
}
.filter-bar select:focus { outline: none; border-color: var(--blue-500); }
.filter-count {
  grid-column: 1 / -1;
  font-size: 12.5px;
  color: var(--slate-500);
  justify-self: end;
}

/* ====================================================================
   GRÁFICOS
==================================================================== */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
@media (max-width: 780px) { .chart-grid { grid-template-columns: 1fr; } }
.chart-card h4 {
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--slate-600);
  margin-bottom: 14px;
}
.chart-card {
  min-height: 380px;
}
.chart-canvas-wrap { position: relative; height: 300px; }
.stat-card.clickable { cursor: pointer; transition: transform 0.12s ease, box-shadow 0.12s ease; }
.stat-card.clickable:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }

/* ====================================================================
   ABAS
==================================================================== */
.tabs-bar {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}
.tab-btn {
  padding: 10px 16px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--slate-500);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--blue-600); }
.tab-btn.active { color: var(--blue-600); border-bottom-color: var(--blue-600); font-weight: 600; }

.nav-card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }

.nav-card-logo {
  width: 44px; height: 44px; border-radius: 10px; object-fit: cover;
  background: var(--paper-dim); border: 1px solid var(--line); flex-shrink: 0;
}
.nav-card-avatar {
  width: 44px; height: 44px; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--blue-600), var(--cyan-300));
  color: white; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; font-size: 17px;
}

.progress-bar {
  height: 6px; background: var(--paper-dim); border-radius: 999px;
  overflow: hidden; margin-top: 12px;
}
.progress-bar-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--blue-500), var(--cyan-300));
  transition: width 0.3s ease;
}

/* ====================================================================
   ACENTO DE COR NOS CARDS DE PENDÊNCIA E BOOK
==================================================================== */
.pendencia-card { border-left: 4px solid var(--aberta); }
.pendencia-card.status-aberta { border-left-color: var(--aberta); }
.pendencia-card.status-em_analise { border-left-color: var(--analise); }
.pendencia-card.status-aprovada { border-left-color: var(--approve); }
.pendencia-card.status-reprovada { border-left-color: var(--reprove); }
.book-card { border-left: 4px solid var(--blue-500); }
