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

:root {
  --brand-blue:   #1a3fa3;
  --brand-red:    #e8302a;
  --blue-dark:    #0d1f6e;
  --blue:         #1a3fa3;
  --blue-light:   #dbeafe;
  --green:        #16a34a;
  --green-light:  #dcfce7;
  --red:          #dc2626;
  --red-light:    #fee2e2;
  --yellow:       #d97706;
  --yellow-light: #fef3c7;
  --orange:       #ea580c;
  --orange-light: #ffedd5;
  --gray:         #6b7280;
  --gray-light:   #f3f4f6;
  --white:        #ffffff;
  --text:         #111827;
  --text-muted:   #6b7280;
  --border:       #e5e7eb;
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.1);
  --shadow-md:    0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg:    0 8px 24px rgba(0,0,0,0.12);
  --radius:       12px;
  --radius-sm:    8px;
  --sidebar-w:    260px;
  --transition:   all 0.2s ease;
}

html { scroll-behavior: smooth; }
body { font-family: 'Montserrat', 'Inter', sans-serif; font-size: 14px; color: var(--text); background: #f0f4f8; min-height: 100vh; }
a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

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

/* === SIDEBAR === */
.sidebar {
  width: var(--sidebar-w);
  background: var(--blue-dark);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-logo img { height: 42px; width: auto; }

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.6);
  font-weight: 500;
  font-size: 0.875rem;
  transition: var(--transition);
  border-left: 3px solid transparent;
}
.nav-item i { width: 18px; text-align: center; font-size: 0.9rem; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,0.07); color: rgba(255,255,255,0.9); border-left-color: rgba(255,255,255,0.2); }
.nav-item.active { background: rgba(232,48,42,0.15); color: white; font-weight: 600; border-left-color: var(--brand-red); }

.nav-badge {
  margin-left: auto;
  background: var(--brand-red);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 100px;
  min-width: 18px;
  text-align: center;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border-top: 1px solid rgba(255,255,255,0.08);
  margin-top: auto;
}

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 0.9rem;
  flex-shrink: 0;
}

.user-name  { display: block; color: white; font-weight: 600; font-size: 0.82rem; }
.user-pct   { display: block; color: rgba(255,255,255,0.45); font-size: 0.7rem; margin-top: 1px; }
.user-info  { flex: 1; min-width: 0; }

.logout-btn { color: rgba(255,255,255,0.35); font-size: 1.1rem; transition: var(--transition); padding: 4px; }
.logout-btn:hover { color: var(--brand-red); }

/* === MAIN CONTENT === */
.main { margin-left: var(--sidebar-w); flex: 1; padding: 32px; min-width: 0; }

/* === PAGE HEADER === */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 28px; gap: 16px; }
.page-title  { font-size: 1.5rem; font-weight: 700; color: var(--text); }
.page-sub    { color: var(--text-muted); font-size: 0.875rem; margin-top: 4px; }
.section-title-sm { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); margin-bottom: 12px; }

/* === CARDS GRID === */
.cards-grid { display: grid; gap: 16px; }
.cards-2 { grid-template-columns: repeat(2, 1fr); }
.cards-3 { grid-template-columns: repeat(3, 1fr); }
.cards-4 { grid-template-columns: repeat(4, 1fr); }

.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 20px;
  transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-capital { border-left: 4px solid var(--brand-blue); }
.card-capital-2 { border-left: 4px solid var(--brand-red); }
.card-success  { border-left: 4px solid var(--green); }
.card-danger   { border-left: 4px solid var(--red); }

.card-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; color: white;
  flex-shrink: 0;
}
.bg-blue    { background: var(--brand-blue); }
.bg-red-brand { background: var(--brand-red); }
.bg-green   { background: var(--green); }
.bg-red     { background: var(--red); }
.bg-orange  { background: var(--orange); }
.bg-yellow  { background: var(--yellow); }
.bg-gray    { background: var(--gray); }

