/* ============================================================
   Diamond Vault – Glassmorphism Design System
   Free Edition v1.0.0
   ============================================================ */

/* --- Reset & Base ------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-primary:      #0a0a12;
  --bg-secondary:    #111118;
  --bg-tertiary:     #18181f;
  --glass-bg:        rgba(255,255,255,0.04);
  --glass-border:    rgba(255,255,255,0.08);
  --glass-hover:     rgba(255,255,255,0.07);
  --text-primary:    #f0f0f5;
  --text-secondary:  #9898b0;
  --text-muted:      #5a5a70;
  --accent:          #6366f1;
  --accent-hover:    #818cf8;
  --accent-light:    rgba(99,102,241,0.15);
  --success:         #22c55e;
  --success-light:   rgba(34,197,94,0.15);
  --danger:          #f87171;
  --danger-light:    rgba(248,113,113,0.15);
  --warning:         #fbbf24;
  --warning-light:   rgba(251,191,36,0.12);
  --border-color:    rgba(255,255,255,0.07);
  --radius:          14px;
  --radius-sm:       8px;
  --radius-lg:       20px;
  --shadow:          0 8px 32px rgba(0,0,0,0.4);
  --shadow-sm:       0 4px 16px rgba(0,0,0,0.3);
  --sidebar-width:   260px;
  --topbar-height:   64px;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* --- Scrollbar -------------------------------------------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* --- Background Orbs -------------------------------------- */
.gradient-orb {
  position: fixed; border-radius: 50%;
  pointer-events: none; z-index: 0;
  filter: blur(80px); opacity: 0.35;
}
.gradient-orb-1 {
  width: 600px; height: 600px;
  background: radial-gradient(circle, #6366f1 0%, transparent 70%);
  top: -200px; right: -200px;
}
.gradient-orb-2 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, #818cf8 0%, transparent 70%);
  bottom: -150px; left: -150px;
}

/* --- Layout ------------------------------------------------ */
.app-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* --- Sidebar ---------------------------------------------- */
.sidebar {
  width: var(--sidebar-width);
  background: rgba(10,10,18,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--glass-border);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center; gap: 12px;
}
.sidebar-logo .logo-icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #818cf8);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  box-shadow: 0 0 20px rgba(99,102,241,0.4);
}
.sidebar-logo span {
  font-size: 17px; font-weight: 700; color: var(--text-primary);
}

.sidebar-nav { flex: 1; padding: 16px 12px; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: var(--radius-sm);
  color: var(--text-secondary); text-decoration: none;
  font-size: 14px; font-weight: 500;
  transition: all 0.2s ease;
  margin-bottom: 2px;
}
.sidebar-nav a:hover {
  background: var(--glass-hover);
  color: var(--text-primary);
}
.sidebar-nav a.active {
  background: var(--accent-light);
  color: var(--accent-hover);
}
.sidebar-nav a .nav-icon { width: 20px; text-align: center; }

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--border-color);
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--glass-bg);
  margin-bottom: 8px;
}
.sidebar-user .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: white;
  flex-shrink: 0;
}
.sidebar-user .user-info { min-width: 0; }
.sidebar-user .user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .user-role { font-size: 11px; color: var(--text-muted); }

/* --- Main Content ----------------------------------------- */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-height);
  background: rgba(10,10,18,0.7);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--glass-border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px;
  position: sticky; top: 0; z-index: 50;
}
.topbar h1 { font-size: 20px; font-weight: 700; }

.page-content { padding: 28px; flex: 1; }

/* --- Cards ------------------------------------------------ */
.glass-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.glass-card:hover {
  border-color: rgba(255,255,255,0.14);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.glass-card-static {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-sm);
}

