:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #172033;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #111827;
  --primary-2: #263244;
  --green: #16875c;
  --green-bg: #e8f7ef;
  --yellow: #9a6a00;
  --yellow-bg: #fff6d6;
  --orange: #b85000;
  --orange-bg: #fff0df;
  --red: #c62828;
  --red-bg: #ffebeb;
  --blue: #2463a5;
  --blue-bg: #eaf3ff;
  --shadow: 0 14px 42px rgba(17,24,39,.08);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { font-size: 11px; font-weight: 800; letter-spacing: .13em; color: #8a93a3; }

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 0%, #334155, #111827 48%, #090d16 100%); }
.auth-card { width: min(430px, 100%); background: rgba(255,255,255,.98); border-radius: 24px; padding: 34px; box-shadow: 0 30px 80px rgba(0,0,0,.28); }
.auth-card h1 { margin: 8px 0 6px; font-size: 30px; }
.brand-mark { width: 54px; height: 54px; border-radius: 17px; display: grid; place-items: center; background: #111827; color: white; font-size: 20px; font-weight: 900; letter-spacing: -.04em; margin-bottom: 22px; }
.brand-mark.small { width: 38px; height: 38px; border-radius: 12px; margin: 0; font-size: 14px; letter-spacing: -.03em; }

.stack { display: flex; flex-direction: column; }
.gap-14 { gap: 14px; }
label { display: flex; flex-direction: column; gap: 7px; font-size: 12px; font-weight: 700; color: #475569; }
input, select, textarea { width: 100%; border: 1px solid #d8dde6; border-radius: 11px; padding: 11px 12px; outline: none; color: var(--text); background: white; transition: border-color .15s, box-shadow .15s; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #7c899d; box-shadow: 0 0 0 3px rgba(71,85,105,.10); }
.form-error { margin-top: 14px; padding: 10px 12px; border-radius: 10px; color: var(--red); background: var(--red-bg); font-size: 13px; }

.btn { border: 0; border-radius: 11px; padding: 11px 15px; font-weight: 800; color: #374151; background: #edf0f4; }
.btn:hover { filter: brightness(.98); }
.btn:disabled { opacity: .55; cursor: wait; }
.btn-primary { background: var(--primary); color: white; }
.btn-success { background: var(--green); color: white; }
.btn-light { background: #f3f4f6; color: #374151; border: 1px solid #e5e7eb; }
.btn-block { width: 100%; margin-top: 6px; }
.btn-small { padding: 8px 11px; font-size: 12px; }

.topbar { height: 66px; background: rgba(255,255,255,.94); backdrop-filter: blur(14px); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar-inner { max-width: 1500px; height: 100%; margin: 0 auto; padding: 0 24px; display: flex; align-items: center; justify-content: space-between; }
.brand-inline { display: flex; gap: 11px; align-items: center; }
.brand-inline strong, .brand-inline span { display: block; }
.brand-inline strong { font-size: 15px; }
.brand-inline span { font-size: 11px; color: var(--muted); margin-top: 2px; }
.user-area { display: flex; align-items: center; gap: 8px; position: relative; }
.icon-btn, .user-chip { border: 0; background: #f4f5f7; border-radius: 10px; padding: 8px 10px; color: #475569; font-size: 12px; font-weight: 700; }
.user-chip { display: flex; align-items: center; gap: 8px; }
.user-chip > span:first-child { width: 25px; height: 25px; border-radius: 8px; background: #111827; color: white; display: grid; place-items: center; font-size: 11px; }
.menu { position: absolute; right: 0; top: 46px; width: 170px; background: white; padding: 7px; border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); z-index: 60; }
.menu button { width: 100%; border: 0; background: transparent; padding: 10px; border-radius: 8px; text-align: left; font-weight: 700; color: #475569; }
.menu button:hover { background: #f5f6f8; }
.danger-text { color: var(--red) !important; }

.page { max-width: 1500px; margin: 0 auto; padding: 30px 24px 50px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.page-head h2 { margin: 4px 0; font-size: 29px; letter-spacing: -.025em; }
.page-head p { margin: 0; font-size: 13px; }

.dashboard-grid { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 12px; margin-bottom: 16px; }
.metric-card { text-align: left; padding: 17px; min-height: 112px; background: white; border: 1px solid var(--border); border-radius: 15px; box-shadow: 0 3px 12px rgba(17,24,39,.025); color: var(--text); }
.metric-card:hover { transform: translateY(-1px); box-shadow: 0 7px 18px rgba(17,24,39,.06); }
.metric-label { display: block; color: #7b8493; font-weight: 700; font-size: 12px; margin-bottom: 12px; }
.metric-card strong { display: block; font-size: 20px; letter-spacing: -.02em; }
.metric-card small { display: block; margin-top: 7px; color: var(--muted); }
.metric-today { border-top: 3px solid #ef4444; }
.metric-soon { border-top: 3px solid #f59e0b; }
.metric-overdue { border-top: 3px solid #b91c1c; }
.metric-paid { border-top: 3px solid #16a34a; }

.panel { background: white; border: 1px solid var(--border); border-radius: 15px; }
.filters-panel { padding: 14px; margin-bottom: 16px; }
.filters-grid { display: grid; grid-template-columns: 2fr repeat(2, minmax(130px,1fr)) auto; gap: 11px; align-items: end; }
.filter-clear { height: 41px; }
.table-panel { overflow: hidden; }
.table-head { min-height: 57px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.table-head > div { display: flex; align-items: baseline; gap: 8px; }
.table-head strong { font-size: 14px; }
.table-head span { font-size: 12px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 880px; }
th { text-align: left; padding: 11px 14px; background: #fafbfc; color: #7b8493; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid #eef0f3; font-size: 12px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fcfcfd; }
.amount-cell { font-weight: 900; font-size: 13px; white-space: nowrap; }
.due-main { font-weight: 800; display: block; white-space: nowrap; }
.due-sub { font-size: 10px; color: var(--muted); display: block; margin-top: 3px; }
.desc-main { font-weight: 800; max-width: 280px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.desc-sub { color: var(--muted); font-size: 10px; margin-top: 3px; display: block; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 999px; font-size: 10px; font-weight: 900; white-space: nowrap; }
.status-pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-green { color: var(--green); background: var(--green-bg); }
.status-yellow { color: var(--yellow); background: var(--yellow-bg); }
.status-orange { color: var(--orange); background: var(--orange-bg); }
.status-red { color: var(--red); background: var(--red-bg); }
.status-blue { color: var(--blue); background: var(--blue-bg); }
.status-gray { color: #6b7280; background: #f0f1f3; }
.row-actions { display: flex; gap: 5px; justify-content: flex-end; }
.row-actions button { border: 1px solid var(--border); background: white; border-radius: 8px; padding: 6px 8px; font-size: 10px; font-weight: 800; color: #475569; }
.row-actions .pay-action { color: var(--green); border-color: #ccebdd; background: #f7fdfa; }
.row-actions .cancel-action { color: #a33; }
.empty-state { padding: 60px 20px; display: flex; align-items: center; flex-direction: column; gap: 7px; color: var(--muted); }
.empty-state strong { color: var(--text); }
.empty-icon { width: 43px; height: 43px; display: grid; place-items: center; border-radius: 50%; background: #eef7f2; color: var(--green); font-weight: 900; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(8,14,24,.45); backdrop-filter: blur(2px); z-index: 70; }
.modal { position: fixed; inset: 0; display: grid; place-items: center; padding: 20px; z-index: 80; pointer-events: none; }
.modal-card { width: min(470px, 100%); max-height: calc(100vh - 40px); overflow: auto; background: white; border-radius: 18px; padding: 20px; box-shadow: 0 24px 70px rgba(0,0,0,.25); pointer-events: auto; }
.modal-wide { width: min(760px, 100%); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; }
.modal-head h3 { margin: 3px 0 0; font-size: 21px; }
.close-btn { border: 0; background: #f2f3f5; border-radius: 9px; width: 34px; height: 34px; font-size: 22px; color: #6b7280; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.span-2 { grid-column: span 2; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }
.pay-summary { border: 1px solid var(--border); border-radius: 12px; padding: 14px; background: #fafbfc; }
.pay-summary strong { display: block; margin-bottom: 4px; }
.pay-summary span { color: var(--muted); font-size: 12px; }

.drawer { position: fixed; top: 0; right: 0; width: min(430px, 92vw); height: 100vh; background: white; box-shadow: -16px 0 48px rgba(0,0,0,.16); z-index: 90; padding: 20px; overflow: auto; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; padding-bottom: 15px; border-bottom: 1px solid var(--border); }
.drawer-head h3 { margin: 3px 0; }
.history-list { padding-top: 8px; }
.history-item { display: grid; grid-template-columns: 34px 1fr; gap: 10px; padding: 13px 0; border-bottom: 1px solid #eef0f3; }
.history-badge { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: #f1f3f5; font-size: 11px; font-weight: 900; }
.history-item strong { display: block; font-size: 12px; }
.history-item span { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; }

.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 120; padding: 11px 15px; border-radius: 11px; background: #111827; color: white; box-shadow: 0 12px 28px rgba(0,0,0,.22); font-size: 12px; font-weight: 700; }
.toast.error { background: #a91f1f; }

@media (max-width: 1050px) {
  .dashboard-grid { grid-template-columns: repeat(3, 1fr); }
  .filters-grid { grid-template-columns: 2fr 1fr 1fr; }
  .filter-clear { grid-column: auto; }
}
@media (max-width: 720px) {
  .topbar-inner, .page { padding-left: 14px; padding-right: 14px; }
  .topbar { height: 61px; }
  .brand-inline span { display: none; }
  #historyBtn { font-size: 0; padding: 8px 9px; }
  #historyBtn::after { content: "Hist."; font-size: 11px; }
  #userName { display: none; }
  .page { padding-top: 20px; }
  .page-head { align-items: center; }
  .page-head h2 { font-size: 25px; }
  .page-head .btn { padding: 10px 12px; font-size: 12px; }
  .dashboard-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .metric-card { min-height: 102px; padding: 14px; }
  .metric-card strong { font-size: 17px; }
  .metric-card:last-child { grid-column: span 2; }
  .filters-grid { grid-template-columns: 1fr 1fr; }
  .search-field, .filter-clear { grid-column: span 2; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .modal { padding: 9px; align-items: end; }
  .modal-card { width: 100%; max-height: 92vh; border-radius: 19px 19px 10px 10px; }
  .table-panel { border-radius: 13px; }
}

/* v1.1 — usuários e anexos */
.field-help { font-size: 10px; font-weight: 500; color: var(--muted); }
.attachment-link { display: inline-flex; align-items: center; gap: 4px; text-decoration: none; color: var(--blue); font-weight: 800; white-space: nowrap; }
.attachment-current { border: 1px solid var(--border); background: #fafbfc; border-radius: 12px; padding: 12px 13px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.attachment-current > div:first-child { min-width: 0; }
.attachment-current strong { display: block; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attachment-current span { display: block; color: var(--muted); font-size: 10px; margin-top: 3px; }
.attachment-actions { display: flex; gap: 7px; flex: 0 0 auto; }
.panel-soft { border: 1px solid var(--border); background: #fafbfc; border-radius: 14px; padding: 14px; }
.users-layout { display: grid; gap: 16px; }
.user-form > strong { display: block; margin-bottom: 12px; }
.compact-grid { align-items: end; }
.check-label { flex-direction: row; align-items: center; gap: 8px; min-height: 41px; }
.check-label input { width: auto; }
.compact-actions { margin-top: 12px; }
.section-title-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin: 3px 0 8px; }
.section-title-row span { font-size: 10px; }
.users-list { border: 1px solid var(--border); border-radius: 13px; overflow: hidden; }
.user-list-item { display: grid; grid-template-columns: 36px minmax(0,1fr) auto; align-items: center; gap: 10px; padding: 11px 12px; border-bottom: 1px solid #eef0f3; background: white; }
.user-list-item:last-child { border-bottom: 0; }
.user-list-item.inactive { opacity: .58; background: #fafafa; }
.user-avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: #111827; color: white; font-weight: 900; font-size: 12px; }
.user-list-main { min-width: 0; }
.user-list-main strong { display: block; font-size: 12px; }
.user-list-main span { display: block; color: var(--muted); font-size: 10px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 720px) {
  .attachment-current { align-items: flex-start; flex-direction: column; }
  .section-title-row { align-items: flex-start; flex-direction: column; gap: 2px; }
  .user-list-item { grid-template-columns: 34px minmax(0,1fr) auto; }
}

/* v1.2 — AJ Guinchos */
.brand-inline strong { letter-spacing: -.01em; }

/* v1.3 — notificações push */
.push-panel { margin-bottom: 16px; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-color: #cfdcf0; background: linear-gradient(135deg,#fff,#f5f9ff); }
.push-copy { display: flex; align-items: center; gap: 11px; min-width: 0; }
.push-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; background: #e8f1ff; font-size: 18px; flex: 0 0 auto; }
.push-copy strong { display: block; font-size: 13px; }
.push-copy span { display: block; color: var(--muted); font-size: 11px; margin-top: 3px; line-height: 1.4; }
.push-actions { display: flex; align-items: center; justify-content: flex-end; gap: 7px; flex-wrap: wrap; }
.push-status { font-size: 11px; font-weight: 800; color: #6b7280; margin-right: 3px; }
.push-status.on { color: var(--green); }
.push-status.off { color: var(--orange); }
.push-status.error { color: var(--red); }
@media (max-width: 720px) {
  .push-panel { align-items: flex-start; flex-direction: column; }
  .push-actions { width: 100%; justify-content: flex-start; }
  .push-actions .btn { width: auto; }
  .push-status { width: 100%; }
}


/* v4.12 — contas recorrentes */
.page-head-actions { display: flex; align-items: center; gap: 9px; }
.modal-subtitle { margin: 6px 0 0; color: var(--muted); font-size: 11px; max-width: 520px; }
.recurring-layout { display: grid; gap: 18px; }
.recurring-note { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: #f7f8fa; color: var(--muted); font-size: 10px; line-height: 1.45; }
.recurring-list { border: 1px solid var(--border); border-radius: 13px; overflow: hidden; }
.recurring-item { display: grid; grid-template-columns: 62px minmax(0,1fr) auto; gap: 12px; align-items: center; padding: 12px; background: white; border-bottom: 1px solid #eef0f3; }
.recurring-item:last-child { border-bottom: 0; }
.recurring-item.inactive { opacity: .62; background: #fafafa; }
.recurring-date { width: 58px; min-height: 52px; border-radius: 12px; background: #f2f4f7; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.recurring-date strong { font-size: 18px; line-height: 1; }
.recurring-date span { font-size: 9px; color: var(--muted); margin-top: 5px; }
.recurring-main { min-width: 0; }
.recurring-main > strong { display: block; font-size: 12px; }
.recurring-main > span { display: block; color: var(--muted); font-size: 10px; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recurring-main > em { display: block; font-style: normal; font-size: 9px; font-weight: 800; margin-top: 5px; }
.active-text { color: var(--green); }
.recurring-actions { display: flex; gap: 6px; }
.recurring-empty { padding: 24px 16px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 5px; color: var(--muted); }
.recurring-empty strong { color: var(--text); font-size: 12px; }
.recurring-empty span { font-size: 10px; }
.recurring-mini { display: inline-block; margin-left: 4px; padding: 2px 5px; border-radius: 999px; background: #eef2ff; color: #4f46e5; font-size: 8px; font-weight: 900; vertical-align: 1px; }

@media (max-width: 720px) {
  .page-head-actions { gap: 6px; }
  .page-head-actions .btn { padding: 10px 10px; }
  .recurring-item { grid-template-columns: 52px minmax(0,1fr); align-items: start; }
  .recurring-date { width: 50px; min-height: 48px; }
  .recurring-actions { grid-column: 2; justify-content: flex-start; }
}
