/* ============================================================
   FamilyVault Design System
   Palette: Forest (#DAD7CD #A3B18A #588157 #3A5A40 #344E41)
   Style: Crystal Glass / Glassmorphism / Organic Rounded
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=DM+Sans:opsz,wght@9..40,300;400;500&display=swap');

/* --- Variables -------------------------------------------- */
:root {
  --c-sand:    #DAD7CD;
  --c-sage:    #A3B18A;
  --c-moss:    #588157;
  --c-forest:  #3A5A40;
  --c-pine:    #344E41;

  --c-bg:      #f0ede6;
  --c-bg2:     #e8e4db;
  --c-surface: rgba(255,255,255,0.55);
  --c-surface-strong: rgba(255,255,255,0.72);
  --c-glass-border: rgba(255,255,255,0.45);
  --c-glass-shadow: rgba(52,78,65,0.12);

  --c-text:    #1e2d25;
  --c-text2:   #3A5A40;
  --c-text3:   #6b8c72;
  --c-muted:   #a0a89c;

  --c-success: #3d8b4e;
  --c-warning: #c9882a;
  --c-danger:  #c94040;
  --c-info:    #2d6fa3;

  --c-overdue:  #c94040;
  --c-urgent:   #c9882a;
  --c-warning2: #8c7a2a;
  --c-normal:   #3d8b4e;

  --r-sm:  8px;
  --r-md:  14px;
  --r-lg:  20px;
  --r-xl:  28px;
  --r-2xl: 36px;

  --blur:  18px;
  --blur2: 32px;

  --font-display: 'DM Serif Display', Georgia, serif;
  --font-body:    'DM Sans', system-ui, sans-serif;

  --nav-w: 260px;
  --header-h: 64px;
  --transition: 0.2s cubic-bezier(0.4,0,0.2,1);
  --shadow-sm: 0 2px 12px rgba(52,78,65,0.08);
  --shadow-md: 0 6px 28px rgba(52,78,65,0.13);
  --shadow-lg: 0 16px 48px rgba(52,78,65,0.18);
}

/* --- Reset ------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  color: var(--c-text);
  background: var(--c-bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Ambient background orbs */
body::before, body::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}
body::before {
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(88,129,87,0.12) 0%, transparent 70%);
  top: -200px; right: -150px;
}
body::after {
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(163,177,138,0.10) 0%, transparent 70%);
  bottom: -150px; left: -100px;
}

