/* MRR - Impressões 3D | Identidade Visual Oficial */
:root {
  --bg: #070b12;
  --bg-elevated: #0f1623;
  --surface: #131c2e;
  --surface-hover: #1a263d;
  --border: #23324d;
  --text: #f8fafc;
  --muted: #94a3b8;
  --blue: #00a8ff;
  --blue-dark: #0077cc;
  --green: #5be318;
  --green-dark: #43b50d;
  --amber: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* ==================== LOGIN SPLIT SCREEN ==================== */
.login-screen {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  min-height: 100vh;
  background: radial-gradient(circle at 15% 20%, rgba(0, 168, 255, 0.14), transparent 45%),
              radial-gradient(circle at 80% 85%, rgba(91, 227, 24, 0.12), transparent 45%),
              var(--bg);
}

.login-hero {
  padding: 4rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-right: 1px solid var(--border);
}

.login-hero-logo {
  width: 260px;
  max-width: 100%;
  display: block;
  margin: 0 auto 2rem auto;
  align-self: center;
  border-radius: 14px;
  box-shadow: 0 0 35px rgba(0, 168, 255, 0.25);
}

.login-hero h1 {
  font-size: 2.3rem;
  line-height: 1.15;
  margin-bottom: 1rem;
  background: linear-gradient(90deg, var(--blue), #ffffff 55%, var(--green));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-hero p {
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 520px;
  margin-bottom: 2rem;
}

.login-features {
  list-style: none;
  display: grid;
  gap: 0.9rem;
  max-width: 500px;
}

.login-features li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(19, 28, 46, 0.7);
  border: 1px solid var(--border);
  padding: 0.8rem 1rem;
  border-radius: 10px;
  font-size: 0.92rem;
}

.login-features .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 10px var(--green);
  flex-shrink: 0;
}

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.login-card {
  width: 100%;
  max-width: 410px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.25rem;
  box-shadow: var(--shadow);
}

.login-card h2 {
  font-size: 1.45rem;
  margin-bottom: 0.35rem;
}

.login-card .subtitle {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

/* ==================== LAYOUT PRINCIPAL ==================== */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 250px;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 1.25rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.brand-box img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--blue);
}

.brand-box strong {
  display: block;
  font-size: 0.98rem;
  color: var(--text);
}

.brand-box span {
  font-size: 0.75rem;
  color: var(--green);
  font-weight: 600;
}

.nav-links {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
}

.nav-links a {
  text-decoration: none;
  color: var(--muted);
  padding: 0.75rem 0.95rem;
  border-radius: 10px;
  font-weight: 500;
  font-size: 0.94rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  transition: 0.2s;
}

.nav-links a:hover {
  background: var(--surface);
  color: var(--text);
}

.nav-links a.active {
  background: linear-gradient(90deg, rgba(0, 168, 255, 0.18), rgba(91, 227, 24, 0.08));
  color: var(--text);
  border-left: 3px solid var(--blue);
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.user-badge {
  font-size: 0.82rem;
  color: var(--muted);
}

.main-content {
  flex: 1;
  padding: 1.75rem 2rem;
  max-width: 1360px;
  width: 100%;
  margin: 0 auto;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-header h1 {
  font-size: 1.6rem;
}

.page-header p {
  color: var(--muted);
  font-size: 0.9rem;
}

/* ==================== CARDS & KPIs ==================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--blue);
}

.kpi-card.green::before { background: var(--green); }
.kpi-card.amber::before { background: var(--amber); }
.kpi-card.danger::before { background: var(--danger); }

.kpi-label { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-value { font-size: 1.55rem; font-weight: 700; margin-top: 0.35rem; }
.kpi-sub { font-size: 0.78rem; color: var(--muted); margin-top: 0.25rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem;
  margin-bottom: 1.25rem;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.65rem;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid-calc { display: grid; grid-template-columns: 1.35fr 1fr; gap: 1.25rem; align-items: start; }

/* ==================== FORMULÁRIOS & BOTÕES ==================== */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.85rem;
}

label {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 500;
}

input, select, textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.65rem 0.8rem;
  border-radius: 8px;
  font-size: 0.92rem;
  width: 100%;
  outline: none;
  transition: border-color 0.2s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--blue);
}

.qty-control {
  display: flex;
  gap: 0.4rem;
}

.qty-control button {
  width: 42px;
  padding: 0;
  flex-shrink: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.65rem 1.1rem;
  border-radius: 8px;
  border: none;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: 0.2s;
  background: var(--blue);
  color: #fff;
}

.btn:hover { background: var(--blue-dark); }
.btn-green { background: var(--green); color: #051402; }
.btn-green:hover { background: var(--green-dark); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--blue); color: var(--blue); }
.btn-danger { background: rgba(239, 68, 68, 0.15); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.35); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 0.38rem 0.7rem; font-size: 0.8rem; }

/* ==================== TABS & TABELAS ==================== */
.tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
}

.tab-btn {
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 0.55rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.86rem;
}