.card-body  { flex: 1; min-width: 0; }
.card-label { font-size: 0.72rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.card-value { font-size: 1.35rem; font-weight: 700; color: var(--text); line-height: 1.2; }
.card-sub   { font-size: 0.75rem; color: var(--text-muted); margin-top: 6px; }

/* === OWNERSHIP BADGE === */
.ownership-badge { font-size: 1.4rem; font-weight: 800; color: rgba(0,0,0,0.07); align-self: center; flex-shrink: 0; letter-spacing: -1px; }
.ownership-badge-inline { display: inline-block; background: var(--blue-light); color: var(--brand-blue); font-size: 0.68rem; font-weight: 700; padding: 1px 7px; border-radius: 100px; margin-left: 6px; vertical-align: middle; }

/* === CAPITAL BAR === */
.capital-bar-wrapper { margin: 10px 0 4px; }
.capital-bar { height: 6px; background: var(--gray-light); border-radius: 3px; overflow: hidden; }
.capital-bar-fill { height: 100%; border-radius: 3px; transition: width 0.6s ease; }
.bar-green { background: var(--green); }
.bar-red   { background: var(--red); }

/* === TWO COLUMN === */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }

/* === TABLE CARD === */
.table-card, .card-table {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}

.card-table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.875rem;
}

.link-sm { font-size: 0.78rem; color: var(--brand-blue); font-weight: 600; }
.link-sm:hover { text-decoration: underline; }

/* === TABLE === */
.table { width: 100%; border-collapse: collapse; }
.table th { padding: 11px 16px; text-align: left; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); border-bottom: 2px solid var(--border); background: #fafafa; }
.table td { padding: 11px 16px; border-bottom: 1px solid var(--border); font-size: 0.875rem; }
.table tr:last-child td { border-bottom: none; }
.table-hover tr:hover td { background: #fafafa; }
.nowrap { white-space: nowrap; }

/* === BADGES === */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 100px; font-size: 0.7rem; font-weight: 700; }
.badge-lg { font-size: 0.8rem; padding: 5px 14px; }
.badge-green  { background: var(--green-light); color: var(--green); }
.badge-red    { background: var(--red-light); color: var(--red); }
.badge-yellow { background: var(--yellow-light); color: var(--yellow); }
.badge-blue   { background: var(--blue-light); color: var(--brand-blue); }
.badge-orange { background: var(--orange-light); color: var(--orange); }
.badge-gray   { background: var(--gray-light); color: var(--gray); }

/* === TAG === */
.tag { display: inline-block; background: var(--blue-light); color: var(--brand-blue); padding: 2px 8px; border-radius: 4px; font-size: 0.7rem; font-weight: 600; }

/* === BUTTONS === */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 0.875rem;
  cursor: pointer; border: none;
  transition: var(--transition); white-space: nowrap;
}
.btn-primary { background: var(--brand-blue); color: white; }
.btn-primary:hover { background: #142f80; transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-success { background: var(--green); color: white; }
.btn-success:hover { background: #15803d; }
.btn-danger  { background: var(--red); color: white; }
.btn-danger:hover  { background: #b91c1c; }
.btn-yellow  { background: var(--yellow); color: white; }
.btn-yellow:hover  { background: #b45309; }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--gray-light); }
.btn-ghost   { background: transparent; color: var(--text-muted); border: none; padding: 6px 10px; }
.btn-ghost:hover { background: var(--gray-light); }
.btn-print   { background: #475569; color: white; }
.btn-print:hover { background: #334155; }
.btn-email-send { background: #0284c7; color: white; }
.btn-email-send:hover { background: #0369a1; }
.btn-sm  { padding: 5px 12px; font-size: 0.78rem; }
.btn-full { width: 100%; justify-content: center; }

/* === FILTER TABS === */
.filter-tabs {
  display: flex; gap: 4px;
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 4px;
  margin-bottom: 20px; width: fit-content;
}
.filter-tab { padding: 7px 16px; border-radius: 6px; font-size: 0.82rem; font-weight: 500; color: var(--text-muted); transition: var(--transition); }
.filter-tab:hover { color: var(--text); background: var(--gray-light); }
.filter-tab.active { background: var(--brand-blue); color: white; font-weight: 600; }

/* === FORMS === */
.form-card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow-sm); border: 1px solid var(--border); padding: 28px; }
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.req { color: var(--brand-red); }

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; padding: 10px 14px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); background: white;
  transition: var(--transition); outline: none; appearance: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--brand-blue); box-shadow: 0 0 0 3px rgba(26,63,163,0.1); }
.form-group textarea { resize: vertical; min-height: 90px; }
.form-group select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5 7l5 5 5-5' stroke='%236b7280' fill='none' stroke-width='1.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; padding-right: 36px; }

.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.input-icon { position: relative; }
.input-icon i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.input-icon input { padding-left: 36px; }
.input-prefix { display: flex; }
.input-prefix span { padding: 10px 14px; background: var(--gray-light); border: 1.5px solid var(--border); border-right: none; border-radius: var(--radius-sm) 0 0 var(--radius-sm); color: var(--text-muted); font-weight: 600; white-space: nowrap; }
.input-prefix input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.form-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }

/* === FILE UPLOAD === */
.file-upload-area { border: 2px dashed var(--border); border-radius: var(--radius-sm); padding: 28px; text-align: center; cursor: pointer; transition: var(--transition); color: var(--text-muted); }
.file-upload-area:hover { border-color: var(--brand-blue); background: var(--blue-light); color: var(--brand-blue); }
.file-upload-area i { font-size: 1.8rem; margin-bottom: 8px; display: block; }
.file-upload-area p { font-weight: 500; font-size: 0.88rem; }
.file-upload-area small { font-size: 0.76rem; opacity: 0.7; }
.file-name-preview { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--green-light); color: var(--green); border-radius: var(--radius-sm); margin-top: 8px; font-size: 0.82rem; font-weight: 500; }