/* --- Glass card -------------------------------------------- */
.glass {
  background: var(--c-surface);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--c-glass-border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-md);
}
.glass-strong {
  background: var(--c-surface-strong);
  backdrop-filter: blur(var(--blur2));
  -webkit-backdrop-filter: blur(var(--blur2));
  border: 1px solid rgba(255,255,255,0.6);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
}
.glass-sm {
  background: var(--c-surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--c-glass-border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}

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

/* --- Sidebar / Nav ---------------------------------------- */
.sidebar {
  width: var(--nav-w);
  height: 100vh;
  position: fixed;
  left: 0; top: 0;
  background: rgba(52,78,65,0.92);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-right: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
  overflow-y: auto;
}
.sidebar-logo {
  padding: 28px 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-logo h1 {
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--c-sand);
  letter-spacing: 0.01em;
}
.sidebar-logo small {
  font-size: 11px;
  color: var(--c-sage);
  display: block;
  margin-top: 2px;
}
.sidebar-user {
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 500;
  color: #fff;
  flex-shrink: 0;
}
.sidebar-user-info { flex: 1; overflow: hidden; }
.sidebar-user-name { font-size: 13px; font-weight: 500; color: var(--c-sand); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 11px; color: var(--c-sage); text-transform: capitalize; }

.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-section-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--c-sage);
  padding: 16px 24px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 24px;
  color: rgba(218,215,205,0.7);
  text-decoration: none;
  font-size: 14px;
  font-weight: 400;
  border-radius: 0;
  transition: all var(--transition);
  position: relative;
}
.nav-item:hover { color: var(--c-sand); background: rgba(255,255,255,0.06); }
.nav-item.active {
  color: var(--c-sand);
  background: rgba(163,177,138,0.15);
  font-weight: 500;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 3px;
  background: var(--c-sage);
  border-radius: 0 3px 3px 0;
}
.nav-item svg { flex-shrink: 0; opacity: 0.75; }
.nav-item.active svg, .nav-item:hover svg { opacity: 1; }
.nav-badge {
  margin-left: auto;
  background: var(--c-danger);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer { padding: 16px 24px; border-top: 1px solid rgba(255,255,255,0.08); }
.sidebar-footer a {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: rgba(218,215,205,0.5);
  text-decoration: none;
  transition: color var(--transition);
}
.sidebar-footer a:hover { color: var(--c-sand); }

/* --- Main content ----------------------------------------- */
.main-content {
  margin-left: var(--nav-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.page-header {
  padding: 28px 32px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.page-title { font-family: var(--font-display); font-size: 28px; color: var(--c-pine); line-height: 1.2; }
.page-subtitle { font-size: 14px; color: var(--c-text3); margin-top: 4px; }
.page-body { padding: 24px 32px 48px; flex: 1; }

/* --- Cards ------------------------------------------------ */
.card {
  background: var(--c-surface);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--c-glass-border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-md);
  padding: 24px;
  transition: box-shadow var(--transition), transform var(--transition);
}
.card:hover { box-shadow: var(--shadow-lg); }
.card-title { font-size: 12px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--c-text3); margin-bottom: 8px; }
.card-value { font-family: var(--font-display); font-size: 32px; color: var(--c-pine); line-height: 1; }
.card-sub { font-size: 13px; color: var(--c-text3); margin-top: 6px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

/* Stat card accent left border */
.stat-card { border-left: 3px solid var(--c-moss); }
.stat-card.green  { border-left-color: var(--c-success); }
.stat-card.amber  { border-left-color: var(--c-warning); }
.stat-card.red    { border-left-color: var(--c-danger); }
.stat-card.blue   { border-left-color: var(--c-info); }

/* --- Tables ----------------------------------------------- */
.table-wrap {
  background: var(--c-surface);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--c-glass-border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.table-header {
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(88,129,87,0.12);
  flex-wrap: wrap;
  gap: 12px;
}
.table-header h3 { font-size: 16px; font-weight: 500; color: var(--c-pine); }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 12px 20px;
  text-align: left;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--c-text3);
  background: rgba(88,129,87,0.06);
  border-bottom: 1px solid rgba(88,129,87,0.1);
}
tbody tr {
  border-bottom: 1px solid rgba(88,129,87,0.07);
  transition: background var(--transition);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(163,177,138,0.08); }
tbody td { padding: 13px 20px; font-size: 14px; color: var(--c-text); }
tbody td.muted { color: var(--c-muted); font-size: 13px; }
tbody td.mono { font-variant-numeric: tabular-nums; }

/* --- Buttons ---------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 20px;
  border-radius: 50px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-primary {
  background: var(--c-forest);
  color: #fff;
  box-shadow: 0 2px 8px rgba(58,90,64,0.3);
}
.btn-primary:hover { background: var(--c-pine); box-shadow: 0 4px 16px rgba(58,90,64,0.4); transform: translateY(-1px); }
.btn-secondary {
  background: rgba(88,129,87,0.12);
  color: var(--c-forest);
  border: 1px solid rgba(88,129,87,0.2);
}
.btn-secondary:hover { background: rgba(88,129,87,0.2); }
.btn-ghost {
  background: transparent;
  color: var(--c-text3);
  border: 1px solid rgba(88,129,87,0.15);
}
.btn-ghost:hover { background: rgba(88,129,87,0.08); color: var(--c-text); }
.btn-danger { background: var(--c-danger); color: #fff; }
.btn-danger:hover { background: #a83535; transform: translateY(-1px); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-icon { padding: 8px; border-radius: 50%; width: 36px; height: 36px; justify-content: center; }

/* --- Forms ------------------------------------------------ */
.form-group { margin-bottom: 20px; }
label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--c-text2);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}
.form-control {
  width: 100%;
  padding: 11px 16px;
  background: rgba(255,255,255,0.6);
  border: 1px solid rgba(88,129,87,0.2);
  border-radius: var(--r-md);
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--c-text);
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
}
.form-control:focus {
  outline: none;
  border-color: var(--c-moss);
  box-shadow: 0 0 0 3px rgba(88,129,87,0.15);
  background: rgba(255,255,255,0.85);
}
.form-control::placeholder { color: var(--c-muted); }
select.form-control { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23588157' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-hint { font-size: 12px; color: var(--c-muted); margin-top: 5px; }
.form-error { font-size: 12px; color: var(--c-danger); margin-top: 5px; }

/* --- Badges / Pills --------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
}
.badge-green  { background: rgba(61,139,78,0.12);  color: #2d6b3a; }
.badge-amber  { background: rgba(201,136,42,0.12); color: #8c5c15; }
.badge-red    { background: rgba(201,64,64,0.12);  color: #8c2828; }
.badge-blue   { background: rgba(45,111,163,0.12); color: #1a4f7a; }
.badge-gray   { background: rgba(88,129,87,0.1);   color: var(--c-text3); }
.badge-sage   { background: rgba(163,177,138,0.2); color: var(--c-forest); }

/* Urgency badges */
.badge-overdue { background: rgba(201,64,64,0.15);  color: var(--c-danger); }
.badge-urgent  { background: rgba(201,136,42,0.15); color: var(--c-warning); }
.badge-normal  { background: rgba(61,139,78,0.12);  color: var(--c-success); }

/* Priority */
.priority-urgent { color: var(--c-danger); }
.priority-high   { color: var(--c-warning); }
.priority-medium { color: var(--c-moss); }
.priority-low    { color: var(--c-muted); }

/* --- Modal ------------------------------------------------ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(30,45,37,0.45);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal {
  background: rgba(240,237,230,0.96);
  backdrop-filter: blur(32px);
  border: 1px solid rgba(255,255,255,0.7);
  border-radius: var(--r-2xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.96) translateY(8px);
  transition: transform var(--transition);
}
.modal-overlay.active .modal { transform: scale(1) translateY(0); }
.modal-header {
  padding: 24px 28px 0;
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-family: var(--font-display); font-size: 22px; color: var(--c-pine); }
.modal-body { padding: 20px 28px 28px; }
.modal-footer { padding: 0 28px 24px; display: flex; gap: 10px; justify-content: flex-end; }

/* --- Action queue item ------------------------------------ */
.action-item {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(88,129,87,0.07);
  transition: background var(--transition);
}
.action-item:last-child { border-bottom: none; }
.action-item:hover { background: rgba(163,177,138,0.08); }
.action-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
}
.action-dot.overdue { background: var(--c-danger); box-shadow: 0 0 0 3px rgba(201,64,64,0.2); }
.action-dot.urgent  { background: var(--c-warning); }
.action-dot.warning { background: #c9c12a; }
.action-dot.normal  { background: var(--c-success); }
.action-content { flex: 1; }
.action-title { font-size: 14px; font-weight: 500; color: var(--c-text); }
.action-meta  { font-size: 12px; color: var(--c-text3); margin-top: 2px; }
.action-days  { font-size: 12px; font-weight: 500; flex-shrink: 0; margin-top: 3px; }

/* --- Charts placeholder ----------------------------------- */
.chart-container { position: relative; width: 100%; }

/* --- Notifications bell ----------------------------------- */
.notif-bell { position: relative; }
.notif-count {
  position: absolute;
  top: -4px; right: -4px;
  background: var(--c-danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  width: 18px; height: 18px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--c-bg);
}

/* --- Toast notifications ---------------------------------- */
.toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: rgba(240,237,230,0.97);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.7);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 14px 18px;
  display: flex; align-items: center; gap: 12px;
  min-width: 280px; max-width: 360px;
  animation: slideUp 0.3s cubic-bezier(0.4,0,0.2,1);
  font-size: 14px;
}
.toast.success { border-left: 3px solid var(--c-success); }
.toast.error   { border-left: 3px solid var(--c-danger); }
.toast.info    { border-left: 3px solid var(--c-info); }
@keyframes slideUp {
  from { opacity:0; transform: translateY(16px); }
  to   { opacity:1; transform: translateY(0); }
}

