:root {
  --yellow: #f4c928;
  --yellow-dark: #d8ad00;
  --ink: #202124;
  --muted: #74777d;
  --line: #e9e9e6;
  --bg: #f7f7f5;
  --white: #fff;
  --green: #16845b;
  --red: #d94b4b;
  --shadow: 0 8px 28px rgba(28,29,31,.045);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
.app { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 248px;
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 26px 18px;
  display: flex;
  flex-direction: column;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 9px 34px; }
.brand-mark {
  height: 39px; width: 39px; border-radius: 12px;
  background: var(--yellow); display: grid; place-items: center;
  font-weight: 900; font-size: 20px; letter-spacing: -2px;
}
.brand-name { font-size: 16px; font-weight: 850; letter-spacing: -.5px; }
.brand-name span {
  display: block; color: #858585; font-size: 10px;
  font-weight: 650; letter-spacing: 2px; margin-top: 2px;
}
.nav-label {
  font-size: 10px; font-weight: 800; letter-spacing: 1.6px;
  color: #a2a2a2; padding: 0 12px; margin: 0 0 10px;
}
.nav { display: grid; gap: 5px; }
.nav button {
  border: 0; background: transparent; color: #73757a;
  display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 12px; border-radius: 10px; font-size: 13px;
  font-weight: 650; transition: .18s;
}
.nav button:hover { background: #f7f7f4; color: var(--ink); }
.nav button.active { background: #fff7d6; color: #2b2b25; }
.nav button.active .nav-icon { background: var(--yellow); }
.nav-icon {
  height: 27px; width: 27px; border-radius: 8px;
  background: #f2f2ef; display: grid; place-items: center;
  font-size: 14px; color: #343434;
}
.side-bottom { margin-top: auto; }
.demo-note {
  padding: 14px; border: 1px solid #eee7c7;
  background: #fffdf3; border-radius: 12px;
  font-size: 11px; line-height: 1.6; color: #77715b;
}
.demo-note strong { display: block; color: #5c501f; font-size: 12px; margin-bottom: 4px; }
.profile { display: flex; align-items: center; gap: 10px; padding: 19px 8px 0; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: #252525; color: var(--yellow);
  display: grid; place-items: center; font-size: 11px; font-weight: 800;
}
.profile strong { display: block; font-size: 12px; }
.profile small { display: block; color: #929292; font-size: 10px; margin-top: 3px; }

.main { margin-left: 248px; padding: 30px 36px 45px; max-width: 1600px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 30px; }
.eyebrow { font-size: 10px; letter-spacing: 1.8px; text-transform: uppercase; color: #989898; font-weight: 800; margin-bottom: 8px; }
.page-title { font-size: 27px; letter-spacing: -1.1px; margin: 0; font-weight: 800; }
.page-sub { font-size: 12px; color: var(--muted); margin-top: 7px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.period-select, .secondary-btn {
  border: 1px solid var(--line); background: #fff;
  padding: 10px 12px; border-radius: 9px; font-size: 12px; color: #555;
}
.primary-btn {
  border: 0; background: var(--yellow); color: #242424;
  font-size: 12px; font-weight: 800; padding: 11px 15px;
  border-radius: 9px; box-shadow: 0 3px 0 #d9b31d; transition: .15s;
}
.primary-btn:hover { transform: translateY(-1px); filter: brightness(.98); }
.section { display: none; animation: fade .2s ease; }
.section.active { display: block; }
@keyframes fade {
  from { opacity: .5; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.welcome {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--yellow); padding: 22px 24px; border-radius: 16px;
  margin-bottom: 20px; overflow: hidden; position: relative;
}
.welcome:after {
  content: "K"; position: absolute; right: 22%; top: -43px;
  font-size: 150px; font-weight: 950; color: rgba(255,255,255,.22); line-height: 1;
}
.welcome h2 { font-size: 18px; margin: 0 0 7px; letter-spacing: -.5px; }
.welcome p { margin: 0; font-size: 12px; color: #65551b; }
.welcome-tag {
  position: relative; z-index: 1; background: rgba(255,255,255,.52);
  border: 1px solid rgba(255,255,255,.65); border-radius: 9px;
  padding: 9px 12px; font-size: 10px; font-weight: 800; white-space: nowrap;
}

.metrics { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 14px; margin-bottom: 20px; }
.metric, .panel { background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.metric { padding: 18px; }
.metric-top { display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: #7e7e7e; font-weight: 650; }
.metric-icon {
  width: 31px; height: 31px; border-radius: 9px; background: #fff7d6;
  display: grid; place-items: center; color: #7c6500; font-size: 15px;
}
.metric-value { font-size: 23px; font-weight: 850; letter-spacing: -.8px; margin: 16px 0 7px; white-space: nowrap; }
.metric-foot { font-size: 10px; color: #8b8b8b; }
.positive { color: var(--green); }
.negative { color: var(--red); }

.grid-two { display: grid; grid-template-columns: minmax(0,1.55fr) minmax(270px,1fr); gap: 16px; margin-bottom: 18px; }
.panel { padding: 20px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 19px; }
.panel-title { font-size: 14px; font-weight: 800; letter-spacing: -.2px; }
.panel-desc { font-size: 10px; color: #999; margin-top: 5px; }
.legend { display: flex; gap: 14px; font-size: 10px; color: #777; }
.legend span { display: flex; align-items: center; gap: 5px; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.chart-wrap { height: 220px; width: 100%; position: relative; }
.chart-wrap svg { width: 100%; height: 100%; overflow: visible; }
.chart-grid { stroke: #eee; stroke-width: 1; stroke-dasharray: 3 4; }
.chart-label { fill: #999; font-size: 10px; }
.chart-line { fill: none; stroke: var(--yellow-dark); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.chart-area { fill: url(#areaFill); }

.bar-chart { display: flex; align-items: end; justify-content: space-around; height: 190px; padding: 12px 4px 0; gap: 12px; }
.bar-col { height: 100%; flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 8px; min-width: 0; }
.bar-pair { height: calc(100% - 18px); display: flex; align-items: end; gap: 4px; width: 100%; justify-content: center; }
.bar { width: min(22px,40%); border-radius: 5px 5px 2px 2px; min-height: 3px; }
.bar.income { background: var(--yellow); }
.bar.expense { background: #dcdedb; }
.bar-label { font-size: 10px; color: #999; }

.category-list { display: grid; gap: 16px; }
.category-row { display: grid; grid-template-columns: 30px minmax(0,1fr) auto; align-items: center; gap: 10px; }
.category-icon { width: 30px; height: 30px; border-radius: 9px; background: #f5f5f2; display: grid; place-items: center; font-size: 13px; }
.category-name { font-size: 11px; font-weight: 700; }
.category-meta { font-size: 10px; color: #9a9a9a; margin-top: 4px; }
.category-amount { font-size: 11px; font-weight: 750; }
.progress { height: 5px; background: #f0f0ed; border-radius: 20px; margin-top: 8px; overflow: hidden; }
.progress span { height: 100%; display: block; border-radius: 20px; background: var(--yellow); }

.table-panel { padding: 0; overflow: hidden; }
.table-panel .panel-head { padding: 20px 20px 0; }
.table-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search { border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; font-size: 11px; outline: none; min-width: 180px; }
.search:focus, input:focus, select:focus { border-color: #d8b72c; box-shadow: 0 0 0 3px rgba(244,201,40,.13); outline: none; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; background: #fafaf8; color: #a0a0a0; font-size: 9px; letter-spacing: .7px; text-transform: uppercase; padding: 13px 20px; font-weight: 800; white-space: nowrap; }
td { padding: 14px 20px; border-top: 1px solid #f0f0ed; font-size: 11px; white-space: nowrap; }
tbody tr:hover { background: #fffdf5; }
.desc-cell { display: flex; align-items: center; gap: 10px; font-weight: 750; }
.tx-icon { height: 29px; width: 29px; border-radius: 9px; background: #f5f5f2; display: grid; place-items: center; }
.pill { font-size: 9px; padding: 5px 8px; border-radius: 20px; background: #f3f3f0; color: #777; display: inline-block; }
.pill.income { background: #e7f6ee; color: #188257; }
.pill.expense { background: #fff0ee; color: #c44a42; }
.amount-income { color: var(--green); font-weight: 800; }
.amount-expense { color: #333; font-weight: 800; }
.actions { display: flex; gap: 5px; }
.icon-btn { border: 1px solid #eee; background: white; border-radius: 7px; padding: 6px 8px; color: #777; font-size: 11px; }
.icon-btn:hover { background: #fff7d6; color: #222; }
.empty { text-align: center; padding: 30px; color: #999; font-size: 12px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters select { border: 1px solid var(--line); border-radius: 8px; padding: 9px; background: white; font-size: 11px; color: #555; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.field { display: grid; gap: 7px; }
.field label { font-size: 11px; font-weight: 750; color: #555; }
.field input, .field select { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 9px; background: white; font-size: 12px; color: #333; }
.field.full { grid-column: 1/-1; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.budget-list { display: grid; gap: 14px; }
.budget-card { padding: 17px; border: 1px solid var(--line); border-radius: 12px; }
.budget-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.budget-head strong { font-size: 12px; }
.budget-numbers { font-size: 11px; color: #777; margin-top: 12px; display: flex; justify-content: space-between; }
.budget-progress { height: 8px; background: #f0f0ed; border-radius: 20px; overflow: hidden; margin-top: 10px; }
.budget-progress span { display: block; height: 100%; background: var(--yellow); border-radius: 20px; }
.budget-progress span.over { background: var(--red); }
.report-summary { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; margin-bottom: 16px; }
.report-card { padding: 17px; background: #fafaf7; border-radius: 11px; }
.report-card span { font-size: 10px; color: #888; }
.report-card strong { display: block; font-size: 19px; margin-top: 8px; letter-spacing: -.5px; }

.toast {
  position: fixed; right: 22px; bottom: 22px; background: #252525; color: white;
  padding: 13px 17px; border-radius: 10px; font-size: 12px;
  box-shadow: 0 8px 28px #0002; z-index: 30; opacity: 0;
  transform: translateY(8px); pointer-events: none; transition: .2s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20,20,20,.38);
  display: none; align-items: center; justify-content: center;
  padding: 20px; z-index: 20;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: #fff; width: min(520px,100%); border-radius: 16px;
  padding: 24px; box-shadow: 0 20px 60px #0002; max-height: 90vh; overflow: auto;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-head h2 { margin: 0; font-size: 18px; }
.close-btn { border: 0; background: #f3f3f0; border-radius: 8px; width: 31px; height: 31px; font-size: 18px; }
.mobile-menu { display: none; }
.footer-note { text-align: center; color: #aaa; font-size: 10px; padding: 25px 0 0; }
.footer-note strong { color: #777; }
.small-muted { font-size: 10px; color: #999; }
.report-actions { display: flex; gap: 8px; flex-wrap: wrap; }

@media (max-width: 1150px) {
  .main { padding: 26px 24px; }
  .metrics { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .grid-two { grid-template-columns: 1fr; }
  .sidebar { width: 220px; }
  .main { margin-left: 220px; }
}

@media (max-width: 700px) {
  .sidebar {
    width: 265px; transform: translateX(-100%); transition: transform .22s;
    box-shadow: 12px 0 35px #0000000d;
  }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; padding: 19px 14px 30px; }
  .mobile-menu {
    display: grid; place-items: center; border: 1px solid var(--line);
    background: white; width: 38px; height: 38px; border-radius: 10px; font-size: 18px;
  }
  .topbar { align-items: flex-start; margin-bottom: 21px; }
  .topbar-left { display: flex; gap: 10px; align-items: flex-start; }
  .page-title { font-size: 22px; }
  .page-sub { max-width: 230px; line-height: 1.5; }
  .top-actions { gap: 6px; }
  .top-actions .period-select { max-width: 120px; padding: 9px 7px; }
  .top-actions .primary-btn { padding: 10px; }
  .welcome { padding: 18px; align-items: flex-start; gap: 12px; }
  .welcome h2 { font-size: 16px; }
  .welcome-tag { font-size: 9px; padding: 7px; }
  .welcome:after { right: 4%; font-size: 110px; top: -20px; }
  .metrics { gap: 9px; }
  .metric { padding: 14px; }
  .metric-value { font-size: 19px; }
  .metric-top { font-size: 10px; gap: 6px; }
  .metric-icon { height: 27px; width: 27px; }
  .metric-foot { font-size: 9px; }
  .panel { padding: 15px; }
  .grid-two { gap: 12px; }
  .chart-wrap { height: 190px; }
  .panel-head { margin-bottom: 15px; }
  .table-panel { padding: 0; }
  .table-panel .panel-head { padding: 16px 15px 0; }
  .table-scroll { overflow-x: auto; }
  table { min-width: 650px; }
  .table-tools { width: 100%; }
  .search { min-width: 0; flex: 1; }
  .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .report-summary { grid-template-columns: 1fr; }
  .top-actions .secondary-btn { display: none; }
}

@media (max-width: 390px) {
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric-value { font-size: 17px; }
  .welcome-tag { display: none; }
  .page-title { font-size: 20px; }
  .top-actions .period-select { max-width: 105px; font-size: 10px; }
}

/* ==========================================
   KOMPANY FINANCE — TELA DE LOGIN
   ========================================== */

#financeLogin {
  position: fixed;
  inset: 0;
  z-index: 9999;

  display: flex;
  align-items: center;
  justify-content: center;

  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  box-sizing: border-box;
  overflow-y: auto;

  padding: 32px 20px;
  background: #f5f5f2;
  color: #20211f;

  font-family: inherit;
}

#financeLogin[hidden] {
  display: none !important;
}

.finance-login-card {
  width: 100%;
  max-width: 440px;
  box-sizing: border-box;

  padding: 42px 36px;
  background: #ffffff;
  border: 1px solid #e8e8e3;
  border-radius: 18px;

  box-shadow: 0 18px 55px rgba(25, 25, 20, 0.08);
}

.finance-login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 42px;
}

.finance-login-mark {
  display: flex;
  align-items: center;
  justify-content: center;

  width: 46px;
  height: 46px;
  flex-shrink: 0;

  border-radius: 12px;
  background: #f4c928;
  color: #20211f;

  font-size: 25px;
  font-weight: 900;
  letter-spacing: -2px;
}

.finance-login-brand-name {
  display: flex;
  flex-direction: column;
  gap: 3px;

  color: #20211f;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 1.5px;
}

.finance-login-brand-name span {
  color: #8b8b83;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 4px;
}

.finance-login-eyebrow {
  margin-bottom: 10px;
  color: #9a7b00;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 2px;
  text-align: center;
}

#financeLoginTitle {
  margin: 0;
  color: #20211f;
  font-size: 29px;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.8px;
  text-align: center;
}

.finance-login-subtitle {
  margin: 12px 0 30px;
  color: #777870;
  font-size: 14px;
  line-height: 1.7;
  text-align: center;
}

#financeLoginForm {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  margin: 0;
}

.finance-login-field {
  display: flex;
  flex-direction: column;
  gap: 9px;
  width: 100%;
}

.finance-login-field label {
  color: #33342f;
  font-size: 13px;
  font-weight: 700;
}

.finance-login-field input {
  width: 100%;
  min-width: 0;
  height: 49px;
  box-sizing: border-box;

  padding: 0 14px;
  border: 1px solid #dedfd8;
  border-radius: 9px;
  outline: none;

  background: #fbfbf9;
  color: #20211f;

  font-family: inherit;
  font-size: 14px;

  transition: border-color 0.2s, box-shadow 0.2s;
}

.finance-login-field input::placeholder {
  color: #a0a097;
}

.finance-login-field input:focus {
  border-color: #d8b20e;
  box-shadow: 0 0 0 3px rgba(244, 201, 40, 0.18);
}

.finance-password-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.finance-password-wrap input {
  padding-right: 84px;
}

.finance-toggle-password {
  position: absolute;
  right: 12px;

  padding: 6px 4px;
  border: 0;
  background: transparent;
  color: #6d5a00;

  font-family: inherit;
  font-size: 12px;
  font-weight: 800;

  cursor: pointer;
}

.finance-toggle-password:hover {
  color: #20211f;
}

.finance-login-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;

  width: 100%;
  min-height: 51px;
  margin-top: 4px;
  padding: 12px 18px;

  border: 0;
  border-radius: 9px;
  background: #f4c928;
  color: #20211f;

  font-family: inherit;
  font-size: 14px;
  font-weight: 800;

  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

.finance-login-submit:hover {
  background: #e8bc12;
  transform: translateY(-1px);
}

.finance-login-submit:focus-visible,
.finance-toggle-password:focus-visible {
  outline: 3px solid rgba(190, 150, 0, 0.4);
  outline-offset: 3px;
}

.finance-login-error {
  margin: -5px 0 0;
  padding: 11px 12px;

  border: 1px solid #f1c5c5;
  border-radius: 8px;
  background: #fff2f2;
  color: #a42c2c;

  font-size: 12px;
  line-height: 1.5;
}

.finance-login-error[hidden] {
  display: none !important;
}

.finance-login-footnote {
  margin-top: 30px;
  padding-top: 19px;
  border-top: 1px solid #eeeeea;

  color: #999a92;
  font-size: 11px;
  line-height: 1.6;
  text-align: center;
}

/* Mantém a plataforma escondida antes do login */
#financeApp {
  display: none;
}

/* Responsividade para celulares */
@media (max-width: 480px) {
  #financeLogin {
    align-items: center;
    padding: 20px 14px;
  }

  .finance-login-card {
    max-width: 100%;
    padding: 32px 22px;
    border-radius: 15px;
  }

  .finance-login-brand {
    margin-bottom: 32px;
  }

  #financeLoginTitle {
    font-size: 25px;
  }

  .finance-login-subtitle {
    font-size: 13px;
  }
}

/* Acessibilidade: respeita preferência por menos animações */
@media (prefers-reduced-motion: reduce) {
  .finance-login-field input,
  .finance-login-submit {
    transition: none;
  }
}