:root {
  --bg: #0b0d14;
  --bg-elev: #12151f;
  --bg-elev-2: #171b28;
  --border: #232838;
  --text: #eef0f6;
  --text-dim: #9aa1b4;
  --text-faint: #666e84;
  --accent: #7c6cf6;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(0,0,0,0.35);
  font-size: 15px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

/* ---------- login ---------- */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 20% 0%, #1b1030 0%, transparent 60%),
              radial-gradient(1200px 600px at 100% 100%, #071b2b 0%, transparent 55%),
              var(--bg);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
  box-shadow: var(--shadow);
}
.login-logo { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.login-logo span { color: var(--accent); }
.login-sub { color: var(--text-dim); margin: 0 0 22px; font-size: 13.5px; }
.login-card label { display: block; font-size: 12.5px; color: var(--text-dim); margin: 14px 0 6px; }
.login-card input {
  width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg-elev-2); color: var(--text); font-size: 14px;
}
.login-card input:focus { outline: none; border-color: var(--accent); }
.login-card button {
  width: 100%; margin-top: 22px; padding: 12px; border: none; border-radius: 10px;
  background: linear-gradient(135deg, #7c6cf6, #5b4fd6); color: white; font-weight: 600; font-size: 14.5px;
}
.login-error { margin-top: 12px; color: #ff6b6b; font-size: 13px; }

/* ---------- layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 250px; flex-shrink: 0;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand { font-weight: 700; font-size: 17px; padding: 20px 18px 14px; }
.brand span { color: var(--accent); }
#nav { flex: 1; overflow-y: auto; padding: 6px 10px; display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px 10px 10px;
  border-radius: 10px;
  border-left: 4px solid var(--nav-color, transparent);
  color: var(--text-dim); text-decoration: none; font-size: 14px; font-weight: 500;
  background: transparent; border-top: none; border-right: none; border-bottom: none;
  width: 100%; text-align: left;
}
.nav-item .ic { font-size: 16px; width: 20px; text-align: center; }
.nav-item:hover { background: var(--bg-elev-2); color: var(--text); }
.nav-item.active { background: var(--bg-elev-2); color: var(--text); border-left-width: 4px; }
.nav-section-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); padding: 14px 12px 4px; }
.sidebar-footer { padding: 14px; border-top: 1px solid var(--border); }
.ghost-btn {
  width: 100%; padding: 9px; border-radius: 9px; border: 1px solid var(--border);
  background: transparent; color: var(--text-dim); font-size: 13px;
}
.ghost-btn:hover { color: var(--text); border-color: var(--text-faint); }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 26px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: rgba(11,13,20,0.85); backdrop-filter: blur(8px); z-index: 5;
}
.menu-toggle { display: none; background: none; border: none; color: var(--text); font-size: 20px; }
.topbar h1 { font-size: 19px; margin: 0; flex: 1; }
.clock { color: var(--text-faint); font-size: 13px; }
.view { padding: 24px 26px 60px; max-width: 1200px; width: 100%; }

/* ---------- widgets ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin-bottom: 22px; }
.card {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 18px; box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 4px; font-size: 13px; color: var(--text-dim); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.card .big { font-size: 30px; font-weight: 700; margin: 6px 0 2px; }
.card .sub { color: var(--text-faint); font-size: 12.5px; }
.section-block { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 18px; }
.section-block h2 { font-size: 15.5px; margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }
.section-title-bar { width: 4px; height: 16px; border-radius: 2px; display: inline-block; }

.stage-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; font-size: 13.5px; }
.stage-name { width: 200px; flex-shrink: 0; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage-bar-track { flex: 1; height: 9px; background: var(--bg-elev-2); border-radius: 5px; overflow: hidden; }
.stage-bar-fill { height: 100%; border-radius: 5px; }
.stage-count { width: 34px; text-align: right; font-weight: 600; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.pill.ok { background: rgba(46, 204, 113, 0.15); color: #2ecc71; }
.pill.warn { background: rgba(241, 196, 15, 0.15); color: #f1c40f; }
.pill.off { background: rgba(255,255,255,0.06); color: var(--text-faint); }

.btn { padding: 9px 16px; border-radius: 9px; border: none; font-size: 13.5px; font-weight: 600; background: var(--accent); color: white; }
.btn.secondary { background: var(--bg-elev-2); color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: rgba(255,90,90,0.12); color: #ff5a5a; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 14px; }
.form-grid input, .form-grid select {
  width: 100%; padding: 9px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg-elev-2); color: var(--text); font-size: 13.5px;
}

.list { display: flex; flex-direction: column; gap: 8px; }
.list-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--bg-elev-2); border-radius: 10px; border: 1px solid var(--border); font-size: 13.5px;
}
.list-item.done { opacity: .5; text-decoration: line-through; }
.list-item .grow { flex: 1; }
.list-item small { color: var(--text-faint); font-weight: 400; text-decoration: none; }

.goal-card { padding: 16px 18px; }
.goal-card .title { font-weight: 600; margin-bottom: 6px; font-size: 14px; }
.goal-card .track { height: 10px; border-radius: 5px; background: var(--bg-elev-2); overflow: hidden; margin: 8px 0 6px; }
.goal-card .fill { height: 100%; }
.goal-card .meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-faint); }

.funnel { display: flex; flex-direction: column; gap: 6px; }
.funnel-step { padding: 12px 16px; border-radius: 10px; color: white; font-weight: 600; font-size: 13.5px; display: flex; justify-content: space-between; align-items: center; }

.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 36px 20px; text-align: center;
  color: var(--text-dim); font-size: 13.5px; margin-bottom: 18px; transition: all .15s;
}
.dropzone.drag { border-color: var(--accent); background: rgba(124,108,246,0.06); color: var(--text); }
.upload-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.upload-item { background: var(--bg-elev-2); border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
.upload-item img { width: 100%; height: 100px; object-fit: cover; display: block; background: #000; }
.upload-item .file-ic { height: 100px; display: flex; align-items: center; justify-content: center; font-size: 30px; }
.upload-item .meta { padding: 8px 10px; font-size: 11.5px; color: var(--text-faint); }
.upload-item .meta .name { color: var(--text); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; margin-bottom: 2px; }

.social-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.social-link {
  display: flex; align-items: center; gap: 10px; padding: 16px 16px;
  background: var(--bg-elev-2); border: 1px solid var(--border); border-radius: 12px;
  text-decoration: none; color: var(--text); font-weight: 600; font-size: 14px;
  border-left: 4px solid var(--sc, var(--accent)); transition: transform .1s;
}
.social-link:hover { transform: translateY(-2px); border-color: var(--sc, var(--accent)); }
.social-ic { font-size: 20px; }

.empty-state { color: var(--text-faint); font-size: 13.5px; padding: 20px 0; text-align: center; }
.muted { color: var(--text-faint); font-size: 12.5px; }
.code-box { background: var(--bg-elev-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-family: monospace; font-size: 12px; color: var(--text-dim); word-break: break-all; }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--bg-elev-2); border: 1px solid var(--border); padding: 11px 18px; border-radius: 10px;
  font-size: 13px; box-shadow: var(--shadow); z-index: 50;
}

@media (max-width: 860px) {
  .menu-toggle { display: block; }
  .sidebar { position: fixed; left: -260px; top: 0; z-index: 30; transition: left .2s; box-shadow: var(--shadow); }
  .sidebar.open { left: 0; }
  .view { padding: 18px 16px 60px; }
  .topbar { padding: 14px 16px; }
  .stage-name { width: 120px; }
}
