/* ============================================================
   Renovate Investment OS — Back Office design system
   Colors are driven by CSS variables (easy to re-theme later).
   ============================================================ */
:root {
  /* Light, airy palette (Verve-inspired) */
  --bo-bg: #e9eef0;
  --bo-surface: #ffffff;
  --bo-surface-2: #f3f7f6;
  --bo-ink: #1f2a28;
  --bo-muted: #7a877f;
  --bo-line: #e6ebec;

  /* Sidebar — light, with a soft indigo active pill */
  --bo-side-bg: #ffffff;
  --bo-side-ink: #283042;
  --bo-side-muted: #909aa6;
  --bo-side-active: #ecedfd;
  --bo-side-active-ink: #4f46c9;

  /* Brand — "Aurora" gradient (indigo → teal). Solid accent for icons/links/
     focus; gradient for fills (primary buttons, logo, login, avatar). */
  --bo-accent: #5b57e0;
  --bo-accent-ink: #ffffff;
  --bo-grad: linear-gradient(135deg, #6366f1 0%, #14b8a6 100%);

  /* Semantic — green reserved for profit/positive */
  --bo-green: #16855e;
  --bo-green-soft: #dcefe3;
  --bo-amber: #9a6a00;
  --bo-amber-soft: #f7edd5;
  --bo-red: #c0473f;
  --bo-red-soft: #fbe4e2;
  --bo-blue: #2f6f9e;
  --bo-blue-soft: #dbe9f4;

  --bo-radius: 16px;
  --bo-radius-sm: 11px;
  --bo-shadow: 0 14px 38px rgba(31, 42, 40, 0.10);
  --bo-shadow-sm: 0 1px 2px rgba(31, 42, 40, 0.05);
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body.bo {
  background: var(--bo-bg);
  color: var(--bo-ink);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
.bo-hidden { display: none !important; }

/* ===== App layout ===== */
.bo-app {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

/* ===== Sidebar ===== */
.bo-side {
  background: var(--bo-side-bg);
  color: var(--bo-side-ink);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  gap: 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--bo-line);
}
.bo-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  font-weight: 700;
  font-size: 1.02rem;
}
.bo-brand__mark {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--bo-grad);
  color: var(--bo-accent-ink);
  display: grid; place-items: center;
  font-weight: 800;
}
.bo-brand small { display: block; font-weight: 500; font-size: .72rem; color: var(--bo-side-muted); }
.bo-nav { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.bo-nav__label {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--bo-side-muted); padding: 10px 10px 4px;
}
.bo-nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 10px;
  color: var(--bo-side-muted); font-weight: 500; font-size: .92rem;
  transition: background .15s, color .15s;
}
.bo-nav a svg { width: 18px; height: 18px; flex: none; }
.bo-nav a:hover { background: var(--bo-side-active); color: var(--bo-side-active-ink); }
.bo-nav a.is-active { background: var(--bo-side-active); color: var(--bo-side-active-ink); font-weight: 600; }
.bo-side__spacer { flex: 1; }
.bo-side__user {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: 12px; background: var(--bo-surface-2);
  border: 1px solid var(--bo-line);
}
.bo-side__avatar {
  width: 36px; height: 36px; border-radius: 999px; flex: none;
  background: var(--bo-grad); color: var(--bo-accent-ink);
  display: grid; place-items: center; font-weight: 700; font-size: .9rem;
}
.bo-side__user-info { min-width: 0; }
.bo-side__user-info strong { display: block; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bo-side__user-info span { font-size: .72rem; color: var(--bo-side-muted); }

/* ===== Main ===== */
.bo-main { min-width: 0; display: flex; flex-direction: column; }
.bo-topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 16px;
  padding: 16px 28px;
  background: color-mix(in srgb, var(--bo-bg) 86%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--bo-line);
}
.bo-topbar h1 { margin: 0; font-size: 1.4rem; font-weight: 700; }
.bo-topbar__sub { margin: 2px 0 0; font-size: .85rem; color: var(--bo-muted); }
.bo-topbar__spacer { flex: 1; }
.bo-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bo-surface); border: 1px solid var(--bo-line);
  border-radius: 999px; padding: 8px 14px; min-width: 220px;
}
.bo-search input { border: 0; outline: 0; background: none; width: 100%; }
.bo-content { padding: 24px 28px 56px; display: flex; flex-direction: column; gap: 20px; }

