/* ================================================================
   OBRA MASTER PRO — Design System v5.0
   Paleta: #0D1B2A (navy) · #FFFFFF · #111827 (preto)
   Minimalista · Flat · Mobile-first · iPhone safe area
   v=500
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;600&display=swap');

/* ── TOKENS ─────────────────────────────────────────────────── */
:root {
  --navy:        #0D1B2A;
  --navy-hover:  #162336;
  --navy-active: #091420;
  --black:       #111827;
  --gray-800:    #1F2937;
  --gray-700:    #374151;
  --gray-600:    #4B5563;
  --gray-500:    #6B7280;
  --gray-400:    #9CA3AF;
  --gray-300:    #D1D5DB;
  --gray-200:    #E5E7EB;
  --gray-100:    #F3F4F6;
  --gray-50:     #F9FAFB;
  --white:       #FFFFFF;
  --red:         #DC2626;
  --red-bg:      #FEF2F2;
  --green:       #16A34A;
  --green-bg:    #F0FDF4;
  --amber:       #D97706;
  --amber-bg:    #FFFBEB;
  --blue-accent: #2563EB;  /* accent only — NÃO usar em botões primários */

  --sidebar-w:   260px;
  --topbar-h:    56px;
  --r:           8px;
  --r-sm:        5px;
  --r-lg:        12px;
  --font:        'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --mono:        'JetBrains Mono', 'SF Mono', monospace;
  --trans:       all .15s ease;
}

/* ── RESET ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

button {
  -webkit-appearance: none !important;
  appearance: none !important;
  background: none;
  border: none;
  font-family: inherit;
  cursor: pointer;
  box-shadow: none;
}

html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Impede zoom automático no iOS em inputs */
  touch-action: manipulation;
}

body {
  font-family: var(--font);
  background: #F1F4F8;
  color: var(--black);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

img { max-width: 100%; height: auto; }
a { color: inherit; }

/* ── SIDEBAR ─────────────────────────────────────────────────
   FUNDO BRANCO. TEXTO E ÍCONES NAVY ESCURO.
   ─────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  height: 100dvh;
  background: #FFFFFF !important;
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  z-index: 900;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 4px; }

/* Logo — fundo branco, sem filtro */
.sidebar-brand {
  flex-shrink: 0;
  padding: 16px 20px 14px;
  border-bottom: 1px solid var(--gray-100);
  background: #FFFFFF;
}
.sidebar-brand a { display: block; line-height: 0; text-decoration: none; }
.sidebar-brand-logo {
  display: block;
  height: 36px;
  width: auto;
  max-width: 200px;
  object-fit: contain;
  object-position: left center;
  /* PNG com fundo branco — zero filtro */
}
.sidebar-brand-sub {
  font-size: 11px;
  color: var(--gray-500);
  margin-top: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

/* Obra ativa */
.sidebar-obra {
  margin: 10px 12px;
  padding: 10px 12px;
  background: var(--gray-50);
  border-left: 3px solid var(--navy);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  font-size: 12px;
  color: var(--gray-600);
}
.sidebar-obra strong {
  display: block;
  color: var(--navy);
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Seções do nav */
.nav-section {
  padding: 16px 20px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--gray-400);
  user-select: none;
}

/* Itens do menu */
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  color: var(--gray-700);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background .12s, color .12s;
  border-left: 3px solid transparent;
  min-height: 37px;
  -webkit-tap-highlight-color: transparent;
}
.nav-item svg {
  flex-shrink: 0;
  color: var(--gray-400);
  transition: color .12s;
}
.nav-item:hover {
  background: var(--gray-50);
  color: var(--navy);
}
.nav-item:hover svg { color: var(--navy); }
.nav-item.active {
  background: var(--gray-100);
  color: var(--navy);
  border-left-color: var(--navy);
  font-weight: 600;
}
.nav-item.active svg { color: var(--navy); }

.nav-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  background: var(--navy);
  color: var(--white);
  padding: 2px 8px;
  border-radius: 20px;
}
.nav-badge.red { background: var(--red); }

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--gray-100);
  padding: 8px 0;
  flex-shrink: 0;
}

