/* ============================================================
   JinYer Balance — Admin Dashboard
   Brand: #0a0a0a bg | #C2C8D4 silver | Space Grotesk + DM Sans
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=DM+Sans:wght@300;400;500;600&display=swap');

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

:root {
  --bg:           #0a0a0a;
  --surface:      #111214;
  --surface-2:    #161718;
  --border:       rgba(255,255,255,0.08);
  --border-hover: rgba(255,255,255,0.16);
  --silver:       #C2C8D4;
  --steel:        #8A9AB0;
  --slate:        #6e8393;
  --muted:        #94a3b8;
  --white:        #f7f8fa;
  --danger:       #ef4444;
  --success:      #22c55e;
  --warning:      #f59e0b;
  --font-head:    'Space Grotesk', system-ui, sans-serif;
  --font-body:    'DM Sans', system-ui, sans-serif;
  --radius:       999px;
  --radius-card:  14px;
  --radius-sm:    8px;
}

html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--white);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { cursor: pointer; font-family: var(--font-body); }

/* ── Scrollbar ────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 3px; }

/* ── Login Page ───────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  top: -40%;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(194,200,212,0.06) 0%, transparent 70%);
  pointer-events: none;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 40px;
  position: relative;
  z-index: 1;
}

.login-logo {
  text-align: center;
  margin-bottom: 8px;
}

.login-logo span {
  font-family: var(--font-head);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--white);
}

.login-badge {
  display: block;
  text-align: center;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--silver);
  background: rgba(194,200,212,0.08);
  border: 1px solid rgba(194,200,212,0.15);
  border-radius: var(--radius);
  padding: 3px 12px;
  margin: 0 auto 32px;
  width: fit-content;
}

.login-title {
  font-family: var(--font-head);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
  text-align: center;
}

.login-sub {
  font-size: 0.875rem;
  color: var(--muted);
  text-align: center;
  margin-bottom: 32px;
}

/* ── Form Elements ────────────────────────────────────── */
.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.04em;
  margin-bottom: 7px;
}

.field input {
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--white);
  transition: border-color 0.2s;
  outline: none;
}

.field input:focus {
  border-color: rgba(194,200,212,0.4);
  background: rgba(255,255,255,0.06);
}

.field input::placeholder { color: var(--slate); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: none;
  border-radius: var(--radius);
  padding: 11px 24px;
  transition: all 0.2s;
  cursor: pointer;
}

.btn-primary {
  background: var(--silver);
  color: #0a0a0a;
  width: 100%;
  padding: 13px;
  font-size: 0.9rem;
}

.btn-primary:hover { background: #d4dae5; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 8px 16px;
  font-size: 0.8rem;
}
.btn-ghost:hover { border-color: var(--border-hover); color: var(--white); }

.error-msg {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: var(--radius-sm);
  color: #fca5a5;
  font-size: 0.8rem;
  padding: 10px 14px;
  margin-bottom: 16px;
  display: none;
}
.error-msg.show { display: block; }

/* ── App Layout ───────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }

/* ── Sidebar ──────────────────────────────────────────── */
.sidebar {
  width: 220px;
  min-height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  padding: 0 20px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.sidebar-logo .wordmark {
  font-family: var(--font-head);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--white);
  display: block;
}

.sidebar-logo .badge {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--silver);
  margin-top: 2px;
  display: block;
}

.nav-section {
  padding: 0 12px;
  margin-bottom: 24px;
}

.nav-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--slate);
  padding: 0 8px;
  margin-bottom: 6px;
  display: block;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
  transition: all 0.15s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  text-decoration: none;
}

.nav-item:hover { background: rgba(255,255,255,0.04); color: var(--white); }
.nav-item.active { background: rgba(194,200,212,0.08); color: var(--silver); }

.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.7; }
.nav-item.active svg { opacity: 1; }

.nav-badge {
  margin-left: auto;
  background: var(--silver);
  color: #0a0a0a;
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: var(--radius);
  padding: 2px 7px;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px 12px 0;
  border-top: 1px solid var(--border);
}

.user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}
.user-row:hover { background: rgba(255,255,255,0.04); }

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(194,200,212,0.15);
  border: 1px solid rgba(194,200,212,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-head);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--silver);
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 0.8rem; font-weight: 600; color: var(--white); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.7rem; color: var(--muted); }

.logout-btn {
  background: none;
  border: none;
  color: var(--slate);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.15s;
  flex-shrink: 0;
}
.logout-btn:hover { color: var(--danger); }

/* ── Main Content ─────────────────────────────────────── */
.main {
  flex: 1;
  margin-left: 220px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 60px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 32px;
  gap: 16px;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-family: var(--font-head);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.topbar-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }

.page { padding: 32px; flex: 1; }

/* ── Stats Row ────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 20px 24px;
  transition: border-color 0.2s;
}
.stat-card:hover { border-color: var(--border-hover); }

.stat-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.stat-value {
  font-family: var(--font-head);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--white);
  line-height: 1;
  margin-bottom: 6px;
}

.stat-delta {
  font-size: 0.75rem;
  color: var(--muted);
}
.stat-delta.up { color: var(--success); }
.stat-delta.warn { color: var(--warning); }

/* ── Section ──────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-title {
  font-family: var(--font-head);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* ── Client Cards ─────────────────────────────────────── */
.clients-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.client-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 20px;
  transition: all 0.2s;
  cursor: pointer;
  text-decoration: none;
  display: block;
  color: inherit;
}
.client-card:hover { border-color: rgba(194,200,212,0.25); transform: translateY(-2px); }

.client-card-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.client-initials {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(194,200,212,0.08);
  border: 1px solid rgba(194,200,212,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-head);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--silver);
  flex-shrink: 0;
}

.client-info { flex: 1; min-width: 0; }
.client-name { font-weight: 600; font-size: 0.95rem; margin-bottom: 2px; }
.client-business { font-size: 0.8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.stage-badge {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: var(--radius);
  flex-shrink: 0;
}
.stage-badge.meeting    { background: rgba(139,166,176,0.15); color: #8ba6b0; }
.stage-badge.build      { background: rgba(245,158,11,0.12);  color: #f59e0b; }
.stage-badge.review     { background: rgba(139,92,246,0.12);  color: #a78bfa; }
.stage-badge.launch     { background: rgba(34,197,94,0.12);   color: #22c55e; }
.stage-badge.ongoing    { background: rgba(194,200,212,0.12); color: var(--silver); }
.stage-badge.proposal   { background: rgba(99,102,241,0.12);  color: #818cf8; }

.client-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--muted);
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* ── Empty State ──────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}
.empty-state svg { margin: 0 auto 16px; opacity: 0.3; }
.empty-state h3 { font-family: var(--font-head); font-size: 1rem; font-weight: 600; color: var(--white); margin-bottom: 8px; opacity: 0.5; }
.empty-state p { font-size: 0.85rem; }

/* ── Loading ──────────────────────────────────────────── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--muted);
  font-size: 0.875rem;
  gap: 10px;
}
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--silver);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Modal ────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.show { opacity: 1; pointer-events: all; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 32px;
  width: 100%;
  max-width: 480px;
  transform: translateY(12px);
  transition: transform 0.2s;
}
.modal-overlay.show .modal { transform: translateY(0); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.modal-title { font-family: var(--font-head); font-size: 1.1rem; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--muted); cursor: pointer; padding: 4px; border-radius: 4px; }
.modal-close:hover { color: var(--white); }

.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; }

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 900px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.3s; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .page { padding: 20px 16px; }
}