/* --- Scroll effects --------------------------------------- */
.fade-in { opacity: 0; transform: translateY(20px); transition: opacity 0.5s ease, transform 0.5s ease; }
.fade-in.visible { opacity: 1; transform: translateY(0); }

/* Stagger children */
.stagger > * { opacity: 0; transform: translateY(16px); transition: opacity 0.4s ease, transform 0.4s ease; }
.stagger > *.visible { opacity: 1; transform: translateY(0); }
.stagger > *:nth-child(1) { transition-delay: 0.05s; }
.stagger > *:nth-child(2) { transition-delay: 0.10s; }
.stagger > *:nth-child(3) { transition-delay: 0.15s; }
.stagger > *:nth-child(4) { transition-delay: 0.20s; }
.stagger > *:nth-child(5) { transition-delay: 0.25s; }
.stagger > *:nth-child(6) { transition-delay: 0.30s; }

/* --- Market ticker (scrolling) ---------------------------- */
.ticker-wrap {
  background: rgba(52,78,65,0.85);
  backdrop-filter: blur(8px);
  border-radius: var(--r-md);
  overflow: hidden;
  padding: 8px 0;
  position: relative;
}
.ticker-label {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--c-forest);
  padding: 0 16px;
  display: flex; align-items: center;
  font-size: 11px; font-weight: 500; letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c-sage);
  z-index: 1;
}
.ticker-track {
  display: flex; gap: 40px;
  animation: ticker 40s linear infinite;
  padding: 0 16px 0 120px;
  width: max-content;
}
.ticker-track:hover { animation-play-state: paused; }
.ticker-item {
  display: flex; align-items: center; gap: 6px;
  white-space: nowrap;
  font-size: 13px; color: var(--c-sand);
}
.ticker-sym { font-weight: 600; color: var(--c-sage); }
.ticker-up   { color: #5cb870; }
.ticker-down { color: #e06060; }
@keyframes ticker { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* --- Empty state ------------------------------------------ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--c-muted);
}
.empty-state svg { opacity: 0.3; margin-bottom: 16px; }
.empty-state h3 { font-size: 16px; font-weight: 500; color: var(--c-text3); margin-bottom: 6px; }
.empty-state p  { font-size: 14px; }

/* --- Mobile hamburger ------------------------------------- */
.hamburger {
  display: none;
  position: fixed;
  top: 16px; left: 16px;
  z-index: 200;
  background: var(--c-pine);
  border: none;
  border-radius: 50%;
  width: 44px; height: 44px;
  cursor: pointer;
  align-items: center; justify-content: center;
  box-shadow: var(--shadow-md);
}
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(30,45,37,0.5);
  z-index: 99;
}

