/* Kikizé - Sistema de Controle de Fluxo de Caixa
   Implementa os tokens do design system (design_system/design-system.html):
   shell escuro/claro, cores semânticas, tipografia Inter/Roboto. */

:root {
  --bg: #f5f8fb;
  --sidebar: #0c213a;
  --card: #ffffff;
  --table-head: #f1f5fa;
  --border: #eceff5;
  --text-body: #303e67;
  --text-muted: #a4abc5;
  --dark: #1d2c48;
  --primary: #1761fd;
  --success: #03d87f;
  --warning: #ffb822;
  --danger: #f5325c;
  --info: #12a4ed;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, Helvetica, Arial, sans-serif;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-body);
  background: var(--bg);
}

h1, h2, h3, h4, h5, h6, .page-title, .card-title, .login-card h1 {
  font-family: 'Roboto', -apple-system, Helvetica, Arial, sans-serif;
}

a { color: var(--primary); }

.icon { width: 18px; height: 18px; flex-shrink: 0; }
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 24px; height: 24px; }

/* ---------- Shell ---------- */
.app-shell { min-height: 100vh; }

.sidebar {
  width: 250px;
  background: var(--sidebar);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 1000;
  transition: transform .3s ease;
}
.sidebar .brand {
  height: 74px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar .brand .icon { color: var(--primary); }
.sidebar nav ul { list-style: none; margin: 0; padding: 12px 0; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 20px; margin: 1px 0;
  color: #c2cbe2; text-decoration: none;
  font-size: 13px; font-weight: 500;
  border-left: 3px solid transparent;
  transition: all .3s ease-out;
}
.sidebar nav a:hover { color: #fff; background: rgba(255,255,255,.06); }
.sidebar nav a.active {
  color: #fff; background: rgba(23,97,253,.15); border-left-color: var(--primary);
}

.main-wrapper { margin-left: 250px; min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  height: 74px; background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; position: sticky; top: 0; z-index: 900;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.menu-toggle {
  display: none; background: none; border: none; cursor: pointer;
  color: var(--text-body); padding: 6px;
}

.page-content { padding: 24px; flex: 1; width: 100%; }

.page-title-box {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}
.page-title { font-size: 20px; font-weight: 600; color: var(--dark); margin: 0; }
.breadcrumb { font-size: 12px; font-weight: 500; color: var(--text-muted); margin: 4px 0 0; padding: 0; list-style: none; display: flex; gap: 4px; }
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb .active { color: var(--text-body); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Cards / KPIs ---------- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 2px 4px rgba(31,30,47,.04); margin-bottom: 24px;
}
.card-body { padding: 20px; }
.card-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
}
.card-title { font-size: 14px; font-weight: 500; margin: 0; color: var(--dark); }

.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 24px; }
@media (max-width: 1100px) { .kpi-row { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 576px) { .kpi-row { grid-template-columns: 1fr; } }

.kpi-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  padding: 18px 20px; display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 2px 4px rgba(31,30,47,.04);
}
.kpi-label { font-size: 12px; font-weight: 600; color: var(--text-body); margin: 0 0 6px; }
.kpi-value { font-size: 20px; font-weight: 600; color: var(--dark); margin: 0; }
.kpi-icon {
  width: 42px; height: 42px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); color: var(--text-muted);
}
.kpi-icon .icon { width: 20px; height: 20px; }
.kpi-icon.success { background: rgba(3,216,127,.12); color: var(--success); }
.kpi-icon.danger { background: rgba(245,50,92,.12); color: var(--danger); }
.kpi-icon.primary { background: rgba(23,97,253,.12); color: var(--primary); }
.kpi-icon.warning { background: rgba(255,184,34,.15); color: #946200; }

/* ---------- Tabelas ---------- */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.table thead th {
  background: var(--table-head); color: var(--text-body); font-weight: 600;
  text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border);
  font-size: 11px; text-transform: uppercase; letter-spacing: .3px; white-space: nowrap;
}
table.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.table tbody tr:hover { background: #fbfcfe; }
table.table tbody tr.row-overdue { background: rgba(245,50,92,.04); }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 4px 9px; font-size: 11px; font-weight: 600; border-radius: 4px; line-height: 1.4; white-space: nowrap; }
.badge-pill { border-radius: 10px; }
.badge-success { background: var(--success); color: #fff; }
.badge-danger { background: var(--danger); color: #fff; }
.badge-warning { background: var(--warning); color: #1d2c48; }
.badge-primary { background: var(--primary); color: #fff; }
.badge-soft-success { background: rgba(3,216,127,.12); color: #037a57; }
.badge-soft-danger { background: rgba(245,50,92,.12); color: #a91d3a; }
.badge-soft-warning { background: rgba(255,184,34,.18); color: #946200; }
.badge-soft-primary { background: rgba(23,97,253,.12); color: var(--primary); }
.badge-soft-secondary { background: var(--border); color: var(--text-muted); }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px;
  font-size: 13px; font-weight: 500; border-radius: 5px; border: 1px solid transparent;
  cursor: pointer; text-decoration: none; transition: all .15s ease; background: #fff; color: var(--text-body);
}
.btn .icon { width: 15px; height: 15px; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: #0f52e0; }
.btn-outline-primary { border-color: var(--primary); color: var(--primary); background: #fff; }
.btn-outline-primary:hover { background: var(--primary); color: #fff; }
.btn-outline-light { border-color: var(--border); color: var(--text-body); background: #fff; }
.btn-outline-light:hover { background: var(--bg); }
.btn-outline-danger { border-color: var(--danger); color: var(--danger); background: #fff; }
.btn-outline-danger:hover { background: var(--danger); color: #fff; }
.btn-soft-primary { background: rgba(23,97,253,.1); color: var(--primary); border-color: transparent; }
.btn-soft-primary:hover { background: rgba(23,97,253,.18); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-icon { padding: 7px; }

/* ---------- Formulários ---------- */
form .form-group { margin-bottom: 16px; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--text-body); margin-bottom: 6px; }
.form-control, .login-card input[type="text"], .login-card input[type="password"] {
  width: 100%; padding: 8px 12px; font-size: 13px; border: 1px solid var(--border);
  border-radius: 5px; background: #fff; color: var(--text-body); font-family: inherit;
}
.form-control:focus, .login-card input:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(23,97,253,.12);
}
textarea.form-control { resize: vertical; }
.form-check { display: flex; align-items: center; gap: 8px; }
.form-check input { width: 16px; height: 16px; }
.form-text { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.errorlist { color: var(--danger); font-size: 12px; margin: 4px 0 0; padding: 0; list-style: none; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }
.radio-option { display: flex; align-items: flex-start; gap: 10px; padding: 12px; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 8px; cursor: pointer; }
.radio-option:hover { background: var(--bg); }
.radio-option input { margin-top: 3px; }

.filters-bar { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; margin-bottom: 16px; }
.filters-bar .form-group { margin-bottom: 0; min-width: 150px; }

.bulk-action-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  padding: 10px 16px; margin-bottom: 16px;
}
.bulk-action-bar .js-bulk-count { font-size: 12px; font-weight: 600; margin-right: auto; }

/* Conciliação lado a lado */
.recon-action-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  padding: 10px 16px; margin-bottom: 16px;
  position: sticky; top: 74px; z-index: 500;
}
.recon-pair-info { display: flex; align-items: center; gap: 10px; margin-right: auto; font-size: 13px; }
.recon-split { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
@media (max-width: 768px) {
  .recon-split { grid-template-columns: 1fr; }
  .recon-action-bar { top: 0; }
}
.recon-list { display: flex; flex-direction: column; gap: 8px; }
.recon-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 6px;
  cursor: pointer; transition: all .15s ease; background: #fff;
}
.recon-row:hover { background: #fbfcfe; border-color: #d6e0ee; }
.recon-row:focus { outline: none; border-color: var(--primary); }
.recon-row.selected { border-color: var(--primary); background: rgba(23,97,253,.06); box-shadow: 0 0 0 1px var(--primary); }
.recon-row.amount-match { border-color: var(--success); }
.recon-row.amount-match .recon-row-title { color: #037a57; }
.recon-row-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.recon-row-title { font-size: 13px; font-weight: 600; color: var(--dark); }
.recon-row-sub { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.recon-row-action { flex-shrink: 0; }

.money-input { position: relative; }
.money-input::before {
  content: 'R$'; position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: 13px; pointer-events: none;
}
.money-input .form-control { padding-left: 36px; }

/* Resumo da seleção (Planejamento): fica no topo da tabela e gruda abaixo
   da topbar ao rolar, mantendo Total selecionado / Saldo restante sempre
   visíveis enquanto o usuário marca as contas. */
.selection-summary {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  padding: 14px 20px; margin-bottom: 16px;
  position: sticky; top: 74px; z-index: 500;
}
@media (max-width: 576px) {
  .selection-summary { grid-template-columns: 1fr; gap: 8px; top: 0; }
}

/* ---------- Alertas / mensagens ---------- */
.alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 12px; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.alert-success { background: rgba(3,216,127,.1); color: #037a57; border: 1px solid rgba(3,216,127,.25); }
.alert-error, .alert-danger { background: rgba(245,50,92,.1); color: #a91d3a; border: 1px solid rgba(245,50,92,.25); }
.alert-warning { background: rgba(255,184,34,.15); color: #946200; border: 1px solid rgba(255,184,34,.3); }
.alert-info { background: rgba(18,164,237,.1); color: #0c6f9e; border: 1px solid rgba(18,164,237,.25); }

.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state .icon { width: 32px; height: 32px; margin-bottom: 10px; }

/* ---------- Login ---------- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--sidebar); padding: 20px; }
.login-card { background: #fff; border-radius: 10px; padding: 36px; width: 100%; max-width: 380px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.login-card h1 { font-size: 20px; font-weight: 600; margin: 0 0 4px; color: var(--dark); }
.login-card p.sub { color: var(--text-muted); font-size: 13px; margin: 0 0 24px; }
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; color: var(--primary); font-weight: 600; }

/* ---------- Dropdown / menu do usuário ---------- */
.user-menu { position: relative; }
.user-menu summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.user-menu summary::-webkit-details-marker { display: none; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 8px); background: #fff;
  border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 3px 12px #d6e4f1;
  min-width: 190px; padding: 6px 0; z-index: 1100;
}
.dropdown-menu a, .dropdown-menu button {
  display: flex; width: 100%; align-items: center; gap: 8px; padding: 9px 16px;
  font-size: 13px; color: var(--text-body); text-decoration: none;
  background: none; border: none; text-align: left; cursor: pointer;
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--bg); }

.avatar-circle {
  width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; flex-shrink: 0;
}

/* ---------- Utilitários ---------- */
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: #946200 !important; }
.text-muted { color: var(--text-muted) !important; }
.text-primary { color: var(--primary) !important; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mb-0 { margin-bottom: 0 !important; }
.mt-2 { margin-top: 8px; }
.d-flex { display: flex; }
.gap-2 { gap: 8px; }
.align-center { align-items: center; }
.font-weight-bold { font-weight: 600; }

.overlay { position: fixed; inset: 0; background: rgba(12,33,58,.4); z-index: 999; display: none; }
.overlay.show { display: block; }

@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .menu-toggle { display: inline-flex; }
}