/* --- Stat Cards ------------------------------------------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  padding: 20px 24px;
  display: flex; align-items: center; gap: 16px;
}
.stat-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.stat-icon.indigo { background: rgba(99,102,241,0.15); }
.stat-icon.green  { background: rgba(34,197,94,0.15); }
.stat-icon.red    { background: rgba(248,113,113,0.15); }
.stat-icon.amber  { background: rgba(251,191,36,0.12); }
.stat-icon.purple { background: rgba(168,85,247,0.15); }

.stat-label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.stat-value { font-size: 22px; font-weight: 800; }
.stat-value.positive { color: var(--success); }
.stat-value.negative { color: var(--danger); }

/* --- Buttons ---------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; cursor: pointer;
  border: none; text-decoration: none;
  transition: all 0.2s ease; white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, #6366f1, #818cf8);
  color: white;
  box-shadow: 0 4px 16px rgba(99,102,241,0.35);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #818cf8, #a5b4fc);
  box-shadow: 0 6px 20px rgba(99,102,241,0.5);
  transform: translateY(-1px);
}
.btn-secondary {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
}
.btn-secondary:hover {
  border-color: rgba(255,255,255,0.15);
  color: var(--text-primary);
}
.btn-danger {
  background: var(--danger-light);
  border: 1px solid rgba(248,113,113,0.3);
  color: var(--danger);
}
.btn-danger:hover {
  background: rgba(248,113,113,0.25);
}
.btn-success {
  background: var(--success-light);
  border: 1px solid rgba(34,197,94,0.3);
  color: var(--success);
}
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* --- Forms ------------------------------------------------ */
.form-group { margin-bottom: 20px; }
.form-label {
  display: block; font-size: 13px; font-weight: 500;
  color: var(--text-secondary); margin-bottom: 8px;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  background: #111118;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: #f0f0f5;
  font-size: 14px;
  padding: 10px 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.form-select {
  color-scheme: dark;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239898b0' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
.form-select option {
  background: #111118;
  color: #f0f0f5;
}
.form-textarea { resize: vertical; min-height: 100px; }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-muted); }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 5px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 5px; }

/* --- Table ------------------------------------------------ */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 12px 16px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid rgba(255,255,255,0.03);
  transition: background 0.15s;
}
tbody tr:hover { background: rgba(255,255,255,0.025); }
tbody td {
  padding: 13px 16px;
  font-size: 14px; color: var(--text-secondary);
}
tbody td:first-child { color: var(--text-primary); }

/* --- Badges ----------------------------------------------- */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.badge-income  { background: var(--success-light); color: var(--success); }
.badge-expense { background: var(--danger-light);  color: var(--danger); }
.badge-admin   { background: var(--accent-light);  color: var(--accent-hover); }
.badge-warning { background: var(--warning-light); color: var(--warning); }

/* --- Category Pill ---------------------------------------- */
.cat-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px; font-size: 12px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
}

/* --- Progress Bar ----------------------------------------- */
.progress-bar {
  height: 6px; border-radius: 3px;
  background: rgba(255,255,255,0.06);
  overflow: hidden;
}
.progress-fill {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, #6366f1, #818cf8);
  transition: width 0.5s ease;
}
.progress-fill.over-budget { background: linear-gradient(90deg, #f87171, #fb923c); }
.progress-fill.warning     { background: linear-gradient(90deg, #fbbf24, #f59e0b); }

/* --- Flash Messages --------------------------------------- */
.flash {
  padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: 14px; margin-bottom: 20px;
  display: flex; align-items: center; gap: 8px;
}
.flash-success { background: var(--success-light); border: 1px solid rgba(34,197,94,0.3); color: var(--success); }
.flash-error   { background: var(--danger-light);  border: 1px solid rgba(248,113,113,0.3); color: var(--danger); }
.flash-warning { background: var(--warning-light); border: 1px solid rgba(251,191,36,0.3);  color: var(--warning); }
.flash-info    { background: var(--accent-light);  border: 1px solid rgba(99,102,241,0.3);  color: var(--accent-hover); }

/* --- Auth Pages (Login / Register) ----------------------- */
.auth-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px; position: relative;
}
.auth-card {
  width: 100%; max-width: 460px;
  position: relative; z-index: 1;
}
.auth-logo {
  text-align: center; margin-bottom: 40px;
}
.auth-logo .logo-icon-lg {
  width: 72px; height: 72px; border-radius: 18px;
  background: linear-gradient(135deg, #6366f1, #818cf8);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px; font-size: 32px;
  box-shadow: 0 0 40px rgba(99,102,241,0.4);
}
.auth-logo h1 { font-size: 26px; font-weight: 800; margin-bottom: 6px; }
.auth-logo p  { color: var(--text-secondary); font-size: 14px; }

/* --- Section Header --------------------------------------- */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}
.section-header h2 { font-size: 18px; font-weight: 700; }

/* --- Grid Layouts ----------------------------------------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* --- Misc ------------------------------------------------- */
.text-right  { text-align: right; }
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.flex  { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }

/* --- Responsive ------------------------------------------- */
@media (max-width: 1024px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.3s ease; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .page-content { padding: 16px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}