/* === ALERTS === */
.alert { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 20px; font-size: 0.88rem; }
.alert-error { background: var(--red-light); color: var(--red); border: 1px solid #fca5a5; }
.alert-success { background: var(--green-light); color: var(--green); border: 1px solid #86efac; }

.info-box { display: flex; gap: 12px; padding: 14px 16px; background: var(--blue-light); border: 1px solid #bfdbfe; border-radius: var(--radius-sm); color: var(--brand-blue); font-size: 0.85rem; line-height: 1.6; }
.info-box i { margin-top: 2px; flex-shrink: 0; }
.info-box p { flex: 1; }
.info-success { background: var(--green-light); border-color: #86efac; color: var(--green); }
.info-danger  { background: var(--red-light); border-color: #fca5a5; color: var(--red); }

/* === EMPTY STATES === */
.empty-state { padding: 24px; text-align: center; color: var(--text-muted); font-size: 0.88rem; }
.empty-state i { font-size: 1.6rem; margin-bottom: 8px; display: block; opacity: 0.4; }
.empty-box { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 60px; text-align: center; background: var(--white); border-radius: var(--radius); border: 1px solid var(--border); color: var(--text-muted); }
.empty-box i { font-size: 3rem; opacity: 0.2; }
.empty-box p { font-size: 1rem; }

/* === APPROVAL UI === */
.approval-form-card { background: var(--white); border: 2px solid var(--brand-blue); border-radius: var(--radius); padding: 24px; margin-top: 20px; }
.approval-form-card h3 { margin-bottom: 16px; color: var(--brand-blue); font-size: 1rem; }
.approval-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 16px; }
.approvals-list { display: flex; flex-direction: column; }
.approval-item { display: flex; align-items: flex-start; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.approval-item:last-child { border-bottom: none; }
.approval-avatar { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: white; font-weight: 700; font-size: 0.85rem; flex-shrink: 0; }
.approval-info { flex: 1; }
.approval-info strong { display: block; font-size: 0.9rem; margin-bottom: 2px; }
.approval-comment { font-style: italic; color: var(--text-muted); font-size: 0.82rem; margin: 4px 0; }
.approval-status { flex-shrink: 0; margin-top: 2px; }

/* === DETAIL CARD === */
.detail-card { background: var(--white); border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow-sm); padding: 24px; }
.detail-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.detail-header h2 { font-size: 1.15rem; font-weight: 700; flex: 1; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.detail-item label { display: block; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; color: var(--text-muted); margin-bottom: 4px; }
.value-big { font-size: 1.5rem; font-weight: 700; color: var(--text); }
.attachment-box { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.attachment-box label { display: block; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; color: var(--text-muted); margin-bottom: 8px; }
.attachment-img { max-height: 200px; border-radius: var(--radius-sm); border: 1px solid var(--border); object-fit: contain; }

/* === MONTH SELECTOR === */
.month-selector { display: flex; gap: 8px; margin-bottom: 24px; }
.month-selector select { padding: 8px 12px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: white; font-weight: 500; cursor: pointer; }
.month-selector select:focus { border-color: var(--brand-blue); outline: none; }

/* === FECHAMENTO MENSAL === */
.fechamento-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  border: 1px solid;
}
.fechamento-aberto {
  background: #f0fdf4;
  border-color: #86efac;
  color: var(--green);
}
.fechamento-fechado {
  background: #fef2f2;
  border-color: #fca5a5;
  color: var(--red);
}
.fechamento-info { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 0.88rem; }
.fechamento-info small { font-weight: 400; font-size: 0.78rem; opacity: 0.8; }
.fechamento-actions { display: flex; gap: 8px; }

/* === CHARTS === */
.chart-container { background: var(--white); border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow-sm); padding: 24px; }
.chart-title { font-size: 0.82rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 16px; }
.chart-wrap { position: relative; height: 220px; }

/* === REPORT ACTIONS === */
.report-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: #f8fafc;
  border-top: 1px solid var(--border);
}

/* === LOGIN PAGE === */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--blue-dark) 0%, var(--brand-blue) 100%);
  padding: 20px;
}
.login-card { background: var(--white); border-radius: 16px; padding: 40px; width: 100%; max-width: 420px; box-shadow: var(--shadow-lg); }
.login-header { text-align: center; margin-bottom: 32px; }
.login-logo-img { height: 120px; width: auto; margin: 0 auto 8px; }
.login-header p { color: var(--text-muted); font-size: 0.875rem; margin-top: 6px; }
.login-footer { margin-top: 24px; text-align: center; font-size: 0.75rem; color: var(--text-muted); border-top: 1px solid var(--border); padding-top: 16px; }

