@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,600;1,400&family=DM+Sans:wght@400;500;600;700&display=swap');

:root {
  --midnight: #041a0b;
  --navy:     #062514;
  --card:     #093d26;
  --elevated: #0E5D3B;
  --gold:     #D8AB53;
  --gold-lt:  #e8c47a;
  --gold-bg:  rgba(216,171,83,0.1);
  --cream:    #F5EBD7;
  --muted:    rgba(245,235,215,0.45);
  --secondary:rgba(245,235,215,0.7);
  --border:   rgba(216,171,83,0.18);
  --green:    #10b981;
  --red:      #ef4444;
  --radius:   12px;
  --font:     'DM Sans', system-ui, sans-serif;
  --serif:    'Cormorant Garamond', Georgia, serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--midnight); color: var(--cream); font-family: var(--font); font-size: 14px; -webkit-font-smoothing: antialiased; }
a { color: var(--gold); text-decoration: none; }

/* ── LOGIN ───────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 40% 15%, #0E5D3B 0%, var(--midnight) 65%);
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 36px 32px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
}
.login-brand { text-align: center; margin-bottom: 28px; }
.login-brand .wordmark {
  font-family: var(--serif); font-size: 32px; font-weight: 600;
  letter-spacing: 0.18em; color: var(--cream);
}
.login-brand .sub { font-size: 11px; letter-spacing: 0.14em; color: var(--muted); text-transform: uppercase; margin-top: 4px; }
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; color: var(--secondary); text-transform: uppercase; margin-bottom: 6px; }
.form-input {
  width: 100%; padding: 11px 14px; border-radius: 8px;
  background: rgba(0,0,0,0.25); border: 1px solid var(--border);
  color: var(--cream); font-family: var(--font); font-size: 14px;
  outline: none; transition: border-color 0.2s;
}
.form-input:focus { border-color: var(--gold); }
.form-select { width: 100%; padding: 11px 14px; border-radius: 8px; background: rgba(0,0,0,0.25); border: 1px solid var(--border); color: var(--cream); font-family: var(--font); font-size: 14px; outline: none; appearance: none; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 18px; border-radius: 8px; font-family: var(--font); font-size: 13px; font-weight: 600; cursor: pointer; border: none; transition: opacity 0.2s, transform 0.15s; }
.btn:hover { opacity: 0.9; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--gold), #c89840); color: #041a0b; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--secondary); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 13px 20px; font-size: 14px; }
.w-full { width: 100%; }
.login-error { color: var(--red); font-size: 12px; margin-top: 8px; display: none; }
.login-hint { font-size: 11px; color: var(--muted); text-align: center; margin-top: 12px; line-height: 1.5; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 11px; margin: 16px 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,0.3); border-top-color: white; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── APP SHELL ───────────────────────────────────────────── */
.app { display: flex; height: 100dvh; overflow: hidden; }

.sidebar {
  width: 220px; flex-shrink: 0;
  background: var(--card); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 0;
  overflow-y: auto;
}
.sidebar-brand {
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand .wordmark { font-family: var(--serif); font-size: 22px; font-weight: 600; letter-spacing: 0.12em; color: var(--cream); }
.sidebar-brand .sub { font-size: 9px; letter-spacing: 0.12em; color: var(--muted); text-transform: uppercase; margin-top: 2px; }
.nav-section { padding: 16px 12px; flex: 1; }
.nav-label { font-size: 9px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); padding: 0 8px; margin-bottom: 6px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px;
  font-size: 13px; font-weight: 500; color: var(--secondary);
  transition: background 0.15s, color 0.15s; text-decoration: none;
  margin-bottom: 2px;
}
.nav-link:hover { background: var(--gold-bg); color: var(--cream); }
.nav-link.active { background: var(--gold-bg); color: var(--gold); font-weight: 600; border-left: 2px solid var(--gold); padding-left: 8px; }
.nav-icon { font-size: 15px; width: 20px; text-align: center; }
.sidebar-bottom { padding: 16px 12px; border-top: 1px solid var(--border); }

.main { flex: 1; overflow-y: auto; background: var(--navy); display: flex; flex-direction: column; }
.page-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 24px 28px 0; flex-shrink: 0;
}
.page-title { font-family: var(--serif); font-size: 26px; font-weight: 600; color: var(--cream); line-height: 1; }
.page-subtitle { font-size: 12px; color: var(--muted); margin-top: 4px; font-style: italic; }
.page-body { padding: 20px 28px 28px; flex: 1; }

/* ── BENTO GRID (dashboard) ─────────────────────────────── */
.bento {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 14px;
  height: calc(100dvh - 88px);
}
.tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex; flex-direction: column;
  overflow: hidden;
  position: relative;
  transition: border-color 0.2s, box-shadow 0.2s;
  animation: tileIn 0.5s ease both;
}
.tile:hover { border-color: rgba(216,171,83,0.35); box-shadow: 0 0 0 1px rgba(216,171,83,0.1); }

