:root {
  --bg: #f4f6f3;
  --panel: #ffffff;
  --ink: #17201a;
  --muted: #667268;
  --line: #dfe6df;
  --primary: #1f7a4f;
  --primary-dark: #17603e;
  --accent: #255f85;
  --danger: #b13b3b;
  --success: #247a55;
  --btn-height: 42px;
  --btn-min-width: 112px;
  --btn-padding-x: 14px;
  --btn-radius: 8px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, Segoe UI, Arial, sans-serif;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}
a { color: inherit; text-decoration: none; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 1fr; }
.sidebar {
  background: #101713;
  color: #eef5ef;
  padding: 14px;
  position: static;
  top: 0;
  height: auto;
  z-index: 4;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; min-width: 0; }
.brand-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 8px;
  display: inline-grid; place-items: center;
  background: var(--primary); color: #fff;
}
.icon-btn {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 8px;
  background: #1d2a22;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}
.desktop-collapse { display: none; }
.mobile-menu { display: inline-grid; place-items: center; }
.side-nav {
  display: none;
  gap: 6px;
  margin-top: 14px;
  overflow-x: auto;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
}
.shell.mobile-open .side-nav { display: flex; }
.side-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #cbd8ce;
  font-weight: 650;
  font-size: 14px;
  line-height: 1.2;
}
.side-nav a:hover, .side-nav a.active { background: #203128; color: #fff; }
.nav-icon {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  display: inline-grid;
  place-items: center;
}
.nav-icon svg {
  width: 20px;
  height: 20px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.nav-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.content { min-width: 0; }
.topbar {
  min-height: 62px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.82);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 3;
}
.topbar div { display: grid; text-align: right; }
.topbar span { color: var(--muted); font-size: 13px; }
.app-main { padding: 16px; max-width: 1240px; margin: 0 auto; }
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-direction: column;
  margin-bottom: 18px;
}
.page-head h1 { margin: 2px 0 0; font-size: 24px; letter-spacing: 0; }
.eyebrow { color: var(--primary); font-size: 12px; text-transform: uppercase; font-weight: 800; }

.grid { display: grid; gap: 18px; }
.grid.two, .grid.three, .grid.four { grid-template-columns: 1fr; }
.panel, .metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 12px 28px rgba(21, 31, 24, .05);
}
.panel h2 { margin: 0 0 14px; font-size: 17px; }
.metric span { color: var(--muted); font-size: 13px; font-weight: 700; }
.metric strong { display: block; margin-top: 8px; font-size: 24px; }
.metric small { display: block; margin-top: 6px; color: var(--muted); }
.chart-box {
  position: relative;
  height: 260px;
  min-height: 260px;
  max-height: 260px;
}
.chart-box canvas {
  width: 100% !important;
  height: 260px !important;
  max-height: 260px !important;
  display: block;
}

.form-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 700; }
input, select {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cfd9d0;
  border-radius: 8px;
  padding: 9px 11px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}