/* === COLORS === */
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-blue   { color: var(--brand-blue); }
.text-muted  { color: var(--text-muted); }

/* === PRINT HEADER (hidden on screen) === */
.print-only { display: none !important; }

/* === RESPONSIVE === */
@media (max-width: 1200px) { .cards-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 900px) { .cards-3 { grid-template-columns: 1fr 1fr; } .two-col { grid-template-columns: 1fr; } }
@media (max-width: 700px) { .sidebar { transform: translateX(-100%); } .main { margin-left: 0; padding: 16px; } .cards-3, .cards-4 { grid-template-columns: 1fr; } .form-row-2 { grid-template-columns: 1fr; } }

/* ============================================================
   WATERMARK — oculta na tela, visível apenas na impressão
   ============================================================ */
.print-watermark { display: none; }
.print-footer    { display: none; }

/* ============================================================
   PRINT STYLES
   ============================================================ */
@media print {
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }

  .sidebar,
  .page-header .btn,
  .btn-print, .btn-email-send,
  .filter-tabs,
  .month-selector,
  .fechamento-actions,
  .report-actions,
  .no-print { display: none !important; }

  .print-only { display: block !important; }

  body { background: white; font-size: 12px; }
  .layout { display: block; }
  .main { margin-left: 0; padding: 0; }

  .card, .table-card, .card-table, .detail-card {
    box-shadow: none;
    border: 1px solid #ddd;
    break-inside: avoid;
  }

  .cards-4, .cards-2, .cards-3 { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr 1fr; }

  .page-title { font-size: 1.2rem; }

  @page { margin: 20mm 15mm 22mm; size: A4; }

  /* ── Marca d'água ── */
  .print-watermark {
    display: block !important;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-30deg);
    width: 480px;
    opacity: 0.055;
    z-index: 0;
    pointer-events: none;
  }
  .print-watermark img { width: 100%; height: auto; }

  /* ── Cabeçalho de impressão ── */
  .print-header {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 14px;
    margin-bottom: 20px;
    border-bottom: 2px solid #1a3fa3;
  }
  .print-header-logo { height: 52px; width: auto; }
  .print-header-info { text-align: right; font-size: 10.5px; color: #555; line-height: 1.6; }
  .print-header-info strong { display: block; font-size: 13px; color: #1a3fa3; margin-bottom: 2px; }

  /* ── Rodapé de impressão ── */
  .print-footer {
    display: block !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px 15mm;
    background: white;
    border-top: 1.5px solid #1a3fa3;
  }
  .print-footer-line { display: none; }
  .print-footer-content {
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 9.5px;
    color: #777;
  }
  .print-footer-content strong { color: #1a3fa3; }
  .print-footer-content span + span::before {
    content: '·';
    margin-right: 16px;
    color: #ccc;
  }
}