/* --- Responsive ------------------------------------------- */
@media (max-width: 768px) {
  :root { --nav-w: 280px; }

  .hamburger { display: flex; }
  .sidebar {
    transform: translateX(-100%);
    z-index: 200;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay { display: block; opacity: 0; pointer-events: none; transition: opacity var(--transition); }
  .sidebar-overlay.active { opacity: 1; pointer-events: all; }

  .main-content { margin-left: 0; }
  .page-header { padding: 70px 20px 0; }
  .page-body { padding: 20px 20px 40px; }

  .form-row, .form-row.cols-3 { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }

  table { display: block; overflow-x: auto; white-space: nowrap; }

  .card-value { font-size: 24px; }
  .page-title { font-size: 22px; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .modal { border-radius: var(--r-xl) var(--r-xl) 0 0; max-height: 95vh; }
  .modal-overlay { align-items: flex-end; padding: 0; }
}

/* --- Utilities -------------------------------------------- */
.flex   { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-24 { gap: 24px; }
.mt-4   { margin-top: 4px; }
.mt-8   { margin-top: 8px; }
.mt-16  { margin-top: 16px; }
.mt-24  { margin-top: 24px; }
.mb-16  { margin-bottom: 16px; }
.mb-24  { margin-bottom: 24px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text-muted { color: var(--c-muted); }
.text-danger { color: var(--c-danger); }
.text-success { color: var(--c-success); }
.fw-500 { font-weight: 500; }
.font-display { font-family: var(--font-display); }
.w-full { width: 100%; }
.hidden { display: none !important; }
.sr-only { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0,0,0,0); }
.divider { border: none; border-top: 1px solid rgba(88,129,87,0.1); margin: 20px 0; }
