@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css');
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

:root {
  --sidebar-width: 264px;
  --header-height: 72px;
  --bg: #f3f5ff;
  --bg-dark: #0f172a;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --stroke: #e5e7eb;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: radial-gradient(circle at 85% -20%, rgba(236,72,153,.18), transparent 35%),
              radial-gradient(circle at -10% 110%, rgba(37,99,235,.16), transparent 32%),
              var(--bg);
  color: var(--text);
}

/* auth */
.auth-body { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(130deg,#4f46e5,#db2777,#f59e0b); }
.auth-card {
  width: 390px;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(14px);
  border-radius: 18px;
  padding: 28px;
  box-shadow: 0 30px 60px rgba(0,0,0,.25);
}
.auth-card h1 { margin: 0 0 6px; font-size: 25px; }
.auth-card p { margin: 0 0 16px; color: #4b5563; }
.auth-card label { display: block; margin: 10px 0 6px; font-size: 12px; font-weight: 700; text-transform: uppercase; color: #4b5563; }
.auth-card input { width: 100%; padding: 11px 12px; border: 1px solid #d1d5db; border-radius: 10px; }

/* sidebar */
.admin-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  padding: 18px 12px;
  background: linear-gradient(180deg,#0b1020 0%, #121a30 52%, #1f0c32 100%);
  border-right: 1px solid rgba(255,255,255,.07);
  color: #f3f4f6;
  overflow-y: auto;
  z-index: 30;
  transition: transform .25s ease;
}
.sidebar-header { text-align: center; margin-bottom: 14px; }
.logo-badge {
  width: 58px;
  height: 58px;
  margin: 0 auto 10px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg,#22d3ee,#ec4899);
  box-shadow: 0 10px 30px rgba(236,72,153,.4);
}
.sidebar-header h2 { margin: 0; font-size: 24px; letter-spacing: -.3px; }
.sidebar-header p { margin: 3px 0 0; color: #9ca3af; font-size: 12px; }
.menu-label {
  padding: 12px 10px 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .9px;
  color: #94a3b8;
  font-weight: 700;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #cbd5e1;
  text-decoration: none;
  padding: 11px 12px;
  border-radius: 12px;
  margin: 4px 0;
  transition: .2s ease;
  font-size: 14px;
  font-weight: 500;
}
.menu-item i { width: 18px; text-align: center; }
.menu-item:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
  transform: translateX(3px);
}
.menu-item.active {
  background: linear-gradient(135deg,rgba(59,130,246,.35),rgba(236,72,153,.35));
  color: #fff;
  border: 1px solid rgba(255,255,255,.18);
}

/* header */
.admin-header {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--header-height);
  background: rgba(255,255,255,.86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(226,232,240,.9);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  z-index: 20;
}
.header-left, .header-right { display: flex; align-items: center; gap: 12px; }
.header-title { margin: 0; font-size: 18px; }
.header-subtitle { color: var(--muted); font-size: 12px; }
.menu-toggle, .theme-toggle, .quick-icon {
  border: 0;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  cursor: pointer;
  background: #eef2ff;
  color: #334155;
}
.theme-toggle { background: #fff0f6; color: #be185d; }
.quick-icon { background: #ecfeff; color: #0f766e; }
.header-search {
  position: relative;
  margin-left: 6px;
}
.header-search i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  font-size: 12px;
}
.header-search input {
  border: 1px solid #dbe2ef;
  border-radius: 999px;
  padding: 9px 12px 9px 34px;
  min-width: 260px;
  background: #fff;
}
.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #e2e8f0;
  padding: 6px 10px 6px 6px;
  border-radius: 999px;
  background: #fff;
}
.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg,#2563eb,#7c3aed);
  font-size: 11px;
  font-weight: 700;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.15; }
.user-meta small { color: var(--muted); font-size: 11px; }
.logout-link { color: #dc2626; text-decoration: none; font-size: 12px; font-weight: 700; }

/* content */
.main-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--header-height);
  padding: 22px;
}
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.page-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}
.page-subtitle {
  margin: 4px 0 0;
  color: #64748b;
  font-size: 13px;
}
.grid {
  display: grid;
  grid-template-columns: repeat(4,minmax(0,1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.dashboard-grid-2 {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 14px;
}
.card {
  background: var(--surface);
  border: 1px solid #e7ebf5;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 12px 28px rgba(15,23,42,.06);
}
.kpi { color: #fff; border: 0; box-shadow: 0 16px 30px rgba(0,0,0,.15); }
.kpi h3 { margin: 0; font-size: 12px; opacity: .9; text-transform: uppercase; letter-spacing: .55px; }
.kpi p { margin: 8px 0 0; font-size: 27px; font-weight: 700; }
.kpi small { display: block; margin-top: 6px; opacity: .92; font-size: 12px; }
.kpi.a { background: linear-gradient(130deg,#2563eb,#60a5fa); }
.kpi.b { background: linear-gradient(130deg,#10b981,#4ade80); }
.kpi.c { background: linear-gradient(130deg,#f97316,#fb923c); }
.kpi.d { background: linear-gradient(130deg,#db2777,#f472b6); }

.monthly-bars { display: grid; gap: 10px; }
.month-row { display: grid; grid-template-columns: 90px 1fr 130px; gap: 10px; align-items: center; }
.month-label { font-size: 12px; color: #64748b; }
.bar-stack { display: grid; gap: 6px; }
.bar-track { width: 100%; height: 8px; border-radius: 999px; background: #eef2ff; overflow: hidden; }
.bar-income { height: 100%; background: linear-gradient(90deg,#10b981,#22c55e); border-radius: 999px; }
.bar-expense { height: 100%; background: linear-gradient(90deg,#f59e0b,#f97316); border-radius: 999px; }
.month-amounts { display: grid; gap: 3px; text-align: right; }
.month-amounts .income { font-size: 11px; color: #166534; }
.month-amounts .expense { font-size: 11px; color: #b45309; }

.status-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; margin-bottom: 12px; }
.status-chip {
  border-radius: 12px;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  display: grid;
  gap: 3px;
}
.status-chip span { color: #64748b; font-size: 12px; }
.status-chip strong { font-size: 20px; }
.status-chip.paid { background: #ecfdf5; border-color: #bbf7d0; }
.status-chip.partial { background: #fff7ed; border-color: #fed7aa; }
.status-chip.unpaid { background: #fef2f2; border-color: #fecaca; }

.mini-kpis { display: grid; gap: 8px; }
.mini-kpis > div {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.mini-kpis small { color: #64748b; }
.mini-kpis strong { font-size: 13px; }

.stock-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  padding: 4px 8px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 12px;
}
.stock-pill.warn { background: #ffedd5; color: #b45309; }
.stock-pill.critical { background: #fee2e2; color: #b91c1c; }

.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--stroke);
}

.table thead {
  background: #f8fafc;
}

.table th {
  padding: 0.875rem 1.25rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.8125rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--stroke);
}

.table td {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--stroke);
  font-size: 0.875rem;
  color: #111827;
  font-weight: 400;
}

.table tbody tr {
  transition: all .2s ease;
}

.table tbody tr:hover {
  background: #f9fafb;
}

.form-card {
  background: #fff;
  border-radius: 16px;
  border: 1px solid #e7ebf5;
  padding: 14px;
  box-shadow: 0 12px 28px rgba(0,0,0,.06);
  margin-bottom: 14px;
}
.form-card > summary { list-style: none; cursor: pointer; font-weight: 700; color: #4338ca; }
.form-card > summary::-webkit-details-marker { display: none; }
.row { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 10px; }
input, select, textarea {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid #d4dbe8;
  border-radius: 10px;
  font-size: 13px;
  background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: 0;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99,102,241,.14);
}
.btn {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn-primary { background: linear-gradient(135deg,#2563eb,#7c3aed); color: #fff; }
.btn-success { background: linear-gradient(135deg,#16a34a,#22c55e); color: #fff; }
.btn-warning { background: linear-gradient(135deg,#ea580c,#f59e0b); color: #fff; }
.btn-secondary { background: #eef2ff; color: #334155; border: 1px solid #dbe2ef; }
.btn-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 8px; gap: 6px; }
.table-actions { display: flex; gap: 6px; }
.icon-btn { min-width: 34px; justify-content: center; }
.alert { padding: 10px 12px; border-radius: 10px; margin-bottom: 10px; font-size: 13px; border: 1px solid transparent; }
.alert-danger { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.alert-success { background: #dcfce7; color: #166534; border-color: #bbf7d0; }

.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  inset: 0;
  background: rgba(2, 6, 23, .55);
  padding: 20px;
}
.modal.open { display: block; }
.modal-content {
  background: #fff;
  margin: 4vh auto;
  width: min(760px, 100%);
  border-radius: 14px;
  border: 1px solid #dbe2ef;
  box-shadow: 0 30px 60px rgba(15, 23, 42, .25);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #e2e8f0;
}
.modal-title {
  margin: 0;
  font-size: 16px;
}
.modal-body {
  padding: 16px;
}
.modal-close {
  border: 1px solid #dbe2ef;
  background: #fff;
  color: #475569;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  cursor: pointer;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 12px;
}

.admin-footer {
  margin-left: var(--sidebar-width);
  padding: 12px 22px 18px;
  color: #64748b;
  font-size: 12px;
}

/* theme */
body.theme-dark {
  background: radial-gradient(circle at 95% -10%, rgba(236,72,153,.2), transparent 35%),
              radial-gradient(circle at -10% 120%, rgba(37,99,235,.2), transparent 30%),
              #0b1224;
  color: #e2e8f0;
}
body.theme-dark .admin-header {
  background: rgba(15,23,42,.8);
  border-bottom-color: rgba(71,85,105,.5);
}
body.theme-dark .header-title { color: #f8fafc; }
body.theme-dark .header-subtitle { color: #94a3b8; }
body.theme-dark .header-search input,
body.theme-dark .user-pill,
body.theme-dark .card,
body.theme-dark .form-card,
body.theme-dark .table {
  background: rgba(15,23,42,.8);
  border-color: rgba(71,85,105,.6);
  color: #e2e8f0;
}
body.theme-dark .table thead { background: rgba(30,41,59,.85); }
body.theme-dark .table th { color: #cbd5e1; border-bottom-color: rgba(71,85,105,.55); }
body.theme-dark .table td { color: #dbe4ef; border-top-color: rgba(71,85,105,.4); }
body.theme-dark .table tbody tr:hover { background: rgba(51,65,85,.45); }
body.theme-dark .page-subtitle { color: #94a3b8; }
body.theme-dark .btn-secondary { background: rgba(30,41,59,.9); color: #e2e8f0; border-color: rgba(100,116,139,.6); }
body.theme-dark .btn-danger { background: rgba(127,29,29,.35); color: #fecaca; border-color: rgba(248,113,113,.35); }
body.theme-dark .modal-content { background: #0f172a; border-color: rgba(100,116,139,.45); }
body.theme-dark .modal-header { border-bottom-color: rgba(100,116,139,.45); }
body.theme-dark .modal-close { background: #1e293b; color: #cbd5e1; border-color: rgba(100,116,139,.5); }
body.theme-dark .bar-track { background: rgba(71,85,105,.5); }
body.theme-dark .month-label { color: #94a3b8; }
body.theme-dark .month-amounts .income { color: #4ade80; }
body.theme-dark .month-amounts .expense { color: #fb923c; }
body.theme-dark .status-chip { border-color: rgba(100,116,139,.5); }
body.theme-dark .status-chip.paid { background: rgba(22,163,74,.2); }
body.theme-dark .status-chip.partial { background: rgba(234,88,12,.2); }
body.theme-dark .status-chip.unpaid { background: rgba(220,38,38,.2); }
body.theme-dark .mini-kpis > div { background: rgba(30,41,59,.75); border-color: rgba(100,116,139,.5); }
body.theme-dark .mini-kpis small { color: #94a3b8; }
body.theme-dark input, body.theme-dark select, body.theme-dark textarea {
  background: rgba(15,23,42,.9);
  border-color: rgba(100,116,139,.7);
  color: #f1f5f9;
}
body.theme-dark .admin-footer { color: #94a3b8; }

/* responsive */
@media (max-width: 1120px) {
  .header-search input { min-width: 200px; }
  .grid, .row { grid-template-columns: 1fr 1fr; }
  .dashboard-grid-2 { grid-template-columns: 1fr; }
  .month-row { grid-template-columns: 82px 1fr; }
  .month-amounts { grid-column: 1 / -1; text-align: left; grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .admin-sidebar { transform: translateX(-100%); }
  .admin-sidebar.open { transform: translateX(0); }
  .admin-header, .main-content, .admin-footer { margin-left: 0; left: 0; }
  .header-search { display: none; }
  .user-meta { display: none; }
  .grid, .row { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
}

