:root {
  --c-navy: #0e0f3b;
  --c-blue: #07407b;
  --c-sky: #7fcdee;
  --c-orange: #f7931e;
  --c-white: #ffffff;
  --bg-0: #070922;
  --text-main: #f5f9ff;
  --text-dim: #c6d8ef;
  --border: rgba(127, 205, 238, 0.22);
  --glass-bg: linear-gradient(
    140deg,
    rgba(255, 255, 255, 0.17),
    rgba(255, 255, 255, 0.05)
  );
  --glass-shadow: 0 22px 52px rgba(0, 0, 0, 0.35);
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --ff-head: "Sora", sans-serif;
  --ff-body: "Source Sans 3", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html,
body {
  min-height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--ff-body);
  color: var(--text-main);
  background:
    radial-gradient(circle at 15% 10%, rgba(127, 205, 238, 0.2), transparent 35%),
    radial-gradient(circle at 88% 8%, rgba(247, 147, 30, 0.18), transparent 34%),
    linear-gradient(160deg, var(--bg-0), var(--c-navy));
  overflow-x: hidden;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: -20%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 20% 20%, rgba(127, 205, 238, 0.28), transparent 48%),
    radial-gradient(circle at 80% 15%, rgba(247, 147, 30, 0.26), transparent 44%),
    radial-gradient(circle at 70% 80%, rgba(7, 64, 123, 0.32), transparent 52%);
  animation: gradient-drift 20s ease-in-out infinite;
}

@keyframes gradient-drift {
  0% {
    transform: translate3d(0, 0, 0) scale(1.02);
    opacity: 0.95;
  }
  50% {
    transform: translate3d(-4%, 3%, 0) scale(1.08);
    opacity: 1;
  }
  100% {
    transform: translate3d(3%, -3%, 0) scale(1.02);
    opacity: 0.95;
  }
}

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0 0 0.5rem;
  line-height: 1.2;
  font-family: var(--ff-head);
}

p {
  margin: 0;
}

a {
  color: var(--c-sky);
  text-underline-offset: 3px;
}

.eyebrow {
  color: var(--c-orange);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-size: 0.8rem;
}

.lead {
  color: var(--text-dim);
}

.muted {
  color: #abc4e2;
  font-size: 0.92rem;
}

.glass {
  background: rgba(10, 16, 42, 0.72);
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--glass-shadow);
  border-radius: var(--radius-lg);
}

.btn,
button {
  border: 0;
  border-radius: var(--radius-sm);
  min-height: 44px;
  padding: 0.68rem 1rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 140ms ease, filter 140ms ease, background-color 140ms ease;
}

.btn:hover,
button:hover {
  transform: translateY(-1px);
  filter: brightness(1.02);
}

.btn-primary {
  background: linear-gradient(120deg, var(--c-orange), #ffb24d);
  color: #1e1301;
}

.btn-secondary {
  background: rgba(127, 205, 238, 0.18);
  color: #ecf6ff;
  border: 1px solid rgba(127, 205, 238, 0.4);
}

.btn-success {
  background: linear-gradient(135deg, #0f78c8, #34a6f7);
  color: #f7fcff;
}

.btn-danger {
  background: linear-gradient(135deg, #bb2a2a, #e45454);
  color: #fff7f7;
}

.form-group {
  display: grid;
  gap: 0.4rem;
}

.form-group label {
  font-weight: 600;
  color: var(--text-dim);
}

.form-control,
input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: linear-gradient(
    140deg,
    rgba(127, 205, 238, 0.15),
    rgba(7, 64, 123, 0.28)
  );
  color: var(--c-white);
  padding: 0.65rem 0.8rem;
  font: inherit;
}

input::placeholder,
textarea::placeholder {
  color: #c7d8ea;
}

select option {
  color: #f7fbff;
  background: #0a1a43;
}

.form-control:focus,
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(247, 147, 30, 0.55);
  box-shadow:
    0 0 0 2px rgba(247, 147, 30, 0.18),
    0 8px 20px rgba(0, 0, 0, 0.22);
}

.card {
  background: rgba(5, 10, 36, 0.46);
  border: 1px solid rgba(127, 205, 238, 0.2);
  border-radius: var(--radius-md);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.card-header {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid rgba(127, 205, 238, 0.24);
  background: rgba(7, 64, 123, 0.22);
}

.card-body {
  padding: 1rem;
}

.progress {
  height: 12px;
  border-radius: 999px;
  background: rgba(127, 205, 238, 0.22);
  overflow: hidden;
  margin: 0.9rem 0;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--c-sky), var(--c-orange));
}

.stat-box {
  background: rgba(6, 13, 46, 0.66);
  border: 1px solid rgba(127, 205, 238, 0.2);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.stat-box.compact {
  margin-bottom: 0.8rem;
}

.stat-box-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #bad7ef;
}