/* ===== KPI cards ===== */
.bo-kpis { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; }
.bo-kpi {
  background: var(--bo-surface); border: 1px solid var(--bo-line);
  border-radius: var(--bo-radius); padding: 18px; box-shadow: var(--bo-shadow-sm);
}
.bo-kpi__label { font-size: .82rem; color: var(--bo-muted); margin-bottom: 8px; }
.bo-kpi__value { font-size: 1.7rem; font-weight: 700; letter-spacing: -.01em; }
.bo-kpi__foot { margin-top: 8px; font-size: .8rem; color: var(--bo-muted); display: flex; gap: 6px; align-items: center; }
/* Verve-style soft-tinted KPI cards */
.bo-kpi--mint { background: var(--bo-green-soft); border-color: transparent; }
.bo-kpi--blue { background: var(--bo-blue-soft); border-color: transparent; }
.bo-kpi--amber { background: var(--bo-amber-soft); border-color: transparent; }
.bo-kpi--rose { background: var(--bo-red-soft); border-color: transparent; }
.bo-kpi--mint .bo-kpi__label, .bo-kpi--mint .bo-kpi__foot { color: color-mix(in srgb, var(--bo-green) 78%, #000 0%); }
.bo-kpi--blue .bo-kpi__label, .bo-kpi--blue .bo-kpi__foot { color: var(--bo-blue); }
.bo-kpi--amber .bo-kpi__label, .bo-kpi--amber .bo-kpi__foot { color: var(--bo-amber); }
.bo-kpi--rose .bo-kpi__label, .bo-kpi--rose .bo-kpi__foot { color: var(--bo-red); }
.bo-trend { font-weight: 600; }
.bo-trend--up { color: var(--bo-green); }
.bo-trend--down { color: var(--bo-red); }

/* ===== Panels ===== */
.bo-panel {
  background: var(--bo-surface); border: 1px solid var(--bo-line);
  border-radius: var(--bo-radius); box-shadow: var(--bo-shadow-sm); overflow: hidden;
}
.bo-panel__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--bo-line);
}
.bo-panel__head h2 { margin: 0; font-size: 1.05rem; font-weight: 700; }
.bo-panel__head p { margin: 2px 0 0; font-size: .82rem; color: var(--bo-muted); }
.bo-panel__body { padding: 18px 20px; }
.bo-grid-2 { display: grid; grid-template-columns: minmax(0,1.5fr) minmax(0,1fr); gap: 20px; align-items: start; }
.bo-grid-2--even { grid-template-columns: repeat(2, minmax(0,1fr)); }

/* ===== Tables ===== */
.bo-table-wrap { overflow-x: auto; }
.bo-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.bo-table th, .bo-table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--bo-line); vertical-align: middle; }
.bo-table thead th {
  background: var(--bo-surface-2); font-size: .74rem; font-weight: 600;
  color: var(--bo-muted); text-transform: uppercase; letter-spacing: .03em;
}
.bo-table tbody tr { cursor: default; }
.bo-table tbody tr.is-clickable:hover { background: var(--bo-surface-2); cursor: pointer; }
.bo-table__title { font-weight: 600; }
.bo-table__sub { font-size: .78rem; color: var(--bo-muted); }
.bo-table__actions { display: flex; gap: 6px; justify-content: flex-end; }
.bo-num { font-variant-numeric: tabular-nums; }

/* ===== Badges ===== */
.bo-badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--bo-surface-2); color: var(--bo-muted); }
.bo-badge--green { background: var(--bo-green-soft); color: var(--bo-green); }
.bo-badge--amber { background: var(--bo-amber-soft); color: var(--bo-amber); }
.bo-badge--red { background: var(--bo-red-soft); color: var(--bo-red); }
.bo-badge--blue { background: var(--bo-blue-soft); color: var(--bo-blue); }
.bo-badge--violet { background: #ecedfd; color: #4f46c9; }

/* ===== Buttons ===== */
.bo-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: .9rem;
  border: 1px solid transparent; white-space: nowrap; transition: filter .15s, background .15s, border-color .15s;
}
.bo-btn--primary { background: var(--bo-grad); color: var(--bo-accent-ink); border: 0; }
.bo-btn--primary:hover { filter: brightness(1.06) saturate(1.05); }
.bo-btn--ghost { background: var(--bo-surface); border-color: var(--bo-line); color: var(--bo-ink); }
.bo-btn--ghost:hover { background: var(--bo-surface-2); }
.bo-btn--danger { background: var(--bo-surface); border-color: var(--bo-red-soft); color: var(--bo-red); }
.bo-btn--danger:hover { background: var(--bo-red-soft); }
.bo-btn--sm { padding: 6px 11px; font-size: .82rem; border-radius: 8px; }
.bo-btn--block { width: 100%; }
.bo-btn:disabled { opacity: .55; cursor: not-allowed; }

