/* ================================
   GLOBAL RESET
================================ */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, sans-serif;
  background: #f8fafc;
  color: #0f172a;
  line-height: 1.6;
}

/* ================================
   TYPOGRAPHY
================================ */
h1, h2, h3, h4 {
  font-weight: 600;
  margin-bottom: 0.75rem;
}

p {
  color: #334155;
  margin-bottom: 0.5rem;
}

small {
  color: #64748b;
}

/* ================================
   LAYOUT
================================ */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem;
}

.section {
  margin-top: 2rem;
}

/* ================================
   CARD
================================ */
.card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 1.25rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

/* ================================
   BUTTONS
================================ */
button {
  font-family: inherit;
  border: none;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
}

.btn-primary {
  background: #2563eb;
  color: #ffffff;
}

.btn-primary:hover {
  background: #1d4ed8;
}

.btn-danger {
  background: #dc2626;
  color: #ffffff;
}

.btn-secondary {
  background: #e5e7eb;
  color: #0f172a;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ================================
   INPUTS
================================ */
input {
  width: 100%;
  padding: 0.55rem 0.6rem;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  font-size: 0.9rem;
}

input:focus {
  outline: none;
  border-color: #2563eb;
}

/* ================================
   LISTS
================================ */
ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

li {
  padding: 0.6rem 0;
  border-bottom: 1px solid #e5e7eb;
}

li:last-child {
  border-bottom: none;
}

/* ================================
   STATUS BADGES
================================ */
.badge {
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-pending {
  background: #fef3c7;
  color: #92400e;
}

.badge-approved {
  background: #dcfce7;
  color: #166534;
}

.badge-rejected {
  background: #fee2e2;
  color: #991b1b;
}

.badge-closed {
  background: #e5e7eb;
  color: #334155;
}

/* ================================
   RESPONSIVE
================================ */
@media (max-width: 768px) {
  .container {
    padding: 1rem;
  }
}

/* ================================
   NAVBAR
================================ */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
}

.navbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  color: #0f172a;
}

.brand-badge {
  background: #2563eb;
  color: #ffffff;
  border-radius: 8px;
  padding: 0.25rem 0.45rem;
  font-size: 0.75rem;
}

.nav-links {
  display: flex;
  gap: 0.75rem;
}

.nav-links a {
  text-decoration: none;
}

@media (max-width: 640px) {
  .nav-links {
    gap: 0.5rem;
  }
}
/* ================================
   BRAND TONE
================================ */
.brand span:last-child {
  font-weight: 600;
  letter-spacing: 0.2px;
}
/* ================================
   MOTION CORE
================================ */

/* Page enter */
body {
  animation: pageFadeIn 160ms ease-out both;
}

@keyframes pageFadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Buttons: hover & press */
button {
  transition:
    transform 120ms ease,
    box-shadow 120ms ease,
    background-color 120ms ease,
    opacity 120ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.08);
}

button:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.12);
}

/* Cards: subtle lift on hover (desktop only) */
@media (hover: hover) and (pointer: fine) {
  .card {
    transition: transform 140ms ease, box-shadow 140ms ease;
  }

  .card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
  }
}

/* Links: quick feedback */
a {
  transition: opacity 120ms ease;
}
a:hover {
  opacity: 0.85;
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* ===== Admin User Modal ===== */
.modal.hidden {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
}

.modal-card {
  position: relative;
  background: #fff;
  width: 95%;
  max-width: 720px;
  max-height: 90vh;
  margin: 5vh auto;
  border-radius: 12px;
  overflow-y: auto;
  padding: 1rem;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header button {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
}
/* ===== Admin Loan Card ===== */
.loan-card {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 1rem;
  padding: 1rem;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
  margin-bottom: 1rem;
}

.loan-card-left {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.loan-user-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background: #e5e7eb;
}

.loan-card-center {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.loan-card-right {
  display: flex;
  align-items: center;
  flex-direction: row;
  gap: 0.5rem;
  align-items: flex-end;
}

.muted {
  color: #64748b;
  font-size: 0.85rem;
}

.modal-body input,
.modal-body textarea {
  width: 100%;
  padding: 0.6rem;
  margin-top: 0.25rem;
  margin-bottom: 0.75rem;
  border-radius: 8px;
  border: 1px solid #cbd5f5;
}

.modal-body label {
  font-weight: 500;
}


/* ================================
   FORM FEEDBACK
================================ */
.text-error {
  color: #b91c1c;
  margin-top: 0.5rem;
  font-size: 0.85rem;
}

/* ================================
   ADMIN PAY MODAL
================================ */
.pay-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.5rem 1rem;
  padding: 0.75rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  margin: 0.5rem 0 1rem;
}

.modal-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}

.table-lite {
  max-height: 260px;
  overflow: auto;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
}

.table-lite table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.table-lite th,
.table-lite td {
  text-align: left;
  padding: 0.45rem 0.4rem;
  border-bottom: 1px solid #e5e7eb;
}

.table-lite thead th {
  color: #475569;
  font-weight: 600;
  background: #f8fafc;
  position: sticky;
  top: 0;
}

.table-lite tbody tr.paid {
  background: #f0fdf4;
}

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

/* ================================
   UI POLISH
================================ */
body {
  background: radial-gradient(1200px 400px at 20% -10%, #eef2ff 0%, #f8fafc 40%, #f8fafc 100%);
}

.card {
  border-radius: 12px;
}

input, textarea, select {
  font-family: inherit;
  border: 1px solid #e2e8f0;
  background: #ffffff;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

button.btn-secondary:hover {
  background: #dbe3ee;
}

.section h3 {
  margin-bottom: 0.75rem;
}

.loan-card {
  border: 1px solid #e5e7eb;
}

@media (max-width: 768px) {
  .loan-card {
    grid-template-columns: 1fr;
  }
  .loan-card-right {
    align-items: flex-start;
  }
}


/* ================================
   DEBUG PANEL
================================ */
.debug-panel {
  border: 1px dashed #cbd5f5;
  background: #f8fafc;
}

.debug-logs {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: #0b1220;
  color: #e2e8f0;
  border-radius: 10px;
  overflow: auto;
  max-height: 320px;
  font-size: 12px;
  line-height: 1.45;
}


/* ================================
   USER LIST (ADMIN)
================================ */
.user-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.user-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  margin-bottom: 0.75rem;
}

.user-card:hover {
  background: #f8fafc;
}

.user-card-left {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  min-width: 0;
}

.user-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background: #e5e7eb;
}

.user-meta {
  min-width: 0;
}

.user-meta strong {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-meta small {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ================================
   KPI GRID (USER)
================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.kpi-card small {
  display: block;
  color: #64748b;
}

/* ================================
   TIMELINE / TAGS
================================ */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  border: 1px solid #e2e8f0;
  background: #ffffff;
}

.tag.done {
  background: #dcfce7;
  border-color: #bbf7d0;
  color: #166534;
}

.tag.pending {
  background: #fef3c7;
  border-color: #fde68a;
  color: #92400e;
}

.tag.fail {
  background: #fee2e2;
  border-color: #fecaca;
  color: #991b1b;
}
