:root{
  --app-font: Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
  --app-bg: #f7f8fc;
  --app-card: #ffffff;
  --app-surface: #ffffff;
  --app-surface-2: rgba(255,255,255,.72);
  --app-text: #0f172a;
  --app-muted: #64748b;
  --app-border: rgba(15, 23, 42, .08);
  --app-shadow: 0 12px 32px rgba(15, 23, 42, .08);
  --app-shadow-soft: 0 8px 22px rgba(15, 23, 42, .06);
  --app-primary: #4f46e5;
  --app-primary-rgb: 79, 70, 229;
  --app-radius: 16px;
  --app-radius-sm: 12px;
}

html, body { height: 100%; }
body{
  font-family: var(--app-font);
  background: var(--app-bg);
  color: var(--app-text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.app-topbar{
  position: sticky;
  top: 0;
  z-index: 1020;
  background: var(--app-surface-2) !important;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.app-shell{ display: flex; min-height: calc(100vh - 56px); }
.app-sidebar{ width: 280px; background: var(--app-surface); }
.app-content{ flex: 1; min-width: 0; }
.app-content{ padding-bottom: 2.5rem; }

.app-sidebar .sidebar-user{
  border-top: 1px solid var(--app-border);
  background: rgba(2, 6, 23, .02);
}

.list-group-item{
  border-color: transparent;
  padding: .85rem 1rem;
  border-radius: 14px;
  margin: .18rem .55rem;
  transition: background-color .18s ease, color .18s ease, transform .12s ease;
}
.list-group-item:hover{ background: rgba(var(--app-primary-rgb),.06); }
.list-group-item.active{
  background: rgba(var(--app-primary-rgb),.12);
  color: #0f172a;
  font-weight: 600;
  position: relative;
}
.list-group-item.active::before{
  content:"";
  position:absolute;
  left:-.55rem;
  top: 18%;
  bottom: 18%;
  width: 3px;
  border-radius: 999px;
  background: rgb(var(--app-primary-rgb));
}

.icon-circle{
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
}

.card{
  border: 1px solid var(--app-border);
  box-shadow: var(--app-shadow-soft);
  border-radius: var(--app-radius);
}
.card:hover{
  box-shadow: var(--app-shadow);
  transform: translateY(-1px);
  transition: transform .14s ease, box-shadow .18s ease;
}
.card .card-body{ padding: 1.05rem 1.05rem; }

/* Global rhythm */
h1, h2, h3, h4, h5{ letter-spacing: -.01em; }
.h3{ letter-spacing: -.02em; }
.card .table-responsive{ margin-top: .25rem; }
.card .table{ margin-bottom: 0; }

/* Fintech-like controls */
.btn{ border-radius: var(--app-radius-sm); transition: transform .08s ease, box-shadow .18s ease, background-color .18s ease, border-color .18s ease; }
.btn:hover{ transform: translateY(-1px); }
.btn:active{ transform: translateY(0); }
.btn-primary{ box-shadow: 0 8px 22px rgba(var(--app-primary-rgb), .18); }

.form-control, .form-select, .input-group-text{
  border-radius: var(--app-radius-sm);
  border-color: var(--app-border);
}
.form-control:focus, .form-select:focus{
  border-color: rgba(var(--app-primary-rgb), .55);
  box-shadow: 0 0 0 .2rem rgba(var(--app-primary-rgb), .12);
}
.form-label{ color: #334155; font-weight: 600; }
.text-muted{ color: var(--app-muted) !important; }

.table{ --bs-table-bg: transparent; }
.table thead th{
  font-size: .82rem;
  color: #475569;
  font-weight: 600;
  border-bottom-color: var(--app-border);
  white-space: nowrap;
}
.table tbody tr:hover{ background: rgba(var(--app-primary-rgb), .04); }

/* JS-enhanced table tools */
.table-tools .table-search{ border-radius: 999px; padding-left: .9rem; padding-right: .9rem; }
.table-meta{ opacity: .9; }
.table-sortable{ cursor: pointer; user-select: none; position: relative; }
.table-sortable::after{
  content: "⇅";
  position: absolute;
  right: .5rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: .75rem;
  color: #94a3b8;
}
.table-sortable.sorted-asc::after{ content: "↑"; color: rgba(var(--app-primary-rgb), .9); }
.table-sortable.sorted-desc::after{ content: "↓"; color: rgba(var(--app-primary-rgb), .9); }

.auth-wrap{
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(2, 6, 23, .70), rgba(2, 6, 23, .50)),
    radial-gradient(1200px 600px at 10% 10%, rgba(79,70,229,.22), transparent 50%),
    radial-gradient(900px 500px at 90% 20%, rgba(16,185,129,.18), transparent 55%),
    radial-gradient(900px 500px at 30% 90%, rgba(14,165,233,.16), transparent 55%),
    url("../img/bg_site.png") center/cover no-repeat,
    #0b1220;
}

[data-theme="dark"] body{
  --app-bg: #0b1220;
  --app-card: #0f172a;
  --app-surface: #0f172a;
  --app-surface-2: rgba(15, 23, 42, .72);
  --app-text: #e5e7eb;
  --app-muted: #94a3b8;
  --app-border: rgba(148, 163, 184, .16);
  background: var(--app-bg);
  color: #e5e7eb;
}
[data-theme="dark"] .bg-white{ background: var(--app-card) !important; }
[data-theme="dark"] .app-sidebar{ background: var(--app-card); }
[data-theme="dark"] .card{ background: var(--app-card); }
[data-theme="dark"] .list-group-item{ background: transparent; color: #e5e7eb; }
[data-theme="dark"] .list-group-item:hover{ background: rgba(99,102,241,.12); }
[data-theme="dark"] .list-group-item.active{
  background: rgba(99,102,241,.18);
  color: #fff;
}
[data-theme="dark"] .table thead th{ color: #cbd5e1; }
[data-theme="dark"] .table-sortable::after{ color: rgba(148, 163, 184, .9); }

@media (prefers-reduced-motion: reduce){
  *{ transition: none !important; scroll-behavior: auto !important; }
  .card:hover{ transform: none !important; }
  .btn:hover{ transform: none !important; }
}
