:root{
  --bg: #14171c;
  --bg-deep: #0f1216;
  --surface: #1c2027;
  --surface-hi: #242a33;
  --line: rgba(255,255,255,0.08);
  --line-strong: rgba(255,255,255,0.14);
  --text: #edeff1;
  --text-mut: #8b93a1;
  --text-dim: #5b6270;
  --sage: #7fa37a;
  --sage-soft: rgba(127,163,122,0.14);
  --sage-line: rgba(127,163,122,0.4);
  --sage-dark: #4f6d4c;
  --coral: #b46a5c;
  --coral-soft: rgba(180,106,92,0.14);
  --radius: 14px;
  --radius-sm: 9px;
  --serif: 'Fraunces', serif;
  --sans: 'Inter', sans-serif;
  --mono: 'IBM Plex Mono', monospace;
}
*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  background-color: var(--bg);
  background-image: radial-gradient(1200px 800px at 15% -10%, #1a1f26 0%, var(--bg) 55%);
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing:antialiased;
  display:flex;
  min-height:100vh;
}
::selection{ background: var(--sage-soft); color: var(--text); }
@media (prefers-reduced-motion: reduce){
  *{ animation-duration:0.001ms !important; transition-duration:0.001ms !important; }
}
code{ background:var(--surface-hi); padding:1px 5px; border-radius:4px; font-family:var(--mono); font-size:0.92em; }

#appShell{ display:flex; min-height:100vh; width:100%; }
.main{ flex:1; min-width:0; padding: 34px 44px 60px; }
.view{ display:none; }
.view.active{ display:block; }
.view-head{ display:flex; align-items:flex-end; justify-content:space-between; margin-bottom: 30px; gap:20px; flex-wrap:wrap; }
.eyebrow{ font-family:var(--mono); font-size:11px; letter-spacing:1.5px; text-transform:uppercase; color: var(--sage); margin:0 0 6px; }
.view-title{ font-family:var(--serif); font-size:30px; font-weight:600; margin:0; letter-spacing:-0.2px; }
.view-desc{ color:var(--text-mut); font-size:13.5px; margin-top:6px; max-width:560px; line-height:1.5; }
@media (max-width:880px){ .main{ padding:22px; } }