.tab-btn.active {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th, td {
  text-align: left;
  padding: 0.75rem 0.65rem;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-green { background: rgba(91, 227, 24, 0.16); color: var(--green); }
.badge-blue { background: rgba(0, 168, 255, 0.16); color: var(--blue); }
.badge-amber { background: rgba(245, 158, 11, 0.18); color: #fbbf24; }
.badge-danger { background: rgba(239, 68, 68, 0.18); color: #f87171; }

/* ==================== RESULTADO ORÇAMENTO ==================== */
.price-box {
  background: linear-gradient(135deg, rgba(0, 168, 255, 0.12), rgba(91, 227, 24, 0.08));
  border: 1px solid var(--blue);
  border-radius: 12px;
  padding: 1.15rem;
  margin-bottom: 1rem;
}

.price-main {
  font-size: 2.15rem;
  font-weight: 800;
  color: var(--green);
  line-height: 1.1;
}

.breakdown {
  list-style: none;
  margin: 0.85rem 0;
}

.breakdown li {
  display: flex;
  justify-content: space-between;
  padding: 0.42rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

.alert-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--danger);
  color: #fca5a5;
  padding: 0.75rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  display: none;
  font-size: 0.88rem;
}

.lote-banner {
  background: rgba(0, 168, 255, 0.1);
  border: 1px solid rgba(0, 168, 255, 0.3);
  color: #bae6fd;
  padding: 0.55rem 0.8rem;
  border-radius: 8px;
  font-size: 0.83rem;
  margin-bottom: 0.9rem;
}

/* ==================== MODAL HISTÓRICO CLIENTE ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1000;
}

.modal-backdrop.open { display: flex; }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  max-width: 720px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 1.5rem;
}

/* ==================== PDF COMERCIAL A4 EXECUTIVO (1 PÁGINA) ==================== */
.badge-muted { background: rgba(148, 163, 184, 0.2); color: #cbd5e1; }

#print-area { display: none; }

@page {
  size: A4 portrait;
  margin: 10mm;
}

@media print {
  html, body {
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
    color: #0f172a !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Oculta tudo exceto #print-area — elimina 100% a primeira página em branco */
  body > *:not(#print-area) {
    display: none !important;
  }

  #print-area {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .pdf-sheet {
    font-family: 'Segoe UI', Arial, sans-serif;
    color: #0f172a;
    background: #ffffff;
    page-break-inside: avoid;
  }

  .pdf-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #070b12 !important;
    color: #ffffff !important;
    padding: 18px 22px;
    border-radius: 10px;
    border-bottom: 4px solid #5be318;
    margin-bottom: 18px;
  }

  .pdf-brand {
    display: flex;
    align-items: center;
    gap: 14px;
  }

  .pdf-brand img {
    height: 68px;
    width: auto;
    border-radius: 8px;
    border: 2px solid #00a8ff;
    background: #000;
  }

  .pdf-brand h1 {
    font-size: 20px;
    color: #ffffff;
    margin-bottom: 3px;
  }

  .pdf-brand p {
    font-size: 11.5px;
    color: #cbd5e1;
  }

  .pdf-doc-info {
    text-align: right;
  }

  .pdf-tag {
    display: inline-block;
    background: #00a8ff !important;
    color: #ffffff !important;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    padding: 3px 9px;
    border-radius: 4px;
    margin-bottom: 5px;
  }

  .pdf-num {
    font-size: 17px;
    font-weight: 800;
    color: #5be318 !important;
  }

  .pdf-dates {
    font-size: 11px;
    color: #e2e8f0;
    margin-top: 3px;
    line-height: 1.4;
  }

  .pdf-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 18px;
  }

  .pdf-info-card {
    background: #f8fafc !important;
    border: 1px solid #cbd5e1;
    border-left: 4px solid #00a8ff;
    border-radius: 8px;
    padding: 12px 14px;
  }

  .pdf-card-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: #0284c7;
    margin-bottom: 6px;
  }

  .pdf-client-name {
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 4px;
  }

  .pdf-info-line {
    font-size: 12px;
    color: #334155;
    margin-bottom: 3px;
  }

  .pdf-section {
    margin-bottom: 18px;
  }

  .pdf-section-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: #334155;
    margin-bottom: 8px;
  }

  .pdf-items-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid #cbd5e1;
  }

  .pdf-items-table th {
    background: #0f172a !important;
    color: #ffffff !important;
    padding: 9px 10px;
    font-size: 11px;
    text-transform: uppercase;
    border: 1px solid #0f172a;
  }

  .pdf-items-table td {
    padding: 11px 10px;
    font-size: 12.5px;
    color: #0f172a;
    border: 1px solid #cbd5e1;
    background: #ffffff !important;
  }

  .pdf-item-sub {
    font-size: 11px;
    color: #64748b;
    margin-top: 2px;
  }

  .pdf-summary-row {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 14px;
    margin-bottom: 18px;
    align-items: stretch;
  }

  .pdf-notes-box {
    background: #f8fafc !important;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 12px;
    color: #334155;
  }

  .pdf-total-card {
    background: #f0fdf4 !important;
    border: 2px solid #5be318;
    border-radius: 8px;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .pdf-total-line {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #334155;
    padding-bottom: 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid #bbf7d0;
  }

  .pdf-total-grand {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
  }

  .pdf-total-grand span {
    font-size: 12px;
    font-weight: 700;
    color: #166534;
  }

  .pdf-total-grand strong {
    font-size: 22px;
    font-weight: 800;
    color: #15803d;
  }

  .pdf-terms {
    background: #f8fafc !important;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 26px;
  }

  .pdf-terms ul {
    padding-left: 16px;
    font-size: 11.5px;
    color: #475569;
    line-height: 1.55;
  }

  .pdf-sign-footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    margin-top: 22px;
    text-align: center;
    font-size: 11.5px;
    color: #334155;
  }

  .pdf-sign-line {
    border-top: 1px solid #64748b;
    margin-bottom: 6px;
  }
}

/* ==================== RESPONSIVO ==================== */
@media (max-width: 980px) {
  .login-screen { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .nav-links { flex-direction: row; flex-wrap: wrap; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-calc, .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