.stat-box-value {
  font-size: clamp(1.28rem, 3.1vw, 1.9rem);
  font-weight: 700;
  color: #f7fbff;
  margin-top: 0.25rem;
}

.stat-box-value.small {
  font-size: 1.24rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.stat-card {
  padding: 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(127, 205, 238, 0.2);
  background: rgba(5, 11, 39, 0.55);
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
  margin: 0.7rem 0;
}

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

.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.28rem 0.62rem;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: capitalize;
}

.pill.warning {
  background: rgba(247, 147, 30, 0.2);
  color: #ffca87;
  border: 1px solid rgba(247, 147, 30, 0.45);
}

.pill.success {
  background: rgba(52, 166, 247, 0.2);
  color: #d9f0ff;
  border: 1px solid rgba(52, 166, 247, 0.45);
}

.pill.danger {
  background: rgba(211, 47, 47, 0.22);
  color: #ffd4d4;
  border: 1px solid rgba(211, 47, 47, 0.42);
}

.pill.info {
  background: rgba(127, 205, 238, 0.22);
  color: #caedff;
  border: 1px solid rgba(127, 205, 238, 0.42);
}

.alert {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid;
  padding: 0.65rem 0.75rem;
  margin-top: 0.7rem;
}

.alert-success {
  border-color: rgba(52, 166, 247, 0.5);
  background: rgba(52, 166, 247, 0.16);
  color: #d7eeff;
}

.alert-danger {
  border-color: rgba(211, 47, 47, 0.45);
  background: rgba(211, 47, 47, 0.16);
  color: #ffd3d3;
}

.alert-warning {
  border-color: rgba(247, 147, 30, 0.5);
  background: rgba(247, 147, 30, 0.15);
  color: #ffd4a7;
}

.alert-info {
  border-color: rgba(127, 205, 238, 0.45);
  background: rgba(127, 205, 238, 0.16);
  color: #caedff;
}

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid rgba(127, 205, 238, 0.2);
}

.list-item:last-child {
  border-bottom: 0;
}

.list-item-content {
  flex: 1;
}

.list-item-title {
  font-weight: 600;
}

.list-item-subtitle {
  color: var(--text-dim);
  font-size: 0.9rem;
}

.list-item-amount {
  white-space: nowrap;
  font-weight: 700;
  color: #ffca87;
}

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(127, 205, 238, 0.2);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

th,
td {
  padding: 0.72rem;
  text-align: left;
  border-bottom: 1px solid rgba(127, 205, 238, 0.16);
}

th {
  background: rgba(7, 64, 123, 0.24);
  font-size: 0.84rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  border: 1px dashed rgba(127, 205, 238, 0.38);
  border-radius: var(--radius-md);
  color: var(--text-dim);
}

.empty-state-icon {
  font-size: 0.86rem;
  font-weight: 700;
  margin-bottom: 0.45rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 4px solid rgba(127, 205, 238, 0.26);
  border-top-color: var(--c-orange);
  animation: spin 1s linear infinite;
}

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

.stack {
  display: grid;
  gap: 0.8rem;
}

.gap-lg {
  gap: 1rem;
}

.form-grid {
  display: grid;
  gap: 0.8rem;
}

.form-actions {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 0.6rem;
}

.form-actions.split {
  justify-content: stretch;
}

.form-actions.split .btn {
  flex: 1 1 0;
}

/* Auth */
body.auth-page {
  min-height: 100vh;
}

.auth-shell {
  min-height: 100vh;
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  padding: 1.2rem;
}