.btn{
  font-family: var(--sans); font-size:13px; font-weight:600; border-radius:10px;
  padding:10px 18px; border:1px solid transparent; cursor:pointer; display:inline-flex; align-items:center; gap:7px;
}
.btn-primary{ background: var(--sage); color:#0f1410; }
.btn-primary:hover{ background:#8fb389; }
.btn-ghost{ background: transparent; border-color: var(--line-strong); color: var(--text); }
.btn-ghost:hover{ border-color: var(--sage-line); color:var(--sage); }
.btn-sm{ padding:6px 12px; font-size:12px; border-radius:8px; }
.btn-block{ width:100%; justify-content:center; }
.btn[disabled]{ opacity:0.55; cursor:default; pointer-events:none; }

/* ---------- Login ---------- */
.login-screen{
  position:fixed; inset:0; z-index:200; display:flex; align-items:center; justify-content:center;
  background: radial-gradient(1200px 800px at 15% -10%, #1a1f26 0%, var(--bg) 55%); padding:20px;
}
.login-panel{
  width:100%; max-width:380px; background:var(--surface); border:1px solid var(--line-strong);
  border-radius:18px; padding:32px 30px; box-shadow:0 30px 80px rgba(0,0,0,0.45);
}
.login-brand{ display:flex; align-items:center; gap:10px; margin-bottom:22px; }
.brand-mark{
  width:30px; height:30px; border-radius:8px;
  background: linear-gradient(135deg, var(--sage) 0%, var(--sage-dark) 100%);
  display:flex; align-items:center; justify-content:center;
  font-family:var(--serif); font-weight:600; font-size:15px; color:#0f1410; flex-shrink:0;
}
.brand-name{ font-family:var(--serif); font-size:17px; font-weight:600; letter-spacing:0.2px; }
.brand-sub{ font-size:10px; color:var(--text-dim); text-transform:uppercase; letter-spacing:1.2px; margin-top:1px; }
.login-title{ font-family:var(--serif); font-size:20px; font-weight:600; margin:0 0 4px; }
.login-sub{ font-size:12.5px; color:var(--text-mut); margin:0 0 22px; line-height:1.5; }
.login-field{ margin-bottom:12px; }
.login-field label{ display:block; font-size:11px; text-transform:uppercase; letter-spacing:1px; color:var(--text-dim); margin-bottom:5px; }
.login-field input{
  width:100%; background:var(--surface-hi); border:1px solid var(--line); border-radius:9px;
  padding:10px 12px; color:var(--text); font-size:13.5px; font-family:var(--sans); outline:none; box-sizing:border-box;
}
.login-field input:focus{ border-color:var(--sage-line); }
.login-error{ background:var(--coral-soft); border:1px solid rgba(180,106,92,0.4); color:#e2a89c; font-size:12px; padding:9px 12px; border-radius:9px; margin-bottom:12px; display:none; line-height:1.4; }
.login-error.active{ display:block; }
.login-actions{ display:flex; flex-direction:column; gap:8px; margin-top:16px; }

/* ---------- Loading global ---------- */
.global-loading-overlay{
  position:fixed; inset:0; z-index:400;
  background:rgba(15,18,22,0.55); backdrop-filter:blur(2px);
  display:flex; align-items:center; justify-content:center;
  opacity:0; pointer-events:none; transition:opacity .18s ease;
}
.global-loading-overlay.active{ opacity:1; pointer-events:all; }
.global-loading-box{
  background:var(--surface); border:1px solid var(--line-strong); border-radius:14px;
  padding:20px 26px; display:flex; align-items:center; gap:14px;
  box-shadow:0 16px 44px rgba(0,0,0,0.45);
}
.global-loading-spinner{
  width:20px; height:20px; border-radius:50%; flex-shrink:0;
  border:2.5px solid var(--line-strong); border-top-color:var(--sage);
  animation: gl-spin .75s linear infinite;
}
@keyframes gl-spin{ to{ transform:rotate(360deg); } }
.global-loading-text{ font-size:13px; color:var(--text); }

/* ---------- Toasts ---------- */
.app-toast-wrap{
  position:fixed; top:22px; left:50%; transform:translateX(-50%); z-index:300;
  display:flex; flex-direction:column; gap:8px; align-items:center; pointer-events:none;
}
.app-toast{
  background:var(--surface-hi); border:1px solid var(--line-strong); border-radius:12px;
  padding:11px 18px; font-size:12.5px; color:var(--text); box-shadow:0 14px 34px rgba(0,0,0,0.4);
  max-width:440px; text-align:center; line-height:1.4;
  opacity:0; transform:translateY(-10px); transition:opacity .22s ease, transform .22s ease;
  pointer-events:auto;
}
.app-toast.show{ opacity:1; transform:translateY(0); }
.app-toast.info{ border-color:var(--sage-line); }
.app-toast.success{ border-color:var(--sage-line); color:var(--sage); }
.app-toast.error{ border-color:rgba(180,106,92,0.55); color:var(--coral); }

/* ---------- Modal de confirmação ---------- */
.confirm-modal{
  display:none; position:fixed; inset:0; z-index:250; background:rgba(10,12,15,0.6);
  align-items:center; justify-content:center; padding:24px;
}
.confirm-modal.active{ display:flex; }
.confirm-modal-panel{
  width:100%; max-width:420px; background:var(--surface-hi); border:1px solid var(--line-strong);
  border-radius:16px; padding:22px; box-shadow:0 20px 60px rgba(0,0,0,0.45);
}
.confirm-modal-text{ font-size:14px; color:var(--text); line-height:1.5; margin:0 0 20px; }
.confirm-modal-actions{ display:flex; justify-content:flex-end; gap:10px; }

/* ---------- Finanças (planilha) ---------- */
.fin-toolbar{ display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin-bottom:14px; }
.fin-color-row{ display:flex; align-items:center; gap:6px; margin-left:6px; }
.fin-color-dot{ width:20px; height:20px; border-radius:6px; border:1px solid var(--line-strong); cursor:pointer; padding:0; }
.fin-color-dot:hover{ border-color:var(--text-mut); transform:scale(1.08); }
.fin-color-dot.fin-color-none{ background:var(--surface); position:relative; }
.fin-color-dot.fin-color-none::after{ content:''; position:absolute; inset:3px; border-top:1px solid var(--coral); transform:rotate(45deg); }
.fin-sheet-wrap{ overflow:auto; border:1px solid var(--line); border-radius:var(--radius-sm); background:var(--surface); max-height:calc(100vh - 260px); padding-bottom:16px; }
table.fin-sheet{ border-collapse:collapse; font-size:12.5px; font-family:var(--sans); }
table.fin-sheet th, table.fin-sheet td{ border:1px solid var(--line); padding:0; }
table.fin-sheet th{
  background:var(--surface-hi); color:var(--text-dim); font-family:var(--mono); font-weight:500;
  font-size:11px; text-align:center; padding:6px 4px; position:sticky; top:0; z-index:2; user-select:none;
}
table.fin-sheet th.fin-row-head{ position:sticky; left:0; z-index:3; min-width:34px; }
table.fin-sheet th.fin-corner{ position:sticky; left:0; top:0; z-index:4; }
table.fin-sheet td.fin-row-head-cell{
  background:var(--surface-hi); color:var(--text-dim); font-family:var(--mono); font-size:11px; text-align:center;
  position:sticky; left:0; z-index:1; user-select:none; padding:6px 4px;
}
table.fin-sheet input.fin-cell-input{
  width:104px; height:30px; box-sizing:border-box; background:transparent; border:none; outline:none;
  color:var(--text); font-family:var(--sans); font-size:12.5px; padding:0 8px;
}
table.fin-sheet input.fin-cell-input:focus{ background:var(--sage-soft); box-shadow:inset 0 0 0 1.5px var(--sage-line); }
table.fin-sheet td.fin-cell.selected{ box-shadow:inset 0 0 0 1.5px var(--sage-line); }
table.fin-sheet td.fin-cell.fin-bold input{ font-weight:700; }
table.fin-sheet td.fin-cell.fin-error input{ color:var(--coral); }
