:root {
  --sun: #f4a21c;
  --sun-dark: #e18b00;
  --sky: #1e6fb6;
  --sky-dark: #0b4f86;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --text: #1a2433;
  --muted: #5c6c7e;
  --line: #e6edf3;
  --accent: #1e6fb6;
  --accent-2: #f4a21c;
  --success: #1f9d55;
  --warning: #f59e0b;
  --danger: #e11d48;
  --shadow: 0 10px 30px rgba(10, 30, 60, 0.12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Montserrat", "Source Sans 3", Arial, sans-serif;
}

a { color: var(--accent); text-decoration: none; }

a:hover { text-decoration: underline; }

.container {
  width: min(1180px, 92%);
  margin: 0 auto;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: var(--shadow);
}

.btn:hover { transform: translateY(-1px); }

.btn.secondary {
  background: #fff;
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: none;
}

.btn.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
  box-shadow: none;
}

.badge {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #eef5fb;
  color: var(--accent);
}

.badge.success { background: #e8f7ee; color: var(--success); }
.badge.success { border: 1px solid #176f3e; }
.badge.status { border: 1px solid #2b3445; }
.badge.status.warning { border: 1px solid #b45309; }
.badge.status.danger { border: 1px solid #9f1239; }
.badge.status.success { border: 1px solid #166534; }
.badge.warning { background: #fff4e6; color: var(--warning); }
.badge.danger { background: #ffe8ee; color: var(--danger); }

.card {
  background: var(--panel);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 20px; }
.grid-5 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }

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

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

.table th { color: var(--muted); font-weight: 700; }

.table tr.selected {
  background: #fff0d2;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 24, 40, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 2000;
}

canvas#faturas-chart {
  width: 100%;
  max-width: 100%;
  display: block;
}

.modal.open { display: flex; }

.invoice-sheet {
  width: min(900px, 96%);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 30px 60px rgba(0,0,0,0.25);
  overflow: hidden;
  border: 1px solid #e3eef9;
}

.invoice-header {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 20px;
  padding: 24px 28px 10px;
  border-bottom: 2px solid #e3eef9;
}

.invoice-title {
  font-size: 40px;
  font-weight: 700;
  margin: 0;
}

.invoice-tag {
  display: inline-block;
  padding: 6px 14px;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 1px;
  font-weight: 700;
}

.invoice-body { padding: 18px 28px; }

.invoice-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}

.invoice-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.invoice-table th, .invoice-table td {
  border-bottom: 1px solid #e3eef9;
  padding: 10px 12px;
}

.invoice-table th {
  background: #f1f7ff;
  text-align: left;
}

.invoice-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f6fbff;
  padding: 12px 14px;
  border-radius: 10px;
  font-weight: 700;
}

.invoice-total.total-strong {
  border: 2px solid #1e6fb6;
  background: #eef6ff;
}

.invoice-mini {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  background: #eef6ff;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid #d4e6f7;
  font-size: 13px;
}

.vencimento-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid #1e6fb6;
  background: #f1f7ff;
  font-weight: 700;
  color: #0b4f86;
}

.total-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid #0b4f86;
  background: #e9f2ff;
  font-weight: 700;
  color: #0b4f86;
}

.modal-close {
  position: absolute;
  right: 24px;
  top: 20px;
  background: #fff;
  border: 1px solid #d7e5f4;
  width: 48px;
  height: 48px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
  font-size: 20px;
}

.print-btn {
  margin-top: 10px;
}

@media print {
  body * { visibility: hidden; }
  .invoice-sheet, .invoice-sheet * { visibility: visible; }
  .invoice-sheet { position: absolute; left: 0; top: 0; width: 100%; box-shadow: none; border: none; }
  .modal-close, .print-btn { display: none; }
  .modal { background: transparent; }
}

.alert {
  padding: 14px 16px;
  border-radius: 12px;
  background: #fff8e6;
  border: 1px solid #ffe2a8;
  color: #8a5b00;
  margin-bottom: 16px;
}

input, select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  font-family: inherit;
}

label { font-size: 13px; color: var(--muted); display: block; margin-bottom: 6px; }

.form-row { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }

.hero {
  padding: 70px 0;
  background: radial-gradient(circle at top right, rgba(244,162,28,0.2), transparent 50%),
              radial-gradient(circle at 10% 20%, rgba(30,111,182,0.2), transparent 45%);
}

.login-full {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top right, rgba(244,162,28,0.25), transparent 50%),
              radial-gradient(circle at 10% 20%, rgba(30,111,182,0.2), transparent 45%);
  padding: 20px;
}

.login-card {
  width: min(520px, 94%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
}

.navbar .links { display: flex; gap: 18px; align-items: center; }

.dashboard {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #0e2d4f;
  color: #d4e6f7;
  padding: 20px 14px;
  box-shadow: inset -1px 0 0 rgba(255,255,255,0.06), 6px 0 20px rgba(2, 10, 28, 0.35);
}

.sidebar .logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.sidebar .logo img { width: 42px; }

.sidebar .nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #d4e6f7;
  padding: 9px 10px;
  border-radius: 10px;
  margin-bottom: 6px;
  font-size: 13px;
}

.sidebar .nav-item .nav-ico {
  width: 22px;
  text-align: center;
  opacity: 0.95;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar .nav-item .nav-ico svg {
  width: 16px;
  height: 16px;
  fill: #cfe3f7;
}

.sidebar .nav-item.active, .sidebar .nav-item:hover {
  background: rgba(244,162,28,0.12);
  color: #fff;
}

.main {
  padding: 24px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

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

.stat {
  padding: 16px;
  border-radius: 14px;
  background: #f1f7ff;
  border: 1px solid #dce9f6;
}

.footer {
  padding: 30px 0 40px;
  text-align: center;
  color: var(--muted);
  margin-top: auto;
}

@media (max-width: 900px) {
  .dashboard { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 10; }
  .form-row, .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