.auth-layout {
  width: min(1100px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 1rem;
  align-items: stretch;
}

.auth-hero {
  padding: 1.4rem;
  display: grid;
  gap: 1rem;
}

.auth-hero h1 {
  font-size: clamp(1.5rem, 3.1vw, 2.25rem);
}

.auth-highlights {
  display: grid;
  gap: 0.65rem;
}

.auth-highlights article {
  display: grid;
  gap: 0.15rem;
  padding: 0.75rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(127, 205, 238, 0.26);
  background: rgba(4, 10, 35, 0.5);
}

.auth-highlights strong {
  color: #f9f3c1;
  font-size: 1rem;
}

.auth-highlights span {
  color: var(--text-dim);
  font-size: 0.93rem;
}

.auth-stack {
  display: grid;
}

.auth-card {
  padding: 1.35rem;
  width: 100%;
}

.auth-brand {
  display: grid;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.auth-logo {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 0.35rem 0.55rem;
  border-radius: 999px;
  background: rgba(127, 205, 238, 0.16);
  border: 1px solid rgba(127, 205, 238, 0.35);
  font-weight: 700;
  font-size: 0.9rem;
  color: #e7f4ff;
}

.auth-copy {
  font-size: 0.98rem;
}

.auth-form {
  display: grid;
  gap: 0.8rem;
}

.auth-field {
  display: grid;
  gap: 0.45rem;
}

.auth-actions {
  display: grid;
  gap: 0.6rem;
}

.auth-submit {
  width: 100%;
}

.auth-switch {
  margin-top: 1rem;
  font-size: 0.95rem;
  color: var(--text-dim);
}

/* Dashboard */
body.dashboard-page {
  min-height: 100vh;
  position: relative;
  z-index: 1;
  padding: 1rem;
}

.dashboard-header {
  position: sticky;
  top: 0.8rem;
  z-index: 30;
  margin-bottom: 1rem;
  padding: 0.8rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.dashboard-header h1 {
  margin: 0.15rem 0 0;
  font-size: clamp(1.1rem, 2.6vw, 1.5rem);
}

.dashboard-greeting {
  color: #dbefff;
  font-weight: 600;
  text-align: right;
}

.menu-toggle {
  display: none;
}

.dashboard-shell {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.dashboard-sidebar {
  position: sticky;
  top: 6.4rem;
  padding: 1rem 0.75rem;
}

.sidebar-top {
  padding: 0 0.45rem 0.8rem;
  border-bottom: 1px solid rgba(127, 205, 238, 0.2);
  margin-bottom: 0.8rem;
}

.sidebar-top h2 {
  margin: 0.2rem 0 0;
  font-size: 1.2rem;
}

.sidebar-nav {
  display: grid;
  gap: 0.3rem;
}

.menu-item {
  width: 100%;
  text-align: left;
  border-radius: var(--radius-sm);
  background: rgba(127, 205, 238, 0.1);
  border: 1px solid transparent;
  color: #edf7ff;
  padding: 0.65rem 0.75rem;
  min-height: 42px;
}

.menu-item:hover {
  border-color: rgba(127, 205, 238, 0.36);
}

.menu-item.active {
  background: linear-gradient(135deg, rgba(7, 64, 123, 0.94), rgba(18, 96, 170, 0.9));
  border-color: rgba(127, 205, 238, 0.46);
}

.menu-logout {
  margin-top: 0.8rem;
  border-color: rgba(211, 47, 47, 0.28);
  background: rgba(211, 47, 47, 0.12);
  color: #ffdede;
}

.dashboard-main {
  min-width: 0;
}

.dashboard-content {
  min-height: 65vh;
  padding: 1rem;
}

.section-head {
  margin-bottom: 0.9rem;
  display: grid;
  gap: 0.25rem;
}

.section-head h3 {
  margin: 0;
}

.loan-item {
  padding: 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(127, 205, 238, 0.24);
  background: rgba(6, 12, 42, 0.56);
}

.loan-item.compact {
  padding: 0.75rem;
}

.loan-item-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.7rem;
  margin-bottom: 0.6rem;
}

.loan-item-head h5 {
  margin: 0 0 0.25rem;
}

.sidebar-backdrop {
  display: none;
}

/* Alerts injected by app.js */
body > .alert {
  position: fixed;
  top: 1rem;
  right: 1rem;
  min-width: min(360px, calc(100vw - 2rem));
  z-index: 1200;
  margin: 0;
}

@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .auth-layout {
    grid-template-columns: 1fr;
  }

  .auth-hero {
    order: 2;
  }

  .auth-stack {
    order: 1;
  }

  body.dashboard-page {
    padding: 0.65rem;
  }

  .menu-toggle {
    display: inline-flex;
  }

  .dashboard-greeting {
    display: none;
  }

  .dashboard-shell {
    grid-template-columns: 1fr;
  }

  .dashboard-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(290px, 86vw);
    z-index: 60;
    border-radius: 0;
    transform: translateX(-102%);
    transition: transform 180ms ease;
    overflow-y: auto;
    padding-top: 1rem;
  }

  body.menu-open .dashboard-sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
    display: block;
  }

  body.menu-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .dashboard-content {
    min-height: calc(100vh - 138px);
    padding: 0.8rem;
  }

  .meta-grid,
  .meta-grid.two {
    grid-template-columns: 1fr;
  }

  .form-actions,
  .form-actions.split {
    flex-direction: column;
  }

  .form-actions .btn {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .auth-shell {
    padding: 0.6rem;
  }

  .auth-card,
  .auth-hero {
    padding: 1rem;
  }

  .dashboard-header {
    top: 0.45rem;
    padding: 0.65rem 0.7rem;
  }

  .dashboard-header h1 {
    font-size: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0ms !important;
    transition-duration: 0ms !important;
  }

  body::before {
    animation: none;
  }
}

@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .glass {
    background: rgba(10, 16, 42, 0.92);
  }
}
