/* ── RESET & TOKENS ── */
:root {
  --bg: #ffffff; --surface: #f7f7f5; --surface2: #f0efed;
  --border: #e5e5e5; --border-strong: #d4d4d4;
  --text: #191919; --text-2: #555; --text-3: #999;
  --red: #dc2626; --red-bg: #fef2f2;
  --accent: #2563eb; --accent-bg: #eff6ff;
  --green: #16a34a; --green-bg: #f0fdf4;
  --yellow: #ca8a04; --yellow-bg: #fefce8;
  --radius: 6px;
  --sidebar-w: 232px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: 'Geist', sans-serif; font-size: 15px;
  -webkit-font-smoothing: antialiased;
  display: flex; overflow: hidden;
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  height: 100vh; overflow: hidden;
}
.sidebar-top {
  padding: 16px 12px 8px;
  display: flex; align-items: center; gap: 8px;
}
.logo-dot { width: 8px; height: 8px; background: var(--red); border-radius: 50%; flex-shrink: 0; }
.logo-name {
  font-family: 'Geist Mono', monospace; font-size: 14px;
  font-weight: 500; letter-spacing: -0.01em; color: var(--text);
}

.sidebar-section { padding: 8px 8px 0; }
.sidebar-section-label {
  font-size: 11px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-3);
  padding: 4px 8px 6px;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 1px; }
.sidebar-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; border-radius: var(--radius);
  font-size: 15px; font-weight: 500; color: var(--text-2);
  cursor: pointer; text-decoration: none;
  transition: background .1s, color .1s; user-select: none;
  border: none; background: none; font-family: 'Geist', sans-serif;
  width: 100%; text-align: left;
}
.sidebar-item:hover { background: var(--surface2); color: var(--text); }
.sidebar-item.active { background: var(--surface2); color: var(--text); font-weight: 600; }
.sidebar-item svg { flex-shrink: 0; opacity: .6; }
.sidebar-item.active svg { opacity: 1; }
.sidebar-item-badge {
  margin-left: auto; font-size: 11px; font-family: 'Geist Mono', monospace;
  font-weight: 600; background: var(--border); color: var(--text-3);
  padding: 1px 6px; border-radius: 10px;
}

.sidebar-divider { height: 1px; background: var(--border); margin: 8px 12px; }

.sidebar-new-btn {
  margin: 8px; padding: 8px 10px;
  background: var(--text); color: white;
  border-radius: var(--radius); border: none;
  font-family: 'Geist', sans-serif; font-size: 15px; font-weight: 600;
  cursor: pointer; display: flex; align-items: center; gap: 8px;
  transition: opacity .15s; text-decoration: none;
}
.sidebar-new-btn:hover { opacity: .82; }

.sidebar-bottom {
  margin-top: auto; padding: 8px;
  border-top: 1px solid var(--border);
}

/* ── MAIN AREA ── */
.main {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; height: 100vh;
}
.topbar {
  height: 48px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; flex-shrink: 0; background: var(--bg);
}
.topbar-title {
  font-size: 14px; font-weight: 600; letter-spacing: -.01em;
}
.topbar-right { display: flex; align-items: center; gap: 8px; }
.main-content { flex: 1; overflow-y: auto; }
.main-content::-webkit-scrollbar { width: 4px; }
.main-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── SHARED BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 13px; border-radius: var(--radius);
  font-family: 'Geist', sans-serif; font-weight: 500; font-size: 14px;
  cursor: pointer; border: none; transition: opacity .15s, background .12s;
  text-decoration: none;
}
.btn-primary { background: var(--text); color: white; }
.btn-primary:hover { opacity: .8; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border-strong); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--red-bg); color: var(--red); border: 1px solid #fecaca; }
.btn-danger:hover { background: #fee2e2; }
.btn-ghost { background: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); }
.btn-icon {
  width: 30px; height: 30px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius); background: none; border: none;
  cursor: pointer; color: var(--text-2); font-size: 14px;
  transition: background .12s;
}
.btn-icon:hover { background: var(--surface2); color: var(--text); }
.btn-icon.danger:hover { background: var(--red-bg); color: var(--red); }

/* ── TOAST ── */
.toast {
  position: fixed; bottom: 20px; left: 50%;
  transform: translateX(-50%) translateY(50px);
  background: var(--text); color: white; font-size: 14px; font-weight: 500;
  padding: 9px 16px; border-radius: var(--radius); opacity: 0;
  transition: all .25s cubic-bezier(.34,1.56,.64,1); pointer-events: none;
  z-index: 999; box-shadow: 0 4px 12px rgba(0,0,0,.15);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.35);
  z-index: 200; display: flex; align-items: center; justify-content: center;
  padding: 24px; opacity: 0; pointer-events: none; transition: opacity .18s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg); border-radius: 10px; width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
  transform: translateY(6px); transition: transform .18s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  padding: 18px 22px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 14px; font-weight: 600; }
.modal-body { padding: 20px 22px; }
.modal-footer {
  padding: 14px 22px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* ── SETTINGS PANEL (slide-in from right) ── */
.settings-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.2);
  z-index: 300; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.settings-overlay.open { opacity: 1; pointer-events: all; }