/* ── OVERLAY MOBILE ─────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .40);
  z-index: 899;
}

/* ── LAYOUT PRINCIPAL ───────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* TOPBAR — navy fundo, texto branco */
.topbar {
  height: var(--topbar-h);
  background: var(--navy);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 800;
  padding-left:  max(24px, env(safe-area-inset-left, 24px));
  padding-right: max(24px, env(safe-area-inset-right, 24px));
}
.topbar-title {
  font-size: 15px;
  font-weight: 600;
  color: #FFFFFF;
  white-space: nowrap;
}
.topbar-sub {
  font-size: 12px;
  color: rgba(255,255,255,.50);
  margin-top: 1px;
}
.topbar-spacer { flex: 1; }
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.topbar-actions .text-muted { color: rgba(255,255,255,.55) !important; }

/* Hamburger */
.mob-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: none !important;
  background: rgba(255,255,255,.12) !important;
  color: #FFFFFF !important;
  cursor: pointer;
  border-radius: var(--r-sm);
  flex-shrink: 0;
  -webkit-appearance: none !important;
  appearance: none !important;
  -webkit-tap-highlight-color: transparent;
}
.mob-toggle:active { background: rgba(255,255,255,.22) !important; }
.mob-toggle svg { color: #FFFFFF !important; }

/* Conteúdo */
.content { flex: 1; padding: 24px 28px; }

/* ── CARDS ──────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.card + .card { margin-top: 18px; }

.card-header {
  padding: 15px 22px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  gap: 10px;
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--black);
}
.card-header .spacer { flex: 1; }
.card-body { padding: 22px; }
.card-footer {
  padding: 13px 22px;
  border-top: 1px solid var(--gray-100);
  background: var(--gray-50);
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── STAT CARDS ─────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--r);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-icon.blue   { background: #DBEAFE; color: #1D4ED8; }
.stat-icon.green  { background: #DCFCE7; color: #15803D; }
.stat-icon.red    { background: #FEE2E2; color: #B91C1C; }
.stat-icon.navy   { background: var(--gray-100); color: var(--navy); }
.stat-icon.yellow { background: #FEF3C7; color: #92400E; }
.stat-info { flex: 1; min-width: 0; }
.stat-label {
  font-size: 11px;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .6px;
  font-weight: 600;
  margin-bottom: 4px;
}
.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--black);
  line-height: 1.2;
  font-family: var(--mono);
  letter-spacing: -.5px;
}
.stat-sub { font-size: 11px; color: var(--gray-500); margin-top: 4px; }

/* ── TABELAS ────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
tr:hover td { background: var(--gray-50); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead tr { background: var(--gray-50); }
th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .7px;
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
td {
  padding: 12px 16px;
  font-size: 14px;
  color: var(--gray-700);
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
th.right, td.right { text-align: right; }
th.center, td.center { text-align: center; }
.td-primary { font-weight: 600; color: var(--black); }
.td-mono { font-family: var(--mono); font-size: 13px; }

/* ══════════════════════════════════════════════════════════════
   BOTÕES — NAVY ESCURO, RETANGULARES, FLAT, SEM SOMBRA
   ══════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 20px;
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none !important;
  text-decoration: none;
  white-space: nowrap;
  transition: background .13s, color .13s;
  line-height: 1.4;
  font-family: var(--font);
  min-height: 40px;
  -webkit-appearance: none !important;
  appearance: none !important;
  box-shadow: none !important;
  -webkit-tap-highlight-color: transparent;
}
.btn svg { flex-shrink: 0; }
.btn-sm  { padding: 6px 14px; font-size: 13px; min-height: 32px; }
.btn-lg  { padding: 12px 28px; font-size: 15px; min-height: 46px; }
.btn:disabled { opacity: .40; cursor: not-allowed; pointer-events: none; }

/* Primary — NAVY ESCURO */
.btn-primary {
  background: var(--navy) !important;
  color: #FFFFFF !important;
}
.btn-primary:hover  { background: var(--navy-hover) !important; }
.btn-primary:active { background: var(--navy-active) !important; }

/* Outline */
.btn-outline {
  background: var(--white) !important;
  color: var(--gray-700) !important;
  border: 1px solid var(--gray-300) !important;
}
.btn-outline:hover { background: var(--gray-50) !important; }

/* Danger */
.btn-danger {
  background: var(--red) !important;
  color: #FFFFFF !important;
}
.btn-danger:hover { background: #B91C1C !important; }

/* Ghost */
.btn-ghost {
  background: transparent !important;
  color: var(--gray-600) !important;
}
.btn-ghost:hover { background: var(--gray-100) !important; color: var(--black) !important; }

/* Success */
.btn-success {
  background: var(--green) !important;
  color: #FFFFFF !important;
}
.btn-success:hover { background: #15803D !important; }

/* Blue (somente onde realmente necessário) */
.btn-blue {
  background: #1D4ED8 !important;
  color: #FFFFFF !important;
}
.btn-blue:hover { background: #1E40AF !important; }

/* ── FORMULÁRIOS ────────────────────────────────────────────── */
.form-grid   { display: grid; gap: 16px; }
.form-grid > * { min-width: 0; }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: repeat(3, 1fr); }
.form-grid-4 { grid-template-columns: repeat(4, 1fr); }
.form-group  { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.form-group.span2 { grid-column: span 2; }
.form-group.span3 { grid-column: span 3; }
.form-group.span4 { grid-column: span 4; }

label {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
}
label .req { color: var(--red); margin-left: 2px; }

input[type=text], input[type=email], input[type=number],
input[type=password], input[type=tel], input[type=date],
input[type=url], select, textarea {
  width: 100%;
  min-width: 0;
  padding: 10px 14px;
  border: 1px solid var(--gray-300);
  border-radius: var(--r-sm);
  font-size: 14px;
  font-family: var(--font);
  color: var(--black);
  background: var(--white);
  transition: border-color .13s, box-shadow .13s;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  min-height: 44px;
  /* iOS: impede zoom ao focar */
  font-size: max(16px, 14px);
}
input[type=number] { font-family: var(--mono); }
input:focus, select:focus, textarea:focus {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(13, 27, 42, .10);
}
input:hover:not(:focus), select:hover:not(:focus) {
  border-color: var(--gray-400);
}
input[readonly], input[disabled] {
  background: var(--gray-50);
  color: var(--gray-500);
  cursor: default;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
  cursor: pointer;
}
textarea { resize: vertical; min-height: 100px; }

.form-hint  { font-size: 12px; color: var(--gray-400); line-height: 1.5; }
.form-error { font-size: 12px; color: var(--red); font-weight: 500; }

.input-group { display: flex; min-width: 0; align-items: stretch; }
.input-group input {
  border-radius: var(--r-sm) 0 0 var(--r-sm);
  border-right: none !important;
  flex: 1;
  min-width: 0;
}
.input-group .btn {
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  flex-shrink: 0;
}
/* Suffix/prefix de texto puro (ex: %) */
.input-suffix {
  display: inline-flex;
  align-items: center;
  padding: 0 13px;
  background: var(--gray-50);
  border: 1px solid var(--gray-300);
  border-left: none;
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-500);
  white-space: nowrap;
  flex-shrink: 0;
  min-height: 44px;
}
.input-group input:focus { position: relative; z-index: 1; }

/* ── BADGES ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .2px;
  white-space: nowrap;
}
.badge-blue   { background: #DBEAFE; color: #1D4ED8; }
.badge-green  { background: #DCFCE7; color: #15803D; }
.badge-yellow { background: #FEF3C7; color: #92400E; }
.badge-red    { background: #FEE2E2; color: #B91C1C; }
.badge-gray   { background: var(--gray-100); color: var(--gray-600); }
.badge-navy   { background: var(--navy); color: #FFFFFF; }

/* ── ALERTS ─────────────────────────────────────────────────── */
.alert {
  padding: 13px 16px;
  border-radius: var(--r);
  font-size: 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid transparent;
  margin-bottom: 16px;
  line-height: 1.6;
}
.alert-success { background: var(--green-bg);  border-color: #BBF7D0; color: #166534; }
.alert-danger  { background: var(--red-bg);    border-color: #FECACA; color: #991B1B; }
.alert-warning { background: var(--amber-bg);  border-color: #FDE68A; color: #78350F; }
.alert-info    { background: #EFF6FF;          border-color: #BFDBFE; color: #1E40AF; }

.system-banner {
  padding: 10px 28px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid transparent;
  flex-shrink: 0;
}
.banner-danger  { background: #7F1D1D; color: #FCA5A5; border-color: #991B1B; }
.banner-warning { background: #78350F; color: #FDE68A; border-color: #92400E; }
.banner-info    { background: #1E3A5F; color: #93C5FD; border-color: #1D4ED8; }

/* ── TABS ───────────────────────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--gray-200);
  gap: 0;
  margin-bottom: 22px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tab {
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-500);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: var(--font);
  white-space: nowrap;
  flex-shrink: 0;
  min-height: 46px;
  transition: color .13s;
}
.tab:hover { color: var(--black); }
.tab.active {
  color: var(--navy);
  border-bottom-color: var(--navy);
  font-weight: 700;
}

/* ── MODAL ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .50);
  z-index: 9000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--white);
  width: 100%;
  max-width: 600px;
  max-height: 92vh;
  border-radius: var(--r-lg);
  display: flex;
  flex-direction: column;
}
.modal-lg { max-width: 900px; }
.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.modal-title { font-size: 15px; font-weight: 700; }
.modal-close {
  margin-left: auto;
  cursor: pointer;
  background: none;
  border: none;
  color: var(--gray-400);
  padding: 4px;
  border-radius: var(--r-sm);
  width: 34px; height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: background .13s;
}
.modal-close:hover { background: var(--gray-100); color: var(--black); }
.modal-body { padding: 22px; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
  background: var(--gray-50);
  flex-shrink: 0;
}

/* ── PROGRESS ───────────────────────────────────────────────── */
.progress-bar {
  height: 6px;
  background: var(--gray-100);
  border-radius: 20px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 20px;
  background: var(--navy);
  transition: width .4s ease;
}
.progress-fill.green  { background: var(--green); }
.progress-fill.amber  { background: var(--amber); }
.progress-fill.red    { background: var(--red); }

/* ── GANTT ──────────────────────────────────────────────────── */
.gantt-wrap  { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.gantt-table { min-width: 900px; }
.gantt-bar   { height: 14px; border-radius: 4px; background: var(--navy); display: block; min-width: 4px; }
.gantt-bar.done    { background: var(--green); }
.gantt-bar.delayed { background: var(--red); }

/* ── TIMELINE ───────────────────────────────────────────────── */
.timeline { list-style: none; position: relative; padding-left: 26px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 8px; top: 0; bottom: 0;
  width: 2px;
  background: var(--gray-200);
}
.timeline-item { position: relative; padding-bottom: 22px; }
.timeline-dot {
  position: absolute;
  left: -22px; top: 3px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--white);
  border: 2px solid var(--gray-300);
}
.timeline-dot.done    { background: var(--green); border-color: var(--green); }
.timeline-dot.active  { background: var(--navy); border-color: var(--navy); }
.timeline-dot.delayed { background: var(--red); border-color: var(--red); }

/* ── TEMPLATES ──────────────────────────────────────────────── */
.template-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}
.template-card {
  border: 2px solid var(--gray-200);
  border-radius: var(--r);
  overflow: hidden;
  cursor: pointer;
  transition: border-color .13s;
  aspect-ratio: 3/4;
  position: relative;
}
.template-card:hover { border-color: var(--navy); }
.template-card.selected { border-color: var(--navy); }
.template-card img { width: 100%; height: 100%; object-fit: cover; }
.template-card .tpl-label {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 6px 8px;
  font-size: 11px; font-weight: 600;
  background: rgba(0,0,0,.70); color: #FFFFFF;
}

/* ── PCI ────────────────────────────────────────────────────── */
.pci-group-header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: var(--navy); color: #FFFFFF;
  border-radius: var(--r-sm);
  font-size: 13px; font-weight: 600;
  cursor: pointer; margin-bottom: 4px;
}
.pci-items { padding: 4px 0; }
.pci-item {
  display: grid;
  grid-template-columns: 1fr 80px 80px 100px;
  gap: 8px; padding: 6px 14px;
  align-items: center;
  border-bottom: 1px solid var(--gray-100);
}
.pci-item:last-child { border-bottom: none; }
.pci-item input { padding: 5px 9px; font-size: 13px; min-height: 34px; }

/* ── CALCULADORAS / BDI ─────────────────────────────────────── */
.calc-result {
  background: var(--navy);
  color: #FFFFFF;
  border-radius: var(--r-lg);
  padding: 22px 26px;
}
.calc-result-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .8px;
  color: rgba(255,255,255,.45); margin-bottom: 8px;
}
.calc-result-value {
  font-size: 2.2rem; font-weight: 700; font-family: var(--mono);
}
.calc-result-sub { font-size: 13px; color: rgba(255,255,255,.40); margin-top: 6px; }

.bdi-result-box {
  background: var(--navy); border-radius: var(--r-lg);
  padding: 20px 24px; color: #FFFFFF;
  display: flex; align-items: center; gap: 28px; flex-wrap: wrap;
}
.bdi-result-value {
  font-size: 2.6rem; font-weight: 700;
  font-family: var(--mono); letter-spacing: -1px;
}
.bdi-result-label {
  font-size: 11px; text-transform: uppercase;
  letter-spacing: .8px; color: rgba(255,255,255,.40); margin-bottom: 4px;
}
.bdi-result-formula {
  font-size: 11px; color: rgba(255,255,255,.28);
  margin-top: 6px; line-height: 1.7;
}

/* ── EMPTY STATE ────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 70px 20px; color: var(--gray-400); }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--gray-600); margin-bottom: 8px; }
.empty-state p  { font-size: 14px; margin-bottom: 22px; }

/* ── OBRAS GRID ─────────────────────────────────────────────── */
.obras-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px; margin-top: 18px;
}
.obra-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  display: flex; flex-direction: column; gap: 10px;
  cursor: pointer; text-decoration: none; color: inherit;
  transition: border-color .13s;
}
.obra-card:hover { border-color: var(--navy); }
.obra-card-title  { font-size: 15px; font-weight: 600; color: var(--black); }
.obra-card-client { font-size: 13px; color: var(--gray-500); }
.obra-card-meta   { display: flex; gap: 8px; flex-wrap: wrap; }

/* ══════════════════════════════════════════════════════════════
   LOGIN / AUTH — fundo navy sólido, caixa branca limpa
   ══════════════════════════════════════════════════════════════ */
.login-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
  padding: 20px;
  padding-top:    max(20px, env(safe-area-inset-top, 20px));
  padding-bottom: max(20px, env(safe-area-inset-bottom, 20px));
}

.login-box {
  width: 100%;
  max-width: 420px;
  background: #FFFFFF;
  border-radius: var(--r-lg);
  padding: 40px 36px;
}

/* Logo no login — sempre dentro de fundo branco */
.login-logo-wrap {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo-img {
  height: 44px;
  width: auto;
  max-width: 240px;
  display: inline-block;
  background: #FFFFFF;
  border-radius: 4px;
}
.login-logo-tagline {
  display: block;
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 8px;
  font-weight: 500;
}

/* Auth form */
.auth-form-group { margin-bottom: 18px; }
.auth-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 7px;
}
.auth-input {
  width: 100%;
  padding: 12px 15px;
  border: 1px solid var(--gray-300);
  border-radius: var(--r-sm);
  font-size: 16px; /* 16px = sem zoom no iOS */
  font-family: var(--font);
  color: var(--black);
  background: var(--white);
  outline: none;
  transition: border-color .13s, box-shadow .13s;
  -webkit-appearance: none;
  appearance: none;
  min-height: 48px;
}
.auth-input:focus {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(13, 27, 42, .10);
}

.auth-hint { font-size: 12px; color: var(--gray-400); margin-top: 5px; line-height: 1.5; }
.auth-error {
  background: var(--red-bg);
  border: 1px solid #FECACA;
  color: #991B1B;
  padding: 12px 15px;
  border-radius: var(--r-sm);
  font-size: 14px;
  margin-bottom: 18px;
  font-weight: 500;
}
.auth-success {
  background: var(--green-bg);
  border: 1px solid #BBF7D0;
  color: #166534;
  padding: 13px 15px;
  border-radius: var(--r-sm);
  font-size: 14px;
  margin-bottom: 18px;
  line-height: 1.6;
}

/* ══════════════════════════════════════════════════════════════
   BTN-AUTH — O BOTÃO PRINCIPAL DE LOGIN
   NAVY ESCURO · BRANCO · NEGRITO · LARGO · RETANGULAR
   ══════════════════════════════════════════════════════════════ */
.btn-auth {
  display: block !important;
  width: 100% !important;
  text-align: center !important;

  padding: 15px 24px !important;
  margin-top: 10px !important;

  background: #0D1B2A !important;
  color: #FFFFFF !important;

  font-size: 16px !important;
  font-weight: 700 !important;
  font-family: var(--font) !important;
  letter-spacing: .3px !important;
  line-height: 1.4 !important;

  border: none !important;
  border-radius: 8px !important;

  cursor: pointer !important;
  text-decoration: none !important;

  min-height: 54px !important;

  -webkit-appearance: none !important;
  appearance: none !important;
  box-shadow: none !important;
  outline: none !important;
  -webkit-tap-highlight-color: transparent !important;

  transition: background .13s !important;
}
.btn-auth:hover,
.btn-auth:visited { background: #162336 !important; color: #FFFFFF !important; }
.btn-auth:active  { background: #091420 !important; color: #FFFFFF !important; }
.btn-auth:focus   { outline: none !important; box-shadow: 0 0 0 3px rgba(13,27,42,.25) !important; }

.auth-link {
  font-size: 13px;
  color: var(--gray-600);
  text-decoration: none;
  font-weight: 500;
}
.auth-link:hover { color: var(--navy); text-decoration: underline; }

/* ── MISC ───────────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--gray-200); margin: 22px 0; }
.text-right   { text-align: right; }
.text-center  { text-align: center; }
.text-muted   { color: var(--gray-500); font-size: 13px; }
.text-small   { font-size: 13px; }
.text-bold    { font-weight: 700; }
.text-red     { color: var(--red); }
.text-green   { color: var(--green); }
.text-mono    { font-family: var(--mono); }
.flex         { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.spacer       { flex: 1; }
.gap-6  { gap: 6px; }   .gap-8   { gap: 8px; }
.gap-12 { gap: 12px; }  .gap-16  { gap: 16px; }
.mt-4   { margin-top: 4px; }    .mt-8    { margin-top: 8px; }
.mt-16  { margin-top: 16px; }   .mt-24   { margin-top: 24px; }
.mb-8   { margin-bottom: 8px; } .mb-16   { margin-bottom: 16px; }
.mb-20  { margin-bottom: 20px; }.mb-24   { margin-bottom: 24px; }
.action-bar {
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap; margin-bottom: 18px;
}
.action-bar .spacer { flex: 1; }
.section-title {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--gray-400); margin-bottom: 14px;
}
.total-row { background: var(--gray-50) !important; }
.total-row td { font-weight: 700; color: var(--black); border-top: 1px solid var(--gray-200); }

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE FIRST
   iPhone SE 375 · iPhone 14 Pro 393 · iPhone Pro Max 430
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 1200px) {
  :root { --sidebar-w: 0px; }

  .sidebar {
    width: 280px;
    left: -280px;
    transition: left .22s ease;
    padding-top: env(safe-area-inset-top, 0);
  }
  .sidebar.open { left: 0; box-shadow: 6px 0 30px rgba(0,0,0,.18); }
  .sidebar-overlay.open { display: block; }
  .mob-toggle { display: flex; }

  .content { padding: 16px; }

  .topbar { padding: 0 16px; gap: 12px; }

  .form-grid-2,
  .form-grid-3,
  .form-grid-4 { grid-template-columns: 1fr; }
  .form-group.span2,
  .form-group.span3,
  .form-group.span4 { grid-column: span 1; }

  .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .template-grid { grid-template-columns: repeat(2, 1fr); }

  /* Modal vira bottom sheet */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .modal {
    border-radius: 16px 16px 0 0;
    max-width: 100%;
    padding-bottom: env(safe-area-inset-bottom, 0);
    max-height: 94vh;
  }
}

@media (max-width: 480px) {
  /* Fontes maiores para mobile — cara de app */
  html { font-size: 15px; }

  .nav-item { font-size: 15px; min-height: 40px; }

  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px 14px; }
  .stat-value { font-size: 20px; }

  .card-body { padding: 16px; }
  .card-header { padding: 14px 16px; }

  .content { padding: 12px 14px; }

  /* Login */
  .login-box { padding: 32px 22px; }
  .login-logo-img { height: 40px; }
  .btn-auth { min-height: 56px !important; font-size: 17px !important; }

  /* Botões mais fáceis de tocar */
  .btn { min-height: 44px; font-size: 15px; }
  .btn-lg { min-height: 50px; }

  .topbar { height: 52px; }
  .topbar-title { font-size: 15px; }
  .topbar-sub { display: none; }

  .obras-grid { grid-template-columns: 1fr; }
  .bdi-result-value { font-size: 2.2rem; }
  .calc-result-value { font-size: 2rem; }
}

/* iPhone landscape */
@media (orientation: landscape) and (max-width: 960px) {
  .sidebar { padding-left: env(safe-area-inset-left, 0); }
  .content {
    padding-left:  max(14px, env(safe-area-inset-left,  14px));
    padding-right: max(14px, env(safe-area-inset-right, 14px));
  }
}

/* Print */
@media print {
  .sidebar, .topbar, .mob-toggle, .no-print { display: none !important; }
  .main { margin-left: 0; }
  .content { padding: 0; }
  body { background: #fff; }
}

/* ── Spinner (loading CEP) ──────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spin-icon { animation: spin .7s linear infinite; display:inline-block; vertical-align:middle; }

/* ── Geo PCI grid — responsivo no mobile ───────────────── */
@media (max-width: 480px) {
  .geo-row { grid-template-columns: 1fr 1fr !important; }
}

/* ── Mobile melhorias v6.0 ─────────────────────────────── */
@media (max-width: 960px) {
  /* Tables — horizontal scroll sem overflow da tela */
  .table-wrap, .table-wrap table { min-width: 0; }
  .topbar-right { gap: 6px; }
  .topbar-right .btn-sm { padding: 5px 8px; font-size: .73rem; }

  /* Cronograma — datas em coluna no mobile */
  .cron-date-cell { display: block; width: 100%; }

  /* Calculadoras — tabs wrap melhor */
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
  .tabs button { white-space: nowrap; flex-shrink: 0; }

  /* Stats grid 2 colunas consistente */
  .stats-grid { grid-template-columns: 1fr 1fr !important; }

  /* Ocultar colunas secundárias em tabelas */
  .hide-mobile { display: none !important; }
}

@media (max-width: 480px) {
  /* Cards mais compactos */
  .card-header { gap: 6px; }
  .card-title { font-size: .82rem; }

  /* Topbar — título truncado */
  .topbar-title { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* Action bar — wrap adequado */
  .action-bar { flex-wrap: wrap; gap: 6px; }
  .action-bar .btn { font-size: .75rem; padding: 6px 10px; }

  /* Inputs de data menores */
  input[type="date"] { font-size: .73rem; padding: 4px 6px; }

  /* Calculadoras — grid 1 coluna forçado */
  .calc-grid { grid-template-columns: 1fr !important; }
  .r-grid { grid-template-columns: repeat(2, 1fr) !important; }

  /* Materiais — ocultar colunas R$/UN CUSTOS no mobile */
  .mat-col-custos { display: none; }

  /* PCI table — não extrapolar */
  .pci-table { font-size: .70rem; }
  .pci-table td, .pci-table th { padding: 4px 6px !important; }

  /* Modal full-screen em mobile pequeno */
  .modal { max-height: 100vh; border-radius: 0; }

  /* Stats 2 colunas inalterado */
  .stats-grid { grid-template-columns: 1fr 1fr !important; gap: 8px; }
  .stat-card { padding: 12px; }
  .stat-value { font-size: 18px; }
  .stat-label { font-size: .65rem; }

  /* Forms — labels visíveis */
  .form-group label { font-size: .78rem; font-weight: 600; }

  /* Botão primário — full width em mobile pequeno em forms */
  .form-submit-mobile { width: 100% !important; }

  /* Sidebar over overlay */
  .sidebar { z-index: 1001; }
  .sidebar-overlay { z-index: 1000; }
}