:root {
  --primary: #16a34a;
  --primary-dark: #166534;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --pending: #0f766e;
  --ink: #1e293b;
  --muted: #64748b;
  --soft: #94a3b8;
  --line: #e2e8f0;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --blue: #2563eb;
  --violet: #7c3aed;
  --teal: #0d9488;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  color-scheme: light;
  font-family: Inter, Roboto, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(120deg, rgba(22, 163, 74, 0.1), rgba(37, 99, 235, 0.08)),
    var(--bg);
}

.login-panel {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 32px;
}

.brand-mark {
  width: 80px;
  height: 80px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  font-weight: 800;
  font-size: 24px;
  margin: 0 auto 28px;
}

.brand-mark.small {
  width: 42px;
  height: 42px;
  font-size: 14px;
  margin: 0;
}

.login-panel h1 {
  margin: 0;
  text-align: center;
  font-size: 28px;
  line-height: 1.2;
}

.login-panel p {
  text-align: center;
  color: var(--muted);
  margin: 8px 0 28px;
}

.form-stack {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 650;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.16);
}

.password-field {
  display: grid;
  grid-template-columns: 1fr 44px;
  gap: 8px;
}

.primary-button,
.ghost-button,
.danger-button,
.confirm-button,
.secondary-button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 750;
}

.primary-button,
.confirm-button {
  background: var(--primary);
  color: white;
}

.ghost-button,
.secondary-button {
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.danger-button {
  color: white;
  background: var(--danger);
}

.icon-button {
  width: 40px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font-size: 18px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 18px 14px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 18px;
}

.sidebar-brand strong,
.sidebar-brand span {
  display: block;
}

.sidebar-brand span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  font-weight: 700;
}

.nav-item.active {
  color: var(--primary-dark);
  background: rgba(22, 163, 74, 0.12);
}

.nav-icon {
  font-size: 15px;
  font-weight: 900;
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 78px;
  padding: 16px 24px;
  background: rgba(248, 250, 252, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.topbar h2 {
  margin: 2px 0 0;
  font-size: 24px;
  line-height: 1.2;
}

.kicker {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.content {
  width: min(1280px, 100%);
  padding: 24px;
}

.grid {
  display: grid;
  gap: 16px;
}

.stats-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.two-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  padding: 16px;
}

.stat-card {
  min-height: 132px;
  display: grid;
  align-content: space-between;
}

.stat-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.stat-card span,
.muted {
  color: var(--muted);
}

.stat-card strong {
  display: block;
  margin-top: 12px;
  font-size: 28px;
  line-height: 1.1;
}

.stat-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: white;
  background: var(--primary);
  font-weight: 900;
}

.chart-card {
  min-height: 300px;
}

.chart {
  width: 100%;
  height: 230px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.toolbar .filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.toolbar label {
  min-width: 150px;
}

.search {
  width: min(360px, 100%);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

tr:last-child td {
  border-bottom: 0;
}

.row-button {
  color: var(--primary-dark);
  background: transparent;
  border: 0;
  font-weight: 800;
  padding: 6px 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
  text-transform: capitalize;
}

.badge.pending {
  background: rgba(15, 118, 110, 0.12);
  color: var(--pending);
}

.badge.completed,
.badge.confirmed,
.badge.success {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
}

.badge.failed,
.badge.error,
.badge.rejected {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
}

.badge.default {
  background: var(--surface-2);
  color: var(--muted);
}

.empty,
.loading,
.error {
  min-height: 260px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.loading::before {
  content: "";
  width: 42px;
  height: 42px;
  border: 4px solid rgba(22, 163, 74, 0.16);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading {
  gap: 14px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.user-summary {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: center;
}

.avatar {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 22px;
  font-weight: 900;
}

.finance-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 16px 0;
}

.metric {
  border-radius: 8px;
  padding: 14px;
  background: #ecfdf5;
  border: 1px solid var(--line);
}

.metric:nth-child(2) {
  background: #eff6ff;
}

.metric:nth-child(3) {
  background: #fffbeb;
}

.metric:nth-child(4) {
  background: #f5f3ff;
}

.metric:nth-child(5) {
  background: #f0fdfa;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.metric strong {
  display: block;
  margin-top: 6px;
  color: var(--primary-dark);
  font-size: 18px;
}

.action-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.bank-list,
.holding-list {
  display: grid;
  gap: 10px;
}

.bank-row,
.holding-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.holding-user {
  margin-bottom: 14px;
}

.positive {
  color: #047857;
  font-weight: 800;
}

.negative {
  color: #b91c1c;
  font-weight: 800;
}

.dialog {
  width: min(980px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

.dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.dialog-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: white;
  border-bottom: 1px solid var(--line);
  padding: 16px;
}

.dialog h3 {
  margin: 2px 0 0;
  font-size: 22px;
}

#dialogBody {
  padding: 16px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 36px));
  background: var(--ink);
  color: white;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  transform: translateY(24px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  background: var(--danger);
}

.toast.success {
  background: var(--primary-dark);
}

.bottom-nav {
  display: none;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
    padding-bottom: 70px;
  }

  .sidebar {
    display: none;
  }

  .content {
    padding: 16px;
  }

  .stats-grid,
  .finance-grid,
  .action-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    background: white;
    border-top: 1px solid var(--line);
  }

  .bottom-nav button {
    min-height: 64px;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
  }

  .bottom-nav button.active {
    color: var(--primary-dark);
    background: rgba(22, 163, 74, 0.08);
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: start;
    padding: 12px 14px;
  }

  .topbar h2 {
    font-size: 20px;
  }

  .topbar-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-actions button {
    min-height: 34px;
    padding: 0 10px;
    font-size: 12px;
  }

  .stats-grid,
  .two-grid,
  .finance-grid,
  .action-grid {
    grid-template-columns: 1fr;
  }

  .toolbar {
    display: grid;
  }

  .toolbar .filters,
  .search {
    width: 100%;
  }

  .login-panel {
    padding: 24px;
  }

  .bank-row,
  .holding-row {
    align-items: flex-start;
    flex-direction: column;
  }
}