input:focus, select:focus { outline: 3px solid rgba(31,122,79,.14); border-color: var(--primary); }
.span-2 { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 9px; }
.check input { width: 18px; min-height: 18px; }
.btn {
  min-width: var(--btn-min-width);
  min-height: var(--btn-height);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--btn-radius);
  padding: 9px var(--btn-padding-x);
  appearance: none;
  background-clip: padding-box;
  cursor: pointer;
  font-weight: 800;
  font: inherit;
  font-size: 14px;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  max-width: 100%;
  transition: background-color .16s ease, border-color .16s ease, color .16s ease, opacity .16s ease;
}
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.secondary { background: #e8f0eb; color: var(--primary-dark); }
.btn.ghost { border-color: var(--line); background: #fff; color: var(--ink); }
.btn.danger { background: #fae6e6; color: var(--danger); }
.btn.tiny {
  min-width: var(--btn-min-width);
  min-height: var(--btn-height);
  padding: 9px var(--btn-padding-x);
  font-size: 14px;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.form-grid > .btn:not(.span-2) {
  width: auto;
  justify-self: start;
  align-self: end;
}
.form-grid > .btn.span-2,
.auth-panel .btn.span-2 {
  width: 100%;
}
.page-head > .btn,
.topbar .btn {
  width: auto;
  flex: 0 0 auto;
}

.alert { border-radius: 8px; padding: 12px 14px; margin-bottom: 14px; font-weight: 700; }
.alert.success { background: #e4f5ec; color: var(--success); }
.alert.danger { background: #f8e5e5; color: var(--danger); }
.table-wrap {
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; min-width: 96px; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; }
td small { display: block; color: var(--muted); margin-top: 3px; }
.amount { text-align: right; font-weight: 800; white-space: nowrap; }
.amount.in { color: var(--success); }
.amount.out { color: var(--danger); }
.pill, .tag { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 9px; background: #edf2ee; color: var(--muted); font-size: 12px; font-weight: 800; white-space: nowrap; }
.pill.ok { background: #e4f5ec; color: var(--success); }
.pill.wait { background: #fff4d8; color: #8a6414; }
.tag.account { background: #e7f0f7; color: var(--accent); }
.tag.card { background: var(--tag-bg, #6d3a9c); color: #fff; }
.tag.person { background: var(--tag-bg, #255f85); color: #fff; }
input[type="color"] { padding: 4px; min-height: 42px; }
.tag.business { background: #e4f5ec; color: var(--primary-dark); }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form select { min-height: var(--btn-height); min-width: 140px; }
.user-list { display: grid; gap: 14px; }
.user-row { display: grid; gap: 10px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.user-edit-form { display: grid; grid-template-columns: 1fr; gap: 10px; }
.user-edit-form .btn { align-self: end; }
.manager-list { display: grid; gap: 14px; }
.manager-list.compact { margin-top: 14px; }
.manager-row { display: grid; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.manager-row:last-child { border-bottom: 0; }
.manager-form { display: grid; grid-template-columns: 1fr; gap: 10px; }
.manager-form .btn { align-self: end; }
.manager-row > form:not(.manager-form) .btn {
  width: auto;
}
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at top left, rgba(31,122,79,.18), transparent 32%), var(--bg);
}
.auth-panel {
  width: min(440px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 20px 42px rgba(23, 32, 26, .12);
}
.auth-brand { margin-bottom: 24px; }
.auth-link { margin: 16px 0 0; color: var(--muted); }
.auth-link a { color: var(--primary-dark); font-weight: 800; }
.auth-panel .container, .auth-panel .row, .auth-panel [class*="col-"], .auth-panel .card, .auth-panel .card-body {
  width: 100%;
  padding: 0;
  margin: 0;
  border: 0;
  box-shadow: none;
}
.card-title { margin: 0 0 16px; font-size: 22px; }
.mb-3 { margin-bottom: 14px; }
.d-grid { display: grid; }

@media (min-width: 680px) {
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .manager-form, .user-edit-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-head { flex-direction: row; align-items: center; }
  .page-head h1 { font-size: 30px; }
}

@media (max-width: 420px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .topbar div { text-align: left; }
  .form-grid > .btn.span-2,
  .auth-panel .btn.span-2 { width: 100%; }
  .inline-form .btn, .row-actions .btn { width: auto; }
  .manager-row > form:not(.manager-form) .btn { width: 100%; }
  .auth-panel { padding: 20px; }
}

@media (min-width: 900px) {
  .shell { grid-template-columns: 248px 1fr; }
  .shell.is-collapsed { grid-template-columns: 74px 1fr; }
  .sidebar {
    padding: 22px 18px;
    position: sticky;
    height: 100vh;
  }
  .side-nav {
    display: grid;
    gap: 4px;
    margin-top: 28px;
    overflow: visible;
  }
  .desktop-collapse { display: inline-grid; place-items: center; }
  .mobile-menu { display: none; }
  .shell.is-collapsed .sidebar { padding-inline: 14px; }
  .shell.is-collapsed .brand-text,
  .shell.is-collapsed .nav-label { display: none; }
  .shell.is-collapsed .side-nav a {
    min-height: 44px;
    padding: 10px;
    justify-content: center;
    position: relative;
  }
  .shell.is-collapsed .sidebar-head { justify-content: center; flex-wrap: wrap; }
  .shell.is-collapsed .nav-icon {
    width: 24px;
    height: 24px;
    flex-basis: 24px;
  }
  .shell.is-collapsed .nav-icon svg {
    width: 22px;
    height: 22px;
  }
  .side-nav a { font-size: 15px; }
  .topbar { justify-content: flex-end; padding: 0 28px; min-height: 68px; }
  .app-main { padding: 28px; }
  .grid.two { grid-template-columns: minmax(320px, .8fr) minmax(420px, 1.2fr); }
  .grid.three { grid-template-columns: repeat(3, 1fr); }
  .grid.four { grid-template-columns: repeat(4, 1fr); }
  .metric strong { font-size: 28px; }
}
