:root {
  --bg: #12141a;
  --surface: #1b1e26;
  --surface-alt: #22262f;
  --border: #2e333d;
  --text: #e5e7eb;
  --text-muted: #9aa1ad;
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --danger: #f87171;
  --success: #4ade80;
  --warning: #fbbf24;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.navbar {
  background: #0b0d11;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 56px;
  border-bottom: 1px solid var(--border);
}

.navbar .brand {
  font-weight: 700;
  color: #fff;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  height: 28px;
  width: auto;
}

.login-logo {
  display: block;
  height: 48px;
  width: auto;
  margin: 0 auto 16px;
}

.navbar nav {
  display: flex;
  gap: 4px;
  align-items: center;
}

.navbar nav a {
  color: #aeb4c0;
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 13px;
}

.navbar nav a:hover, .navbar nav a.active {
  background: var(--surface-alt);
  color: #fff;
  text-decoration: none;
}

.navbar .user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #9299a6;
  font-size: 13px;
}

.navbar form { margin: 0; }

.navbar button.link-btn {
  background: none;
  border: none;
  color: #9299a6;
  cursor: pointer;
  font-size: 13px;
  padding: 4px 8px;
}
.navbar button.link-btn:hover { color: #fff; }

.container {
  max-width: 1200px;
  margin: 24px auto;
  padding: 0 20px;
}

.page-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}

.page-title h1 { font-size: 20px; margin: 0; color: var(--text); }

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

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

th {
  background: var(--surface-alt);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.03em;
}

tbody tr:hover { background: var(--surface-alt); }

.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mono { font-variant-numeric: tabular-nums; }

.positivo { color: var(--success); }
.negativo { color: var(--danger); }
.positivo a, .negativo a { color: inherit; }

form.inline { display: inline; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--text-muted); font-weight: 600; }

input, select, textarea {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  background: var(--surface-alt);
  color: var(--text);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
}

input::placeholder, textarea::placeholder { color: var(--text-muted); }

/* Navegadores escurecem o seletor nativo de data/hora por padrão em temas claros;
   força o ícone a inverter para ficar visível no tema escuro. */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
}

.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }

.btn-secondary {
  background: var(--surface-alt);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--border); }

.btn-danger {
  background: var(--surface-alt);
  color: var(--danger);
  border-color: var(--danger);
}
.btn-danger:hover { background: #3a2020; }

.btn-sm { padding: 4px 10px; font-size: 12px; }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-aberto { background: #4c1d1d; color: #fca5a5; }
.badge-parcial { background: #4a3512; color: #fcd34d; }
.badge-devolvido { background: #123a22; color: #86efac; }

.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
}
.alert-error { background: #3a1d1d; color: #fca5a5; border: 1px solid #5c2626; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
}

.login-card h1 { font-size: 18px; margin: 0 0 20px; text-align: center; color: var(--text); }
.login-card .field { margin-bottom: 14px; }
.login-card .btn { width: 100%; margin-top: 6px; }

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

.grid-table { table-layout: auto; }
.grid-table td, .grid-table th { text-align: center; white-space: nowrap; }
.grid-table td.dia-label, .grid-table th.dia-label {
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
  min-width: 140px;
  position: sticky;
  left: 0;
  background: var(--surface);
  z-index: 1;
}
.grid-table tr:nth-child(even) td.dia-label { background: var(--surface); }
.grid-table td.zero { color: #545b68; }

.pd-row { display: grid; grid-template-columns: 2fr 1fr auto; gap: 8px; margin-bottom: 8px; align-items: center; }

.summary-box {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.summary-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.summary-item .label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; margin-bottom: 4px; }
.summary-item .value { font-size: 18px; font-weight: 700; color: var(--text); }

.recibo-paper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 640px;
  margin: 0 auto;
}
.recibo-paper h1 { text-align: center; font-size: 18px; margin-bottom: 4px; color: var(--text); }
.recibo-paper .subtitle { text-align: center; color: var(--text-muted); margin-bottom: 24px; font-size: 13px; }
.recibo-linha { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.assinatura { margin-top: 60px; text-align: center; }
.assinatura .linha { border-top: 1px solid var(--text); width: 260px; margin: 0 auto 6px; }

.relatorio-header {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}
.relatorio-header img {
  height: 50px;
  width: auto;
}

.print-only { display: none; }
.page-break {
  page-break-after: always;
  break-after: page;
}
.page-break-avoid {
  page-break-inside: avoid;
  break-inside: avoid;
}

@media print {
  @page { size: portrait; margin: 10mm; }
  @page wide { size: landscape; margin: 10mm; }
  body.print-landscape { page: wide; }
  .no-print { display: none !important; }
  .print-only { display: block !important; }
  body { background: #fff; color: #000; }
  .container { margin: 0; max-width: none; padding: 0; }
  .card, .recibo-paper, .summary-item {
    background: #fff;
    border: none;
    box-shadow: none;
    padding: 8px 0;
    color: #000;
  }
  .card h1, .card h2, .card h3, .recibo-paper h1,
  .summary-item .value, .page-title h1, td, th {
    color: #000 !important;
  }
  th { background: #f3f4f6; }
  .text-muted { color: #555 !important; }
  .badge-aberto, .badge-parcial, .badge-devolvido { color: #000 !important; background: none !important; border: 1px solid #999; }
  .positivo { color: #166534 !important; }
  .negativo { color: #991b1b !important; }
  .positivo a, .negativo a { color: inherit !important; }
  .page-break { page-break-after: always !important; break-after: page !important; }
  .page-break-avoid { page-break-inside: avoid !important; break-inside: avoid !important; }

  .table-scroll { overflow: visible !important; width: auto !important; }
  .grid-table {
    width: 100% !important;
    table-layout: fixed !important;
    font-size: 9px !important;
  }
  .grid-table td, .grid-table th {
    padding: 3px 2px !important;
    white-space: normal !important;
    word-break: break-word !important;
  }
  .grid-table td.dia-label, .grid-table th.dia-label {
    position: static !important;
    min-width: 0 !important;
    background: #fff !important;
  }
  .grid-table tr[style*="var(--surface-alt)"] td.dia-label,
  .grid-table tr[style*="var(--surface-alt)"] td {
    background: #f3f4f6 !important;
  }
}