.settings-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: 540px;
  background: var(--bg); border-left: 1px solid var(--border);
  box-shadow: -8px 0 32px rgba(0,0,0,.08);
  transform: translateX(100%); transition: transform .22s cubic-bezier(.4,0,.2,1);
  z-index: 301; display: flex; flex-direction: column; overflow: hidden;
}
.settings-overlay.open .settings-panel { transform: translateX(0); }
.settings-header {
  height: 52px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px; flex-shrink: 0;
}
.settings-header-title { font-size: 14px; font-weight: 600; }
.settings-body { flex: 1; overflow-y: auto; padding: 24px 22px 60px; }
.settings-body::-webkit-scrollbar { width: 4px; }
.settings-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.settings-save-bar {
  padding: 12px 22px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0; background: var(--surface);
}
.settings-save-note { font-size: 12px; color: var(--text-3); }

/* ── FORM ELEMENTS ── */
label { display: block; font-size: 14px; font-weight: 500; color: var(--text-2); margin-bottom: 5px; margin-top: 12px; }
label:first-of-type { margin-top: 0; }
input[type="text"], input[type="number"], input[type="email"], textarea, select {
  width: 100%; background: var(--bg); border: 1px solid var(--border-strong);
  color: var(--text); font-family: 'Geist', sans-serif; font-size: 15px;
  padding: 7px 10px; border-radius: var(--radius); outline: none;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none; appearance: none;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--text); box-shadow: 0 0 0 3px rgba(23,23,23,.06);
}
textarea { resize: vertical; min-height: 60px; line-height: 1.5; }
.input-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ── CFG BLOCKS (settings panel) ── */
.cfg-block { margin-bottom: 24px; }
.cfg-block-title { font-size: 15px; font-weight: 600; margin-bottom: 3px; }
.cfg-block-desc { font-size: 13px; color: var(--text-3); margin-bottom: 12px; }
.cfg-card { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.cfg-row { display: grid; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); gap: 12px; }
.cfg-row:last-child { border-bottom: none; }
.cfg-row-2 { grid-template-columns: 1fr 130px; }
.cfg-row-label { font-size: 14px; font-weight: 500; }
.cfg-row-sub { font-size: 11px; color: var(--text-3); margin-top: 1px; }
.cfg-input { font-family: 'Geist Mono', monospace !important; font-size: 14px !important; text-align: right; }
.cfg-list-item { display: grid; grid-template-columns: 1fr 100px 32px; align-items: center; gap: 8px; padding: 9px 14px; border-bottom: 1px solid var(--border); }
.cfg-list-item:last-child { border-bottom: none; }
.cfg-list-footer { padding: 10px 14px; border-top: 1px solid var(--border); background: var(--surface); }
.cfg-new-row { display: grid; grid-template-columns: 1fr 100px auto; gap: 8px; align-items: center; }
.cfg-currency-tabs { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-bottom: 22px; }
.cfg-ctab { flex: 1; padding: 10px 14px; cursor: pointer; font-size: 14px; font-weight: 500; color: var(--text-2); background: var(--surface); border: none; font-family: 'Geist', sans-serif; transition: background .12s; display: flex; align-items: center; gap: 8px; border-right: 1px solid var(--border); }
.cfg-ctab:last-child { border-right: none; }
.cfg-ctab:hover { background: var(--surface2); }
.cfg-ctab.active-brl { background: var(--bg); color: var(--text); font-weight: 600; }
.cfg-ctab.active-usd { background: var(--accent-bg); color: var(--accent); font-weight: 600; }
.cfg-panel { display: none; } .cfg-panel.active { display: block; }

/* ── STATUS BADGES ── */
.status { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 4px; font-size: 15px; font-weight: 600; cursor: pointer; position: relative; }
.status::after { content: '▾'; font-size: 9px; opacity: .55; margin-left: 1px; }
.status.static::after { display: none; cursor: default; }
.status.draft  { background: var(--surface2); color: var(--text-2); border: 1px solid var(--border-strong); }
.status.sent   { background: var(--accent-bg); color: var(--accent); border: 1px solid #bfdbfe; }
.status.approved { background: var(--green-bg); color: var(--green); border: 1px solid #bbf7d0; }
.status.rejected { background: var(--red-bg); color: var(--red); border: 1px solid #fecaca; }
.status-menu { position: absolute; top: calc(100% + 4px); left: 0; background: var(--bg); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: 0 4px 12px rgba(0,0,0,.1); z-index: 100; min-width: 130px; display: none; }
.status-menu.open { display: block; }
.status-menu-item { padding: 7px 12px; font-size: 14px; font-weight: 500; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.status-menu-item:hover { background: var(--surface2); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.dot-draft { background: var(--text-3); } .dot-sent { background: var(--accent); }
.dot-approved { background: var(--green); } .dot-rejected { background: var(--red); }

/* ── MISC ── */
.mono { font-family: 'Geist Mono', monospace; }
.mkt { display: inline-flex; padding: 2px 6px; border-radius: 3px; font-family: 'Geist Mono', monospace; font-size: 11px; font-weight: 600; }
.mkt.BRL { background: var(--surface2); color: var(--text-2); }
.mkt.USD { background: var(--accent-bg); color: var(--accent); }
.mini-note { font-size: 15px; color: var(--text-3); margin-top: 8px; line-height: 1.5; padding: 8px 10px; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); }

@media (max-width: 720px) {
  .sidebar { display: none; }
  .settings-panel { width: 100%; }
}