/* ===== Forms ===== */
.bo-form { display: flex; flex-direction: column; gap: 16px; }
.bo-field { display: flex; flex-direction: column; gap: 6px; }
.bo-field > label { font-size: .82rem; font-weight: 600; }
.bo-field .bo-hint { font-size: .76rem; color: var(--bo-muted); }
.bo-field input, .bo-field select, .bo-field textarea {
  padding: 10px 12px; border: 1px solid var(--bo-line); border-radius: 10px;
  background: var(--bo-surface); color: var(--bo-ink); transition: border-color .15s, box-shadow .15s;
}
.bo-field input:focus, .bo-field select:focus, .bo-field textarea:focus {
  outline: 0; border-color: var(--bo-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bo-accent) 18%, transparent);
}
.bo-field textarea { min-height: 90px; resize: vertical; }
.bo-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.bo-grid--3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.bo-grid .bo-span-2 { grid-column: 1 / -1; }
.bo-section-title { font-size: .95rem; font-weight: 700; margin: 6px 0 0; padding-top: 14px; border-top: 1px solid var(--bo-line); }
.bo-form__footer { display: flex; justify-content: flex-end; gap: 10px; padding-top: 16px; border-top: 1px solid var(--bo-line); flex-wrap: wrap; }

/* toggle list */
.bo-toggle-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px 18px; }
.bo-toggle { display: flex; align-items: center; gap: 9px; font-size: .88rem; }

/* ===== Empty / state ===== */
.bo-state { padding: 48px 20px; text-align: center; color: var(--bo-muted); }
.bo-state--error { color: var(--bo-red); }

/* ===== Alert banner ===== */
.bo-alert {
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  padding: 14px 18px; border-radius: var(--bo-radius);
  background: var(--bo-green-soft); color: var(--bo-green); font-size: .9rem; font-weight: 500;
}

/* ===== Modal ===== */
.bo-modal { position: fixed; inset: 0; background: rgba(16,24,20,.46); display: none; align-items: center; justify-content: center; padding: 18px; z-index: 50; }
.bo-modal.is-open { display: flex; }
.bo-modal__card { background: var(--bo-surface); border-radius: var(--bo-radius); width: min(720px, 100%); max-height: 92vh; overflow: auto; box-shadow: var(--bo-shadow); }
.bo-modal__card--wide { width: min(940px, 100%); }
.bo-modal__head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--bo-line); position: sticky; top: 0; background: var(--bo-surface); }
.bo-modal__head h2 { margin: 0; font-size: 1.1rem; }
.bo-modal__body { padding: 20px 22px; }

/* ===== Toast ===== */
.bo-toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--bo-ink); color: #fff; padding: 12px 20px; border-radius: 999px; box-shadow: var(--bo-shadow); font-size: .9rem; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 9999; }
.bo-toast.is-show { opacity: 1; transform: translateX(-50%) translateY(0); }
.bo-toast--success { background: var(--bo-green); }
.bo-toast--error { background: var(--bo-red); }

/* ===== Auth (login) ===== */
.bo-auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--bo-grad); }
.bo-auth__card { background: var(--bo-surface); border-radius: 18px; box-shadow: var(--bo-shadow); padding: 36px; width: 100%; max-width: 400px; }
.bo-auth__brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; font-weight: 700; }
.bo-auth__card h1 { margin: 0 0 6px; font-size: 1.4rem; }
.bo-auth__card p.sub { margin: 0 0 22px; color: var(--bo-muted); font-size: .9rem; }
.bo-auth__error { background: var(--bo-red-soft); color: var(--bo-red); padding: 10px 14px; border-radius: 10px; font-size: .85rem; margin-bottom: 14px; }

/* mini bar chart */
.bo-bars { display: flex; align-items: flex-end; gap: 10px; height: 160px; padding-top: 10px; }
.bo-bars__col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bo-bars__bar { width: 70%; background: var(--bo-green); border-radius: 6px 6px 0 0; min-height: 3px; transition: height .3s; }
.bo-bars__lbl { font-size: .72rem; color: var(--bo-muted); }

/* ===== Responsive ===== */
@media (max-width: 1080px) {
  .bo-kpis { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .bo-grid-2, .bo-grid-2--even { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .bo-app { grid-template-columns: 1fr; }
  .bo-side { position: fixed; left: 0; top: 0; width: 248px; transform: translateX(-100%); transition: transform .2s; z-index: 60; }
  .bo-side.is-open { transform: translateX(0); }
  .bo-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: none; z-index: 55; }
  .bo-backdrop.is-open { display: block; }
  .bo-burger { display: inline-grid !important; }
  .bo-grid, .bo-grid--3, .bo-toggle-grid { grid-template-columns: 1fr; }
}
.bo-burger { display: none; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--bo-line); background: var(--bo-surface); }

/* dual bars for cashflow (in vs out per month) */
.bo-bars__pair { display: flex; align-items: flex-end; gap: 3px; height: 100%; }
.bo-bars__bar--out { background: var(--bo-red); }

/* ===== Print (export PDF via browser print) ===== */
@media print {
  body.bo { background: #fff; }
  .bo-side, .bo-backdrop, .bo-burger, .no-print { display: none !important; }
  .bo-app { display: block; }
  .bo-topbar { position: static; border-bottom: 2px solid #000; backdrop-filter: none; background: #fff; }
  .bo-content { padding: 12px 0; }
  .bo-panel, .bo-kpi { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  .bo-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  a { text-decoration: none; }
}
