:root {
  --bg: #0b0c0e;
  --panel: #14161a;
  --panel-2: #1a1e26;
  --border: #282c33;
  --border-2: #2a303b;
  --text: #eef1f5;
  --muted: #8d96a8;
  --dim: #b9c2d0;
  --blue: #6d8cff;
  --purple: #a78bfa;
  --green: #6ee7b7;
  --red: #f87171;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ---------- Auth ---------- */
.auth-wrap, .onboard-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.auth-card, .onboard-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 1.5rem;
  padding: 2.2rem 2.4rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 40px -12px rgba(0,0,0,0.8);
}
.onboard-card { max-width: 640px; }

.brand { display: flex; gap: 0.9rem; align-items: center; margin-bottom: 1.6rem; }
.brand.small { margin-bottom: 1.2rem; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(135deg, var(--purple), var(--blue));
  color: #fff; font-weight: 800; font-size: 1.4rem;
  display: flex; align-items: center; justify-content: center;
}
.brand.small .brand-mark { width: 34px; height: 34px; font-size: 1.1rem; border-radius: 9px; }
.brand-title { font-weight: 700; font-size: 1.3rem; letter-spacing: -0.02em; }
.brand-sub { color: var(--muted); font-size: 0.85rem; }

.tabs { display: flex; gap: 0.4rem; background: var(--panel-2); padding: 0.3rem; border-radius: 12px; margin-bottom: 1.2rem; }
.tab {
  flex: 1; border: none; background: transparent; color: var(--dim);
  padding: 0.55rem; border-radius: 9px; cursor: pointer; font-size: 0.92rem; font-weight: 600;
}
.tab.active { background: #232832; color: var(--text); }

.form { display: flex; flex-direction: column; gap: 0.85rem; }
.form label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.85rem; color: var(--dim); }
.form input, .form select, .form textarea {
  background: var(--panel-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 10px; padding: 0.65rem 0.8rem; font-size: 0.95rem; outline: none;
}
.form input:focus, .form select:focus, .form textarea:focus { border-color: var(--blue); }
.form textarea { min-height: 90px; resize: vertical; font-family: inherit; }

.btn {
  border: none; border-radius: 10px; padding: 0.7rem 1.1rem;
  font-weight: 600; font-size: 0.95rem; cursor: pointer; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--border);
  transition: opacity 0.15s, transform 0.05s;
}
.btn:hover { opacity: 0.88; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(135deg, var(--blue), var(--purple)); border: none; }
.btn.green { background: #1a3a2e; border-color: #23543f; color: var(--green); }
.btn.red { background: #3a1f1f; border-color: #5a2a2a; color: var(--red); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 0.4rem 0.8rem; font-size: 0.82rem; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.auth-note { margin-top: 1.3rem; color: var(--muted); font-size: 0.83rem; line-height: 1.5; }

/* ---------- Onboarding ---------- */
.onboard-head h1 { font-size: 1.6rem; letter-spacing: -0.02em; }
.onboard-head p { color: var(--muted); margin-top: 0.35rem; font-size: 0.92rem; }
.steps { display: flex; gap: 0.4rem; margin: 1.4rem 0 1.6rem; }
.step {
  flex: 1; text-align: center; font-size: 0.78rem; font-weight: 600; color: var(--muted);
  background: var(--panel-2); padding: 0.5rem 0.3rem; border-radius: 9px;
}
.step.active { color: var(--purple); background: #2a1f3a; border: 1px solid #43306b; }
.step.done { color: var(--green); }

.wizard-body { display: flex; flex-direction: column; gap: 1.1rem; }
.chips { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.chip {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 30px;
  padding: 0.35rem 0.9rem; font-size: 0.85rem; cursor: pointer; color: var(--dim); user-select: none;
}
.chip.on { background: #232b47; border-color: var(--blue); color: #c5d0ff; }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; background: var(--panel); border-right: 1px solid var(--border);
  padding: 1.3rem 0.9rem; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.nav { display: flex; flex-direction: column; gap: 0.25rem; }
.nav-btn {
  display: flex; align-items: center; gap: 0.7rem; border: none; background: transparent;
  color: var(--dim); padding: 0.7rem 0.9rem; border-radius: 10px; cursor: pointer;
  font-size: 0.93rem; font-weight: 500; text-align: left;
}
.nav-btn:hover { background: var(--panel-2); }
.nav-btn.active { background: var(--panel-2); color: var(--text); border-left: 3px solid var(--purple); }
.nav-btn span { font-size: 1rem; }
.side-foot { margin-top: auto; }
.logout { color: var(--red); }

.main { flex: 1; padding: 1.4rem 1.8rem; max-width: 1100px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.4rem; flex-wrap: wrap; gap: 0.8rem; }
.topbar-title { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
.stats { display: flex; gap: 0.6rem; align-items: center; }
.stat {
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 0.55rem 1rem; font-weight: 700; font-size: 0.95rem;
}
.stat .lbl { display: block; font-size: 0.68rem; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.stat.mode { color: var(--purple); cursor: pointer; }
.stat#stat-bell { display: flex; align-items: center; gap: 0.45rem; cursor: pointer; padding: 0.5rem 0.85rem; }
.stat#stat-bell:hover { background: #20242e; }
.bell-badge {
  background: var(--red); color: #fff; font-size: 0.66rem; font-weight: 700;
  border-radius: 20px; min-width: 18px; height: 18px; line-height: 18px;
  text-align: center; padding: 0 5px;
}
.bell-badge.hidden { display: none; }

.notif-wrap {
  position: fixed; top: 5.1rem; right: 1.2rem; z-index: 45;
  width: 340px; max-height: 72vh; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--border-2); border-radius: 1rem;
  box-shadow: 0 18px 44px rgba(0,0,0,0.55); overflow: hidden;
}
.notif-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.85rem 1rem; border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: 0.95rem;
}
.notif-list { overflow: auto; }
.notif-item {
  display: flex; gap: 0.7rem; padding: 0.75rem 1rem; cursor: pointer;
  border-bottom: 1px solid var(--border); align-items: flex-start;
}
.notif-item:hover { background: var(--panel-2); }
.notif-item.unread { background: #1c2130; }
.notif-item.unread:hover { background: #21273a; }
.notif-ico { font-size: 1.05rem; }
.notif-body { flex: 1; min-width: 0; }
.notif-title { font-size: 0.88rem; font-weight: 600; }
.notif-detail { color: var(--muted); font-size: 0.8rem; margin-top: 0.15rem; }
.notif-time { color: var(--muted); font-size: 0.72rem; margin-top: 0.3rem; }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); margin-top: 0.4rem; flex: none; }
.notif-demo { display: flex; gap: 0.5rem; padding: 0.75rem 1rem; border-top: 1px solid var(--border); }

/* ---------- Content blocks ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }
.card {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 1.1rem;
  padding: 1.2rem 1.3rem;
}
.card h3 { font-size: 1rem; margin-bottom: 0.4rem; }
.card .sub { color: var(--muted); font-size: 0.85rem; }
.card .row { display: flex; justify-content: space-between; align-items: center; gap: 0.8rem; }

.metric-row { display: flex; gap: 1rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
.metric {
  flex: 1; min-width: 160px; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 1rem; padding: 1rem 1.2rem;
}
.metric .num { font-size: 1.9rem; font-weight: 800; letter-spacing: -0.02em; }
.metric .num.green { color: var(--green); }
.metric .num.blue { color: var(--blue); }
.metric .num.purple { color: var(--purple); }
.metric .lbl { color: var(--muted); font-size: 0.82rem; }

.timeline { display: flex; flex-direction: column; gap: 0.55rem; }
.tl-item {
  display: flex; gap: 0.85rem; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 0.9rem; padding: 0.8rem 1rem;
}
.tl-icon { font-size: 1.1rem; opacity: 0.9; width: 28px; text-align: center; }
.tl-body { flex: 1; }
.tl-title { font-weight: 600; font-size: 0.93rem; }
.tl-detail { color: var(--muted); font-size: 0.82rem; margin-top: 0.15rem; }
.tl-time { color: var(--muted); font-size: 0.75rem; white-space: nowrap; }

.job-card { display: flex; flex-direction: column; gap: 0.6rem; }
.job-head { display: flex; justify-content: space-between; gap: 0.6rem; align-items: flex-start; }
.job-title { font-size: 1.02rem; font-weight: 700; }
.job-company { color: var(--muted); font-size: 0.88rem; }
.job-sal { font-weight: 700; color: var(--green); white-space: nowrap; }
.job-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.tag {
  background: #232832; border-radius: 20px; padding: 0.2rem 0.7rem;
  font-size: 0.75rem; color: var(--dim);
}
.job-meta { display: flex; gap: 1rem; color: var(--muted); font-size: 0.8rem; }
.job-reason { color: var(--purple); font-size: 0.8rem; }
.score-pill {
  background: #1a3a2e; color: var(--green); border-radius: 8px;
  font-size: 0.78rem; font-weight: 700; padding: 0.2rem 0.55rem;
}

.letters-list { display: flex; flex-direction: column; gap: 0.7rem; }
.letter-item {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 1rem; padding: 1rem 1.2rem;
}
.letter-item .job { font-weight: 600; }
.letter-item .status-chip { font-size: 0.72rem; border-radius: 20px; padding: 0.15rem 0.7rem; margin-left: 0.5rem; }
.status-chip.draft { background: #232832; color: var(--dim); }
.status-chip.sent { background: #1a3a2e; color: var(--green); }
.letter-preview {
  margin-top: 0.6rem; color: var(--dim); font-size: 0.86rem; white-space: pre-wrap;
  max-height: 180px; overflow: auto;
}

.editor {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 1.2rem;
  padding: 1.4rem; margin-top: 1rem;
}
.editor textarea { width: 100%; min-height: 220px; }

.fin-row { display: flex; justify-content: space-between; align-items: center; padding: 0.6rem 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.fin-row:last-child { border-bottom: none; }
.fin-amount.credit { color: var(--green); font-weight: 700; }
.fin-amount.debit { color: var(--red); font-weight: 700; }
.fin-note { color: var(--dim); }
.fin-time { color: var(--muted); font-size: 0.75rem; }

/* ---------- Plans ---------- */
.plan-card { position: relative; display: flex; flex-direction: column; gap: 0.5rem; }
.plan-card.popular { border-color: var(--purple); box-shadow: 0 0 0 1px var(--purple); }
.plan-badge {
  position: absolute; top: -0.7rem; right: 1rem;
  background: linear-gradient(90deg, var(--purple), var(--blue));
  color: #fff; font-size: 0.72rem; font-weight: 700;
  padding: 0.25rem 0.8rem; border-radius: 20px;
}
.plan-name { font-weight: 700; font-size: 1.1rem; }
.plan-dur { color: var(--muted); font-size: 0.85rem; }
.plan-price { font-weight: 800; font-size: 1.7rem; letter-spacing: -0.02em; margin-top: 0.4rem; }
.plan-price-sub { color: var(--muted); font-size: 0.82rem; }
.plan-feats { list-style: none; display: flex; flex-direction: column; gap: 0.4rem; margin: 0.4rem 0 0.8rem; color: var(--dim); font-size: 0.88rem; }
.plan-feats li::before { content: '✓ '; color: var(--green); font-weight: 700; }

.check { display: flex; gap: 0.6rem; align-items: center; cursor: pointer; padding: 0.5rem 0; }
.check input { accent-color: var(--purple); width: 16px; height: 16px; }

.section-title { font-size: 1.05rem; font-weight: 700; margin: 1.2rem 0 0.6rem; }
.section-title:first-child { margin-top: 0; }

.toast {
  position: fixed; bottom: 1.2rem; right: 1.2rem; z-index: 50;
  background: #232832; border: 1px solid var(--border); color: var(--text);
  border-radius: 12px; padding: 0.8rem 1.2rem; font-size: 0.9rem; max-width: 340px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.5);
}
.toast.error { border-color: var(--red); color: #ffb4b4; }
.toast.ok { border-color: var(--green); }

.empty { color: var(--muted); text-align: center; padding: 2.5rem 1rem; font-size: 0.95rem; }

.modal-veil {
  position: fixed; inset: 0; background: rgba(0,0,0,0.65); z-index: 40;
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.modal {
  background: var(--panel); border: 1px solid var(--border); border-radius: 1.2rem;
  padding: 1.4rem; width: 100%; max-width: 620px; max-height: 86vh; overflow: auto;
}

@media (max-width: 820px) {
  .sidebar { width: 72px; }
  .sidebar .brand-text, .nav-btn span { display: none; }
  .sidebar .brand .brand-mark { margin: 0 auto; }
  .main { padding: 1rem; }
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; justify-content: space-between; align-items: center; padding: 0.6rem 0.9rem; }
  .nav { flex-direction: row; overflow-x: auto; }
  .nav-btn { padding: 0.5rem 0.7rem; white-space: nowrap; }
  .side-foot { margin: 0; }
}