/* ERP — Spa Bruna Passaura */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600&family=Instrument+Sans:wght@400;500;600&display=swap');

:root {
  --paper: #F6F4EF;
  --card: #FFFFFF;
  --ink: #1F2421;
  --ink-2: #5C645E;
  --pine: #21332C;
  --pine-2: #2C443A;
  --brass: #A8854B;
  --brass-soft: #EFE6D6;
  --line: #E4E1D8;
  --pos: #2E7D5B;
  --pos-soft: #E4F0EA;
  --neg: #B5472E;
  --neg-soft: #F7E7E2;
  --warn: #B07C2A;
  --warn-soft: #F6EEDC;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(31,36,33,.06), 0 4px 14px rgba(31,36,33,.05);
  --display: 'Fraunces', Georgia, serif;
  --body: 'Instrument Sans', system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: var(--body); background: var(--paper); color: var(--ink); font-size: 14px; }
.num { font-variant-numeric: tabular-nums; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ---- Layout ---- */
.layout { display: grid; grid-template-columns: 218px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--pine); color: #E9EDE8; padding: 22px 14px;
  display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh;
}
.brand { font-family: var(--display); font-size: 19px; font-weight: 600; color: #fff; padding: 2px 10px 4px; letter-spacing: .2px; }
.brand small { display: block; font-family: var(--body); font-weight: 400; font-size: 11px; color: #A8B5AC; letter-spacing: .14em; text-transform: uppercase; margin-top: 3px; }
.sidebar hr { border: none; border-top: 1px solid rgba(255,255,255,.12); margin: 14px 6px; }
.nav-label { font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: #8FA095; padding: 10px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  color: #CBD4CC; text-decoration: none; font-weight: 500; font-size: 13.5px;
}
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav a.active { background: var(--pine-2); color: #fff; box-shadow: inset 2px 0 0 var(--brass); }
.nav a .ico { width: 17px; text-align: center; opacity: .85; }
.sidebar .foot { margin-top: auto; font-size: 11px; color: #7E8F84; padding: 0 10px; }

.main { padding: 0 28px 48px; min-width: 0; }

/* ---- Topbar com régua de equilíbrio ---- */
.topbar {
  display: flex; align-items: center; gap: 22px; padding: 16px 0 14px;
  border-bottom: 1px solid var(--line); margin-bottom: 22px; flex-wrap: wrap;
}
.topbar h1 { font-family: var(--display); font-size: 24px; font-weight: 600; }
.gauge { flex: 1; min-width: 260px; }
.gauge .g-head { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--ink-2); margin-bottom: 5px; }
.gauge .g-head b { color: var(--ink); }
.gauge .g-bar { height: 7px; background: #E9E5DA; border-radius: 99px; overflow: hidden; position: relative; }
.gauge .g-fill { height: 100%; background: linear-gradient(90deg, var(--brass), #C8A56A); border-radius: 99px; transition: width .6s ease; }
.gauge .g-fill.ok { background: linear-gradient(90deg, var(--pos), #4BA37E); }
.topbar .mes-sel { display: flex; align-items: center; gap: 8px; }
.topbar input[type="month"], .topbar select {
  border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 7px 10px;
}

/* ---- Cards ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 22px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.card .c-label { font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); margin-bottom: 6px; }
.card .c-value { font-family: var(--display); font-size: 24px; font-weight: 600; }
.card .c-sub { font-size: 12px; color: var(--ink-2); margin-top: 4px; }
.card.pos .c-value { color: var(--pos); }
.card.neg .c-value { color: var(--neg); }
.card.warn .c-value { color: var(--warn); }

/* ---- Painéis / tabelas ---- */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 22px; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-head h2 { font-family: var(--display); font-size: 17px; font-weight: 600; }
.panel-body { padding: 16px 18px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 12px; border-bottom: 1px solid #EFEDE6; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #FBFAF6; }
td.r, th.r { text-align: right; }
.muted { color: var(--ink-2); }
.small { font-size: 12px; }

/* ---- Pills / badges ---- */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; padding: 3px 10px; border-radius: 99px; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--pos-soft); color: var(--pos); }
.pill.pend { background: var(--warn-soft); color: var(--warn); }
.pill.late { background: var(--neg-soft); color: var(--neg); }
.tag { font-size: 11.5px; background: var(--brass-soft); color: #7A6234; border-radius: 6px; padding: 2px 8px; }

/* ---- Botões ---- */
.btn { border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 8px; padding: 8px 14px; font-weight: 500; font-size: 13.5px; }
.btn:hover { border-color: #CFCBBE; background: #FBFAF6; }
.btn.primary { background: var(--pine); border-color: var(--pine); color: #fff; }
.btn.primary:hover { background: var(--pine-2); }
.btn.brass { background: var(--brass); border-color: var(--brass); color: #fff; }
.btn.brass:hover { filter: brightness(1.05); }
.btn.sm { padding: 4px 10px; font-size: 12.5px; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { color: var(--ink); background: #F1EFE8; }
.btn.danger { color: var(--neg); }
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--brass); outline-offset: 1px; }

/* ---- Filtros ---- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filters input, .filters select { border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: #fff; }
.filters input[type="search"] { min-width: 200px; }

/* ---- Modal ---- */
.overlay { position: fixed; inset: 0; background: rgba(31,36,33,.45); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; z-index: 50; overflow: auto; }
.modal { background: var(--card); border-radius: 14px; width: 100%; max-width: 620px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px 0; }
.modal-head h3 { font-family: var(--display); font-size: 19px; font-weight: 600; }
.modal-body { padding: 16px 22px 22px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 12px; font-weight: 500; color: var(--ink-2); margin-bottom: 5px; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; background: #fff; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 0 22px 22px; }
.hint { font-size: 12px; color: var(--ink-2); background: var(--brass-soft); border-radius: 8px; padding: 10px 12px; margin-top: 10px; }

/* ---- DRE ---- */
.dre-table th, .dre-table td { padding: 7px 10px; font-size: 13px; }
.dre-table .grp td { font-weight: 600; background: #F4F1E9; border-top: 1px solid var(--line); }
.dre-table .tot td { font-weight: 600; background: var(--pine); color: #fff; }
.dre-table .sub td { font-weight: 600; background: #ECE8DC; }
.dre-table td.cat { padding-left: 24px; cursor: pointer; }
.dre-table td.cat:hover { color: var(--brass); }
.dre-table .det td { background: #FBFAF6; font-size: 12.5px; }
.dre-table .det td.cat { padding-left: 42px; color: var(--ink-2); cursor: default; }
.neg-v { color: var(--neg); }
.pos-v { color: var(--pos); }

/* ---- Gráfico SVG ---- */
.chart-wrap { overflow-x: auto; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--ink-2); padding: 4px 0 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ---- Toast ---- */
#toast { position: fixed; bottom: 24px; right: 24px; background: var(--pine); color: #fff; padding: 12px 18px; border-radius: 10px; box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); transition: .25s; z-index: 99; font-size: 13.5px; }
#toast.show { opacity: 1; transform: none; }

/* ---- Grupos de vencimento ---- */
.due-group { font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2); padding: 14px 12px 6px; }
.due-group.late { color: var(--neg); }

/* ---- Usuário na sidebar ---- */
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 10px; margin-top: 8px;
  border-top: 1px solid rgba(255,255,255,.1);
}
.su-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--brass); color: #fff; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; letter-spacing: .04em;
}
.su-info { flex: 1; min-width: 0; }
.su-name { font-size: 13px; font-weight: 600; color: #E9EDE8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.su-perfil { font-size: 10.5px; color: #8FA095; text-transform: capitalize; letter-spacing: .08em; }
.su-logout {
  background: none; border: none; color: #8FA095; cursor: pointer;
  padding: 4px; border-radius: 6px; display: flex; align-items: center;
  flex-shrink: 0;
}
.su-logout:hover { color: #E9EDE8; background: rgba(255,255,255,.08); }

/* ---- Tela de login ---- */
.login-screen {
  position: fixed; inset: 0;
  background: var(--paper);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 200; padding: 20px; gap: 20px;
}
.login-card {
  width: 100%; max-width: 420px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 4px 6px rgba(31,36,33,.04), 0 12px 48px rgba(31,36,33,.11);
  overflow: hidden;
}
.login-brand {
  background: var(--pine); color: #fff;
  display: flex; align-items: center; gap: 16px;
  padding: 26px 30px;
}
.login-logo {
  width: 48px; height: 48px;
  background: var(--brass); border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display); font-size: 19px; font-weight: 600;
  color: #fff; letter-spacing: .04em; flex-shrink: 0;
}
.login-brand .login-title {
  font-family: var(--display); font-size: 20px; font-weight: 600; line-height: 1.2;
}
.login-brand .login-sub {
  font-size: 11px; color: #A8B5AC;
  text-transform: uppercase; letter-spacing: .16em; margin-top: 4px;
}
.login-body { padding: 30px 30px 34px; }
.login-desc { font-size: 13.5px; color: var(--ink-2); margin-bottom: 24px; }
.pass-wrap { position: relative; }
.pass-wrap input { padding-right: 40px; }
.pass-toggle {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: var(--ink-2);
  padding: 2px; display: flex; align-items: center;
}
.pass-toggle:hover { color: var(--ink); }
.login-error {
  background: var(--neg-soft); color: var(--neg);
  border-radius: 8px; padding: 10px 14px;
  font-size: 13.5px; margin-top: 14px;
}
.login-footer { font-size: 12px; color: var(--ink-2); }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .sidebar .foot, .sidebar hr, .nav-label, .sidebar-user { display: none; }
  .nav { display: flex; flex-wrap: wrap; }
  .main { padding: 0 14px 40px; }
  .form-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
