@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/inter-latin-400-normal.woff2') format('woff2');
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/inter-latin-500-normal.woff2') format('woff2');
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/inter-latin-600-normal.woff2') format('woff2');
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/inter-latin-700-normal.woff2') format('woff2');
}

:root {
  --bg: #0a0a0a;
  --card: #161616;
  --border: #222222;
  --input-bg: #111111;
  --red: #cc0000;
  --red-hover: #aa0000;
  --white: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.5);
  --green: #2ecc71;
  --yellow: #e6b800;
  --gray: #8a8a8a;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at top right, rgba(204, 0, 0, 0.16), transparent 55%),
    radial-gradient(circle at bottom left, rgba(204, 0, 0, 0.14), transparent 55%);
  background-attachment: fixed;
  background-repeat: no-repeat;
  color: var(--white);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

.icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.icon-hidden {
  display: none;
}

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 200px;
  flex-shrink: 0;
  background: rgba(17, 17, 17, 0.8);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
}

.sidebar-brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 28px 22px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand .brand-logo {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: var(--white);
}

.sidebar-brand .brand-logo .plus {
  color: var(--red);
  font-weight: 800;
}

.sidebar-brand .brand-tag {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-secondary);
}

.sidebar-nav {
  flex: 1;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px 12px 11px;
  border-left: 3px solid transparent;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  cursor: pointer;
}

.sidebar-nav a:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--white);
}

.sidebar-nav a.active {
  background: rgba(255, 255, 255, 0.06);
  border-left-color: var(--red);
  color: var(--white);
}

.sidebar-nav a.active .icon {
  color: var(--red);
}

.sidebar-footer {
  padding: 18px 14px;
  border-top: 1px solid var(--border);
}

.logout-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  transition: border-color 0.15s, color 0.15s;
}

.logout-btn:hover {
  border-color: var(--red);
  color: var(--white);
}

/* Main content */
.main-content {
  margin-left: 200px;
  flex: 1;
  padding: 32px 36px;
  width: calc(100% - 200px);
  position: relative;
}

.app-section {
  display: none;
}

.app-section.active {
  display: block;
  animation: sectionFadeIn 150ms ease;
}

@keyframes sectionFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Spinner */
.spinner-overlay {
  position: fixed;
  inset: 0;
  margin-left: 200px;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 10, 0.5);
  z-index: 50;
}

.spinner-overlay.show {
  display: flex;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h2 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.page-header p {
  margin: 6px 0 0;
  color: var(--text-secondary);
  font-size: 13.5px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 14px;
  line-height: 1;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s, border-color 0.15s;
}

.btn-primary {
  background: rgba(204, 0, 0, 0.15);
  border: 1px solid rgba(204, 0, 0, 0.4);
  color: var(--red);
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-weight: 500;
}

.btn-primary:hover {
  background: rgba(204, 0, 0, 0.25);
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--white);
}

.btn-secondary:hover {
  border-color: var(--white);
}

.btn-danger {
  background: transparent;
  border: 1px solid var(--red);
  color: var(--red);
}

.btn-danger:hover {
  background: var(--red);
  color: var(--white);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 12px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Cards / KPIs */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.kpi-grid-3 { grid-template-columns: repeat(3, 1fr); }

.card {
  background: rgba(22, 22, 22, 0.6);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 20px;
}

.kpi-card .kpi-label {
  color: var(--text-secondary);
  font-size: 12.5px;
  margin-bottom: 10px;
}

.kpi-card .kpi-value {
  font-size: 28px;
  font-weight: 700;
}

.kpi-card.alert {
  border-color: rgba(204, 0, 0, 0.35);
}

.kpi-card.alert .kpi-value {
  color: var(--red);
}

.kpi-value-green { color: var(--green); }
.kpi-value-red { color: var(--red); }

.section-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
}

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

thead th {
  text-align: left;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.empty-row td {
  text-align: center;
  color: var(--text-secondary);
  padding: 24px;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.badge-ativo { background: rgba(46, 204, 113, 0.15); color: var(--green); }
.badge-vencido { background: rgba(204, 0, 0, 0.18); color: var(--red); }
.badge-inativo { background: rgba(138, 138, 138, 0.18); color: var(--gray); }
.badge-pendente { background: rgba(230, 184, 0, 0.18); color: var(--yellow); }
.badge-pago { background: rgba(46, 204, 113, 0.15); color: var(--green); }
.badge-entrada { background: rgba(46, 204, 113, 0.15); color: var(--green); }
.badge-saida { background: rgba(204, 0, 0, 0.18); color: var(--red); }

/* Forms */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.form-group.full {
  grid-column: 1 / -1;
}

.form-group-inline {
  flex-direction: row;
  align-items: center;
}

label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--red);
}

input, select, textarea {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--white);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
}

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

textarea {
  resize: vertical;
  min-height: 70px;
}

.password-field {
  position: relative;
  display: flex;
}

.password-field input {
  width: 100%;
  padding-right: 42px;
}

.password-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  border-radius: var(--radius-sm);
}

.password-toggle:hover {
  color: var(--white);
}

/* Toolbar */
.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}

.toolbar input, .toolbar select {
  min-width: 160px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

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

.modal {
  background: rgba(22, 22, 22, 0.75);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

/* Alerts / toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--red);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 14px 18px;
  color: var(--white);
  font-size: 14px;
  z-index: 2000;
  max-width: 320px;
  display: none;
}

.toast.show {
  display: block;
}

.toast.success {
  border-left-color: var(--green);
}

.form-error {
  color: var(--red);
  font-size: 13px;
  min-height: 18px;
}

/* Login page */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: rgba(22, 22, 22, 0.55);
  -webkit-backdrop-filter: blur(28px);
  backdrop-filter: blur(28px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 36px;
  width: 100%;
  max-width: 380px;
}

.login-card .brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 28px;
}

.login-card .brand-logo {
  font-size: 24px;
  font-weight: 700;
  color: var(--white);
}

.login-card .brand-logo .plus {
  color: var(--red);
  font-weight: 800;
}

.login-card .brand-tag {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.login-card p.subtitle {
  color: var(--text-secondary);
  font-size: 13px;
  margin: 10px 0 0;
  text-align: center;
}

.login-card .btn-primary {
  width: 100%;
  justify-content: center;
  margin-top: 6px;
}

.text-muted { color: var(--text-secondary); }
.text-right { text-align: right; }

.label-inline { margin: 0; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mb-14 { margin-bottom: 14px; }

@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .section-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .sidebar {
    width: 72px;
  }
  .sidebar-brand .brand-tag, .sidebar-nav a span.label, .logout-btn span.label {
    display: none;
  }
  .sidebar-brand .brand-logo {
    font-size: 16px;
  }
  .sidebar-nav a, .logout-btn {
    justify-content: center;
  }
  .main-content {
    margin-left: 72px;
    width: calc(100% - 72px);
    padding: 20px 16px;
  }
  .spinner-overlay {
    margin-left: 72px;
  }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
}
