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

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0c0c0e;
  --bg2:       #111114;
  --bg3:       #18181d;
  --border:    rgba(255,255,255,0.07);
  --border2:   rgba(255,255,255,0.12);
  --text:      #f0efe8;
  --muted:     #6b6a66;
  --muted2:    #9a9890;
  --accent:    #e8b44a;
  --accent-bg: rgba(232,180,74,0.08);
  --accent-border: rgba(232,180,74,0.2);
  --green:     #4ade80;
  --green-bg:  rgba(74,222,128,0.08);
  --red:       #f87171;
  --red-bg:    rgba(248,113,113,0.08);
  --blue:      #60a5fa;
  --blue-bg:   rgba(96,165,250,0.08);
  --serif:     'Instrument Serif', Georgia, serif;
  --sans:      'DM Sans', sans-serif;
  --mono:      'DM Mono', monospace;
  --radius:    10px;
  --radius-lg: 14px;
}

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-weight: 400;
  line-height: 1.6;
  min-height: 100vh;
}

/* Noise texture overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
  opacity: 0.4;
}

/* Typography */
h1, h2, h3, h4 { font-weight: 500; letter-spacing: -0.02em; color: var(--text); }
h1 { font-size: clamp(2rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); }
h3 { font-size: 1.1rem; }
p { color: var(--muted2); line-height: 1.7; }
a { color: inherit; text-decoration: none; }

/* Nav */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 max(24px, calc((100vw - 1100px) / 2));
  height: 60px;
  background: rgba(12,12,14,0.8);
  backdrop-filter: blur(12px);
  border-bottom: 0.5px solid var(--border);
}

.nav-logo {
  font-family: var(--serif);
  font-size: 1.3rem;
  color: var(--text);
  display: flex; align-items: center; gap: 8px;
}

.nav-logo span {
  width: 26px; height: 26px;
  background: var(--accent);
  border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; color: #0c0c0e; font-weight: 600;
  font-family: var(--sans);
}

.nav-links { display: flex; align-items: center; gap: 28px; }
.nav-links a { font-size: 14px; color: var(--muted2); transition: color 0.15s; }
.nav-links a:hover { color: var(--text); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 20px; border-radius: var(--radius);
  font-family: var(--sans); font-size: 14px; font-weight: 500;
  cursor: pointer; transition: all 0.15s; border: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent); color: #0c0c0e;
}
.btn-primary:hover { background: #f0c060; }

.btn-ghost {
  background: transparent; color: var(--muted2);
  border: 0.5px solid var(--border2);
}
.btn-ghost:hover { color: var(--text); border-color: var(--border2); background: var(--bg3); }

.btn-outline {
  background: transparent; color: var(--text);
  border: 0.5px solid var(--border2);
}
.btn-outline:hover { background: var(--bg3); }

.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-lg { padding: 12px 28px; font-size: 15px; }

/* Cards */
.card {
  background: var(--bg2);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
}

.card-sm { padding: 14px 16px; border-radius: var(--radius); }

/* Form elements */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 13px; font-weight: 500; color: var(--muted2); }

.input {
  background: var(--bg3); border: 0.5px solid var(--border2);
  border-radius: var(--radius); padding: 10px 14px;
  font-family: var(--sans); font-size: 14px; color: var(--text);
  outline: none; transition: border-color 0.15s; width: 100%;
}
.input:focus { border-color: var(--accent); }
.input::placeholder { color: var(--muted); }

select.input { cursor: pointer; }

/* Badge */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 500; padding: 3px 9px;
  border-radius: 20px; letter-spacing: 0.2px;
}
.badge-accent { background: var(--accent-bg); color: var(--accent); border: 0.5px solid var(--accent-border); }
.badge-green  { background: var(--green-bg);  color: var(--green);  border: 0.5px solid rgba(74,222,128,0.2); }
.badge-red    { background: var(--red-bg);    color: var(--red);    border: 0.5px solid rgba(248,113,113,0.2); }
.badge-blue   { background: var(--blue-bg);   color: var(--blue);   border: 0.5px solid rgba(96,165,250,0.2); }
.badge-muted  { background: var(--bg3);       color: var(--muted2); border: 0.5px solid var(--border); }

/* Divider */
.divider { height: 0.5px; background: var(--border); }

/* Page wrapper */
.page { padding-top: 60px; position: relative; z-index: 1; }

/* App layout (authenticated pages) */
.app-layout { display: flex; min-height: calc(100vh - 60px); }

.sidebar {
  width: 220px; flex-shrink: 0;
  border-right: 0.5px solid var(--border);
  padding: 24px 0;
  position: sticky; top: 60px; height: calc(100vh - 60px);
  overflow-y: auto;
}

.sidebar-section { padding: 0 12px; margin-bottom: 6px; }
.sidebar-label {
  font-size: 10px; font-weight: 500; letter-spacing: 0.8px;
  text-transform: uppercase; color: var(--muted);
  padding: 0 8px; margin-bottom: 4px; margin-top: 16px;
}

.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  font-size: 14px; color: var(--muted2);
  cursor: pointer; transition: all 0.15s;
  text-decoration: none;
}
.sidebar-link:hover { background: var(--bg3); color: var(--text); }
.sidebar-link.active { background: var(--accent-bg); color: var(--accent); }
.sidebar-link svg { width: 16px; height: 16px; flex-shrink: 0; }

.main-content { flex: 1; padding: 32px; max-width: 900px; }

/* Pro gate */
.pro-gate {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 12px; padding: 48px 24px;
  text-align: center; border: 0.5px dashed var(--border2);
  border-radius: var(--radius-lg);
}
.pro-gate-icon {
  width: 48px; height: 48px; border-radius: 12px;
  background: var(--accent-bg); border: 0.5px solid var(--accent-border);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}

/* Stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.stat-card {
  background: var(--bg3); border-radius: var(--radius);
  padding: 16px; border: 0.5px solid var(--border);
}
.stat-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.stat-value { font-size: 24px; font-weight: 500; letter-spacing: -0.03em; color: var(--text); font-family: var(--mono); }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 999;
  background: var(--bg3); border: 0.5px solid var(--border2);
  border-radius: var(--radius); padding: 12px 18px;
  font-size: 14px; color: var(--text);
  transform: translateY(80px); opacity: 0;
  transition: all 0.25s cubic-bezier(0.34,1.56,0.64,1);
  pointer-events: none;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-color: rgba(74,222,128,0.3); }
.toast.error   { border-color: rgba(248,113,113,0.3); }

/* Animations */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-up { animation: fadeUp 0.5s ease backwards; }
.fade-up-1 { animation-delay: 0.1s; }
.fade-up-2 { animation-delay: 0.2s; }
.fade-up-3 { animation-delay: 0.3s; }
.fade-up-4 { animation-delay: 0.4s; }

/* Utility */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.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; }
.mt-32 { margin-top: 32px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-sm   { font-size: 13px; }
.text-xs   { font-size: 12px; }
.text-muted  { color: var(--muted2); }
.text-accent { color: var(--accent); }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.font-mono   { font-family: var(--mono); }
.font-medium { font-weight: 500; }
.w-full { width: 100%; }
.text-center { text-align: center; }