@keyframes tileIn {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Staggered animation delays */
.tile:nth-child(1)  { animation-delay: 0.05s; }
.tile:nth-child(2)  { animation-delay: 0.10s; }
.tile:nth-child(3)  { animation-delay: 0.15s; }
.tile:nth-child(4)  { animation-delay: 0.20s; }
.tile:nth-child(5)  { animation-delay: 0.25s; }
.tile:nth-child(6)  { animation-delay: 0.30s; }
.tile:nth-child(7)  { animation-delay: 0.35s; }
.tile:nth-child(8)  { animation-delay: 0.40s; }
.tile:nth-child(9)  { animation-delay: 0.45s; }
.tile:nth-child(10) { animation-delay: 0.50s; }

/* Span sizes */
.tile-wide  { grid-column: span 2; }
.tile-tall  { grid-row: span 2; }
.tile-full  { grid-column: span 4; }

/* Tile header */
.tile-label { font-size: 9px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.tile-value { font-family: var(--serif); font-size: 36px; font-weight: 600; line-height: 1; }
.tile-sub   { font-size: 11px; color: var(--muted); margin-top: 6px; }
.tile-icon  { position: absolute; bottom: 16px; right: 16px; font-size: 28px; opacity: 0.18; }

/* Color variants */
.tile-gold  { border-color: rgba(216,171,83,0.35); background: linear-gradient(135deg, #093d26, #0a4520); }
.tile-accent { background: linear-gradient(135deg, #093d26 0%, #052010 100%); }

/* Gold glow ring on key tiles */
.tile-gold::before {
  content: ''; position: absolute; inset: -1px; border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(216,171,83,0.3), transparent 60%);
  pointer-events: none;
}

.text-gold  { color: var(--gold); }
.text-green { color: var(--green); }
.text-red   { color: var(--red); }
.text-muted { color: var(--muted); }

/* ── PROGRESS BAR ────────────────────────────────────────── */
.prog-track { height: 5px; background: rgba(255,255,255,0.08); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.prog-fill  { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--gold), var(--gold-lt)); transition: width 0.8s ease; }

/* ── BADGE ───────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 99px; font-size: 10px; font-weight: 600;
  letter-spacing: 0.06em;
}
.badge-gold   { background: rgba(216,171,83,0.18); color: var(--gold); border: 1px solid rgba(216,171,83,0.3); }
.badge-green  { background: rgba(16,185,129,0.15); color: var(--green); }
.badge-plan   { background: rgba(216,171,83,0.22); color: var(--gold); }
.badge-free   { background: rgba(14,93,59,0.6); color: #86c4a0; }

/* ── TOOLS GRID ─────────────────────────────────────────── */
.tools-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tool-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: 8px;
  background: rgba(245,235,215,0.05); border: 1px solid var(--border);
  color: var(--secondary); font-size: 12px; font-weight: 500;
  cursor: pointer; transition: background 0.15s, border-color 0.15s;
  text-align: left;
}
.tool-btn:hover { background: var(--gold-bg); border-color: rgba(216,171,83,0.35); color: var(--cream); }

/* ── PLAN TIER ───────────────────────────────────────────── */
.plan-tier { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-radius: 8px; background: rgba(216,171,83,0.08); border: 1px solid rgba(216,171,83,0.2); margin-bottom: 8px; }
.plan-name { font-size: 13px; font-weight: 600; color: var(--gold); }
.plan-price { font-size: 11px; color: var(--muted); }

/* ── GIVING METER ────────────────────────────────────────── */
.giving-ring {
  width: 80px; height: 80px; border-radius: 50%;
  border: 4px solid rgba(216,171,83,0.15);
  display: flex; align-items: center; justify-content: center;
  position: relative; margin: 0 auto 12px;
}
.giving-ring-fill {
  position: absolute; inset: -4px; border-radius: 50%;
  border: 4px solid transparent;
  border-top-color: var(--gold); border-right-color: var(--gold);
}
.giving-pct { font-family: var(--serif); font-size: 20px; font-weight: 600; color: var(--gold); }

/* ── SCROLLABLE TILE BODY ────────────────────────────────── */
.tile-scroll { flex: 1; overflow-y: auto; margin-top: 6px; }
.tile-scroll::-webkit-scrollbar { width: 3px; }
.tile-scroll::-webkit-scrollbar-track { background: transparent; }
.tile-scroll::-webkit-scrollbar-thumb { background: rgba(216,171,83,0.25); border-radius: 99px; }

/* ── ADMIN SPECIFIC ──────────────────────────────────────── */
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th { padding: 8px 12px; text-align: left; font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--border); }
.admin-table td { padding: 10px 12px; border-bottom: 1px solid rgba(216,171,83,0.07); }
.admin-table tr:hover td { background: var(--gold-bg); }
.stat-row { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 24px; }
.stat-box { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.stat-box-label { font-size: 10px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.stat-box-value { font-family: var(--serif); font-size: 28px; font-weight: 600; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 24px; margin-bottom: 20px; }
.card-title { font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--secondary); margin-bottom: 16px; }
.input-row { display: flex; gap: 10px; flex-wrap: wrap; }
.input-row .form-group { flex: 1; min-width: 140px; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 10px; font-weight: 600; margin-left: 6px; }
.tag-active   { background: rgba(16,185,129,0.15); color: var(--green); }
.tag-inactive { background: rgba(239,68,68,0.12); color: var(--red); }
.tag-free     { background: rgba(14,93,59,0.5); color: #86c4a0; }
.tag-pro      { background: rgba(216,171,83,0.2); color: var(--gold); }
.action-btn { padding: 4px 10px; border-radius: 6px; font-size: 11px; font-weight: 600; cursor: pointer; border: 1px solid var(--border); background: transparent; color: var(--secondary); font-family: var(--font); }
.action-btn:hover { background: var(--gold-bg); color: var(--cream); border-color: rgba(216,171,83,0.4); }
.action-btn-danger { border-color: rgba(239,68,68,0.3); color: var(--red); }
.action-btn-danger:hover { background: rgba(239,68,68,0.1); }

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 900px) {
  .bento { grid-template-columns: repeat(2, 1fr); grid-template-rows: auto; height: auto; }
  .tile-wide { grid-column: span 2; }
  .tile-tall { grid-row: span 1; }
  .tile-full { grid-column: span 2; }
  .sidebar { display: none; }
}
